[tracker/miner-web: 27/48] Port Facebook miner to the (hopefully) final miner-web API
- From: Adrien Bustany <abustany src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/miner-web: 27/48] Port Facebook miner to the (hopefully) final miner-web API
- Date: Tue, 2 Feb 2010 22:09:35 +0000 (UTC)
commit e7ca8277df9059f6aa0bc026beb19295da4d6e22
Author: Adrien Bustany <madcat mymadcat com>
Date: Sat Jan 30 17:58:30 2010 -0300
Port Facebook miner to the (hopefully) final miner-web API
src/tracker-miner-facebook/Makefile.am | 1 -
src/tracker-miner-facebook/facebook.vala | 79 +++++++++++++++---------------
2 files changed, 40 insertions(+), 40 deletions(-)
---
diff --git a/src/tracker-miner-facebook/Makefile.am b/src/tracker-miner-facebook/Makefile.am
index f0e2db1..0714950 100644
--- a/src/tracker-miner-facebook/Makefile.am
+++ b/src/tracker-miner-facebook/Makefile.am
@@ -7,7 +7,6 @@ VALAINCLUDES= \
--vapidir $(top_srcdir)/src/libtracker-miner \
--pkg posix \
--pkg dbus-glib-1 \
- --pkg tracker-miner-web-0.7 \
--pkg tracker-miner-0.7 \
--pkg rest \
--pkg uuid \
diff --git a/src/tracker-miner-facebook/facebook.vala b/src/tracker-miner-facebook/facebook.vala
index 0c0ec22..a32ad9a 100644
--- a/src/tracker-miner-facebook/facebook.vala
+++ b/src/tracker-miner-facebook/facebook.vala
@@ -1,7 +1,7 @@
using Tracker;
using Rest;
-public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
+public class FacebookMiner : Tracker.MinerWeb {
private const string SERVICE_NAME = "Facebook";
private const string SERVICE_DESCRIPTION = "Authentication token for Facebook miner";
private const string API_KEY = "a07366931355e51525938ade2d0df2fb";
@@ -14,6 +14,8 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
dynamic DBus.Object tracker;
+ private unowned PasswordProvider password_provider;
+
private Proxy rest;
private string auth_token;
private string session = null;
@@ -23,21 +25,20 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
private uint timeout_handle = 0;
- private MinerWeb.AssociationStatus _miner_status = Tracker.MinerWeb.AssociationStatus.UNASSOCIATED;
- private MinerWeb.AssociationStatus miner_status {
- get { return _miner_status; }
- set {
- if (_miner_status == miner_status)
- return;
-
- _miner_status = miner_status ;
- AssociationStatusChanged (miner_status);
-
- if (miner_status == MinerWeb.AssociationStatus.ASSOCIATED && timeout_handle != 0) {
- timeout_handle = Timeout.add_seconds (update_interval, pull);
- }
- }
- }
+// private MinerWeb.AssociationStatus miner_status {
+// get { return _miner_status; }
+// set {
+// if (_miner_status == miner_status)
+// return;
+//
+// _miner_status = miner_status ;
+// AssociationStatusChanged (miner_status);
+//
+// if (miner_status == MinerWeb.AssociationStatus.ASSOCIATED && timeout_handle != 0) {
+// timeout_handle = Timeout.add_seconds (update_interval, pull);
+// }
+// }
+// }
private bool _is_paused = false;
private bool is_paused {
@@ -56,6 +57,8 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
construct {
// Set name for Tracker.Miner
set ("name", SERVICE_NAME);
+
+ password_provider = PasswordProvider.get_password_provider ();
}
public FacebookMiner ()
@@ -67,7 +70,7 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
public override void started ()
{
try {
- Authenticate ();
+ authenticate ();
} catch (Error e) {
warning ("Error while authenticating : %s", e.message);
}
@@ -85,21 +88,12 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
{
}
- public override void terminated ()
- {
- }
-
- public override void error (GLib.Error error)
- {
- critical ("An error occured : %s", error.message);
- }
-
- public override void progress (string status, double progress)
+ public override void writeback (string [] subjects)
{
}
// Tracker.MinerWeb
- public HashTable<string, string> AssociationData () throws MinerWebError
+ public override HashTable<string, string> get_association_data () throws MinerWebError
{
var ret = new HashTable<string, string> (str_hash, str_equal);
ProxyCall c = rest.new_call ();
@@ -137,7 +131,7 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
}
// This supposes we have a valid auth_token. Else, well, it'll just fail...
- public void Associate (HashTable<string, string> data) throws MinerWebError
+ public override void associate (HashTable<string, string> data) throws MinerWebError
{
ProxyCall c = rest.new_call ();
c.add_param ("method", "auth.getSession");
@@ -160,21 +154,27 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
}
try {
- PasswordProvider.password_provider.store (SERVICE_NAME, SERVICE_DESCRIPTION, session, secret);
+ password_provider.store_password (SERVICE_NAME, SERVICE_DESCRIPTION, session, secret);
} catch (Error e) {
warning ("Couldn't store credentials in the keyring : %s", e.message);
throw new MinerWebError.KEYRING (e.message);
}
}
- public void Authenticate () throws MinerWebError
+ public override void dissociate () throws Tracker.MinerWebError
+ {
+ message ("Dissociate not implemented");
+ }
+
+ public override MinerWebAssociationStatus authenticate () throws MinerWebError
{
string secret;
+
+ uint association_status = MinerWebAssociationStatus.UNASSOCIATED;
try {
- secret = PasswordProvider.password_provider.get (SERVICE_NAME, out session);
+ secret = password_provider.get_password (SERVICE_NAME, out session);
} catch (Error e) {
if (e is PasswordProviderError.NOTFOUND) {
- miner_status = MinerWeb.AssociationStatus.UNASSOCIATED;
throw new MinerWebError.NO_CREDENTIALS (_("Association needed"));
} else {
warning ("Couldn't access the keyring : %s", e.message);
@@ -202,19 +202,20 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
}
} else {
username = node.content;
- miner_status = MinerWeb.AssociationStatus.ASSOCIATED;
+ association_status = MinerWebAssociationStatus.ASSOCIATED;
}
- }
- public MinerWeb.AssociationStatus GetAssociationStatus ()
- {
- return miner_status;
+ set ("association_status", association_status);
+
+ return (MinerWebAssociationStatus)association_status;
}
public bool pull ()
{
+ uint association_status;
+ get ("association_status", out association_status);
// Only accept new work if we're idle
- if (miner_status != MinerWeb.AssociationStatus.ASSOCIATED && timeout_handle != 0) {
+ if (association_status != MinerWebAssociationStatus.ASSOCIATED && timeout_handle != 0) {
timeout_handle = 0;
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]