Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public static void RemoveContact(Contact contact)
        {
            try
            {
                var account = Frontend.Accounts[contact.account];
                if (account != null)
                {
                    Unsubscribe(contact);
                    Unsubscribed(contact);

                    // Remove hin from the roster
                    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          = contact.jid;
                    item.subscription = Tags.jabber.iq.roster.item.subscriptionEnum.remove;
                    query.Add(item);
                    iq.Add(query);

                    Frontend.Backend.SendTag(account.jid, iq);
                }
            }
            catch (Exception uiEx) { Frontend.UIError(uiEx); }
        }
Ejemplo n.º 3
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); }
        }
Ejemplo n.º 4
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); }
        }
Ejemplo n.º 5
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); }
        }
Ejemplo n.º 6
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); }
        }
Ejemplo n.º 7
0
        public static void RemoveContact(Contact contact)
        {
            try
            {
                var account = Frontend.Accounts[contact.account];
                if (account != null)
                {
                    Unsubscribe(contact);
                    Unsubscribed(contact);

                    // Remove hin from the roster
                    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 = contact.jid;
                    item.subscription = Tags.jabber.iq.roster.item.subscriptionEnum.remove;
                    query.Add(item);
                    iq.Add(query);

                    Frontend.Backend.SendTag(account.jid, iq);
                }
            }
            catch (Exception uiEx) { Frontend.UIError(uiEx); }
        }
Ejemplo n.º 8
0
        public static void RequestRoster(Account account)
        {
            var iq = new Tags.jabber.client.iq();

            if (!string.IsNullOrEmpty(account.CurrentJID.Bare))
                iq.from = account.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: " + account.CurrentJID.ToString() + " id " + iq.id);
#endif
            
            Runtime.Interface.SendTag(new XMPP.JID(account.jid).Bare, iq);
        }