1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  *  Copyright © 2016 Iulian-Gabriel Radu <iulian.radu67@gmail.com>
4  *
5  *  This file is part of Epiphany.
6  *
7  *  Epiphany is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  Epiphany is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with Epiphany.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #pragma once
22 
23 #include "ephy-bookmark.h"
24 
25 #include <glib/gi18n.h>
26 #include <gio/gio.h>
27 
28 G_BEGIN_DECLS
29 
30 #define EPHY_TYPE_BOOKMARKS_MANAGER (ephy_bookmarks_manager_get_type ())
31 
32 G_DECLARE_FINAL_TYPE (EphyBookmarksManager, ephy_bookmarks_manager, EPHY, BOOKMARKS_MANAGER, GObject)
33 
34 #define EPHY_BOOKMARKS_FAVORITES_TAG    _("Favorites")
35 #define EPHY_BOOKMARKS_MOBILE_TAG       _("Mobile")
36 #define FIREFOX_BOOKMARKS_MOBILE_FOLDER "Mobile Bookmarks"
37 
38 EphyBookmarksManager *ephy_bookmarks_manager_new                    (void);
39 
40 void         ephy_bookmarks_manager_add_bookmark                    (EphyBookmarksManager *self,
41                                                                      EphyBookmark         *bookmark);
42 void         ephy_bookmarks_manager_add_bookmarks                   (EphyBookmarksManager *self,
43                                                                      GSequence            *bookmarks);
44 void         ephy_bookmarks_manager_remove_bookmark                 (EphyBookmarksManager *self,
45                                                                      EphyBookmark         *bookmark);
46 EphyBookmark *ephy_bookmarks_manager_get_bookmark_by_url            (EphyBookmarksManager *self,
47                                                                      const char           *url);
48 EphyBookmark *ephy_bookmarks_manager_get_bookmark_by_id             (EphyBookmarksManager *self,
49                                                                      const char           *id);
50 
51 void         ephy_bookmarks_manager_create_tag                      (EphyBookmarksManager *self,
52                                                                      const char           *tag);
53 void         ephy_bookmarks_manager_delete_tag                      (EphyBookmarksManager *self,
54                                                                      const char           *tag);
55 gboolean     ephy_bookmarks_manager_tag_exists                      (EphyBookmarksManager *self,
56                                                                      const char           *tag);
57 
58 GSequence   *ephy_bookmarks_manager_get_bookmarks                   (EphyBookmarksManager *self);
59 GSequence   *ephy_bookmarks_manager_get_bookmarks_with_tag          (EphyBookmarksManager *self,
60                                                                      const char           *tag);
61 gboolean     ephy_bookmarks_manager_has_bookmarks_with_tag          (EphyBookmarksManager *self,
62                                                                      const char           *tag);
63 GSequence   *ephy_bookmarks_manager_get_tags                        (EphyBookmarksManager *self);
64 
65 gboolean     ephy_bookmarks_manager_save_sync                       (EphyBookmarksManager  *self,
66                                                                      GError               **error);
67 void         ephy_bookmarks_manager_save                            (EphyBookmarksManager  *self,
68                                                                      GCancellable          *cancellable,
69                                                                      GAsyncReadyCallback    callback,
70                                                                      gpointer               user_data);
71 gboolean     ephy_bookmarks_manager_save_finish                     (EphyBookmarksManager  *self,
72                                                                      GAsyncResult          *result,
73                                                                      GError               **error);
74 
75 void          ephy_bookmarks_manager_save_warn_on_error_cb          (GObject               *object,
76                                                                      GAsyncResult          *result,
77                                                                      gpointer               user_data);
78 GCancellable *ephy_bookmarks_manager_save_warn_on_error_cancellable (EphyBookmarksManager  *self);
79 
80 G_END_DECLS
81