[tracker/miner-web] First attempt at adding TrackerMinerWeb.



commit 8913191db48c4f2f5d9570e6e3ffe2dae107e62c
Author: Adrien Bustany <madcat mymadcat com>
Date:   Mon Oct 26 22:04:44 2009 -0300

    First attempt at adding TrackerMinerWeb.
    
    The current version doesn't do anything useful since it doesn't export
    the MinerWeb interface. It's only useful if you want to port bridges against
    the new lib (and don't want to test them :-p).

 configure.ac                                      |   13 +
 src/libtracker-miner/Makefile.am                  |   51 +++-
 src/libtracker-miner/gnome-keyring-1.vapi         |  336 +++++++++++++++++++++
 src/libtracker-miner/gnome-password-provider.vala |   65 ++++
 src/libtracker-miner/password-provider.vala       |   33 ++
 src/libtracker-miner/tracker-miner-0.7.vapi       |   34 ++
 src/libtracker-miner/tracker-miner-web.deps.in    |    1 +
 src/libtracker-miner/tracker-miner-web.vala       |   34 ++
 8 files changed, 563 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0a897ca..cf9b470 100644
--- a/configure.ac
+++ b/configure.ac
@@ -154,6 +154,7 @@ EDS_REQUIRED=2.25.5
 # Unlikely version for now, Nepomuk integration isn't finished in streamanalyzer atm
 LIBSTREAMANALYZER_REQUIRED=0.7.0
 GEE_REQUIRED=0.3
+GNOMEKEYRING_REQUIRED=2.26
 
 # Library Checks
 PKG_CHECK_MODULES(GLIB2, [glib-2.0 >= $GLIB_REQUIRED])
@@ -809,6 +810,18 @@ PKG_CHECK_MODULES(TRACKER_VALA,
 AC_SUBST(TRACKER_VALA_CFLAGS)
 AC_SUBST(TRACKER_VALA_LIBS)
 
+PKG_CHECK_MODULES(GNOMEKEYRING,
+                  [ gnome-keyring-1 >= $GNOMEKEYRING_REQUIRED ],
+                  [have_gnomekeyring=yes],
+                  [have_gnomekeyring=no])
+AC_SUBST(GNOMEKEYRING_LIBS)
+AC_SUBST(GNOMEKEYRING_CFLAGS)
+
+if test "x$have_gnomekeyring" = "xyes"; then
+	AC_DEFINE(HAVE_GNOMEKEYRING, [], [Define if we have Gnome Keyring for password storage])
+fi
+
+AM_CONDITIONAL(HAVE_GNOMEKEYRING, test "x$have_gnomekeyring" = "xyes")
 
 ##################################################################
 # Enable building libtracker-gtk?
diff --git a/src/libtracker-miner/Makefile.am b/src/libtracker-miner/Makefile.am
index 1cf3c61..55cf081 100644
--- a/src/libtracker-miner/Makefile.am
+++ b/src/libtracker-miner/Makefile.am
@@ -19,12 +19,18 @@ INCLUDES =						\
 	$(HAL_CFLAGS)					\
 	$(DEVKIT_POWER_CFLAGS)				\
 	$(DBUS_CFLAGS)					\
-	$(UNAC_CFLAGS)
+	$(UNAC_CFLAGS)                  \
+	--include $(top_srcdir)/config.h
 
 libtracker_minerdir = $(libdir)/tracker-$(TRACKER_API_VERSION)
 libtracker_minerincludedir=$(includedir)/tracker-$(TRACKER_API_VERSION)/libtracker-miner/
 libtracker_miner_LTLIBRARIES = libtracker-miner.la
 
+libtracker_miner_la_VALASOURCES=     \
+    tracker-miner-web.vala           \
+    password-provider.vala           \
+    gnome-password-provider.vala
+
 libtracker_miner_la_SOURCES = 				\
 	tracker-crawler.c				\
 	tracker-crawler.h				\
@@ -40,12 +46,14 @@ libtracker_miner_la_SOURCES = 				\
 	tracker-monitor.c				\
 	tracker-monitor.h				\
 	tracker-utils.c					\
-	tracker-utils.h
+	tracker-utils.h                 \
+	$(libtracker_miner_la_VALASOURCES:.vala=.c)
 
 libtracker_minerinclude_HEADERS = 			\
 	tracker-miner.h 				\
 	tracker-miner-dbus.h 				\
-	tracker-miner-fs.h
+	tracker-miner-fs.h              \
+	tracker-miner-web.h
 
 libtracker_miner_la_LDFLAGS = \
 	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
@@ -65,6 +73,16 @@ libtracker_miner_la_LIBADD = 				\
 	$(GLIB2_LIBS)					\
 	$(GDKPIXBUF_LIBS)
 
+vapidir=$(datadir)/vala/vapi
+vapi_DATA =                     \
+	tracker-miner-$(TRACKER_API_VERSION).vapi \
+	tracker-miner-web-$(TRACKER_API_VERSION).vapi \
+	tracker-miner-web-$(TRACKER_API_VERSION).deps
+
+tracker-miner-web-$(TRACKER_API_VERSION).deps: tracker-miner-web.deps.in
+	@sed -e "s|@VERSION[ ]|${TRACKER_API_VERSION}|" $< > $@
+
+
 tracker-marshal.h: tracker-marshal.list
 	$(AM_V_GEN)$(GLIB_GENMARSHAL) $< --prefix=tracker_marshal --header > $@
 
@@ -80,13 +98,38 @@ dbus_sources = 						\
 	tracker-miner-glue.h				\
 	tracker-miner-client.h
 
+VALAPKGS =                          \
+	--pkg dbus-glib-1               \
+	--pkg tracker-miner-0.7
+
+VALAFLAGS =                         \
+	--vapidir $(top_srcdir)/src/libtracker-miner
+
+if HAVE_GNOMEKEYRING
+VALAPKGS +=                         \
+	--pkg gnome-keyring-1
+VALAFLAGS +=                        \
+	-D HAVE_GNOMEKEYRING
+
+INCLUDES +=                         \
+	$(GNOMEKEYRING_CFLAGS)
+
+libtracker_miner_la_LIBADD +=       \
+	$(GNOMEKEYRING_LIBS)
+endif
+
+
+libtracker-miner-web.vala.stamp: $(libtracker_miner_la_VALASOURCES)
+	$(VALAC) -C $(VALAPKGS) $(VALAFLAGS) -H tracker-miner-web.h --library tracker-miner-web-$(TRACKER_API_VERSION) $^
+	touch $@
+
 %-glue.h: $(top_srcdir)/data/dbus/%.xml
 	$(AM_V_GEN)$(DBUSBINDINGTOOL) --mode=glib-server --output=$@ --prefix=$(subst -,_,$*) $^
 
 %-client.h: $(top_srcdir)/data/dbus/%.xml
 	$(AM_V_GEN)$(DBUSBINDINGTOOL) --mode=glib-client --output=$@ --prefix=$(subst -,_,$*) $^
 
-BUILT_SOURCES = $(dbus_sources) $(marshal_sources)
+BUILT_SOURCES = $(dbus_sources) $(marshal_sources) libtracker-miner-web.vala.stamp
 
 CLEANFILES = $(BUILT_SOURCES)
 
diff --git a/src/libtracker-miner/gnome-keyring-1.vapi b/src/libtracker-miner/gnome-keyring-1.vapi
new file mode 100644
index 0000000..dcd7960
--- /dev/null
+++ b/src/libtracker-miner/gnome-keyring-1.vapi
@@ -0,0 +1,336 @@
+/* gnome-keyring-1.vapi generated by vapigen, do not modify. */
+
+[CCode (cprefix = "GnomeKeyring", lower_case_cprefix = "gnome_keyring_")]
+namespace GnomeKeyring {
+	[Compact]
+	[CCode (copy_function = "gnome_keyring_access_control_copy", cheader_filename = "gnome-keyring.h")]
+	public class AccessControl {
+		public unowned GnomeKeyring.AccessControl copy ();
+		[CCode (has_construct_function = false)]
+		public AccessControl (GnomeKeyring.ApplicationRef application, GnomeKeyring.AccessType types_allowed);
+	}
+	[Compact]
+	[CCode (copy_function = "gnome_keyring_application_ref_copy", cheader_filename = "gnome-keyring.h")]
+	public class ApplicationRef {
+		public unowned GnomeKeyring.ApplicationRef copy ();
+		[CCode (has_construct_function = false)]
+		public ApplicationRef ();
+	}
+	[Compact]
+	[CCode (cheader_filename = "gnome-keyring.h", free_function = "gnome_keyring_attribute_list_free", copy_function = "gnome_keyring_attribute_list_copy")]
+	public class AttributeList : GLib.Array<GnomeKeyring.Attribute> {
+		public AttributeList ();
+		public void append_string (string name, string value);
+		public void append_uint32 (string name, uint32 value);
+		public unowned GnomeKeyring.AttributeList copy ();
+		public GnomeKeyring.Attribute index (int i);
+	}
+	[Compact]
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public class Found {
+		public weak GnomeKeyring.AttributeList attributes;
+		public uint item_id;
+		public weak string keyring;
+		public weak string secret;
+	}
+
+	[Compact]
+	[CCode (copy_function = "gnome_keyring_info_copy", cheader_filename = "gnome-keyring.h")]
+	public class Info {
+		public unowned GnomeKeyring.Info copy ();
+		public ulong get_ctime ();
+		public bool get_is_locked ();
+		public bool get_lock_on_idle ();
+		public uint32 get_lock_timeout ();
+		public ulong get_mtime ();
+		public void set_lock_on_idle (bool value);
+		public void set_lock_timeout (uint32 value);
+	}
+	[Compact]
+	[CCode (copy_function = "gnome_keyring_item_info_copy", cheader_filename = "gnome-keyring.h")]
+	public class ItemInfo {
+		public unowned GnomeKeyring.ItemInfo copy ();
+		public ulong get_ctime ();
+		public unowned string get_display_name ();
+		public ulong get_mtime ();
+		public unowned string get_secret ();
+		[CCode (has_construct_function = false)]
+		public ItemInfo ();
+		public void set_display_name (string value);
+		public void set_secret (string value);
+		public void set_type (GnomeKeyring.ItemType type);
+	}
+	[Compact]
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public class NetworkPasswordData {
+		public weak string authtype;
+		public weak string domain;
+		public uint32 item_id;
+		public weak string keyring;
+		public weak string object;
+		public weak string password;
+		public uint32 port;
+		public weak string protocol;
+		public weak string server;
+		public weak string user;
+	}
+
+	[Compact]
+	public struct PasswordSchemaAttribute {
+		public unowned string name;
+		public GnomeKeyring.AttributeType type;
+	}
+
+	[Compact]
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public struct PasswordSchema {
+		public GnomeKeyring.ItemType item_type;
+		public PasswordSchemaAttribute[] attributes;
+	}
+
+	[Compact]
+	public struct AttributeValue {
+		public uint integer;
+		public string @string;
+	}
+
+	[SimpleType]
+	[CCode (type_id = "GNOME_KEYRING_TYPE_ATTRIBUTE", cheader_filename = "gnome-keyring.h")]
+	public struct Attribute {
+		public weak string name;
+		public unowned GnomeKeyring.AttributeType type;
+		public unowned AttributeValue value;
+	}
+	[CCode (cprefix = "GNOME_KEYRING_ACCESS_", has_type_id = "0", cheader_filename = "gnome-keyring.h")]
+	public enum AccessRestriction {
+		ASK,
+		DENY,
+		ALLOW
+	}
+	[CCode (cprefix = "GNOME_KEYRING_ACCESS_", has_type_id = "0", cheader_filename = "gnome-keyring.h")]
+	public enum AccessType {
+		READ,
+		WRITE,
+		REMOVE
+	}
+	[CCode (cprefix = "GNOME_KEYRING_ATTRIBUTE_TYPE_", has_type_id = "0", cheader_filename = "gnome-keyring.h")]
+	public enum AttributeType {
+		STRING,
+		UINT32
+	}
+	[CCode (cprefix = "GNOME_KEYRING_ITEM_INFO_", has_type_id = "0", cheader_filename = "gnome-keyring.h")]
+	public enum ItemInfoFlags {
+		ALL,
+		BASICS,
+		SECRET
+	}
+	[CCode (cprefix = "GNOME_KEYRING_ITEM_", has_type_id = "0", cheader_filename = "gnome-keyring.h")]
+	public enum ItemType {
+		APPLICATION_SECRET,
+		ITEM_TYPE_MASK,
+		GENERIC_SECRET,
+		NETWORK_PASSWORD,
+		NOTE,
+		CHAINED_KEYRING_PASSWORD,
+		ENCRYPTION_KEY_PASSWORD,
+		PK_STORAGE,
+		LAST_TYPE
+	}
+	[CCode (cprefix = "GNOME_KEYRING_RESULT_", has_type_id = "0", cheader_filename = "gnome-keyring.h")]
+	public enum Result {
+		OK,
+		DENIED,
+		NO_KEYRING_DAEMON,
+		ALREADY_UNLOCKED,
+		NO_SUCH_KEYRING,
+		BAD_ARGUMENTS,
+		IO_ERROR,
+		CANCELLED,
+		KEYRING_ALREADY_EXISTS,
+		NO_MATCH
+	}
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public delegate void OperationDoneCallback (GnomeKeyring.Result result);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public delegate void OperationGetAttributesCallback (GnomeKeyring.Result result, GnomeKeyring.AttributeList attributes);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public delegate void OperationGetIntCallback (GnomeKeyring.Result result, uint32 val);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public delegate void OperationGetItemInfoCallback (GnomeKeyring.Result result, GnomeKeyring.ItemInfo info);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public delegate void OperationGetKeyringInfoCallback (GnomeKeyring.Result result, GnomeKeyring.Info info);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public delegate void OperationGetListCallback (GnomeKeyring.Result result, GLib.List list);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public delegate void OperationGetStringCallback (GnomeKeyring.Result result, string str);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public const string DEFAULT;
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public const GnomeKeyring.PasswordSchema NETWORK_PASSWORD;
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public const string SESSION;
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static unowned GLib.List acl_copy (GLib.List list);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void acl_free (GLib.List acl);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void cancel_request (void* request);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* change_password (string keyring, string? original, string? password, owned GnomeKeyring.OperationDoneCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result change_password_sync (string keyring, string? original, string? password);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* create (string keyring_name, string? password, owned GnomeKeyring.OperationDoneCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result create_sync (string keyring_name, string? password);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result daemon_prepare_environment_sync ();
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result daemon_set_display_sync (string display);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* @delete (string keyring, GnomeKeyring.OperationDoneCallback callback, void* data, GLib.DestroyNotify destroy_data);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* delete_password (GnomeKeyring.PasswordSchema schema, owned GnomeKeyring.OperationDoneCallback callback, ...);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result delete_password_sync (GnomeKeyring.PasswordSchema schema, ...);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result delete_sync (string keyring);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* find_items (GnomeKeyring.ItemType type, GnomeKeyring.AttributeList attributes, owned GnomeKeyring.OperationGetListCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result find_items_sync (GnomeKeyring.ItemType type, GnomeKeyring.AttributeList attributes, out GLib.List found);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* find_itemsv (GnomeKeyring.ItemType type, owned GnomeKeyring.OperationGetListCallback callback, ...);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result find_itemsv_sync (GnomeKeyring.ItemType type, GLib.List found, ...);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* find_network_password (string? user, string? domain, string? server, string? object, string? protocol, string? authtype, uint32 port, owned GnomeKeyring.OperationGetListCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result find_network_password_sync (string? user, string? domain, string? server, string? object, string? protocol, string? authtype, uint32 port, out unowned GLib.List results);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* find_password (GnomeKeyring.PasswordSchema schema, owned GnomeKeyring.OperationGetStringCallback callback, ...);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result find_password_sync (GnomeKeyring.PasswordSchema schema, out unowned string password, ...);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void free_password (string password);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* get_default_keyring (owned GnomeKeyring.OperationGetStringCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result get_default_keyring_sync (out unowned string keyring);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* get_info (string? keyring, owned GnomeKeyring.OperationGetKeyringInfoCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result get_info_sync (string? keyring, out unowned GnomeKeyring.Info info);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static bool is_available ();
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.AccessType item_ac_get_access_type (GnomeKeyring.AccessControl ac);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static unowned string item_ac_get_display_name (GnomeKeyring.AccessControl ac);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static unowned string item_ac_get_path_name (GnomeKeyring.AccessControl ac);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void item_ac_set_access_type (GnomeKeyring.AccessControl ac, GnomeKeyring.AccessType value);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void item_ac_set_display_name (GnomeKeyring.AccessControl ac, string value);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void item_ac_set_path_name (GnomeKeyring.AccessControl ac, string value);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* item_create (string? keyring, GnomeKeyring.ItemType type, string display_name, GnomeKeyring.AttributeList attributes, string secret, bool update_if_exists, owned GnomeKeyring.OperationGetIntCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result item_create_sync (string? keyring, GnomeKeyring.ItemType type, string display_name, GnomeKeyring.AttributeList attributes, string secret, bool update_if_exists, uint32 item_id);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* item_delete (string? keyring, uint32 id, owned GnomeKeyring.OperationDoneCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result item_delete_sync (string? keyring, uint32 id);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* item_get_acl (string? keyring, uint32 id, owned GnomeKeyring.OperationGetListCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result item_get_acl_sync (string? keyring, uint32 id, GLib.List acl);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* item_get_attributes (string? keyring, uint32 id, owned GnomeKeyring.OperationGetAttributesCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result item_get_attributes_sync (string? keyring, uint32 id, out unowned GnomeKeyring.AttributeList attributes);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* item_get_info (string? keyring, uint32 id, owned GnomeKeyring.OperationGetItemInfoCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* item_get_info_full (string? keyring, uint32 id, uint32 flags, owned GnomeKeyring.OperationGetItemInfoCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result item_get_info_full_sync (string? keyring, uint32 id, uint32 flags, out unowned GnomeKeyring.ItemInfo info);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static unowned GnomeKeyring.Result? item_get_info_sync (string keyring, uint32 id, out unowned GnomeKeyring.ItemInfo info);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* item_grant_access_rights (string? keyring, string display_name, string full_path, uint32 id, GnomeKeyring.AccessType rights, owned GnomeKeyring.OperationDoneCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result item_grant_access_rights_sync (string? keyring, string display_name, string full_path, uint32 id, GnomeKeyring.AccessType rights);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* item_set_acl (string? keyring, uint32 id, GLib.List acl, owned GnomeKeyring.OperationDoneCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result item_set_acl_sync (string? keyring, uint32 id, GLib.List acl);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* item_set_attributes (string? keyring, uint32 id, GnomeKeyring.AttributeList attributes, owned GnomeKeyring.OperationDoneCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result item_set_attributes_sync (string? keyring, uint32 id, GnomeKeyring.AttributeList attributes);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* item_set_info (string? keyring, uint32 id, GnomeKeyring.ItemInfo info, owned GnomeKeyring.OperationDoneCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result item_set_info_sync (string? keyring, uint32 id, GnomeKeyring.ItemInfo info);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* list_item_ids (string? keyring, owned GnomeKeyring.OperationGetListCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result list_item_ids_sync (string? keyring, out GLib.List<uint> ids);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* list_keyring_names (owned GnomeKeyring.OperationGetListCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result list_keyring_names_sync (GLib.List keyrings);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* @lock (string keyring, GnomeKeyring.OperationDoneCallback callback, void* data, GLib.DestroyNotify destroy_data);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* lock_all (owned GnomeKeyring.OperationDoneCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result lock_all_sync ();
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result lock_sync (string? keyring);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* memory_alloc (ulong sz);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void memory_free (void* p);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static bool memory_is_secure (void* p);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* memory_realloc (void* p, ulong sz);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static unowned string memory_strdup (string str);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* memory_try_alloc (ulong sz);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* memory_try_realloc (void* p, ulong sz);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void network_password_free (GnomeKeyring.NetworkPasswordData data);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void network_password_list_free (GLib.List list);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static unowned string result_to_message (GnomeKeyring.Result res);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* set_default_keyring (string keyring, owned GnomeKeyring.OperationDoneCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result set_default_keyring_sync (string keyring);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* set_info (string? keyring, GnomeKeyring.Info info, owned GnomeKeyring.OperationDoneCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result set_info_sync (string? keyring, GnomeKeyring.Info info);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* set_network_password (string? keyring, string? user, string? domain, string? server, string? object, string? protocol, string? authtype, uint32 port, string? password, owned GnomeKeyring.OperationGetIntCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result set_network_password_sync (string? keyring, string? user, string? domain, string? server, string? object, string? protocol, string? authtype, uint32 port, string? password, out uint32 item_id);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* store_password (GnomeKeyring.PasswordSchema schema, string? keyring, string display_name, string password, owned GnomeKeyring.OperationDoneCallback callback, ...);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result store_password_sync (GnomeKeyring.PasswordSchema schema, string? keyring, string display_name, string password, ...);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void string_list_free (GLib.List strings);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static void* unlock (string? keyring, string? password, owned GnomeKeyring.OperationDoneCallback callback);
+	[CCode (cheader_filename = "gnome-keyring.h")]
+	public static GnomeKeyring.Result unlock_sync (string? keyring, string? password);
+}
diff --git a/src/libtracker-miner/gnome-password-provider.vala b/src/libtracker-miner/gnome-password-provider.vala
new file mode 100644
index 0000000..b8a4154
--- /dev/null
+++ b/src/libtracker-miner/gnome-password-provider.vala
@@ -0,0 +1,65 @@
+namespace Tracker {
+	class GnomePasswordProvider : Tracker.PasswordProviderIface, GLib.Object {
+
+		private const GnomeKeyring.PasswordSchema password_schema = {
+			GnomeKeyring.ItemType.GENERIC_SECRET,
+			{ { "username", GnomeKeyring.AttributeType.STRING },
+			  { "service", GnomeKeyring.AttributeType.STRING },
+			  { null, 0 } }
+		};
+
+		public void store (string service, string description, string username, string password) throws PasswordProviderError
+		{
+			GnomeKeyring.Result r = GnomeKeyring.store_password_sync (password_schema, null /* default keyring */, description, password, "username", username, "service", service, null);
+
+			if (r != GnomeKeyring.Result.OK) {
+				throw new PasswordProviderError.SERVICE (_("Couldn't save the password in Gnome Keyring : %s"), GnomeKeyring.result_to_message (r));
+			}
+		}
+
+		public new string get (string service, out string? username) throws PasswordProviderError
+		{
+			GnomeKeyring.AttributeList attributes = new GnomeKeyring.AttributeList ();
+			attributes.append_string ("service", service);
+
+			var results = new List<GnomeKeyring.Found> ();
+			GnomeKeyring.Result r = GnomeKeyring.find_items_sync (GnomeKeyring.ItemType.GENERIC_SECRET, attributes, out results);
+
+			if (r == GnomeKeyring.Result.OK) {
+				if (results.length () == 0) {
+					throw new PasswordProviderError.NOTFOUND (_("No results found"));
+				}
+
+				for (weak List<GnomeKeyring.Found> l = results.first() ; l != null ; l = l.next) {
+					weak GnomeKeyring.Found f = (GnomeKeyring.Found)l.data;
+					for (int j = 0 ; j < f.attributes.length ; ++j) {
+						weak GnomeKeyring.Attribute a = f.attributes.index (j);
+						if (a.name == "username" && username != null) {
+							username = a.value.string;
+						}
+					}
+					return f.secret;
+				}
+
+			} else if (r == GnomeKeyring.Result.NO_MATCH) {
+				throw new PasswordProviderError.NOTFOUND (_("No results found"));
+			} else {
+				// Throw error
+				throw new PasswordProviderError.SERVICE (_("Couldn't search in Gnome Keyring : %s"), GnomeKeyring.result_to_message (r));
+			}
+
+			// This point shouldn't be reached
+			return "";
+		}
+
+		public void forget (string service, string username) throws PasswordProviderError
+		{
+			GnomeKeyring.Result r = GnomeKeyring.delete_password_sync (password_schema, "service", service, "username", username, null);
+			if (r != GnomeKeyring.Result.OK) {
+				// Throw error
+				throw new PasswordProviderError.SERVICE (_("Couldn't delete password from Gnome Keyring : %s"), GnomeKeyring.result_to_message (r));
+			}
+		}
+
+	}
+} // Namespace Tracker
diff --git a/src/libtracker-miner/password-provider.vala b/src/libtracker-miner/password-provider.vala
new file mode 100644
index 0000000..2b6401e
--- /dev/null
+++ b/src/libtracker-miner/password-provider.vala
@@ -0,0 +1,33 @@
+namespace Tracker {
+	[CCode (cheader_filename = "libtracker-miner/tracker-miner-web.h")]
+	public errordomain PasswordProviderError {
+		SERVICE, // The service couldn't be contacted
+		NOTFOUND, // No results were found during a call to get
+	}
+
+	[CCode (cheader_filename = "libtracker-miner/tracker-miner-web.h")]
+	public interface PasswordProviderIface : GLib.Object {
+		public abstract void store (string service, string description, string username, string password) throws PasswordProviderError;
+		public abstract string @get (string service, out string? username) throws PasswordProviderError;
+		public abstract void forget (string service, string username) throws PasswordProviderError;
+	}
+
+	[CCode (cheader_filename = "libtracker-miner/tracker-miner-web.h")]
+	public class PasswordProvider : GLib.Object {
+		private static PasswordProviderIface _instance = null;
+
+		public static unowned PasswordProviderIface instance ()
+		{
+			if (_instance == null) {
+#if HAVE_GNOMEKEYRING
+				_instance = new GnomePasswordProvider ();
+#else
+				critical ("No password storage backend defined at compile time");
+#endif
+			}
+
+			assert (_instance != null);
+			return _instance;
+		}
+	}
+}
diff --git a/src/libtracker-miner/tracker-miner-0.7.vapi b/src/libtracker-miner/tracker-miner-0.7.vapi
new file mode 100644
index 0000000..cd2ff4d
--- /dev/null
+++ b/src/libtracker-miner/tracker-miner-0.7.vapi
@@ -0,0 +1,34 @@
+[CCode (cprefix = "Tracker", lower_case_cprefix = "tracker_")]
+namespace Tracker {
+	[Compact]
+	[CCode (cheader_filename = "libtracker-miner/tracker-miner.h")]
+	public abstract class Miner : GLib.Object {
+		public bool commit ();
+		public static GLib.Quark error_quark ();
+		public bool execute_batch_update (string sparql) throws GLib.Error;
+		public unowned GLib.PtrArray execute_sparql (string sparql) throws GLib.Error;
+		public bool execute_update (string sparql) throws GLib.Error;
+		public bool is_started ();
+		public int pause (string application, string reason) throws GLib.Error;
+		public bool resume (int cookie) throws GLib.Error;
+		public void start ();
+		public void stop ();
+
+		public abstract void error (GLib.Error error);
+		public abstract void paused ();
+		public abstract void progress (string status, double progress);
+		public abstract void resumed ();
+		public abstract void started ();
+		public abstract void stopped ();
+		public abstract void terminated ();
+	}
+
+	[CCode (cheader_filename = "libtracker-miner/tracker-miner.h")]
+	public const string MINER_DBUS_INTERFACE;
+	[CCode (cheader_filename = "libtracker-miner/tracker-miner.h")]
+	public const string MINER_DBUS_NAME_PREFIX;
+	[CCode (cheader_filename = "libtracker-miner/tracker-miner.h")]
+	public const string MINER_DBUS_PATH_PREFIX;
+	[CCode (cheader_filename = "libtracker-miner/tracker-miner.h")]
+	public const string MINER_ERROR_DOMAIN;
+}
diff --git a/src/libtracker-miner/tracker-miner-web.deps.in b/src/libtracker-miner/tracker-miner-web.deps.in
new file mode 100644
index 0000000..0f1fc53
--- /dev/null
+++ b/src/libtracker-miner/tracker-miner-web.deps.in
@@ -0,0 +1 @@
+tracker-miner- VERSION@
diff --git a/src/libtracker-miner/tracker-miner-web.vala b/src/libtracker-miner/tracker-miner-web.vala
new file mode 100644
index 0000000..0d8f482
--- /dev/null
+++ b/src/libtracker-miner/tracker-miner-web.vala
@@ -0,0 +1,34 @@
+namespace Tracker {
+
+	[CCode (cheader_filename = "libtracker-miner/tracker-miner-web.h")]
+	[DBus (name = "org.freedesktop.Tracker1.MinerWebError")]
+	public errordomain MinerWebError {
+		WRONG_CREDENTIALS, // Wrong credentials
+		TOKEN_EXPIRED, // Token expired, need to associate again
+		NO_CREDENTIALS, // No credentials found in the keyring
+		KEYRING, // Error contacting the keyring
+		SERVICE, // Error contacting the web service
+		TRACKER // Error contacting Tracker
+	}
+
+	[DBus (name = "org.freedesktop.Tracker1.MinerWeb")]
+	public interface MinerWebIface : GLib.Object {
+		public abstract void Authenticate () throws DBus.Error, MinerWebError;
+	}
+
+	[CCode (cheader_filename = "libtracker-miner/tracker-miner-web.h")]
+	public abstract class MinerWeb : Tracker.Miner, Tracker.MinerWebIface {
+		public abstract void Authenticate () throws DBus.Error, MinerWebError;
+		public abstract HashTable<string, string> AssociationData () throws DBus.Error, MinerWebError;
+		public abstract void Associate (HashTable<string, string> data) throws DBus.Error, MinerWebError;
+
+		public enum AssociationStatus {
+			ASSOCIATED,
+			UNASSOCIATED
+		}
+
+		public signal void AssociationStatusChanged (AssociationStatus s);
+		public abstract AssociationStatus GetAssociationStatus () throws DBus.Error;
+	}
+
+} // namespace Tracker



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