Exemplo n.º 1
0
        /// <summary>
        /// Cancel a pending or in-progress file transfer
        /// </summary>
        /// <param name="key">The key received with the transfer request</param>
        /// <exception cref="NotLoggedInException">Thrown when the <see cref="Session"/> is not logged in</exception>
        /// <exception cref="System.Exception">Thrown when <paramref name="key"/> is not a valid file transfer key</exception>
        public void CancelFileTransfer(Cookie key)
        {
            if (!LoggedIn)
            {
                throw new NotLoggedInException();
            }

            FileTransferConnection conn = Connections.GetDirectConnectionByCookie(key) as FileTransferConnection;
            if (conn != null)
            {
                conn.CancelFileTransfer("User cancelled transfer");
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new MessageAcceptedEventArgs
 /// </summary>
 public MessageAcceptedEventArgs(Cookie cookie, string screenName)
 {
     this.cookie = cookie;
     screenname = screenName;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Inserts an ICBM header
 /// </summary>
 private static void InsertIcbmHeader(ByteStream stream, Cookie cookie, ushort channel, string screenName)
 {
     stream.WriteByteArray(cookie.ToByteArray());
             stream.WriteUshort(channel);
             stream.WriteByte((byte)Encoding.ASCII.GetByteCount(screenName));
             stream.WriteString(screenName, Encoding.ASCII);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Cancel a pending or in-progress Direct IM session
        /// </summary>
        /// <param name="key">The key received with the connection request</param>
        /// <exception cref="NotLoggedInException">Thrown when the <see cref="Session"/> is not logged in</exception>
        /// <exception cref="System.Exception">Thrown when <paramref name="key"/> is not a valid file transfer key</exception>
        public void CancelDirectIMSession(Cookie key)
        {
            if (!LoggedIn)
            {
                throw new NotLoggedInException();
            }

            DirectIMConnection conn = Connections.GetDirectConnectionByCookie(key) as DirectIMConnection;
            if (conn != null)
            {
                Messages.SendDirectConnectionCancellation(conn, "User cancelled Direct Connection");
                conn.DisconnectFromServer(false);
            }
        }
Exemplo n.º 5
0
 private void sess_FileTransferCompleted(Session sess, Cookie cookie)
 {
     filecookie = null;
     Console.WriteLine("File transfer of {0} complete", cookie.ToString());
 }
Exemplo n.º 6
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.º 7
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.º 8
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.º 9
0
 /// <summary>
 /// Raises the DirectIM message progress events
 /// </summary>
 /// <param name="incoming">A value indicating whether the message is incoming or outgoing</param>
 /// <param name="cookie">The rendezvous cookie belonging to the DirectIM session</param>
 /// <param name="bytestransfered">The number of bytes transfered so far</param>
 /// <param name="bytestotal">The total number of bytes to be transfered</param>
 protected internal void OnDirectIMMessageProgress(bool incoming, Cookie cookie, uint bytestransfered,
                                                   uint bytestotal)
 {
     if (incoming)
     {
         if (DirectIMIncomingMessageProgress != null)
         {
             DirectIMIncomingMessageProgress(this, cookie, bytestransfered, bytestotal);
         }
     }
     else
     {
         if (DirectIMOutgoingMessageProgress != null)
         {
             DirectIMOutgoingMessageProgress(this, cookie, bytestransfered, bytestotal);
         }
     }
 }
Exemplo n.º 10
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.º 11
0
        /// <summary>
        /// Raises the <see cref="FileTransferRequestReceived"/> event
        /// </summary>
        /// <param name="key">The unique key needed to respond to this request</param>
        protected internal void OnDirectConnectionRequestReceived(Cookie key)
        {
            DirectConnection conn = Connections.GetDirectConnectionByCookie(key);

            if (conn is FileTransferConnection && this.FileTransferRequestReceived != null)
            {
                FileTransferConnection ftc = conn as FileTransferConnection;
                this.FileTransferRequestReceived(this, ftc.Other, ftc.VerifiedIP, ftc.FileHeader.Name,
                                                 ftc.TotalFileSize, ftc.Message, key);
            }
            else if (conn is DirectIMConnection && this.DirectIMRequestReceived != null)
            {
                this.DirectIMRequestReceived(this, conn.Other, conn.Message, key);
            }
            //else if (rd.DirectConnection.ConnectionType == DirectConnectType.DirectIM &&
            //  this.OscarLib_DirectIMRequestReceived != null)
            //{
            //  this.OscarLib_DirectIMRequestReceived(this, rd.UserInfo);
            //}
        }
Exemplo n.º 12
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.º 13
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.º 14
0
 /// <summary>
 /// Initializes a new MessageStatusInfo stamped with the current time
 /// </summary>
 /// <param name="cookie">The cookie uniquely identifying the message</param>
 /// <param name="destination">The screenname to which the message was sent</param>
 public MessageStatusEventArgs(Cookie cookie, string destination)
 {
     this.cookie = cookie;
     this.destination = destination;
     this.timestamp = DateTime.Now;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Raises the <see cref="FileTransferCompleted"/> event
 /// </summary>
 /// <param name="cookie">The rendezvous cookie belonging to the completed file</param>
 protected internal void OnFileTransferCompleted(Cookie cookie)
 {
     if (this.FileTransferCompleted != null)
     {
         this.FileTransferCompleted(this, cookie);
     }
 }
Exemplo n.º 16
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.º 17
0
 /// <summary>
 /// Raises the <see cref="FileTransferProgress"/> event
 /// </summary>
 /// <param name="cookie">The rendezvous cookie belonging to the file being transfered</param>
 /// <param name="bytestransfered">The number of bytes transfered so far</param>
 /// <param name="bytestotal">The total number of bytes to be transfered</param>
 protected internal void OnFileTransferProgress(Cookie cookie,
                                                uint bytestransfered, uint bytestotal)
 {
     if (this.FileTransferProgress != null)
     {
         this.FileTransferProgress(this, cookie, bytestransfered, bytestotal);
     }
 }
Exemplo n.º 18
0
 private void sess_FileTransferCancelled(Session sess, UserInfo other, Cookie cookie, string reason)
 {
     filecookie = null;
     Console.WriteLine("FileTransferCancelled " + reason + " " + other.ScreenName);
 }
Exemplo n.º 19
0
        /// <summary>
        /// Accept an invitation to a DirectIM session
        /// </summary>
        /// <param name="key">The key received in the <see cref="OscarLib_DirectIMRequestReceived"/> event</param>
        public void AcceptDirectIMSession(Cookie key)
        {
            if (!LoggedIn)
            {
                throw new NotLoggedInException();
            }

            DirectIMConnection conn = Connections.GetDirectConnectionByCookie(key) as DirectIMConnection;
            if (conn != null)
            {
                conn.ConnectToServer();
            }
            else
            {
                throw new Exception("Invalid DirectIM session key: \"" + key + "\"");
            }
        }
Exemplo n.º 20
0
 private void sess_FileTransferProgress(Session sess, Cookie cookie, uint BytesTransfered, uint BytesTotal)
 {
     Console.WriteLine("Transfered {0} of {1} of {2}", BytesTransfered, BytesTotal, cookie.ToString());
 }
Exemplo n.º 21
0
        /// <summary>
        /// Accept a file being sent to the client
        /// </summary>
        /// <param name="key">The key received in the <see cref="FileTransferRequestReceived"/> event</param>
        /// <param name="savelocation">The path to which to save the file</param>
        /// <exception cref="NotLoggedInException">Thrown when the <see cref="Session"/> is not logged in</exception>
        /// <exception cref="System.Exception">Thrown when <paramref name="key"/> is not a valid file transfer key</exception>
        public void AcceptFileTransfer(Cookie key, string savelocation)
        {
            if (!LoggedIn)
            {
                throw new NotLoggedInException();
            }

            FileTransferConnection conn = Connections.GetDirectConnectionByCookie(key) as FileTransferConnection;
            if (conn != null)
            {
                conn.LocalFileName = savelocation;
                conn.ConnectToServer();
            }
            else
            {
                throw new Exception("Invalid file transfer key: \"" + key + "\"");
            }
        }
Exemplo n.º 22
0
        public void Go()
        {
            string line;
            while ((line = Console.ReadLine()) != "quit")
            {
                start = DateTime.Now;
                    if (line.Equals("sendsms"))
                {
                    Console.WriteLine("Enter phone to send SMS to (+972XXXXXXXXX)" );
                    string phone = Console.ReadLine();
                    Console.WriteLine("Enter phone message" );
                    string message = Console.ReadLine();
                    sess.ICQ.SendSMSMessage(phone,message,"SMS");
                }
                else if (line.Equals("filesend"))
                {
                    filecookie = sess.SendFile("560280115", "C:\\DevTools.exe");
                }
                else if (line.Equals("filesendproxy"))
                {
                    filecookie = sess.SendFileProxied("560280115", "C:\\DevTools.exe");
                }
                else if (line.Equals("filecancel"))
                {
                    if (filecookie != null)
                        sess.CancelFileTransfer(filecookie);
                }
                else if (line.Equals("upicon"))
                {
                    sess.Graphics.UploadBuddyIcon("C:\\testavatar.jpg");
                }
                else if (line.Equals("addbuddy"))
                {
                    Console.WriteLine("Name?");
                    string buddyname = Console.ReadLine();
                    Console.WriteLine("Group ID?");
                    ushort parentID = ushort.Parse(Console.ReadLine());
                    Console.WriteLine("Index?");
                    int index = int.Parse(Console.ReadLine());

                    sess.AddBuddy(buddyname, parentID, index, "", "", "", "", "", false, "");
                }
                else if (line.Equals("addgroup"))
                {
                    Console.WriteLine("Name?");
                    string groupname = Console.ReadLine();
                    Console.WriteLine("Index?");
                    int index = int.Parse(Console.ReadLine());

                    sess.AddGroup(groupname, index);
                }
                else if (line.Equals("movebuddy"))
                {
                    Console.WriteLine("ID?");
                    ushort buddyID = ushort.Parse(Console.ReadLine());
                    Console.WriteLine("Group ID?");
                    ushort parentID = ushort.Parse(Console.ReadLine());
                    Console.WriteLine("Index?");
                    int index = int.Parse(Console.ReadLine());

                    sess.MoveBuddy(buddyID, parentID, index);
                }
                else if (line.Equals("movegroup"))
                {
                    Console.WriteLine("ID?");
                    ushort groupID = ushort.Parse(Console.ReadLine());
                    Console.WriteLine("Index?");
                    int index = int.Parse(Console.ReadLine());

                    sess.MoveGroup(groupID, index);
                }
                else if (line.Equals("removebuddy"))
                {
                    Console.WriteLine("ScreenName?");
                    SSIBuddy buddy = sess.SSI.GetBuddyByName(Console.ReadLine());

                    if (buddy != null)
                    {
                        sess.SSI.RemoveBuddy(buddy);
                        sess.SSI.RemoveYourself(buddy.Name);
                    }
                }
                else if (line.Equals("removegroup"))
                {
                    Console.WriteLine("ID?");
                    ushort groupID = ushort.Parse(Console.ReadLine());

                    sess.RemoveGroup(groupID);
                }
                else if (line.Equals("offline"))
                {
                    Console.WriteLine("Retrieving offline messages");
                    sess.Messages.RetrieveOfflineMessages();
                }
                else if (line.Equals("sendoffline"))
                {
                    Console.WriteLine("Who?");
                    string destination = Console.ReadLine();
                    sess.Messages.SendMessage(destination, "An offline message", OutgoingMessageFlags.DeliverOffline);
                }
                else if (line.Equals("send"))
                {
                    Console.WriteLine("Where?");
                    string destination = Console.ReadLine();
                    sess.Messages.SendMessage(destination, "A test message");
                }
                else if (line.Equals("shortinfo"))
                {
                    Console.WriteLine("Who?");
                    sess.ICQ.RequestShortUserInfo(Console.ReadLine());
                }
                else if (line.Equals("fullinfo"))
                {
                    Console.WriteLine("Who?");
                    sess.ICQ.RequestFullUserInfo(Console.ReadLine());
                }
                else if (line.Equals("setpass"))
                {
                    Console.WriteLine("New password?");
                    sess.ICQ.SendNewPassword(Console.ReadLine());
                }
                else if (line.Equals("updatebuddy"))
                {
                    SSIBuddy buddy = sess.SSI.GetBuddyByName("560280115");
                    Console.WriteLine("New Nick?");
                    string nick = Console.ReadLine();
                    buddy.DisplayName = nick;
                    sess.SSI.ModifyBuddy(buddy);
                }
                else if (line.Equals("setinfo"))
                {
                    Console.WriteLine("Sets own userdetails");
                    sess.ICQ.SendUserInfo(myui);
                }
                else if (line.Equals("setemail"))
                {
                    Console.WriteLine("Email?");
                    string email = Console.ReadLine();
                    Console.WriteLine("error code: " + sess.ICQ.SendUserEmail(email));
                }
                else if (line.Equals("checkout"))
                {
                    sess.SendContactListCheckout();
                }
            }
        }
Exemplo n.º 23
0
        private void ProcessClientServerDataChannelTwo(ByteStream stream, Cookie cookie, DataPacket dp)
        {
            DirectConnection directconn = null;

            if ((directconn = parent.Connections.GetDirectConnectionByCookie(cookie)) == null)
            {
                // Currently unsupported
                parent.OnWarning(ServerErrorCode.RequestedServiceUnknown, dp);
            }
            else
            {
                if (directconn is FileTransferConnection)
                {
                    (directconn as FileTransferConnection).CancelFileTransfer("Remote user cancelled direct connection");
                }
            }
        }