[gthumb] fixed some compilation errors
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] fixed some compilation errors
- Date: Wed, 19 May 2010 18:53:27 +0000 (UTC)
commit df92d0fbfca9e58fc1530ff080f4fa876cb70b17
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Apr 22 01:08:16 2010 +0200
fixed some compilation errors
extensions/oauth/Makefile.am | 7 +-
extensions/oauth/oauth-account-chooser-dialog.c | 66 ++--
extensions/oauth/oauth-account-chooser-dialog.h | 42 +-
extensions/oauth/oauth-account-manager-dialog.c | 60 ++--
extensions/oauth/oauth-account-manager-dialog.h | 38 +-
extensions/oauth/oauth-account.c | 9 +
extensions/oauth/oauth-account.h | 4 +-
extensions/oauth/oauth-authentication.c | 153 +++++-
extensions/oauth/oauth-authentication.h | 8 +
extensions/oauth/oauth-connection.c | 75 ++--
extensions/oauth/oauth-connection.h | 32 ++-
extensions/oauth/oauth-types.h | 52 --
extensions/photobucket/Makefile.am | 23 +-
extensions/photobucket/dlg-export-to-photobucket.c | 4 +-
extensions/photobucket/photobucket-consumer.c | 211 ++++++++
extensions/photobucket/photobucket-consumer.h | 30 ++
extensions/photobucket/photobucket-service.c | 533 --------------------
extensions/photobucket/photobucket-service.h | 72 ---
18 files changed, 561 insertions(+), 858 deletions(-)
---
diff --git a/extensions/oauth/Makefile.am b/extensions/oauth/Makefile.am
index ff9a692..deb10ad 100644
--- a/extensions/oauth/Makefile.am
+++ b/extensions/oauth/Makefile.am
@@ -16,12 +16,7 @@ liboauth_la_SOURCES = \
oauth-authentication.c \
oauth-authentication.h \
oauth-connection.c \
- oauth-connection.h \
- oauth-service.c \
- oauth-service.h \
- oauth-types.h \
- oauth-user.c \
- oauth-user.h
+ oauth-connection.h
liboauth_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(GNOME_KEYRING_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
liboauth_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
diff --git a/extensions/oauth/oauth-account-chooser-dialog.c b/extensions/oauth/oauth-account-chooser-dialog.c
index ff539e4..a486263 100644
--- a/extensions/oauth/oauth-account-chooser-dialog.c
+++ b/extensions/oauth/oauth-account-chooser-dialog.c
@@ -22,7 +22,7 @@
#include <config.h>
#include <glib/gi18n.h>
-#include "flickr-account-chooser-dialog.h"
+#include "oauth-account-chooser-dialog.h"
#define GET_WIDGET(x) (_gtk_builder_get_widget (self->priv->builder, (x)))
@@ -38,17 +38,17 @@ enum {
static gpointer parent_class = NULL;
-struct _FlickrAccountChooserDialogPrivate {
+struct _OAuthAccountChooserDialogPrivate {
GtkBuilder *builder;
};
static void
-flickr_account_chooser_dialog_finalize (GObject *object)
+oauth_account_chooser_dialog_finalize (GObject *object)
{
- FlickrAccountChooserDialog *self;
+ OAuthAccountChooserDialog *self;
- self = FLICKR_ACCOUNT_CHOOSER_DIALOG (object);
+ self = OAUTH_ACCOUNT_CHOOSER_DIALOG (object);
_g_object_unref (self->priv->builder);
@@ -57,15 +57,15 @@ flickr_account_chooser_dialog_finalize (GObject *object)
static void
-flickr_account_chooser_dialog_class_init (FlickrAccountChooserDialogClass *klass)
+oauth_account_chooser_dialog_class_init (OAuthAccountChooserDialogClass *klass)
{
GObjectClass *object_class;
parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (FlickrAccountChooserDialogPrivate));
+ g_type_class_add_private (klass, sizeof (OAuthAccountChooserDialogPrivate));
object_class = (GObjectClass*) klass;
- object_class->finalize = flickr_account_chooser_dialog_finalize;
+ object_class->finalize = oauth_account_chooser_dialog_finalize;
}
@@ -73,9 +73,9 @@ static void
account_combobox_changed_cb (GtkComboBox *combobox,
gpointer user_data)
{
- FlickrAccountChooserDialog *self = user_data;
- GtkTreeIter iter;
- FlickrAccount *account;
+ OAuthAccountChooserDialog *self = user_data;
+ GtkTreeIter iter;
+ OAuthAccount *account;
if (! gtk_combo_box_get_active_iter (combobox, &iter))
return;
@@ -85,7 +85,7 @@ account_combobox_changed_cb (GtkComboBox *combobox,
-1);
if (account == NULL)
- gtk_dialog_response (GTK_DIALOG (self), FLICKR_ACCOUNT_CHOOSER_RESPONSE_NEW);
+ gtk_dialog_response (GTK_DIALOG (self), OAUTH_ACCOUNT_CHOOSER_RESPONSE_NEW);
_g_object_unref (account);
}
@@ -96,7 +96,7 @@ row_separator_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer user_data)
{
- FlickrAccountChooserDialog *self = user_data;
+ OAuthAccountChooserDialog *self = user_data;
gboolean is_separator;
gtk_tree_model_get (GTK_TREE_MODEL (GET_WIDGET ("account_liststore")),
@@ -109,11 +109,11 @@ row_separator_func (GtkTreeModel *model,
static void
-flickr_account_chooser_dialog_init (FlickrAccountChooserDialog *self)
+oauth_account_chooser_dialog_init (OAuthAccountChooserDialog *self)
{
GtkWidget *content;
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, FLICKR_TYPE_ACCOUNT_CHOOSER_DIALOG, FlickrAccountChooserDialogPrivate);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, OAUTH_TYPE_ACCOUNT_CHOOSER_DIALOG, OAuthAccountChooserDialogPrivate);
self->priv->builder = _gtk_builder_new_from_file ("flicker-account-chooser.ui", "flicker");
gtk_window_set_resizable (GTK_WINDOW (self), FALSE);
@@ -154,7 +154,7 @@ flickr_account_chooser_dialog_init (FlickrAccountChooserDialog *self)
gtk_dialog_add_button (GTK_DIALOG (self),
GTK_STOCK_NEW,
- FLICKR_ACCOUNT_CHOOSER_RESPONSE_NEW);
+ OAUTH_ACCOUNT_CHOOSER_RESPONSE_NEW);
gtk_dialog_add_button (GTK_DIALOG (self),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
@@ -166,25 +166,25 @@ flickr_account_chooser_dialog_init (FlickrAccountChooserDialog *self)
GType
-flickr_account_chooser_dialog_get_type (void)
+oauth_account_chooser_dialog_get_type (void)
{
static GType type = 0;
if (type == 0) {
static const GTypeInfo g_define_type_info = {
- sizeof (FlickrAccountChooserDialogClass),
+ sizeof (OAuthAccountChooserDialogClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
- (GClassInitFunc) flickr_account_chooser_dialog_class_init,
+ (GClassInitFunc) oauth_account_chooser_dialog_class_init,
(GClassFinalizeFunc) NULL,
NULL,
- sizeof (FlickrAccountChooserDialog),
+ sizeof (OAuthAccountChooserDialog),
0,
- (GInstanceInitFunc) flickr_account_chooser_dialog_init,
+ (GInstanceInitFunc) oauth_account_chooser_dialog_init,
NULL
};
type = g_type_register_static (GTK_TYPE_DIALOG,
- "FlickrAccountChooserDialog",
+ "OAuthAccountChooserDialog",
&g_define_type_info,
0);
}
@@ -194,9 +194,9 @@ flickr_account_chooser_dialog_get_type (void)
static void
-flickr_account_chooser_dialog_construct (FlickrAccountChooserDialog *self,
+oauth_account_chooser_dialog_construct (OAuthAccountChooserDialog *self,
GList *accounts,
- FlickrAccount *default_account)
+ OAuthAccount *default_account)
{
GtkTreeIter iter;
GList *scan;
@@ -206,7 +206,7 @@ flickr_account_chooser_dialog_construct (FlickrAccountChooserDialog *self,
gtk_list_store_clear (GTK_LIST_STORE (GET_WIDGET ("account_liststore")));
for (scan = accounts, idx = 0; scan; scan = scan->next, idx++) {
- FlickrAccount *account = scan->data;
+ OAuthAccount *account = scan->data;
if ((default_account != NULL) && (g_strcmp0 (account->username, default_account->username) == 0))
active = idx;
@@ -238,23 +238,23 @@ flickr_account_chooser_dialog_construct (FlickrAccountChooserDialog *self,
GtkWidget *
-flickr_account_chooser_dialog_new (GList *accounts,
- FlickrAccount *default_account)
+oauth_account_chooser_dialog_new (GList *accounts,
+ OAuthAccount *default_account)
{
- FlickrAccountChooserDialog *self;
+ OAuthAccountChooserDialog *self;
- self = g_object_new (FLICKR_TYPE_ACCOUNT_CHOOSER_DIALOG, NULL);
- flickr_account_chooser_dialog_construct (self, accounts, default_account);
+ self = g_object_new (OAUTH_TYPE_ACCOUNT_CHOOSER_DIALOG, NULL);
+ oauth_account_chooser_dialog_construct (self, accounts, default_account);
return (GtkWidget *) self;
}
-FlickrAccount *
-flickr_account_chooser_dialog_get_active (FlickrAccountChooserDialog *self)
+OAuthAccount *
+oauth_account_chooser_dialog_get_active (OAuthAccountChooserDialog *self)
{
GtkTreeIter iter;
- FlickrAccount *account;
+ OAuthAccount *account;
if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (GET_WIDGET ("account_combobox")), &iter))
return NULL;
diff --git a/extensions/oauth/oauth-account-chooser-dialog.h b/extensions/oauth/oauth-account-chooser-dialog.h
index a288527..bc1cc15 100644
--- a/extensions/oauth/oauth-account-chooser-dialog.h
+++ b/extensions/oauth/oauth-account-chooser-dialog.h
@@ -20,42 +20,42 @@
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
-#ifndef FLICKR_ACCOUNT_CHOOSER_DIALOG_H
-#define FLICKR_ACCOUNT_CHOOSER_DIALOG_H
+#ifndef OAUTH_ACCOUNT_CHOOSER_DIALOG_H
+#define OAUTH_ACCOUNT_CHOOSER_DIALOG_H
#include <gtk/gtk.h>
#include <gthumb.h>
-#include "flickr-account.h"
+#include "oauth-account.h"
G_BEGIN_DECLS
-#define FLICKR_ACCOUNT_CHOOSER_RESPONSE_NEW 1
+#define OAUTH_ACCOUNT_CHOOSER_RESPONSE_NEW 1
-#define FLICKR_TYPE_ACCOUNT_CHOOSER_DIALOG (flickr_account_chooser_dialog_get_type ())
-#define FLICKR_ACCOUNT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FLICKR_TYPE_ACCOUNT_CHOOSER_DIALOG, FlickrAccountChooserDialog))
-#define FLICKR_ACCOUNT_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FLICKR_TYPE_ACCOUNT_CHOOSER_DIALOG, FlickrAccountChooserDialogClass))
-#define FLICKR_IS_ACCOUNT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FLICKR_TYPE_ACCOUNT_CHOOSER_DIALOG))
-#define FLICKR_IS_ACCOUNT_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FLICKR_TYPE_ACCOUNT_CHOOSER_DIALOG))
-#define FLICKR_ACCOUNT_CHOOSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FLICKR_TYPE_ACCOUNT_CHOOSER_DIALOG, FlickrAccountChooserDialogClass))
+#define OAUTH_TYPE_ACCOUNT_CHOOSER_DIALOG (oauth_account_chooser_dialog_get_type ())
+#define OAUTH_ACCOUNT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OAUTH_TYPE_ACCOUNT_CHOOSER_DIALOG, OAuthAccountChooserDialog))
+#define OAUTH_ACCOUNT_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OAUTH_TYPE_ACCOUNT_CHOOSER_DIALOG, OAuthAccountChooserDialogClass))
+#define OAUTH_IS_ACCOUNT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OAUTH_TYPE_ACCOUNT_CHOOSER_DIALOG))
+#define OAUTH_IS_ACCOUNT_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OAUTH_TYPE_ACCOUNT_CHOOSER_DIALOG))
+#define OAUTH_ACCOUNT_CHOOSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OAUTH_TYPE_ACCOUNT_CHOOSER_DIALOG, OAuthAccountChooserDialogClass))
-typedef struct _FlickrAccountChooserDialog FlickrAccountChooserDialog;
-typedef struct _FlickrAccountChooserDialogClass FlickrAccountChooserDialogClass;
-typedef struct _FlickrAccountChooserDialogPrivate FlickrAccountChooserDialogPrivate;
+typedef struct _OAuthAccountChooserDialog OAuthAccountChooserDialog;
+typedef struct _OAuthAccountChooserDialogClass OAuthAccountChooserDialogClass;
+typedef struct _OAuthAccountChooserDialogPrivate OAuthAccountChooserDialogPrivate;
-struct _FlickrAccountChooserDialog {
+struct _OAuthAccountChooserDialog {
GtkDialog parent_instance;
- FlickrAccountChooserDialogPrivate *priv;
+ OAuthAccountChooserDialogPrivate *priv;
};
-struct _FlickrAccountChooserDialogClass {
+struct _OAuthAccountChooserDialogClass {
GtkDialogClass parent_class;
};
-GType flickr_account_chooser_dialog_get_type (void);
-GtkWidget * flickr_account_chooser_dialog_new (GList *accounts,
- FlickrAccount *default_account);
-FlickrAccount * flickr_account_chooser_dialog_get_active (FlickrAccountChooserDialog *self);
+GType oauth_account_chooser_dialog_get_type (void);
+GtkWidget * oauth_account_chooser_dialog_new (GList *accounts,
+ OAuthAccount *default_account);
+OAuthAccount * oauth_account_chooser_dialog_get_active (OAuthAccountChooserDialog *self);
G_END_DECLS
-#endif /* FLICKR_ACCOUNT_CHOOSER_DIALOG_H */
+#endif /* OAUTH_ACCOUNT_CHOOSER_DIALOG_H */
diff --git a/extensions/oauth/oauth-account-manager-dialog.c b/extensions/oauth/oauth-account-manager-dialog.c
index 63e810a..6876c8e 100644
--- a/extensions/oauth/oauth-account-manager-dialog.c
+++ b/extensions/oauth/oauth-account-manager-dialog.c
@@ -22,8 +22,8 @@
#include <config.h>
#include <glib/gi18n.h>
-#include "flickr-account.h"
-#include "flickr-account-manager-dialog.h"
+#include "oauth-account.h"
+#include "oauth-account-manager-dialog.h"
#define GET_WIDGET(x) (_gtk_builder_get_widget (self->priv->builder, (x)))
@@ -38,17 +38,17 @@ enum {
static gpointer parent_class = NULL;
-struct _FlickrAccountManagerDialogPrivate {
+struct _OAuthAccountManagerDialogPrivate {
GtkBuilder *builder;
};
static void
-flickr_account_manager_dialog_finalize (GObject *object)
+oauth_account_manager_dialog_finalize (GObject *object)
{
- FlickrAccountManagerDialog *self;
+ OAuthAccountManagerDialog *self;
- self = FLICKR_ACCOUNT_MANAGER_DIALOG (object);
+ self = OAUTH_ACCOUNT_MANAGER_DIALOG (object);
_g_object_unref (self->priv->builder);
@@ -57,15 +57,15 @@ flickr_account_manager_dialog_finalize (GObject *object)
static void
-flickr_account_manager_dialog_class_init (FlickrAccountManagerDialogClass *klass)
+oauth_account_manager_dialog_class_init (OAuthAccountManagerDialogClass *klass)
{
GObjectClass *object_class;
parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (FlickrAccountManagerDialogPrivate));
+ g_type_class_add_private (klass, sizeof (OAuthAccountManagerDialogPrivate));
object_class = (GObjectClass*) klass;
- object_class->finalize = flickr_account_manager_dialog_finalize;
+ object_class->finalize = oauth_account_manager_dialog_finalize;
}
@@ -73,7 +73,7 @@ static void
delete_button_clicked_cb (GtkWidget *button,
gpointer user_data)
{
- FlickrAccountManagerDialog *self = user_data;
+ OAuthAccountManagerDialog *self = user_data;
GtkTreeModel *tree_model;
GtkTreeIter iter;
@@ -92,10 +92,10 @@ text_renderer_edited_cb (GtkCellRendererText *renderer,
char *new_text,
gpointer user_data)
{
- FlickrAccountManagerDialog *self = user_data;
+ OAuthAccountManagerDialog *self = user_data;
GtkTreePath *tree_path;
GtkTreeIter iter;
- FlickrAccount *account;
+ OAuthAccount *account;
tree_path = gtk_tree_path_new_from_string (path);
tree_path = gtk_tree_path_new_from_string (path);
@@ -111,7 +111,7 @@ text_renderer_edited_cb (GtkCellRendererText *renderer,
gtk_tree_model_get (GTK_TREE_MODEL (GET_WIDGET ("accounts_liststore")), &iter,
ACCOUNT_DATA_COLUMN, &account,
-1);
- flickr_account_set_username (account, new_text);
+ oauth_account_set_username (account, new_text);
gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("accounts_liststore")), &iter,
ACCOUNT_DATA_COLUMN, account,
@@ -123,11 +123,11 @@ text_renderer_edited_cb (GtkCellRendererText *renderer,
static void
-flickr_account_manager_dialog_init (FlickrAccountManagerDialog *self)
+oauth_account_manager_dialog_init (OAuthAccountManagerDialog *self)
{
GtkWidget *content;
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, FLICKR_TYPE_ACCOUNT_MANAGER_DIALOG, FlickrAccountManagerDialogPrivate);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, OAUTH_TYPE_ACCOUNT_MANAGER_DIALOG, OAuthAccountManagerDialogPrivate);
self->priv->builder = _gtk_builder_new_from_file ("flicker-account-manager.ui", "flicker");
gtk_window_set_resizable (GTK_WINDOW (self), FALSE);
@@ -141,7 +141,7 @@ flickr_account_manager_dialog_init (FlickrAccountManagerDialog *self)
gtk_dialog_add_button (GTK_DIALOG (self),
GTK_STOCK_NEW,
- FLICKR_ACCOUNT_MANAGER_RESPONSE_NEW);
+ OAUTH_ACCOUNT_MANAGER_RESPONSE_NEW);
gtk_dialog_add_button (GTK_DIALOG (self),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
@@ -163,25 +163,25 @@ flickr_account_manager_dialog_init (FlickrAccountManagerDialog *self)
GType
-flickr_account_manager_dialog_get_type (void)
+oauth_account_manager_dialog_get_type (void)
{
static GType type = 0;
if (type == 0) {
static const GTypeInfo g_define_type_info = {
- sizeof (FlickrAccountManagerDialogClass),
+ sizeof (OAuthAccountManagerDialogClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
- (GClassInitFunc) flickr_account_manager_dialog_class_init,
+ (GClassInitFunc) oauth_account_manager_dialog_class_init,
(GClassFinalizeFunc) NULL,
NULL,
- sizeof (FlickrAccountManagerDialog),
+ sizeof (OAuthAccountManagerDialog),
0,
- (GInstanceInitFunc) flickr_account_manager_dialog_init,
+ (GInstanceInitFunc) oauth_account_manager_dialog_init,
NULL
};
type = g_type_register_static (GTK_TYPE_DIALOG,
- "FlickrAccountManagerDialog",
+ "OAuthAccountManagerDialog",
&g_define_type_info,
0);
}
@@ -191,7 +191,7 @@ flickr_account_manager_dialog_get_type (void)
static void
-flickr_account_manager_dialog_construct (FlickrAccountManagerDialog *self,
+oauth_account_manager_dialog_construct (OAuthAccountManagerDialog *self,
GList *accounts)
{
GtkListStore *list_store;
@@ -201,7 +201,7 @@ flickr_account_manager_dialog_construct (FlickrAccountManagerDialog *self,
list_store = GTK_LIST_STORE (GET_WIDGET ("accounts_liststore"));
gtk_list_store_clear (list_store);
for (scan = accounts; scan; scan = scan->next) {
- FlickrAccount *account = scan->data;
+ OAuthAccount *account = scan->data;
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
@@ -213,19 +213,19 @@ flickr_account_manager_dialog_construct (FlickrAccountManagerDialog *self,
GtkWidget *
-flickr_account_manager_dialog_new (GList *accounts)
+oauth_account_manager_dialog_new (GList *accounts)
{
- FlickrAccountManagerDialog *self;
+ OAuthAccountManagerDialog *self;
- self = g_object_new (FLICKR_TYPE_ACCOUNT_MANAGER_DIALOG, NULL);
- flickr_account_manager_dialog_construct (self, accounts);
+ self = g_object_new (OAUTH_TYPE_ACCOUNT_MANAGER_DIALOG, NULL);
+ oauth_account_manager_dialog_construct (self, accounts);
return (GtkWidget *) self;
}
GList *
-flickr_account_manager_dialog_get_accounts (FlickrAccountManagerDialog *self)
+oauth_account_manager_dialog_get_accounts (OAuthAccountManagerDialog *self)
{
GList *accounts;
GtkTreeModel *tree_model;
@@ -237,7 +237,7 @@ flickr_account_manager_dialog_get_accounts (FlickrAccountManagerDialog *self)
accounts = NULL;
do {
- FlickrAccount *account;
+ OAuthAccount *account;
gtk_tree_model_get (tree_model, &iter,
ACCOUNT_DATA_COLUMN, &account,
diff --git a/extensions/oauth/oauth-account-manager-dialog.h b/extensions/oauth/oauth-account-manager-dialog.h
index 5db8d52..5101f69 100644
--- a/extensions/oauth/oauth-account-manager-dialog.h
+++ b/extensions/oauth/oauth-account-manager-dialog.h
@@ -20,40 +20,40 @@
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
-#ifndef FLICKR_ACCOUNT_MANAGER_DIALOG_H
-#define FLICKR_ACCOUNT_MANAGER_DIALOG_H
+#ifndef OAUTH_ACCOUNT_MANAGER_DIALOG_H
+#define OAUTH_ACCOUNT_MANAGER_DIALOG_H
#include <gtk/gtk.h>
#include <gthumb.h>
G_BEGIN_DECLS
-#define FLICKR_ACCOUNT_MANAGER_RESPONSE_NEW 1
+#define OAUTH_ACCOUNT_MANAGER_RESPONSE_NEW 1
-#define FLICKR_TYPE_ACCOUNT_MANAGER_DIALOG (flickr_account_manager_dialog_get_type ())
-#define FLICKR_ACCOUNT_MANAGER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FLICKR_TYPE_ACCOUNT_MANAGER_DIALOG, FlickrAccountManagerDialog))
-#define FLICKR_ACCOUNT_MANAGER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FLICKR_TYPE_ACCOUNT_MANAGER_DIALOG, FlickrAccountManagerDialogClass))
-#define FLICKR_IS_ACCOUNT_MANAGER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FLICKR_TYPE_ACCOUNT_MANAGER_DIALOG))
-#define FLICKR_IS_ACCOUNT_MANAGER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FLICKR_TYPE_ACCOUNT_MANAGER_DIALOG))
-#define FLICKR_ACCOUNT_MANAGER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FLICKR_TYPE_ACCOUNT_MANAGER_DIALOG, FlickrAccountManagerDialogClass))
+#define OAUTH_TYPE_ACCOUNT_MANAGER_DIALOG (oauth_account_manager_dialog_get_type ())
+#define OAUTH_ACCOUNT_MANAGER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OAUTH_TYPE_ACCOUNT_MANAGER_DIALOG, OAuthAccountManagerDialog))
+#define OAUTH_ACCOUNT_MANAGER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OAUTH_TYPE_ACCOUNT_MANAGER_DIALOG, OAuthAccountManagerDialogClass))
+#define OAUTH_IS_ACCOUNT_MANAGER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OAUTH_TYPE_ACCOUNT_MANAGER_DIALOG))
+#define OAUTH_IS_ACCOUNT_MANAGER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OAUTH_TYPE_ACCOUNT_MANAGER_DIALOG))
+#define OAUTH_ACCOUNT_MANAGER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OAUTH_TYPE_ACCOUNT_MANAGER_DIALOG, OAuthAccountManagerDialogClass))
-typedef struct _FlickrAccountManagerDialog FlickrAccountManagerDialog;
-typedef struct _FlickrAccountManagerDialogClass FlickrAccountManagerDialogClass;
-typedef struct _FlickrAccountManagerDialogPrivate FlickrAccountManagerDialogPrivate;
+typedef struct _OAuthAccountManagerDialog OAuthAccountManagerDialog;
+typedef struct _OAuthAccountManagerDialogClass OAuthAccountManagerDialogClass;
+typedef struct _OAuthAccountManagerDialogPrivate OAuthAccountManagerDialogPrivate;
-struct _FlickrAccountManagerDialog {
+struct _OAuthAccountManagerDialog {
GtkDialog parent_instance;
- FlickrAccountManagerDialogPrivate *priv;
+ OAuthAccountManagerDialogPrivate *priv;
};
-struct _FlickrAccountManagerDialogClass {
+struct _OAuthAccountManagerDialogClass {
GtkDialogClass parent_class;
};
-GType flickr_account_manager_dialog_get_type (void);
-GtkWidget * flickr_account_manager_dialog_new (GList *accounts);
-GList * flickr_account_manager_dialog_get_accounts (FlickrAccountManagerDialog *dialog);
+GType oauth_account_manager_dialog_get_type (void);
+GtkWidget * oauth_account_manager_dialog_new (GList *accounts);
+GList * oauth_account_manager_dialog_get_accounts (OAuthAccountManagerDialog *dialog);
G_END_DECLS
-#endif /* FLICKR_ACCOUNT_MANAGER_DIALOG_H */
+#endif /* OAUTH_ACCOUNT_MANAGER_DIALOG_H */
diff --git a/extensions/oauth/oauth-account.c b/extensions/oauth/oauth-account.c
index 9c503c8..905f907 100644
--- a/extensions/oauth/oauth-account.c
+++ b/extensions/oauth/oauth-account.c
@@ -42,6 +42,7 @@ oauth_account_finalize (GObject *obj)
g_free (self->username);
g_free (self->token);
+ g_free (self->token_secret);
G_OBJECT_CLASS (oauth_account_parent_class)->finalize (obj);
}
@@ -173,6 +174,14 @@ oauth_account_set_token (OAuthAccount *self,
}
+void
+oauth_account_set_token_secret (OAuthAccount *self,
+ const char *value)
+{
+ _g_strset (&self->token_secret, value);
+}
+
+
int
oauth_account_cmp (OAuthAccount *a,
OAuthAccount *b)
diff --git a/extensions/oauth/oauth-account.h b/extensions/oauth/oauth-account.h
index 15f6842..1592d15 100644
--- a/extensions/oauth/oauth-account.h
+++ b/extensions/oauth/oauth-account.h
@@ -44,7 +44,7 @@ struct _OAuthAccount {
OAuthAccountPrivate *priv;
char *username;
- char *access_token;
+ char *token;
char *token_secret;
gboolean is_default;
};
@@ -57,7 +57,7 @@ GType oauth_account_get_type (void);
OAuthAccount * oauth_account_new (void);
void oauth_account_set_username (OAuthAccount *self,
const char *value);
-void oauth_account_set_access_token (OAuthAccount *self,
+void oauth_account_set_token (OAuthAccount *self,
const char *value);
void oauth_account_set_token_secret (OAuthAccount *self,
const char *value);
diff --git a/extensions/oauth/oauth-authentication.c b/extensions/oauth/oauth-authentication.c
index 38d587f..5326821 100644
--- a/extensions/oauth/oauth-authentication.c
+++ b/extensions/oauth/oauth-authentication.c
@@ -31,7 +31,7 @@
#include "oauth-authentication.h"
-#define SECRET_SEPARATOR ("::")
+#define TOKEN_SECRET_SEPARATOR ("::")
#define OAUTH_AUTHENTICATION_RESPONSE_CHOOSE_ACCOUNT 1
@@ -157,7 +157,7 @@ oauth_authentication_new (OAuthConnection *conn,
self = (OAuthAuthentication *) g_object_new (OAUTH_TYPE_AUTHENTICATION, NULL);
self->priv->conn = g_object_ref (conn);
self->priv->cancellable = _g_object_ref (cancellable);
- self->priv->accounts = oauth_accounts_load_from_file ();
+ self->priv->accounts = oauth_accounts_load_from_file (self->priv->conn->consumer->name);
self->priv->account = oauth_accounts_find_default (self->priv->accounts);
self->priv->browser = browser;
self->priv->dialog = dialog;
@@ -244,7 +244,7 @@ check_token_ready_cb (GObject *source_object,
show_authentication_error_dialog (self, &error);
return;
}
- oauth_accounts_save_to_file (self->priv->accounts, self->priv->account);
+ oauth_accounts_save_to_file (self->priv->conn->consumer->name, self->priv->accounts, self->priv->account);
g_signal_emit (self, oauth_authentication_signals[READY], 0);
}
@@ -252,13 +252,13 @@ check_token_ready_cb (GObject *source_object,
static void
connect_to_server_step2 (OAuthAuthentication *self)
{
- if (self->priv->account->access_token == NULL) {
+ if (self->priv->account->token == NULL) {
start_authorization_process (self);
return;
}
oauth_connection_set_token (self->priv->conn,
- self->priv->account->access_token,
+ self->priv->account->token,
self->priv->account->token_secret);
oauth_connection_check_token (self->priv->conn,
self->priv->cancellable,
@@ -278,9 +278,9 @@ find_password_cb (GnomeKeyringResult result,
if (string != NULL) {
char **values;
- values = g_strsplit (string, SECRET_SEPARATOR, 2);
+ values = g_strsplit (string, TOKEN_SECRET_SEPARATOR, 2);
if ((values[0] != NULL) && (values[1] != NULL)) {
- self->priv->account->access_token = g_strdup (values[0]);
+ self->priv->account->token = g_strdup (values[0]);
self->priv->account->token_secret = g_strdup (values[1]);
}
@@ -298,7 +298,7 @@ connect_to_server (OAuthAuthentication *self)
g_return_if_fail (self->priv->account != NULL);
#ifdef HAVE_GNOME_KEYRING
- if (((self->priv->account->access_token == NULL) || (self->priv->account->token_secret == NULL)) && gnome_keyring_is_available ()) {
+ if (((self->priv->account->token == NULL) || (self->priv->account->token_secret == NULL)) && gnome_keyring_is_available ()) {
gnome_keyring_find_password (GNOME_KEYRING_NETWORK_PASSWORD,
find_password_cb,
self,
@@ -369,13 +369,13 @@ get_access_token_ready_cb (GObject *source_object,
if (gnome_keyring_is_available ()) {
char *secret;
- secret = g_strconcat (account->access_token,
+ secret = g_strconcat (account->token,
TOKEN_SECRET_SEPARATOR,
account->token_secret,
NULL);
gnome_keyring_store_password (GNOME_KEYRING_NETWORK_PASSWORD,
NULL,
- self->priv->conn->consumer->name,
+ self->priv->conn->consumer->display_name,
secret,
store_password_done_cb,
self,
@@ -438,7 +438,7 @@ complete_authorization (OAuthAuthentication *self)
builder = _gtk_builder_new_from_file ("oauth-complete-authorization.ui", "oauth");
dialog = _gtk_builder_get_widget (builder, "complete_authorization_messagedialog");
- text = g_strdup_printf (_("Return to this window when you have finished the authorization process on %s"), self->priv->conn->consumer->name);
+ text = g_strdup_printf (_("Return to this window when you have finished the authorization process on %s"), self->priv->conn->consumer->display_name);
secondary_text = g_strdup (_("Once you're done, click the 'Continue' button below."));
g_object_set (dialog, "text", text, "secondary-text", secondary_text, NULL);
g_object_set_data_full (G_OBJECT (dialog), "builder", builder, g_object_unref);
@@ -512,8 +512,8 @@ ask_authorization (OAuthAuthentication *self)
builder = _gtk_builder_new_from_file ("oauth-ask-authorization.ui", "oauth");
dialog = _gtk_builder_get_widget (builder, "ask_authorization_messagedialog");
- text = g_strdup_printf (_("gthumb requires your authorization to upload the photos to %s"), self->priv->conn->consumer->name);
- secondary_text = g_strdup_printf (_("Click 'Authorize' to open your web browser and authorize gthumb to upload photos to %s. When you're finished, return to this window to complete the authorization."), self->priv->conn->consumer->name);
+ text = g_strdup_printf (_("gthumb requires your authorization to upload the photos to %s"), self->priv->conn->consumer->display_name);
+ secondary_text = g_strdup_printf (_("Click 'Authorize' to open your web browser and authorize gthumb to upload photos to %s. When you're finished, return to this window to complete the authorization."), self->priv->conn->consumer->display_name);
g_object_set (dialog, "text", text, "secondary-text", secondary_text, NULL);
g_object_set_data_full (G_OBJECT (dialog), "builder", builder, g_object_unref);
g_signal_connect (dialog,
@@ -534,14 +534,14 @@ ask_authorization (OAuthAuthentication *self)
static void
-login_request_ready_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
+get_request_token_ready_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
OAuthAuthentication *self = user_data;
GError *error = NULL;
- if (! oauth_connection_login_request_finish (OAUTH_CONNECTION (source_object), res, &error))
+ if (! oauth_connection_get_request_token_finish (OAUTH_CONNECTION (source_object), res, &error))
show_authentication_error_dialog (self, &error);
else
ask_authorization (self);
@@ -551,10 +551,10 @@ login_request_ready_cb (GObject *source_object,
static void
start_authorization_process (OAuthAuthentication *self)
{
- oauth_connection_login_request (self->priv->conn,
- self->priv->cancellable,
- login_request_ready_cb,
- self);
+ oauth_connection_get_request_token (self->priv->conn,
+ self->priv->cancellable,
+ get_request_token_ready_cb,
+ self);
}
@@ -682,7 +682,7 @@ account_manager_dialog_response_cb (GtkDialog *dialog,
}
else
g_signal_emit (self, oauth_authentication_signals[ACCOUNTS_CHANGED], 0);
- oauth_accounts_save_to_file (self->priv->accounts, self->priv->account);
+ oauth_accounts_save_to_file (self->priv->conn->consumer->name, self->priv->accounts, self->priv->account);
gtk_widget_destroy (GTK_WIDGET (dialog));
break;
@@ -714,3 +714,112 @@ oauth_authentication_edit_accounts (OAuthAuthentication *self,
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_window_present (GTK_WINDOW (dialog));
}
+
+
+/* utilities */
+
+
+GList *
+oauth_accounts_load_from_file (const char *service_name)
+{
+ GList *accounts = NULL;
+ char *filename;
+ char *buffer;
+ gsize len;
+ DomDocument *doc;
+
+ filename = gth_user_dir_get_file (GTH_DIR_CONFIG, GTHUMB_DIR, "accounts", service_name, ".xml", NULL);
+ if (! g_file_get_contents (filename, &buffer, &len, NULL)) {
+ g_free (filename);
+ return NULL;
+ }
+
+ doc = dom_document_new ();
+ if (dom_document_load (doc, buffer, len, NULL)) {
+ DomElement *node;
+
+ node = DOM_ELEMENT (doc)->first_child;
+ if ((node != NULL) && (g_strcmp0 (node->tag_name, "accounts") == 0)) {
+ DomElement *child;
+
+ for (child = node->first_child;
+ child != NULL;
+ child = child->next_sibling)
+ {
+ if (strcmp (child->tag_name, "account") == 0) {
+ OAuthAccount *account;
+
+ account = oauth_account_new ();
+ dom_domizable_load_from_element (DOM_DOMIZABLE (account), child);
+
+ accounts = g_list_prepend (accounts, account);
+ }
+ }
+
+ accounts = g_list_reverse (accounts);
+ }
+ }
+
+ g_object_unref (doc);
+ g_free (buffer);
+ g_free (filename);
+
+ return accounts;
+}
+
+
+OAuthAccount *
+oauth_accounts_find_default (GList *accounts)
+{
+ GList *scan;
+
+ for (scan = accounts; scan; scan = scan->next) {
+ OAuthAccount *account = scan->data;
+
+ if (account->is_default)
+ return g_object_ref (account);
+ }
+
+ return NULL;
+}
+
+
+void
+oauth_accounts_save_to_file (const char *service_name,
+ GList *accounts,
+ OAuthAccount *default_account)
+{
+ DomDocument *doc;
+ DomElement *root;
+ GList *scan;
+ char *buffer;
+ gsize len;
+ char *filename;
+ GFile *file;
+
+ doc = dom_document_new ();
+ root = dom_document_create_element (doc, "accounts", NULL);
+ dom_element_append_child (DOM_ELEMENT (doc), root);
+ for (scan = accounts; scan; scan = scan->next) {
+ OAuthAccount *account = scan->data;
+ DomElement *node;
+
+ if ((default_account != NULL) && g_strcmp0 (account->username, default_account->username) == 0)
+ account->is_default = TRUE;
+ else
+ account->is_default = FALSE;
+ node = dom_domizable_create_element (DOM_DOMIZABLE (account), doc);
+ dom_element_append_child (root, node);
+ }
+
+ gth_user_dir_make_dir_for_file (GTH_DIR_CONFIG, GTHUMB_DIR, "accounts", service_name, ".xml", NULL);
+ filename = gth_user_dir_get_file (GTH_DIR_CONFIG, GTHUMB_DIR, "accounts", service_name, ".xml", NULL);
+ file = g_file_new_for_path (filename);
+ buffer = dom_document_dump (doc, &len);
+ g_write_file (file, FALSE, G_FILE_CREATE_PRIVATE | G_FILE_CREATE_REPLACE_DESTINATION, buffer, len, NULL, NULL);
+
+ g_free (buffer);
+ g_object_unref (file);
+ g_free (filename);
+ g_object_unref (doc);
+}
diff --git a/extensions/oauth/oauth-authentication.h b/extensions/oauth/oauth-authentication.h
index 54097a8..ee1ddab 100644
--- a/extensions/oauth/oauth-authentication.h
+++ b/extensions/oauth/oauth-authentication.h
@@ -68,6 +68,14 @@ GList * oauth_authentication_get_accounts (OAuthAuthentication
void oauth_authentication_edit_accounts (OAuthAuthentication *auth,
GtkWindow *parent);
+/* utilities */
+
+GList * oauth_accounts_load_from_file (const char *service_name);
+OAuthAccount * oauth_accounts_find_default (GList *accounts);
+void oauth_accounts_save_to_file (const char *service_name,
+ GList *accounts,
+ OAuthAccount *default_account);
+
G_END_DECLS
#endif /* OAUTH_AUTHENTICATION_H */
diff --git a/extensions/oauth/oauth-connection.c b/extensions/oauth/oauth-connection.c
index 04b4216..4f27afd 100644
--- a/extensions/oauth/oauth-connection.c
+++ b/extensions/oauth/oauth-connection.c
@@ -159,12 +159,12 @@ oauth_connection_get_type (void)
OAuthConnection *
-oauth_connection_new (OAuthServer *server)
+oauth_connection_new (OAuthConsumer *consumer)
{
OAuthConnection *self;
self = (OAuthConnection *) g_object_new (OAUTH_TYPE_CONNECTION, NULL);
- self->consumer = server;
+ self->consumer = consumer;
return self;
}
@@ -267,7 +267,6 @@ oauth_connection_add_signature (OAuthConnection *self,
GList *scan;
GString *base_string;
GString *signature_key;
- char *signature;
/* Add the OAuth specific parameters */
@@ -345,26 +344,22 @@ get_request_token_ready_cb (SoupSession *session,
SoupMessage *msg,
gpointer user_data)
{
- OAuthConnection *self = user_data;
- GSimpleAsyncResult *result;
- SoupBuffer *body;
- GError *error = NULL;
-
- result = oauth_connection_get_result (self->priv->conn);
+ OAuthConnection *self = user_data;
+ SoupBuffer *body;
if (msg->status_code != 200) {
- g_simple_async_result_set_error (result,
+ g_simple_async_result_set_error (self->priv->result,
SOUP_HTTP_ERROR,
msg->status_code,
"%s",
soup_status_get_phrase (msg->status_code));
- g_simple_async_result_complete_in_idle (result);
+ g_simple_async_result_complete_in_idle (self->priv->result);
return;
}
body = soup_message_body_flatten (msg->response_body);
- self->consumer->login_request_response (self, msg, body, result);
- g_simple_async_result_complete_in_idle (result);
+ self->consumer->get_request_token_response (self, msg, body, self->priv->result);
+ g_simple_async_result_complete_in_idle (self->priv->result);
soup_buffer_free (body);
}
@@ -379,12 +374,12 @@ oauth_connection_get_request_token (OAuthConnection *self,
GHashTable *data_set;
SoupMessage *msg;
- gth_task_progress (GTH_TASK (self->priv->conn), _("Connecting to the server"), _("Getting account information"), TRUE, 0.0);
+ gth_task_progress (GTH_TASK (self), _("Connecting to the server"), _("Getting account information"), TRUE, 0.0);
data_set = g_hash_table_new (g_str_hash, g_str_equal);
- oauth_connection_add_signature (self->priv->conn, "POST", self->consumer->request_token_url, data_set);
+ oauth_connection_add_signature (self, "POST", self->consumer->request_token_url, data_set);
msg = soup_form_request_new_from_hash ("POST", self->consumer->request_token_url, data_set);
- oauth_connection_send_message (self->priv->conn,
+ oauth_connection_send_message (self,
msg,
cancellable,
callback,
@@ -412,7 +407,7 @@ oauth_connection_get_request_token_finish (OAuthConnection *self,
char *
oauth_connection_get_login_link (OAuthConnection *self)
{
- self->consumer->get_login_link (self);
+ return self->consumer->get_login_link (self);
}
@@ -424,26 +419,22 @@ get_access_token_ready_cb (SoupSession *session,
SoupMessage *msg,
gpointer user_data)
{
- OAuthConnection *self = user_data;
- GSimpleAsyncResult *result;
- SoupBuffer *body;
- GError *error = NULL;
-
- result = oauth_connection_get_result (self->priv->conn);
+ OAuthConnection *self = user_data;
+ SoupBuffer *body;
if (msg->status_code != 200) {
- g_simple_async_result_set_error (result,
+ g_simple_async_result_set_error (self->priv->result,
SOUP_HTTP_ERROR,
msg->status_code,
"%s",
soup_status_get_phrase (msg->status_code));
- g_simple_async_result_complete_in_idle (result);
+ g_simple_async_result_complete_in_idle (self->priv->result);
return;
}
body = soup_message_body_flatten (msg->response_body);
- self->consumer->get_access_token_response (self, msg, body, result);
- g_simple_async_result_complete_in_idle (result);
+ self->consumer->get_access_token_response (self, msg, body, self->priv->result);
+ g_simple_async_result_complete_in_idle (self->priv->result);
soup_buffer_free (body);
}
@@ -458,12 +449,12 @@ oauth_connection_get_access_token (OAuthConnection *self,
GHashTable *data_set;
SoupMessage *msg;
- gth_task_progress (GTH_TASK (self->priv->conn), _("Connecting to the server"), _("Getting account information"), TRUE, 0.0);
+ gth_task_progress (GTH_TASK (self), _("Connecting to the server"), _("Getting account information"), TRUE, 0.0);
data_set = g_hash_table_new (g_str_hash, g_str_equal);
- oauth_connection_add_signature (self->priv->conn, "POST", self->consumer->access_token_url, data_set);
+ oauth_connection_add_signature (self, "POST", self->consumer->access_token_url, data_set);
msg = soup_form_request_new_from_hash ("POST", self->consumer->access_token_url, data_set);
- oauth_connection_send_message (self->priv->conn,
+ oauth_connection_send_message (self,
msg,
cancellable,
callback,
@@ -484,7 +475,7 @@ oauth_connection_get_access_token_finish (OAuthConnection *self,
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
return FALSE;
else
- return g_object_ref (g_simple_async_result_get_op_res_gpointer (result));
+ return g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result)));
}
@@ -520,26 +511,22 @@ check_token_ready_cb (SoupSession *session,
SoupMessage *msg,
gpointer user_data)
{
- OAuthConnection *self = user_data;
- GSimpleAsyncResult *result;
- SoupBuffer *body;
- GError *error = NULL;
-
- result = oauth_connection_get_result (self->priv->conn);
+ OAuthConnection *self = user_data;
+ SoupBuffer *body;
if (msg->status_code != 200) {
- g_simple_async_result_set_error (result,
+ g_simple_async_result_set_error (self->priv->result,
SOUP_HTTP_ERROR,
msg->status_code,
"%s",
soup_status_get_phrase (msg->status_code));
- g_simple_async_result_complete_in_idle (result);
+ g_simple_async_result_complete_in_idle (self->priv->result);
return;
}
body = soup_message_body_flatten (msg->response_body);
- self->consumer->check_token_response (self, msg, body, result);
- g_simple_async_result_complete_in_idle (result);
+ self->consumer->check_token_response (self, msg, body, self->priv->result);
+ g_simple_async_result_complete_in_idle (self->priv->result);
soup_buffer_free (body);
}
@@ -554,12 +541,12 @@ oauth_connection_check_token (OAuthConnection *self,
GHashTable *data_set;
SoupMessage *msg;
- gth_task_progress (GTH_TASK (self->priv->conn), _("Connecting to the server"), _("Getting account information"), TRUE, 0.0);
+ gth_task_progress (GTH_TASK (self), _("Connecting to the server"), _("Getting account information"), TRUE, 0.0);
data_set = g_hash_table_new (g_str_hash, g_str_equal);
- oauth_connection_add_signature (self->priv->conn, "POST", self->consumer->check_token_url, data_set);
+ oauth_connection_add_signature (self, "POST", self->consumer->check_token_url, data_set);
msg = soup_form_request_new_from_hash ("POST", self->consumer->check_token_url, data_set);
- oauth_connection_send_message (self->priv->conn,
+ oauth_connection_send_message (self,
msg,
cancellable,
callback,
diff --git a/extensions/oauth/oauth-connection.h b/extensions/oauth/oauth-connection.h
index 8bde86d..b684a58 100644
--- a/extensions/oauth/oauth-connection.h
+++ b/extensions/oauth/oauth-connection.h
@@ -30,7 +30,7 @@
#include <libsoup/soup.h>
#endif /* HAVE_LIBSOUP_GNOME */
#include <gthumb.h>
-#include "oauth-types.h"
+#include "oauth-account.h"
#define OAUTH_CONNECTION_ERROR oauth_connection_error_quark ()
GQuark oauth_connection_error_quark (void);
@@ -47,6 +47,7 @@ GQuark oauth_connection_error_quark (void);
typedef struct _OAuthConnection OAuthConnection;
typedef struct _OAuthConnectionPrivate OAuthConnectionPrivate;
typedef struct _OAuthConnectionClass OAuthConnectionClass;
+typedef struct _OAuthConsumer OAuthConsumer;
struct _OAuthConnection
{
@@ -104,4 +105,33 @@ gboolean oauth_connection_check_token_finish (OAuthConnection
GAsyncResult *result,
GError **error);
+/* -- OAuthConsumer -- */
+
+typedef void (*OAuthResponseFunc) (OAuthConnection *self,
+ SoupMessage *msg,
+ SoupBuffer *body,
+ GSimpleAsyncResult *result);
+typedef char * (*OAuthLoginLinkFunc) (OAuthConnection *self);
+
+
+struct _OAuthConsumer {
+ const char *display_name;
+ const char *name;
+ const char *url;
+ const char *protocol;
+ const char *consumer_key;
+ const char *consumer_secret;
+
+ const char *request_token_url;
+ OAuthResponseFunc get_request_token_response;
+
+ OAuthLoginLinkFunc get_login_link;
+
+ const char *access_token_url;
+ OAuthResponseFunc get_access_token_response;
+
+ const char *check_token_url;
+ OAuthResponseFunc check_token_response;
+};
+
#endif /* OAUTH_CONNECTION_H */
diff --git a/extensions/photobucket/Makefile.am b/extensions/photobucket/Makefile.am
index 2cf881b..616c74b 100644
--- a/extensions/photobucket/Makefile.am
+++ b/extensions/photobucket/Makefile.am
@@ -12,26 +12,9 @@ libphotobucket_la_SOURCES = \
callbacks.h \
dlg-export-to-photobucket.c \
dlg-export-to-photobucket.h \
- photobucket-account.c \
- photobucket-account.h \
- photobucket-account-chooser-dialog.c \
- photobucket-account-chooser-dialog.h \
- photobucket-account-manager-dialog.c \
- photobucket-account-manager-dialog.h \
- photobucket-authentication.c \
- photobucket-authentication.h \
- photobucket-connection.c \
- photobucket-connection.h \
- photobucket-photo.c \
- photobucket-photo.h \
- photobucket-photoset.c \
- photobucket-photoset.h \
- photobucket-service.c \
- photobucket-service.h \
- photobucket-types.h \
- photobucket-user.c \
- photobucket-user.h \
- main.c
+ main.c \
+ photobucket-consumer.c \
+ photobucket-consumer.h
libphotobucket_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(GNOME_KEYRING_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
libphotobucket_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
diff --git a/extensions/photobucket/dlg-export-to-photobucket.c b/extensions/photobucket/dlg-export-to-photobucket.c
index 1929c44..fd63de6 100644
--- a/extensions/photobucket/dlg-export-to-photobucket.c
+++ b/extensions/photobucket/dlg-export-to-photobucket.c
@@ -24,7 +24,7 @@
#include <gtk/gtk.h>
#include <gthumb.h>
#include "dlg-export-to-photobucket.h"
-#include "photobucket-service.h"
+#include "photobucket-consumer.h"
#define GET_WIDGET(x) (_gtk_builder_get_widget (data->builder, (x)))
@@ -53,7 +53,6 @@ typedef struct {
GtkWidget *dialog;
GtkWidget *progress_dialog;
OAuthConnection *conn;
- PhotobucketService *service;
OAuthAuthentication *auth;
PhotobucketUser *user;
GList *albums;
@@ -75,7 +74,6 @@ export_dialog_destroy_cb (GtkWidget *widget,
_g_object_list_unref (data->albums);
_g_object_unref (data->user);
_g_object_unref (data->auth);
- _g_object_unref (data->service);
_g_object_unref (data->conn);
_g_object_unref (data->builder);
_g_object_list_unref (data->file_list);
diff --git a/extensions/photobucket/photobucket-consumer.c b/extensions/photobucket/photobucket-consumer.c
new file mode 100644
index 0000000..efa9fe3
--- /dev/null
+++ b/extensions/photobucket/photobucket-consumer.c
@@ -0,0 +1,211 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * 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 later 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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gthumb.h>
+#include "photobucket-consumer.h"
+
+
+static gboolean
+photobucket_utils_parse_response (SoupBuffer *body,
+ DomDocument **doc_p,
+ GError **error)
+{
+ DomDocument *doc;
+ DomElement *node;
+
+ doc = dom_document_new ();
+ if (! dom_document_load (doc, body->data, body->length, error)) {
+ g_object_unref (doc);
+ return FALSE;
+ }
+
+ for (node = DOM_ELEMENT (doc)->first_child; node; node = node->next_sibling) {
+ if (g_strcmp0 (node->tag_name, "response") == 0) {
+ DomElement *child;
+ const char *status = NULL;
+ const char *message;
+ const char *code;
+
+ for (child = node->first_child; child; child = child->next_sibling) {
+ if (g_strcmp0 (child->tag_name, "status") == 0) {
+ status = dom_element_get_inner_text (child);
+ }
+ else if (g_strcmp0 (child->tag_name, "message") == 0) {
+ message = dom_element_get_inner_text (child);
+ }
+ else if (g_strcmp0 (child->tag_name, "code") == 0) {
+ code = dom_element_get_inner_text (child);
+ }
+ }
+
+ if (status == NULL) {
+ error = g_error_new_literal (OAUTH_CONNECTION_ERROR, 999, _("Unknown error"));
+ g_simple_async_result_set_from_error (self->priv->result, error);
+ }
+ else if (strcmp (status, "Exception") == 0) {
+ *error = g_error_new_literal (OAUTH_CONNECTION_ERROR,
+ (code != NULL) ? atoi (code) : 999,
+ (message != NULL) ? message : _("Unknown error"));
+ }
+
+ g_object_unref (doc);
+ return FALSE;
+ }
+ }
+
+ *doc_p = doc;
+
+ return TRUE;
+}
+
+
+static void
+photobucket_login_request_response (OAuthConnection *self,
+ SoupMessage *msg,
+ SoupBuffer *body,
+ GSimpleAsyncResult *result)
+{
+ DomDocument *doc = NULL;
+ GError *error = NULL;
+
+ if (photobucket_utils_parse_response (body, &doc, &error)) {
+ /*OAuthAccount *account;
+ char *username;*/
+
+ /* FIXME: set the connection token and token_secret from the response */
+
+ /*account = oauth_account_new ();
+ oauth_account_set_username (account, username);
+ oauth_account_set_token (account, oauth_connection_get_token (self));
+ oauth_account_set_token_secret (account, oauth_connection_get_token_secret (self));*/
+
+ char *token;
+ char *token_secret;
+
+ token = NULL;
+ token_secret = NULL;
+
+ /* FIXME: parse the body and set the token */
+ /*oauth_connection_set_token (self, token, token_secret);*/
+
+ if ((token == NULL) || (token_secret == NULL)) {
+ error = g_error_new_literal (OAUTH_CONNECTION_ERROR, 0, _("Unknown error"));
+ g_simple_async_result_set_from_error (result, error);
+ }
+ else
+ g_simple_async_result_set_op_res_gboolean (self->priv->result, TRUE);
+
+ g_object_unref (doc);
+ }
+ else
+ g_simple_async_result_set_from_error (result, error);
+}
+
+
+static char *
+phoyobucket_get_login_link (OAuthConnection *self)
+{
+ char *token;
+ char *uri;
+
+ token = soup_uri_encode (oauth_connection_get_token (self), NULL);
+ uri = g_strconcat ("http://photobucket.com/apilogin/login?oauth_token=", token, NULL);
+
+ g_free (token);
+
+ return uri;
+}
+
+
+static void
+photobucket_get_access_token_response (OAuthConnection *self,
+ SoupMessage *msg,
+ SoupBuffer *body,
+ GSimpleAsyncResult *result)
+{
+ DomDocument *doc = NULL;
+ GError *error = NULL;
+
+ if (photobucket_utils_parse_response (body, &doc, &error)) {
+ OAuthAccount *account = NULL;
+ char *username;
+
+ /* FIXME: parse the body and set the account */
+
+ /*account = oauth_account_new ();
+ oauth_account_set_username (account, username);
+ oauth_account_set_token (account, oauth_connection_get_token (self));
+ oauth_account_set_token_secret (account, oauth_connection_get_token_secret (self));*/
+
+ /*oauth_connection_set_token (self, token, token_secret);*/
+
+ if (account == NULL) {
+ error = g_error_new_literal (OAUTH_CONNECTION_ERROR, 0, _("Unknown error"));
+ g_simple_async_result_set_from_error (result, error);
+ }
+ else
+ g_simple_async_result_set_op_res_gpointer (self->priv->result, account, g_object_unref);
+
+ g_object_unref (doc);
+ }
+ else
+ g_simple_async_result_set_from_error (result, error);
+}
+
+
+static void
+photobucket_check_token_response (OAuthConnection *self,
+ SoupMessage *msg,
+ SoupBuffer *body,
+ GSimpleAsyncResult *result)
+{
+ DomDocument *doc = NULL;
+ GError *error = NULL;
+
+ if (photobucket_utils_parse_response (body, &doc, &error)) {
+ /* FIXME: add other user info to the account */
+ g_simple_async_result_set_op_res_gboolean (self->priv->result, TRUE);
+ g_object_unref (doc);
+ }
+ else
+ g_simple_async_result_set_from_error (result, error);
+}
+
+
+OAuthConsumer photobucket_consumer = {
+ "PhotoBucket",
+ "photobucket",
+ "http://www.photobucket.com",
+ "http",
+ "8960706ee7f4151e893b11837e9c24ce",
+ "1ff8d1e45c873423",
+ "http://api.photobucket.com/login/request",
+ photobucket_login_request_response,
+ phoyobucket_get_login_link,
+ "http://api.photobucket.com/login/access",
+ photobucket_get_access_token_response,
+ "http://api.photobucket.com/user/",
+ photobucket_check_token_response
+};
diff --git a/extensions/photobucket/photobucket-consumer.h b/extensions/photobucket/photobucket-consumer.h
new file mode 100644
index 0000000..25a2515
--- /dev/null
+++ b/extensions/photobucket/photobucket-consumer.h
@@ -0,0 +1,30 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * 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 later 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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef PHOTOBUCKET_CONSUMER_H
+#define PHOTOBUCKET_CONSUMER_H
+
+#include <extensions/oauth/oauth-connection.h>
+
+extern OAuthConsumer photobucket_consumer;
+
+#endif /* PHOTOBUCKET_CONSUMER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]