public void GetMyVcard()
        {
            //  throw new NotImplementedException();

            VcardIq viq = new VcardIq(IqType.get);
            dbcon.IqGrabber.SendIq(viq, new IqCB(VcardResult), null);
        }
Пример #2
0
        public frmVcard(Jid jid, XmppClientConnection con)
        {
            InitializeComponent();

            _connection = con;

            this.Text = "Vcard from: " + jid.Bare;

            VcardIq viq = new VcardIq(IqType.get, new Jid(jid.Bare));
            packetId = viq.Id;
            con.IqGrabber.SendIq(viq, new IqCB(VcardResult), null);
        }
Пример #3
0
 /// <summary>
 /// Publication de la fiche d'identit�
 /// </summary>
 /// <returns>vrai si la publication a bien �t� effectu�e, sinon faux</returns>
 public bool publish()
 {
     // si il n'y a pas de stream XMPP en cours ou si ce n'est pas notre fiche d'identit�, on s'arrete l�.
     if (!Jabber.xmpp.Authenticated || Jabber.xmpp.MyJID.ToString() != jabberID.full)
     {
         return(false);
     }
     agsXMPP.protocol.iq.vcard.VcardIq viq = new agsXMPP.protocol.iq.vcard.VcardIq();
     viq.Type  = agsXMPP.protocol.client.IqType.set;
     viq.To    = Jabber.xmpp.MyJID;
     viq.Vcard = toVcard();
     Jabber.xmpp.Send(viq);
     onIdentityPublished();
     return(true);
 }
Пример #4
0
 public Task<ContactDetails> Send()
 {
     var dispatcher = Dispatcher.CurrentDispatcher;
     var connection = ConnectionManager.GetOrCreateConnection(_client);
     _onIq = dispatcher.Wrap<object, IQ>(OnIq);
     _connection = connection.Connection;
     _connection.OnIq += _onIq.Exec;
     var iq = new VcardIq();
     iq.Type = IqType.get;
     iq.To = _jid;
     iq.From = _connection.MyJID;
     iq.Id = _id = Guid.NewGuid().ToString("N");
     _connection.Send(iq);
     return _task.Task;
 }
Пример #5
0
 /// <summary>
 /// Demande d'identit�
 /// </summary>
 /// <returns>vrai si la demande est effectu�e, sinon faux</returns>
 public bool retrieve()
 {
     // si il n'y a pas de stream XMPP en cours, on s'arrete l�.
     if (!Jabber.xmpp.Authenticated)
     {
         return(false);
     }
     agsXMPP.protocol.iq.vcard.VcardIq viq = new agsXMPP.protocol.iq.vcard.VcardIq();
     viq.Type = agsXMPP.protocol.client.IqType.get;
     viq.From = Jabber.xmpp.MyJID;
     if (Jabber.xmpp.MyJID.ToString() != jabberID.full)
     {
         viq.To = new agsXMPP.Jid(jabberID.full);
     }
     Jabber.xmpp.IqGrabber.SendIq(viq, new agsXMPP.IqCB(retrieveIqResult), viq.Id);
     return(true);
 }
Пример #6
0
        /// <summary>
        /// The xmpp on on registered.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        private void XmppOnOnRegistered(object sender)
        {
            this.myPresence.Type = PresenceType.available;
            this.myPresence.Show = ShowType.chat;
            this.MucManager = new MucManager(this.xmpp);
            var room = new Jid("lobby@conference." + this.Config.ChatHost);
            this.MucManager.AcceptDefaultConfiguration(room);

            // MucManager.JoinRoom(room,Username,Password,false);
            this.Me = new User(this.xmpp.MyJID);
            this.Me.SetStatus(UserStatus.Online);
            this.xmpp.PresenceManager.Subscribe(this.xmpp.MyJID);

            var v = new Vcard();
            var e = new Email { UserId = this.email, Type = EmailType.INTERNET, Value = this.email };
            v.AddChild(e);
            v.JabberId = new Jid(this.Username + "@" + this.Config.ChatHost);
            var vc = new VcardIq(IqType.set, v);
            vc.To = this.Config.ChatHost;
            vc.GenerateId();
            this.xmpp.Send(vc);
            if (this.OnRegisterComplete != null)
            {
                this.OnRegisterComplete.Invoke(this, RegisterResults.Success);
            }
        }
Пример #7
0
 private void XmppOnOnRosterEnd(object sender)
 {
     foreach(var n in Friends)
     {
         var viq = new VcardIq{Type = IqType.get , To = n.User.Bare};
         viq.GenerateId();
         Xmpp.Send(viq);
     }
     if(OnDataRecieved != null)
         OnDataRecieved.Invoke(this,DataRecType.FriendList,Friends);
     if (Chatting.Rooms.Count(x => x.IsGroupChat && x.GroupUser.User.Bare == "*****@*****.**") == 0)
         Xmpp.RosterManager.AddRosterItem(new Jid("*****@*****.**"));
 }
Пример #8
0
 private void XmppOnOnRegistered(object sender)
 {
     Vcard v = new Vcard();
     v.AddEmailAddress(new Email(EmailType.HOME, _email,true));
     v.JabberId = new Jid(this.Username + "@server.octgn.info");
     VcardIq vc = new VcardIq(IqType.set,v);
     Xmpp.IqGrabber.SendIq(vc);
     if(OnRegisterComplete != null)
         OnRegisterComplete.Invoke(this,RegisterResults.Success);
 }
Пример #9
0
            private void ProcessVcard(IQ iq)
            {

                if (iq.Type == IqType.get)
                {
                    Jid to = iq.To;
                    foreach (Account account in this.m_Server.AccountManager.Accounts)
                    {
                        if (account.JID.Bare.ToLower() == iq.To.Bare.ToLower())
                        {
                            VcardIq newIQ = new VcardIq(IqType.result);
                            newIQ.Id = iq.Id;
                            newIQ.To = iq.To;

                            newIQ.Vcard.Fullname = account.UserID;
                            newIQ.Vcard.JabberId = account.JID;
                            newIQ.Vcard.Name = new Name("SiteView", "test", "test");
                            newIQ.Vcard.Nickname = account.UserName;
                            newIQ.Vcard.Organization = new Organization("SiteView", account.Company);
                            newIQ.Vcard.Role = account.Type.ToString();
                            newIQ.Vcard.Url = "http://www.siteview.com";
                            newIQ.Vcard.Birthday = DateTime.Now;
                            newIQ.Vcard.Photo = new Photo("http://www.siteview.com/siteview/images/logo.gif");

                            Send(newIQ);

                        }
                    }

                }
                else if (iq.Type == IqType.set)
                {

                }
                else
                {

                }
            }
        private void OnRosterResult(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
        {
            //_debug += item.ToString();
            if (item.Name != null)
            {
                if (item.Jid.Server != "public.talk.google.com")
                {
                    if (!cm.contactList.ContainsKey(item.Jid.Bare))
                    {
                        cm.contactList.Add(item.Jid.Bare,item.Jid);
                        VcardIq viq = new VcardIq(IqType.get, new Jid(item.Jid.Bare));
                        packetId = viq.Id;
                        xmppCon.IqGrabber.SendIq(viq, new IqCB(VcardResult), item.Jid);
                    }

                }
            }
        }
Пример #11
0
 /// <summary>
 /// Publication de la fiche d'identit�
 /// </summary>
 /// <returns>vrai si la publication a bien �t� effectu�e, sinon faux</returns>
 public bool publish()
 {
     // si il n'y a pas de stream XMPP en cours ou si ce n'est pas notre fiche d'identit�, on s'arrete l�.
     if (!Jabber.xmpp.Authenticated || Jabber.xmpp.MyJID.ToString() != jabberID.full)
     {
         return false;
     }
     agsXMPP.protocol.iq.vcard.VcardIq viq = new agsXMPP.protocol.iq.vcard.VcardIq();
     viq.Type = agsXMPP.protocol.client.IqType.set;
     viq.To = Jabber.xmpp.MyJID;
     viq.Vcard = toVcard();
     Jabber.xmpp.Send(viq);
     onIdentityPublished();
     return true;
 }
Пример #12
0
        private void OnSubscribePresence(Presence presence)
        {
            Contact contact;

            lock (_realContacts)
            {
                contact = FindContact(presence.From);
            }

            switch (presence.Type)
            {
                case PresenceType.subscribe:
                    {
                        VcardIq viq = new VcardIq(IqType.get, presence.From);
                        Account.Instance.XmppConnection.IqGrabber.SendIq(viq, new IqCB(VcardResultAuth),
                                                                         (contact ?? (object) presence));

                        if (contact == null)
                        {
                            Authorization.Instance.Ask(presence);
                        }
                        else
                        {
                            Authorization.Instance.Ask(contact);
                        }
                        break;
                    }
                case PresenceType.subscribed:
                    {
                        if (contact == null)
                        {
                            EventInfo eventinfo =
                                new EventInfo(string.Format("'{0}' just authorized you", presence.From));
                            Events.Instance.OnEvent(this, eventinfo);
                        }
                        else
                        {
                            EventInfo eventinfo =
                                new EventInfo(
                                    string.Format("'{0} ({1})' just authorized you", contact.DisplayName, contact.Jid));
                            Events.Instance.OnEvent(this, eventinfo);

                            // try to get v-card instantly
                            VcardIq viq = new VcardIq(IqType.get, contact.Jid);
                            Account.Instance.XmppConnection.IqGrabber.SendIq(viq, new IqCB(VcardResult), contact);
                        }

                        break;
                    }
                case PresenceType.unsubscribe:
                    {
                        break;
                    }
                case PresenceType.unsubscribed:
                    {
                        if (contact == null)
                        {
                            EventInfo eventinfo =
                                new EventInfo(string.Format("'{0}' removed your authorization", presence.From));
                            Events.Instance.OnEvent(this, eventinfo);
                        }
                        else
                        {
                            EventInfo eventinfo =
                                new EventInfo(
                                    string.Format("'{0} ({1})' removed your authorization", contact.DisplayName,
                                                  contact.Jid));
                            Events.Instance.OnEvent(this, eventinfo);
                        }

                        break;
                    }
            }
        }
Пример #13
0
        public void SetFreshVcard(IContact contact, int maxOldness)
        {
            Contact cont = contact as Contact;
            MetaContact metaContact = contact as MetaContact;

            if (metaContact != null)
            {
                lock (metaContact.SubContacts._syncObject)
                {
                    cont = metaContact.FindContact(contact.Jid);
                }
            }

            if (cont == null)
            {
                return;
            }

            Vcard vcard = Storage.GetVcard(contact.Jid, maxOldness);

            if (vcard != null)
            {
                cont.SetVcard(vcard);
            }
            else // if (cont.HasFeature(Uri.VCARD))
            {
                VcardIq viq = new VcardIq(IqType.get, contact.Jid);
                Account.Instance.XmppConnection.IqGrabber.SendIq(viq, new IqCB(VcardResult), cont);
            }
        }
Пример #14
0
        public void PublishVCard()
        {
            VcardIq vcardIq = new VcardIq(IqType.set, _card.Vcard);
            Account.Instance.XmppConnection.Send(vcardIq);

            Account.Instance.SendMyPresence();
        }
Пример #15
0
 public void AskMyVcard()
 {
     VcardIq viq = new VcardIq(IqType.get, Jid);
     Account.Instance.XmppConnection.IqGrabber.SendIq(viq, new IqCB(VcardResult), null);
 }
        private void OnPresence(object sender, agsXMPP.protocol.client.Presence pres)
        {
            if (pres.From.Server != "public.talk.google.com") {
                if (!cm.PresenceList.ContainsKey(pres.From.Bare)) {
                    cm.PresenceList[pres.From.Bare] = pres;
                    cW.Refresh();
                }
                VcardIq viq = new VcardIq(IqType.get, new Jid(pres.From.Bare));
                packetId = viq.Id;
                xmppCon.IqGrabber.SendIq(viq, new IqCB(VcardResult), pres.From);

            }
        }
Пример #17
0
        private void XmppOnOnRegistered(object sender)
        {
			Vcard v = new Vcard();
			Email e = new Email
			{
				UserId = _email,
				Type = EmailType.INTERNET,
				Value = _email
			};
			v.AddChild(e);
			v.JabberId = new Jid(this.Username + "@" + Host);
			VcardIq vc = new VcardIq(IqType.set, v);
			vc.To = Host;
			vc.GenerateId();
			Xmpp.Send(vc);
            if(OnRegisterComplete != null)
                OnRegisterComplete.Invoke(this,RegisterResults.Success);
        }
Пример #18
0
 /// <summary>
 /// Demande d'identit�
 /// </summary>
 /// <returns>vrai si la demande est effectu�e, sinon faux</returns>
 public bool retrieve()
 {
     // si il n'y a pas de stream XMPP en cours, on s'arrete l�.
     if (!Jabber.xmpp.Authenticated)
     {
         return false;
     }
     agsXMPP.protocol.iq.vcard.VcardIq viq = new agsXMPP.protocol.iq.vcard.VcardIq();
     viq.Type = agsXMPP.protocol.client.IqType.get;
     viq.From = Jabber.xmpp.MyJID;
     if (Jabber.xmpp.MyJID.ToString() != jabberID.full)
     {
         viq.To = new agsXMPP.Jid(jabberID.full);
     }
     Jabber.xmpp.IqGrabber.SendIq(viq, new agsXMPP.IqCB(retrieveIqResult), viq.Id);
     return true;
 }