public BubbleGroupCache(string guid, string name, DisaThumbnail photo, List <DisaParticipant> participants)
 {
     Guid         = guid;
     Name         = name;
     Photo        = photo;
     Participants = participants;
 }
Esempio n. 2
0
 public TypingContainer(bool typing, bool available, bool isAudio, DisaThumbnail photo)
 {
     Typing    = typing;
     Available = available;
     IsAudio   = isAudio;
     Photo     = photo;
 }
Esempio n. 3
0
 public BubbleGroupCache(string guid, string name, DisaThumbnail photo, List<DisaParticipant> participants)
 {
     Guid = guid;
     Name = name;
     Photo = photo;
     Participants = participants;
 }
Esempio n. 4
0
 public static DisaThumbnail CreatePartyBitmap(Service service, string name,
                                               DisaThumbnail big, string bigName,
                                               DisaThumbnail small1, string small1Name,
                                               DisaThumbnail small2, string small2Name)
 {
     return(PlatformImplementation.CreatePartyBitmap(service, name, big, bigName, small1, small1Name, small2,
                                                     small2Name));
 }
Esempio n. 5
0
 public static DisaThumbnail CreatePartyBitmap(Service service, string name,
     DisaThumbnail big, string bigName,
     DisaThumbnail small1, string small1Name,
     DisaThumbnail small2, string small2Name)
 {
     return PlatformImplementation.CreatePartyBitmap(service, name, big, bigName, small1, small1Name, small2,
         small2Name);
 }
 public abstract DisaThumbnail CreatePartyBitmap(Service service, string name, 
     DisaThumbnail big, string bigName,
     DisaThumbnail small1, string small1Name,
     DisaThumbnail small2, string small2Name);
Esempio n. 7
0
 public abstract DisaThumbnail CreatePartyBitmap(Service service, string name,
                                                 DisaThumbnail big, string bigName,
                                                 DisaThumbnail small1, string small1Name,
                                                 DisaThumbnail small2, string small2Name);
Esempio n. 8
0
 public override DisaThumbnail CreatePartyBitmap(Service service, string name, DisaThumbnail big, string bigName, DisaThumbnail small1, string small1Name, DisaThumbnail small2, string small2Name)
 {
     throw new NotImplementedException();
 }
 public TypingContainer(bool typing, bool available, bool isAudio, DisaThumbnail photo)
 {
     Typing = typing;
     Available = available;
     IsAudio = isAudio;
     Photo = photo;
 }
Esempio n. 10
0
        public static void StitchPartyPhoto(BubbleGroup bubbleGroup, Action <DisaThumbnail> result)
        {
            Action <DisaParticipant[]> doIt = participants =>
            {
                if (participants == null || !participants.Any())
                {
                    result(null);
                    return;
                }

                DisaThumbnail firstImage         = null;
                string        firstName          = null;
                var           firstImageFetched  = false;
                DisaThumbnail secondImage        = null;
                string        secondName         = null;
                var           secondImageFetched = false;
                DisaThumbnail thirdImage         = null;
                string        thirdName          = null;
                var           thirdImageFetched  = false;

                Action pushIfAllFetched = () =>
                {
                    if (firstImageFetched && secondImageFetched && thirdImageFetched)
                    {
                        result(Platform.CreatePartyBitmap(bubbleGroup.Service,
                                                          bubbleGroup.ID, firstImage, firstName, secondImage, secondName, thirdImage, thirdName));
                    }
                };

                var random = participants.ToList();
                if (random.Count > 0)
                {
                    firstName = random[0].Name;
                    try
                    {
                        bubbleGroup.Service.GetBubbleGroupPartyParticipantPhoto(random[0], result2 =>
                        {
                            if (result2 != null && result2.Failed)
                            {
                                result2 = null;
                            }

                            firstImageFetched = true;
                            firstImage        = result2;
                            pushIfAllFetched();
                        });
                    }
                    catch
                    {
                        firstImageFetched = true;
                        pushIfAllFetched();
                    }
                }
                else
                {
                    firstImageFetched = true;
                    pushIfAllFetched();
                }
                if (random.Count > 1)
                {
                    secondName = random[1].Name;
                    try
                    {
                        bubbleGroup.Service.GetBubbleGroupPartyParticipantPhoto(random[1], result2 =>
                        {
                            if (result2 != null && result2.Failed)
                            {
                                result2 = null;
                            }

                            secondImageFetched = true;
                            secondImage        = result2;
                            pushIfAllFetched();
                        });
                    }
                    catch
                    {
                        secondImageFetched = true;
                        pushIfAllFetched();
                    }
                }
                else
                {
                    secondImageFetched = true;
                    pushIfAllFetched();
                }
                if (random.Count > 2)
                {
                    thirdName = random[2].Name;
                    try
                    {
                        bubbleGroup.Service.GetBubbleGroupPartyParticipantPhoto(random[2], result2 =>
                        {
                            if (result2 != null && result2.Failed)
                            {
                                result2 = null;
                            }

                            thirdImageFetched = true;
                            thirdImage        = result2;
                            pushIfAllFetched();
                        });
                    }
                    catch
                    {
                        thirdImageFetched = true;
                        pushIfAllFetched();
                    }
                }
                else
                {
                    thirdImageFetched = true;
                    pushIfAllFetched();
                }
            };

            try
            {
                if (bubbleGroup.IsParticipantsSetFromService)
                {
                    doIt(bubbleGroup.Participants.ToArray());
                }
                else
                {
                    bubbleGroup.Service.GetBubbleGroupPartyParticipants(bubbleGroup, participants =>
                    {
                        doIt(participants);
                    });
                }
            }
            catch
            {
                result(null);
            }
        }
Esempio n. 11
0
        internal static IEnumerable <BubbleGroupCache> Load()
        {
            var location = GetLocation();

            if (!File.Exists(location))
            {
                yield break;
            }

            lock (BubbleGroupNamesLock)
            {
                using (var xmlReader = XmlReader.Create(location))
                {
                    while (true)
                    {
                        bool read;
                        try
                        {
                            read = xmlReader.Read();
                        }
                        catch
                        {
                            Utils.DebugPrint(
                                "Failed to read bubble group names in. Something must've corrupt. Nuking file.");
                            File.Delete(location);
                            yield break;
                        }

                        if (!read)
                        {
                            break;
                        }

                        if (!xmlReader.IsStartElement())
                        {
                            continue;
                        }

                        switch (xmlReader.Name)
                        {
                        case "BubbleGroupName":

                            var name = xmlReader["Name"];
                            var guid = xmlReader["Guid"];

                            DisaThumbnail photo        = null;
                            var           encodedPhoto = xmlReader["Photo"];
                            if (encodedPhoto != null)
                            {
                                using (var ms = new MemoryStream(Convert.FromBase64String(encodedPhoto)))
                                {
                                    photo = Serializer.Deserialize <DisaThumbnail>(ms);
                                }
                            }

                            var encodedParticipants             = xmlReader["Participants"];
                            List <DisaParticipant> participants = null;
                            if (encodedParticipants != null)
                            {
                                using (var ms = new MemoryStream(Convert.FromBase64String(encodedParticipants)))
                                {
                                    participants = Serializer.Deserialize <List <DisaParticipant> >(ms);
                                }
                            }

                            yield return(new BubbleGroupCache(guid, name, photo, participants));

                            break;
                        }
                    }
                }
            }
        }