diff options
author | Adrien Bustany <abustany@gnome.org> | 2009-11-06 15:25:19 +0100 |
---|---|---|
committer | Martyn Russell <martyn@lanedo.com> | 2010-03-18 13:56:44 +0000 |
commit | 662d56a960ae913c8f5d615954447b9520fee591 (patch) | |
tree | 1ccb5fe32ef143d313493f14da3036889d3a65e1 /examples/libtracker-miner | |
parent | 99e0162454d36abd014e3f4ee10e77949990d0e2 (diff) | |
download | tracker-662d56a960ae913c8f5d615954447b9520fee591.tar.gz |
libtracker-miner: Add TrackerMinerWeb class
The TrackerMinerWeb class is a thin layer above TrackerMiner which adds
functions commonly used by miners fetching data from remote services.
Diffstat (limited to 'examples/libtracker-miner')
-rw-r--r-- | examples/libtracker-miner/Makefile.am | 16 | ||||
-rw-r--r-- | examples/libtracker-miner/password-provider-test.c | 88 |
2 files changed, 103 insertions, 1 deletions
diff --git a/examples/libtracker-miner/Makefile.am b/examples/libtracker-miner/Makefile.am index 5f753ce7a..6e1da788c 100644 --- a/examples/libtracker-miner/Makefile.am +++ b/examples/libtracker-miner/Makefile.am @@ -17,7 +17,7 @@ INCLUDES = \ $(DBUS_CFLAGS) \ $(UNAC_CFLAGS) -noinst_PROGRAMS = tracker-miner-test +noinst_PROGRAMS = tracker-miner-test password-provider-test tracker_miner_test_SOURCES = \ tracker-miner-test.c \ @@ -36,3 +36,17 @@ tracker_miner_test_LDADD = \ $(GLIB2_LIBS) \ -lz \ -lm + +password_provider_test_SOURCES = \ + password-provider-test.c + +password_provider_test_LDADD = \ + $(top_builddir)/src/libtracker-miner/libtracker-miner-@TRACKER_API_VERSION@.la \ + $(DBUS_LIBS) \ + $(GMODULE_LIBS) \ + $(GTHREAD_LIBS) \ + $(GIO_LIBS) \ + $(GCOV_LIBS) \ + $(GLIB2_LIBS) \ + -lz \ + -lm diff --git a/examples/libtracker-miner/password-provider-test.c b/examples/libtracker-miner/password-provider-test.c new file mode 100644 index 000000000..14178042b --- /dev/null +++ b/examples/libtracker-miner/password-provider-test.c @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2010, Adrien Bustany (abustany@gnome.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include <libtracker-miner/tracker-password-provider.h> + +#define SERVICE_NAME "TestService" + +int main (int argc, char **argv) +{ + gchar *username = NULL; + gchar *password = NULL; + GError *error = NULL; + + g_type_init (); + g_set_application_name ("PasswordBackendTest"); + + TrackerPasswordProvider *provider = tracker_password_provider_get (); + + tracker_password_provider_store_password (provider, + SERVICE_NAME, + "This is the test service", + "testUser", + "testPass", + &error); + + if (error) { + g_critical ("tracker_password_provider_store: %s", error->message); + g_error_free (error); + + return 1; + } + + password = tracker_password_provider_get_password (provider, + SERVICE_NAME, + &username, + &error); + + if (error) { + g_critical ("tracker_password_provider_get: %s", error->message); + g_error_free (error); + g_free (username); + g_free (password); + + return 1; + } else { + g_message ("Username: %s , Password:%s", username, password); + } + + g_free (username); + g_free (password); + + // Also test without getting the username + password = tracker_password_provider_get_password (provider, + SERVICE_NAME, + NULL, + &error); + + if (error) { + g_critical ("tracker_password_provider_get: %s", error->message); + g_error_free (error); + g_free (password); + + return 1; + } else { + g_message ("Password:%s", password); + } + + g_free (password); + g_object_unref (provider); + return 0; +} |