public void SendQueryLastOnline(string jid) { string id = TicketCounter.MakeId("last_"); var child = new ProtocolTreeNode("query", null); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("to", GetJID(jid)), new KeyValue("xmlns", "jabber:iq:last") }, child); this.SendNode(node); }
public void SendSetGroupSubject(string gjid, string subject) { string id = TicketCounter.MakeId("set_group_subject_"); var child = new ProtocolTreeNode("subject", new[] { new KeyValue("value", subject) }); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "set"), new KeyValue("xmlns", "w:g"), new KeyValue("to", gjid) }, child); this.SendNode(node); }
public void SendGetServerProperties() { string id = TicketCounter.MakeId("get_server_properties_"); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("xmlns", "w"), new KeyValue("to", "s.whatsapp.net") }, new ProtocolTreeNode("props", null)); this.SendNode(node); }
public void SendPing() { string id = TicketCounter.MakeId("ping_"); var child = new ProtocolTreeNode("ping", new[] { new KeyValue("xmlns", "w:p") }); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get") }, child); this.SendNode(node); }
public void SendGetParticipants(string gjid) { string id = TicketCounter.MakeId("get_participants_"); var child = new ProtocolTreeNode("list", null); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("xmlns", "w:g"), new KeyValue("to", WhatsApp.GetJID(gjid)) }, child); this.SendNode(node); }
public void SendGetGroupInfo(string gjid) { string id = TicketCounter.MakeId("get_g_info_"); var child = new ProtocolTreeNode("query", null); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("xmlns", "w:g"), new KeyValue("to", WhatsAppApi.WhatsApp.GetJID(gjid)) }, new ProtocolTreeNode[] { child }); this.SendNode(node); }
public void SendGetDirty() { string id = TicketCounter.MakeId("get_dirty_"); var child = new ProtocolTreeNode("status", new[] { new KeyValue("xmlns", "urn:xmpp:whatsapp:dirty") }); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("to", "s.whatsapp.net") }, new ProtocolTreeNode[] { child }); this.SendNode(node); }
public void SendClientConfig(string platform, string lg, string lc) { string v = TicketCounter.MakeId("config_"); var child = new ProtocolTreeNode("config", new[] { new KeyValue("xmlns", "urn:xmpp:whatsapp:push"), new KeyValue("platform", platform), new KeyValue("lg", lg), new KeyValue("lc", lc) }); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", v), new KeyValue("type", "set"), new KeyValue("to", WhatsConstants.WhatsAppRealm) }, new ProtocolTreeNode[] { child }); this.SendNode(node); }
public void SendCreateGroupChat(string subject) { string id = TicketCounter.MakeId("create_group_"); var child = new ProtocolTreeNode("group", new[] { new KeyValue("action", "create"), new KeyValue("subject", subject) }); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "set"), new KeyValue("xmlns", "w:g"), new KeyValue("to", "g.us") }, new ProtocolTreeNode[] { child }); this.SendNode(node); }
public void SendEndGroupChat(string gjid) { string id = TicketCounter.MakeId("remove_group_"); var child = new ProtocolTreeNode("group", new[] { new KeyValue("action", "delete") }); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "set"), new KeyValue("xmlns", "w:g"), new KeyValue("to", gjid) }, new ProtocolTreeNode[] { child }); this.SendNode(node); }
public void SendGetClientConfig() { string id = TicketCounter.MakeId("get_config_"); var child = new ProtocolTreeNode("config", new[] { new KeyValue("xmlns", "urn:xmpp:whatsapp:push") }); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("to", WhatsConstants.WhatsAppRealm) }, new ProtocolTreeNode[] { child }); this.SendNode(node); }
/// <summary> /// Make a request to leave multiple groups at the same time. /// </summary> /// <param name="gjids">The group jabber id.</param> /// <param name="onSuccess">The action to be executed when the request was successful.</param> /// <param name="onError">The action to be executed when the request failed.</param> public void SendLeaveGroups(IEnumerable <string> gjids, Action onSuccess, Action <int> onError) { string id = TicketCounter.MakeId("leave_group_"); IEnumerable <ProtocolTreeNode> innerChilds = from gjid in gjids select new ProtocolTreeNode("group", new[] { new KeyValue("id", gjid) }); var child = new ProtocolTreeNode("leave", new KeyValue[] { new KeyValue("xmlns", "w:g") }, innerChilds); var node = new ProtocolTreeNode("iq", new KeyValue[] { new KeyValue("id", id), new KeyValue("type", "set"), new KeyValue("to", "g.us") }, child); this.whatsNetwork.SendData(this._binWriter.Write(node)); }
/// <summary> /// Make a request to retrieve a list of privacy's /// </summary> public void SendGetPrivacyList() { string id = TicketCounter.MakeId("privacylist_"); var innerChild = new ProtocolTreeNode("list", new[] { new KeyValue("name", "default") }); var child = new ProtocolTreeNode("query", new KeyValue[] { new KeyValue("xmlns", "jabber:iq:privacy") }, innerChild); var node = new ProtocolTreeNode("iq", new KeyValue[] { new KeyValue("id", id), new KeyValue("type", "get") }, child); this.whatsNetwork.SendData(this._binWriter.Write(node)); }
/// <summary> /// Make a request to retrieve a list of photo id's /// </summary> /// <param name="jids">The list of jabber id's the photos need to be retrieved of.</param> public void SendGetPhotoIds(IEnumerable <string> jids) { string id = TicketCounter.MakeId("get_photo_id_"); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("to", this.MyJID) }, new ProtocolTreeNode("list", new[] { new KeyValue("xmlns", "w:profile:picture") }, (from jid in jids select new ProtocolTreeNode("user", new[] { new KeyValue("jid", jid) })).ToArray <ProtocolTreeNode>())); this.whatsNetwork.SendData(this._binWriter.Write(node)); }
// Constructor public Repository() { // For every entry in Food Price Dictionary, // add an entry into TicketCounter dictionary. foreach (var item in Prices) { TicketCounter.Add(item.Key, 0); } }
public void SendGetPhotoIds(IEnumerable <string> jids) { string id = TicketCounter.MakeId(); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("to", GetJID(this.phoneNumber)) }, new ProtocolTreeNode("list", new[] { new KeyValue("xmlns", "w:profile:picture") }, (from jid in jids select new ProtocolTreeNode("user", new[] { new KeyValue("jid", jid) })).ToArray <ProtocolTreeNode>())); this.SendNode(node); }
public void SendPing() { string id = TicketCounter.MakeId("ping_"); //this.AddIqHandler(id, new IqResultHandler((node, from) => this.EventHandler.OnPingResponseReceived(), node => this.EventHandler.OnPingResponseReceived())); var child = new ProtocolTreeNode("ping", new[] { new KeyValue("xmlns", "w:p") }); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get") }, child); this.whatsNetwork.SendNode(node); }
public void SendGetPrivacyList() { string id = TicketCounter.MakeId(); var innerChild = new ProtocolTreeNode("list", new[] { new KeyValue("name", "default") }); var child = new ProtocolTreeNode("query", null, innerChild); var node = new ProtocolTreeNode("iq", new KeyValue[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("xmlns", "jabber:iq:privacy") }, child); this.SendNode(node); }
public void SendCreateGroupChat(string subject, IEnumerable <string> participants) { string id = TicketCounter.MakeId(); IEnumerable <ProtocolTreeNode> participant = from jid in participants select new ProtocolTreeNode("participant", new[] { new KeyValue("jid", GetJID(jid)) }); var child = new ProtocolTreeNode("create", new[] { new KeyValue("subject", subject) }, new ProtocolTreeNode[] { (ProtocolTreeNode)participant }); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "set"), new KeyValue("xmlns", "w:g2"), new KeyValue("to", "g.us") }, new ProtocolTreeNode[] { child }); this.SendNode(node); }
public void SendDeleteFromRoster(string jid) { string v = TicketCounter.MakeId(); var innerChild = new ProtocolTreeNode("item", new[] { new KeyValue("jid", jid), new KeyValue("subscription", "remove") }); var child = new ProtocolTreeNode("query", new[] { new KeyValue("xmlns", "jabber:iq:roster") }, new ProtocolTreeNode[] { innerChild }); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("type", "set"), new KeyValue("id", v) }, new ProtocolTreeNode[] { child }); this.SendNode(node); }
public static string GenerateId() { if (_instance == null) { _instance = new TicketManager(); } return(IdBase + "-" + TicketCounter.NextTicket()); }
public void SendLeaveGroups(IEnumerable <string> gjids) { string id = TicketCounter.MakeId(); IEnumerable <ProtocolTreeNode> innerChilds = from gjid in gjids select new ProtocolTreeNode("group", new[] { new KeyValue("id", gjid) }); var child = new ProtocolTreeNode("leave", null, innerChilds); var node = new ProtocolTreeNode("iq", new KeyValue[] { new KeyValue("id", id), new KeyValue("type", "set"), new KeyValue("xmlns", "w:g2"), new KeyValue("to", "g.us") }, child); this.SendNode(node); }
public void Message(string to, string txt) { //var bodyNode = new ProtocolTreeNode("body", null, txt); var tmpMessage = new FMessage(to, true) { key = { id = TicketCounter.MakeId("mSend_") }, data = txt }; this.WhatsParser.WhatsSendHandler.SendMessage(tmpMessage); }
public void CountTicketsPiterAlgorithmTest(int maxlimit, int expectedCount) { TicketCounter counter = new TicketCounter(new PiterAlgorithm()); int actualTicketCounts; //Act actualTicketCounts = counter.CountTickets((uint)maxlimit); //Assert Assert.AreEqual(expectedCount, actualTicketCounts); }
public void SendSetPrivacyBlockedList(IEnumerable <string> jidSet) { string id = TicketCounter.MakeId(); ProtocolTreeNode[] nodeArray = Enumerable.Select <string, ProtocolTreeNode>(jidSet, (Func <string, int, ProtocolTreeNode>)((jid, index) => new ProtocolTreeNode("item", new KeyValue[] { new KeyValue("type", "jid"), new KeyValue("value", jid), new KeyValue("action", "deny"), new KeyValue("order", index.ToString(CultureInfo.InvariantCulture)) }))).ToArray <ProtocolTreeNode>(); var child = new ProtocolTreeNode("list", new KeyValue[] { new KeyValue("name", "default") }, (nodeArray.Length == 0) ? null : nodeArray); var node2 = new ProtocolTreeNode("query", null, child); var node3 = new ProtocolTreeNode("iq", new KeyValue[] { new KeyValue("id", id), new KeyValue("type", "set"), new KeyValue("xmlns", "jabber:iq:privacy") }, node2); this.SendNode(node3); }
public void SendGetOwningGroups() { string id = TicketCounter.MakeId("get_owning_groups_"); //this.AddIqHandler(id, new FunXMPP.IqResultHandler(delegate(FunXMPP.ProtocolTreeNode node, string from) //{ // List<string> list = new List<string>(); // this.ReadGroupList(node, list); // this.GroupEventHandler.OnOwningGroups(list); //})); this.SendGetGroups(id, "owning"); }
public void SendSetPrivacyBlockedList(IEnumerable <string> jidSet, Action onSuccess, Action <int> onError) { string id = TicketCounter.MakeId("privacy_"); //this.AddIqHandler(id, new IqResultHandler((node, from) => onSuccess(), onError)); ProtocolTreeNode[] nodeArray = Enumerable.Select <string, ProtocolTreeNode>(jidSet, (Func <string, int, ProtocolTreeNode>)((jid, index) => new ProtocolTreeNode("item", new KeyValue[] { new KeyValue("type", "jid"), new KeyValue("value", jid), new KeyValue("action", "deny"), new KeyValue("order", index.ToString(CultureInfo.InvariantCulture)) }))).ToArray <ProtocolTreeNode>(); var child = new ProtocolTreeNode("list", new KeyValue[] { new KeyValue("name", "default") }, (nodeArray.Length == 0) ? null : nodeArray); var node2 = new ProtocolTreeNode("query", new KeyValue[] { new KeyValue("xmlns", "jabber:iq:privacy") }, child); var node3 = new ProtocolTreeNode("iq", new KeyValue[] { new KeyValue("id", id), new KeyValue("type", "set") }, node2); this.whatsNetwork.SendNode(node3); }
public void SendGetPrivacySettings() { ProtocolTreeNode node = new ProtocolTreeNode("iq", new KeyValue[] { new KeyValue("to", "s.whatsapp.net"), new KeyValue("id", TicketCounter.MakeId()), new KeyValue("type", "get"), new KeyValue("xmlns", "privacy") }, new ProtocolTreeNode[] { new ProtocolTreeNode("privacy", null) }); this.SendNode(node); }
public void SendGetBroadcastLists() { string id = TicketCounter.MakeId(); var listNode = new ProtocolTreeNode("lists", null); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("to", "s.whatsapp.net"), new KeyValue("id", id), new KeyValue("xmlns", "w:b"), new KeyValue("type", "get") }, new[] { listNode }); SendNode(node); }
public void SendClearDirty(IEnumerable <string> categoryNames) { string id = TicketCounter.MakeId("clean_dirty_"); IEnumerable <ProtocolTreeNode> source = from category in categoryNames select new ProtocolTreeNode("category", new[] { new KeyValue("name", category) }); var child = new ProtocolTreeNode("clean", new[] { new KeyValue("xmlns", "urn:xmpp:whatsapp:dirty") }, source); var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "set"), new KeyValue("to", "s.whatsapp.net") }, child); this.whatsNetwork.SendData(this._binWriter.Write(node)); }