/// <summary> /// Decline the use of any active list /// </summary> /// <param name="cb">Callback for the server result</param> /// <param name="cbArg">Callback arguments for the result when needed</param> public void DeclineActiveList(IqHandler cb) { /* * In order to decline the use of any active list, the connected resource MUST send an empty <active/> element * with no 'name' attribute. * * Example: Client declines the use of active lists: * * <iq from='[email protected]/orchard' type='set' id='active3'> * <query xmlns='jabber:iq:privacy'> * <active/> * </query> * </iq> * * Example: Server acknowledges success of declining any active list: * * <iq type='result' id='active3' to='[email protected]/orchard'/> */ PrivacyIq pIq = new PrivacyIq(); pIq.Type = agsXMPP.protocol.client.IqType.set; pIq.Query.Active = new Active(); SendStanza(pIq, cb); }
/// <summary> /// Retrieving all Privacy Lists /// </summary> /// <param name="cb">Callback for the server result</param> /// <param name="cbArg">Callback arguments for the result when needed</param> public void GetLists(IqHandler cb) { /* * Example: Client requests names of privacy lists from server: * * <iq from='[email protected]/orchard' type='get' id='getlist1'> * <query xmlns='jabber:iq:privacy'/> * </iq> * * Example: Server sends names of privacy lists to client, preceded by active list and default list: * * <iq type='result' id='getlist1' to='[email protected]/orchard'> * <query xmlns='jabber:iq:privacy'> * <active name='private'/> * <default name='public'/> * <list name='public'/> * <list name='private'/> * <list name='special'/> * </query> * </iq> * */ PrivacyIq pIq = new PrivacyIq(); pIq.Type = agsXMPP.protocol.client.IqType.get; SendStanza(pIq, cb); }
/// <summary> /// Requests a privacy list from the server by its name /// </summary> /// <param name="name">name of the privacy list to retrieve</param> /// <param name="cb">Callback for the server result</param> /// <param name="cbArg">Callback arguments for the result when needed</param> public void GetList(string name, IqHandler cb) { /* * Example: Client requests a privacy list from server: * * <iq from='[email protected]/orchard' type='get' id='getlist2'> * <query xmlns='jabber:iq:privacy'> * <list name='public'/> * </query> * </iq> * * Example: Server sends a privacy list to client: * * <iq type='result' id='getlist2' to='[email protected]/orchard'> * <query xmlns='jabber:iq:privacy'> * <list name='public'> * <item type='jid' * value='*****@*****.**' * action='deny' * order='1'/> * <item action='allow' order='2'/> * </list> * </query> * </iq> * */ PrivacyIq pIq = new PrivacyIq(); pIq.Type = agsXMPP.protocol.client.IqType.get; pIq.Query.AddList(new List(name)); SendStanza(pIq, cb); }
public void CreateNode(Jid to, Jid from, string node, bool defaultConfig, IqHandler cb) { PubSubIq pubsubIq = new PubSubIq(IqType.set, to); if (from != null) { pubsubIq.From = from; } pubsubIq.PubSub.Create = new Create(node); if (defaultConfig) { pubsubIq.PubSub.Configure = new Configure(); } if (cb == null) { m_connection.Send(pubsubIq); } else { m_connection.IqGrabber.SendIq(pubsubIq, cb); } }
public ChatClient(IPEndPoint endPoint, bool ssl) { TcpClient = new TcpStringClient(endPoint, ssl); PresenceManager = new PresenceManager(this); IqManager = new IqHandler(this); MessageManager = new MessageManager(this); AuthHandler = new AuthHandler(this); }
/// <summary> /// Remove a privacy list /// </summary> /// <param name="name">name of the privacy list to remove</param> /// <param name="cb">Callback for the server result</param> /// <param name="cbArg">Callback arguments for the result when needed</param> public void RemoveList(string name, IqHandler cb) { PrivacyIq pIq = new PrivacyIq(); pIq.Type = agsXMPP.protocol.client.IqType.set; pIq.Query.AddList(new List(name)); SendStanza(pIq, cb); }
/// <summary> /// Change the default list /// </summary> /// <param name="name">name of the new default list</param> /// <param name="cb">Callback for the server result</param> /// <param name="cbArg">Callback arguments for the result when needed</param> public void ChangeDefaultList(string name, IqHandler cb) { PrivacyIq pIq = new PrivacyIq(); pIq.Type = agsXMPP.protocol.client.IqType.set; pIq.Query.Default = new Default(name); SendStanza(pIq, cb); }
/// <summary> /// Decline the use of the default list /// </summary> /// <param name="cb">Callback for the server result</param> /// <param name="cbArg">Callback arguments for the result when needed</param> public void DeclineDefaultList(IqHandler cb) { PrivacyIq pIq = new PrivacyIq(); pIq.Type = agsXMPP.protocol.client.IqType.set; pIq.Query.Default = new Default(); SendStanza(pIq, cb); }
/// <summary> /// Request the bookmarks from the storage on the server /// </summary> /// <param name="cb"></param> /// <param name="cbArgs"></param> public void RequestBookmarks(IqHandler cb) { StorageIq siq = new StorageIq(IqType.get); if (cb == null) m_connection.Send(siq); else m_connection.IqGrabber.SendIq(siq, cb); }
public async Task ConnectSSL(string host, AuthCred cred) { PresenceManager = new PresenceManager(this); IqManager = new IqHandler(this); await TcpClient.ConnectSSL(host); TcpClient.SendString( $"<stream:stream to=\"{host}\" xml:lang=\"*\" version=\"1.0\" xmlns:stream=\"http://etherx.jabber.org/streams\" xmlns=\"jabber:client\">"); AuthCred = cred; }
/// <summary> /// Sends a PrivacyIq over the active connection /// </summary> /// <param name="pIq"></param> /// <param name="cb"></param> /// <param name="cbArg"></param> private void SendStanza(PrivacyIq pIq, IqHandler cb) { if (cb == null) { m_connection.Send(pIq); } else { m_connection.IqGrabber.SendIq(pIq, cb); } }
/// <summary> /// Request the bookmarks from the storage on the server /// </summary> /// <param name="cb"></param> /// <param name="cbArgs"></param> public void RequestBookmarks(IqHandler cb) { StorageIq siq = new StorageIq(IqType.get); if (cb == null) { m_connection.Send(siq); } else { m_connection.IqGrabber.SendIq(siq, cb); } }
/// <summary> /// Update the list with the given name and rules. /// </summary> /// <remarks> /// Specify the desired changes to the list by including all elements/rules in the list /// (not the "delta") /// </remarks> /// <param name="name">name of this list</param> /// <param name="rules">rules of this list</param> /// <param name="cb">Callback for the server result</param> /// <param name="cbArg">Callback arguments for the result when needed</param> public void UpdateList(string name, Item[] rules, IqHandler cb) { PrivacyIq pIq = new PrivacyIq(); pIq.Type = agsXMPP.protocol.client.IqType.set; // create a new list with the given name List list = new List(name); list.AddItems(rules); // add the list to the query pIq.Query.AddList(list); SendStanza(pIq, cb); }
/// <summary> /// Send an IQ Request and store the object with callback in the Hashtable /// </summary> /// <param name="iq">The iq to send</param> /// <param name="cb">the callback function which gets raised for the response</param> public void SendIq(IQ iq, IqHandler cb) { // check if the callback is null, in case of wrong usage of this class if (cb == null) { throw new ArgumentNullException("cb"); } if (iq == null) { throw new ArgumentNullException("cb"); } m_grabbing[iq.Id] = cb; m_connection.Send(iq); }
public void DiscoverInformation(Jid to, Jid from, string node, IqHandler cb) { /* * * Example 9. Querying a specific JID and node combination * * <iq type='get' * from='[email protected]/orchard' * to='mim.shakespeare.lit' * id='info3'> * <query xmlns='http://jabber.org/protocol/disco#info' * node='http://jabber.org/protocol/commands'/> * </iq> * * * Example 10. JID+node result * * <iq type='result' * from='mim.shakespeare.lit' * to='[email protected]/orchard' * id='info3'> * <query xmlns='http://jabber.org/protocol/disco#info' * node='http://jabber.org/protocol/commands'> * <identity * category='automation' * type='command-list'/> * </query> * </iq> */ DiscoInfoIq discoIq = new DiscoInfoIq(IqType.get); discoIq.To = to; if (from != null) { discoIq.From = from; } if (node != null && node.Length > 0) { discoIq.Query.Node = node; } xmppConnection.IqGrabber.SendIq(discoIq, cb); }
public void DiscoverItems(Jid to, Jid from, string node, IqHandler cb) { DiscoItemsIq discoIq = new DiscoItemsIq(IqType.get); discoIq.To = to; if (from != null) { discoIq.From = from; } if (node != null && node.Length > 0) { discoIq.Query.Node = node; } xmppConnection.IqGrabber.SendIq(discoIq, cb); }
public void OwnerRequestSubscribers(Jid to, Jid from, string node, IqHandler cb) { owner.PubSubIq pubsubIq = new owner.PubSubIq(IqType.get, to); if (from != null) { pubsubIq.From = from; } pubsubIq.PubSub.Subscribers = new agsXMPP.protocol.extensions.pubsub.owner.Subscribers(node); if (cb == null) { m_connection.Send(pubsubIq); } else { m_connection.IqGrabber.SendIq(pubsubIq, cb); } }
public void RequestAffiliations(Jid to, Jid from, IqHandler cb) { PubSubIq pubsubIq = new PubSubIq(IqType.get, to); if (from != null) { pubsubIq.From = from; } pubsubIq.PubSub.Affiliations = new Affiliations(); if (cb == null) { m_connection.Send(pubsubIq); } else { m_connection.IqGrabber.SendIq(pubsubIq, cb); } }
public void CreateInstantNode(Jid to, Jid from, IqHandler cb) { PubSubIq pubsubIq = new PubSubIq(IqType.set, to); if (from != null) { pubsubIq.From = from; } pubsubIq.PubSub.Create = new Create(); if (cb == null) { m_connection.Send(pubsubIq); } else { m_connection.IqGrabber.SendIq(pubsubIq, cb); } }
public void Subscribe(Jid to, Jid from, Jid subscribe, string node, IqHandler cb) { PubSubIq pubsubIq = new PubSubIq(IqType.set, to); if (from != null) { pubsubIq.From = from; } pubsubIq.PubSub.Subscribe = new Subscribe(node, subscribe); if (cb == null) { m_connection.Send(pubsubIq); } else { m_connection.IqGrabber.SendIq(pubsubIq, cb); } }
public void OwnerRequestAffiliations(Jid to, Jid from, string node, IqHandler cb) { owner.PubSubIq pubsubIq = new owner.PubSubIq(IqType.get, to); if (from != null) { pubsubIq.From = from; } pubsubIq.PubSub.Affiliates = new owner.Affiliates(node); if (cb == null) { m_connection.Send(pubsubIq); } else { m_connection.IqGrabber.SendIq(pubsubIq, cb); } }
public void PurgeNode(Jid to, Jid from, string node, IqHandler cb) { owner.PubSubIq pubsubIq = new owner.PubSubIq(IqType.set, to); if (from != null) { pubsubIq.From = from; } pubsubIq.PubSub.Purge = new owner.Purge(node); if (cb == null) { m_connection.Send(pubsubIq); } else { m_connection.IqGrabber.SendIq(pubsubIq, cb); } }
public void RetractItem(Jid to, Jid from, string node, string id, IqHandler cb) { PubSubIq pubsubIq = new PubSubIq(IqType.set, to); if (from != null) { pubsubIq.From = from; } pubsubIq.PubSub.Retract = new Retract(node, id); if (cb == null) { m_connection.Send(pubsubIq); } else { m_connection.IqGrabber.SendIq(pubsubIq, cb); } }
/// <summary> /// Change the active list /// </summary> /// <param name="name"></param> /// <param name="cb">Callback for the server result</param> /// <param name="cbArg">Callback arguments for the result when needed</param> public void ChangeActiveList(string name, IqHandler cb) { /* * Example: Client requests change of active list: * * <iq from='[email protected]/orchard' type='set' id='active1'> * <query xmlns='jabber:iq:privacy'> * <active name='special'/> * </query> * </iq> * * The server MUST activate and apply the requested list before sending the result back to the client. * * Example: Server acknowledges success of active list change: * * <iq type='result' id='active1' to='[email protected]/orchard'/> * * If the user attempts to set an active list but a list by that name does not exist, the server MUST return an <item-not-found/> stanza error to the user: * * Example: Client attempts to set a non-existent list as active: * * <iq to='[email protected]/orchard' type='error' id='active2'> * <query xmlns='jabber:iq:privacy'> * <active name='The Empty Set'/> * </query> * <error type='cancel'> * <item-not-found * xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> * </error> * </iq> * */ PrivacyIq pIq = new PrivacyIq(); pIq.Type = agsXMPP.protocol.client.IqType.set; pIq.Query.Active = new Active(name); SendStanza(pIq, cb); }
/// <summary> /// Send booksmarks to the server storage /// </summary> /// <param name="urls"></param> /// <param name="conferences"></param> /// <param name="cb"></param> /// <param name="cbArgs"></param> public void StoreBookmarks(Url[] urls, Conference[] conferences, IqHandler cb) { StorageIq siq = new StorageIq(IqType.set); if (urls != null) { siq.Query.Storage.AddUrls(urls); } if (conferences != null) { siq.Query.Storage.AddConferences(conferences); } if (cb == null) { m_connection.Send(siq); } else { m_connection.IqGrabber.SendIq(siq, cb); } }
/// <summary> /// Publish a payload to a Node /// </summary> /// <param name="to"></param> /// <param name="from"></param> /// <param name="node"></param> /// <param name="payload"></param> /// <param name="cb"></param> public void PublishItem(Jid to, Jid from, string node, Item payload, IqHandler cb) { PubSubIq pubsubIq = new PubSubIq(IqType.set, to); if (from != null) { pubsubIq.From = from; } Publish publish = new Publish(node); publish.AddItem(payload); pubsubIq.PubSub.Publish = publish; if (cb == null) { m_connection.Send(pubsubIq); } else { m_connection.IqGrabber.SendIq(pubsubIq, cb); } }
/// <summary> /// Add a new list with the given name and rules. /// </summary> /// <param name="name"></param> /// <param name="rules"></param> ///// <param name="cb">Callback for the server result</param> /// <param name="cbArg">Callback arguments for the result when needed</param> public void AddList(string name, Item[] rules, IqHandler cb) { UpdateList(name, rules, cb); }
/// <summary> /// Sends a PrivacyIq over the active connection /// </summary> /// <param name="pIq"></param> /// <param name="cb"></param> /// <param name="cbArg"></param> private void SendStanza(PrivacyIq pIq, IqHandler cb) { if (cb == null) m_connection.Send(pIq); else m_connection.IqGrabber.SendIq(pIq, cb); }
public void Subscribe(Jid to, Jid from, Jid subscribe, string node, IqHandler cb) { PubSubIq pubsubIq = new PubSubIq(IqType.set, to); if (from != null) pubsubIq.From = from; pubsubIq.PubSub.Subscribe = new Subscribe(node, subscribe); if (cb == null) m_connection.Send(pubsubIq); else m_connection.IqGrabber.SendIq(pubsubIq, cb); }
public void DiscoverItems(Jid to, Jid from, IqHandler cb) { DiscoverItems(to, from, null, cb); }
public void DiscoverInformation(Jid to, string node, IqHandler cb) { DiscoverInformation(to, null, node, cb); }
/// <summary> /// Send booksmarks to the server storage /// </summary> /// <param name="urls"></param> /// <param name="conferences"></param> /// <param name="cb"></param> /// <param name="cbArgs"></param> public void StoreBookmarks(Url[] urls, Conference[] conferences, IqHandler cb) { StorageIq siq = new StorageIq(IqType.set); if (urls != null) siq.Query.Storage.AddUrls(urls); if (conferences != null) siq.Query.Storage.AddConferences(conferences); if (cb == null) m_connection.Send(siq); else m_connection.IqGrabber.SendIq(siq, cb); }
/// <summary> /// Send booksmarks to the server storage /// </summary> /// <param name="conferences"></param> /// <param name="cb"></param> /// <param name="cbArgs"></param> public void StoreBookmarks(Conference[] conferences, IqHandler cb) { StoreBookmarks(null, conferences, cb); }
public void DiscoverInformation(Jid to, Jid from, string node, IqHandler cb) { /* Example 9. Querying a specific JID and node combination <iq type='get' from='[email protected]/orchard' to='mim.shakespeare.lit' id='info3'> <query xmlns='http://jabber.org/protocol/disco#info' node='http://jabber.org/protocol/commands'/> </iq> Example 10. JID+node result <iq type='result' from='mim.shakespeare.lit' to='[email protected]/orchard' id='info3'> <query xmlns='http://jabber.org/protocol/disco#info' node='http://jabber.org/protocol/commands'> <identity category='automation' type='command-list'/> </query> </iq> */ DiscoInfoIq discoIq = new DiscoInfoIq(IqType.get); discoIq.To = to; if (from != null) discoIq.From = from; if (node != null && node.Length > 0) discoIq.Query.Node = node; xmppConnection.IqGrabber.SendIq(discoIq, cb); }
public void CreateCollectionNode(Jid to, string node, bool defaultConfig, IqHandler cb) { CreateCollectionNode(to, null, node, defaultConfig, cb); }
public void RetractItem(Jid to, string node, string id, IqHandler cb) { RetractItem(to, null, node, id, cb); }
public void DiscoverItems(Jid to, Jid from, string node, IqHandler cb) { DiscoItemsIq discoIq = new DiscoItemsIq(IqType.get); discoIq.To = to; if (from != null) discoIq.From = from; if (node != null && node.Length > 0) discoIq.Query.Node = node; xmppConnection.IqGrabber.SendIq(discoIq, cb); }
public void DiscoverItems(Jid to, string node, IqHandler cb) { DiscoverItems(to, null, node, cb); }
/// <summary> /// Change the active list /// </summary> /// <param name="name"></param> /// <param name="cb">Callback for the server result</param> /// <param name="cbArg">Callback arguments for the result when needed</param> public void ChangeActiveList(string name, IqHandler cb) { /* Example: Client requests change of active list: <iq from='[email protected]/orchard' type='set' id='active1'> <query xmlns='jabber:iq:privacy'> <active name='special'/> </query> </iq> The server MUST activate and apply the requested list before sending the result back to the client. Example: Server acknowledges success of active list change: <iq type='result' id='active1' to='[email protected]/orchard'/> If the user attempts to set an active list but a list by that name does not exist, the server MUST return an <item-not-found/> stanza error to the user: Example: Client attempts to set a non-existent list as active: <iq to='[email protected]/orchard' type='error' id='active2'> <query xmlns='jabber:iq:privacy'> <active name='The Empty Set'/> </query> <error type='cancel'> <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> </error> </iq> */ PrivacyIq pIq = new PrivacyIq(); pIq.Type = agsXMPP.protocol.client.IqType.set; pIq.Query.Active = new Active(name); SendStanza(pIq, cb); }
public void Unsubscribe(Jid to, Jid from, Jid unsubscribe, string node, IqHandler cb) { Unsubscribe(to, from, unsubscribe, node, cb); }
public void RetractItem(Jid to, Jid from, string node, string id, IqHandler cb) { PubSubIq pubsubIq = new PubSubIq(IqType.set, to); if (from != null) pubsubIq.From = from; pubsubIq.PubSub.Retract = new Retract(node, id); if (cb == null) m_connection.Send(pubsubIq); else m_connection.IqGrabber.SendIq(pubsubIq, cb); }
public void DiscoverItems(Jid to, IqHandler cb) { DiscoverItems(to, null, null, cb); }
public void Unsubscribe(Jid to, Jid unsubscribe, string node, string subid, IqHandler cb) { Unsubscribe(to, null, unsubscribe, node, subid, cb); }
public void Unsubscribe(Jid to, Jid from, Jid unsubscribe, string node, string subid, IqHandler cb) { PubSubIq pubsubIq = new PubSubIq(IqType.set, to); if (from != null) pubsubIq.From = from; Unsubscribe unsub = new Unsubscribe(node, unsubscribe); if (subid != null) unsub.SubId = subid; pubsubIq.PubSub.Unsubscribe = unsub; if (cb == null) m_connection.Send(pubsubIq); else m_connection.IqGrabber.SendIq(pubsubIq, cb); }
public void DiscoverInformation(Jid to, Jid from, IqHandler cb) { DiscoverInformation(to, from, null, cb); }
/// <summary> /// Send booksmarks to the server storage /// </summary> /// <param name="urls"></param> /// <param name="cb"></param> /// <param name="cbArgs"></param> public void StoreBookmarks(Url[] urls, IqHandler cb) { StoreBookmarks(urls, null, cb); }
/// <summary> /// Decline the use of any active list /// </summary> /// <param name="cb">Callback for the server result</param> /// <param name="cbArg">Callback arguments for the result when needed</param> public void DeclineActiveList(IqHandler cb) { /* In order to decline the use of any active list, the connected resource MUST send an empty <active/> element with no 'name' attribute. Example: Client declines the use of active lists: <iq from='[email protected]/orchard' type='set' id='active3'> <query xmlns='jabber:iq:privacy'> <active/> </query> </iq> Example: Server acknowledges success of declining any active list: <iq type='result' id='active3' to='[email protected]/orchard'/> */ PrivacyIq pIq = new PrivacyIq(); pIq.Type = agsXMPP.protocol.client.IqType.set; pIq.Query.Active = new Active(); SendStanza(pIq, cb); }
public void CreateCollectionNode(Jid to, Jid from, string node, bool defaultConfig, IqHandler cb) { PubSubIq pubsubIq = new PubSubIq(IqType.set, to); if (from != null) pubsubIq.From = from; pubsubIq.PubSub.Create = new Create(node, Type.collection); if (defaultConfig) pubsubIq.PubSub.Configure = new Configure(); if (cb == null) m_connection.Send(pubsubIq); else m_connection.IqGrabber.SendIq(pubsubIq, cb); }
/// <summary> /// Requests a privacy list from the server by its name /// </summary> /// <param name="name">name of the privacy list to retrieve</param> /// <param name="cb">Callback for the server result</param> /// <param name="cbArg">Callback arguments for the result when needed</param> public void GetList(string name, IqHandler cb) { /* Example: Client requests a privacy list from server: <iq from='[email protected]/orchard' type='get' id='getlist2'> <query xmlns='jabber:iq:privacy'> <list name='public'/> </query> </iq> Example: Server sends a privacy list to client: <iq type='result' id='getlist2' to='[email protected]/orchard'> <query xmlns='jabber:iq:privacy'> <list name='public'> <item type='jid' value='*****@*****.**' action='deny' order='1'/> <item action='allow' order='2'/> </list> </query> </iq> */ PrivacyIq pIq = new PrivacyIq(); pIq.Type = agsXMPP.protocol.client.IqType.get; pIq.Query.AddList(new List(name)); SendStanza(pIq, cb); }
/// <summary> /// Retrieving all Privacy Lists /// </summary> /// <param name="cb">Callback for the server result</param> /// <param name="cbArg">Callback arguments for the result when needed</param> public void GetLists(IqHandler cb) { /* Example: Client requests names of privacy lists from server: <iq from='[email protected]/orchard' type='get' id='getlist1'> <query xmlns='jabber:iq:privacy'/> </iq> Example: Server sends names of privacy lists to client, preceded by active list and default list: <iq type='result' id='getlist1' to='[email protected]/orchard'> <query xmlns='jabber:iq:privacy'> <active name='private'/> <default name='public'/> <list name='public'/> <list name='private'/> <list name='special'/> </query> </iq> */ PrivacyIq pIq = new PrivacyIq(); pIq.Type = agsXMPP.protocol.client.IqType.get; SendStanza(pIq, cb); }
public void Subscribe(Jid to, Jid subscribe, string node, IqHandler cb) { Subscribe(to, null, subscribe, node, cb); }