private async Task AddMucAsync(Client client, string roomBareJid, string nickname, string password, bool bookmark, bool autoJoin) { ChatModel chat = new ChatModel(roomBareJid, client.dbAccount) { chatType = ChatType.MUC, inRoster = bookmark, subscription = "none", isChatActive = true }; MucInfoModel muc = new MucInfoModel() { chat = chat, subject = null, autoEnterRoom = autoJoin, name = null, nickname = nickname, password = string.IsNullOrEmpty(password) ? null : password, state = MucState.DISCONNECTED }; chat.muc = muc; SemaLock semaLock = DataCache.INSTANCE.NewChatSemaLock(); semaLock.Wait(); DataCache.INSTANCE.AddChatUnsafe(chat, client); semaLock.Dispose(); if (muc.autoEnterRoom) { await MucHandler.INSTANCE.EnterMucAsync(client.xmppClient, muc); } if (bookmark) { List <ConferenceItem> conferenceItems; using (MainDbContext ctx = new MainDbContext()) { conferenceItems = ctx.GetXEP0048ConferenceItemsForAccount(client.dbAccount.bareJid); } MessageResponseHelperResult <IQMessage> result = await client.xmppClient.PUB_SUB_COMMAND_HELPER.setBookmars_xep_0048Async(conferenceItems); if (result.STATE == MessageResponseHelperResultState.SUCCESS) { if (result.RESULT is IQErrorMessage errMsg) { Logger.Warn("Failed to set bookmarks: " + errMsg.ToString()); } } else { Logger.Warn("Failed to set bookmarks: " + result.STATE); } } }
private void UpdateBookmarks(XMPPClient client) { List <ConferenceItem> conferences; using (MainDbContext ctx = new MainDbContext()) { conferences = ctx.GetXEP0048ConferenceItemsForAccount(client.getXMPPAccount().getBareJid()); } if (updateBookmarksHelper != null) { updateBookmarksHelper.Dispose(); } updateBookmarksHelper = client.PUB_SUB_COMMAND_HELPER.setBookmars_xep_0048(conferences, OnUpdateBookmarksMessage, OnUpdateBookmarksTimeout); }
private void UpdateBookmarks(ChatDataTemplate chat) { List <ConferenceItem> conferences; using (MainDbContext ctx = new MainDbContext()) { conferences = ctx.GetXEP0048ConferenceItemsForAccount(chat.Client.dbAccount.bareJid); } if (updateBookmarksHelper != null) { updateBookmarksHelper.Dispose(); } // TODO: Register callbacks for once an error occurred and show a notification to the user updateBookmarksHelper = chat.Client.xmppClient.PUB_SUB_COMMAND_HELPER.setBookmars_xep_0048(conferences, null, null); }
private async Task <bool> UpdateBookmarksAsync(ChatDataTemplate chat) { List <ConferenceItem> conferences; using (MainDbContext ctx = new MainDbContext()) { conferences = ctx.GetXEP0048ConferenceItemsForAccount(chat.Chat.accountBareJid); } MessageResponseHelperResult <IQMessage> result = await chat.Client.xmppClient.PUB_SUB_COMMAND_HELPER.setBookmars_xep_0048Async(conferences); if (string.Equals(result.RESULT.TYPE, IQMessage.RESULT)) { return(true); } if (result.RESULT is IQErrorMessage errorMessage) { Logger.Warn("Failed to update XEP-0048 Bookmarks: " + errorMessage.ERROR_OBJ.ToString()); } else { Logger.Warn("Failed to update XEP-0048 Bookmarks: " + result.RESULT.TYPE); } return(false); }