Esempio n. 1
0
 /// <summary>
 /// Raises the <see cref="BuddyIconUploadFailed"/> event
 /// </summary>
 protected internal void OnBuddyIconUploadFailed(BartReplyCode errorCode)
 {
     if (BuddyIconUploadFailed != null)
     {
         BuddyIconUploadFailed(this, new BuddyIconUploadFailedArgs(errorCode));
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Processes a download reply - SNAC(10,07)
        /// </summary>
        /// <param name="dp">A <see cref="DataPacket"/> object with a buffer containing SNAC(10,07)</param>
        private void ProcessDownloadReply(DataPacket dp)
        {
            string screenName = dp.Data.ReadString(dp.Data.ReadByte(), Encoding.ASCII);
            BartID queriedId  = new BartID(dp.Data);

            currentlyDownloading.Remove(queriedId);

            BartReplyCode responseCode = (BartReplyCode)dp.Data.ReadByte();

            if (responseCode == BartReplyCode.Success)
            {
                BartID replyId    = new BartID(dp.Data);
                ushort dataLength = dp.Data.ReadUshort();
                byte[] data       = dp.Data.ReadByteArray(dataLength);

                if (!Directory.Exists(AutoSaveLocation))
                {
                    MemoryStream iconStream = new MemoryStream(data);
                    if (BuddyIconReceived != null)
                    {
                        BuddyIconReceived(this, new BuddyIconReceivedEventArgs(screenName, replyId, iconStream));
                    }
                }
                else
                {
                    string saveLocation = Path.Combine(AutoSaveLocation, replyId.ToString());
                    using (FileStream writer = new FileStream(saveLocation, FileMode.Create, FileAccess.Write))
                    {
                        writer.Write(data, 0, data.Length);
                    }
                    OnBuddyIconDownloaded(screenName, replyId, saveLocation);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Processes an upload reply - SNAC(10,03)
        /// </summary>
        /// <param name="dp">A <see cref="DataPacket"/> object with a buffer containing SNAC(10,03)</param>
        private void ProcessUploadReply(DataPacket dp)
        {
            BartReplyCode responseCode = (BartReplyCode)dp.Data.ReadByte();

            if (responseCode == BartReplyCode.Success)
            {
                BartID uploadedItem = new BartID(dp.Data);
                if (BuddyIconUploadCompleted != null)
                {
                    BuddyIconUploadCompleted(this, new BuddyIconUploadCompletedArgs(uploadedItem));
                }
            }
            else
            {
                OnBuddyIconUploadFailed(responseCode);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new BuddyIconUploadFailedArgs
 /// </summary>
 internal BuddyIconUploadFailedArgs(BartReplyCode errorCode)
 {
     this.errorCode = errorCode;
 }
Esempio n. 5
0
 /// <summary>
 /// Raises the <see cref="BuddyIconUploadFailed"/> event
 /// </summary>
 protected internal void OnBuddyIconUploadFailed(BartReplyCode errorCode)
 {
     if (BuddyIconUploadFailed != null)
     {
         BuddyIconUploadFailed(this, new BuddyIconUploadFailedArgs(errorCode));
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new BuddyIconUploadFailedArgs
 /// </summary>
 internal BuddyIconUploadFailedArgs(BartReplyCode errorCode)
 {
     this.errorCode = errorCode;
 }