Ejemplo n.º 1
0
        private static void SetAutoImportSetting(IDevice device, SqmDeviceInfoStream stream)
        {
            bool?nullable = (bool?)DeviceSettings.Get(device.WinMoDeviceId, "ImportPictures");
            bool flag     = nullable.HasValue ? nullable.GetValueOrDefault() : false;

            if (device.IsFirstConnect)
            {
                if (flag)
                {
                    stream.IsAutoImportEnabled = SqmAutoImportSetting.FirstConnectYes;
                }
                else
                {
                    stream.IsAutoImportEnabled = SqmAutoImportSetting.FirstConnectNo;
                }
            }
            else if (flag)
            {
                stream.IsAutoImportEnabled = SqmAutoImportSetting.Yes;
            }
            else
            {
                stream.IsAutoImportEnabled = SqmAutoImportSetting.No;
            }
        }
Ejemplo n.º 2
0
        private void CalculateDeviceStorageInfo(ISyncPartnership partnership, SqmDeviceInfoStream stream)
        {
            this.musicSize = 0.0;
            this.photoSize = 0.0;
            this.videoSize = 0.0;
            double      num        = 0.0;
            double      freeBytes  = 0.0;
            double      totalBytes = 0.0;
            double      num4       = 0.0;
            double      num5       = 0.0;
            IDevice     device     = partnership.Device;
            StorageInfo info       = (from i in device.StorageDevices.Values
                                      where i.StorageType == StorageType.FixedRam
                                      select i).FirstOrDefault <StorageInfo>();

            if (info != null)
            {
                this.musicSize += info.UsedStorageMusic;
                this.photoSize += info.UsedStoragePictures;
                this.videoSize += info.UsedStorageVideos;
                num            += info.UsedStorageDocs;
                freeBytes       = info.FreeBytes;
                totalBytes      = info.TotalBytes;
            }
            info = (from i in device.StorageDevices.Values
                    where i.StorageType == StorageType.RemovableRam
                    select i).FirstOrDefault <StorageInfo>();
            if (info != null)
            {
                this.musicSize += info.UsedStorageMusic;
                this.photoSize += info.UsedStoragePictures;
                this.videoSize += info.UsedStorageVideos;
                num            += info.UsedStorageDocs;
                num5            = info.TotalBytes;
                num4            = info.FreeBytes;
            }
            stream.InternalCapacity  = (uint)(totalBytes / 1000000.0);
            stream.InternalFreeSpace = (uint)(freeBytes / 1000000.0);
            stream.SDCardCapacity    = (uint)(num5 / 1000000.0);
            stream.SDCardFreeSpace   = (uint)(num4 / 1000000.0);
            stream.MusicFileSize     = (uint)(this.musicSize / 1000000.0);
            stream.PhotoFileSize     = (uint)(this.photoSize / 1000000.0);
            stream.VideoFileSize     = (uint)(this.videoSize / 1000000.0);
            stream.DocumentFileSize  = (uint)(num / 1000000.0);
            stream.StorageAreaCount  = (uint)device.StorageDevices.Count;
        }
Ejemplo n.º 3
0
 public void CreateDeviceInfoStream(ISyncPartnership partnership, int uniqueIndex)
 {
     if ((partnership != null) && this.isSqmEnabled)
     {
         SqmDeviceInfoStream stream = new SqmDeviceInfoStream {
             DeviceIndex = (uint) (uniqueIndex + 1)
         };
         if (partnership.Device != null)
         {
             stream.MakeModel = partnership.Device.ManufacturerModelID;
         }
         this.CalculateDeviceStorageInfo(partnership, stream);
         CalculateAcquiredItemResults(partnership, stream);
         CalculateCumulativeSyncResults(partnership, stream);
         SetAutoImportSetting(partnership.Device, stream);
         this.sqmManager.SetStream(stream);
     }
 }
Ejemplo n.º 4
0
 public void CreateDeviceInfoStream(ISyncPartnership partnership, int uniqueIndex)
 {
     if ((partnership != null) && this.isSqmEnabled)
     {
         SqmDeviceInfoStream stream = new SqmDeviceInfoStream {
             DeviceIndex = (uint)(uniqueIndex + 1)
         };
         if (partnership.Device != null)
         {
             stream.MakeModel = partnership.Device.ManufacturerModelID;
         }
         this.CalculateDeviceStorageInfo(partnership, stream);
         CalculateAcquiredItemResults(partnership, stream);
         CalculateCumulativeSyncResults(partnership, stream);
         SetAutoImportSetting(partnership.Device, stream);
         this.sqmManager.SetStream(stream);
     }
 }
Ejemplo n.º 5
0
 private void CalculateDeviceStorageInfo(ISyncPartnership partnership, SqmDeviceInfoStream stream)
 {
     this.musicSize = 0.0;
     this.photoSize = 0.0;
     this.videoSize = 0.0;
     double num = 0.0;
     double freeBytes = 0.0;
     double totalBytes = 0.0;
     double num4 = 0.0;
     double num5 = 0.0;
     IDevice device = partnership.Device;
     StorageInfo info = (from i in device.StorageDevices.Values
         where i.StorageType == StorageType.FixedRam
         select i).FirstOrDefault<StorageInfo>();
     if (info != null)
     {
         this.musicSize += info.UsedStorageMusic;
         this.photoSize += info.UsedStoragePictures;
         this.videoSize += info.UsedStorageVideos;
         num += info.UsedStorageDocs;
         freeBytes = info.FreeBytes;
         totalBytes = info.TotalBytes;
     }
     info = (from i in device.StorageDevices.Values
         where i.StorageType == StorageType.RemovableRam
         select i).FirstOrDefault<StorageInfo>();
     if (info != null)
     {
         this.musicSize += info.UsedStorageMusic;
         this.photoSize += info.UsedStoragePictures;
         this.videoSize += info.UsedStorageVideos;
         num += info.UsedStorageDocs;
         num5 = info.TotalBytes;
         num4 = info.FreeBytes;
     }
     stream.InternalCapacity = (uint) (totalBytes / 1000000.0);
     stream.InternalFreeSpace = (uint) (freeBytes / 1000000.0);
     stream.SDCardCapacity = (uint) (num5 / 1000000.0);
     stream.SDCardFreeSpace = (uint) (num4 / 1000000.0);
     stream.MusicFileSize = (uint) (this.musicSize / 1000000.0);
     stream.PhotoFileSize = (uint) (this.photoSize / 1000000.0);
     stream.VideoFileSize = (uint) (this.videoSize / 1000000.0);
     stream.DocumentFileSize = (uint) (num / 1000000.0);
     stream.StorageAreaCount = (uint) device.StorageDevices.Count;
 }
Ejemplo n.º 6
0
 private static void SetAutoImportSetting(IDevice device, SqmDeviceInfoStream stream)
 {
     bool? nullable = (bool?) DeviceSettings.Get(device.WinMoDeviceId, "ImportPictures");
     bool flag = nullable.HasValue ? nullable.GetValueOrDefault() : false;
     if (device.IsFirstConnect)
     {
         if (flag)
         {
             stream.IsAutoImportEnabled = SqmAutoImportSetting.FirstConnectYes;
         }
         else
         {
             stream.IsAutoImportEnabled = SqmAutoImportSetting.FirstConnectNo;
         }
     }
     else if (flag)
     {
         stream.IsAutoImportEnabled = SqmAutoImportSetting.Yes;
     }
     else
     {
         stream.IsAutoImportEnabled = SqmAutoImportSetting.No;
     }
 }
Ejemplo n.º 7
0
 private static void CalculateCumulativeSyncResults(ISyncPartnership partnership, SqmDeviceInfoStream stream)
 {
     double num = 0.0;
     List<SyncOperation> list = new List<SyncOperation>(partnership.SuccessfulCumulativeSyncOperations);
     stream.ItemsSuccessfullySyncedCount = (uint) list.Count;
     foreach (SyncOperation operation in list)
     {
         if ((operation.OperationType != SyncOperationType.Delete) && (operation.OperationType != SyncOperationType.Update))
         {
             int? nullable2 = operation.Item.Properties.NullableIntForKey("Size");
             long? nullable = nullable2.HasValue ? new long?((long) nullable2.GetValueOrDefault()) : null;
             if (nullable.HasValue)
             {
                 num += (double) nullable.Value;
             }
         }
     }
     stream.ItemsSuccessfullySyncedSize = (uint) (num / 1000000.0);
 }
Ejemplo n.º 8
0
 private static void CalculateAcquiredItemResults(ISyncPartnership partnership, SqmDeviceInfoStream stream)
 {
     double num = 0.0;
     uint num2 = 0;
     uint num3 = 0;
     uint num4 = 0;
     uint num5 = 0;
     List<SyncOperation> list = new List<SyncOperation>(partnership.SuccessfulAcquiredOperations);
     stream.AcquiredItemsCount = (uint) list.Count;
     foreach (SyncOperation operation in list)
     {
         int? nullable2 = operation.Item.Properties.NullableIntForKey("Size");
         long? nullable = nullable2.HasValue ? new long?((long) nullable2.GetValueOrDefault()) : null;
         if (nullable.HasValue)
         {
             num += (double) nullable.Value;
         }
         if (operation.Item.Properties.BooleanForKey("Picture", false))
         {
             num3++;
         }
         else
         {
             if (operation.Item.Properties.BooleanForKey("Podcast", false))
             {
                 num5++;
                 continue;
             }
             if (operation.Item.Properties.BooleanForKey("Has Video", false))
             {
                 num4++;
                 continue;
             }
             if (operation.Item.Properties.BooleanForKey("Audio", false))
             {
                 num2++;
             }
         }
     }
     stream.AcquiredItemsSize = (uint) (num / 1000000.0);
     stream.AcquiredPhotoItemsCount = num3;
     stream.AcquiredMusicItemsCount = num2;
     stream.AcquiredVideoItemsCount = num4;
     stream.AcquiredPodcastItemsCount = num5;
 }
Ejemplo n.º 9
0
        private static void CalculateCumulativeSyncResults(ISyncPartnership partnership, SqmDeviceInfoStream stream)
        {
            double num = 0.0;
            List <SyncOperation> list = new List <SyncOperation>(partnership.SuccessfulCumulativeSyncOperations);

            stream.ItemsSuccessfullySyncedCount = (uint)list.Count;
            foreach (SyncOperation operation in list)
            {
                if ((operation.OperationType != SyncOperationType.Delete) && (operation.OperationType != SyncOperationType.Update))
                {
                    int? nullable2 = operation.Item.Properties.NullableIntForKey("Size");
                    long?nullable  = nullable2.HasValue ? new long?((long)nullable2.GetValueOrDefault()) : null;
                    if (nullable.HasValue)
                    {
                        num += (double)nullable.Value;
                    }
                }
            }
            stream.ItemsSuccessfullySyncedSize = (uint)(num / 1000000.0);
        }
Ejemplo n.º 10
0
        private static void CalculateAcquiredItemResults(ISyncPartnership partnership, SqmDeviceInfoStream stream)
        {
            double num  = 0.0;
            uint   num2 = 0;
            uint   num3 = 0;
            uint   num4 = 0;
            uint   num5 = 0;
            List <SyncOperation> list = new List <SyncOperation>(partnership.SuccessfulAcquiredOperations);

            stream.AcquiredItemsCount = (uint)list.Count;
            foreach (SyncOperation operation in list)
            {
                int? nullable2 = operation.Item.Properties.NullableIntForKey("Size");
                long?nullable  = nullable2.HasValue ? new long?((long)nullable2.GetValueOrDefault()) : null;
                if (nullable.HasValue)
                {
                    num += (double)nullable.Value;
                }
                if (operation.Item.Properties.BooleanForKey("Picture", false))
                {
                    num3++;
                }
                else
                {
                    if (operation.Item.Properties.BooleanForKey("Podcast", false))
                    {
                        num5++;
                        continue;
                    }
                    if (operation.Item.Properties.BooleanForKey("Has Video", false))
                    {
                        num4++;
                        continue;
                    }
                    if (operation.Item.Properties.BooleanForKey("Audio", false))
                    {
                        num2++;
                    }
                }
            }
            stream.AcquiredItemsSize         = (uint)(num / 1000000.0);
            stream.AcquiredPhotoItemsCount   = num3;
            stream.AcquiredMusicItemsCount   = num2;
            stream.AcquiredVideoItemsCount   = num4;
            stream.AcquiredPodcastItemsCount = num5;
        }