Exemplo n.º 1
0
 private void sess_DirectIMRequestReceived(Session sess, UserInfo sender, string message, Cookie key)
 {
     Console.WriteLine("Auto-accepting DIM invite from {0} ({1})", sender.ScreenName, message);
     sess.AcceptDirectIMSession(key);
 }
Exemplo n.º 2
0
 private void sess_FileTransferCancelled(Session sess, UserInfo other, Cookie cookie, string reason)
 {
     filecookie = null;
     Console.WriteLine("FileTransferCancelled " + reason + " " + other.ScreenName);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new offline instant message received with a <see cref="UserInfo"/> block
 /// </summary>
 public OfflineIM(UserInfo userInfo)
     : base(userInfo)
 {
 }
Exemplo n.º 4
0
 private void sess_ChatInvitationReceived(Session sess, UserInfo sender, string roomname, string message,
                                          Encoding encoding, string language, Cookie key)
 {
     Console.WriteLine("Received chat invite from " + sender.ScreenName + " to " + roomname + ": " + message);
     Console.WriteLine("Auto-accepting");
     sess.ChatRooms.JoinChatRoom(key);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new ChatRoomChangedEventArgs
 /// </summary>
 /// <param name="user">The user that has joined or left the chat room</param>
 public ChatRoomChangedEventArgs(UserInfo user)
 {
     this.user = user;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instant message received with a <see cref="UserInfo"/> block
 /// </summary>
 public IM(UserInfo userinfo)
 {
     userInfo = userinfo;
     screenName = userinfo.ScreenName;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Raises the <see cref="WarningReceived"/> event.
 /// </summary>
 /// <param name="newlevel">The client's new warning level</param>
 /// <param name="anonymous"><c>true</c> if this warning was sent anonymously, <c>false</c> otherwise</param>
 /// <param name="ui">A <see cref="UserInfo"/> structure describing the warning user. If <paramref name="anonymous"/> is
 /// <c>true</c>, this structure is unpopulated</param>
 protected internal void OnWarningReceived(ushort newlevel, bool anonymous, UserInfo ui)
 {
     if (this.WarningReceived != null)
         this.WarningReceived(this, newlevel, anonymous, ui);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Processes an incoming ICBM message on channel 1 -- SNAC(04,07)
        /// </summary>
        /// <param name="stream">A received <see cref="ByteStream"/></param>
        /// <param name="ui">The UserInfo block that came with this message</param>
        private void ProcessChannelOneMessage(ByteStream stream, UserInfo ui)
        {
            IM message = new IM(ui);
            using (TlvBlock tlvs = new TlvBlock(stream.ReadByteArrayToEnd()))
            {
                message.IsAutoResponse = tlvs.HasTlv(0x0004);
                // If this message was received offline, cast it to an OfflineIM
                if (tlvs.HasTlv(0x0006))
                {
                    message = new OfflineIM(message);
                    if (tlvs.HasTlv(0x0016))
                    {
                        ((OfflineIM)message).ReceivedOn = tlvs.ReadDateTime(0x0016);
                    }
                }
                GetChannelOneMessage(new ByteStream(tlvs.ReadByteArray(0x0002)), ref message);
            }

            // Figure out what to do with it
            if (message is OfflineIM)
            {
                OfflineIM offlineMessage = message as OfflineIM;
                if (isRetrievingOfflineMessages)
                {
                    // Queue it for delivery
                    AcceptIcbmOIM(offlineMessage);
                }
                else
                {
                    // A single offline message?  Okay then
                    if (OfflineMessagesReceived != null)
                    {
                        List<OfflineIM> tmpList = new List<OfflineIM>(1);
                        tmpList.Add(offlineMessage);
                        OfflineMessagesReceived(this, new OfflineMessagesReceivedEventArgs(parent.ScreenName,
                                                                                           new Collection<OfflineIM>(tmpList)));
                    }
                }
                // Offline messages don't get delivered via OnMessageReceived - if the offline messages event
                // isn't hooked up, tough stuff.
                return;
            }
            else
            {
                OnMessageReceived(message);
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Raises the <see cref="DirectIMSessionClosed"/>
 /// </summary>
 /// <param name="other">A <see cref="UserInfo"/> object describing the other session participant</param>
 /// <param name="cookie">The rendezvous cookie belonging to the cancelled session</param>
 protected internal void OnDirectIMSessionClosed(UserInfo other, Cookie cookie)
 {
     Connections.RemoveDirectConnection(cookie);
     if (this.DirectIMSessionClosed != null)
     {
         this.DirectIMSessionClosed(this, other, cookie);
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Raises the <see cref="FileTransferCancelled"/> event
 /// </summary>
 /// <param name="other">The <see cref="UserInfo"/> of the user on the other side of the connection</param>
 /// <param name="cookie">The rendezvous cookie belonging to the cancelled file</param>
 /// <param name="reason">The reason for the cancellation</param>
 protected internal void OnFileTransferCancelled(UserInfo other, Cookie cookie, string reason)
 {
     if (this.FileTransferCancelled != null)
     {
         this.FileTransferCancelled(this, other, cookie, reason);
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Raises the <see cref="DirectIMSessionReady"/> event
 /// </summary>
 /// <param name="other">A <see cref="UserInfo"/> object describing the other session participant</param>
 /// <param name="cookie">The rendezvous cookie belonging to the session</param>
 protected internal void OnDirectConnectionComplete(UserInfo other, Cookie cookie)
 {
     if (this.DirectIMSessionReady != null)
     {
         this.DirectIMSessionReady(this, other, cookie);
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Raises the <see cref="ChatInvitationReceived"/> event
 /// </summary>
 /// <param name="sender">A <see cref="UserInfo"/> object represnting the inviter</param>
 /// <param name="roomname">The name of the chatroom</param>
 /// <param name="message">An invitation chatroom</param>
 /// <param name="encoding">The text encoding used in the chatroom</param>
 /// <param name="language">The language used in the chatroom</param>
 /// <param name="key">The unique key needed to respond to this request</param>
 protected internal void OnChatInvitationReceived(UserInfo sender,
                                                  string roomname,
                                                  string message,
                                                  Encoding encoding,
                                                  string language,
                                                  Cookie key)
 {
     if (this.ChatInvitationReceived != null)
         this.ChatInvitationReceived(this, sender, roomname, message, encoding, language, key);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Process a ICBM that was sent over channel two - rich text messages, chat/filetransfer invites, buddy icons
 /// </summary>
 private void ProcessChannelTwoMessage(ByteStream stream, UserInfo ui, DataPacket dp)
 {
     TlvBlock tlvs = new TlvBlock(stream.ReadByteArrayToEnd());
     //KSD-SYSTEMS - commented at 02.12.2009 -> Hangs up at errorCode reading
     //ushort errorCode = tlvs.ReadUshort(0x000B);
     DirectConnection conn = ProcessChannel2Tlv05(new ByteStream(tlvs.ReadByteArray(0x0005)), ui, dp);
 }
Exemplo n.º 14
0
 private void sess_FileTransferRequestReceived(Session sess, UserInfo sender, string IP, string filename, uint filesize, string message, Cookie key)
 {
     filecookie = key;
     Console.WriteLine("Auto-accepting " + filename);
     sess.AcceptFileTransfer(key, "C:\\recv_" + filename);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new UndeliverableMessageEventArgs
 /// </summary>
 /// <param name="channel">The channel on which the message was missed</param>
 /// <param name="userInfo">A <see cref="UserInfo"/> block describing the sender</param>
 /// <param name="numberMissed">The number of messages missed from the sender</param>
 /// <param name="reason">An <see cref="UndeliverableMessageReason"/> value describing the failure</param>
 public UndeliverableMessageEventArgs(int channel, UserInfo userInfo,
                                      int numberMissed, UndeliverableMessageReason reason)
 {
     this.channel = channel;
     userinfo = userInfo;
     this.numberMissed = numberMissed;
     this.reason = reason;
 }
Exemplo n.º 16
0
 private void sess_UserStatusReceived(object sender, UserInfo userinfo)
 {
     Console.WriteLine("{0} has come online", userinfo.ScreenName);
     if (userinfo.Icon != null)
     {
         //Console.WriteLine("Got valid icon info for " + userinfo.ScreenName);
         //sess.Graphics.DownloadBuddyIcon(userinfo.ScreenName, userinfo.Icon);
     }
     else
     {
         sess.Statuses.RequestBasicUserInfo(userinfo.ScreenName, BasicUserInfoRequest.GeneralInfo);
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// Processes the inner TLV list in TLV 0x0005 and returns a new DirectConnection
        /// </summary>
        private DirectConnection ProcessChannel2Tlv05(ByteStream stream, UserInfo ui, DataPacket dp)
        {
            byte[] invitemessage;
                    Encoding encoding = Encoding.ASCII;
                    string language = "en";

                    DirectConnection directconn = null;

                    // Pull the type, cookie, and capability array
                    RendezvousType rtype = RendezvousData.TypeFromUshort(stream.ReadUshort());
                    Cookie cookie = Cookie.GetReceivedCookie(stream.ReadByteArray(8));
                    byte[] capabilitiesArray = stream.ReadByteArray(16);
                    Capabilities capabilities = CapabilityProcessor.ProcessCLSIDList(capabilitiesArray);

                    // Create the correct type of connection based on the capability
                    if (capabilities == Capabilities.SendFiles)
                    {
                        if ((directconn = parent.Connections.GetDirectConnectionByCookie(cookie)) == null)
                        {
                            directconn = parent.Connections.CreateNewFileTransferConnection(
                                DirectConnectionMethod.Direct, DirectConnectRole.Receiver);
                        }
                    }
                    else if (capabilities == Capabilities.DirectIM)
                    {
                        if ((directconn = parent.Connections.GetDirectConnectionByCookie(cookie)) == null)
                        {
                            directconn = parent.Connections.CreateNewDirectIMConnection(
                                DirectConnectionMethod.Direct, DirectConnectRole.Receiver);
                        }
                    }
                    else if (capabilities == Capabilities.Chat)
                    {
                        directconn = parent.Connections.CreateNewChatInvitationConnection(DirectConnectRole.Receiver);
                    }
                    else
                    {
                        // Currently unsupported
                        parent.OnWarning(ServerErrorCode.UnknownRendezvousChannel, dp);
                        return null;
                    }

                    directconn.Other = ui;
                    directconn.Cookie = cookie;
                    directconn.Type = rtype;

                    ByteStream serviceData = null;
                    Encoding serviceDataEncoding = Encoding.ASCII;

                    // Process the inner TLV list
                    using (TlvBlock tlvs = new TlvBlock(stream.ReadByteArrayToEnd()))
                    {
                        directconn.AOLProxyIP = tlvs.ReadIPAddress(DC_PROXY_IP_ADDRESS);        // proxy ip
                        directconn.ClientIP = tlvs.ReadIPAddress(DC_CLIENT_IP_ADDRESS);         // internal ip
                        directconn.VerifiedIP = tlvs.ReadIPAddress(0x0004);                     // external ip
                        directconn.Port = tlvs.ReadUshort(DC_PORT);
                        directconn.Sequence = RendezvousData.SequenceFromUshort(tlvs.ReadUshort(DC_SEQUENCE_NUMBER));
                        invitemessage = tlvs.ReadByteArray(DC_MESSAGE);
                        if (tlvs.HasTlv(0x000D))
                        {
                            encoding = Encoding.GetEncoding(tlvs.ReadString(0x000D, Encoding.ASCII));
                        }
                        language = tlvs.ReadString(0x000E, Encoding.ASCII);
                        directconn.Method = (tlvs.HasTlv(DC_USE_PROXY_FLAG))
                            ?
                            DirectConnectionMethod.Proxied
                            : DirectConnectionMethod.Direct;

                        serviceData = new ByteStream(tlvs.ReadByteArray(0x2711));
                        if (tlvs.HasTlv(0x2712))
                        {
                            serviceDataEncoding = Encoding.GetEncoding(tlvs.ReadString(0x2712, Encoding.ASCII));
                        }
                    }

                    if (invitemessage != null)
                    {
                        directconn.Message = encoding.GetString(invitemessage, 0, invitemessage.Length);
                    }

                    // Process the extra data, if necessary
                    if (directconn is FileTransferConnection || directconn is DirectIMConnection)
                    {
                        ProcessDirectConnectionRequest(directconn, serviceData);
                    }
                    else if (directconn is ChatInvitationConnection)
                    {
                        ChatInvitationConnection cic = directconn as ChatInvitationConnection;
                        cic.ChatInvite = new ChatInvitation();
                        cic.ChatInvite.Message = directconn.Message;
                        cic.ChatInvite.Encoding = encoding;
                        cic.ChatInvite.Language = language;
                        ProcessChatInvitationRequest(cic, serviceData);
                    }

                    return directconn;
        }