private void ManageRoster() { if (!rainbowApplication.IsConnected()) { return; } string id = contact_id.StringValue; if (!String.IsNullOrEmpty(id)) { Contact contact = rainbowContacts.GetContactFromContactId(id); if (contact == null) { // We want to add it to the roster Invitations invit = rainbowApplication.GetInvitations(); invit.SendInvitationByContactId(id, callback => { if (callback.Result.Success) { AddStateLine($"Invitation sent to this contact [{id}]"); } else { string logline = String.Format("Impossible to send an invitation to this contact [{1}]:\r\n{0}", Util.SerializeSdkError(callback.Result), id); AddStateLine(logline); log.Warn(logline); } }); } else { // We cant to remove from the roster rainbowContacts.RemoveFromContactId(id, callback => { if (callback.Result.Success) { AddStateLine($"Contact [{id}] has been removed from your roster"); } else { string logline = String.Format("Impossible to remove this contact [{1}] from your roster:\r\n{0}", Util.SerializeSdkError(callback.Result), id); AddStateLine(logline); log.Warn(logline); } }); } } }
private void UpdateConversationsCombobox() { InvokeOnMainThread(() => { cbConversations.RemoveAllItems(); valuesConversations.Clear(); int index = 0; foreach (Conversation conv in rainbowConvList) { string displayName = conv.Name; if (String.IsNullOrEmpty(displayName)) { Contact contact = rainbowContacts.GetContactFromContactId(conv.PeerId); if (contact != null) { displayName = contact.DisplayName; if (String.IsNullOrEmpty(displayName)) { displayName = $"{contact.FirstName} {contact.LastName}"; } } else { displayName = conv.Id; } } valuesConversations.Add(index, conv.Id); index++; cbConversations.AddItem(new NSString(displayName)); } if (cbConversations.IndexOfSelectedItem > 0) { cbConversations.SelectItem(0); } CheckConversationsSelectedAsFavorite(); CheckContactSelectedAsConversation(); }); }
public override Rainbow.Model.Contact GetContactFromContactId(String peerId) { return(RbContacts.GetContactFromContactId(peerId)); }
private void LoadOlderMessages() { if (selectionCorrect) { Conversation conversation; string contactDisplayName = ""; if (contactSelected) { string conversationId = rainbowConversations.GetConversationIdByPeerIdFromCache(idSelected); conversation = rainbowConversations.GetConversationByIdFromCache(conversationId); if (conversation == null) { AddStateLine($"Conversation not found for this contact: [{idSelected}]"); return; } else { Contact contact = rainbowContacts.GetContactFromContactId(idSelected); contactDisplayName = GetContactDisplayName(contact); } } else { conversation = rainbowConversations.GetConversationByIdFromCache(idSelected); if (conversation == null) { AddStateLine($"Conversation not found for this conversation ID: [{idSelected}]"); return; } else { contactDisplayName = conversation.Name; if (String.IsNullOrEmpty(contactDisplayName)) { contactDisplayName = conversation.Id; } } } if (conversation != null) { rainbowInstantMessaging.GetMessagesFromConversationId(conversation.Id, 20, callback => { if (callback.Result.Success) { InvokeOnMainThread(() => boxMessages.Hidden = false); List <Rainbow.Model.Message> list = callback.Data; int nb = list.Count; if (nb > 0) { AddStateLine($"We found [{nb}] older messages in this conversation"); string msgList = ""; string newLine = "\r\n\r\n=========================================================================\r\n"; foreach (Message msg in list) { msgList = $"{newLine}{msg.ToString()}" + msgList; } AddOlderMessagesInStream(msgList); } else { AddStateLine("There is no more older messages in this conversation"); } } else { string logLine = String.Format("Impossible to get older messages from this conversation[{1}]: \r\n{0}", Util.SerializeSdkError(callback.Result), conversation.Id); AddStateLine(logLine); log.Warn(logLine); } }); } } }
private void UpdateConferenceInProgress() { InvokeOnMainThread(() => { log.Debug("[UpdateConferenceInProgress] - IN"); if (conferenceInProgress != null) { if (conferenceInProgress.Active) { box_inProgress.Hidden = false; Bubble bubble = rainbowBubbles.GetBubbleByConferenceIdFromCache(conferenceInProgress.Id); if (bubble == null) { AddStateLine("Strange ! We don't have a bubble related to this conference ... This should never occur ..."); } // Is it a Personal Conference ? Bubble personaleConferenceBubble = rainbowBubbles.PersonalConferenceGetBubbleFromCache(); if ((bubble != null) && (personaleConferenceBubble != null) && (bubble.Id == personaleConferenceBubble.Id)) { cbIsPersonalConference.State = NSCellStateValue.On; } else { cbIsPersonalConference.State = NSCellStateValue.Off; } // Bubble Id / Name / Owner if (bubble != null) { txtBubbleId.StringValue = bubble.Id; txtBubbleName.StringValue = bubble.Name; Contact owner = rainbowContacts.GetContactFromContactId(bubble.Creator); if (owner != null) { txtBubbleOwner.StringValue = owner.DisplayName; } else { txtBubbleOwner.StringValue = ""; } } else { txtBubbleId.StringValue = ""; txtBubbleName.StringValue = ""; txtBubbleOwner.StringValue = ""; } // Talkers if ((conferenceInProgress.Talkers != null) && (conferenceInProgress.Talkers.Count > 0)) { txtConferenceTalkers.StringValue = String.Join(",", conferenceInProgress.Talkers.ToArray()); } else { txtConferenceTalkers.StringValue = ""; } // Conference - global mute if (conferenceInProgress.Muted) { btnConferenceMute.StringValue = "Unmute"; } else { btnConferenceMute.StringValue = "Mute"; } if (cbIsPersonalConference.State == NSCellStateValue.On) { btnConferenceLock.Enabled = true; /// Conference - global lock if (conferenceInProgress.Locked) { btnConferenceLock.StringValue = "Unlock"; } else { btnConferenceLock.StringValue = "Lock"; } } else { btnConferenceLock.Enabled = false; } // Update participants UpdateConferenceParticipants(conferenceInProgress.Participants); // Update publishers UpdateConferencePublishers(conferenceInProgress.Publishers); } else { box_inProgress.Hidden = true; } } else { box_inProgress.Hidden = true; } if (box_inProgress.Hidden) { // Reset form to default values cbIsPersonalConference.State = NSCellStateValue.Off; txtBubbleId.StringValue = ""; txtBubbleName.StringValue = ""; txtBubbleOwner.StringValue = ""; txtConferenceTalkers.StringValue = ""; btnConferenceMute.StringValue = "Mute"; btnConferenceLock.StringValue = "Lock"; // Reset participants UpdateConferenceParticipants(null); // Reset publishers UpdateConferencePublishers(null); } log.Debug("[UpdateConferenceInProgress] - OUT"); }); }