kov changed libgksu/branches/libgksu2/libgksu/ChangeLog,
libgksu/branches/libgksu2/libgksu/libgksu.c,
libgksu/branches/libgksu2/libgksu/libgksu.h
Gustavo Noronha
kov at costa.debian.org
Sun Apr 23 15:01:44 UTC 2006
Mensagem de log:
new API gksu_run{,_full}, which leaves the choice of using
su or sudo backend to the gconf key sudo-mode
-----
Modified: libgksu/branches/libgksu2/libgksu/ChangeLog
===================================================================
--- libgksu/branches/libgksu2/libgksu/ChangeLog 2006-04-16 16:11:14 UTC (rev 548)
+++ libgksu/branches/libgksu2/libgksu/ChangeLog 2006-04-23 15:01:42 UTC (rev 549)
@@ -1,3 +1,10 @@
+2006-04-23 Gustavo Noronha Silva <kov at debian.org>
+
+ * libgksu.{c,h}:
+ - new API gksu_run{,_full}, that is a generic way of using
+ gksu functionality, leaving the choice of su or sudo backend
+ to the gconf setting
+
2006-03-12 Gustavo Noronha Silva <kov at debian.org>
* libgksu.c:
Modified: libgksu/branches/libgksu2/libgksu/libgksu.c
===================================================================
--- libgksu/branches/libgksu2/libgksu/libgksu.c 2006-04-16 16:11:14 UTC (rev 548)
+++ libgksu/branches/libgksu2/libgksu/libgksu.c 2006-04-23 15:01:42 UTC (rev 549)
@@ -1932,3 +1932,83 @@
return retval;
}
+
+/**
+ * gksu_run_full:
+ * @context: a #GksuContext
+ * @ask_pass: a #GksuAskPassFunc to be called when the lib determines
+ * requesting a password is necessary; it may be NULL, in which case
+ * the standard password request dialog will be used
+ * @ask_pass_data: a #gpointer with user data to be passed to the
+ * #GksuAskPasswordFunc
+ * @pass_not_needed: a #GksuPassNotNeededFunc that will be called
+ * when the command is being run without the need for requesting
+ * a password; it will only be called if the display-no-pass-info
+ * gconf key is enabled; NULL will have the standard dialog be shown
+ * @pass_not_needed_data: a #gpointer with the user data to be passed to the
+ * #GksuPasswordNotNeededFunc
+ * @error: a #GError object to be filled with the error code or NULL
+ *
+ * This function is a wrapper for gksu_sudo_full/gksu_su_full. It will
+ * call one of them, depending on the GConf key that defines whether
+ * the default behavior for gksu is su or sudo mode. This is the
+ * recommended way of using the library functionality.
+ *
+ * Returns: FALSE if all went fine, TRUE if failed
+ */
+gboolean
+gksu_run_full (GksuContext *context,
+ GksuAskPassFunc ask_pass,
+ gpointer ask_pass_data,
+ GksuPassNotNeededFunc pass_not_needed,
+ gpointer pass_not_needed_data,
+ GError **error)
+{
+ GConfClient *gconf_client;
+ gboolean sudo_mode;
+
+ gconf_client = context->gconf_client;
+ sudo_mode = gconf_client_get_bool (gconf_client, BASE_PATH "sudo-mode",
+ NULL);
+ g_object_unref (gconf_client);
+
+ if (sudo_mode)
+ return gksu_sudo_full (context, ask_pass, ask_pass_data,
+ pass_not_needed, pass_not_needed_data,
+ error);
+
+ return gksu_su_full (context, ask_pass, ask_pass_data,
+ pass_not_needed, pass_not_needed_data,
+ error);
+}
+
+/**
+ * gksu_run
+ * @command_line: the command line that will be executed as other user
+ * @error: a #GError to be set with the error condition, if an error
+ * happens
+ *
+ * This function is a wrapper for gksu_sudo/gksu_su. It will call one
+ * of them, depending on the GConf key that defines whether the default
+ * behavior for gksu is su or sudo mode. This is the recommended way of
+ * using the library functionality.
+ *
+ * Returns: FALSE if all went well, TRUE if an error happend.
+ */
+gboolean
+gksu_run (gchar *command_line,
+ GError **error)
+{
+ GConfClient *gconf_client;
+ gboolean sudo_mode;
+
+ gconf_client = context->gconf_client;
+ sudo_mode = gconf_client_get_bool (gconf_client, BASE_PATH "sudo-mode",
+ NULL);
+ g_object_unref (gconf_client);
+
+ if (sudo_mode)
+ return gksu_sudo (command_line, error);
+
+ return gksu_su (command_line, error);
+}
Modified: libgksu/branches/libgksu2/libgksu/libgksu.h
===================================================================
--- libgksu/branches/libgksu2/libgksu/libgksu.h 2006-04-16 16:11:14 UTC (rev 548)
+++ libgksu/branches/libgksu2/libgksu/libgksu.h 2006-04-23 15:01:42 UTC (rev 549)
@@ -48,10 +48,6 @@
GConfClient *gconf_client;
- /*
- * Public
- */
-
/* what to run, with whose powers */
gchar *user;
gchar *command;
@@ -162,6 +158,19 @@
gksu_sudo (gchar *command_line,
GError **error);
+
+gboolean
+gksu_run_full (GksuContext *context,
+ GksuAskPassFunc ask_pass,
+ gpointer ask_pass_data,
+ GksuPassNotNeededFunc pass_not_needed,
+ gpointer pass_not_needed_data,
+ GError **error);
+
+gboolean
+gksu_run (gchar *command_line,
+ GError **error);
+
G_END_DECLS
#endif
More information about the gksu-commits
mailing list