libepc r198 - in trunk: . examples



Author: hasselmm
Date: Fri Jan 18 15:23:44 2008
New Revision: 198
URL: http://svn.gnome.org/viewvc/libepc?rev=198&view=rev

Log:
Support authentication credentials in lookup-resource example.

* examples/lookup-resource.c: Add --username and --password
command line switches for passing authentication credentials.


Modified:
   trunk/ChangeLog
   trunk/examples/lookup-resource.c

Modified: trunk/examples/lookup-resource.c
==============================================================================
--- trunk/examples/lookup-resource.c	(original)
+++ trunk/examples/lookup-resource.c	Fri Jan 18 15:23:44 2008
@@ -46,6 +46,8 @@
 
   gchar *service_name = "Easy Publisher Test";
   gchar *application = "test-publisher";
+  gchar *username = NULL;
+  gchar *password = NULL;
   gchar *domain = NULL;
 
   GOptionEntry entries[] =
@@ -56,6 +58,10 @@
         N_("Application name of the publisher"), N_("NAME") },
       { "domain", 'd', 0, G_OPTION_ARG_STRING, &domain,
         N_("DNS domain of the publisher"), N_("DOMAIN") },
+      { "username", 'u', 0, G_OPTION_ARG_STRING, &username,
+        N_("The username to use for authenication"), N_("USERNAME") },
+      { "password", 'p', 0, G_OPTION_ARG_STRING, &password,
+        N_("The password to use for authenication"), N_("PASSWORD") },
       { NULL, 0, 0, 0, NULL, NULL, NULL }
     };
 
@@ -78,10 +84,19 @@
 
   g_option_context_free (options);
 
-  /* Create an consumer and lookup the request items. */
+  /* Create the consumer */
 
   consumer = epc_consumer_new_for_name_full (service_name, application, domain);
 
+  /* Attach default credentials for authentication, when provided. */
+
+  if (username)
+    epc_consumer_set_username (consumer, username);
+  if (password)
+    epc_consumer_set_password (consumer, password);
+
+  /* Query the resources specified on command line. */
+
   if (argc > 1)
     for (i = 1; i < argc; ++i)
       lookup (consumer, argv[i]);



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