kov changed libgksu/branches/libgksu2/ChangeLog, libgksu/branches/libgksu2/libgksu/libgksu.c, libgksu/branches/libgksu2/libgksu/libgksu.h

Gustavo Noronha kov at costa.debian.org
Sun Apr 30 19:47:00 UTC 2006


Mensagem de log: 
provide an API for simply getting the password
standardize the get methods that return string to
return NULL if they were not set, and updated
"docstrings" to fit;


-----


Modified: libgksu/branches/libgksu2/ChangeLog
===================================================================
--- libgksu/branches/libgksu2/ChangeLog	2006-04-30 19:17:54 UTC (rev 579)
+++ libgksu/branches/libgksu2/ChangeLog	2006-04-30 19:46:58 UTC (rev 580)
@@ -1,5 +1,11 @@
 2006-04-30  Gustavo Noronha Silva  <kov at debian.org>
 
+	* libgksu/libgksu.c:
+	- provide an API for simply getting the password
+	- standardize the get methods that return string to
+	  return NULL if they were not set, and updated
+	  "docstrings" to fit;
+
 	* libgksuui/libgksu.{c,h}, libgksuui/gksuui-dialog.c:
 	- accepted changes from the Ubuntu people to make the dialog
 	  and messages be more beatiful; also provide an API that

Modified: libgksu/branches/libgksu2/libgksu/libgksu.c
===================================================================
--- libgksu/branches/libgksu2/libgksu/libgksu.c	2006-04-30 19:17:54 UTC (rev 579)
+++ libgksu/branches/libgksu2/libgksu/libgksu.c	2006-04-30 19:46:58 UTC (rev 580)
@@ -1289,7 +1289,7 @@
  * Gets the user the command will be run as, as set
  * by gksu_context_set_user.
  *
- * Returns: a pointer to the string containing the username.
+ * Returns: a string with the user or NULL if not set.
  */
 const gchar*
 gksu_context_get_user (GksuContext *context)
@@ -1322,7 +1322,7 @@
  * Gets the command that will be run, as set by
  * gksu_context_set_command.
  *
- * Returns: a pointer to the string containing the command.
+ * Returns: a string with the command or NULL if not set.
  */
 const gchar*
 gksu_context_get_command (GksuContext *context)
@@ -1415,14 +1415,12 @@
  * default function for requesting the password is
  * called.
  *
- * Returns: a string with the description.
+ * Returns: a string with the description or NULL if not set.
  */
 gchar*
 gksu_context_get_description (GksuContext *context)
 {
-  if (context->description)
-    return context->description;
-  return "";
+  return context->description;
 }
 
 /**
@@ -1449,14 +1447,12 @@
  * default function for requesting the password is
  * called.
  *
- * Returns: a string with the message.
+ * Returns: a string with the message or NULL if not set.
  */
 gchar*
 gksu_context_get_message (GksuContext *context)
 {
-  if (context->message)
-    return context->message;
-  return "";
+  return context->message;
 }
 
 /**
@@ -2473,3 +2469,47 @@
 
   return gksu_su (command_line, error);
 }
+
+/**
+ * gksu_ask_password_full:
+ * @context: a #GksuContext
+ * @prompt: a prompt different from Password:
+ * @error: a #GError object to be filled with the error code or NULL
+ *
+ * This function uses the gksu infra-structure to request for a
+ * password, but instead of passing it to su or sudo to run a command
+ * it simply returns the password.
+ *
+ * Returns: a newly allocated string with the password;
+ */
+gchar*
+gksu_ask_password_full (GksuContext *context, gchar *prompt,
+			GError **error)
+{
+  return su_ask_password (context, prompt, NULL, error);
+}
+
+/**
+ * gksu_ask_password
+ * @error: a #GError to be set with the error condition, if an error
+ * happens
+ *
+ * This function uses the gksu infra-structure to request for a
+ * password, but instead of passing it to su or sudo to run a command
+ * it simply returns the password. This is just a convenience wrapper
+ * for gksu_ask_password_full.
+ *
+ * Returns: a newly allocated string with the password;
+ */
+gchar*
+gksu_ask_password (GError **error)
+{
+  GksuContext *context = gksu_context_new ();
+  gchar* retval;
+
+  context->user = g_strdup ("root");
+  retval = gksu_ask_password_full (context, NULL, error);
+  gksu_context_free (context);
+
+  return retval;
+}

Modified: libgksu/branches/libgksu2/libgksu/libgksu.h
===================================================================
--- libgksu/branches/libgksu2/libgksu/libgksu.h	2006-04-30 19:17:54 UTC (rev 579)
+++ libgksu/branches/libgksu2/libgksu/libgksu.h	2006-04-30 19:46:58 UTC (rev 580)
@@ -185,6 +185,14 @@
 gksu_run (gchar *command_line,
 	  GError **error);
 
+gchar*
+gksu_ask_password_full (GksuContext *context,
+			gchar *prompt,
+			GError **error);
+
+gchar*
+gksu_ask_password (GError **error);
+
 G_END_DECLS
 
 #endif




More information about the gksu-commits mailing list