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); }
internal static void SyncContactsIfNeeded(Service service) { var needSync = GetServicesThatNeedContactSync().FirstOrDefault(x => x == service) != null; if (!needSync) { Utils.DebugPrint("Service " + service.Information.ServiceName + " does not need a contact sync!"); return; } Utils.DebugPrint("Syncing service contacts " + service.Information.ServiceName + " because it needs a contact sync..."); try { PhoneBook.SyncService(service); } catch (Exception ex) { Utils.DebugPrint("Failed to sync contacts: " + ex); return; } Utils.DebugPrint("Successfully synced contacts for service " + service.Information.ServiceName); SetNeedsContactSync(service, false); }