[grilo] grilo-test-ui: Load Flickr's token from gconf



commit 58e6c92be8547b1bd7e1afc89441811d05805d8d
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Tue Jul 6 17:07:27 2010 +0200

    grilo-test-ui: Load Flickr's token from gconf
    
    If user has set up a token in gconf (/apps/grilo-test-ui/auth-token) then it
    will be used.

 configure.ac                    |    7 +++++--
 tools/Makefile.am               |    2 +-
 tools/grilo-test-ui/Makefile.am |    4 ++--
 tools/grilo-test-ui/main.c      |   31 +++++++++++++++++++++++++++++--
 4 files changed, 37 insertions(+), 7 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b28fca8..7d29eef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -160,8 +160,11 @@ PKG_CHECK_MODULES(DEPS, glib-2.0 \
 
 # Tools
 
-PKG_CHECK_MODULES(GTK, gtk+-2.0, HAVE_GTK=yes, HAVE_GTK=no)
-AM_CONDITIONAL(HAVE_GTK, test "x$HAVE_GTK" = "xyes")
+PKG_CHECK_MODULES(GTU, gtk+-2.0 \
+                       gconf-2.0,
+                       BUILD_GRILO_TEST_UI=yes,
+                       BUILD_GRILO_TEST_UI=no)
+AM_CONDITIONAL(BUILD_GRILO_TEST_UI, test "x$BUILD_GRILO_TEST_UI" = "xyes")
 
 # ----------------------------------------------------------
 # WORKAROUNDS
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 9a9a528..b81879c 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -7,7 +7,7 @@
 
 SUBDIRS =
 
-if HAVE_GTK
+if BUILD_GRILO_TEST_UI
 SUBDIRS += grilo-test-ui
 endif
 
diff --git a/tools/grilo-test-ui/Makefile.am b/tools/grilo-test-ui/Makefile.am
index e2db348..d043336 100644
--- a/tools/grilo-test-ui/Makefile.am
+++ b/tools/grilo-test-ui/Makefile.am
@@ -14,14 +14,14 @@ grilo_test_ui_SOURCES =	\
 
 grilo_test_ui_CFLAGS =		\
 	-DPREFIX=$(prefix)	\
-	$(GTK_CFLAGS)		\
+	$(GTU_CFLAGS)		\
 	-I$(top_srcdir)/src	\
 	-I$(top_srcdir)/src/data
 
 grilo_test_ui_LDADD =	\
 	-ldl -lpthread	\
 	$(DEPS_LIBS)	\
-	$(GTK_LIBS)	\
+	$(GTU_LIBS)	\
 	$(top_builddir)/src/lib GRL_NAME@.la
 
 MAINTAINERCLEANFILES =	\
diff --git a/tools/grilo-test-ui/main.c b/tools/grilo-test-ui/main.c
index ab75550..5e3adba 100644
--- a/tools/grilo-test-ui/main.c
+++ b/tools/grilo-test-ui/main.c
@@ -24,6 +24,7 @@
 
 #include <gtk/gtk.h>
 #include <string.h>
+#include <gconf/gconf-client.h>
 
 #undef G_LOG_DOMAIN
 #define G_LOG_DOMAIN "test-ui"
@@ -33,6 +34,8 @@
 #define FLICKR_KEY    "fa037bee8120a921b34f8209d715a2fa"
 #define FLICKR_SECRET "9f6523b9c52e3317"
 
+#define GCONF_GTU_FLICKR_TOKEN "/apps/grilo-test-ui/auth-token"
+
 /* ----- Youtube Config tokens ---- */
 
 #define YOUTUBE_KEY   "AI39si4EfscPllSfUy1IwexMf__kntTL_G5dfSr2iUEVN45RHGq92Aq0lX25OlnOkG6KTN-4soVAkAf67fWYXuHfVADZYr7S1A"
@@ -1158,18 +1161,42 @@ search_combo_setup (void)
   gtk_combo_box_set_active (GTK_COMBO_BOX (view->search_combo), 0);
 }
 
+static gchar *
+get_flickr_token (void)
+{
+  GConfClient *confclient;
+  gchar *token;
+
+  confclient = gconf_client_get_default();
+
+  token = gconf_client_get_string (confclient, GCONF_GTU_FLICKR_TOKEN, NULL);
+
+  return token;
+}
+
 static void
 set_flickr_config (void)
 {
   GrlConfig *config;
   GrlPluginRegistry *registry;
+  gchar *token;
+
+  registry = grl_plugin_registry_get_instance ();
 
   config = grl_config_new ("grl-flickr", NULL);
   grl_config_set_api_key (config, FLICKR_KEY);
   grl_config_set_api_secret (config, FLICKR_SECRET);
-
-  registry = grl_plugin_registry_get_instance ();
   grl_plugin_registry_add_config (registry, config);
+
+  token = get_flickr_token ();
+  if (token) {
+    config = grl_config_new ("grl-flickr", NULL);
+    grl_config_set_api_key (config, FLICKR_KEY);
+    grl_config_set_api_secret (config, FLICKR_SECRET);
+    grl_config_set_api_token (config, token);
+    grl_plugin_registry_add_config (registry, config);
+    g_free (token);
+  }
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]