[gnome-pocket] Rename GnomePocket object to GnomePocketClient
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-pocket] Rename GnomePocket object to GnomePocketClient
- Date: Sat, 20 Sep 2014 20:32:55 +0000 (UTC)
commit 3bec3acc496bb18eb8c415dad297b9514cb67627
Author: Bastien Nocera <hadess hadess net>
Date: Sat Sep 20 22:31:31 2014 +0200
Rename GnomePocket object to GnomePocketClient
Makefile.am | 3 +-
.../{gnome-pocket.c => gnome-pocket-client.c} | 98 ++++++++++----------
gnome-pocket/gnome-pocket-client.h | 82 ++++++++++++++++
gnome-pocket/gnome-pocket.h | 54 +----------
test.c | 21 ++--
5 files changed, 145 insertions(+), 113 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 6bb6c53..9396c0f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,7 +26,8 @@ libgnome_pocket_la_LIBADD = $(GNOME_POCKET_LIBS)
libgnome_pocket_la_LDFLAGS = -avoid-version
libgnome_pocket_la_SOURCES = \
gnome-pocket/gnome-pocket.h \
- gnome-pocket/gnome-pocket.c \
+ gnome-pocket/gnome-pocket-client.h \
+ gnome-pocket/gnome-pocket-client.c \
gnome-pocket/gnome-pocket-item.h \
gnome-pocket/gnome-pocket-item.c
diff --git a/gnome-pocket/gnome-pocket.c b/gnome-pocket/gnome-pocket-client.c
similarity index 89%
rename from gnome-pocket/gnome-pocket.c
rename to gnome-pocket/gnome-pocket-client.c
index 4f586c9..636e971 100644
--- a/gnome-pocket/gnome-pocket.c
+++ b/gnome-pocket/gnome-pocket-client.c
@@ -39,11 +39,11 @@ enum {
PROP_AVAILABLE
};
-G_DEFINE_TYPE (GnomePocket, gnome_pocket, G_TYPE_OBJECT);
+G_DEFINE_TYPE (GnomePocketClient, gnome_pocket_client, G_TYPE_OBJECT);
-#define GNOME_POCKET_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GNOME_TYPE_POCKET,
GnomePocketPrivate))
+#define GNOME_POCKET_CLIENT_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object),
GNOME_TYPE_POCKET_CLIENT, GnomePocketClientPrivate))
-struct _GnomePocketPrivate {
+struct _GnomePocketClientPrivate {
GCancellable *cancellable;
GoaClient *client;
GoaOAuth2Based *oauth2;
@@ -59,14 +59,14 @@ struct _GnomePocketPrivate {
};
gboolean
-gnome_pocket_refresh_finish (GnomePocket *self,
+gnome_pocket_client_refresh_finish (GnomePocketClient *self,
GAsyncResult *res,
GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
gboolean ret = FALSE;
- g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == gnome_pocket_refresh);
+ g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == gnome_pocket_client_refresh);
if (!g_simple_async_result_propagate_error (simple, error))
ret = g_simple_async_result_get_op_res_gboolean (simple);
@@ -214,7 +214,7 @@ end:
}
static void
-update_list (GnomePocket *self,
+update_list (GnomePocketClient *self,
GList *updated_items)
{
GHashTable *removed; /* key=id, value=gboolean */
@@ -283,7 +283,7 @@ update_list (GnomePocket *self,
}
static gint64
-load_since (GnomePocket *self)
+load_since (GnomePocketClient *self)
{
char *path;
char *contents = NULL;
@@ -302,7 +302,7 @@ load_since (GnomePocket *self)
}
static void
-save_since (GnomePocket *self)
+save_since (GnomePocketClient *self)
{
char *str;
char *path;
@@ -410,9 +410,9 @@ refresh_cb (GObject *object,
rest_proxy_call_get_payload_length (REST_PROXY_CALL (object)),
NULL)) {
GList *updated_items;
- GnomePocket *self;
+ GnomePocketClient *self;
- self = GNOME_POCKET (g_async_result_get_source_object (G_ASYNC_RESULT (simple)));
+ self = GNOME_POCKET_CLIENT (g_async_result_get_source_object (G_ASYNC_RESULT (simple)));
updated_items = parse_json (parser, &self->priv->since, self->priv->repository);
if (self->priv->since != 0)
save_since (self);
@@ -429,7 +429,7 @@ refresh_cb (GObject *object,
}
void
-gnome_pocket_refresh (GnomePocket *self,
+gnome_pocket_client_refresh (GnomePocketClient *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -444,7 +444,7 @@ gnome_pocket_refresh (GnomePocket *self,
simple = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
- gnome_pocket_refresh);
+ gnome_pocket_client_refresh);
g_simple_async_result_set_check_cancellable (simple, cancellable);
@@ -470,14 +470,14 @@ gnome_pocket_refresh (GnomePocket *self,
}
gboolean
-gnome_pocket_add_url_finish (GnomePocket *self,
+gnome_pocket_client_add_url_finish (GnomePocketClient *self,
GAsyncResult *res,
GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
gboolean ret = FALSE;
- g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == gnome_pocket_add_url);
+ g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == gnome_pocket_client_add_url);
if (!g_simple_async_result_propagate_error (simple, error))
ret = g_simple_async_result_get_op_res_gboolean (simple);
@@ -505,7 +505,7 @@ add_url_cb (GObject *object,
}
void
-gnome_pocket_add_url (GnomePocket *self,
+gnome_pocket_client_add_url (GnomePocketClient *self,
const char *url,
const char *tweet_id,
GCancellable *cancellable,
@@ -522,7 +522,7 @@ gnome_pocket_add_url (GnomePocket *self,
simple = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
- gnome_pocket_add_url);
+ gnome_pocket_client_add_url);
g_simple_async_result_set_check_cancellable (simple, cancellable);
@@ -544,7 +544,7 @@ load_cached_thread (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
- GnomePocket *self = GNOME_POCKET (source_object);
+ GnomePocketClient *self = GNOME_POCKET_CLIENT (source_object);
GomResourceGroup *group;
GError *error = NULL;
guint count, i;
@@ -584,7 +584,7 @@ load_cached_thread (GTask *task,
}
void
-gnome_pocket_load_cached (GnomePocket *self,
+gnome_pocket_client_load_cached (GnomePocketClient *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -600,7 +600,7 @@ gnome_pocket_load_cached (GnomePocket *self,
}
gboolean
-gnome_pocket_load_cached_finish (GnomePocket *self,
+gnome_pocket_client_load_cached_finish (GnomePocketClient *self,
GAsyncResult *res,
GError **error)
{
@@ -612,26 +612,26 @@ gnome_pocket_load_cached_finish (GnomePocket *self,
}
/**
- * gnome_pocket_get_items:
- * @self: a #GnomePocket
+ * gnome_pocket_client_get_items:
+ * @self: a #GnomePocketClient
*
* Gets the items that Pocket knows about.
*
* Returns: (element-type GnomePocketItem) (transfer none): A list of
* items or %NULL. Do not modify or free the list, it belongs to the
- * #GnomePocket object.
+ * #GnomePocketClient object.
**/
GList *
-gnome_pocket_get_items (GnomePocket *self)
+gnome_pocket_client_get_items (GnomePocketClient *self)
{
g_return_val_if_fail (self->priv->cache_loaded, NULL);
return self->priv->items;
}
static void
-gnome_pocket_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+gnome_pocket_client_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
{
- GnomePocket *self = GNOME_POCKET (object);
+ GnomePocketClient *self = GNOME_POCKET_CLIENT (object);
switch (property_id) {
case PROP_AVAILABLE:
@@ -644,9 +644,9 @@ gnome_pocket_get_property (GObject *object, guint property_id, GValue *value, GP
}
static void
-gnome_pocket_finalize (GObject *object)
+gnome_pocket_client_finalize (GObject *object)
{
- GnomePocketPrivate *priv = GNOME_POCKET (object)->priv;
+ GnomePocketClientPrivate *priv = GNOME_POCKET_CLIENT (object)->priv;
GError *error = NULL;
g_cancellable_cancel (priv->cancellable);
@@ -671,11 +671,11 @@ gnome_pocket_finalize (GObject *object)
g_clear_object (&priv->repository);
}
- G_OBJECT_CLASS (gnome_pocket_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gnome_pocket_client_parent_class)->finalize (object);
}
static void
-gnome_pocket_class_init (GnomePocketClass *klass)
+gnome_pocket_client_class_init (GnomePocketClientClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -684,8 +684,8 @@ gnome_pocket_class_init (GnomePocketClass *klass)
g_mkdir_with_parents (cache_path, 0700);
}
- object_class->get_property = gnome_pocket_get_property;
- object_class->finalize = gnome_pocket_finalize;
+ object_class->get_property = gnome_pocket_client_get_property;
+ object_class->finalize = gnome_pocket_client_finalize;
g_object_class_install_property (object_class,
PROP_AVAILABLE,
@@ -695,7 +695,7 @@ gnome_pocket_class_init (GnomePocketClass *klass)
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
- g_type_class_add_private (object_class, sizeof (GnomePocketPrivate));
+ g_type_class_add_private (object_class, sizeof (GnomePocketClientPrivate));
}
static void
@@ -703,7 +703,7 @@ migrate_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
- GnomePocket *self = user_data;
+ GnomePocketClient *self = user_data;
GomRepository *repository = (GomRepository *)object;
GError *error = NULL;
@@ -723,7 +723,7 @@ open_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
- GnomePocket *self = user_data;
+ GnomePocketClient *self = user_data;
GomAdapter *adapter = (GomAdapter *)object;
GError *error = NULL;
GList *object_types;
@@ -751,7 +751,7 @@ get_db_uri (void)
}
static void
-setup_database (GnomePocket *self)
+setup_database (GnomePocketClient *self)
{
GomAdapter *adapter;
char *uri;
@@ -766,7 +766,7 @@ setup_database (GnomePocket *self)
static void
got_access_token (GObject *object,
GAsyncResult *res,
- GnomePocket *self)
+ GnomePocketClient *self)
{
GError *error = NULL;
char *access_token;
@@ -793,7 +793,7 @@ got_access_token (GObject *object,
}
static void
-handle_accounts (GnomePocket *self)
+handle_accounts (GnomePocketClient *self)
{
GList *accounts, *l;
GoaOAuth2Based *oauth2 = NULL;
@@ -837,7 +837,7 @@ handle_accounts (GnomePocket *self)
static void
account_added_cb (GoaClient *client,
GoaObject *object,
- GnomePocket *self)
+ GnomePocketClient *self)
{
if (self->priv->oauth2 != NULL) {
/* Don't care, already have an account */
@@ -850,7 +850,7 @@ account_added_cb (GoaClient *client,
static void
account_changed_cb (GoaClient *client,
GoaObject *object,
- GnomePocket *self)
+ GnomePocketClient *self)
{
GoaOAuth2Based *oauth2;
@@ -864,7 +864,7 @@ account_changed_cb (GoaClient *client,
static void
account_removed_cb (GoaClient *client,
GoaObject *object,
- GnomePocket *self)
+ GnomePocketClient *self)
{
GoaOAuth2Based *oauth2;
@@ -878,7 +878,7 @@ account_removed_cb (GoaClient *client,
static void
client_ready_cb (GObject *source_object,
GAsyncResult *res,
- GnomePocket *self)
+ GnomePocketClient *self)
{
GoaClient *client;
GError *error = NULL;
@@ -906,11 +906,11 @@ client_ready_cb (GObject *source_object,
}
static void
-gnome_pocket_init (GnomePocket *self)
+gnome_pocket_client_init (GnomePocketClient *self)
{
g_assert (cache_path);
- self->priv = GNOME_POCKET_GET_PRIVATE (self);
+ self->priv = GNOME_POCKET_CLIENT_GET_PRIVATE (self);
self->priv->cancellable = g_cancellable_new ();
self->priv->proxy = rest_proxy_new ("https://getpocket.com/", FALSE);
@@ -919,16 +919,16 @@ gnome_pocket_init (GnomePocket *self)
}
/**
- * gnome_pocket_new:
+ * gnome_pocket_client_new:
*
- * Creates a new #GnomePocket object.
+ * Creates a new #GnomePocketClient object.
*
- * Returns: (transfer full): a new #GnomePocket object. Use g_object_unref() when done.
+ * Returns: (transfer full): a new #GnomePocketClient object. Use g_object_unref() when done.
**/
-GnomePocket *
-gnome_pocket_new (void)
+GnomePocketClient *
+gnome_pocket_client_new (void)
{
- return g_object_new (GNOME_TYPE_POCKET, NULL);
+ return g_object_new (GNOME_TYPE_POCKET_CLIENT, NULL);
}
/*
diff --git a/gnome-pocket/gnome-pocket-client.h b/gnome-pocket/gnome-pocket-client.h
new file mode 100644
index 0000000..bf68b47
--- /dev/null
+++ b/gnome-pocket/gnome-pocket-client.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2013 Bastien Nocera <hadess hadess net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any pocket version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef GNOME_POCKET_CLIENT_H
+#define GNOME_POCKET_CLIENT_H
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define GNOME_TYPE_POCKET_CLIENT (gnome_pocket_client_get_type ())
+#define GNOME_POCKET_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNOME_TYPE_POCKET_CLIENT,
GnomePocketClient))
+#define GNOME_POCKET_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNOME_TYPE_POCKET_CLIENT,
GnomePocketClientClass))
+#define GNOME_IS_POCKET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNOME_TYPE_POCKET_CLIENT))
+#define GNOME_IS_POCKET_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNOME_TYPE_POCKET_CLIENT))
+#define GNOME_POCKET_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNOME_TYPE_POCKET_CLIENT,
GnomePocketClientClass))
+
+typedef struct _GnomePocketClient GnomePocketClient;
+typedef struct _GnomePocketClientClass GnomePocketClientClass;
+typedef struct _GnomePocketClientPrivate GnomePocketClientPrivate;
+
+struct _GnomePocketClient
+{
+ /*< private >*/
+ GObject parent;
+ GnomePocketClientPrivate *priv;
+};
+
+struct _GnomePocketClientClass
+{
+ /*< private >*/
+ GObjectClass parent;
+};
+
+GType gnome_pocket_client_get_type (void) G_GNUC_CONST;
+
+GnomePocketClient *gnome_pocket_client_new (void);
+void gnome_pocket_client_add_url (GnomePocketClient *self,
+ const char *url,
+ const char *tweet_id,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean gnome_pocket_client_add_url_finish (GnomePocketClient *self,
+ GAsyncResult *res,
+ GError **error);
+void gnome_pocket_client_refresh (GnomePocketClient *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean gnome_pocket_client_refresh_finish (GnomePocketClient *self,
+ GAsyncResult *res,
+ GError **error);
+GList *gnome_pocket_client_get_items (GnomePocketClient *self);
+
+void gnome_pocket_client_load_cached (GnomePocketClient *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean gnome_pocket_client_load_cached_finish (GnomePocketClient *self,
+ GAsyncResult *res,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* GNOME_POCKET_CLIENT_H */
diff --git a/gnome-pocket/gnome-pocket.h b/gnome-pocket/gnome-pocket.h
index c950074..1001c17 100644
--- a/gnome-pocket/gnome-pocket.h
+++ b/gnome-pocket/gnome-pocket.h
@@ -24,58 +24,8 @@
G_BEGIN_DECLS
-#define GNOME_TYPE_POCKET (gnome_pocket_get_type ())
-#define GNOME_POCKET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNOME_TYPE_POCKET, GnomePocket))
-#define GNOME_POCKET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNOME_TYPE_POCKET, GnomePocketClass))
-#define GNOME_IS_POCKET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNOME_TYPE_POCKET))
-#define GNOME_IS_POCKET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNOME_TYPE_POCKET))
-#define GNOME_POCKET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNOME_TYPE_POCKET, GnomePocketClass))
-
-typedef struct _GnomePocket GnomePocket;
-typedef struct _GnomePocketClass GnomePocketClass;
-typedef struct _GnomePocketPrivate GnomePocketPrivate;
-
-struct _GnomePocket
-{
- /*< private >*/
- GObject parent;
- GnomePocketPrivate *priv;
-};
-
-struct _GnomePocketClass
-{
- /*< private >*/
- GObjectClass parent;
-};
-
-GType gnome_pocket_get_type (void) G_GNUC_CONST;
-
-GnomePocket *gnome_pocket_new (void);
-void gnome_pocket_add_url (GnomePocket *self,
- const char *url,
- const char *tweet_id,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean gnome_pocket_add_url_finish (GnomePocket *self,
- GAsyncResult *res,
- GError **error);
-void gnome_pocket_refresh (GnomePocket *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean gnome_pocket_refresh_finish (GnomePocket *self,
- GAsyncResult *res,
- GError **error);
-GList *gnome_pocket_get_items (GnomePocket *self);
-
-void gnome_pocket_load_cached (GnomePocket *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean gnome_pocket_load_cached_finish (GnomePocket *self,
- GAsyncResult *res,
- GError **error);
+#include <gnome-pocket/gnome-pocket-client.h>
+#include <gnome-pocket/gnome-pocket-item.h>
G_END_DECLS
diff --git a/test.c b/test.c
index b38deb0..6abf127 100644
--- a/test.c
+++ b/test.c
@@ -1,16 +1,15 @@
#include <locale.h>
#include <gnome-pocket/gnome-pocket.h>
-#include <gnome-pocket/gnome-pocket-item.h>
static GMainLoop *loop = NULL;
static void
-print_items (GnomePocket *pocket)
+print_items (GnomePocketClient *pocket)
{
GList *items, *l;
- items = gnome_pocket_get_items (pocket);
+ items = gnome_pocket_client_get_items (pocket);
for (l = items; l != NULL; l = l->next) {
GnomePocketItem *item = l->data;
@@ -27,10 +26,10 @@ refresh_cb (GObject *object,
g_message ("finished a refresh");
- ret = gnome_pocket_refresh_finish (GNOME_POCKET (object), res, NULL);
+ ret = gnome_pocket_client_refresh_finish (GNOME_POCKET_CLIENT (object), res, NULL);
g_message ("refresh_cb: %d", ret);
- print_items (GNOME_POCKET (object));
+ print_items (GNOME_POCKET_CLIENT (object));
g_main_loop_quit (loop);
}
@@ -42,19 +41,19 @@ cached_cb (GObject *object,
{
gboolean ret;
- ret = gnome_pocket_load_cached_finish (GNOME_POCKET (object), res, NULL);
+ ret = gnome_pocket_client_load_cached_finish (GNOME_POCKET_CLIENT (object), res, NULL);
if (!ret) {
g_message ("Failed to load the cached data");
return;
}
#if 0
- print_items (GNOME_POCKET (object));
+ print_items (GNOME_POCKET_CLIENT (object));
g_main_loop_quit (loop);
return;
#endif
g_message ("launching a refresh");
- gnome_pocket_refresh (GNOME_POCKET (object),
+ gnome_pocket_client_refresh (GNOME_POCKET_CLIENT (object),
NULL,
refresh_cb,
NULL);
@@ -73,7 +72,7 @@ is_available (GObject *gobject,
}
g_message ("Loading cached data");
- gnome_pocket_load_cached (GNOME_POCKET (user_data),
+ gnome_pocket_client_load_cached (GNOME_POCKET_CLIENT (user_data),
NULL,
cached_cb,
NULL);
@@ -81,14 +80,14 @@ is_available (GObject *gobject,
int main (int argc, char **argv)
{
- GnomePocket *pocket;
+ GnomePocketClient *pocket;
setlocale (LC_ALL, "");
g_set_prgname ("org.gnome.Pocket.test");
loop = g_main_loop_new (NULL, FALSE);
- pocket = gnome_pocket_new ();
+ pocket = gnome_pocket_client_new ();
g_signal_connect (pocket, "notify::available",
G_CALLBACK (is_available), pocket);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]