Ejemplo n.º 1
0
        public static string GetParticipantNicknameOrName(BubbleGroup group, DisaParticipant participant)
        {
            var fetchNickname = false;
            var name          = participant.Name;

            if (!string.IsNullOrWhiteSpace(participant.Name))
            {
                if (!PhoneBook.IsPossibleNumber(participant.Name))
                {
                    //fall-through
                }
                else
                {
                    fetchNickname = true;
                }
            }
            else
            {
                fetchNickname = true;
            }
            var prependParticipantName = false;

            if (fetchNickname)
            {
                var participantNicknames = group.ParticipantNicknames;
                if (participantNicknames != null)
                {
                    var participantNickname = participantNicknames.FirstOrDefault(x =>
                                                                                  group.Service.BubbleGroupComparer(participant.Address, x.Address));
                    if (participantNickname != null)
                    {
                        name = participantNickname.Nickname;
                        if (participant.Unknown)
                        {
                            prependParticipantName = true;
                        }
                    }
                }
            }
            if (prependParticipantName && !string.IsNullOrWhiteSpace(participant.Name))
            {
                return(name + " (" + participant.Name + ")");
            }
            return(name);
        }
Ejemplo n.º 2
0
        public static async void UpdateParticipantPhoto(Service service, DisaParticipant participant, Action <DisaThumbnail> finished)
        {
            if (!ServiceManager.IsRunning(service))
            {
                return;
            }

            if (service.Information.UsesInternet && !Platform.HasInternetConnection())
            {
                return;
            }

            var participantClosure = participant;

            try
            {
                await service.GetBubbleGroupPartyParticipantPhoto(participant, result =>
                {
                    if (result != null && result.Failed)
                    {
                        if (finished != null)
                        {
                            finished(participantClosure.Photo);
                        }
                        return;
                    }

                    participantClosure.IsPhotoSetFromService = true;
                    participantClosure.Photo = result;
                    finished(result);
                });
            }
            catch (Exception ex)
            {
                Utils.DebugPrint("Error updating bubble group participant photo: " + service.Information.ServiceName +
                                 " - " + participant.Address + ": " + ex);
                if (finished != null)
                {
                    finished(null);
                }
            }

            return;
        }
Ejemplo n.º 3
0
        public static bool UpdateParticipantPhoto(Service service, DisaParticipant participant, Action<DisaThumbnail> finished)
        {
            if (!ServiceManager.IsRunning(service)) return false;

            if (service.Information.UsesInternet && !Platform.HasInternetConnection())
                return false;

            var participantClosure = participant;
            try
            {
                service.GetBubbleGroupPartyParticipantPhoto(participant, result =>
                {
                    if (result != null && result.Failed)
                    {
                        if (finished != null)
                        {
                            finished(participantClosure.Photo);
                        }
                        return;
                    }

                    participantClosure.IsPhotoSetFromService = true;
                    participantClosure.Photo = result;
                    finished(result);
                });
            }
            catch (Exception ex)
            {
                Utils.DebugPrint("Error updating bubble group participant photo: " +
                                         service.Information.ServiceName + ": " + ex.Message);
                if (finished != null)
                {
                    finished(null);
                }
            }

            return true;
        }
Ejemplo n.º 4
0
 public static string GetParticipantNicknameOrName(BubbleGroup group, DisaParticipant participant)
 {
     var fetchNickname = false;
     var name = participant.Name;
     if (!string.IsNullOrWhiteSpace(participant.Name))
     {
         if (!PhoneBook.IsPossibleNumber(participant.Name))
         {
             //fall-through
         }
         else
         {
             fetchNickname = true;
         }
     }
     else
     {
         fetchNickname = true;
     }
     var prependParticipantName = false;
     if (fetchNickname)
     {
         var participantNicknames = group.ParticipantNicknames;
         if (participantNicknames != null)
         {
             var participantNickname = participantNicknames.FirstOrDefault(x =>
                 group.Service.BubbleGroupComparer(participant.Address, x.Address));
             if (participantNickname != null)
             {
                 name = participantNickname.Nickname;
                 if (participant.Unknown)
                 {
                     prependParticipantName = true;
                 }
             }
         }
     }
     if (prependParticipantName && !string.IsNullOrWhiteSpace(participant.Name))
     {
         return name + " (" + participant.Name + ")";
     }
     return name;
 }
Ejemplo n.º 5
0
 public abstract Task GetBubbleGroupPartyParticipantPhoto(DisaParticipant participant, Action <DisaThumbnail> result);
Ejemplo n.º 6
0
 public override Task GetBubbleGroupPartyParticipantPhoto(DisaParticipant participant, Action <DisaThumbnail> result)
 {
     throw new NotImplementedException();
 }