MakeId() публичный статический Метод

public static MakeId ( string prefix ) : string
prefix string
Результат string
Пример #1
0
        protected void SendQrSync(byte[] qrkey, byte[] token = null)
        {
            string id = TicketCounter.MakeId();
            List <ProtocolTreeNode> children = new List <ProtocolTreeNode>();

            children.Add(new ProtocolTreeNode("sync", null, qrkey));
            if (token != null)
            {
                children.Add(new ProtocolTreeNode("code", null, token));
            }
            ProtocolTreeNode node = new ProtocolTreeNode("iq", new[] {
                new KeyValue("type", "set"),
                new KeyValue("id", id),
                new KeyValue("xmlns", "w:web")
            }, children.ToArray());

            this.SendNode(node);
        }
Пример #2
0
        public void SendSetPrivacySetting(VisibilityCategory category, VisibilitySetting setting)
        {
            ProtocolTreeNode node = new ProtocolTreeNode("iq", new[] {
                new KeyValue("to", "s.whatsapp.net"),
                new KeyValue("id", TicketCounter.MakeId()),
                new KeyValue("type", "set"),
                new KeyValue("xmlns", "privacy")
            }, new ProtocolTreeNode[] {
                new ProtocolTreeNode("privacy", null, new ProtocolTreeNode[] {
                    new ProtocolTreeNode("category", new [] {
                        new KeyValue("name", this.privacyCategoryToString(category)),
                        new KeyValue("value", this.privacySettingToString(setting))
                    })
                })
            });

            this.SendNode(node);
        }
Пример #3
0
        public void SendSetPrivacySetting(WhatsAPI.UniversalApps.Libs.Constants.Enums.VisibilityCategory category, WhatsAPI.UniversalApps.Libs.Constants.Enums.VisibilitySetting setting)
        {
            ProtocolTreeNode node = new ProtocolTreeNode("iq", new[] {
                new KeyValue("to", "s.whatsapp.net"),
                new KeyValue("id", TicketCounter.MakeId("setprivacy_")),
                new KeyValue("type", "set"),
                new KeyValue("xmlns", "privacy")
            }, new ProtocolTreeNode[] {
                new ProtocolTreeNode("privacy", null, new ProtocolTreeNode[] {
                    new ProtocolTreeNode("category", new [] {
                        new KeyValue("name", this.privacyCategoryToString(category)),
                        new KeyValue("value", this.privacySettingToString(setting))
                    })
                })
            });

            this.SendNode(node);
        }
Пример #4
0
        public string SendGetPhoto(string jid, string expectedPhotoId, bool largeFormat)
        {
            string id       = TicketCounter.MakeId();
            var    attrList = new List <KeyValue>();

            if (!largeFormat)
            {
                attrList.Add(new KeyValue("type", "preview"));
            }
            if (expectedPhotoId != null)
            {
                attrList.Add(new KeyValue("id", expectedPhotoId));
            }
            var child = new ProtocolTreeNode("picture", attrList.ToArray());
            var node  = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("xmlns", "w:profile:picture"), new KeyValue("to", WhatsAppApi.WhatsApp.GetJID(jid)) }, child);

            this.SendNode(node);
            return(id);
        }
Пример #5
0
        public void SendGetGroupInfo(string gjid)
        {
            string id = TicketCounter.MakeId("get_g_info_");
            //this.AddIqHandler(id, new FunXMPP.IqResultHandler(delegate(FunXMPP.ProtocolTreeNode node, string from)
            //{
            //    FunXMPP.ProtocolTreeNode child = node.GetChild(0);
            //    FunXMPP.ProtocolTreeNode.Require(child, "group");
            //    child.GetAttributeValue("id");
            //    string owner = child.GetAttributeValue("owner");
            //    string attributeValue = child.GetAttributeValue("subject");
            //    string s = child.GetAttributeValue("s_t");
            //    string str4 = child.GetAttributeValue("s_o");
            //    string str5 = child.GetAttributeValue("creation");
            //    this.GroupEventHandler.OnGroupInfo(from, owner, attributeValue, str4, int.Parse(s, CultureInfo.InvariantCulture), int.Parse(str5, CultureInfo.InvariantCulture));
            //}));
            var child = new ProtocolTreeNode("query", new[] { new KeyValue("xmlns", "w:g") });
            var node  = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("to", gjid) }, new ProtocolTreeNode[] { child });

            this.whatsNetwork.SendNode(node);
        }
Пример #6
0
        /// <summary>
        /// Make a reques to the Whatsapp servers to delete a specific account.
        /// </summary>
        /// <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 SendDeleteAccount(Action onSuccess, Action <int> onError)
        {
            string id   = TicketCounter.MakeId("del_acct_");
            var    node = new ProtocolTreeNode("iq",
                                               new[]
            {
                new KeyValue("id", id), new KeyValue("type", "get"),
                new KeyValue("to", "s.whatsapp.net")
            },
                                               new ProtocolTreeNode[]
            {
                new ProtocolTreeNode("remove",
                                     new[]
                {
                    new KeyValue("xmlns", "urn:xmpp:whatsapp:account")
                })
            });

            this.whatsNetwork.SendData(this._binWriter.Write(node));
        }
Пример #7
0
        public void SendDeleteAccount()
        {
            string id   = TicketCounter.MakeId();
            var    node = new ProtocolTreeNode("iq",
                                               new KeyValue[]
            {
                new KeyValue("id", id),
                new KeyValue("type", "get"),
                new KeyValue("to", "s.whatsapp.net"),
                new KeyValue("xmlns", "urn:xmpp:whatsapp:account")
            },
                                               new ProtocolTreeNode[]
            {
                new ProtocolTreeNode("remove",
                                     null
                                     )
            });

            this.SendNode(node);
        }
Пример #8
0
    public void SendGetPhoto(string jid, string expectedPhotoId, bool largeFormat, Action onComplete)
    {
        string id       = TicketCounter.MakeId("get_photo_");
        var    attrList = new List <KeyValue> {
            new KeyValue("xmlns", "w:profile:picture")
        };

        if (!largeFormat)
        {
            attrList.Add(new KeyValue("type", "preview"));
        }
        if (expectedPhotoId != null)
        {
            attrList.Add(new KeyValue("id", expectedPhotoId));
        }
        var child = new ProtocolTreeNode("picture", attrList.ToArray());
        var node  = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("to", jid) }, child);

        this.whatsNetwork.SendData(this._binWriter.Write(node));
    }
Пример #9
0
        public void SendGetStatuses(string[] jids)
        {
            List <ProtocolTreeNode> targets = new List <ProtocolTreeNode>();

            foreach (string jid in jids)
            {
                targets.Add(new ProtocolTreeNode("user", new[] { new KeyValue("jid", GetJID(jid)) }, null, null));
            }

            ProtocolTreeNode node = new ProtocolTreeNode("iq", new[] {
                new KeyValue("to", "s.whatsapp.net"),
                new KeyValue("type", "get"),
                new KeyValue("xmlns", "status"),
                new KeyValue("id", TicketCounter.MakeId())
            }, new[] {
                new ProtocolTreeNode("status", null, targets.ToArray(), null)
            }, null);

            this.SendNode(node);
        }
Пример #10
0
        public void SendDeleteAccount(Action onSuccess, Action <int> onError)
        {
            string id = TicketCounter.MakeId("del_acct_");
            //this.AddIqHandler(id, new FunXMPP.IqResultHandler((node, from) => onSuccess(), onError));
            var node = new ProtocolTreeNode("iq",
                                            new[]
            {
                new KeyValue("id", id), new KeyValue("type", "get"),
                new KeyValue("to", "s.whatsapp.net")
            },
                                            new ProtocolTreeNode[]
            {
                new ProtocolTreeNode("remove",
                                     new[]
                {
                    new KeyValue("xmlns", "urn:xmpp:whatsapp:account")
                })
            });

            this.whatsNetwork.SendNode(node);
        }
Пример #11
0
        public void SendClearDirty(IEnumerable <string> categoryNames)
        {
            string id = TicketCounter.MakeId("clean_dirty_");
            List <ProtocolTreeNode> children = new List <ProtocolTreeNode>();

            foreach (string category in categoryNames)
            {
                ProtocolTreeNode cat = new ProtocolTreeNode("clean", new[] { new KeyValue("type", category) });
                children.Add(cat);
            }
            var node = new ProtocolTreeNode("iq",
                                            new[]
            {
                new KeyValue("id", id),
                new KeyValue("type", "set"),
                new KeyValue("to", "s.whatsapp.net"),
                new KeyValue("xmlns", "urn:xmpp:whatsapp:dirty")
            }, children);

            this.SendNode(node);
        }
Пример #12
0
        public void SendQueryLastOnline(string jid)
        {
            string id = TicketCounter.MakeId("last_");
            //this.AddIqHandler(id, new IqResultHandler(delegate(ProtocolTreeNode node, string from)
            //{
            //    int num;
            //    ProtocolTreeNode child = node.GetChild(0);
            //    ProtocolTreeNode.Require(child, "query");
            //    string s = child.GetAttributeValue("seconds");
            //    string dataString = null;
            //    dataString = child.GetDataString();
            //    if (((s != null) && (from != null)) && int.TryParse(s, WhatsAppNumberStyle, CultureInfo.InvariantCulture, out num))
            //    {
            //        this.EventHandler.OnLastSeen(from, num, dataString);
            //    }
            //}));
            var child = new ProtocolTreeNode("query", new[] { new KeyValue("xmlns", "jabber:iq:last") });
            var node  = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("to", jid) }, child);

            this.whatsNetwork.SendNode(node);
        }
Пример #13
0
        public void SendGetPhoto(string jid, string expectedPhotoId, bool largeFormat, Action onComplete)
        {
            string id = TicketCounter.MakeId("get_photo_");
            //this.AddIqHandler(id, new FunXMPP.IqResultHandler(delegate(FunXMPP.ProtocolTreeNode node, string from)
            //{
            //    string x = node.GetAttributeValue("type");
            //    if (StringComparer.Ordinal.Equals(x, "result") && (this.EventHandler != null))
            //    {
            //        foreach (FunXMPP.ProtocolTreeNode node2 in node.children ?? new FunXMPP.ProtocolTreeNode[0])
            //        {
            //            if (FunXMPP.ProtocolTreeNode.TagEquals(node2, "picture"))
            //            {
            //                string attributeValue = node2.GetAttributeValue("id");
            //                if (((attributeValue != null) && (node2.data != null)) && (node2.data.Length != 0))
            //                {
            //                    this.EventHandler.OnPhotoData(attributeValue, node2.data, jid, largeFormat);
            //                    this.EventHandler.OnPhotoChanged(jid, null, attributeValue);
            //                }
            //            }
            //        }
            //    }
            //    onComplete();
            //}, error => onComplete()));
            var attrList = new List <KeyValue> {
                new KeyValue("xmlns", "w:profile:picture")
            };

            if (!largeFormat)
            {
                attrList.Add(new KeyValue("type", "preview"));
            }
            if (expectedPhotoId != null)
            {
                attrList.Add(new KeyValue("id", expectedPhotoId));
            }
            var child = new ProtocolTreeNode("picture", attrList.ToArray());
            var node  = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("to", jid) }, child);

            this.whatsNetwork.SendNode(node);
        }
Пример #14
0
        public void SendGetServerProperties()
        {
            string id = TicketCounter.MakeId("get_server_properties_");
            //this.AddIqHandler(id, new IqResultHandler(delegate(ProtocolTreeNode node, string from)
            //{
            //    var enumerable = from n in node.GetAllChildren("props")
            //                     select n.GetAllChildren("prop") into propNode
            //                     select new { Name = propNode.GetAttributeValue("name"), Value = propNode.GetAttributeValue("value") };
            //    Dictionary<string, string> nameValueMap = new Dictionary<string, string>();
            //    foreach (var typeb in enumerable)
            //    {
            //        if ((typeb.Name != null) && (typeb.Value != null))
            //        {
            //            nameValueMap[typeb.Name] = typeb.Value;
            //        }
            //    }
            //    this.GroupEventHandler.OnServerProperties(nameValueMap);
            //}));
            var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("to", "s.whatsapp.net") },
                                            new ProtocolTreeNode("props", new[] { new KeyValue("xmlns", "w") }));

            this.whatsNetwork.SendNode(node);
        }
Пример #15
0
        public void SendGetClientConfig()
        {
            string id = TicketCounter.MakeId("get_config_");
            //this.AddIqHandler(id, new FunXMPP.IqResultHandler(delegate(FunXMPP.ProtocolTreeNode node, string from)
            //{
            //    FunXMPP.ProtocolTreeNode child = node.GetChild(0);
            //    FunXMPP.ProtocolTreeNode.Require(child, "config");
            //    string attributeValue = child.GetAttributeValue("id");
            //    this.EventHandler.OnClientConfigReceived(attributeValue);
            //}, delegate(FunXMPP.ProtocolTreeNode node)
            //{
            //    foreach (string str in from configNode in node.GetAllChildren("config")
            //                           where configNode != null
            //                           select configNode.GetAttributeValue("id"))
            //    {
            //        this.EventHandler.OnClientConfigReceived(str);
            //    }
            //}));
            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", this.whatsAppRealm) }, new ProtocolTreeNode[] { child });

            this.whatsNetwork.SendNode(node);
        }
Пример #16
0
        public void SendLeaveGroups(IEnumerable <string> gjids, Action onSuccess, Action <int> onError)
        {
            string id = TicketCounter.MakeId("leave_group_");
            //this.AddIqHandler(id, new IqResultHandler(delegate (ProtocolTreeNode node, string from) {
            //    ProtocolTreeNode child = node.GetChild("leave");
            //    if (child != null)
            //    {
            //        foreach (string str in from group in child.GetAllChildren("group") select group.GetAttributeValue("id"))
            //        {
            //            this.GroupEventHandler.OnLeaveGroup(str);
            //        }
            //    }
            //    if (onSuccess != null)
            //    {
            //        onSuccess();
            //    }
            //}, onError));
            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.SendNode(node);
        }
Пример #17
0
        public void SendGetOwningGroups()
        {
            string id = TicketCounter.MakeId();

            this.SendGetGroups(id, "owning");
        }
Пример #18
0
        public void SendGetGroups()
        {
            string id = TicketCounter.MakeId();

            this.SendGetGroups(id, "participating");
        }
Пример #19
0
        public void SendAddParticipants(string gjid, IEnumerable <string> participants)
        {
            string id = TicketCounter.MakeId();

            this.SendVerbParticipants(gjid, participants, id, "add");
        }
Пример #20
0
        /// <summary>
        /// Request to remove participants from a group
        /// </summary>
        /// <param name="gjid">The group jabber id</param>
        /// <param name="participants">A list of participants</param>
        /// <param name="onSuccess">Action to execute when the request was successful</param>
        /// <param name="onError">Action to execute when the request failed</param>
        public void SendRemoveParticipants(string gjid, List <string> participants, Action onSuccess, Action <int> onError)
        {
            string id = TicketCounter.MakeId("remove_group_participants_");

            this.SendVerbParticipants(gjid, participants, id, "remove");
        }
Пример #21
0
        /// <summary>
        /// Make a request to retrieve all groups where the client is participating in
        /// </summary>
        /// <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 SendGetGroups(Action onSuccess, Action <int> onError)
        {
            string id = TicketCounter.MakeId("get_groups_");

            this.SendGetGroups(id, "participating");
        }
Пример #22
0
        public void SendRemoveParticipants(string gjid, List <string> participants)
        {
            string id = TicketCounter.MakeId();

            this.SendVerbParticipants(gjid, participants, id, "remove");
        }
Пример #23
0
        /// <summary>
        /// Sends a request to the server to add participants to a group chat
        /// </summary>
        /// <param name="gjid">Group jabber id</param>
        /// <param name="participants">A list of participants (List of jids)</param>
        /// <param name="onSuccess">The action to be executed when the request is successfull.</param>
        /// <param name="onError">The action to be executed when the request fails</param>
        public void SendAddParticipants(string gjid, IEnumerable <string> participants, Action onSuccess, Action <int> onError)
        {
            string id = TicketCounter.MakeId("add_group_participants_");

            this.SendVerbParticipants(gjid, participants, id, "add");
        }