public RequestFriendForm(XMPP.XmppClientConnection XmppCon, XMPP.Jid jid) { // TODO: Complete member initialization this.XmppCon = XmppCon; this.jid = jid; InitializeComponent(); this.lab_friend.Text = jid.ToString(); }
public Main() { InitializeComponent(); CompressionRegistry.AddCompression(Assembly.LoadFile(Path.Combine(Application.StartupPath, "ubiety.compression.sharpziplib.dll"))); Errors.OnError += Errors_OnError; _xmpp = new XMPP(); slVersion.Text = Resources.Version_Label + XMPP.Version; }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build (); xmpp = new XMPP(); error.OnError += new EventHandler<ErrorEventArgs>(OnError); //ubiety.LocalCertificate = X509Certificate.CreateFromCertFile("cert.pem"); //ExceptionManager.UnhandledException += new UnhandledExceptionHandler(OnExceptionEvent); statusbar1.Push(1, "Ubiety Version: " + xmpp.Version); }
public void RefreshFriend(string Bare, XMPP.protocol.client.PresenceType presenceType, ShowType Show) { Friend friend = Rosters[Bare]; //dnd 忙碌 busy 4 away 离开 away 2 //int state = 1;//不知道是什么 switch (Show) { case ShowType.NONE: bool isonline = friend.IsOnline; friend.State = 0; friend.IsOnline = isonline; break; case ShowType.dnd: //state = 4; friend.State = 4; break; case ShowType.away: //state = 2; friend.State = 2; break; } //friend.State = state; Group group_item = Groups[friend.GroupName]; int group_index = Controls.IndexOfKey(StringFinal.GroupName + friend.GroupID); GroupControl gruop_user = Controls[group_index] as GroupControl; int panel_index = Controls.IndexOfKey(StringFinal.UserPanelName + friend.GroupID); Panel panel_user = Controls[panel_index] as Panel; if (presenceType == XMPP.protocol.client.PresenceType.unavailable) { if (friend.IsOnline) { if (gruop_user.GroupInfo.OnlineCount > 0) { group_item.OnlineCount -= 1; gruop_user.GroupInfo = group_item; } } friend.IsOnline = false; if(Path.InputAlertSwitch) SoundPlayEx.MsgPlay(Path.InputAlertPath); } else { if (friend.IsOnline==false) { group_item.OnlineCount += 1; gruop_user.GroupInfo = group_item; } friend.IsOnline = true; if(Path.GlobalSwitch) SoundPlayEx.MsgPlay(Path.GlobalPath); } int friend_index = panel_user.Controls.IndexOfKey(StringFinal.FriendName + friend.Uin); FriendControl friend_user = panel_user.Controls[friend_index] as FriendControl; friend_user.FriendInfo = friend; friend_user.UpdateImage();//更新名片 UpdateLayout(panel_user); System.GC.Collect(); }
public static void CreateContact(Account account, XMPP.JID jid, string alias = "") { try { if (account != null) { var contact = account.Roster[jid.Bare]; if (contact == null) contact = account.Roster.CreateContact(account.jid, jid.Bare); if (contact == null) return; var iq = new Tags.jabber.client.iq(); iq.from = account.CurrentJID; iq.type = Tags.jabber.client.iq.typeEnum.set; var query = new Tags.jabber.iq.roster.query(); var item = new Tags.jabber.iq.roster.item(); item.jid = jid.Bare; if (!string.IsNullOrEmpty(alias)) item.name = alias; query.Add(item); iq.Add(query); Frontend.Backend.SendTag(account.jid, iq); Subscribe(contact); } } catch (Exception uiEx) { Frontend.UIError(uiEx); } }
public static void EditContact(Account account, XMPP.JID jid, string alias = "") { try { if (account != null) { var iq = new Tags.jabber.client.iq(); iq.from = account.CurrentJID; iq.type = Tags.jabber.client.iq.typeEnum.set; var query = new Tags.jabber.iq.roster.query(); var item = new Tags.jabber.iq.roster.item(); item.jid = jid.Bare; item.name = alias; query.Add(item); iq.Add(query); Frontend.Backend.SendTag(account.jid, iq); } } catch (Exception uiEx) { Frontend.UIError(uiEx); } }
/// <summary> /// 对方同意视频,并初使化视频后,本地也进行视频初使化 /// </summary> /// <param name="msg"></param> void ReturnAcceptVideoInitMethod(XMPP.protocol.client.Message msg) { UserInfo user1; UserInfo user2; CSS.IM.XMPP.protocol.client.Message res_msg; RemotVideoUDPPort = msg.GetTagInt("UDPPort"); RemotVideoUDPIP = IPAddress.Parse(msg.GetTag("UDPIP")); user1 = new UserInfo(); user1.LocalIP = RemotVideoUDPIP; user1.LocalPort = RemotVideoUDPPort; avForm.SetRemoteAddress(user1, RemotVideoUDPPort); user2 = new UserInfo(); user2.LocalIP = Program.LocalHostIP; user2.LocalPort = ListenBasicUDPPort; avForm.SetLocalAddress(user2); avForm.iniAV(CSS.IM.Library.AV.VideoSizeModel.W320_H240); res_msg = new CSS.IM.XMPP.protocol.client.Message(); res_msg.Type = MessageType.chat; res_msg.To = TO_Jid; res_msg.SetTag("m_type", 3); XmppConn.Send(res_msg);//告诉对我准备好了 if (avForm.callSoundPlayer != null) avForm.callSoundPlayer.Stop(); }
/// <summary> /// 拒绝视频请求 /// </summary> /// <param name="msg"></param> private void Red5RefuseMethod(XMPP.protocol.client.Message msg) { if (InvokeRequired) { this.Invoke(Red5RefuseEvent, new object[] { msg }); } if (red5MsgSend != null || red5MsgSend.IsDisposed) { red5MsgSend.Close(); red5MsgSend.Dispose(); red5MsgSend = null; } this.AppendSystemRtf("对方" + msg.From.User + "拒绝了你的视频请求"); }
/// <summary> /// red5视频请求 /// </summary> /// <param name="msg"></param> private void Red5AccpetMethod(XMPP.protocol.client.Message msg) { if (InvokeRequired) { this.Invoke(Red5AccpetEvent, new object[]{msg}); } if (red5MsgReceive != null) if (!red5MsgReceive.IsDisposed) return; DialogResult result=MsgBox.Show(this, "CSS&IM", "好友" + NickName + "向您发送视频请求,是否接受!", MessageBoxButtons.YesNo); if (result==DialogResult.Yes) { string serUrl = @"http://"+Program.ServerIP+":7070/redfire/video/redfire_2way.html?me={0}&you={1}&key={2}"; red5MsgReceive = new Red5Msg(); red5MsgReceive.FriendName = "正在与[" + msg.GetTag("me").ToString() + "]视频通话中"; red5MsgReceive.FormClosing += new FormClosingEventHandler(red5MsgReceive_FormClosing); red5MsgReceive.Accept(string.Format(serUrl, msg.GetTag("you").ToString(), msg.GetTag("me").ToString(), msg.GetTag("key").ToString())); red5MsgReceive.Show(); this.AppendSystemRtf("开始与" + msg.GetTag("me").ToString() + "进行视频通话"); } else { CSS.IM.XMPP.protocol.client.Message emsg = new CSS.IM.XMPP.protocol.client.Message(); emsg.Type = MessageType.chat; emsg.To = TO_Jid; emsg.SetTag("m_type", 12); emsg.SetTag("me", msg.GetTag("me").ToString()); emsg.SetTag("you", msg.GetTag("you").ToString()); emsg.SetTag("key", msg.GetTag("key").ToString()); XmppConn.Send(emsg); this.AppendSystemRtf("拒绝了" + msg.GetTag("me").ToString() + "视频通话"); } }
/// <summary> /// 接收离线文件 /// </summary> /// <param name="msg"></param> private void GetFtpFileAMethod(XMPP.protocol.client.Message msg) { FTPClient ftpClient = new FTPClient(Util.ServerAddress, Util.ftpPath, Util.ftpUser, Util.ftpPswd, Util.ftpPort); ftpClient.FtpPath = msg.GetTag("Path"); ftpClient.GetFileErrorEvent += new FTPClient.GetFileErrorDelegate(ftpClient_GetFileErrorEvent); ftpClient.GetFileProgressEvent += new FTPClient.GetFileProgressDelegate(ftpClient_GetFileProgressEvent); ftpClient.GetFileSucceedEvent += new FTPClient.GetFileSucceedDelegate(ftpClient_GetFileSucceedEvent); ftpClient.ChDir("/" + ftpClient.FtpPath + "/"); long fileSize = long.Parse(msg.GetTag("Length")); FileTransfersItem item = fileTansfersContainer.AddItem( msg.GetTag("MD5"), "接收文件", msg.GetTag("FileName"), Properties.Resources.ReceiveIco, fileSize, FileTransfersItemStyle.FtpGet); item.BaseColor = _baseColor; item.BorderColor = _borderColor; item.ProgressBarBarColor = _progressBarBarColor; item.ProgressBarBorderColor = _progressBarBorderColor; item.ProgressBarTextColor = _progressBarTextColor; RequestSendFileEventArgs requestSendFileEventArgs = new RequestSendFileEventArgs(); requestSendFileEventArgs.ftpClient = ftpClient; ftpClient.fileTransfersItem = item; item.Tag = requestSendFileEventArgs; item.SaveButtonClick += new EventHandler(ItemSaveButtonClick); item.SaveToButtonClick += new EventHandler(ItemSaveToButtonClick); item.RefuseButtonClick += new EventHandler(ItemRefuseButtonClick); Util.ReceiveFileManagerList.Add(msg.GetTag("MD5"), requestSendFileEventArgs); this.Invoke(new RequestSendFilePanel(RequestSendFilePanelMethod)); this.AppendSystemRtf(string.Format("请求接收离线文件 {0}。", msg.GetTag("FileName"))); }
/// <summary> /// 我发送视频后,对方同意后进行初使化视频 /// </summary> /// <param name="msg"></param> void AcceptVideoOpenMethod(XMPP.protocol.client.Message msg) { //if (ravForm.callSoundPlayer != null) // ravForm.callSoundPlayer.Stop(); ravForm.iniAV(CSS.IM.Library.AV.VideoSizeModel.W320_H240); }
/// <summary> /// 我发送视频后,对方同意后进行初使化视频 /// </summary> /// <param name="msg"></param> void AcceptOpenMethod(XMPP.protocol.client.Message msg) { ravForm.iniAV(VideoSizeModel.W320_H240); }
/// <summary> /// 对方同意视频,并初使化视频后,本地也进行视频初使化 /// </summary> /// <param name="msg"></param> void ReturnAcceptMethod(XMPP.protocol.client.Message msg) { UserInfo user1; UserInfo user2; CSS.IM.XMPP.protocol.client.Message res_msg; VideoRemotUDPPort = msg.GetTagInt("UDPPort"); VideoRemotUDPIP = IPAddress.Parse(msg.GetTag("UDPIP")); user1 = new UserInfo(); user1.LocalIP = VideoRemotUDPIP; user1.LocalPort = VideoRemotUDPPort; avForm.SetRemoteAddress(user1, VideoRemotUDPPort); user2 = new UserInfo(); user2.LocalIP = Program.LocalHostIP; user2.LocalPort = int.Parse(LocalVideoUDPPort); avForm.SetLocalAddress(user2); avForm.iniAV(VideoSizeModel.W320_H240); res_msg = new CSS.IM.XMPP.protocol.client.Message(); res_msg.Type = MessageType.chat; res_msg.To = to_Jid; res_msg.SetTag("m_type", 3); res_msg.Body = "falg"; _connection.Send(res_msg);//告诉对我准备好了 }
private void chatgroup_ChatGroupOpenEvent(XMPP.Jid jid) { if (ChatGroupOpenEvent != null) ChatGroupOpenEvent(jid); }
void XmppCon_OnRegisterInformation(object sender, XMPP.protocol.iq.register.RegisterEventArgs args) { //MessageBox.Show("a"); //if (InvokeRequired) //{ // Invoke(new CSS.IM.XMPP.protocol.iq.register.RegisterEventHandler(_connection_OnRegisterInformation), new object[] { sender, args }); //} //MessageBox.Show( "注册失败," + args.Register.ToString()); //XmppCon.Close(); //this.Close(); }
private void XmppCon_OnRegisterError(object sender, XMPP.Xml.Dom.Element e) { try { this.Invoke(ShowMessageBoxEvent, new object[] { "注册失败,请更换用户名后,请重试!", true }); //MsgBox.Show(this, "系统", "注册失败,请更换用户名后,请重试!"); } catch (Exception) { } }