gsoc

Sign in or create your account | Project List | Help

gsoc Commit Details

Date:2009-07-27 21:36:18 (1 year 1 day ago)
Author:Adrien Bustany
Commit:bfb69a48278f4e37b3d0d85de9a97dd424a9abac
Message:GData bridge : autotoolize

Files: bridges/gdata/AUTHORS (1 diff)
bridges/gdata/COPYING (0 diffs)
bridges/gdata/ChangeLog (0 diffs)
bridges/gdata/INSTALL (1 diff)
bridges/gdata/Makefile (1 diff)
bridges/gdata/Makefile.am (1 diff)
bridges/gdata/NEWS (0 diffs)
bridges/gdata/README (0 diffs)
bridges/gdata/autogen.sh (1 diff)
bridges/gdata/config.h (1 diff)
bridges/gdata/configure.ac (1 diff)
bridges/gdata/data/Makefile.am (1 diff)
bridges/gdata/data/gdata-picasaweb.desktop (1 diff)
bridges/gdata/gdata-bridge-picasaweb.vala (1 diff)
bridges/gdata/gdata-bridge.vala (1 diff)
bridges/gdata/gdata-picasaweb.desktop (1 diff)
bridges/gdata/libgdata.deps (1 diff)
bridges/gdata/libgdata.vapi (1 diff)
bridges/gdata/main.vala (1 diff)
bridges/gdata/po/LINGUAS (0 diffs)
bridges/gdata/po/POTFILES.in (1 diff)
bridges/gdata/po/POTFILES.skip (1 diff)
bridges/gdata/src/Makefile.am (1 diff)
bridges/gdata/src/gdata-bridge-picasaweb.vala (1 diff)
bridges/gdata/src/main.vala (1 diff)

Change Details

bridges/gdata/AUTHORS
1Adrien Bustany <madcat@mymadcat.com>
bridges/gdata/COPYING
bridges/gdata/ChangeLog
bridges/gdata/INSTALL
1Installation Instructions
2*************************
3
4Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
52006, 2007, 2008, 2009 Free Software Foundation, Inc.
6
7   This file is free documentation; the Free Software Foundation gives
8unlimited permission to copy, distribute and modify it.
9
10Basic Installation
11==================
12
13   Briefly, the shell commands `./configure; make; make install' should
14configure, build, and install this package. The following
15more-detailed instructions are generic; see the `README' file for
16instructions specific to this package.
17
18   The `configure' shell script attempts to guess correct values for
19various system-dependent variables used during compilation. It uses
20those values to create a `Makefile' in each directory of the package.
21It may also create one or more `.h' files containing system-dependent
22definitions. Finally, it creates a shell script `config.status' that
23you can run in the future to recreate the current configuration, and a
24file `config.log' containing compiler output (useful mainly for
25debugging `configure').
26
27   It can also use an optional file (typically called `config.cache'
28and enabled with `--cache-file=config.cache' or simply `-C') that saves
29the results of its tests to speed up reconfiguring. Caching is
30disabled by default to prevent problems with accidental use of stale
31cache files.
32
33   If you need to do unusual things to compile the package, please try
34to figure out how `configure' could check whether to do them, and mail
35diffs or instructions to the address given in the `README' so they can
36be considered for the next release. If you are using the cache, and at
37some point `config.cache' contains results you don't want to keep, you
38may remove or edit it.
39
40   The file `configure.ac' (or `configure.in') is used to create
41`configure' by a program called `autoconf'. You need `configure.ac' if
42you want to change it or regenerate `configure' using a newer version
43of `autoconf'.
44
45The simplest way to compile this package is:
46
47  1. `cd' to the directory containing the package's source code and type
48     `./configure' to configure the package for your system.
49
50     Running `configure' might take a while. While running, it prints
51     some messages telling which features it is checking for.
52
53  2. Type `make' to compile the package.
54
55  3. Optionally, type `make check' to run any self-tests that come with
56     the package.
57
58  4. Type `make install' to install the programs and any data files and
59     documentation.
60
61  5. You can remove the program binaries and object files from the
62     source code directory by typing `make clean'. To also remove the
63     files that `configure' created (so you can compile the package for
64     a different kind of computer), type `make distclean'. There is
65     also a `make maintainer-clean' target, but that is intended mainly
66     for the package's developers. If you use it, you may have to get
67     all sorts of other programs in order to regenerate files that came
68     with the distribution.
69
70  6. Often, you can also type `make uninstall' to remove the installed
71     files again.
72
73Compilers and Options
74=====================
75
76   Some systems require unusual options for compilation or linking that
77the `configure' script does not know about. Run `./configure --help'
78for details on some of the pertinent environment variables.
79
80   You can give `configure' initial values for configuration parameters
81by setting variables in the command line or in the environment. Here
82is an example:
83
84     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
85
86   *Note Defining Variables::, for more details.
87
88Compiling For Multiple Architectures
89====================================
90
91   You can compile the package for more than one kind of computer at the
92same time, by placing the object files for each architecture in their
93own directory. To do this, you can use GNU `make'. `cd' to the
94directory where you want the object files and executables to go and run
95the `configure' script. `configure' automatically checks for the
96source code in the directory that `configure' is in and in `..'.
97
98   With a non-GNU `make', it is safer to compile the package for one
99architecture at a time in the source code directory. After you have
100installed the package for one architecture, use `make distclean' before
101reconfiguring for another architecture.
102
103   On MacOS X 10.5 and later systems, you can create libraries and
104executables that work on multiple system types--known as "fat" or
105"universal" binaries--by specifying multiple `-arch' options to the
106compiler but only a single `-arch' option to the preprocessor. Like
107this:
108
109     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
110                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
111                 CPP="gcc -E" CXXCPP="g++ -E"
112
113   This is not guaranteed to produce working output in all cases, you
114may have to build one architecture at a time and combine the results
115using the `lipo' tool if you have problems.
116
117Installation Names
118==================
119
120   By default, `make install' installs the package's commands under
121`/usr/local/bin', include files under `/usr/local/include', etc. You
122can specify an installation prefix other than `/usr/local' by giving
123`configure' the option `--prefix=PREFIX'.
124
125   You can specify separate installation prefixes for
126architecture-specific files and architecture-independent files. If you
127pass the option `--exec-prefix=PREFIX' to `configure', the package uses
128PREFIX as the prefix for installing programs and libraries.
129Documentation and other data files still use the regular prefix.
130
131   In addition, if you use an unusual directory layout you can give
132options like `--bindir=DIR' to specify different values for particular
133kinds of files. Run `configure --help' for a list of the directories
134you can set and what kinds of files go in them.
135
136   If the package supports it, you can cause programs to be installed
137with an extra prefix or suffix on their names by giving `configure' the
138option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
139
140Optional Features
141=================
142
143   Some packages pay attention to `--enable-FEATURE' options to
144`configure', where FEATURE indicates an optional part of the package.
145They may also pay attention to `--with-PACKAGE' options, where PACKAGE
146is something like `gnu-as' or `x' (for the X Window System). The
147`README' should mention any `--enable-' and `--with-' options that the
148package recognizes.
149
150   For packages that use the X Window System, `configure' can usually
151find the X include and library files automatically, but if it doesn't,
152you can use the `configure' options `--x-includes=DIR' and
153`--x-libraries=DIR' to specify their locations.
154
155Particular systems
156==================
157
158   On HP-UX, the default C compiler is not ANSI C compatible. If GNU
159CC is not installed, it is recommended to use the following options in
160order to use an ANSI C compiler:
161
162     ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
163
164and if that doesn't work, install pre-built binaries of GCC for HP-UX.
165
166   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
167parse its `<wchar.h>' header file. The option `-nodtk' can be used as
168a workaround. If GNU CC is not installed, it is therefore recommended
169to try
170
171     ./configure CC="cc"
172
173and if that doesn't work, try
174
175     ./configure CC="cc -nodtk"
176
177   On Solaris, don't put `/usr/ucb' early in your `PATH'. This
178directory contains several dysfunctional programs; working variants of
179these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
180in your `PATH', put it _after_ `/usr/bin'.
181
182   On Haiku, software installed for all users goes in `/boot/common',
183not `/usr/local'. It is recommended to use the following options:
184
185     ./configure --prefix=/boot/common
186
187Specifying the System Type
188==========================
189
190   There may be some features `configure' cannot figure out
191automatically, but needs to determine by the type of machine the package
192will run on. Usually, assuming the package is built to be run on the
193_same_ architectures, `configure' can figure that out, but if it prints
194a message saying it cannot guess the machine type, give it the
195`--build=TYPE' option. TYPE can either be a short name for the system
196type, such as `sun4', or a canonical name which has the form:
197
198     CPU-COMPANY-SYSTEM
199
200where SYSTEM can have one of these forms:
201
202     OS
203     KERNEL-OS
204
205   See the file `config.sub' for the possible values of each field. If
206`config.sub' isn't included in this package, then this package doesn't
207need to know the machine type.
208
209   If you are _building_ compiler tools for cross-compiling, you should
210use the option `--target=TYPE' to select the type of system they will
211produce code for.
212
213   If you want to _use_ a cross compiler, that generates code for a
214platform different from the build platform, you should specify the
215"host" platform (i.e., that on which the generated programs will
216eventually be run) with `--host=TYPE'.
217
218Sharing Defaults
219================
220
221   If you want to set default values for `configure' scripts to share,
222you can create a site shell script called `config.site' that gives
223default values for variables like `CC', `cache_file', and `prefix'.
224`configure' looks for `PREFIX/share/config.site' if it exists, then
225`PREFIX/etc/config.site' if it exists. Or, you can set the
226`CONFIG_SITE' environment variable to the location of the site script.
227A warning: not all `configure' scripts look for a site script.
228
229Defining Variables
230==================
231
232   Variables not defined in a site shell script can be set in the
233environment passed to `configure'. However, some packages may run
234configure again during the build, and the customized values of these
235variables may be lost. In order to avoid this problem, you should set
236them in the `configure' command line, using `VAR=value'. For example:
237
238     ./configure CC=/usr/local2/bin/gcc
239
240causes the specified `gcc' to be used as the C compiler (unless it is
241overridden in the site shell script).
242
243Unfortunately, this technique does not work for `CONFIG_SHELL' due to
244an Autoconf bug. Until the bug is fixed you can use this workaround:
245
246     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
247
248`configure' Invocation
249======================
250
251   `configure' recognizes the following options to control how it
252operates.
253
254`--help'
255`-h'
256     Print a summary of all of the options to `configure', and exit.
257
258`--help=short'
259`--help=recursive'
260     Print a summary of the options unique to this package's
261     `configure', and exit. The `short' variant lists options used
262     only in the top level, while the `recursive' variant lists options
263     also present in any nested packages.
264
265`--version'
266`-V'
267     Print the version of Autoconf used to generate the `configure'
268     script, and exit.
269
270`--cache-file=FILE'
271     Enable the cache: use and save the results of the tests in FILE,
272     traditionally `config.cache'. FILE defaults to `/dev/null' to
273     disable caching.
274
275`--config-cache'
276`-C'
277     Alias for `--cache-file=config.cache'.
278
279`--quiet'
280`--silent'
281`-q'
282     Do not print messages saying which checks are being made. To
283     suppress all normal output, redirect it to `/dev/null' (any error
284     messages will still be shown).
285
286`--srcdir=DIR'
287     Look for the package's source code in directory DIR. Usually
288     `configure' can determine that directory automatically.
289
290`--prefix=DIR'
291     Use DIR as the installation prefix. *Note Installation Names::
292     for more details, including other options available for fine-tuning
293     the installation locations.
294
295`--no-create'
296`-n'
297     Run the configure checks, but stop before creating any output
298     files.
299
300`configure' also accepts some other, not widely useful, options. Run
301`configure --help' for more details.
302
bridges/gdata/Makefile
1VALAC=valac
2
3VALAFLAGS=-v --thread -g --vapidir=. --vapidir=.. --pkg dbus-glib-1 --pkg libgdata --pkg gnome-keyring-1 --pkg tracker-bridge -X --include=config.h -D DEBUG -X -I.. -X -L.. -X -ltracker-bridge -X -O0
4
5.SUFFIXES:.vala
6
7SOURCES=gdata-bridge-picasaweb.vala main.vala
8TARGET=gdata_bridge
9
10$(TARGET) : $(SOURCES) Makefile
11    $(VALAC) $(VALAFLAGS) -o $(TARGET) $(SOURCES)
12
13C : $(SOURCES)
14    $(VALAC) $(VALAFLAGS) -C $(SOURCES)
bridges/gdata/Makefile.am
1SUBDIRS=src po data
2
3EXTRA_DIST= \
4    intltool-extract.in \
5    intltool-merge.in \
6    intltool-update.in
7
8DISTCLEANFILES= \
9    intltool-extract \
10    intltool-merge \
11    intltool-update
12
bridges/gdata/NEWS
bridges/gdata/README
bridges/gdata/autogen.sh
1#!/bin/sh
2# Run this to generate all the initial makefiles, etc.
3
4srcdir=`dirname $0`
5test -z "$srcdir" && srcdir=.
6
7PKG_NAME="tracker-bridge-gdata"
8
9. gnome-autogen.sh
bridges/gdata/config.h
1#define GETTEXT_PACKAGE "GDataBridge"
2
bridges/gdata/configure.ac
1AC_INIT([tracker-bridge-gdata], [0.1.0], [http://bugzilla.gnome.org/enter_bug.cgi?product=tracker], [tracker-bridge-gdata])
2AC_CONFIG_SRCDIR([src/main.vala])
3AC_CONFIG_HEADERS(config.h)
4AM_INIT_AUTOMAKE([dist-bzip2])
5
6AC_SUBST(PACKAGE_URL, [http://www.tracker-project.org])
7
8AC_PROG_CC
9AM_PROG_CC_C_O
10AC_DISABLE_STATIC
11AC_PROG_LIBTOOL
12
13AC_PATH_PROG(VALAC, valac, valac)
14AC_SUBST(VALAC)
15
16AH_TEMPLATE([GETTEXT_PACKAGE], [Package name for gettext])
17GETTEXT_PACKAGE=tracker-bridge-gdata
18AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE")
19AC_SUBST(GETTEXT_PACKAGE)
20AM_GLIB_GNU_GETTEXT
21IT_PROG_INTLTOOL([0.35.0])
22AM_MAINTAINER_MODE
23
24AC_SUBST(CFLAGS)
25AC_SUBST(CPPFLAGS)
26AC_SUBST(LDFLAGS)
27
28GLIB_REQUIRED=2.12.0
29DBUS_REQUIRED=0.60
30TRACKERBRIDGE_REQUIRED=0.1
31GNOMEKEYRING_REQUIRED=2.26
32LIBGDATA_REQUIRED=0.5
33UUID_REQUIRED=1.41
34
35PKG_CHECK_MODULES(GLIB2, glib-2.0 >= $GLIB_REQUIRED)
36AC_SUBST(GLIB2_CFLAGS)
37AC_SUBST(GLIB2_LIBS)
38
39PKG_CHECK_MODULES(GOBJECT, gobject-2.0 >= $GLIB_REQUIRED)
40AC_SUBST(GOBJECT_CFLAGS)
41AC_SUBST(GOBJECT_LIBS)
42
43PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= $GLIB_REQUIRED)
44AC_SUBST(GOBJECT_CFLAGS)
45AC_SUBST(GOBJECT_LIBS)
46
47PKG_CHECK_MODULES(DBUS, [dbus-1 >= $DBUS_REQUIRED dbus-glib-1 >= $DBUS_REQUIRED])
48AC_SUBST(DBUS_CFLAGS)
49AC_SUBST(DBUS_LIBS)
50
51PKG_CHECK_MODULES(TRACKERBRIDGE, tracker-bridge-0.1 >= $TRACKERBRIDGE_REQUIRED)
52AC_SUBST(TRACKERBRIDGE_CFLAGS)
53AC_SUBST(TRACKERBRIDGE_LIBS)
54
55PKG_CHECK_MODULES(GNOMEKEYRING, gnome-keyring-1 >= $GNOMEKEYRING_REQUIRED)
56AC_SUBST(GNOMEKEYRING_CFLAGS)
57AC_SUBST(GNOMEKEYRING_LIBS)
58
59PKG_CHECK_MODULES(LIBGDATA, libgdata >= $LIBGDATA_REQUIRED)
60AC_SUBST(LIBGDATA_CFLAGS)
61AC_SUBST(LIBGDATA_LIBS)
62
63PKG_CHECK_MODULES(UUID, uuid >= $UUID_REQUIRED)
64AC_SUBST(UUID_CFLAGS)
65AC_SUBST(UUID_LIBS)
66
67AC_CONFIG_FILES([Makefile
68    src/Makefile
69    data/Makefile
70    po/Makefile.in])
71
72AC_OUTPUT
bridges/gdata/data/Makefile.am
1desktopdir=$(datadir)/tracker/bridges
2desktop_DATA= \
3    gdata-picasaweb.desktop
bridges/gdata/data/gdata-picasaweb.desktop
1[Desktop Entry]
2Encoding=UTF-8
3Type=Service
4Name=Google - PicasaWeb
5Comment=Index your pictures on PicasaWeb
6Icon=/usr/share/hplip/data/images/48x48/prog.png
7X-DBus-Name=org.freedesktop.Tracker.GDataBridge
8X-DBus-Path=/org/freedesktop/Tracker/BridgePicasaWeb
9X-Tracker-Bridge-AuthScheme=UserPass
bridges/gdata/gdata-bridge-picasaweb.vala
1using GData;
2using Tracker;
3
4class GDataBridgePicasaWeb : Object, Tracker.Bridge {
5    private const string API_KEY = "ABQIAAAAISU_TtyUrVg0N9RGhb8pTxRI3KVolA1NVmS0lLG3RQFyztcosBSHs5rHiQHsmL41EbX1SehKnf1rrw";
6    private const string TRACKER_NAME = "org.freedesktop.Tracker";
7    private const string TRACKER_RESOURCES_PATH = "/org/freedesktop/Tracker/Resources";
8    private const string TRACKER_RESOURCES_INTERFACE = "org.freedesktop.Tracker.Resources";
9    private const string SERVICE_NAME = "GData-PicasaWeb";
10
11    private DBus.Connection conn;
12    private dynamic DBus.Object tracker;
13
14    private string username;
15
16    private uint bridge_status;
17
18    private PicasaWeb.Service service = null;
19
20    public GDataBridgePicasaWeb ()
21    {
22        set_bridge_status (Bridge.Status.NotAuthenticated);
23
24        try {
25            conn = DBus.Bus.get (DBus.BusType.SESSION);
26        } catch (Error e) {
27            critical ("Cannot connect to session bus : %s\n", e.message);
28        }
29
30        tracker = conn.get_object (TRACKER_NAME, TRACKER_RESOURCES_PATH, TRACKER_RESOURCES_INTERFACE);
31
32        service = new PicasaWeb.Service (API_KEY);
33    }
34
35    public void Authenticate ()
36    {
37        HashTable<string, string> pwdData = null;
38        try {
39            pwdData = Tracker.passwordProvider.search (null, SERVICE_NAME);
40        } catch (Error e) {
41            critical ("Couldn't retrieve stored passowrd : %s", e.message);
42        }
43
44        if (pwdData != null) {
45            username = pwdData.lookup ("username");
46            string password = pwdData.lookup ("secret");
47
48            bool result = false;
49            try {
50                result = service.authenticate (username, password, null);
51            } catch (Error e) {
52                Error (Bridge.DBusErrorCode.AuthenticationError, _("Couldn't authenticate against remote service : %s").printf (e.message));
53                set_bridge_status (Bridge.Status.NotAuthenticated);
54            }
55
56            if (!result) {
57                Error (Bridge.DBusErrorCode.AuthenticationError, _("Invalid username and/or password"));
58                set_bridge_status (Bridge.Status.WrongToken);
59            } else {
60                set_bridge_status (Bridge.Status.Authenticated, username);
61            }
62        } else {
63            set_bridge_status (Bridge.Status.NotAuthenticated);
64            return;
65        }
66    }
67
68    public HashTable<string, string> GetAssociationData ()
69    {
70        var ret = new HashTable<string, string> (str_hash, str_equal);
71        return ret;
72    }
73
74    public void FinishAssociation (HashTable<string, string> data)
75    {
76        if (data.lookup ("user") == null || data.lookup("password") == null) {
77            critical ("Invalid user and/or password");
78            return;
79        }
80
81        try {
82            Tracker.passwordProvider.save (data.lookup ("user"), SERVICE_NAME, data.lookup ("password"), _("Authentification data for Google services (PicasaWeb)"));
83        } catch (Error e) {
84            critical ("Error while storing password : %s", e.message);
85        }
86
87        Authenticate ();
88
89    }
90
91    public uint GetStatus ()
92    {
93        return bridge_status;
94    }
95
96    public void Pull ()
97    {
98        set_bridge_status (Status.Working);
99        service.query_all_albums_async (null, username, null, null, list_albums);
100    }
101
102    public void Shutdown ()
103    {
104    }
105
106    private void insertPicture (Entry file)
107    {
108
109        string uri = "urn:nepomuk:gdata:%s".printf (file.id);
110
111        try {
112            tracker.SparqlUpdate ("insert {<%s> a nmm:Photo}".printf (uri));
113            tracker.SparqlUpdate ("insert {<%s> a nfo:RemoteDataObject}".printf (uri));
114            tracker.SparqlUpdate ("insert {<%s> rdfs:label '%s'}".printf (uri, file.title.escape ("")));
115
116            tracker.SparqlUpdate ("insert {<%s> nfo:height %u}".printf (uri, ((PicasaWeb.File)file).height));
117            tracker.SparqlUpdate ("insert {<%s> nfo:width %u}".printf (uri, ((PicasaWeb.File)file).width));
118
119            if (((PicasaWeb.File)file).tags != null) {
120                foreach (string tag in ((PicasaWeb.File)file).tags.split (",")) {
121                    string tagUri = getTagUri (tag);
122                    tracker.SparqlUpdate ("insert {<%s> a nao:Tag}".printf (tagUri));
123                    tracker.SparqlUpdate ("insert {<%s> rdfs:label '%s'}".printf (tagUri, tag));
124                    tracker.SparqlUpdate ("insert {<%s> nao:hasTag <%s>}".printf (uri, tagUri));
125                }
126            }
127        } catch (Error e) {
128            critical ("Error while entering metadata into Tracker : %s", e.message);
129        }
130    }
131
132    private void list_albums (Object source_object, AsyncResult res)
133    {
134        Feed albums = null;
135        try {
136            albums = service.query_finish (res);
137        } catch (Error e) {
138            critical ("Couldn't list albums : %s", e.message);
139        }
140        debug ("Got %u albums to list", albums.total_results);
141
142        int progress_increment = 100/(int)albums.total_results;
143        int current_progress = 0;
144        Progress (current_progress);
145
146        foreach (Entry album in albums.get_entries ()) {
147            Feed pictures = null;
148            try {
149                pictures = service.query_files ((PicasaWeb.Album)album, null, null, null);
150            } catch (Error e) {
151                critical ("Unable to retrieve files for album %s : %s", album.title, e.message);
152                continue;
153            }
154
155            foreach (Entry picture in pictures.get_entries ()) {
156                insertPicture (picture);
157            }
158            current_progress += progress_increment;
159            Progress (current_progress);
160        }
161
162        Progress (100);
163    }
164
165    private void set_bridge_status (Tracker.Bridge.Status s, string message = "")
166    {
167#if DEBUG
168        debug ("Changing status to %u", s);
169#endif
170        bridge_status = s;
171        StatusChanged ((uint)s, message);
172    }
173}
bridges/gdata/gdata-bridge.vala
1using Tracker;
2using GData;
3
4class GDataBridge : Object, Tracker.Bridge {
5    protected const string SERVICE_NAME = "GData";
6    protected const string API_KEY = "ABQIAAAAISU_TtyUrVg0N9RGhb8pTxRI3KVolA1NVmS0lLG3RQFyztcosBSHs5rHiQHsmL41EbX1SehKnf1rrw";
7    protected const string TRACKER_NAME = "org.freedesktop.Tracker";
8    protected const string TRACKER_RESOURCES_PATH = "/org/freedesktop/Tracker/Resources";
9    protected const string TRACKER_RESOURCES_INTERFACE = "org.freedesktop.Tracker.Resources";
10
11    protected DBus.Connection conn;
12    protected dynamic DBus.Object tracker;
13
14    protected string username;
15
16    protected uint bridge_status;
17
18    protected Service service = null;
19
20    public GDataBridge ()
21    {
22        set_bridge_status (Bridge.Status.NotAuthenticated);
23
24        try {
25            conn = DBus.Bus.get (DBus.BusType.SESSION);
26        } catch (Error e) {
27            critical ("Cannot connect to session bus : %s\n", e.message);
28        }
29
30        tracker = conn.get_object (TRACKER_NAME, TRACKER_RESOURCES_PATH, TRACKER_RESOURCES_INTERFACE);
31    }
32
33
34
35    public uint GetStatus ()
36    {
37        return Bridge.Status.NotAuthenticated;
38    }
39
40    public void Pull ()
41    {
42    }
43
44    public void Shutdown ()
45    {
46    }
47
48
49
50    protected void finish_association_internal (HashTable<string, string> data, string service_name, string description)
51    {
52    }
53}
54
bridges/gdata/gdata-picasaweb.desktop
1[Desktop Entry]
2Encoding=UTF-8
3Type=Service
4Name=Google - PicasaWeb
5Comment=Index your pictures on PicasaWeb
6Icon=/usr/share/hplip/data/images/48x48/prog.png
7X-DBus-Name=org.freedesktop.Tracker.GDataBridge
8X-DBus-Path=/org/freedesktop/Tracker/BridgePicasaWeb
9X-Tracker-Bridge-AuthScheme=UserPass
bridges/gdata/libgdata.deps
1libsoup-2.4
bridges/gdata/libgdata.vapi
1/* libgdata.vapi
2 *
3 * Copyright (C) 2009 Adrien Bustany
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Author:
20 * Adrien Bustany <madcat@mymadcat.com>
21 */
22
23using GLib;
24using Soup;
25
26[CCode (lower_case_cprefix = "gdata_", cheader_filename = "libgdata/gdata/gdata.h")]
27namespace GData {
28    class Service : Object {
29        public bool authenticate (string username, string password, Cancellable? cancellable) throws Error;
30        public void authenticate_async (string username, string password, Cancellable? cancellable, AsyncReadyCallback callback);
31        public void authenticate_finish (AsyncResult result) throws Error;
32        public bool is_authenticated ();
33        public Feed? query (string feed_uri, Query? query, Type entry_type, Cancellable? cancellable, QueryProgressCallback? progress_callback) throws Error;
34        public void query_async (string feed_uri, Query? query, Type entry_type, Cancellable? cancellable, QueryProgressCallback? progress_callback, AsyncReadyCallback callback) throws Error;
35        public Feed? query_finish (AsyncResult async_result) throws Error;
36        public Entry? insert_entry (string upload_uri, Entry entry, Cancellable? cancellable) throws Error;
37        public void insert_entry_async (string upload_uri, Entry entry, Cancellable? cancellable, AsyncReadyCallback callback);
38        public Entry? insert_entry_finish (AsyncResult result) throws Error;
39        public Entry? update_entry (Entry entry, Cancellable? cancellable) throws Error;
40        public void update_entry_async (Entry entry, Cancellable? cancellable, AsyncReadyCallback callback);
41        public Entry? update_entry_finish (AsyncResult result) throws Error;
42        public bool delete_entry (Entry entry, Cancellable? cancellable) throws Error;
43        public void delete_entry_async (Entry entry, Cancellable? cancellable, AsyncReadyCallback callback);
44        public bool delete_entry_finish (AsyncResult result) throws Error;
45
46        public string client_id { get; }
47        public string username { get; }
48        public string password { get; }
49        public Soup.URI proxy_uri { get; set; }
50        public bool authenticated { get; }
51
52        public signal void captcha_challenge(string uri);
53    }
54
55    delegate void QueryProgressCallback (GData.Entry entry, uint entry_key, uint entry_count);
56
57    class Query : Object {
58        public Query (string q);
59        public static Query new_with_limits (string q, int start_index, int max_results);
60        public static Query new_for_id (string entry_id);
61        public string get_query_uri (string feed_uri);
62        void next_page ();
63        void previous_page ();
64        public string q { get; set; }
65        public string entry_id { get; set; }
66        public string etag { get; set; }
67        public string author { get; set; }
68        public string categories { get; set; }
69        public TimeVal published_min { get; set; }
70        public TimeVal published_max { get; set; }
71        public TimeVal updated_min { get; set; }
72        public TimeVal updated_max { get; set; }
73        public int start_index { get; set; }
74        public int max_results { get; set; }
75        public bool is_strict ();
76        public void set_is_strict (bool is_strict);
77    }
78
79    class Feed : Parsable {
80        public string title { get; }
81        public string subtitle { get; }
82        public string id { get; }
83        public string etag { get; }
84        public List<Author> get_authors ();
85        public List<Category> get_categories ();
86        public List<Entry> get_entries ();
87        public Entry? look_up_entry (string id);
88        public Generator generator { get; }
89        public List<Link> get_links ();
90        public Link? look_up_link (string rel);
91        public string logo { get; }
92        public TimeVal udpated { get; }
93        public uint start_index { get; }
94        public uint total_results { get; }
95        public uint items_per_page { get; }
96    }
97
98    class Entry : Parsable {
99        public Entry (string id);
100        public static Entry new_from_xml (string xml, int length) throws Error;
101        public string title { get; set; }
102        public string summary { get; set; }
103        public string id { get; }
104        public string etag { get; }
105        public string content { get; set; }
106        public TimeVal published { get; }
107        public TimeVal updated { get; }
108        public void add_author (Author author);
109        public void add_category (Category category);
110        public List<Category> get_categories ();
111        public void add_link (Link link);
112        public List<Link> get_links ();
113        public Link? look_up_link (string rel);
114        public bool is_inserted { get; }
115        public string get_xml ();
116    }
117
118    struct Color {
119        public uint16 red;
120        public uint16 green;
121        public uint16 blue;
122
123        public static bool from_hexadecimal (string hexadecimal, out Color color);
124        public string to_hexadecimal ();
125    }
126
127    [CCode (ref_function = "g_object_ref", unref_function = "g_object_unref")]
128    class Parsable {
129    }
130
131    interface AccessHandler {
132        public Feed? get_rules (Service service, Cancellable? cancellable, QueryProgressCallback? callback) throws Error;
133        public AccessRule? insert_rule (Service service, AccessRule rule, Cancellable? cancellable) throws Error;
134        public AccessRule? update_rule (Service service, AccessRule rule, Cancellable? cancellable) throws Error;
135        public bool delete_rule (Service service, AccessRule rule, Cancellable? cancellable) throws Error;
136    }
137
138    class AccessRule : Entry {
139        public AccessRule (string id);
140        public static AccessRule new_from_xml (string xml, int length) throws Error;
141        public string role { get; set; }
142        public void get_scope (out string type, out string value);
143        public void set_scope (string type, string value);
144    }
145
146    class Author : Parsable {
147        public Author ();
148        public int compare (Author a, Author b);
149        public string name { get; set; }
150        public string uri { get; set; }
151        public string email_address { get; set; }
152    }
153
154    class Category : Parsable {
155        public Category ();
156        public int compare (Category a, Category b);
157        public string label { get; set; }
158        public string scheme { get; set; }
159        public string term { get; set; }
160    }
161
162    class Generator : Parsable {
163        public int compare (Generator a, Generator b);
164        public string name { get; }
165        public string uri { get; }
166        public string version { get; }
167    }
168
169    class Link : Parsable {
170        public Link ();
171        public int compare (Link a, Link b);
172        public string uri { get; set; }
173        public string relation_type { get; set; }
174        public string content_type { get; set; }
175        public string language { get; set; }
176        public string title { get; set; }
177        public int length { get; set; }
178    }
179
180    namespace GD {
181        class EmailAddress : Parsable {
182            public EmailAddress (string address, string relation_type, string label, bool is_primary);
183            public int compare (EmailAddress a, EmailAddress b);
184            public string address { get; set; }
185            public bool is_primary { get; set; }
186            public string label { get; set; }
187            public string relation_type { get; set; }
188        }
189
190        class IMAddress : Parsable {
191            public IMAddress (string address, string protocol, string relation_type, string label, bool is_primary);
192            public int compare (IMAddress a, IMAddress b);
193            public string address { get; set; }
194            public bool is_primary { get; set; }
195            public string label { get; set; }
196            public string relation_type { get; set; }
197            public string protocol { get; set; }
198        }
199
200        class Organization : Parsable {
201            public Organization (string name, string title, string relation_type, string label, bool is_primary);
202            public int compare (Organization a, Organization b);
203            public string name { get; set; }
204            public bool is_primary { get; set; }
205            public string label { get; set; }
206            public string relation_type { get; set; }
207            public string title { get; set; }
208        }
209
210        class PhoneNumber : Parsable {
211            public PhoneNumber (string number, string relation_type, string label, string uri, bool is_primary);
212            public int compare (PhoneNumber a, PhoneNumber b);
213            public string number { get; set; }
214            public bool is_primary { get; set; }
215            public string label { get; set; }
216            public string relation_type { get; set; }
217            public string uri { get; set; }
218        }
219
220        class PostalAddress : Parsable {
221            public PostalAddress (string address, string relation_type, string label, bool is_primary);
222            public int compare (PostalAddress a, PostalAddress b);
223            public string address { get; set; }
224            public bool is_primary { get; set; }
225            public string label { get; set; }
226            public string relation_type { get; set; }
227        }
228
229        class Reminder : Parsable {
230            public Reminder (string method, TimeVal absolute_time, int relative_time);
231            public int compare (Reminder a, Reminder b);
232            public string method { get; set; }
233            public TimeVal absolute_time { get; set; }
234            public bool is_absolute_time ();
235            public int relative_time { get; set; }
236        }
237
238        class When : Parsable {
239            public When (TimeVal start_time, TimeVal end_time, bool is_date);
240            public int compare (When a, When b);
241            public TimeVal start_time { get; set; }
242            public TimeVal end_time { get; set; }
243            public bool is_date { get; set; }
244            public string value_string { get; set; }
245            public List<Reminder> get_reminders ();
246        }
247
248        class Where : Parsable {
249            public Where (string relation_type, string value_string, string label);
250            int compare (Where a, Where b);
251            public string relation_type { get; set; }
252            public string value_string { get; set; }
253            public string label { get; set; }
254        }
255
256        class Who : Parsable {
257            public Who (string relation_type, string value_string, string email_address);
258            int compare (Who a, Who b);
259            public string relation_type { get; set; }
260            public string value_string { get; set; }
261            public string email_address { get; set; }
262        }
263    } // Namespace GD
264
265    class MediaCategory : Parsable {
266        public MediaCategory (string category, string scheme, string label);
267        public string category { get; set; }
268        public string scheme { get; set; }
269        public string label { get; set; }
270    }
271
272    [CCode (cprefix = "GDATA_MEDIA_")]
273    enum MediaMedium {
274        UNKNOWN,
275        IMAGE,
276        AUDIO,
277        VIDEO,
278        DOCUMENT,
279        EXECUTABLE
280    }
281
282    [CCode (cprefix = "GDATA_MEDIA_EXPRESSION_")]
283    enum MediaExpression {
284        SAMPLE,
285        FULL,
286        NONSTOP
287    }
288
289    class MediaContent : Parsable {
290        public string uri { get; }
291        public ulong filesize { get; }
292        public string content_type { get; }
293        MediaMedium medium { get; }
294        bool is_default ();
295        MediaExpression expression { get; }
296        int64 duration { get; }
297        uint height { get; }
298        uint width { get; }
299    }
300
301    class MediaCredit : Parsable {
302        public string credit { get; }
303        public string role { get; }
304        public string scheme { get; }
305    }
306
307    class MediaThumbnail : Parsable {
308        public string uri { get; }
309        public uint height { get; }
310        public uint width { get; }
311        public int64 time { get; }
312    }
313
314    namespace YouTube {
315        [CCode (cprefix = "GDATA_YOUTUBE_FORMAT_")]
316        enum Format {
317            UNKNOWN = 0,
318            RTSP_H263_AMR = 1,
319            HTTP_SWF = 5,
320            RTSP_MPEG4_AAC = 6
321        }
322
323        class Content : MediaContent {
324            Format format { get; }
325        }
326
327        class Credit : MediaCredit {
328            public string entity_type { get; }
329        }
330
331        class State : Parsable {
332            public string name { get; }
333            public string reason_code { get; }
334            public string help_uri { get; }
335            public string message { get; }
336        }
337
338        class Service : GData.Service {
339            public Service (string developer_key, string client_id);
340            public Feed query_videos (GData.Query? query, Cancellable? cancellable, QueryProgressCallback? callback) throws GLib.Error;
341            public void query_videos_async (GData.Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback, AsyncReadyCallback callback);
342            public Feed query_related (Video video, GData.Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback) throws GLib.Error;
343            public void query_related_async (Video video, GData.Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback, AsyncReadyCallback callback);
344            public Feed query_standard_feed (StandardFeedType feed_type, GData.Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback) throws GLib.Error;
345            public void query_standard_feed_async (StandardFeedType feed_type, GData.Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback, AsyncReadyCallback callback);
346            public Video upload_video (Video video, File video_file, Cancellable? cancellable) throws GLib.Error;
347            public string developer_key { get; }
348            public string youtube_user { get; }
349
350            [CCode (cprefix = "GDATA_YOUTUBE_SERVICE_ERROR_")]
351            public enum Error {
352                API_QUOTA_EXCEEDED,
353                ENTRY_QUOTA_EXCEEDED
354            }
355        }
356
357        [CCode (cprefix = "GDATA_YOUTUBE_")]
358        enum StandardFeedType {
359            TOP_RATED_FEED,
360            TOP_FAVORITES_FEED,
361            MOST_VIEWED_FEED,
362            MOST_POPULAR_FEED,
363            MOST_RECENT_FEED,
364            MOST_DISCUSSED_FEED,
365            MOST_LINKED_FEED,
366            MOST_RESPONDED_FEED,
367            RECENTLY_FEATURED_FEED,
368            WATCH_ON_MOBILE_FEED
369        }
370
371        [CCode (cprefix = "GDATA_YOUTUBE_AGE_")]
372        enum Age {
373            ALL_TIME = 0,
374            TODAY,
375            THIS_WEEK,
376            THIS_MONTH
377        }
378
379        [CCode (cprefix = "GDATA_YOUTUBE_SAFE_SEARCH_")]
380        enum SafeSearch {
381            NONE = 0,
382            MODERATE,
383            STRICT
384        }
385
386        [CCode (cprefix = "GDATA_YOUTUBE_SORT_")]
387        enum SortOrder {
388            NONE = 0,
389            ASCENDING,
390            DESCENDING
391        }
392
393        [CCode (cprefix = "GDATA_YOUTUBE_UPLOADER_")]
394        enum Uploader {
395            ALL = 0,
396            PARTNER
397        }
398
399        class Query : GData.Query {
400            public Query (string q);
401            public Age age { get; set; }
402            public Format format { get; set; }
403            public string language { get; set; }
404            public void get_location (out double latitude, out double longitude, out double radius, out bool has_location);
405            public void set_location (double latitude, double longitude, double radius, bool has_location);
406            public string order_by { get; set; }
407            public string restriction { get; set; }
408            public SafeSearch safe_search { get; set; }
409            public SortOrder sort_order { get; set; }
410            public Uploader uploader { get; set; }
411        }
412
413        class Video : GData.Entry {
414            public Video (string id);
415            public static Video new_from_xml (string xml, int length) throws GLib.Error;
416            public Content? look_up_content (string type);
417            public List<GData.MediaThumbnail> get_thumbnails ();
418            public MediaCategory category { get; set; }
419            public Credit credit { get; }
420            public string description { get; set; }
421            public uint duration { get; }
422            public string keywords { get; set; }
423            public string location { get; set; }
424            public uint view_count { get; }
425            public uint favorite_count { get; }
426            public bool is_restricted_in_country (string country);
427            public bool no_embed { get; set; }
428            public string player_uri { get; }
429            public bool is_private ();
430            public void set_is_private (bool is_private);
431            public bool is_draft ();
432            public void set_is_draft (bool is_draft);
433            public State state { get; }
434            public void get_rating (out uint min, out uint max, out uint count, out double average);
435            public string title { get; set; }
436            public TimeVal uploaded { get; }
437            public TimeVal recorded { get; set; }
438            public string video_id { get; }
439        }
440    } // Namespace YouTube
441
442    namespace Calendar {
443        class Service : GData.Service {
444            public Service (string client_id);
445            Feed query_all_calendars (GData.Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback) throws GLib.Error;
446            void query_all_calendars_aync (GData.Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback, AsyncReadyCallback callback) ;
447            Feed query_own_calendars (GData.Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback) throws GLib.Error;
448            void query_own_calendars_aync (GData.Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback, AsyncReadyCallback callback) ;
449            Feed query_events (Calendar calendar, GData.Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback) throws GLib.Error;
450            Event? insert_event (Event event, Cancellable? cancellable) throws GLib.Error;
451        }
452
453        class Feed : GData.Feed {
454            public string timezone { get; }
455            public uint times_cleaned { get; }
456        }
457
458        class Query : GData.Query {
459            public Query (string q);
460            public static Query new_with_limits (string q, TimeVal start_min, TimeVal start_max);
461            public bool future_events { get; set; }
462            public bool single_events { get; set; }
463            public string order_by { get; set; }
464            public string sort_order { get; set; }
465            public TimeVal start_min { get; set; }
466            public TimeVal start_max { get; set; }
467            public TimeVal recurrence_expansion_start { get; set; }
468            public TimeVal recurrence_expansion_end { get; set; }
469            public string timezone { get; set; }
470        }
471
472        class Calendar : GData.Entry {
473            public Calendar (string id);
474            public static Calendar new_from_xml (string xml, int length) throws Error;
475            public Color color { get; set; }
476            public bool hidden { get; set; }
477            public bool selected { get; set; }
478            public string timezone { get; set; }
479            public TimeVal edited { get; }
480            public uint times_cleaned { get; }
481            public string access_level { get; }
482        }
483
484        class Event : GData.Entry {
485            public Event (string id);
486            public static Event new_from_xml (string xml, int length) throws Error;
487            public List<GD.Who>? get_people ();
488            public void add_person (GD.Who who);
489            public List<GD.Where>? get_places ();
490            public void add_place (GD.Where where);
491            public List<GD.When>? get_times ();
492            public bool get_primary_time (out TimeVal start_time, out TimeVal end_time, out GD.When when);
493            public void add_time (GD.When when);
494            public string recurrence { get; set; }
495            public void get_original_event_details (out string event_id, out string event_uri);
496            public bool is_exception ();
497            public bool anyone_can_add_self { get; set; }
498            public bool guests_can_invite_others { get; set; }
499            public bool guests_can_modify { get; set; }
500            public bool guests_can_see_guests { get; set; }
501            public uint sequence { get; set; }
502            public string status { get; set; }
503            public string transparency { get; set; }
504            public string uid { get; set; }
505            public string visibility { get; set; }
506            public TimeVal edited { get; }
507        }
508    } // Namespace Calendar
509
510    namespace Contacts {
511        class Service : GData.Service {
512            public Service (string client_id);
513            public GData.Feed query_contacts (GData.Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback) throws GLib.Error;
514            public void query_contacts_async (GData.Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback, AsyncReadyCallback callback);
515            public Contact? insert_contact (Contact contact, Cancellable? cancellable) throws GLib.Error;
516        }
517
518        class Query : GData.Query {
519            public Query (string q);
520            public static Query new_with_limits (string q, TimeVal start_min, TimeVal start_max);
521            public string order_by { get; set; }
522            public string sort_order { get; set; }
523            public bool show_deleted { get; set; }
524            public string group { get; set; }
525        }
526
527        class Contact {
528            public Contact (string id);
529            public static Contact new_from_xml (string xml, int length) throws GLib.Error;
530            public List<GD.EmailAddress>? get_email_addresses ();
531            public GD.EmailAddress? get_primary_email_address ();
532            public void add_email_address (GD.EmailAddress address);
533            public List<GD.IMAddress>? get_im_addresses ();
534            public GD.IMAddress? get_primary_im_address ();
535            public void add_im_address (GD.IMAddress address);
536            public List<GD.PostalAddress>? get_postal_addresses ();
537            public GD.PostalAddress? get_primary_postal_address ();
538            public void add_postal_address (GD.PostalAddress address);
539            public List<GD.PhoneNumber>? get_phone_numbers ();
540            public GD.PhoneNumber? get_primary_phone_number ();
541            public void add_phone_number (GD.PhoneNumber address);
542            public List<GD.Organization>? get_organizations ();
543            public GD.Organization? get_primary_organization ();
544            public void add_organization (GD.Organization address);
545            public List<string>? get_groups ();
546            public void add_group (string href);
547            public void remove_group (string href);
548            public bool is_group_deleted (string href);
549            public string get_extended_property (string name);
550            public HashTable<string, string> get_extended_properties ();
551            public bool set_extended_property (string name, string value);
552            public TimeVal edited { get; }
553            public bool is_deleted ();
554            public bool has_photo ();
555            public string get_photo (Service service, out size_t length, out string? content_type, Cancellable? cancellable) throws GLib.Error;
556            public bool set_photo (Service service, string data, size_t length = 0, Cancellable? cancellable = null) throws Error;
557        }
558    } // Namespace Contacts
559
560    [CCode (lower_case_cprefix = "gdata_picasaweb_")]
561    namespace PicasaWeb {
562        class Service : GData.Service {
563            public Service (string client_id);
564            public Feed query_all_albums (Query? query, string? username, Cancellable? cancellable, QueryProgressCallback? progress_callback) throws GLib.Error;
565            public void query_all_albums_async (Query? query, string? username, Cancellable? cancellable, QueryProgressCallback? progress_callback, AsyncReadyCallback callback);
566            public Feed query_files (Album? album, Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback) throws GLib.Error;
567            public File upload_file (Album? album, File file, GLib.File actual_file, Cancellable? cancellable) throws GLib.Error;
568        }
569
570        [CCode (cprefix = "GDATA_PICASAWEB_")]
571        enum Visibility {
572            PUBLIC = 1,
573            PRIVATE
574        }
575
576        class Query : GData.Query {
577            public Query (string q);
578            public Visibility visibility { get; set; }
579            public string thumbnail_size { get; set; }
580            public string image_size { get; set; }
581            public string tag { get; set; }
582            void get_bounding_box (out double north, out double east, out double south, out double west);
583            void set_bounding_box (double north, double east, double south, double west);
584            public string location { get; set; }
585        }
586
587        class Album : GData.Entry {
588            public Album (string id);
589            public static Album new_from_xml (string xml, int length) throws Error;
590            public string user { get; }
591            public string nickname { get; }
592            public TimeVal edited { get; }
593            public string name { get; }
594            public string location { get; set; }
595            public Visibility visibility { get; set; }
596            public TimeVal timestamp { get; set; }
597            public uint num_photos { get; }
598            public uint num_photos_remaining { get; }
599            public long bytes_used { get; }
600            public bool is_commenting_enabled ();
601            public void set_is_commenting_enabled (bool is_commenting_enabled);
602            public uint comment_count { get; }
603            public string tags { get; set; }
604            public string description { get; set; }
605            public List<MediaContent> get_contents ();
606            public List<MediaThumbnail>? get_thumbnails ();
607        }
608
609        class File : GData.Entry {
610            public File (string id);
611            public static File new_from_xml (string xml, int length) throws Error;
612            public TimeVal edited { get; }
613            public string version { get; }
614            public double position { get; set; }
615            public string album_id { get; set; }
616            public uint width { get; }
617            public uint height { get; }
618            public size_t size { get; }
619            public string client { get; set; }
620            public string checksum { get; set; }
621            public TimeVal timestamp { get; set; }
622            public bool is_commenting_enabled ();
623            public void set_is_commenting_enabled (bool is_commenting_enabled);
624            public uint comment_count { get; }
625            public uint rotation { get; set; }
626            public string video_status { get; }
627            public string tags { get; set; }
628            public string credit { get; }
629            public string caption { get; set; }
630            public List<MediaContent> get_contents ();
631            public List<MediaThumbnail>? get_thumbnails ();
632        }
633    } // Namespace PicasaWeb
634
635    namespace Documents {
636        class Service : GData.Service {
637            public Service (string client_id);
638            public Feed query_documents (Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback) throws Error;
639            public void query_documents_async (Query? query, Cancellable? cancellable, QueryProgressCallback? progress_callback, AsyncReadyCallback callback);
640            public Entry upload_document (Entry document, GLib.File document_file, Folder? folder, bool metadata, Cancellable? cancellable) throws GLib.Error;
641            public Entry update_document (Entry document, GLib.File? document_file, bool metadata, bool none_match, bool match, Cancellable? cancellable) throws Error;
642            public Entry move_document_to_folder (Entry document, Folder folder, Cancellable? cancellable) throws Error;
643            public void remove_document_from_folder (Entry document, Folder folder, bool match, Cancellable? cancellable) throws Error;
644        }
645
646        class Query : GData.Query {
647            public Query (string q);
648            public static Query new_with_limits (string q, int start_index, int max_results);
649            public bool show_deleted { get; set; }
650            public bool show_folders { get; set; }
651            public string folder_id { get; set; }
652            public string title { get; set; }
653            public bool exact_title { get; }
654            public List<GD.EmailAddress>? get_collaborators_address ();
655            public List<GD.EmailAddress>? get_readers_address ();
656            public void add_a_collaborator_email_address (string collborator_address);
657            public void add_a_reader_email_address (string reader_address);
658        }
659
660        class Entry : GData.Entry {
661            public TimeVal edited { get; }
662            public TimeVal last_viewed { get; }
663            public string path { get; set; }
664            public string document_id { get; set; }
665            public bool writers_can_invite { get; set; }
666            public Author last_modified_by { get; }
667            public GData.Feed? access_rules { get; }
668            public void set_access_rules (GData.Service service, Cancellable? cancellable, QueryProgressCallback progress_callback) throws GLib.Error;
669        }
670
671        class Feed : GData.Feed {
672        }
673
674        class Folder : GData.Entry {
675        }
676
677        class Presentation : GData.Entry {
678            public Presentation (string id);
679            GLib.File download_document (Service service, out string? content_type, Presentation.Format format, GLib.File destination_directory, bool replace_if_exists, Cancellable? cancellable) throws Error;
680
681            [CCode (cprefix = "GDATA_DOCUMENTS_PRESENTATION_")]
682            public enum Format {
683                PDF,
684                PNG,
685                PPT,
686                SWF,
687                TXT
688            }
689        }
690
691        class Spreadsheet : GData.Entry {
692            public Spreadsheet (string id);
693            GLib.File download_document (Service service, out string? content_type, Presentation.Format format, GLib.File destination_directory, bool replace_if_exists, Cancellable? cancellable) throws Error;
694
695            [CCode (cprefix = "GDATA_DOCUMENTS_SPREADSHEET_")]
696            public enum Format {
697                XLS,
698                CSV,
699                PDF,
700                ODS,
701                TSV,
702                HTML
703            }
704        }
705
706        class Text : GData.Entry {
707            public Text (string id);
708            GLib.File download_document (Service service, out string? content_type, Presentation.Format format, GLib.File destination_directory, bool replace_if_exists, Cancellable? cancellable) throws Error;
709
710            [CCode (cprefix = "GDATA_DOCUMENTS_TEXT_")]
711            public enum Format {
712                DOC,
713                HTML,
714                ODT,
715                PDF,
716                PNG,
717                RTF,
718                TXT,
719                ZIP
720            }
721        }
722    } // Namespace Documents
723
724} // Namespace GData
bridges/gdata/main.vala
1
2MainLoop loop;
3
4void main ()
5{
6    loop = new MainLoop (null, false);
7
8    Environment.set_application_name ("GDataBrige");
9
10    try {
11        var conn = DBus.Bus.get (DBus.BusType.SESSION);
12        dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
13
14        uint request_name_result = bus.request_name ("org.freedesktop.Tracker.GDataBridge", (uint)0);
15        if (request_name_result != DBus.RequestNameReply.PRIMARY_OWNER) {
16            critical ("Somebody already got our name on the bus !");
17            return;
18        }
19
20#if DEBUG
21        message ("Creating the bridge...\n");
22#endif
23
24        var picasa_bridge = new GDataBridgePicasaWeb ();
25        conn.register_object ("/org/freedesktop/Tracker/BridgePicasaWeb", picasa_bridge);
26
27
28        loop.run ();
29    } catch (Error e) {
30        critical ("Cannot start the bridge : %s", e.message);
31    }
32}
bridges/gdata/po/LINGUAS
bridges/gdata/po/POTFILES.in
1src/gdata-bridge-picasaweb.vala
2src/main.vala
bridges/gdata/po/POTFILES.skip
1src/gdata-bridge-picasaweb.c
2src/main.c
bridges/gdata/src/Makefile.am
1AM_CPPFLAGS = \
2    -include $(CONFIG_HEADER)
3
4VALAINCLUDES= \
5    --pkg dbus-glib-1 \
6    --pkg tracker-bridge \
7    --pkg libgdata \
8    --pkg uuid \
9    --thread
10
11libexec_PROGRAMS=tracker-bridge-gdata
12
13tracker_bridge_gdata_VALASOURCES= \
14    gdata-bridge-picasaweb.vala \
15    main.vala
16
17tracker_bridge_gdata_SOURCES= \
18    $(tracker_bridge_gdata_VALASOURCES:.vala=.c)
19
20tracker-bridge-gdata.vala.stamp: $(tracker_bridge_gdata_VALASOURCES)
21    $(VALAC) -C $(VALAINCLUDES) $(VALAFLAGS) $^
22    touch $@
23
24tracker_bridge_gdata_CFLAGS= \
25    -DSHAREDIR=\""$(datadir)"\" \
26    -DLOCALEDIR=\""$(localedir)"\" \
27    -I$(top_srcdir)/src \
28    $(WARN_CFLAGS) \
29    $(GLIB2_CFLAGS) \
30    $(GOBJECT_CFLAGS) \
31    $(GTHREAD_CFLAGS) \
32    $(DBUS_CFLAGS) \
33    $(TRACKERBRIDGE_CFLAGS) \
34    $(LIBGDATA_CFLAGS) \
35    $(UUID_CFLAGS)
36
37tracker_bridge_gdata_LDADD= \
38    $(GLIB2_LIBS) \
39    $(GOBJECT_LIBS) \
40    $(GTHREAD_LIBS) \
41    $(DBUS_LIBS) \
42    $(TRACKERBRIDGE_LIBS) \
43    $(LIBGDATA_LIBS) \
44    $(UUID_LIBS)
45
46BUILT_SOURCES= \
47    tracker-bridge-gdata.vala.stamp
48
49CLEANFILES= $(BUILT_SOURCES)
50
51EXTRA_DIST= \
52    tracker-bridge-gdata.vala.stamp \
53    $(tracker_bridge_gdata_SOURCES) \
54    $(tracker_bridge_gdata_VALASOURCES)
55
56MAINTAINERCLEANFILES= \
57    $(tracker_bridge_gdata_SOURCES) \
58    tracker-bridge-gdata.vala.stamp
bridges/gdata/src/gdata-bridge-picasaweb.vala
1using GData;
2using Tracker;
3
4class GDataBridgePicasaWeb : Object, Tracker.Bridge {
5    private const string API_KEY = "ABQIAAAAISU_TtyUrVg0N9RGhb8pTxRI3KVolA1NVmS0lLG3RQFyztcosBSHs5rHiQHsmL41EbX1SehKnf1rrw";
6    private const string TRACKER_NAME = "org.freedesktop.Tracker";
7    private const string TRACKER_RESOURCES_PATH = "/org/freedesktop/Tracker/Resources";
8    private const string TRACKER_RESOURCES_INTERFACE = "org.freedesktop.Tracker.Resources";
9    private const string SERVICE_NAME = "GData-PicasaWeb";
10
11    private DBus.Connection conn;
12    private dynamic DBus.Object tracker;
13
14    private string username;
15
16    private uint bridge_status;
17
18    private PicasaWeb.Service service = null;
19
20    public GDataBridgePicasaWeb ()
21    {
22        set_bridge_status (Bridge.Status.NotAuthenticated);
23
24        try {
25            conn = DBus.Bus.get (DBus.BusType.SESSION);
26        } catch (Error e) {
27            critical ("Cannot connect to session bus : %s\n", e.message);
28        }
29
30        tracker = conn.get_object (TRACKER_NAME, TRACKER_RESOURCES_PATH, TRACKER_RESOURCES_INTERFACE);
31
32        service = new PicasaWeb.Service (API_KEY);
33    }
34
35    public void Authenticate ()
36    {
37        HashTable<string, string> pwdData = null;
38        try {
39            pwdData = Tracker.passwordProvider.search (null, SERVICE_NAME);
40        } catch (Error e) {
41            critical ("Couldn't retrieve stored passowrd : %s", e.message);
42        }
43
44        if (pwdData != null) {
45            username = pwdData.lookup ("username");
46            string password = pwdData.lookup ("secret");
47
48            bool result = false;
49            try {
50                result = service.authenticate (username, password, null);
51            } catch (Error e) {
52                Error (Bridge.DBusErrorCode.AuthenticationError, _("Couldn't authenticate against remote service : %s").printf (e.message));
53                set_bridge_status (Bridge.Status.NotAuthenticated);
54            }
55
56            if (!result) {
57                Error (Bridge.DBusErrorCode.AuthenticationError, _("Invalid username and/or password"));
58                set_bridge_status (Bridge.Status.WrongToken);
59            } else {
60                set_bridge_status (Bridge.Status.Authenticated, username);
61            }
62        } else {
63            set_bridge_status (Bridge.Status.NotAuthenticated);
64            return;
65        }
66    }
67
68    public HashTable<string, string> GetAssociationData ()
69    {
70        var ret = new HashTable<string, string> (str_hash, str_equal);
71        return ret;
72    }
73
74    public void FinishAssociation (HashTable<string, string> data)
75    {
76        if (data.lookup ("user") == null || data.lookup("password") == null) {
77            critical ("Invalid user and/or password");
78            return;
79        }
80
81        try {
82            Tracker.passwordProvider.save (data.lookup ("user"), SERVICE_NAME, data.lookup ("password"), _("Authentification data for Google services (PicasaWeb)"));
83        } catch (Error e) {
84            critical ("Error while storing password : %s", e.message);
85        }
86
87        Authenticate ();
88
89    }
90
91    public uint GetStatus ()
92    {
93        return bridge_status;
94    }
95
96    public void Pull ()
97    {
98        set_bridge_status (Status.Working);
99        service.query_all_albums_async (null, username, null, null, list_albums);
100    }
101
102    public void Shutdown ()
103    {
104    }
105
106    private void insertPicture (Entry file)
107    {
108
109        string uri = "urn:nepomuk:gdata:%s".printf (file.id);
110
111        try {
112            tracker.SparqlUpdate ("insert {<%s> a nmm:Photo}".printf (uri));
113            tracker.SparqlUpdate ("insert {<%s> a nfo:RemoteDataObject}".printf (uri));
114            tracker.SparqlUpdate ("insert {<%s> rdfs:label '%s'}".printf (uri, file.title.escape ("")));
115
116            tracker.SparqlUpdate ("insert {<%s> nfo:height %u}".printf (uri, ((PicasaWeb.File)file).height));
117            tracker.SparqlUpdate ("insert {<%s> nfo:width %u}".printf (uri, ((PicasaWeb.File)file).width));
118
119            if (((PicasaWeb.File)file).tags != null) {
120                foreach (string tag in ((PicasaWeb.File)file).tags.split (",")) {
121                    string tagUri = getTagUri (tag);
122                    tracker.SparqlUpdate ("insert {<%s> a nao:Tag}".printf (tagUri));
123                    tracker.SparqlUpdate ("insert {<%s> rdfs:label '%s'}".printf (tagUri, tag));
124                    tracker.SparqlUpdate ("insert {<%s> nao:hasTag <%s>}".printf (uri, tagUri));
125                }
126            }
127        } catch (Error e) {
128            critical ("Error while entering metadata into Tracker : %s", e.message);
129        }
130    }
131
132    private void list_albums (Object source_object, AsyncResult res)
133    {
134        Feed albums = null;
135        try {
136            albums = service.query_finish (res);
137        } catch (Error e) {
138            critical ("Couldn't list albums : %s", e.message);
139        }
140        debug ("Got %u albums to list", albums.total_results);
141
142        int progress_increment = 100/(int)albums.total_results;
143        int current_progress = 0;
144        Progress (current_progress);
145
146        foreach (Entry album in albums.get_entries ()) {
147            Feed pictures = null;
148            try {
149                pictures = service.query_files ((PicasaWeb.Album)album, null, null, null);
150            } catch (Error e) {
151                critical ("Unable to retrieve files for album %s : %s", album.title, e.message);
152                continue;
153            }
154
155            foreach (Entry picture in pictures.get_entries ()) {
156                insertPicture (picture);
157            }
158            current_progress += progress_increment;
159            Progress (current_progress);
160        }
161
162        Progress (100);
163    }
164
165    private void set_bridge_status (Tracker.Bridge.Status s, string message = "")
166    {
167#if DEBUG
168        debug ("Changing status to %u", s);
169#endif
170        bridge_status = s;
171        StatusChanged ((uint)s, message);
172    }
173}
bridges/gdata/src/main.vala
1
2MainLoop loop;
3
4void main ()
5{
6    loop = new MainLoop (null, false);
7
8    Environment.set_application_name ("GDataBrige");
9
10    try {
11        var conn = DBus.Bus.get (DBus.BusType.SESSION);
12        dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
13
14        uint request_name_result = bus.request_name ("org.freedesktop.Tracker.GDataBridge", (uint)0);
15        if (request_name_result != DBus.RequestNameReply.PRIMARY_OWNER) {
16            critical ("Somebody already got our name on the bus !");
17            return;
18        }
19
20#if DEBUG
21        message ("Creating the bridge...\n");
22#endif
23
24        var picasa_bridge = new GDataBridgePicasaWeb ();
25        conn.register_object ("/org/freedesktop/Tracker/BridgePicasaWeb", picasa_bridge);
26
27
28        loop.run ();
29    } catch (Error e) {
30        critical ("Cannot start the bridge : %s", e.message);
31    }
32}

Archive Download the corresponding diff file

Branches:
master