Пример #1
0
 /// <summary>
 /// Changes the Client Information for the user in the given message.
 /// Call this method when a Client Information Message (308) is 
 /// received from the server.
 /// </summary>
 /// <param name="message"></param>
 public void OnClientInformationMessage(MessageEventArgs_308 message)
 {
     var u = GetUser(message.UserId);
     if (u != null) {
         u.OnClientInformationMessage(message);
     }
 }
Пример #2
0
        // 308
        private void OnClientInformationEvent(object sender, int messageId, string messageName, string message)
        {
            if (ClientInformationEvent != null) {
                string[] w;
                string nick, login, host, clientVersion, cipherName, downloads,
                       uploads, status, transfer, path;
                int userId, icon, cipherBits, transferred, size, speed;
                bool idle, admin;
                IPAddress ip;
                DateTime loginTime, idleTime;
                Bitmap image;

                w = SplitMessage(message);
                userId = int.Parse(w[0]);
                idle = Utility.ConvertIntToBool(int.Parse(w[1]));
                admin = Utility.ConvertIntToBool(int.Parse(w[2]));
                icon = int.Parse(w[3]);
                nick = w[4];
                login = w[5];
                ip = IPAddress.Parse(w[6]);
                host = w[7];
                clientVersion = w[8];
                cipherName = w[9];
                cipherBits = int.Parse(w[10]);
                loginTime = DateTime.Parse(w[11]);
                idleTime = DateTime.Parse(w[12]);
                downloads = w[13];
                uploads = w[14];
                status = w[15];
                image = Utility.Base64StringToBitmap(w[16]);
                try {
                    // This try is needed because of a possbile bug in
                    // WiredServer which omitts the last five fields.
                    transfer = w[17];
                    path = w[18];
                    transferred = int.Parse(w[19]);
                    size = int.Parse(w[20]);
                    speed = int.Parse(w[21]);
                } catch (IndexOutOfRangeException e) {
                    transfer = "";
                    path = "";
                    transferred = -1;
                    size = -1;
                    speed = -1;
                    Debug.WriteLine("Messages.cs: Failed to set client information string. Setting default values. Exception: " + e);
                }
                var m = new MessageEventArgs_308(messageId, messageName, userId, image, idle, admin, icon, nick, login, status, ip, host, clientVersion, cipherName, cipherBits, loginTime, idleTime, downloads, uploads, transfer, path, transferred, size, speed);

                ClientInformationEvent(m);
            }
        }
Пример #3
0
        /// <summary>Call this method when the client information for this user has been updated</summary>
        /// <param name="message"></param>
        public void OnClientInformationMessage(MessageEventArgs_308 message)
        {
            if (message.UserId != userId) {
                throw new ApplicationException("The user from the given " +
                                               "message ('" + message + "') did not match the current " +
                                               "user ('" + this + "')");
            }

            admin = message.Admin;
            cipherBits = message.CipherBits;
            cipherName = message.CipherName;
            clientVersion = message.ClientVersion;
            downloads = message.Downloads;
            host = message.Host;
            icon = message.Icon;
            idle = message.Idle;
            idleTime = message.IdleTime;
            image = message.Image;
            ip = message.Ip;
            login = message.Login;
            loginTime = message.LoginTime;
            nick = message.Nick;
            path = message.Path;
            size = message.Size;
            speed = message.Speed;
            status = message.Status;
            transfer = message.Transfer;
            transferred = message.Transferred;
            uploads = message.Uploads;
            userId = message.UserId;
            if (Updated != null) {
                Updated(this);
            }
        }
Пример #4
0
        /// <summary>Constructor for Client Information</summary>
        /// <param name="e"></param>
        public GuiMessageItem(MessageEventArgs_308 e)
        {
            nickName = "";
            timeStamp = DateTime.Now;
            var s = new StringBuilder();
            s.Append("User Information" + "\\r\\n\\r\\n");
            s.Append("Nick: " + e.Nick + "\\r\\n");
            s.Append("Login: "******"\\r\\n");
            s.Append("UserId: " + e.UserId + "\\r\\n");
            s.Append("Idle: " + e.Idle + "\\r\\n");
            s.Append("IdleTime: " + e.IdleTime + "\\r\\n");
            s.Append("LoginTime: " + e.LoginTime + "\\r\\n");
            s.Append("Status: " + e.Status + "\\r\\n");
            s.Append("Admin: " + e.Admin + "\\r\\n");
            s.Append("Host: " + e.Host + "\\r\\n");
            s.Append("Ip:  " + e.Ip + "\\r\\n");
            s.Append("ClientVersion: " + e.ClientVersion + "\\r\\n");
            s.Append("Downloads: " + e.Downloads + "\\r\\n");
            s.Append("Path: " + e.Path + "\\r\\n");
            s.Append("Size: " + e.Size + "\\r\\n");
            s.Append("Speed: " + e.Speed + "\\r\\n");
            s.Append("Transfer: " + e.Transfer + "\\r\\n");
            s.Append("Transferred: " + e.Transferred + "\\r\\n");
            s.Append("Uploads: " + e.Uploads + "\\r\\n");
            s.Append("CipherBits: " + e.CipherBits + "\\r\\n");
            s.Append("CipherName: " + e.CipherName + "\\r\\n");
            //s.Append("Icon" + e.Icon + "\\r\\n");
            //s.Append("Image" + e.Image + "\\r\\n");

            message = s.ToString();
        }