TReKiE / msnp-sharp

Automatically exported from code.google.com/p/msnp-sharp
0 stars 0 forks source link

ADL & {lockkey} problems #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
ADL
'Add List' command, uses XML to identify each contact, and works as a
payload message. Each ADL command may contain up to 150 contacts (a payload
of roughly 7500 bytes). The format of the payload looks like this: 

Code is:

NS15MessageHandler.cs (new)
--------------------

        private int adlcount = 0;
        private string[] ConstructADLString()
        {
            Dictionary<string, List<string>> d = new Dictionary<string,
List<string>>();

            string domain = "";
            string name = "";
            string type = "";
            string list = "";

            foreach (Contact contact in ContactList.All)
            {
                list = "";
                domain = contact.Mail.Split('@')[1];
                name = contact.Mail.Split('@')[0].Replace('ı', 'i');
                type = ((int)contact.ClientType).ToString();
                if (contact.OnForwardList)
                {
                    list = "3";
                }
                if (contact.OnBlockedList)
                {
                    list = ((int)(MSNLists.BlockedList)).ToString();
                }
                if (contact.OnAllowedList && !contact.OnForwardList)
                {
                    list = ((int)(MSNLists.AllowedList)).ToString();
                }

                if (!d.ContainsKey(domain.ToLower()))
                {
                    d[domain.ToLower()] = new List<string>();
                }

                d[domain.ToLower()].Add(
                                    "<c n=\"" + name + "\" l=\""
                                    + list
                                    + "\" t=\"" + type + "\"/>"
                );
            }

            List<string> ret = new List<string>();
            foreach (string dom in d.Keys)
            {
                adlcount++;
                int cnt = 0;
                string stmp = "<d n=\"" + dom + "\">";
                foreach (string c in d[dom])
                {
                    stmp += c;

                    if (++cnt == 150)
                    {
                        stmp += "</d>";
                        ret.Add("<ml l=\"1\">" + stmp + "</ml>");
                        stmp = "<d n=\"" + dom + "\">";
                        cnt = 0;
                        adlcount++;
                    }
                }

                stmp += "</d>";
                ret.Add("<ml l=\"1\">" + stmp + "</ml>");
            }

            return ret.ToArray();
        }

public virtual void SynchronizeContactList()

 {
                foreach (string ret in ConstructADLString())
                {
                    MessageProcessor.SendMessage(new NSMessage("ADL", new
string[] { Encoding.UTF8.GetByteCount(ret).ToString() }));
                    //MessageProcessor.SendMessage(new NSMessage("ADL", new
string[] { ret.Length.ToString() }));
                    MessageProcessor.SendMessage(new NSMessage(ret));
                }
            }

private void OnADLReceived(NSMessage message)
        {
            if (message.CommandValues[1].ToString() == "OK" && synSended ==
false && --adlcount <= 0)
{

                synSended = true;
                adlcount = 0;

 {lockkey} problems
------------------
SendOIMMessage()

reqsoap.Replace("{lockkey}", _Tickets.ContainsKey("lock_key") ?
HttpUtility.HtmlEncode(_Tickets["lock_key"]) : "");

// BASE64: Base64FormattingOptions.InsertLineBreaks
                reqsoap.Replace("{base64_msg}",
Convert.ToBase64String(Encoding.UTF8.GetBytes(msg),
Base64FormattingOptions.InsertLineBreaks));

NS15MessageHandler.cs // NOT _Tickets.Add, _Tickets["lock_key"] = md;
-----------------
protected virtual void OnCHLReceived(NSMessage message)
        {
            if (Credentials == null)
                throw new MSNPSharpException("No credentials available for
the NSMSNP11 handler. No challenge answer could be send.");

            clsQRYFactory qryfactory = new clsQRYFactory();
            string md = qryfactory.CreateQRY(Credentials.ClientID,
Credentials.ClientCode, message.CommandValues[1].ToString());
            _Tickets["lock_key"] = md;
            MessageProcessor.SendMessage(new NSMessage("QRY", new string[]
{ " " + Credentials.ClientID, " 32\r\n", md }));
        }

Original issue reported on code.google.com by hepha...@gmail.com on 7 Apr 2008 at 12:48

GoogleCodeExporter commented 9 years ago
Thanks,I will fix it soon.

Original comment by freezing...@gmail.com on 9 Apr 2008 at 4:54

GoogleCodeExporter commented 9 years ago

Original comment by hepha...@gmail.com on 9 Apr 2008 at 5:13