minfoprovider: Response-received signal updated
authorSimón Pena <spenap@gmail.com>
Sun, 30 May 2010 14:23:52 +0000 (16:23 +0200)
committerSimón Pena <spenap@gmail.com>
Sun, 30 May 2010 20:06:28 +0000 (22:06 +0200)
* The signal notifying for response-received now returns an array
of object paths.
* The TMDBMovie service objects are updated so that they get an ID
to tell between each other.
* The TODO file is updated to reflect the progress

WARNING: Currently, the ID the movie service objects are receiving
starts with 0 in each call to query, which causes conflicts once
that a query is done:
- A method to generate UID must be added
- The result objects lifetime must be controlled and finalized
when not needed.

TODO
src/Makefile.am
src/mvs-minfo-provider-service.c
src/mvs-tmdb-movie-service.c
src/mvs-tmdb-movie-service.h

diff --git a/TODO b/TODO
index d0ad8e4..6a4b62d 100644 (file)
--- a/TODO
+++ b/TODO
@@ -2,8 +2,9 @@ Release 0.1:
 * Expose TMDBMovie via DBus
        - Creating TMDB movie-service gobject
                + Getters for each property
-       - Updating dataprovider-service daemon
-               + Signal should return a list of result paths
+       - A method to generate UID must be added
+       - The result objects lifetime must be controlled and finalized
+       when not needed.
 * Update build so that it creates a .service file
 * Create a MovieManager class in Python to ask for and retrieve results
 * Connect the UI with the MovieManager
index 5764f52..eeb9f32 100644 (file)
@@ -20,7 +20,10 @@ maevies_service_SOURCES = \
        mvs-tmdb-movie.c \
        mvs-tmdb-movie.h \
        mvs-watc-movie.c \
-       mvs-watc-movie.h
+       mvs-watc-movie.h \
+       mvs-tmdb-movie-service.c \
+       mvs-tmdb-movie-service.h \
+       mvs-tmdb-movie-service-glue.h
 
 maevies_service_CFLAGS = \
        $(DEPS_CFLAGS)
@@ -35,7 +38,11 @@ MAINTAINERCLEANFILES =       \
 mvs-minfo-provider-service-glue.h: mvs-minfo-provider.xml
        dbus-binding-tool --mode=glib-server --prefix=mvs_minfo_provider_service $< > $@
 
+mvs-tmdb-movie-service-glue.h: mvs-tmdb-movie.xml
+       dbus-binding-tool --mode=glib-server --prefix=mvs_tmdb_movie_service $< > $@
+
 DISTCLEANFILES = $(MAINTAINERCLEANFILES)
 
 BUILT_SOURCES =                        \
-       mvs-minfo-provider-service-glue.h
\ No newline at end of file
+       mvs-minfo-provider-service-glue.h \
+       mvs-tmdb-movie-service-glue.h
\ No newline at end of file
index f35150a..1e6e049 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "mvs-minfo-provider-service.h"
 #include "mvs-minfo-provider.h"
+#include "mvs-tmdb-movie-service.h"
+#include "mvs-tmdb-movie.h"
 
 #define MINFO_PROVIDER_SERVICE_OBJECT_PATH "/MInfoProvider"
 #define MINFO_PROVIDER_SERVICE_NAME "com.simonpena.maevies.minfoprovider"
@@ -60,11 +62,30 @@ mvs_minfo_provider_service_query (MvsMInfoProviderService *self,
 #include "mvs-minfo-provider-service-glue.h"
 
 static void
-response_received_cb (MvsMInfoProvider *provider, gpointer response,
+response_received_cb (MvsMInfoProvider *provider, GList *list,
                       gpointer user_data)
 {
         MvsMInfoProviderService *self = MVS_MINFO_PROVIDER_SERVICE (user_data);
-        g_signal_emit (self, mvs_minfo_provider_service_signals[RESPONSE_RECEIVED], 0);
+        MvsTMDBMovieService *movie = NULL;
+        GError *error = NULL;
+        GList *iter = NULL;
+        gchar  **object_paths= g_new0 (gchar*, g_list_length (list) + 1);
+        guint i = 0;
+
+        for (iter = list; iter; iter = iter->next) {
+                if (MVS_IS_TMDB_MOVIE (iter->data)) {
+                        MvsTmdbMovie *tmdb_movie = MVS_TMDB_MOVIE (iter->data);
+
+                        mvs_tmdb_movie_print (tmdb_movie);
+                        movie = mvs_tmdb_movie_service_new (self->priv->connection, tmdb_movie, i);
+                        object_paths[i] = g_strdup_printf ("/TMDBMovie/%d", i);
+                }
+                i++;
+        }
+        object_paths[i] = NULL;
+
+        g_signal_emit (self, mvs_minfo_provider_service_signals[RESPONSE_RECEIVED], 0, object_paths);
+        g_strfreev (object_paths);
 }
 
 static void
@@ -155,9 +176,10 @@ mvs_minfo_provider_service_class_init (MvsMInfoProviderServiceClass *klass)
                          0,
                          NULL,
                          NULL,
-                         g_cclosure_marshal_VOID__VOID,
+                         g_cclosure_marshal_VOID__POINTER,
                          G_TYPE_NONE,
-                         0,
+                         1,
+                         G_TYPE_STRV,
                          NULL);
 }
 
index 788eb18..36b910b 100644 (file)
@@ -27,6 +27,7 @@ G_DEFINE_TYPE (MvsTMDBMovieService, mvs_tmdb_movie_service, G_TYPE_OBJECT)
 
 enum {
         PROP_0,
+        PROP_ID,
         PROP_DBUSGCONN,
 };
 
@@ -36,6 +37,7 @@ enum {
 struct _MvsTMDBMovieServicePrivate {
         MvsTmdbMovie *movie;
         DBusGConnection *connection;
+        guint id;
 };
 
 gboolean
@@ -54,8 +56,7 @@ setup_dbus (MvsTMDBMovieService *self)
         DBusGProxy *proxy;
         guint request_name_result;
         GError *error = NULL;
-
-        g_message ("Registering DBUS " TMDB_MOVIE_SERVICE_OBJECT_PATH " " TMDB_MOVIE_SERVICE_NAME);
+        gchar *object_path = NULL;
 
         proxy = dbus_g_proxy_new_for_name (self->priv->connection,
                                            DBUS_SERVICE_DBUS,
@@ -70,10 +71,14 @@ setup_dbus (MvsTMDBMovieService *self)
                 g_error_free (error);
         }
 
+        object_path = g_strdup_printf (TMDB_MOVIE_SERVICE_OBJECT_PATH "/%d",
+                        self->priv->id);
+
         dbus_g_connection_register_g_object (self->priv->connection,
-                                             TMDB_MOVIE_SERVICE_OBJECT_PATH,
+                                             object_path,
                                              G_OBJECT (self));
 
+        g_free (object_path);
         g_object_unref (proxy);
 }
 
@@ -126,7 +131,7 @@ mvs_tmdb_movie_service_class_init (MvsTMDBMovieServiceClass *klass)
                 (object_class, PROP_DBUSGCONN,
                  g_param_spec_pointer ("connection", "DBusGConnection",
                                        "DBus GConnection",
-                                       G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+                                       G_PARAM_WRITABLE));
 
          dbus_g_object_type_install_info (MVS_TYPE_TMDB_MOVIE_SERVICE,
                                           &dbus_glib_mvs_tmdb_movie_service_object_info);
@@ -141,10 +146,12 @@ mvs_tmdb_movie_service_init (MvsTMDBMovieService *self)
 }
 
 MvsTMDBMovieService*
-mvs_tmdb_movie_service_new (DBusGConnection *connection, MvsTmdbMovie *movie)
+mvs_tmdb_movie_service_new (DBusGConnection *connection,
+                MvsTmdbMovie *movie, guint id)
 {
-        MvsTMDBMovieService *instance = g_object_new (MVS_TYPE_TMDB_MOVIE_SERVICE,
-                             "connection", connection, NULL);
+        MvsTMDBMovieService *instance = g_object_new (MVS_TYPE_TMDB_MOVIE_SERVICE, NULL);
+        instance->priv->id = id;
+        g_object_set (instance, "connection", connection, NULL);
         instance->priv->movie = movie;
         return instance;
 }
index b296a83..a185e72 100644 (file)
@@ -51,7 +51,7 @@ typedef struct {
 
 GType mvs_tmdb_movie_service_get_type (void);
 MvsTMDBMovieService* mvs_tmdb_movie_service_new (DBusGConnection *connection,
-                MvsTmdbMovie *movie);
+                MvsTmdbMovie *movie, guint id);
 
 G_END_DECLS