Esempio n. 1
0
 public MessageEventArgs(S22.Xmpp.Jid jid, S22.Xmpp.Im.Message message)
 {
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     message.ThrowIfNull <S22.Xmpp.Im.Message>("message");
     this.Jid     = jid;
     this.Message = message;
 }
 public MoodChangedEventArgs(S22.Xmpp.Jid jid, S22.Xmpp.Extensions.Mood mood, string description = null)
 {
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     this.Jid         = jid;
     this.Mood        = mood;
     this.Description = description;
 }
Esempio n. 3
0
 public Item(S22.Xmpp.Jid jid, string node = null, string name = null)
 {
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     this.Jid  = jid;
     this.Node = node;
     this.Name = name;
 }
Esempio n. 4
0
 public StatusEventArgs(S22.Xmpp.Jid jid, S22.Xmpp.Im.Status status)
 {
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     status.ThrowIfNull <S22.Xmpp.Im.Status>("status");
     this.Jid    = jid;
     this.Status = status;
 }
Esempio n. 5
0
        internal Iq IqRequest(IqType type, S22.Xmpp.Jid to = null, S22.Xmpp.Jid from = null, XmlElement data = null, CultureInfo language = null, int millisecondsTimeout = -1, string seqID = "")
        {
            //Iq stanza = new Iq(type, null, to, from, data, language);
            //foreach (XmppExtension extension in this.extensions)
            //{
            //    IOutputFilter<Iq> filter = extension as IOutputFilter<Iq>;
            //    if (filter != null)
            //    {
            //        filter.Output(stanza);
            //    }
            //}
            //return this.core.IqRequest(stanza, millisecondsTimeout, seqID);

            Iq iq = new Iq(type, null, to, from, data, language);

            // Invoke IOutput<Iq> Plugins.
            foreach (var ext in extensions)
            {
                var filter = ext as IOutputFilter <Iq>;
                if (filter != null)
                {
                    filter.Output(iq);
                }
            }
            return(core.IqRequest(iq, millisecondsTimeout, seqID));
        }
Esempio n. 6
0
 public void RevokeSubscription(S22.Xmpp.Jid jid)
 {
     this.AssertValid(true);
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     S22.Xmpp.Im.Presence presence = new S22.Xmpp.Im.Presence(jid, null, PresenceType.Unsubscribed, null, null, new XmlElement[0]);
     this.SendPresence(presence);
 }
Esempio n. 7
0
 public void SendMessage(S22.Xmpp.Jid to, IDictionary <string, string> bodies, IDictionary <string, string> subjects = null, string thread = null, MessageType type = 0, CultureInfo language = null)
 {
     this.AssertValid();
     to.ThrowIfNull <S22.Xmpp.Jid>("to");
     bodies.ThrowIfNull <IDictionary <string, string> >("bodies");
     this.im.SendMessage(to, bodies, subjects, thread, type, language);
 }
Esempio n. 8
0
 public void SendMessage(S22.Xmpp.Jid to, string body, string subject = null, string thread = null, MessageType type = 0, CultureInfo language = null)
 {
     this.AssertValid();
     to.ThrowIfNull <S22.Xmpp.Jid>("to");
     body.ThrowIfNullOrEmpty("body");
     this.im.SendMessage(to, body, subject, thread, type, language);
 }
Esempio n. 9
0
 public void IqRequestBeatJieShun(S22.Xmpp.Jid to)
 {
     if (this.im != null)
     {
         this.im.IqRequestBeatJieShun(to, this.Jid, IqType.Get);
     }
 }
Esempio n. 10
0
 public void Block(S22.Xmpp.Jid jid)
 {
     this.AssertValid();
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     if (this.block.Supported)
     {
         this.block.Block(jid);
     }
     else
     {
         PrivacyList privacyList        = null;
         string      defaultPrivacyList = this.im.GetDefaultPrivacyList();
         if (defaultPrivacyList != null)
         {
             privacyList = this.im.GetPrivacyList(defaultPrivacyList);
         }
         foreach (PrivacyList list2 in this.im.GetPrivacyLists())
         {
             if (list2.Name == "blocklist")
             {
                 privacyList = list2;
             }
         }
         if (privacyList == null)
         {
             privacyList = new PrivacyList("blocklist");
         }
         privacyList.Add(new JidPrivacyRule(jid, false, 0, 0), true);
         this.im.EditPrivacyList(privacyList);
         this.im.SetDefaultPrivacyList(privacyList.Name);
         this.im.SetActivePrivacyList(privacyList.Name);
     }
 }
Esempio n. 11
0
 public void AddContact(S22.Xmpp.Jid jid, string name = null, params string[] groups)
 {
     this.AssertValid();
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     this.im.AddToRoster(new RosterItem(jid, name, groups));
     this.im.RequestSubscription(jid);
 }
 public AvatarChangedEventArgs(S22.Xmpp.Jid jid, string hash = null, Image avatar = null)
 {
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     this.Jid    = jid;
     this.Hash   = hash;
     this.Avatar = avatar;
 }
Esempio n. 13
0
 public ActivityChangedEventArgs(S22.Xmpp.Jid jid, GeneralActivity activity, SpecificActivity specific = SpecificActivity.Other, string description = null)
 {
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     this.Jid         = jid;
     this.Activity    = activity;
     this.Specific    = specific;
     this.Description = description;
 }
Esempio n. 14
0
 public Iq IqRequestJieShun(S22.Xmpp.Jid to, string cnt, int crc, string mode, IqType iqType = 0, int millisecondsTimeout = -1, string seqID = "")
 {
     if (millisecondsTimeout == -1)
     {
         millisecondsTimeout = 0x4e20;
     }
     return(this.im.IqRequestJieShun(to, this.Jid, cnt, crc, mode, iqType, millisecondsTimeout, seqID));
 }
Esempio n. 15
0
        public Iq IqRequestJieShun(S22.Xmpp.Jid to, S22.Xmpp.Jid from, string cnt, int crc, string mode, IqType iqType = 0, int millisecondsTimeout = -1, string seqID = "")
        {
            XmlElement e = Xml.Element("dreq", "xmpp:iq:shunt");

            e.Child(Xml.Element("cnt", null).Text(XmlHelper.FilterChar(cnt)));
            e.Child(Xml.Element("crc", null).Text(crc.ToString()));
            e.Child(Xml.Element("mode", null).Text(mode));
            return(this.IqRequest(iqType, to, from, e, null, millisecondsTimeout, seqID));
        }
Esempio n. 16
0
 public Streamhost(S22.Xmpp.Jid jid, string host, int port)
 {
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     host.ThrowIfNullOrEmpty("host");
     port.ThrowIfOutOfRange("port", 0, 0xffff);
     this.Jid  = jid;
     this.Host = host;
     this.Port = port;
 }
Esempio n. 17
0
 private UserInfo GetUser(Jid jid)
 {
     var bare = jid.GetBareJid();
     var result = _client.GetRoster().First(_ => _.Jid == bare);
     return new UserInfo
            {
                Id = jid.ToString(),
                Name = result.Name,
            };
 }
Esempio n. 18
0
 public void Unblock(S22.Xmpp.Jid jid)
 {
     this.AssertValid();
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     if (this.block.Supported)
     {
         this.block.Unblock(jid);
     }
     else
     {
         PrivacyList privacyList        = null;
         string      defaultPrivacyList = this.im.GetDefaultPrivacyList();
         if (defaultPrivacyList != null)
         {
             privacyList = this.im.GetPrivacyList(defaultPrivacyList);
         }
         foreach (PrivacyList list2 in this.im.GetPrivacyLists())
         {
             if (list2.Name == "blocklist")
             {
                 privacyList = list2;
             }
         }
         if (privacyList != null)
         {
             ISet <JidPrivacyRule> set = new HashSet <JidPrivacyRule>();
             foreach (PrivacyRule rule in privacyList)
             {
                 if (rule is JidPrivacyRule)
                 {
                     JidPrivacyRule item = rule as JidPrivacyRule;
                     if (!(!(item.Jid == jid) || item.Allow))
                     {
                         set.Add(item);
                     }
                 }
             }
             foreach (JidPrivacyRule rule3 in set)
             {
                 privacyList.Remove(rule3);
             }
             if (privacyList.Count == 0)
             {
                 this.im.SetDefaultPrivacyList(null);
                 this.im.RemovePrivacyList(privacyList.Name);
             }
             else
             {
                 this.im.EditPrivacyList(privacyList);
                 this.im.SetDefaultPrivacyList(privacyList.Name);
             }
         }
     }
 }
Esempio n. 19
0
        public void RemoveFromRoster(S22.Xmpp.Jid jid)
        {
            this.AssertValid(true);
            jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
            XmlElement data    = Xml.Element("query", "jabber:iq:roster").Child(Xml.Element("item", null).Attr("jid", jid.ToString()).Attr("subscription", "remove"));
            Iq         errorIq = this.IqRequest(IqType.Set, null, this.Jid, data, null, -1, "");

            if (errorIq.Type == IqType.Error)
            {
                throw Util.ExceptionFromError(errorIq, "The item could not be removed from the roster.");
            }
        }
Esempio n. 20
0
        internal string IqRequestAsync(IqType type, S22.Xmpp.Jid to = null, S22.Xmpp.Jid from = null, XmlElement data = null, CultureInfo language = null, Action <string, Iq> callback = null)
        {
            Iq stanza = new Iq(type, null, to, from, data, language);

            foreach (XmppExtension extension in this.extensions)
            {
                IOutputFilter <Iq> filter = extension as IOutputFilter <Iq>;
                if (filter != null)
                {
                    filter.Output(stanza);
                }
            }
            return(this.core.IqRequestAsync(stanza, callback));
        }
Esempio n. 21
0
        internal void IqResponse(IqType type, string id, S22.Xmpp.Jid to = null, S22.Xmpp.Jid from = null, XmlElement data = null, CultureInfo language = null)
        {
            this.AssertValid(false);
            Iq stanza = new Iq(type, id, to, from, data, language);

            foreach (XmppExtension extension in this.extensions)
            {
                IOutputFilter <Iq> filter = extension as IOutputFilter <Iq>;
                if (filter != null)
                {
                    filter.Output(stanza);
                }
            }
            this.core.IqResponse(stanza);
        }
Esempio n. 22
0
 internal RosterItem(S22.Xmpp.Jid jid, string name, S22.Xmpp.Im.SubscriptionState state, bool pending, IEnumerable <string> groups)
 {
     this.groups = new HashSet <string>();
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     this.Jid  = jid;
     this.Name = name;
     if (groups != null)
     {
         foreach (string str in groups)
         {
             if (!string.IsNullOrEmpty(str))
             {
                 this.groups.Add(str);
             }
         }
     }
     this.SubscriptionState = state;
     this.Pending           = pending;
 }
Esempio n. 23
0
 public void IqResponse(IqType type, string id, S22.Xmpp.Jid to = null, S22.Xmpp.Jid from = null, XmlElement data = null, CultureInfo language = null)
 {
     this.AssertValid();
     this.IqResponse(new S22.Xmpp.Core.Iq(type, id, to, from, data, null));
 }
Esempio n. 24
0
 public string IqRequestAsync(IqType type, S22.Xmpp.Jid to = null, S22.Xmpp.Jid from = null, XmlElement data = null, CultureInfo language = null, Action <string, S22.Xmpp.Core.Iq> callback = null)
 {
     this.AssertValid();
     return(this.IqRequestAsync(new S22.Xmpp.Core.Iq(type, null, to, from, data, language), callback));
 }
Esempio n. 25
0
 public S22.Xmpp.Core.Iq IqRequest(IqType type, S22.Xmpp.Jid to = null, S22.Xmpp.Jid from = null, XmlElement data = null, CultureInfo language = null, int millisecondsTimeout = -1)
 {
     this.AssertValid();
     return(this.IqRequest(new S22.Xmpp.Core.Iq(type, null, to, from, data, language), millisecondsTimeout, ""));
 }
Esempio n. 26
0
 public RosterItem(S22.Xmpp.Jid jid, string name = null, params string[] groups) : this(jid, name, S22.Xmpp.Im.SubscriptionState.None, false, groups)
 {
 }
Esempio n. 27
0
 public SubscriptionRequestEventArgs(S22.Xmpp.Jid jid)
 {
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     this.Jid = jid;
 }
Esempio n. 28
0
 public JidPrivacyRule(S22.Xmpp.Jid jid, bool allow, uint order, PrivacyGranularity granularity = 0) : base(allow, order, granularity)
 {
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     this.Jid = jid;
 }
Esempio n. 29
0
 public void SendMessage(S22.Xmpp.Jid to = null, S22.Xmpp.Jid from = null, XmlElement data = null, string id = null, CultureInfo language = null)
 {
     this.AssertValid();
     this.Send(new S22.Xmpp.Core.Message(to, from, data, id, language));
 }
Esempio n. 30
0
 private void removeFriendToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         ListView.SelectedListViewItemCollection selectedItem = friendView.SelectedItems;
         ListViewItem lsItem = selectedItem[0];
         String item = lsItem.Text;
         S22.Xmpp.Jid tempRemove = new S22.Xmpp.Jid(item + "@" + Properties.Settings.Default.srv);
         try
         {
             client.RemoveContact(tempRemove);
         }
         catch (Exception ex)
         {
             msg("Error - Remove Contact - Roster", ex.ToString());
         }
     } catch(Exception exa)
     {
         msg("Error - Remove Contact - Roster", "You must first select a friend to remove.");
     }
     
     
 }
Esempio n. 31
0
        internal void IqResponseJieShun(IqType type, string id, string cnt, int crc, int rc, string sync, S22.Xmpp.Jid to = null, S22.Xmpp.Jid from = null, CultureInfo language = null)
        {
            this.AssertValid(false);
            XmlElement e = Xml.Element("dres", "xmpp:iq:shunt");

            e.Child(Xml.Element("cnt", null).Text(XmlHelper.FilterChar(cnt)));
            e.Child(Xml.Element("crc", null).Text(crc.ToString()));
            e.Child(Xml.Element("sync", null).Text(sync));
            e.Child(Xml.Element("rc", null).Text("0"));
            Iq stanza = new Iq(type, id, to, from, e, language);

            foreach (XmppExtension extension in this.extensions)
            {
                IOutputFilter <Iq> filter = extension as IOutputFilter <Iq>;
                if (filter != null)
                {
                    filter.Output(stanza);
                }
            }
            this.core.IqResponse(stanza);
        }
Esempio n. 32
0
 public void SendPresence(S22.Xmpp.Jid to = null, S22.Xmpp.Jid from = null, string id = null, CultureInfo language = null, params XmlElement[] data)
 {
     this.AssertValid();
     this.Send(new S22.Xmpp.Core.Presence(to, from, id, language, data));
 }
Esempio n. 33
0
 private bool OnSubRequest(Jid from)
 {
     return true;
 }