Esempio n. 1
0
        void on_editAccountButton_clicked()
        {
            var selected = accountsList.SelectionModel().SelectedIndexes();

            if (selected.Count > 0)
            {
                var data = accountsList.Model().Data(selected[0], (int)Qt.ItemDataRole.DisplayRole);
                var jid  = new jabber.JID((string)data);

                var accountService = ServiceManager.Get <AccountService>();

                Account account = accountService.GetAccount(jid);
                if (account != null)
                {
                    if (!account.IsReadOnly)
                    {
                        var dialog = new EditAccountDialog(account.Info, this);
                        dialog.Show();
                        dialog.Exec();

                        accountsList.Update();
                    }
                    else
                    {
                        QMessageBox.Critical(this, "Error", "Cannot modify account while connected.");
                    }
                }
            }
        }
Esempio n. 2
0
        internal static void PresManager_OnPrimarySessionChange(object sender, jabber.JID bare)
        {
            if (AllPlayers.ContainsKey(bare.User))
            {
                ChatPlayerItem Player = AllPlayers[bare.User];
                Player.IsOnline = false;
                UpdatePlayers   = true;
                jabber.protocol.client.Presence[] s = PresManager.GetAll(bare);
                if (s.Length == 0)
                {
                    return;
                }
                string Presence = s[0].Status;
                if (Presence == null)
                {
                    return;
                }
                Player          = ParsePresence(Presence);
                Player.IsOnline = true;

                if (String.IsNullOrWhiteSpace(Player.Status))
                {
                    Player.Status = "Online";
                }
            }
        }
Esempio n. 3
0
 private void btnRemove_Click(object sender, System.EventArgs e)
 {
     this.Cursor = Cursors.WaitCursor;
     try
     {
         jabber.JID jid = new jabber.JID(txtEntry.Text);
         int        i   = 0;
         foreach (object o in lstJID.Items)
         {
             if (jid.Equals(o))
             {
                 lstJID.Items.RemoveAt(i);
                 txtEntry.Clear();
                 error.SetError(txtEntry, null);
                 break;
             }
             i++;
         }
     }
     catch (Exception ex)
     {
         error.SetError(txtEntry, "Invalid JID: " + ex.ToString());
     }
     this.Cursor = Cursors.Default;
 }
Esempio n. 4
0
        /// <summary>Starts a new real-time message for a specific user</summary>
        /// <param name="user">User who started typing</param>
        /// <returns>A new, rael time decoder</returns>
        public RealTimeMessage NewRealTimeMessage(XmlDocument doc, jabber.JID jid, Color colorValue)
        {
            RealTimeMessage rtt = new RealTimeMessage(jid, colorValue);

            chatRealTime[(string)jid] = rtt;
            rtt.Decoder = new RealTimeText.Decoder(doc);
            return(rtt);
        }
        private async void AddFriendButton_Click(object sender, RoutedEventArgs e)
        {
            var JID = await Client.PVPNet.GetSummonerByName(FriendAddBox.Text);

            jabber.JID jid    = new jabber.JID("sum" + JID.SummonerId, Client.ChatClient.Server, "");
            string[]   groups = new List <String>(new String[] { "Online" }).ToArray();
            Client.ChatClient.Subscribe(jid, "", groups);
        }
Esempio n. 6
0
        private void ConnectButton_Click(object sender, EventArgs e)
        {
            // Make sure a JID and password were entered
            if (txtUserJid.TextLength == 0 || txtUserJid.Text == "*****@*****.**")
            {
                MessageBox.Show("You must enter an IM address.");
                return;
            }
            else if (txtPassword.TextLength == 0)
            {
                MessageBox.Show("You must enter your password.");
                return;
            }

            // Make sure a valid JID was entered
            jabber.JID UserJid;

            try {
                UserJid = new jabber.JID(this.txtUserJid.Text);
            } catch (Exception) {
                MessageBox.Show("Invalid IM address entered.  Please try again.");
                return;
            }

            this.AcceptButton         = null;
            ConnectButton.Enabled     = false;
            ConnectingLabel.Visible   = true;
            ConnectingSpinner.Visible = true;

            // Save settings
            Properties.Settings.Default.UserJid = txtUserJid.Text;
            Properties.Settings.Default.Save();

            // Give the UI changes a chance to update
            Application.DoEvents();

            //Set all the login parameters
            XmppGlobal.Connection.Username   = UserJid.User;
            XmppGlobal.Connection.Server     = UserJid.Server;
            XmppGlobal.Connection.Password   = this.txtPassword.Text;
            XmppGlobal.Connection.Port       = 5222;
            XmppGlobal.Connection.Resource   = "Test";
            XmppGlobal.Connection.Priority   = 1;
            XmppGlobal.Connection.Encryption = (EncryptionMode)0;

            // We don't treat anyone special, except Google  :/
            if (XmppGlobal.Connection.Server == "gmail.com")
            {
                XmppGlobal.Connection.NetworkHost = "talk.google.com";
            }
            else
            {
                XmppGlobal.Connection.NetworkHost = string.Empty;
            }

            XmppGlobal.Connection.Connect();
        }
Esempio n. 7
0
        /// <summary>Append a line of chat to conversation.  Also clears the real time text</summary>
        public void AppendConversation(jabber.JID from, string str, Color color)
        {
            m_chat.RemoveRealTimeMessage(from);
            ChatMessage line = new ChatMessage(from, str, color);

            m_chat.History.Add(line);
            ResetConversationMessageHistoryCache();
            UpdateConversationWindow();
        }
Esempio n. 8
0
        /// <summary>Clears the real time message of specified JID or full JID</summary>
        /// <param name="jid">JID of user</param>
        public void RemoveRealTimeMessage(jabber.JID jid)
        {
            RealTimeMessage rttMessage = (RealTimeMessage)chatRealTime[(string)jid];

            if (rttMessage != null)
            {
                rttMessage.Decoder.Dispose();
                chatRealTime.Remove((string)jid);
            }
        }
Esempio n. 9
0
        public void LoadVCard(jabber.JID jid)
        {
            Text          = string.Format("Information for {0}", jid.Bare);
            JidLabel.Text = jid.Bare;

            jabber.protocol.iq.VCardIQ iq = XmppGlobal.Queries.CreateVCardQuery();
            iq.To   = new jabber.JID(jid.Bare);
            iq.Type = jabber.protocol.client.IQType.get;

            XmppGlobal.Queries.SendQuery(iq, new QueryCallback(GotVCard), null);
        }
Esempio n. 10
0
        public void LoadEntityTime(jabber.JID jid)
        {
            TimeIQ iq = XmppGlobal.Queries.CreateTimeQuery();

            iq.To = jid;

            XmppGlobal.Queries.SendQuery(iq, new QueryCallback(GotTimeQuery), null);

            JidLabel.Text   = jid.ToString();
            Spinner.Visible = true;
        }
Esempio n. 11
0
        public MessageWindow(jabber.JID jid)
        {
            InitializeComponent();

            foreign_jid      = jid;
            thread_id        = Guid.NewGuid().ToString().Replace("-", "");
            UserAvatar.Image = XmppImages.DefaultAvatar;

            Activated                += new EventHandler(MessageWindow_Activated);
            FormClosing              += new FormClosingEventHandler(MessageWindow_FormClosing);
            Load                     += new EventHandler(MessageWindow_Load);
            OutgoingTextBox.KeyDown  += new KeyEventHandler(OutgoingTextBox_KeyDown);
            RichTextBox1.LinkClicked += new LinkClickedEventHandler(RichTextBox1_LinkClicked);
            SendButton.Click         += new EventHandler(SendButton_Click);
        }
Esempio n. 12
0
        public MessageWindow(jabber.JID jid)
        {
            InitializeComponent ();

            foreign_jid = jid;
            thread_id = Guid.NewGuid ().ToString ().Replace ("-", "");
            UserAvatar.Image = XmppImages.DefaultAvatar;

            Activated += new EventHandler (MessageWindow_Activated);
            FormClosing += new FormClosingEventHandler (MessageWindow_FormClosing);
            Load += new EventHandler (MessageWindow_Load);
            OutgoingTextBox.KeyDown += new KeyEventHandler (OutgoingTextBox_KeyDown);
            RichTextBox1.LinkClicked += new LinkClickedEventHandler (RichTextBox1_LinkClicked);
            SendButton.Click += new EventHandler (SendButton_Click);
        }
        private bool IsFormValid()
        {
            if (txtJid.TextLength == 0) {
                MessageBox.Show ("IM address must be filled in.");
                return false;
            }

            try {
                jabber.JID j = new jabber.JID (txtJid.Text);
            } catch (jabber.JIDFormatException) {
                MessageBox.Show ("IM address is not valid.");
                return false;
            }

            return true;
        }
Esempio n. 14
0
        public void GotMessage(jabber.protocol.client.Message msg)
        {
            foreign_jid  = msg.From;
            message_type = msg.Type;
            thread_id    = msg.Thread;

            if (msg.Body.Trim().Length > 0)
            {
                RichTextBox1.SelectionColor = Color.Red;
                RichTextBox1.AppendText(string.Format("({0}) {1}: ", DateTime.Now.ToString("hh:mm:ss"), Text));
                RichTextBox1.SelectionColor = Color.Black;
                RichTextBox1.AppendText(string.Format("{0}\n", msg.Body));

                XmppSounds.PlaySound(DefaultSounds.MessageIn);
            }
        }
Esempio n. 15
0
 private void btnAdd_Click(object sender, System.EventArgs e)
 {
     this.Cursor = Cursors.WaitCursor;
     try
     {
         jabber.JID jid = new jabber.JID(txtEntry.Text);
         lstJID.Items.Add(jid);
         txtEntry.Clear();
         error.SetError(txtEntry, null);
     }
     catch
     {
         error.SetError(txtEntry, "Invalid JID");
     }
     this.Cursor = Cursors.Default;
 }
        private bool IsFormValid()
        {
            if (txtJid.TextLength == 0)
            {
                MessageBox.Show("IM address must be filled in.");
                return(false);
            }

            try {
                jabber.JID j = new jabber.JID(txtJid.Text);
            } catch (jabber.JIDFormatException) {
                MessageBox.Show("IM address is not valid.");
                return(false);
            }

            return(true);
        }
Esempio n. 17
0
        // Manage the back button entry list
        private void AddBackJid(jabber.JID jid, string node)
        {
            if (back_history.Count > 0)
            {
                ItemNode inode = back_history.Peek();

                if (inode.Jid != jid || inode.Node != node)
                {
                    back_history.Push(new ItemNode(jid, node));
                    BackButton.Enabled = true;
                }
            }
            else
            {
                back_history.Push(new ItemNode(jid, node));
                BackButton.Enabled = true;
            }
        }
Esempio n. 18
0
            private void jid_Validating(object sender, CancelEventArgs e)
            {
                TextBox jtxt = (TextBox)sender;

                if (jtxt.Text == "")
                {
                    return;
                }

                try
                {
                    jabber.JID j = new jabber.JID(jtxt.Text);
                }
                catch
                {
                    e.Cancel = true;
                    m_form.error.SetError(jtxt, "Invalid JID");
                }
            }
Esempio n. 19
0
        void on_removeAccountButton_clicked()
        {
            var selected = accountsList.SelectionModel().SelectedIndexes();

            if (selected.Count > 0)
            {
                var data = accountsList.Model().Data(selected[0], (int)Qt.ItemDataRole.DisplayRole);
                var jid  = new jabber.JID((string)data);

                var     accountService = ServiceManager.Get <AccountService>();
                Account account        = accountService.GetAccount(jid);
                if (account != null)
                {
                    if (QMessageBox.Question(this, "Remove Account",
                                             "Are you sure you want to remove this account?",
                                             (uint)QMessageBox.StandardButton.Yes | (uint)QMessageBox.StandardButton.No,
                                             QMessageBox.StandardButton.No) == QMessageBox.StandardButton.Yes)
                    {
                        accountService.RemoveAccount(account);
                    }
                }
            }
        }
Esempio n. 20
0
        // Submit a new query
        private void SubmitQuery(jabber.JID jid, string node, bool refresh)
        {
            IdentityNameLabel.Text         = string.Empty;
            IdentityAddressLabel.Text      = string.Empty;
            IdentityCategoryTypeLabel.Text = string.Empty;

            Label4.Visible       = false;
            ActionButton.Visible = false;
            StopButton.Enabled   = true;
            Spinner.Visible      = true;
            ErrorPicture.Visible = false;
            got_one_response     = false;
            was_stopped          = false;

            ServiceListView.Items.Clear();

            AddressTextBox.SelectAll();

            current_jid  = jid;
            current_node = node;

            XmppGlobal.Disco.DiscoInfoQuery(jid, node, refresh, new QueryCallback(GotInfoQuery), null);
            XmppGlobal.Disco.DiscoItemsQuery(jid, node, refresh, new QueryCallback(GotItemsQuery), null);
        }
Esempio n. 21
0
        public void DiscoItemsQuery(jabber.JID to, string node, bool refresh, QueryCallback callback, object state)
        {
            if (!refresh)
            {
                IQ cache_version = XmppGlobal.InternalQueryCache.DiscoItems[to.ToString() + "!!!!!" + node];

                if (cache_version != null)
                {
                    callback.Invoke(this, cache_version, state);
                    return;
                }
            }

            DiscoItemsIQ iq = XmppGlobal.Queries.CreateDiscoItemsQuery();

            iq.To = to;

            if (!string.IsNullOrEmpty(node))
            {
                iq.Node = node;
            }

            XmppGlobal.Queries.SendQuery(iq, callback, state);
        }
Esempio n. 22
0
 public ItemNode(jabber.JID jid, string node)
 {
     this.jid  = jid;
     this.node = node;
 }
Esempio n. 23
0
 public RosterResource(jabber.JID jid)
 {
     this.jid = jid;
 }
Esempio n. 24
0
 private void btnAdd_Click(object sender, System.EventArgs e)
 {
     this.Cursor = Cursors.WaitCursor;
     try
     {
         jabber.JID jid = new jabber.JID(txtEntry.Text);
         lstJID.Items.Add(jid);
         txtEntry.Clear();
         error.SetError(txtEntry, null);
     }
     catch
     {
         error.SetError(txtEntry, "Invalid JID");
     }
     this.Cursor = Cursors.Default;
 }
Esempio n. 25
0
 private void btnRemove_Click(object sender, System.EventArgs e)
 {
     this.Cursor = Cursors.WaitCursor;
     try
     {
         jabber.JID jid = new jabber.JID(txtEntry.Text);
         int i = 0;
         foreach (object o in lstJID.Items)
         {
             if (jid.Equals(o))
             {
                 lstJID.Items.RemoveAt(i);
                 txtEntry.Clear();
                 error.SetError(txtEntry, null);
                 break;
             }
             i++;
         }
     }
     catch (Exception ex)
     {
         error.SetError(txtEntry, "Invalid JID: " + ex.ToString());
     }
     this.Cursor = Cursors.Default;
 }
Esempio n. 26
0
 public ChatMessage(jabber.JID jidValue, string textValue, Color colorValue)
 {
     jid = jidValue;
     text = textValue;
     color = colorValue;
 }
Esempio n. 27
0
 // Manage the forward button entry list
 private void AddForwardJid(jabber.JID jid, string node)
 {
     forward_history.Push(new ItemNode(jid, node));
     ForwardButton.Enabled = true;
 }
Esempio n. 28
0
 public ItemNode(jabber.JID jid, string node)
 {
     this.jid = jid;
     this.node = node;
 }
Esempio n. 29
0
 /// <summary>Returns the real time message of specified JID or full JID</summary>
 /// <param name="jid">JID of user</param>
 /// <returns>Real time message, if any found</returns>
 public RealTimeMessage GetRealTimeMessage(jabber.JID jid)
 {
     return((RealTimeMessage)chatRealTime[(string)jid]);
 }
Esempio n. 30
0
 public RosterResource(jabber.JID jid)
 {
     this.jid = jid;
 }
Esempio n. 31
0
 public ChatMessage(jabber.JID jidValue, string textValue, Color colorValue)
 {
     jid   = jidValue;
     text  = textValue;
     color = colorValue;
 }
Esempio n. 32
0
        public RosterItem(jabber.JID jid)
        {
            this.jid = jid;

            CreateContextMenu ();
        }
Esempio n. 33
0
        public void GotMessage(jabber.protocol.client.Message msg)
        {
            foreign_jid = msg.From;
            message_type = msg.Type;
            thread_id = msg.Thread;

            if (msg.Body.Trim ().Length > 0) {
                RichTextBox1.SelectionColor = Color.Red;
                RichTextBox1.AppendText (string.Format ("({0}) {1}: ", DateTime.Now.ToString ("hh:mm:ss"), Text));
                RichTextBox1.SelectionColor = Color.Black;
                RichTextBox1.AppendText (string.Format ("{0}\n", msg.Body));

                XmppSounds.PlaySound (DefaultSounds.MessageIn);
            }
        }
Esempio n. 34
0
        internal static void PresManager_OnPrimarySessionChange(object sender, jabber.JID bare)
        {
            jabber.protocol.client.Presence[] s = Client.PresManager.GetAll(bare);
            if (s.Length == 0)
            {
                return;
            }
            string Presence = s[0].Status;

            if (Presence == null)
            {
                return;
            }
            Debug.WriteLine(Presence);
            if (Client.AllPlayers.ContainsKey(bare.User))
            {
                UpdatePlayers = true;
                ChatPlayerItem Player = Client.AllPlayers[bare.User];
                using (XmlReader reader = XmlReader.Create(new StringReader(Presence)))
                {
                    while (reader.Read())
                    {
                        if (reader.IsStartElement())
                        {
                            #region Parse Presence

                            switch (reader.Name)
                            {
                            case "profileIcon":
                                reader.Read();
                                Player.ProfileIcon = Convert.ToInt32(reader.Value);
                                break;

                            case "level":
                                reader.Read();
                                Player.Level = Convert.ToInt32(reader.Value);
                                break;

                            case "wins":
                                reader.Read();
                                Player.Wins = Convert.ToInt32(reader.Value);
                                break;

                            case "leaves":
                                reader.Read();
                                Player.Leaves = Convert.ToInt32(reader.Value);
                                break;

                            case "rankedWins":
                                reader.Read();
                                Player.RankedWins = Convert.ToInt32(reader.Value);
                                break;

                            case "timeStamp":
                                reader.Read();
                                Player.Timestamp = Convert.ToInt64(reader.Value);
                                break;

                            case "statusMsg":
                                reader.Read();
                                Player.Status = reader.Value;
                                break;

                            case "UsingLegendaryClient":
                                Player.UsingLegendary = true;
                                break;

                            case "gameStatus":
                                reader.Read();
                                Player.GameStatus = reader.Value;
                                break;

                            case "skinname":
                                reader.Read();
                                Player.Champion = reader.Value;
                                break;

                            case "rankedLeagueName":
                                reader.Read();
                                Player.LeagueName = reader.Value;
                                break;

                            case "rankedLeagueTier":
                                reader.Read();
                                Player.LeagueTier = reader.Value;
                                break;

                            case "rankedLeagueDivision":
                                reader.Read();
                                Player.LeagueDivision = reader.Value;
                                break;
                            }

                            #endregion Parse Presence
                        }
                    }
                }
                if (String.IsNullOrWhiteSpace(Player.Status))
                {
                    Player.Status = "Online";
                }
            }
        }
Esempio n. 35
0
        void on_editAccountButton_clicked()
        {
            var selected = accountsList.SelectionModel().SelectedIndexes();
            if (selected.Count > 0) {
                var data = accountsList.Model().Data(selected[0], (int)Qt.ItemDataRole.DisplayRole);
                var jid = new jabber.JID((string)data);

                var accountService = ServiceManager.Get<AccountService>();

                Account account = accountService.GetAccount(jid);
                if (account != null) {
                    if (!account.IsReadOnly) {
                        var dialog = new EditAccountDialog(account.Info, this);
                        dialog.Show();
                        dialog.Exec();

                        accountsList.Update();
                    } else {
                        QMessageBox.Critical(this, "Error", "Cannot modify account while connected.");
                    }
                }
            }
        }
Esempio n. 36
0
        public RosterItem(jabber.JID jid)
        {
            this.jid = jid;

            CreateContextMenu();
        }
Esempio n. 37
0
            private void jid_Validating(object sender, CancelEventArgs e)
            {
                TextBox jtxt = (TextBox) sender;
                if (jtxt.Text == "")
                    return;

                try
                {
                    jabber.JID j = new jabber.JID(jtxt.Text);
                }
                catch
                {
                    e.Cancel = true;
                    m_form.error.SetError(jtxt, "Invalid JID");
                }
            }
Esempio n. 38
0
        // Submit a new query
        private void SubmitQuery(jabber.JID jid, string node, bool refresh)
        {
            IdentityNameLabel.Text = string.Empty;
            IdentityAddressLabel.Text = string.Empty;
            IdentityCategoryTypeLabel.Text = string.Empty;

            Label4.Visible = false;
            ActionButton.Visible = false;
            StopButton.Enabled = true;
            Spinner.Visible = true;
            ErrorPicture.Visible = false;
            got_one_response = false;
            was_stopped = false;

            ServiceListView.Items.Clear ();

            AddressTextBox.SelectAll ();

            current_jid = jid;
            current_node = node;

            XmppGlobal.Disco.DiscoInfoQuery (jid, node, refresh, new QueryCallback (GotInfoQuery), null);
            XmppGlobal.Disco.DiscoItemsQuery (jid, node, refresh, new QueryCallback (GotItemsQuery), null);
        }
Esempio n. 39
0
        void on_removeAccountButton_clicked()
        {
            var selected = accountsList.SelectionModel().SelectedIndexes();
            if (selected.Count > 0) {
                var data = accountsList.Model().Data(selected[0], (int)Qt.ItemDataRole.DisplayRole);
                var jid = new jabber.JID((string)data);

                var accountService = ServiceManager.Get<AccountService>();
                Account account = accountService.GetAccount(jid);
                if (account != null) {
                    if (QMessageBox.Question(this, "Remove Account",
                                             "Are you sure you want to remove this account?",
                                             (uint)QMessageBox.StandardButton.Yes | (uint)QMessageBox.StandardButton.No,
                                             QMessageBox.StandardButton.No) == QMessageBox.StandardButton.Yes)
                    {
                        accountService.RemoveAccount(account);
                    }
                }
            }
        }