コード例 #1
0
        public static ConversationLight GetConversationFromRBConversation(Rainbow.Model.Conversation rbConversation)
        {
            ConversationLight conversation = null;

            if (rbConversation != null)
            {
                InstantMessaging.App XamarinApplication = (InstantMessaging.App)Xamarin.Forms.Application.Current;
                AvatarPool           avatarPool         = AvatarPool.Instance;

                conversation = new ConversationLight();


                if (rbConversation.Type == Rainbow.Model.Conversation.ConversationType.Room)
                {
                    conversation.Name           = rbConversation.Name;
                    conversation.Topic          = rbConversation.Topic;
                    conversation.Jid            = rbConversation.Jid_im;
                    conversation.PresenceSource = "";
                }
                else if (rbConversation.Type == Rainbow.Model.Conversation.ConversationType.User)
                {
                    // Get Display name of this user
                    Rainbow.Model.Contact contact = XamarinApplication.RbContacts.GetContactFromContactId(rbConversation.PeerId);
                    if (contact != null)
                    {
                        conversation.Name  = Util.GetContactDisplayName(contact);
                        conversation.Topic = "";
                        conversation.Jid   = contact.Jid_im;

                        Presence presence = XamarinApplication.RbContacts.GetAggregatedPresenceFromContactId(rbConversation.PeerId);
                        conversation.PresenceSource = InstantMessaging.Helpers.Helper.GetPresenceSourceFromPresence(presence);
                    }
                    else
                    {
                        //log.Debug("[GetConversationFromRBConversation] - unknown contact - contactId:[{0}]", rbConversation.PeerId);
                        XamarinApplication.RbContacts.GetContactFromContactIdFromServer(rbConversation.PeerId, null);
                    }
                }
                else
                {
                    //TODO ( bot case)
                    //log.Debug("[GetConversationFromRBConversation] Conversation from model not created - Id:[{0}]", rbConversation.Id);
                    return(null);
                }

                conversation.Id     = rbConversation.Id;
                conversation.PeerId = rbConversation.PeerId;

                conversation.Type                 = rbConversation.Type;
                conversation.NbMsgUnread          = rbConversation.UnreadMessageNumber;
                conversation.NbMsgUnreadIsVisible = (conversation.NbMsgUnread > 0) ? "True" : "False";

                conversation.LastMessage         = rbConversation.LastMessageText;
                conversation.LastMessageDateTime = rbConversation.LastMessageDate;

                // Humanized the DateTime
                conversation.MessageTimeDisplay = Helpers.Helper.HumanizeDateTime(conversation.LastMessageDateTime);
            }
            return(conversation);
        }
コード例 #2
0
        private FilePool()
        {
            avatarPool = AvatarPool.Instance;

            MaxThumbnailWidth  = 200;
            MaxThumbnailHeight = 200;
        }
コード例 #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        public ConversationsLightModel()
        {
            // Init commands
            m_ItemLeftClick = new RelayCommand <object>(new Action <object>(ItemLeftClickCommand));

            //ConversationsLightList = new SortableObservableCollection<ConversationLightViewModel>(new ConversationLightViewModel.ConversationLightViewModelComparer(), true);
            ConversationsLightList = new RangeObservableCollection <ConversationLightViewModel>();


            if (CurrentApplication.USE_DUMMY_DATA)
            {
                LoadFakeConversations();
                return;
            }

            // Get Rainbow SDK Objects
            RbBubbles       = CurrentApplication.RbBubbles;
            RbContacts      = CurrentApplication.RbContacts;
            RbConversations = CurrentApplication.RbConversations;

            // Manage event(s) from AvatarPool
            AvatarPool = AvatarPool.Instance;
            AvatarPool.ContactAvatarChanged += AvatarPool_ContactAvatarChanged;
            AvatarPool.BubbleAvatarChanged  += AvatarPool_BubbleAvatarChanged;

            // Manage event(s) from Rainbow SDK about CONVERSATIONS
            RbConversations.ConversationCreated += RbConversations_ConversationCreated;
            RbConversations.ConversationRemoved += RbConversations_ConversationRemoved;
            RbConversations.ConversationUpdated += RbConversations_ConversationUpdated;

            // Manage event(s) from Rainbow SDK about CONTACTS
            RbContacts.ContactPresenceChanged += RbContacts_ContactPresenceChanged;

            RbContacts.PeerAdded       += RbContacts_PeerAdded;
            RbContacts.PeerInfoChanged += RbContacts_PeerInfoChanged;

            // Manage event(s) from Rainbow SDK about BUBBLES
            RbBubbles.BubbleInfoUpdated += RbBubbles_BubbleInfoUpdated;

            // Set conversations list using cache
            ResetModelWithRbConversations(RbConversations.GetAllConversationsFromCache());

            // Get first conversation and load its stream
            if (ConversationsLightList.Count > 0)
            {
                CurrentApplication.ApplicationMainWindow.SetConversationIdSelectionFromConversationsList(ConversationsLightList[0].Id);
            }

            // Now allow Avatar download
            AvatarPool.AllowAvatarDownload(true);

            // Now allow to ask server info about unknown contacts
            AvatarPool.AllowToAskInfoForUnknownContact(true);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public ConversationsViewModel()
        {
            Conversations = new ObservableRangeCollection <ConversationLight>();

            // Get Xamarin Application
            XamarinApplication = (InstantMessaging.App)Xamarin.Forms.Application.Current;

            // Manage event(s) from AvatarPool
            avatarPool = AvatarPool.Instance;
            avatarPool.ContactAvatarChanged += AvatarPool_ContactAvatarChanged;
            avatarPool.BubbleAvatarChanged  += AvatarPool_BubbleAvatarChanged;
        }
コード例 #5
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            InitLogs();

            AvatarPool avatarPool = AvatarPool.Instance;

            avatarPool.SetImageManagement(new ImageManagement());

            LoadApplication(new App());

            return(base.FinishedLaunching(app, options));
        }
コード例 #6
0
        private void InitAvatarPool()
        {
            // Get AvatarPool and initialize it
            string avatarsFolderPath = Path.Combine(Helper.GetTempFolder(), "Rainbow.CSharp.SDK", "Avatars");

            // FOR TEST PURPOSE ONLY
            //if (Directory.Exists(avatarsFolderPath))
            //    Directory.Delete(avatarsFolderPath, true);

            AvatarPool avatarPool = AvatarPool.Instance;

            avatarPool.SetAvatarSize(60);
            avatarPool.SetFont("Arial", 20);

            avatarPool.SetFolderPath(avatarsFolderPath);
            avatarPool.SetApplication(ref RbApplication);
        }
コード例 #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            //TabLayoutResource = Resource.Layout.Tabbar;
            //ToolbarResource = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            //Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

            InitLogs();

            AvatarPool avatarPool = AvatarPool.Instance;

            avatarPool.SetImageManagement(new ImageManagement());

            LoadApplication(new App());
        }
コード例 #8
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector(); //显示默认所有参数

        AvatarPool demo = (AvatarPool)target;

        if (GUILayout.Button("Spawn"))
        {
            GamePlayer player = new GamePlayer();
            player.avatar = AvatarModel.Reimu;
            demo.Spawn(player);
        }
        else if (GUILayout.Button("DespawnAll"))
        {
            demo.DespawnAll();
        }
        else if (GUILayout.Button("CountLog"))
        {
            demo.CountLog();
        }
    }
コード例 #9
0
        private void InitAvatarPool()
        {
            // Get AvatarPool and initialize it
            string avatarsFolderPath = Path.Combine(Helper.GetTempFolder(), LogFolderName, "Avatars");

            if (!USE_AVATAR_CACHE)
            {
                if (Directory.Exists(avatarsFolderPath))
                {
                    Directory.Delete(avatarsFolderPath, true);
                }
            }

            AvatarPool avatarPool = AvatarPool.Instance;

            avatarPool.SetAvatarSize(60);
            avatarPool.SetFont("Arial", 11);

            avatarPool.SetFolderPath(avatarsFolderPath);
            avatarPool.SetApplication(ref RbApplication);

            avatarPool.SetImageManagement(new ImageManagement());
        }
コード例 #10
0
        }                                                                               // Need to be public - Used as Binding from XAML

        public FavoritesModel()
        {
            //FavoritesList = new RangeObservableCollection<FavoriteViewModel>(new FavoriteViewModel.FavoriteViewModelComparer());
            FavoritesList = new RangeObservableCollection <FavoriteViewModel>();

            if (CurrentApplication.USE_DUMMY_DATA)
            {
                LoadFakeConversations();
                return;
            }

            // Get Rainbow SDK Objects
            RbBubbles       = CurrentApplication.RbBubbles;
            RbContacts      = CurrentApplication.RbContacts;
            RbConversations = CurrentApplication.RbConversations;
            RbFavorites     = CurrentApplication.RbFavorites;

            // Manage event(s) from AvatarPool
            AvatarPool = AvatarPool.Instance;
            AvatarPool.ContactAvatarChanged += AvatarPool_ContactAvatarChanged;
            AvatarPool.BubbleAvatarChanged  += AvatarPool_BubbleAvatarChanged;

            // Manage event(s) from Rainbow SDK about FAVORITES
            RbFavorites.FavoriteCreated += RbFavorites_FavoriteCreated;
            RbFavorites.FavoriteRemoved += RbFavorites_FavoriteRemoved;
            RbFavorites.FavoriteUpdated += RbFavorites_FavoriteUpdated;

            // Manage event(s) from Rainbow SDK about CONVERSATIONS
            // RbConversations.ConversationRemoved += RbConversations_ConversationRemoved; // A converation removed doesn't mean the favorties is removed
            RbConversations.ConversationUpdated += RbConversations_ConversationUpdated;

            // Manage event(s) from Rainbow SDK about CONTACTS
            RbContacts.ContactPresenceChanged += RbContacts_ContactPresenceChanged;

            RbContacts.PeerAdded       += RbContacts_PeerAdded;
            RbContacts.PeerInfoChanged += RbContacts_PeerInfoChanged;

            // Manage event(s) from Rainbow SDK about BUBBLES
            RbBubbles.BubbleInfoUpdated += RbBubbles_BubbleInfoUpdated;

            // Set favorites list using cache
            Task task = new Task(() =>
            {
                // Get favorites list
                List <Favorite> list = RbFavorites.GetFavorites();

                if ((list != null) && (list.Count > 0))
                {
                    // We need to update UI so we nend to be on correct Thread
                    if (System.Windows.Application.Current != null)
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            ResetModelWithRbFavorites(list);
                        }));
                    }
                }
            });

            task.Start();
        }
        }                                                      // Need to be public - Used as Binding from XAML

        #endregion XAML BINDING ELEMENTS

        #region PUBLIC METHODS

        /// <summary>
        /// Constructor
        /// </summary>
        public ConversationStreamViewModel(String conversationId)
        {
            // Get Xamarin Application
            XamarinApplication = (InstantMessaging.App)Xamarin.Forms.Application.Current;

            // Manage event(s) from FilePool
            filePool = FilePool.Instance;
            filePool.FileDescriptorAvailable += FilePool_FileDescriptorAvailable;
            filePool.ThumbnailAvailable      += FilePool_ThumbnailAvailable;

            // Manage event(s) from AvatarPool
            avatarPool = AvatarPool.Instance;
            avatarPool.ContactAvatarChanged += AvatarPool_ContactAvatarChanged;
            avatarPool.BubbleAvatarChanged  += AvatarPool_BubbleAvatarChanged;

            // Manage event(s) from InstantMessaging
            XamarinApplication.RbInstantMessaging.MessageReceived   += RbInstantMessaging_MessageReceived;
            XamarinApplication.RbInstantMessaging.ReceiptReceived   += RbInstantMessaging_ReceiptReceived;
            XamarinApplication.RbInstantMessaging.MessagesAllRead   += RbInstantMessaging_MessagesAllRead;
            XamarinApplication.RbInstantMessaging.UserTypingChanged += RbInstantMessaging_UserTypingChanged;

            // Manage event(s) from Contacts
            XamarinApplication.RbContacts.ContactAdded       += RbContacts_ContactAdded;
            XamarinApplication.RbContacts.ContactInfoChanged += RbContacts_ContactInfoChanged;

            currentContactJid = XamarinApplication.RbContacts.GetCurrentContactJid();

            // Store conversation Id
            this.conversationId = conversationId;

            // Create default ConversationStream object
            ConversationStream = new ConversationStream
            {
                LoadingIndicatorIsVisible = "False",
                ListViewIsEnabled         = "True"
            };

            // Create default MessagesList  object
            MessagesList = new ObservableRangeCollection <InstantMessaging.Model.Message>();

            if (string.IsNullOrEmpty(this.conversationId))
            {
                //TODO
                Conversation = new ConversationLight();
            }
            else
            {
                // Get Rainbow Conversation object
                rbConversation = XamarinApplication.RbConversations.GetConversationByIdFromCache(this.conversationId);

                // Get Conversation Model Object using Rainbow Conversation
                Conversation = Helper.GetConversationFromRBConversation(rbConversation);
                if (Conversation != null)
                {
                    Conversation.AvatarSource = Helper.GetConversationAvatarImageSource(Conversation);
                }

                // Get Messages
                List <Rainbow.Model.Message> rbMessagesList = XamarinApplication.RbInstantMessaging.GetAllMessagesFromConversationIdFromCache(this.conversationId);
                if (rbMessagesList != null)
                {
                    if (rbMessagesList.Count > 0)
                    {
                        AddToModelRbMessages(rbMessagesList);
                    }

                    if (rbMessagesList.Count < NB_MESSAGE_LOADED_BY_ROW)
                    {
                        LoadMoreMessages();
                    }
                }
                else
                {
                    LoadMoreMessages();
                }
            }
        }
        private InstantMessaging.Model.Message GetMessageFromRBMessage(Rainbow.Model.Message rbMessage, String conversationType)
        {
            InstantMessaging.Model.Message message = null;
            if (rbMessage != null)
            {
                InstantMessaging.App XamarinApplication = (InstantMessaging.App)Xamarin.Forms.Application.Current;
                AvatarPool           avatarPool         = AvatarPool.Instance;

                //log.Debug("[GetMessageFromRBMessage] Message.Id:[{0}] - Message.ReplaceId:[{1}] - DateTime:[{2}] - Content:[{3}]", rbMessage.Id, rbMessage.ReplaceId, rbMessage.Date.ToString("o"), rbMessage.Content);

                message = new InstantMessaging.Model.Message();
                message.EventMessageBodyPart2Color = Color.Black; // Set default value

                Rainbow.Model.Contact contact = XamarinApplication.RbContacts.GetContactFromContactJid(rbMessage.FromJid);
                if (contact != null)
                {
                    message.PeerId = contact.Id;

                    message.PeerDisplayName = Util.GetContactDisplayName(contact);
                    message.BackgroundColor = Color.FromHex(Rainbow.Helpers.AvatarPool.GetColorFromDisplayName(message.PeerDisplayName));
                }
                else
                {
                    message.BackgroundColor = Color.FromHex(Rainbow.Helpers.AvatarPool.GetColorFromDisplayName(""));

                    // We ask to have more info about this contact usin AvatarPool
                    avatarPool.AddUnknownContactToPoolByJid(rbMessage.FromJid);
                }

                // We have the display name only in Room / Bubble context
                message.PeerDisplayNameIsVisible = (conversationType == Rainbow.Model.Conversation.ConversationType.Room) ? "True" : "False";

                message.Id      = rbMessage.Id;
                message.PeerJid = rbMessage.FromJid;

                message.MessageDateTime    = rbMessage.Date;
                message.MessageDateDisplay = Helper.HumanizeDateTime(rbMessage.Date);

                // Receipt
                SetReceiptPartOfMessage(message, rbMessage.Receipt);

                // Is-it an "Event message" ?
                String content;
                if (!String.IsNullOrEmpty(rbMessage.BubbleEvent))
                {
                    message.IsEventMessage        = "True";
                    message.EventMessageBodyPart1 = Helper.GetBubbleEventMessageBody(contact, rbMessage.BubbleEvent);
                }
                // Is-it an "CallLog message" ?
                else if (rbMessage.CallLogAttachment != null)
                {
                    SetCallLogPartOfMessage(message, rbMessage.CallLogAttachment);
                }
                else
                {
                    message.IsEventMessage     = "False";
                    message.BodyFontAttributes = FontAttributes.None;
                    message.BodyColor          = (message.PeerJid == currentContactJid) ? Color.Black : Color.White;

                    if (!String.IsNullOrEmpty(rbMessage.Content))
                    {
                        content = rbMessage.Content;
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(rbMessage.ReplaceId))
                        {
                            content = "";
                        }
                        else
                        {
                            content = "This message was deleted.";
                            message.BodyFontAttributes = FontAttributes.Italic;
                            message.BodyColor          = (message.PeerJid == currentContactJid) ? Color.Gray : Color.FromHex(Rainbow.Helpers.AvatarPool.GetDarkerColorFromDisplayName(message.PeerDisplayName));
                        }
                    }

                    // Edited text visible ?
                    message.EditedIsVisible = String.IsNullOrEmpty(rbMessage.ReplaceId) ? "False" : "True";

                    // Reply part
                    // By default is not displayed
                    message.ReplyPartIsVisible = "False";
                    if (rbMessage.ReplyMessage != null)
                    {
                        // Store Id of this reply message
                        message.ReplyId = rbMessage.ReplyMessage.Id;

                        // Set background color
                        message.ReplyBackgroundColor = Color.FromHex(Rainbow.Helpers.AvatarPool.GetDarkerColorFromDisplayName(message.PeerDisplayName));

                        // We need to get Name and text of the replied message ...
                        Rainbow.Model.Message rbRepliedMessage = XamarinApplication.RbInstantMessaging.GetOneMessageFromConversationIdFromCache(this.conversationId, rbMessage.ReplyMessage.Id);
                        if (rbRepliedMessage != null)
                        {
                            SetReplyPartOfMessage(message, rbRepliedMessage);
                        }
                        else
                        {
                            AddUnknownRepliedMessageInvolved(rbMessage.ReplyMessage.Id, rbMessage.ReplyMessage.Stamp);
                        }
                    }
                    else
                    {
                        // Set default color to avoir warning
                        message.ReplyBackgroundColor = Color.White;
                    }

                    // FileAttachment
                    if (rbMessage.FileAttachment != null)
                    {
                        // Set Global info
                        message.FileAttachmentIsVisible  = "True";
                        message.FileDefaultInfoIsVisible = "True";
                        message.FileId   = rbMessage.FileAttachment.Id;
                        message.FileName = rbMessage.FileAttachment.Name;
                        message.FileSize = Helper.HumanizeFileSize(rbMessage.FileAttachment.Size);

                        if (filePool.IsThumbnailFileAvailable(conversationId, rbMessage.FileAttachment.Id, rbMessage.FileAttachment.Name))
                        {
                            SetFileAttachmentSourceOfMessage(message, rbMessage.FileAttachment.Id);
                        }
                        else
                        {
                            // Ask more info about this file
                            filePool.AskFileDescriptorDownload(this.conversationId, rbMessage.FileAttachment.Id);

                            // Set default icon
                            message.FileAttachmentSource       = "icon_unknown_blue";
                            message.FileAttachmentSourceWidth  = 50;
                            message.FileAttachmentSourceHeight = 50;
                        }
                    }
                    else
                    {
                        message.FileAttachmentIsVisible  = "False";
                        message.FileDefaultInfoIsVisible = "False";

                        message.FileAttachmentSourceWidth  = 0;
                        message.FileAttachmentSourceHeight = 0;
                    }

                    message.Body          = content;
                    message.BodyIsVisible = String.IsNullOrEmpty(message.Body) ? "False" : "True";
                }

                // We store info about this contact in message context
                AddContactInvolved(message.PeerJid);
            }
            return(message);
        }
コード例 #13
0
    void Awake()
    {
        instance = this;

        Init();
    }
コード例 #14
0
        public static ConversationLightViewModel GetConversationFromRBConversation(Rainbow.Model.Conversation rbConversation)
        {
            ConversationLightViewModel conversation = null;

            if (rbConversation != null)
            {
                InstantMessaging.App CurrentApplication = (InstantMessaging.App)System.Windows.Application.Current;
                AvatarPool           avatarPool         = AvatarPool.Instance;

                conversation = new ConversationLightViewModel();

                if (rbConversation.Type == Rainbow.Model.Conversation.ConversationType.Room)
                {
                    conversation.Name           = rbConversation.Name;
                    conversation.Topic          = rbConversation.Topic;
                    conversation.Jid            = rbConversation.Jid_im;
                    conversation.PresenceSource = "";
                }
                else if (rbConversation.Type == Rainbow.Model.Conversation.ConversationType.User)
                {
                    // Get Display name of this user
                    Rainbow.Model.Contact contact = CurrentApplication.RbContacts.GetContactFromContactId(rbConversation.PeerId);
                    if (contact != null)
                    {
                        conversation.Name  = Util.GetContactDisplayName(contact);
                        conversation.Topic = "";
                        conversation.Jid   = contact.Jid_im;

                        Presence presence = CurrentApplication.RbContacts.GetAggregatedPresenceFromContactId(rbConversation.PeerId);
                        conversation.PresenceSource = InstantMessaging.Helpers.Helper.GetPresenceSourceFromPresence(presence, rbConversation.PeerId == CurrentApplication.CurrentUserId);
                    }
                    else
                    {
                        // We ask to have more info about this contact using AvatarPool
                        log.LogDebug("[GetConversationFromRBConversation] - unknown contact - contactId:[{0}]", rbConversation.PeerId);
                        avatarPool.AddUnknownContactToPoolById(rbConversation.PeerId);

                        // Try to get info from pool
                        AvatarsData.LightContact lightContact = avatarPool.GetLightContact(rbConversation.PeerId, rbConversation.Jid_im);

                        if (lightContact != null)
                        {
                            conversation.Name           = lightContact.DisplayName;
                            conversation.Topic          = "";
                            conversation.PeerId         = lightContact.Id;
                            conversation.Jid            = lightContact.Jid;
                            conversation.PresenceSource = "presence_offline.png";
                        }
                    }
                }
                else
                {
                    //TODO ( bot case)
                    log.LogDebug("[GetConversationFromRBConversation] Conversation from model not created - Id:[{0}]", rbConversation.Id);
                    return(null);
                }

                conversation.Id     = rbConversation.Id;
                conversation.PeerId = rbConversation.PeerId;

                conversation.Type        = rbConversation.Type;
                conversation.NbMsgUnread = rbConversation.UnreadMessageNumber;

                conversation.LastMessage         = rbConversation.LastMessageText;
                conversation.LastMessageDateTime = rbConversation.LastMessageDate;
            }
            return(conversation);
        }
コード例 #15
0
        public static FavoriteViewModel GetFavoriteFromRbFavorite(Rainbow.Model.Favorite rbFavorite)
        {
            FavoriteViewModel result = null;

            if (rbFavorite != null)
            {
                InstantMessaging.App CurrentApplication = (InstantMessaging.App)System.Windows.Application.Current;
                AvatarPool           avatarPool         = AvatarPool.Instance;

                result = new FavoriteViewModel();

                Conversation rbConversation = CurrentApplication.RbConversations.GetConversationByPeerIdFromCache(rbFavorite.PeerId);

                if (rbConversation != null)
                {
                    result.IsVisible   = true;
                    result.Jid         = rbConversation.Jid_im;
                    result.NbMsgUnread = rbConversation.UnreadMessageNumber;

                    if (rbConversation.Type == Rainbow.Model.Conversation.ConversationType.Room)
                    {
                        result.Name           = rbConversation.Name;
                        result.PresenceSource = "";
                    }
                    else if (rbConversation.Type == Rainbow.Model.Conversation.ConversationType.User)
                    {
                        // Get Display name of this user
                        Rainbow.Model.Contact contact = CurrentApplication.RbContacts.GetContactFromContactId(rbConversation.PeerId);
                        if (contact != null)
                        {
                            Presence presence = CurrentApplication.RbContacts.GetAggregatedPresenceFromContactId(rbConversation.PeerId);

                            result.Name           = Util.GetContactDisplayName(contact);
                            result.PresenceSource = InstantMessaging.Helpers.Helper.GetPresenceSourceFromPresence(presence, rbConversation.PeerId == CurrentApplication.CurrentUserId);
                        }
                        else
                        {
                            // We ask to have more info about this contact using AvatarPool
                            log.LogDebug("[GetFavoriteFromRbFavorite] - unknown contact - contactId:[{0}]", rbConversation.PeerId);
                            avatarPool.AddUnknownContactToPoolById(rbConversation.PeerId);

                            // Try to get info from pool
                            AvatarsData.LightContact lightContact = avatarPool.GetLightContact(rbConversation.PeerId, rbConversation.Jid_im);

                            if (lightContact != null)
                            {
                                result.Name           = lightContact.DisplayName;
                                result.PresenceSource = "presence_offline.png";
                            }
                        }
                    }
                    else
                    {
                        //TODO (bot case)
                        log.LogDebug("[GetFavoriteFromRbFavorite] Conversation from model not created - Id:[{0}]", rbConversation.Id);
                        return(null);
                    }
                }
                else
                {
                    Bubble bubble = CurrentApplication.RbBubbles.GetBubbleByIdFromCache(rbFavorite.PeerId);
                    if (bubble != null)
                    {
                        result.IsVisible      = true;
                        result.Name           = bubble.Name;
                        result.Jid            = bubble.Jid;
                        result.NbMsgUnread    = 0;
                        result.PresenceSource = "";
                    }
                    else
                    {
                        result.IsVisible      = false;
                        result.Name           = "";
                        result.Jid            = "";
                        result.NbMsgUnread    = 0;
                        result.PresenceSource = "";

                        log.LogWarning("[GetFavoriteFromRbFavorite] Cannot get Conversation or Bubble object from Favorite - FavoriteId:[{0}] - FavoritePeerId:[{1}]", rbFavorite.Id, rbFavorite.PeerId);
                    }

                    //TODO - need to get conversation ?
                }

                result.Id       = rbFavorite.Id;
                result.PeerId   = rbFavorite.PeerId;
                result.Position = rbFavorite.Position;

                // Name, PresenceSource,  NbMsgUnread and IsVisible are set before
            }
            return(result);
        }