Exemple #1
0
 private void DataReceivedCallback(IAsyncResult ar)
 {
     if ((this.socket != null) && this.socket.Connected)
       {
     int num2;
     int num1 = 0;
     try
     {
           num1 = this.socket.EndReceive(ar);
           if (num1 <= 0)
           {
                 this.CloseConnection();
           }
     }
     catch (ObjectDisposedException)
     {
           return;
     }
     this.totalMessage = this.totalMessage + this.TextEncoding.GetString(this.socketBuffer, 0, num1);
     while ((num2 = this.totalMessage.IndexOf("\r\n")) > 0)
     {
           Contact contact6;
           Contact contact8;
           object[] objArray1;
           string text6;
           string text1 = this.totalMessage.Substring(0, num2);
           this.totalMessage = this.totalMessage.Remove(0, num2 + 2);
           if (this.MessageReceived != null)
           {
                 this.MessageReceived(this, text1);
           }
           Match match1 = Messenger.messageRe.Match(text1);
           if (!match1.Success)
           {
                 continue;
           }
           text1 = match1.Groups["Message"].ToString();
           switch (match1.Groups[1].ToString())
           {
                 case "CHL":
                 {
                       match1 = Messenger.RunRegularExpression(Messenger.CHLRe, text1);
                       if (match1.Success)
                       {
                             string text2 = this.HashMD5(match1.Groups["Hash"].ToString() + "Q1P7W2E4J9R8U3S5");
                             objArray1 = new object[4] { "QRY ", this.NewTrans(), " [email protected] 32\r\n", text2 } ;
                             this.SocketSend(string.Concat(objArray1));
                       }
                       continue;
                 }
                 case "ILN":
                 {
                       goto Label_033D;
                 }
                 case "NLN":
                 {
                       goto Label_0401;
                 }
                 case "FLN":
                 {
                       goto Label_04D2;
                 }
                 case "LST":
                 {
                       goto Label_0557;
                 }
                 case "XFR":
                 {
                       goto Label_07CE;
                 }
                 case "RNG":
                 {
                       goto Label_092F;
                 }
                 case "BPR":
                 {
                       match1 = Messenger.RunRegularExpression(Messenger.BPRRe7, text1);
                       if (!match1.Success)
                       {
                             goto Label_0BCA;
                       }
                       contact6 = this.GetContact(match1.Groups["Mail"].ToString());
                       goto Label_0AE3;
                 }
                 case "LSG":
                 {
                       goto Label_0CF8;
                 }
                 case "SYN":
                 {
                       goto Label_0D79;
                 }
                 case "REA":
                 {
                       match1 = Messenger.RunRegularExpression(Messenger.REARe, text1);
                       if (match1.Success)
                       {
                             if ((this.owner == null) || (match1.Groups["Mail"].ToString() != this.owner.mail))
                             {
                                   goto Label_0E81;
                             }
                             this.owner.SetName(match1.Groups["Name"].ToString());
                       }
                       continue;
                 }
                 case "ADD":
                 {
                       goto Label_0EBF;
                 }
                 case "REM":
                 {
                       goto Label_0FC4;
                 }
                 case "BLP":
                 {
                       match1 = Messenger.RunRegularExpression(Messenger.BLPRe, text1);
                       if (!match1.Success || (this.owner == null))
                       {
                             continue;
                       }
                       goto Label_10DB;
                 }
                 case "GTC":
                 {
                       match1 = Messenger.RunRegularExpression(Messenger.GTCRe, text1);
                       if (!match1.Success || (this.owner == null))
                       {
                             continue;
                       }
                       goto Label_1168;
                 }
                 case "ADG":
                 {
                       goto Label_11C7;
                 }
                 case "RMG":
                 {
                       goto Label_1269;
                 }
                 case "REG":
                 {
                       goto Label_12ED;
                 }
                 case "MSG":
                 {
                       goto Label_1395;
                 }
                 default:
                 {
                       goto Label_140D;
                 }
           }
     Label_033D:
           match1 = Messenger.RunRegularExpression(Messenger.ILNRe, text1);
           if (!match1.Success)
           {
                 continue;
           }
           Contact contact1 = this.GetContact(match1.Groups["Mail"].ToString());
           contact1.SetName(match1.Groups["Name"].ToString());
           MSNStatus status1 = contact1.Status;
           contact1.SetStatus(this.ParseStatus(match1.Groups["Status"].ToString()));
           if (((status1 == MSNStatus.Unknown) || (status1 == MSNStatus.Offline)) && (this.ContactOnline != null))
           {
                 this.ContactOnline(this, new ContactEventArgs(contact1));
           }
           if (this.ContactStatusChange != null)
           {
                 this.ContactStatusChange(this, new ContactStatusChangeEventArgs(contact1, status1));
           }
           continue;
     Label_0401:
           match1 = Messenger.RunRegularExpression(Messenger.NLNRe, text1);
           if (!match1.Success)
           {
                 continue;
           }
           Contact contact2 = this.GetContact(match1.Groups["Mail"].ToString());
           contact2.SetName(match1.Groups["Name"].ToString());
           MSNStatus status2 = contact2.status;
           contact2.SetStatus(this.ParseStatus(match1.Groups["Status"].ToString()));
           if (this.ContactStatusChange != null)
           {
                 this.ContactStatusChange(this, new ContactStatusChangeEventArgs(contact2, status2));
           }
           match1.Groups["Name"].ToString();
           if (this.ContactOnline != null)
           {
                 this.ContactOnline(this, new ContactEventArgs(contact2));
           }
           continue;
     Label_04D2:
           if (!(match1 = Messenger.FLNRe.Match(text1)).Success)
           {
                 continue;
           }
           Contact contact3 = this.GetContact(match1.Groups["Mail"].ToString());
           MSNStatus status3 = contact3.status;
           contact3.SetStatus(MSNStatus.Offline);
           if (this.ContactStatusChange != null)
           {
                 this.ContactStatusChange(this, new ContactStatusChangeEventArgs(contact3, status3));
           }
           if (this.ContactOffline != null)
           {
                 this.ContactOffline(this, new ContactEventArgs(contact3));
           }
           continue;
     Label_0557:
           this.syncContactsCount--;
           match1 = Messenger.RunRegularExpression(Messenger.LSTRe7, text1);
           if (match1.Success)
           {
                 Contact contact4 = this.GetContact(match1.Groups["Mail"].ToString());
                 MSNList list1 = this.GetMSNList(match1.Groups["Type"].ToString());
                 contact4.lists |= list1;
                 contact4.SetName(match1.Groups["Name"].ToString());
                 if (match1.Groups["GroupID"].ToString().Length > 0)
                 {
                       contact4.SetContactGroup(int.Parse(match1.Groups["GroupID"].ToString()));
                 }
                 contact4.updateVersion = int.Parse(match1.Groups["Version"].ToString());
                 if (match1.Groups["Nr"].ToString() == match1.Groups["Total"].ToString())
                 {
                       MSNList list2 = this.GetMSNList(match1.Groups["Type"].ToString());
                       if (this.ListReceived != null)
                       {
                             this.ListReceived(this, new ListReceivedEventArgs(list2));
                       }
                 }
                 continue;
           }
           match1 = Messenger.RunRegularExpression(Messenger.LSTRe8, text1);
           if (!match1.Success)
           {
                 continue;
           }
           Contact contact5 = this.GetContact(match1.Groups["Mail"].ToString());
           this.lastContactSynced = contact5;
           contact5.lists = (MSNList) int.Parse(match1.Groups["Lists"].ToString());
           contact5.updateVersion = this.lastSync;
           contact5.SetName(match1.Groups["Name"].ToString());
           char[] chArray1 = new char[1] { ',' } ;
           string[] textArray1 = match1.Groups["Groups"].ToString().Split(chArray1);
           string[] textArray2 = textArray1;
           for (int num11 = 0; num11 < textArray2.Length; num11++)
           {
                 string text3 = textArray2[num11];
                 if (text3 != "")
                 {
                       contact5.SetContactGroup(int.Parse(text3));
                 }
           }
           if ((this.syncContactsCount <= 0) && (this.SynchronizationCompleted != null))
           {
                 this.SynchronizationCompleted(this, new EventArgs());
           }
           continue;
     Label_07CE:
           match1 = Messenger.RunRegularExpression(Messenger.XFRRe, text1);
           if (!match1.Success)
           {
                 continue;
           }
           IPEndPoint point1 = new IPEndPoint(IPAddress.Parse(match1.Groups["IP"].ToString()), int.Parse(match1.Groups["Port"].ToString()));
           Socket socket1 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
           socket1.Connect(point1);
           if (!socket1.Connected)
           {
                 this.log.Add("Could not connect");
                 objArray1 = new object[4] { "Could not connect to switchboard server @ ", match1.Groups["IP"], ":", match1.Groups["Port"] } ;
                 throw new MSNException(string.Concat(objArray1));
           }
           if (this.conversationQueue.Count <= 0)
           {
                 throw new MSNException("Server sends chatanswer but there are no conversations left in the queue");
           }
           Conversation conversation1 = (Conversation) this.conversationQueue.Dequeue();
           conversation1.SetConnection(socket1, match1.Groups["Hash"].ToString());
           this.conversationList.Add(conversation1);
           conversation1.ConnectionClosed += new Conversation.ConnectionClosedHandler(this.conversation_ConnectionClosed);
           if (this.ConversationCreated != null)
           {
                 this.ConversationCreated(this, new ConversationEventArgs(conversation1));
           }
           conversation1.InitiateRequest();
           continue;
     Label_092F:
           match1 = Messenger.RunRegularExpression(Messenger.RNGRe, text1);
           if (!match1.Success)
           {
                 continue;
           }
           IPEndPoint point2 = new IPEndPoint(IPAddress.Parse(match1.Groups["IP"].ToString()), int.Parse(match1.Groups["Port"].ToString()));
           Socket socket2 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
           socket2.Connect(point2);
           if (!socket2.Connected)
           {
                 this.log.Add("Could not connect");
                 objArray1 = new object[4] { "Could not connect to switchboard server @ ", match1.Groups["IP"], ":", match1.Groups["Port"] } ;
                 throw new MSNException(string.Concat(objArray1));
           }
           Conversation conversation2 = new Conversation(socket2, match1.Groups["Hash"].ToString(), this.GetContact(match1.Groups["Mail"].ToString()), this, int.Parse(match1.Groups["Session"].ToString()));
           this.conversationList.Add(conversation2);
           conversation2.ConnectionClosed += new Conversation.ConnectionClosedHandler(this.conversation_ConnectionClosed);
           if (this.ConversationCreated != null)
           {
                 this.ConversationCreated(this, new ConversationEventArgs(conversation2));
           }
           conversation2.InitiateAnswer();
           continue;
     Label_0AE3:
           if ((text6 = match1.Groups["Type"].ToString()) == null)
           {
                 continue;
           }
           text6 = string.IsInterned(text6);
           if (text6 != "PHH")
           {
                 if (text6 == "PHW")
                 {
                       goto Label_0B58;
                 }
                 if (text6 == "PHM")
                 {
                       goto Label_0B7E;
                 }
                 if (text6 == "MOB")
                 {
                       goto Label_0BA4;
                 }
                 continue;
           }
           contact6.homePhone = HttpUtility.UrlDecode(match1.Groups["Value"].ToString());
           continue;
     Label_0B58:
           contact6.workPhone = HttpUtility.UrlDecode(match1.Groups["Value"].ToString());
           continue;
     Label_0B7E:
           contact6.mobilePhone = HttpUtility.UrlDecode(match1.Groups["Value"].ToString());
           continue;
     Label_0BA4:
           contact6.mobilePager = HttpUtility.UrlDecode(match1.Groups["Value"].ToString());
           continue;
     Label_0BCA:
           match1 = Messenger.RunRegularExpression(Messenger.BPRRe8, text1);
           if (!match1.Success)
           {
                 continue;
           }
           Contact contact7 = this.lastContactSynced;
           if (contact7 == null)
           {
                 throw new MSNException("Phone numbers are sent but lastContact == null");
           }
           if ((text6 = match1.Groups["Type"].ToString()) == null)
           {
                 continue;
           }
           text6 = string.IsInterned(text6);
           if (text6 != "PHH")
           {
                 if (text6 == "PHW")
                 {
                       goto Label_0C7B;
                 }
                 if (text6 == "PHM")
                 {
                       goto Label_0CA1;
                 }
                 if (text6 == "MOB")
                 {
                       goto Label_0CC7;
                 }
                 continue;
           }
           contact7.homePhone = HttpUtility.UrlDecode(match1.Groups["Value"].ToString());
           continue;
     Label_0C7B:
           contact7.workPhone = HttpUtility.UrlDecode(match1.Groups["Value"].ToString());
           continue;
     Label_0CA1:
           contact7.mobilePhone = HttpUtility.UrlDecode(match1.Groups["Value"].ToString());
           continue;
     Label_0CC7:
           contact7.mobilePager = HttpUtility.UrlDecode(match1.Groups["Value"].ToString());
           continue;
     Label_0CF8:
           match1 = Messenger.RunRegularExpression(Messenger.LSGRe, text1);
           if (!match1.Success)
           {
                 continue;
           }
           try
           {
                 this.contactGroups.Add(int.Parse(match1.Groups["GroupID"].ToString()), new ContactGroup(match1.Groups["Name"].ToString(), int.Parse(match1.Groups["GroupID"].ToString()), this));
                 continue;
           }
           catch (FormatException)
           {
                 continue;
           }
     Label_0D79:
           match1 = Messenger.RunRegularExpression(Messenger.SYNRe, text1);
           if (!match1.Success)
           {
                 continue;
           }
           int num3 = int.Parse(match1.Groups["SyncID"].ToString());
           if (this.lastSync == num3)
           {
                 this.syncContactsCount = 0;
                 if (this.SynchronizationCompleted != null)
                 {
                       this.SynchronizationCompleted(this, new EventArgs());
                 }
                 continue;
           }
           this.lastSync = num3;
           this.lastContactSynced = null;
           string text4 = match1.Groups["UsersCount"].Value;
           this.syncContactsCount = int.Parse(text4);
           continue;
     Label_0E81:
           contact8 = this.GetContact(match1.Groups["Mail"].ToString());
           contact8.SetName(match1.Groups["Name"].ToString());
           continue;
     Label_0EBF:
           match1 = Messenger.RunRegularExpression(Messenger.ADDRe, text1);
           if (!match1.Success)
           {
                 continue;
           }
           MSNList list3 = this.GetMSNList(match1.Groups["Type"].ToString());
           Contact contact9 = this.GetContact(match1.Groups["Mail"].ToString());
           contact9.SetName(match1.Groups["Name"].ToString());
           int num4 = 0;
           if (match1.Groups["Group"].ToString().Length > 0)
           {
                 num4 = int.Parse(match1.Groups["Group"].ToString());
           }
           contact9.AddToList(list3);
           if (num4 > 0)
           {
                 contact9.SetContactGroup(num4);
           }
           if ((list3 == MSNList.ReverseList) && (this.ReverseAdded != null))
           {
                 this.ReverseAdded(this, new ContactEventArgs(contact9));
           }
           if (this.ContactAdded != null)
           {
                 this.ContactAdded(this, new ListMutateEventArgs(contact9, list3));
           }
           continue;
     Label_0FC4:
           match1 = Messenger.RunRegularExpression(Messenger.REMRe, text1);
           if (!match1.Success)
           {
                 continue;
           }
           MSNList list4 = this.GetMSNList(match1.Groups["Type"].ToString());
           Contact contact10 = this.GetContact(match1.Groups["Mail"].ToString());
           int num5 = 0;
           if (match1.Groups["Group"].ToString().Length > 0)
           {
                 num5 = int.Parse(match1.Groups["Group"].ToString());
           }
           contact10.RemoveFromList(list4);
           if (num5 > 0)
           {
                 contact10.SetContactGroup(num5);
           }
           if ((list4 == MSNList.ReverseList) && (this.ReverseRemoved != null))
           {
                 this.ReverseRemoved(this, new ContactEventArgs(contact10));
           }
           if (this.ContactRemoved != null)
           {
                 this.ContactRemoved(this, new ListMutateEventArgs(contact10, list4));
           }
           continue;
     Label_10DB:
           if ((text6 = match1.Groups["Mode"].ToString()) == null)
           {
                 continue;
           }
           text6 = string.IsInterned(text6);
           if (text6 != "AL")
           {
                 if (text6 == "BL")
                 {
                       goto Label_1129;
                 }
                 continue;
           }
           this.owner.privacy = MSNPrivacy.AllExceptBlocked;
           continue;
     Label_1129:
           this.owner.privacy = MSNPrivacy.NoneButAllowed;
           continue;
     Label_1168:
           if ((text6 = match1.Groups["Mode"].ToString()) == null)
           {
                 continue;
           }
           text6 = string.IsInterned(text6);
           if (text6 != "A")
           {
                 if (text6 == "N")
                 {
                       goto Label_11B6;
                 }
                 continue;
           }
           this.owner.notifyPrivacy = MSNNotifyPrivacy.PromptOnAdd;
           continue;
     Label_11B6:
           this.owner.notifyPrivacy = MSNNotifyPrivacy.AutomaticAdd;
           continue;
     Label_11C7:
           match1 = Messenger.RunRegularExpression(Messenger.ADG, text1);
           if (!match1.Success)
           {
                 continue;
           }
           try
           {
                 int num6 = int.Parse(match1.Groups["GroupID"].ToString());
                 this.contactGroups[num6] = new ContactGroup(Messenger.URLDecode(match1.Groups["Name"].ToString()), num6, this);
                 if (this.ContactGroupAdded != null)
                 {
                       this.ContactGroupAdded(this, new ContactGroupEventArgs((ContactGroup) this.contactGroups[num6]));
                 }
                 continue;
           }
           catch (Exception)
           {
                 continue;
           }
     Label_1269:
           match1 = Messenger.RunRegularExpression(Messenger.RMG, text1);
           if (!match1.Success)
           {
                 continue;
           }
           try
           {
                 int num7 = int.Parse(match1.Groups["GroupID"].ToString());
                 ContactGroup group1 = (ContactGroup) this.contactGroups[num7];
                 this.contactGroups.Remove(num7);
                 if (this.ContactGroupRemoved != null)
                 {
                       this.ContactGroupRemoved(this, new ContactGroupEventArgs(group1));
                 }
                 continue;
           }
           catch (Exception)
           {
                 continue;
           }
     Label_12ED:
           match1 = Messenger.RunRegularExpression(Messenger.REG, text1);
           if (!match1.Success)
           {
                 continue;
           }
           try
           {
                 int num8 = int.Parse(match1.Groups["GroupID"].ToString());
                 ContactGroup group2 = (ContactGroup) this.contactGroups[num8];
                 group2.Name = Messenger.URLDecode(match1.Groups["Name"].ToString());
                 if (this.ContactGroupChanged != null)
                 {
                       this.ContactGroupChanged(this, new ContactGroupEventArgs((ContactGroup) this.contactGroups[num8]));
                 }
                 continue;
           }
           catch (Exception)
           {
                 continue;
           }
     Label_1395:
           if (!(match1 = Messenger.MSGRe.Match(match1.Groups["Message"].ToString())).Success)
           {
                 continue;
           }
           try
           {
                 int num9 = int.Parse(match1.Groups["Length"].ToString());
                 string text5 = this.totalMessage.Substring(0, num9);
                 this.totalMessage = this.totalMessage.Remove(0, num9);
                 this.ParseHotmailMessages(text5);
                 continue;
           }
           catch (FormatException)
           {
                 continue;
           }
     Label_140D:
           try
           {
                 int num10 = int.Parse(match1.Groups[1].ToString());
                 if (this.ErrorReceived != null)
                 {
                       this.ErrorReceived(this, new MSNErrorEventArgs((MSNError) Enum.ToObject(typeof(MSNError), num10)));
                 }
                 continue;
           }
           catch (FormatException)
           {
                 continue;
           }
     }
     this.socketBuffer = new byte[this.socketBuffer.Length];
     if (this.socket.Connected)
     {
           try
           {
                 this.socket.BeginReceive(this.socketBuffer, 0, this.socketBuffer.Length, SocketFlags.None, new AsyncCallback(this.DataReceivedCallback), new object());
           }
           catch (SocketException exception1)
           {
                 if (this.ConnectionFailure != null)
                 {
                       this.ConnectionFailure(this, new ConnectionErrorEventArgs(exception1));
                 }
                 return;
           }
     }
       }
 }
 // Methods
 public ConversationEventArgs(Conversation conversation)
 {
     this.Conversation = conversation;
 }
Exemple #3
0
 public Conversation RequestConversation(string mail, object clientData)
 {
     Conversation conversation1 = new Conversation(this, this.GetContact(mail), clientData);
       this.conversationQueue.Enqueue(conversation1);
       this.SocketSend("XFR " + this.NewTrans() + " SB\r\n");
       return conversation1;
 }
Exemple #4
0
 private void conversation_ConnectionClosed(Conversation sender, EventArgs e)
 {
     this.conversationList.Remove(sender);
 }
Exemple #5
0
 private void OnConversationReceived(Conversation sender, MessageEventArgs e)
 {
     Console.Text = sender.Messenger.Owner.Name + "User said: " + e.Message.Text;
     ind = pi.chatWithPrelude(e.Message.Text);
     Console.Text = "I, Prelude, say: " + ind ;
     sender.SendMessage(ind);
     if(e.Message.Text == "exit__")
         pi.stopPreludeEngine();
 }
Exemple #6
0
 private void ContactTyping(Conversation sender, ContactEventArgs e)
 {
     //Console.WriteLine(e.Contact.Name + " is typing");
 }
Exemple #7
0
        private void ContactJoined(Conversation sender, ContactEventArgs e)
        {
            // someone joined our conversation! remember that this also occurs when you are
            // only talking to 1 other person. Log this event.
            Console.Text = e.Contact.Name + " joined the conversation.\r\n";

            // now say something back. You can send messages using the Conversation object.
            sender.SendMessage("Hello world!");
        }
Exemple #8
0
 private void ConnectionEstablished(Conversation sender, EventArgs e)
 {
     Console.Text = "connection established.\r\n";
 }
Exemple #9
0
 private void ConnectionEstablished(Conversation sender, EventArgs e)
 {
     Console.WriteLine("connection established.\r\n");
 }