//############################################################################################################# // Incoming messages private void jabberClient_OnMessage(object sender, jabber.protocol.client.Message msg) { // Handle messages on the same thread as UI. if (this.InvokeRequired) { this.Invoke(new MessageHandler(jabberClient_OnMessage), sender, msg); } bool newWindow = false; string bareJID = msg.From.Bare; string nickName = null; if (chatNicknames.ContainsKey(bareJID)) { nickName = chatNicknames[bareJID]; } // Do we already have a chat window for this message? FrmChat chatWindow = InitializeChatWindow(msg.From, nickName); if (msg.Body != null) { if (!chatWindow.Visible) { // Show chat window only when receiving first full-line message. newWindow = true; chatWindow.Show(); chatWindow.BringToFront(); chatWindow.WindowState = FormWindowState.Normal; chatWindow.Flash(); } else if (chatWindow.WindowState == FormWindowState.Minimized) { // Flash chat window in taskbar, if minimized chatWindow.Flash(); } chatWindow.ReceiveFlag = true; } // Show window and handle chat message if (chatWindow.Visible) { chatWindow.HandleMessage(msg); } // Special behaviour if we're invited to a group chat if (!chatInRoster.ContainsKey(bareJID)) { Console.WriteLine("NOTICE: Message from unrecogized bareJID: " + bareJID); if (newWindow && bareJID.EndsWith("groupchat.google.com")) { MessageBox.Show("You have been invited to a group chat. However, group chat is not yet supported in this specific client. (XEP-0045 not implemented)"); } } }
/// <summary>Doubleclicking on a buddy in the list, opens a new chat window (or activates existing window)</summary> void rosterTree_DoubleClick(object sender, EventArgs e) { muzzle.RosterTree.ItemNode selectedNode = rosterTree.SelectedNode as muzzle.RosterTree.ItemNode; if (selectedNode != null) { string bareJID = selectedNode.JID.Bare; string nickName = !String.IsNullOrEmpty(selectedNode.Nickname) ? selectedNode.Nickname : bareJID; FrmChat chatWindow = InitializeChatWindow(selectedNode.JID, nickName); chatWindow.Show(); chatWindow.BringToFront(); } }