Add IMDb plugin
authorPhilipp Zabel <philipp.zabel@gmail.com>
Fri, 25 Sep 2009 10:48:50 +0000 (12:48 +0200)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Fri, 30 Oct 2009 22:17:31 +0000 (23:17 +0100)
A plugin to control downloading a copy of the plaintext IMDb database
and querying the local copy or online IMDb.

In the future, IMDb account management and publishing of ratings
might be added.

Makefile
src/plugins/imdb-plugin.vala [new file with mode: 0644]

index 414bb64..b141c03 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+all: cinaest libimdb-plugin.so
+
 cinaest_SOURCES = \
        src/main.vala \
        src/movie.vala \
@@ -13,7 +15,23 @@ cinaest_VALAFLAGS = --vapidir ./vapi --pkg hildon-1 --pkg libosso --pkg gmodule-
 cinaest: ${cinaest_SOURCES}
        valac -o $@ ${cinaest_VALAFLAGS} ${cinaest_SOURCES}
 
-.PHONY: clean
+imdb_plugin_SOURCES = \
+       src/movie.vala \
+       src/plugin-interface.vala \
+       src/plugins/imdb-plugin.vala
+
+imdb_plugin_CSOURCES = \
+       src/plugins/imdb-plugin.c
+
+imdb_plugin_VALAFLAGS = --vapidir ./vapi --pkg hildon-1
+imdb_plugin_CFLAGS = -shared -fPIC `pkg-config --cflags hildon-1`
+imdb_plugin_LDADD = `pkg-config --cflags hildon-1`
+
+libimdb-plugin.so: ${imdb_plugin_SOURCES}
+       valac -C ${imdb_plugin_VALAFLAGS} ${imdb_plugin_SOURCES}
+       gcc -o $@ ${imdb_plugin_CFLAGS} ${imdb_plugin_LDADD} ${imdb_plugin_CSOURCES}
+
+.PHONY: all clean
 
 clean:
-       rm -f cinaest
+       rm -f cinaest libimdb-plugin.so src/*.c src/plugins/*.c
diff --git a/src/plugins/imdb-plugin.vala b/src/plugins/imdb-plugin.vala
new file mode 100644 (file)
index 0000000..c4a3f01
--- /dev/null
@@ -0,0 +1,46 @@
+/* This file is part of Cinaest.
+ *
+ * Copyright (C) 2009 Philipp Zabel
+ *
+ * Cinaest 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Cinaest 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 Cinaest. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+using Hildon;
+
+class IMDbPlugin : Plugin {
+       public override void hello (Gtk.Window window) {
+               string filename = Path.build_filename (Environment.get_user_cache_dir(),
+                                                      "cinaest", "imdb.db", null);
+               stdout.printf ("IMDb Plugin Loaded. Cache Db: %s\n", filename);
+
+               if (!FileUtils.test (filename, FileTest.EXISTS)) {
+                       var note = new Note.confirmation (window, "There is no local copy of the Internet Movie Database (IMDb). Download it now?\n\nThis can be started later from the Settings dialog.");
+
+                       note.run ();
+                       note.destroy ();
+               }
+       }
+
+       public override void get_movies (string filter, Plugin.ReceiveMovieFunction callback, int limit) {
+       }
+
+       public override void add_movie (Movie movie) {
+       }
+}
+
+[ModuleInit]
+public Type register_plugin () {
+       // types are registered automatically
+       return typeof (IMDbPlugin);
+}