public static void BookmarksManagerSendsThePasswordToJoin() { using var stream = new MemoryStream(); using var connection = new MockedXmppTcpConnection(null, stream); var elements = new List <XElement>(); connection.Element += (_, element) => elements.Add(element.Stanza); var conference = new BookmarkedConference { JID = new JID("*****@*****.**"), Password = "******" }; var bookmarksManager = new BookmarksManager(connection, false); bookmarksManager.Join(conference); Thread.MemoryBarrier(); var joinElement = Stanza.Parse <XMPPPresence>(elements.Single()); var password = joinElement .Element(XNamespace.Get(Namespaces.MUC) + "x") ! .Element(XNamespace.Get(Namespaces.MUC) + "password") ! .Value; Assert.AreEqual("12345", password); }
protected override void CommandCallback(OleMenuCommand command) { BookmarksManager.GoToNextIn( Package.Options.NavigateInFolderIncludesSubfolders ? BookmarkActionTarget.FolderAndSubfolders : BookmarkActionTarget.Folder); }
protected override void CommandCallback(OleMenuCommand command) { if(!Package.StorageOptions.SaveBookmarksToOwnFile) { if (Helpers.ShowYesNoQuestionMessage(requiresSettingMessage)) this.Package.ShowOptionPage(typeof(StorageOptionsPage)); return; } if(!File.Exists(Package.DataFilePath)) { Helpers.ShowInfoMessage(noFileExistsMessage); return; } if (Package.ConfirmationOptions.ReplacingLoadRequiresConfirmation) { var existingCount = BookmarksManager.GetBookmarksCount(BookmarkActionTarget.Solution); if (existingCount != 0) { var fileCount = BookmarksManager.GetFilesWithBookmarksCount(); var message = $@"{Helpers.Quantifier(existingCount, @"existing bookmark")} in {Helpers.Quantifier(fileCount, "file")} will be replaced with the bookmarks read from the .SuperBookmarks.dat file. Are you sure?"; if (!Helpers.ShowYesNoQuestionMessage(message)) return; } } Package.LoadBookmarksFromDatFile(); }
protected override void CommandCallback(OleMenuCommand command) { var fileName = FileDialogs.BrowseForFileOpen(IntPtr.Zero, ".dat files|*.dat|All files|*.*", Package.GetLastUsedExportImportFolder(), "Import Bookmarks"); if (fileName == null) { return; } SerializableBookmarksInfo info; try { using (var stream = File.OpenRead(fileName)) info = SerializableBookmarksInfo.DeserializeFrom(stream); } catch { Helpers.ShowErrorMessage("Sorry, I couldn't parse the file. Perhaps it is malformed?", showHeader: false); return; } if (!Package.Options.MergeWhenImporting) { if (Package.ConfirmationOptions.ReplacingImportRequiresConfirmation) { var existingCount = BookmarksManager.GetBookmarksCount(BookmarkActionTarget.Solution); if (existingCount != 0) { var newCount = info.TotalBookmarksCount; var message = $@"{Helpers.Quantifier(existingCount, @"existing bookmark")} will be replaced with {Helpers.Quantifier(newCount, "bookmark")} from the file. Are you sure?"; if (!Helpers.ShowYesNoQuestionMessage(message)) { return; } } } this.BookmarksManager.DeleteAllBookmarksIn(BookmarkActionTarget.Solution); } try { this.BookmarksManager.RecreateBookmarksFromSerializedInfo(info); Helpers.WriteToStatusBar($"Import done, solution has now {Helpers.Quantifier(BookmarksManager.GetBookmarksCount(BookmarkActionTarget.Solution), "bookmark")} in {Helpers.Quantifier(BookmarksManager.GetFilesWithBookmarksCount(), "file")}"); } catch { Helpers.ShowErrorMessage("Sorry, I couldn't get bookmarks information from the file. Perhaps it is malformed?", showHeader: false); return; } Package.SetLastUsedExportImportFolder(Path.GetDirectoryName(fileName)); }
public XmppClient(JID jid, string password, bool autoPresence = true) : base(Namespaces.JabberClient, jid, password) { SignedIn += (sender, args) => { if (autoPresence) { Send(new XMPPPresence()); } }; BookmarkManager = new BookmarksManager(this, autoPresence); RosterManager = new RosterManager(this, autoPresence); }
protected override void CommandCallback(OleMenuCommand command) { var shouldAskConfirmation = Package.ConfirmationOptions.ShouldConfirmForDeleteAllIn(Target); if (!shouldAskConfirmation) { BookmarksManager.DeleteAllBookmarksIn(Target); return; } string message; var count = BookmarksManager.GetBookmarksCount(Target); if (count == 0) { message = $"There are no bookmarks in {TargetDisplayName}"; Helpers.ShowInfoMessage(message); return; } message = $@"There {(count == 1 ? "is 1 bookmark" : $"are {count} bookmarks")} in {TargetDisplayName}.
protected override void CommandCallback(OleMenuCommand command) { var count = BookmarksManager.GetBookmarksCount(BookmarkActionTarget.Solution); if (count == 0) { Helpers.ShowInfoMessage("There are no bookmarks to export"); return; } var fileName = FileDialogs.BrowseForFileSave(IntPtr.Zero, ".dat files|*.dat|All files|*.*", Package.GetLastUsedExportImportFolder(), "Export Bookmarks"); if (fileName != null) { var info = this.BookmarksManager.GetSerializableInfo(); using (var stream = File.Create(fileName)) info.SerializeTo(stream, prettyPrint: true); Helpers.WriteToStatusBar($"{Helpers.Quantifier(info.TotalBookmarksCount, "bookmark")} from {Helpers.Quantifier(info.TotalFilesCount, "file")} have been exported to {Path.GetFileName(fileName)}"); Package.SetLastUsedExportImportFolder(Path.GetDirectoryName(fileName)); } }
protected override void CommandCallback(OleMenuCommand command) { BookmarksManager.GoToNextIn(BookmarkActionTarget.OpenDocuments); }
protected override void CommandCallback(OleMenuCommand command) { BookmarksManager.GoToPrevIn(BookmarkActionTarget.Document); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.PagesThumbList, container, false); ListView list = view.FindViewById <ListView>(Resource.Id.viewerPageList); var manager = new BookmarksManager(_pubblicazione); List <Articolo> articles = new List <Articolo>(); var bookmarks = manager.GetBookMarks(); if (_pubblicazione.IsPDF) { int[] pages = { }; var el = from b in bookmarks select(b.Pagina - 1); if (el.Count() > 0) { pages = el.ToArray <int>(); } list.Adapter = new PDFPagesAdapter(Activity, _pdfCore, _pubblicazione.Path, _currentPage, pages); } else { foreach (Bookmark book in bookmarks) { var doc = _pubblicazione.Documenti.Where(d => d.ID == book.Documento).FirstOrDefault <Documento>(); if (doc == null) { continue; } if (!_pubblicazione.IsPDF && !File.Exists(System.IO.Path.Combine(doc.Path, doc.Articoli[book.Pagina - 1].Path, "miniatura.jpg"))) { continue; } if (book.Pagina - 1 < doc.Articoli.Count) { var art = doc.Articoli[book.Pagina - 1]; articles.Add(art); } } list.Adapter = new PagesAdapter(Activity, articles, _pubblicazione, _documento, _currentPage, bookmarks); } list.ItemClick += (sender, e) => { var book = bookmarks[e.Position]; _pageItemClick(new string[] { book.Documento, (book.Pagina - 1).ToString() }); }; return(view); }
protected override void CommandCallback(OleMenuCommand command) { BookmarksManager.SetOrRemoveBookmarkInCurrentDocument(); }