Beispiel #1
0
 /// <summary>
 /// Processes a notification of SSI items modified remotely -- SNAC(13,09)
 /// </summary>
 /// <param name="dp">A <see cref="DataPacket"/> containing SNAC(13,09)</param>
 public static void ProcessItemsModified(DataPacket dp)
 {
     while (dp.Data.HasMoreData)
     {
         SSIItem moditem = dp.Data.ReadSSIItem();
         dp.ParentSession.SSI.UpdateSSIItem(moditem);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Processes a notification of SSI items removed remotely -- SNAC(13,0A)
 /// </summary>
 /// <param name="dp">A <see cref="DataPacket"/> containing SNAC(13,0A)</param>
 public static void ProcessItemsRemoved(DataPacket dp)
 {
     while (dp.Data.HasMoreData)
     {
         SSIItem removeitem = dp.Data.ReadSSIItem();
         dp.ParentSession.SSI.RemoveSSIItem(removeitem);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Processes a notification of SSI items added remotely -- SNAC(13,08)
 /// </summary>
 /// <param name="dp">A <see cref="DataPacket"/> containing SNAC(13,08)</param>
 public static void ProcessItemsAdded(DataPacket dp)
 {
     while (dp.Data.HasMoreData)
     {
         SSIItem newitem = dp.Data.ReadSSIItem();
         dp.ParentSession.SSI.AddSSIItem(newitem);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Modifies a series of SSI items on the server-side list -- SNAC(13,09)
        /// </summary>
        /// <param name="sess">A <see cref="Session"/> object</param>
        /// <param name="items">An array of <see cref="SSIItem"/> objects</param>
        public static void ModifySSIItems(Session sess, SSIItem[] items)
        {
            SNACHeader sh = new SNACHeader();
            sh.FamilyServiceID = (ushort) SNACFamily.SSIService;
            sh.FamilySubtypeID = (ushort) SSIService.SSIEditUpdateGroupHeader;

            ByteStream stream = new ByteStream();
            stream.WriteSSIItems(items);
            sess.SSI.OutstandingRequests++;
            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream));
        }
Beispiel #5
0
        /// <summary>
        /// Reads an <see cref="SSIItem"/> from the stream
        /// </summary>
        /// <returns>A populated <see cref="SSIItem"/></returns>
        public SSIItem ReadSSIItem()
        {
            SSIItem item = new SSIItem();

            item.Name     = ReadString(ReadUshort(), Encoding.UTF8);
            item.GroupID  = ReadUshort();
            item.ItemID   = ReadUshort();
            item.ItemType = ReadUshort();
            item.Tlvs     = new TlvBlock(ReadByteArray(ReadUshort()));

            return(item);
        }
Beispiel #6
0
 /// <summary>
 /// Writes an <see cref="SSIItem"/> into the stream
 /// </summary>
 public void WriteSSIItem(SSIItem value)
 {
     lock (this)
     {
         dataSegments.Add(new SSIItemSegment(value));
         if (value.Tlvs == null)
         {
             byteCount += 10 + value.Name.Length;
         }
         else
         {
             byteCount += 10 + value.Name.Length + value.Tlvs.GetByteCount();
         }
     }
 }
Beispiel #7
0
        /// <summary>
        /// Processes the server-stored buddy list -- SNAC(13,06)
        /// </summary>
        /// <param name="dp">A <see cref="DataPacket"/> object with a buffer containing SNAC(13,06)</param>
        public static void ProcessBuddyList(DataPacket dp)
        {
            byte   ssiVersion = dp.Data.ReadByte();
            ushort numItems   = dp.Data.ReadUshort();

            if (firstBuddyListPacket)
            {
                dp.ParentSession.SSI.ResetContactList();
                firstBuddyListPacket = false;
            }
            dp.ParentSession.SSI.PreallocateLists(numItems);
            for (int i = 0; i < numItems; i++)
            {
                SSIItem item = dp.Data.ReadSSIItem();
                dp.ParentSession.SSI.AddSSIItem(item);
            }

            DateTime lastModifiedTime = dp.Data.ReadDateTime();


            // Thanks to smartmlp for noticing this!
            // The buddy list can be sent in multiple SNACs, but only the last
            // in the series will have its LSB set to zero. Don't trigger other
            // events until that happens.
            if ((dp.SNAC.Flags & 0x0001) == 0x0000)
            {
                firstBuddyListPacket = true;
                if (!dp.ParentSession.LoggedIn)
                {
                    dp.ParentSession.OnLoginStatusUpdate("Contact list received", 1.0);
                    // Send a couple last SNACs, then tell the server that we're ready to go
                    dp.ParentSession.Services.SendReadyNotification(dp.ParentConnection);
                }
                dp.ParentSession.OnContactListFinished(lastModifiedTime);
            }
        }
Beispiel #8
0
 /// <summary>
 /// Writes a series of <see cref="SSIItem"/>s into the stream
 /// </summary>
 /// <param name="items"></param>
 public void WriteSSIItems(SSIItem[] items)
 {
     foreach (SSIItem item in items)
     {
         WriteSSIItem(item);
     }
 }
Beispiel #9
0
 /// <summary>
 /// Writes an <see cref="SSIItem"/> into the stream
 /// </summary>
 public void WriteSSIItem(SSIItem value)
 {
     lock (this)
     {
         dataSegments.Add(new SSIItemSegment(value));
         if (value.Tlvs == null)
             byteCount += 10 + value.Name.Length;
         else
             byteCount += 10 + value.Name.Length + value.Tlvs.GetByteCount();
     }
 }
Beispiel #10
0
        /// <summary>
        /// Reads an <see cref="SSIItem"/> from the stream
        /// </summary>
        /// <returns>A populated <see cref="SSIItem"/></returns>
        public SSIItem ReadSSIItem()
        {
            SSIItem item = new SSIItem();
            item.Name = ReadString(ReadUshort(), Encoding.UTF8);
            item.GroupID = ReadUshort();
            item.ItemID = ReadUshort();
            item.ItemType = ReadUshort();
            item.Tlvs = new TlvBlock(ReadByteArray(ReadUshort()));

            return item;
        }
Beispiel #11
0
 public SSIItemSegment(SSIItem value)
 {
     item = value;
 }
Beispiel #12
0
 public SSIItemSegment(SSIItem value)
 {
     item = value;
 }