Пример #1
0
        public static void RequestRoster(XMPP.JID currentJID)
        {
            var iq = new Tags.jabber.client.iq();

            if (!string.IsNullOrEmpty(currentJID.Bare))
            {
                iq.from = currentJID;
            }
            else
            {
                return;
            }

            iq.type = Tags.jabber.client.iq.typeEnum.get;

            var query = new Tags.jabber.iq.roster.query();

            iq.Add(query);

#if DEBUG
            System.Diagnostics.Debug.WriteLine("[Frontend] Requesting Roster for: " + currentJID.ToString() + " id " + iq.id);
#endif

            Runtime.Interface.SendTag(currentJID.Bare, iq);
        }
Пример #2
0
        private bool Process(Tags.jabber.client.presence presence)
        {
            if (presence.type == Tags.jabber.client.presence.typeEnum.error)
            {
                var errorMessage = Helper.GetErrorMessage(presence);
                NotifyError(XMPP.ErrorPolicyType.Informative, Helper.Translate("ErrorTagPresence") + ": " + errorMessage);
            }
            else if (presence.type == Tags.jabber.client.presence.typeEnum.subscribe)
            {
                var fromJid = new XMPP.JID(presence.from);
                Notify(presence.Account, presence.from, fromJid + " " + Helper.Translate("SubscriptionRequest"));
            }

            return(false);
        }
Пример #3
0
        private bool Process(Tags.jabber.client.message message)
        {
            if (message.type == Tags.jabber.client.message.typeEnum.error)
            {
                var errorMessage = Helper.GetErrorMessage(message);
                NotifyError(XMPP.ErrorPolicyType.Informative, Helper.Translate("ErrorTagMessage") + ": " + errorMessage);
            }
            else if (message.type == Tags.jabber.client.message.typeEnum.chat || message.type == Tags.jabber.client.message.typeEnum.normal)
            {
                if (message.bodyElements.Count() > 0)
                {
                    var from     = new XMPP.JID(message.from);
                    var bodytext = string.Join(" ", (from body in message.bodyElements select body.Value));
                    Notify(message.Account, from.Bare, bodytext);
                    return(true);
                }
            }

            return(false);
        }
Пример #4
0
        private async void OnAdd(object sender, RoutedEventArgs e)
        {
            var account = AccountSelector.SelectedItem as Account;
            var jid = new XMPP.JID(Jid.Text);
            if (account == null ||
                string.IsNullOrEmpty(jid.Bare) ||
                string.IsNullOrEmpty(jid.Server) ||
                string.IsNullOrEmpty(jid.User))
            {
                Warning.Visibility = Windows.UI.Xaml.Visibility.Visible;
                return;
            }

            await Frontend.RunAsync(() =>
            {
                XMPPHelper.CreateContact(account, jid, Alias.Text);
            });

            flyoutSelf.Hide();
        }
Пример #5
0
        public static void RequestVCard(XMPP.JID currentJID)
        {
            var iq = new Tags.jabber.client.iq();

            if (!string.IsNullOrEmpty(currentJID.Bare))
            {
                iq.from = currentJID;
            }
            else
            {
                return;
            }

            iq.type = Tags.jabber.client.iq.typeEnum.get;

            var vcard = new Tags.vcard_temp.vCard();

            iq.Add(vcard);

            Runtime.Interface.SendTag(currentJID.Bare, iq);
        }
Пример #6
0
        private async void OnAdd(object sender, RoutedEventArgs e)
        {
            var account = AccountSelector.SelectedItem as Account;
            var jid     = new XMPP.JID(Jid.Text);

            if (account == null ||
                string.IsNullOrEmpty(jid.Bare) ||
                string.IsNullOrEmpty(jid.Server) ||
                string.IsNullOrEmpty(jid.User))
            {
                Warning.Visibility = Windows.UI.Xaml.Visibility.Visible;
                return;
            }

            await Frontend.RunAsync(() =>
            {
                XMPPHelper.CreateContact(account, jid, Alias.Text);
            });

            flyoutSelf.Hide();
        }
Пример #7
0
        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); }
        }
Пример #8
0
        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); }
        }