added documentation for error, log, and dictionary objects
authorImran Zaman <imran.zaman@intel.com>
Wed, 13 Nov 2013 14:44:25 +0000 (16:44 +0200)
committerImran Zaman <imran.zaman@intel.com>
Wed, 13 Nov 2013 14:44:25 +0000 (16:44 +0200)
17 files changed:
include/gum/common/gum-dictionary.h
include/gum/common/gum-error.h
include/gum/common/gum-group-types.h
include/gum/common/gum-log.h
include/gum/common/gum-user-types.h
src/common/gum-dictionary.c
src/common/gum-error.c
src/common/gum-file.c
src/common/gum-validate.c
src/daemon/dbus/gumd-dbus-group-service-adapter.c
src/daemon/dbus/gumd-dbus-user-service-adapter.c
src/daemon/gumd-daemon-group.c
src/daemon/gumd-daemon-user.c
src/daemon/gumd-daemon.c
src/lib/gum-group.c
src/lib/gum-user.c
test/common/commontest.c

index 296c4af..df63cc6 100644 (file)
@@ -3,9 +3,9 @@
 /*
  * This file is part of gum
  *
- * Copyright (C) 2012-2013 Intel Corporation.
+ * Copyright (C) 2013 Intel Corporation.
  *
- * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
+ * Contact: Imran Zaman <imran.zaman@intel.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -34,10 +34,10 @@ G_BEGIN_DECLS
 #define GUM_TYPE_DICTIONARY (G_TYPE_HASH_TABLE)
 
 #define GUM_DICTIONARY(obj)  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-                                           GUM_TYPE_DICTIONARY, \
-                                           GumDictionary))
+        GUM_TYPE_DICTIONARY, \
+        GumDictionary))
 #define GUM_IS_DICTIONARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
-                                           GUM_TYPE_DICTIONARY))
+        GUM_TYPE_DICTIONARY))
 
 typedef GHashTable GumDictionary;
 
@@ -45,76 +45,111 @@ GumDictionary *
 gum_dictionary_new (void);
 
 void
-gum_dictionary_ref (GumDictionary *dict);
+gum_dictionary_ref (
+        GumDictionary *dict);
 
 void
-gum_dictionary_unref (GumDictionary *dict);
+gum_dictionary_unref (
+        GumDictionary *dict);
 
 GumDictionary *
-gum_dictionary_copy (GumDictionary *other);
+gum_dictionary_copy (
+        GumDictionary *other);
 
 GumDictionary *
-gum_dictionary_new_from_variant (GVariant *variant);
+gum_dictionary_new_from_variant (
+        GVariant *variant);
 
 GVariant *
-gum_dictionary_to_variant (GumDictionary *self);
+gum_dictionary_to_variant (
+        GumDictionary *dict);
 
 GVariant *
-gum_dictionary_get (GumDictionary *dict, const gchar *key);
+gum_dictionary_get (
+        GumDictionary *dict,
+        const gchar *key);
 
 gboolean
-gum_dictionary_set (GumDictionary *dict,
-    const gchar *key, GVariant *value);
+gum_dictionary_set (
+        GumDictionary *dict,
+        const gchar *key,
+        GVariant *value);
 
 gboolean
-gum_dictionary_get_boolean (GumDictionary *dict, const gchar *key,
-                                 gboolean *value);
+gum_dictionary_get_boolean (
+        GumDictionary *dict,
+        const gchar *key,
+        gboolean *value);
 
 gboolean
-gum_dictionary_set_boolean (GumDictionary *dict, const gchar *key,
-                                 gboolean value);
+gum_dictionary_set_boolean (
+        GumDictionary *dict,
+        const gchar *key,
+        gboolean value);
 
 gboolean
-gum_dictionary_get_int32 (GumDictionary *dict, const gchar *key,
-                               gint *value);
+gum_dictionary_get_int32 (
+        GumDictionary *dict,
+        const gchar *key,
+        gint *value);
 
 gboolean
-gum_dictionary_set_int32 (GumDictionary *dict, const gchar *key,
-                               gint value);
+gum_dictionary_set_int32 (
+        GumDictionary *dict,
+        const gchar *key,
+        gint value);
 
 gboolean
-gum_dictionary_get_uint32 (GumDictionary *dict, const gchar *key,
-                                guint *value);
+gum_dictionary_get_uint32 (
+        GumDictionary *dict,
+        const gchar *key,
+        guint *value);
 
 gboolean
-gum_dictionary_set_uint32 (GumDictionary *dict, const gchar *key,
-                                guint32 value);
+gum_dictionary_set_uint32 (
+        GumDictionary *dict,
+        const gchar *key,
+        guint32 value);
 
 gboolean
-gum_dictionary_get_int64 (GumDictionary *dict, const gchar *key,
-                               gint64 *value);
+gum_dictionary_get_int64 (
+        GumDictionary *dict,
+        const gchar *key,
+        gint64 *value);
 
 gboolean
-gum_dictionary_set_int64 (GumDictionary *dict, const gchar *key,
-                               gint64 value);
+gum_dictionary_set_int64 (
+        GumDictionary *dict,
+        const gchar *key,
+        gint64 value);
 
 gboolean
-gum_dictionary_get_uint64 (GumDictionary *dict, const gchar *key,
-                                guint64 *value);
+gum_dictionary_get_uint64 (
+        GumDictionary *dict,
+        const gchar *key,
+        guint64 *value);
 
 gboolean
-gum_dictionary_set_uint64 (GumDictionary *dict, const gchar *key,
-                                guint64 value);
+gum_dictionary_set_uint64 (
+        GumDictionary *dict,
+        const gchar *key,
+        guint64 value);
 
 const gchar *
-gum_dictionary_get_string (GumDictionary *dict, const gchar *key);
+gum_dictionary_get_string (
+        GumDictionary *dict,
+        const gchar *key);
 
 gboolean
-gum_dictionary_set_string (GumDictionary *dict, const gchar *key,
-                                const gchar *value);
+gum_dictionary_set_string (
+        GumDictionary *dict,
+        const gchar *key,
+        const gchar *value);
 
 gboolean
-gum_dictionary_remove (GumDictionary *dict, const gchar *key);
+gum_dictionary_remove (
+        GumDictionary *dict,
+        const gchar *key);
 
 G_END_DECLS
 
index 1dc62ef..5d27a90 100644 (file)
 
 G_BEGIN_DECLS
 
-#define GUM_ERROR_DOMAIN "gum"
-
-/**
- * GUM_ERROR:
- *
- */
 #define GUM_ERROR   (gum_error_quark())
 
 typedef enum {
     GUM_ERROR_NONE,
 
-    /**< Catch-all for errors not distinguished by another code. */
     GUM_ERROR_UNKNOWN = 1,
-    /**< Signon Daemon internal error. */
-    GUM_ERROR_INTERNAL_SERVER = 2,
-    /**< Communication with Signon Daemon error. */
-    GUM_ERROR_INTERNAL_COMMUNICATION = 3,
-    /**< The operation cannot be performed due to insufficient client
-     * permissions. */
-    GUM_ERROR_PERMISSION_DENIED = 4,
+    GUM_ERROR_INTERNAL_SERVER,
+    GUM_ERROR_PERMISSION_DENIED,
 
     GUM_ERROR_USER_ALREADY_EXISTS = 32,
     GUM_ERROR_USER_GROUP_ADD_FAILURE,
@@ -96,69 +84,42 @@ typedef enum {
 
     GUM_ERROR_INVALID_INPUT = 160,
 
-    /* Placeholder to rearrange enumeration - User space specific */
     GUM_ERROR_USER_ERR = 400
-   
-} GumError;
-
-#define gum_gerr(error, handler) \
-    G_STMT_START {                 \
-        GString* msg = gum_prepend_domain_to_error_msg(error); \
-        handler(msg->str); \
-        g_string_free(msg, TRUE); \
-    } G_STMT_END\
-
-#define gum_error_gerr(err)       gum_gerr(err, g_error)
-
-#define gum_critical_gerr(err)    gum_gerr(err, g_critical)
-
-#define gum_warning_gerr(err)     gum_gerr(err, g_warning)
-
-#define gum_message_gerr(err)     gum_gerr(err, g_message)
-
-#define gum_debug_gerr(err)       gum_gerr(err, g_debug)
-
-GQuark
-gum_error_quark (void);
-
-GString*
-gum_concat_domain_and_error (
-        const gchar *str1,
-        const gchar *str2);
-
-GString*
-gum_prepend_domain_to_error_msg (
-        const GError *err);
-
-GError *
-gum_error_new_from_variant (
-        GVariant *var);
 
-GVariant *
-gum_error_to_variant (
-        GError *error);
+} GumError;
 
-#define gum_get_gerror_for_id(err, message, args...) \
-    g_error_new (gum_error_quark(), err, message, ##args);
+#define GUM_GET_ERROR_FOR_ID(code, message, args...) \
+    g_error_new (GUM_ERROR, code, message, ##args);
 
-#define SET_ERROR(code, err_str, err, retvar, retval) \
+#define GUM_SET_ERROR(code, err_str, err, retvar, retval) \
     { \
         if (err) { \
-            *err = gum_get_gerror_for_id (code, err_str); \
+            *err = GUM_GET_ERROR_FOR_ID (code, err_str); \
             DBG ("Error %d:%s", code, err_str); \
         } \
         retvar = retval; \
     }
 
-#define RETURN_WITH_ERROR(code, err_str, err, retval) \
+#define GUM_RETURN_WITH_ERROR(code, err_str, err, retval) \
     { \
         if (err) { \
-            *err = gum_get_gerror_for_id (code, err_str); \
+            *err = GUM_GET_ERROR_FOR_ID (code, err_str); \
             DBG ("Error %d:%s", code, err_str); \
         } \
         return retval; \
     }
 
+GQuark
+gum_error_quark (void);
+
+GError *
+gum_error_new_from_variant (
+        GVariant *var);
+
+GVariant *
+gum_error_to_variant (
+        GError *error);
+
 G_END_DECLS
 
 #endif /* __GUM_ERROR_H__ */
index f0734c1..e44c363 100644 (file)
 
 G_BEGIN_DECLS
 
+/**
+ * SECTION:gum-group-types
+ * @short_description: group types definition
+ * @title: Group types
+ *
+ * This file provides various types of group that can be created by the user
+ * management framework.
+ *
+ */
+
+/**
+ * GumGroupType:
+ * @GUM_GROUPTYPE_NONE: group type not defined/set.
+ * @GUM_GROUPTYPE_SYSTEM: system group.
+ * @GUM_GROUPTYPE_USER: normal group.
+ *
+ * This enumeration lists group types.
+ */
+
 typedef enum {
 
     GUM_GROUPTYPE_NONE = 0,
index 63f2318..37f92c3 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
+/**
+ * SECTION:gum-log
+ * @short_description: logging facilities
+ * @title: Logging
+ * @include: gum/common/gum-log.h
+ *
+ * <filename>gum/common/gum-log.h</filename> file contains logging macros
+ *
+ * For example:
+ * |[    INFO("Object initialized"); ]|
+ */
+
+/**
+ * TRACEBACK:
+ *
+ * This macro prints the current function call stack to stderr.
+ */
 #define TRACEBACK() \
 { \
     void *array[256];\
     }\
 }
 
+/**
+ * INFO:
+ * @frmt: format string for the message
+ * @...: arguments for the format string
+ *
+ * Use this macro to log informational messages. Gum will take care of
+ * correctly saving them.
+ */
 #define INFO(frmt, args...) g_message("%f %s:%d %s " frmt , \
         g_get_monotonic_time()*1.0e-6, __FILE__, __LINE__, \
         __PRETTY_FUNCTION__, ##args)
+
+/**
+ * ERR:
+ * @frmt: format string for the message
+ * @...: arguments for the format string
+ *
+ * Use this macro to log error messages. Gum will take care of
+ * correctly saving them.
+ */
 #define ERR(frmt, args...)  g_critical("%f %s:%d %s " frmt , \
         g_get_monotonic_time()*1.0e-6, __FILE__, __LINE__, \
         __PRETTY_FUNCTION__, ##args)
+
+/**
+ * WARN:
+ * @frmt: format string for the message
+ * @...: arguments for the format string
+ *
+ * Use this macro to log warning messages. Gum will take care of
+ * correctly saving them.
+ */
 #define WARN(frmt, args...) g_warning("%f %s:%d %s " frmt , \
         g_get_monotonic_time()*1.0e-6, __FILE__, __LINE__, \
         __PRETTY_FUNCTION__, ##args)
+
+/**
+ * DBG:
+ * @frmt: format string for the message
+ * @...: arguments for the format string
+ *
+ * Use this macro to log debug messages. Gum will take care of
+ * correctly saving them.
+ */
 #define DBG(frmt, args...)  g_debug("%f %s:%d %s " frmt , \
         g_get_monotonic_time()*1.0e-6, __FILE__, __LINE__, \
         __PRETTY_FUNCTION__, ##args)
index a17d892..239029f 100644 (file)
 
 G_BEGIN_DECLS
 
+/**
+ * SECTION:gum-user-types
+ * @short_description: user types definition
+ * @title: User types
+ *
+ * This file provides various types of users that can be created by the user
+ * management framework.
+ *
+ */
+
+/**
+ * GumUserType:
+ * @GUM_USERTYPE_NONE: user type not defined/set
+ * @GUM_USERTYPE_SYSTEM: system user. No home directory will be created for
+ * system user. System user is not able to use login/logout functionality as
+ * its primary usage is limited to system daemons.
+ * @GUM_USERTYPE_ADMIN: admin user is similar to normal user with the addition
+ * of super user privileges.
+ * @GUM_USERTYPE_GUEST: guest user does not need secret/password to login.
+ * Guest user home directory is created with login and cleaned up/destroyed
+ * when user logs out.
+ * @GUM_USERTYPE_NORMAL: normal user with home directory created based on prefix
+ * #GUM_CONFIG_GENERAL_HOME_DIR_PREF. Contents of #GUM_CONFIG_GENERAL_SKEL_DIR
+ * are copied to the home directory.
+ *
+ * This enumeration lists users types.
+ */
+
 typedef enum {
 
     GUM_USERTYPE_NONE = 0,
index b542570..2bff607 100644 (file)
@@ -3,9 +3,9 @@
 /*
  * This file is part of gum
  *
- * Copyright (C) 2012-2013 Intel Corporation.
+ * Copyright (C) 2013 Intel Corporation.
  *
- * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
+ * Contact: Imran Zaman <imran.zaman@intel.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
 #include "common/gum-log.h"
 
 /**
+ * SECTION:gum-dictionary
+ * @short_description: a dictionary container holding string keys and variant
+ *  values
+ * @title: GumDictionary
+ * @include: gum/common/gum-dictionary.h
+ *
+ * A #GumDictionary is a dictionary data structure that maps string keys to
+ * #GVariant values. It's used in multiple places in gum and its public API
+ * to pass key-value data sets.
+ *
+ * |[
+ *     GumDictionary* dict = gum_dictionary_new();
+ *     gum_dictionary_set_string(dict, "name", "John Smith");
+ *     gum_dictionary_set_uint32(dict, "age", 32);
+ *
+ *     guint32 age;
+ *     gboolean success = gum_dictionary_get_uint32(dict, "age", &age);
+ *     const gchar* name = gum_dictionary_get_string(dict, "name");
+ *     gum_dictionary_unref(dict);
+ * ]|
+ */
+
+/**
+ * GumDictionary:
+ *
+ * #GumDictionary is a typedef for #GHashTable, which
+ * means the developers may also use methods associated with that structure.
+ */
+
+/**
  * gum_dictionary_new_from_variant:
- * @variant: instance of #GVariant
+ * @variant: (transfer none): instance of #GVariant
  *
- * Converts the variant to GumDictionary.
+ * Converts the #GVariant to #GumDictionary. This is useful for example if
+ * the dictionary needs to be deserialized, or if it's contained in another
+ * #GumDictionary and has been retrieved using gum_dictionary_get().
  *
- * Returns: (transfer full) object if successful, NULL otherwise.
+ * Returns: (transfer full): #GumDictionary if successful, NULL otherwise.
  */
 GumDictionary *
-gum_dictionary_new_from_variant (GVariant *variant)
+gum_dictionary_new_from_variant (
+        GVariant *variant)
 {
     GumDictionary *dict = NULL;
     GVariantIter iter;
@@ -56,14 +89,16 @@ gum_dictionary_new_from_variant (GVariant *variant)
 
 /**
  * gum_dictionary_to_variant:
- * @dict: instance of #GumDictionary
+ * @dict: (transfer none): instance of #GumDictionary
  *
- * Converts the GumDictionary to variant.
+ * Converts the #GumDictionary to a #GVariant. The result can be serialized
+ * or put into another #GumDictionary using gum_dictionary_set().
  *
- * Returns: (transfer full) #GVariant object if successful, NULL otherwise.
+ * Returns: (transfer full): #GVariant object if successful, NULL otherwise.
  */
 GVariant *
-gum_dictionary_to_variant (GumDictionary *dict)
+gum_dictionary_to_variant (
+        GumDictionary *dict)
 {
     GVariantBuilder builder;
     GHashTableIter iter;
@@ -90,9 +125,9 @@ gum_dictionary_to_variant (GumDictionary *dict)
 /**
  * gum_dictionary_new:
  *
- * Creates new instance of GumDictionary.
+ * Creates a new instance of #GumDictionary.
  *
- * Returns: (transfer full) #GumDictionary object if successful,
+ * Returns: (transfer full): #GumDictionary object if successful,
  * NULL otherwise.
  */
 GumDictionary *
@@ -106,12 +141,14 @@ gum_dictionary_new (void)
 
 /**
  * gum_dictionary_ref:
- * @dict: instance of #GumDictionary
+ * @dict: (transfer none): instance of #GumDictionary
+ *
+ * Increments the reference count of the dictionary structure.
  *
- * Increment reference count of the dictionary structure.
  */
 void
-gum_dictionary_ref (GumDictionary *dict)
+gum_dictionary_ref (
+        GumDictionary *dict)
 {
     g_return_if_fail (dict != NULL);
 
@@ -120,13 +157,15 @@ gum_dictionary_ref (GumDictionary *dict)
 
 /**
  * gum_dictionary_unref:
- * @dict: instance of #GumDictionary
+ * @dict: (transfer none): instance of #GumDictionary
  *
- * Decrement reference count of the dictionary structure.
+ * Decrements the reference count of the dictionary structure. If the reference
+ * count reaches zero, the structure is deallocated and shouldn't be used.
  *
  */
 void
-gum_dictionary_unref (GumDictionary *dict)
+gum_dictionary_unref (
+        GumDictionary *dict)
 {
     if (!dict)
         return;
@@ -136,14 +175,22 @@ gum_dictionary_unref (GumDictionary *dict)
 
 /**
  * gum_dictionary_get:
- * @dict: instance of #GumDictionary
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): the key to look up in the dictionary
  *
- * Retrieves a value from the dictionary.
+ * Retrieves a #GVariant value from the dictionary. This can be used to retrieve
+ * a value of an arbitrary type, and then convert it manually to a specific type
+ * using #GVariant methods. For most commonly used types, also getters that
+ * return the specific type directly are provided (gum_dictionary_get_string()
+ * and similar).
  *
- * Returns: (transfer none) the value; NULL is returned in case of failure.
+ * Returns: (transfer none): the value; NULL is returned in case of failure (for
+ * example if the entry corresponding to the supplied key doesn't exist).
  */
 GVariant *
-gum_dictionary_get (GumDictionary *dict, const gchar *key)
+gum_dictionary_get (
+        GumDictionary *dict,
+        const gchar *key)
 {
     g_return_val_if_fail (dict != NULL, NULL);
     g_return_val_if_fail (key != NULL, NULL);
@@ -153,18 +200,21 @@ gum_dictionary_get (GumDictionary *dict, const gchar *key)
 
 /**
  * gum_dictionary_set:
- * @dict: instance of #GumDictionary
- *
- * @key: key to be set
- * @value: value to be set
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key to be set
+ * @value: (transfer full): value to be set
  *
- * Adds or replaces key-value pair in the dictionary.
+ * Adds or replaces key-value pair in the dictionary. This allows to set a value
+ * of an arbitrary type: it first needs to be converted to a #GVariant. For most
+ * commonly used types also type-specific setters are provided.
  *
  * Returns: TRUE if successful, FALSE otherwise.
  */
 gboolean
-gum_dictionary_set (GumDictionary *dict,
-    const gchar *key, GVariant *value)
+gum_dictionary_set (
+        GumDictionary *dict,
+        const gchar *key,
+        GVariant *value)
 {
     g_return_val_if_fail (dict != NULL, FALSE);
     g_return_val_if_fail (key != NULL, FALSE);
@@ -181,12 +231,19 @@ gum_dictionary_set (GumDictionary *dict,
 
 /**
  * gum_dictionary_get_boolean:
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key to look up
+ * @value: (transfer none): points to the location where the value should be set
  *
- * Overload, see #gum_dictionary_get for details.
+ * Retrieves a gboolean value.
+ *
+ * Returns: TRUE if the value was retrieved successfully, FALSE otherwise.
  */
 gboolean
-gum_dictionary_get_boolean (GumDictionary *dict, const gchar *key,
-                                 gboolean *value)
+gum_dictionary_get_boolean (
+        GumDictionary *dict,
+        const gchar *key,
+        gboolean *value)
 {
     GVariant *variant = gum_dictionary_get (dict, key);
 
@@ -199,25 +256,39 @@ gum_dictionary_get_boolean (GumDictionary *dict, const gchar *key,
 }
 
 /**
- * gsignon_dictionary_set_boolean:
+ * gum_dictionary_set_boolean:
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key to set
+ * @value: value to set
+ *
+ * Sets or replaces a gboolean value in the dictionary.
  *
- * Overload, see #gum_dictionary_set for details.
+ * Returns: TRUE if the value was set or replaced successfully, FALSE otherwise.
  */
 gboolean
-gum_dictionary_set_boolean (GumDictionary *dict, const gchar *key,
-                                 gboolean value)
+gum_dictionary_set_boolean (
+        GumDictionary *dict,
+        const gchar *key,
+        gboolean value)
 {
     return gum_dictionary_set (dict, key, g_variant_new_boolean (value));
 }
 
 /**
  * gum_dictionary_get_int32:
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key to look up
+ * @value: (transfer none): points to the location where the value should be set
+ *
+ * Retrieves a int32 value.
  *
- * Overload, see #gum_dictionary_get for details.
+ * Returns: TRUE if the value was retrieved successfully, FALSE otherwise.
  */
 gboolean
-gum_dictionary_get_int32 (GumDictionary *dict, const gchar *key,
-                               gint32 *value)
+gum_dictionary_get_int32 (
+        GumDictionary *dict,
+        const gchar *key,
+        gint32 *value)
 {
     GVariant *variant = gum_dictionary_get (dict, key);
 
@@ -230,25 +301,39 @@ gum_dictionary_get_int32 (GumDictionary *dict, const gchar *key,
 }
 
 /**
- * gsignon_dictionary_set_int32:
+ * gum_dictionary_set_int32:
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key to set
+ * @value: value to set
  *
- * Overload, see #gum_dictionary_set for details.
+ * Sets or replaces a int32 value in the dictionary.
+ *
+ * Returns: TRUE if the value was set or replaced successfully, FALSE otherwise.
  */
 gboolean
-gum_dictionary_set_int32 (GumDictionary *dict, const gchar *key,
-                               gint32 value)
+gum_dictionary_set_int32 (
+        GumDictionary *dict,
+        const gchar *key,
+        gint32 value)
 {
     return gum_dictionary_set (dict, key, g_variant_new_int32 (value));
 }
 
 /**
- * gum_dictionary_get_guint32:
+ * gum_dictionary_get_uint32:
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key to look up
+ * @value: (transfer none): points to the location where the value should be set
+ *
+ * Retrieves a uint32 value.
  *
- * Overload, see #gum_dictionary_get for details.
+ * Returns: TRUE if the value was retrieved successfully, FALSE otherwise.
  */
 gboolean
-gum_dictionary_get_uint32 (GumDictionary *dict, const gchar *key,
-                                guint32 *value)
+gum_dictionary_get_uint32 (
+        GumDictionary *dict,
+        const gchar *key,
+        guint32 *value)
 {
     GVariant *variant = gum_dictionary_get (dict, key);
 
@@ -261,25 +346,39 @@ gum_dictionary_get_uint32 (GumDictionary *dict, const gchar *key,
 }
 
 /**
- * gsignon_dictionary_set_guint32:
+ * gum_dictionary_set_uint32:
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key to set
+ * @value: value to set
+ *
+ * Sets or replaces a uint32 value in the dictionary.
  *
- * Overload, see #gum_dictionary_set for details.
+ * Returns: TRUE if the value was set or replaced successfully, FALSE otherwise.
  */
 gboolean
-gum_dictionary_set_uint32 (GumDictionary *dict, const gchar *key,
-                                guint32 value)
+gum_dictionary_set_uint32 (
+        GumDictionary *dict,
+        const gchar *key,
+        guint32 value)
 {
     return gum_dictionary_set (dict, key, g_variant_new_uint32 (value));
 }
 
 /**
  * gum_dictionary_get_int64:
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key to look up
+ * @value: (transfer none): points to the location where the value should be set
  *
- * Overload, see #gum_dictionary_get for details.
+ * Retrieves a int64 value.
+ *
+ * Returns: TRUE if the value was retrieved successfully, FALSE otherwise.
  */
 gboolean
-gum_dictionary_get_int64 (GumDictionary *dict, const gchar *key,
-                               gint64 *value)
+gum_dictionary_get_int64 (
+        GumDictionary *dict,
+        const gchar *key,
+        gint64 *value)
 {
     GVariant *variant = gum_dictionary_get (dict, key);
 
@@ -292,25 +391,39 @@ gum_dictionary_get_int64 (GumDictionary *dict, const gchar *key,
 }
 
 /**
- * gsignon_dictionary_set_int32:
+ * gum_dictionary_set_int64:
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key to set
+ * @value: value to set
+ *
+ * Sets or replaces a int64 value in the dictionary.
  *
- * Overload, see #gum_dictionary_set for details.
+ * Returns: TRUE if the value was set or replaced successfully, FALSE otherwise.
  */
 gboolean
-gum_dictionary_set_int64 (GumDictionary *dict, const gchar *key,
-                               gint64 value)
+gum_dictionary_set_int64 (
+        GumDictionary *dict,
+        const gchar *key,
+        gint64 value)
 {
     return gum_dictionary_set (dict, key, g_variant_new_int64 (value));
 }
 
 /**
- * gum_dictionary_get_guint32:
+ * gum_dictionary_get_uint64:
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key to look up
+ * @value: (transfer none): points to the location where the value should be set
+ *
+ * Retrieves a uint64 value.
  *
- * Overload, see #gum_dictionary_get for details.
+ * Returns: TRUE if the value was retrieved successfully, FALSE otherwise.
  */
 gboolean
-gum_dictionary_get_uint64 (GumDictionary *dict, const gchar *key,
-                                guint64 *value)
+gum_dictionary_get_uint64 (
+        GumDictionary *dict,
+        const gchar *key,
+        guint64 *value)
 {
     GVariant *variant = gum_dictionary_get (dict, key);
 
@@ -323,25 +436,38 @@ gum_dictionary_get_uint64 (GumDictionary *dict, const gchar *key,
 }
 
 /**
- * gsignon_dictionary_set_guint32:
+ * gum_dictionary_set_uint64:
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key to set
+ * @value: value to set
  *
- * Overload, see #gum_dictionary_set for details.
+ * Sets or replaces a uint64 value in the dictionary.
+ *
+ * Returns: TRUE if the value was set or replaced successfully, FALSE otherwise.
  */
 gboolean
-gum_dictionary_set_uint64 (GumDictionary *dict, const gchar *key,
-                                guint64 value)
+gum_dictionary_set_uint64 (
+        GumDictionary *dict,
+        const gchar *key,
+        guint64 value)
 {
     return gum_dictionary_set (dict, key, g_variant_new_uint64 (value));
 }
 
-
 /**
  * gum_dictionary_get_string:
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key to look up
+ *
+ * Retrieves a string value.
  *
- * Overload, see #gum_dictionary_get for details.
+ * Returns: (transfer none): the value if it was retrieved successfully, NULL
+ * otherwise.
  */
 const gchar *
-gum_dictionary_get_string (GumDictionary *dict, const gchar *key)
+gum_dictionary_get_string (
+        GumDictionary *dict,
+        const gchar *key)
 {
     GVariant *variant = gum_dictionary_get (dict, key);
 
@@ -352,30 +478,37 @@ gum_dictionary_get_string (GumDictionary *dict, const gchar *key)
 }
 
 /**
- * gsignon_dictionary_set_string:
+ * gum_dictionary_set_string:
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key to set
+ * @value: (transfer none): value to set
  *
- * Overload, see #gum_dictionary_set for details.
+ * Sets or replaces a string value in the dictionary.
+ *
+ * Returns: TRUE if the value was set or replaced successfully, FALSE otherwise.
  */
 gboolean
-gum_dictionary_set_string (GumDictionary *dict, const gchar *key,
-                                const gchar *value)
+gum_dictionary_set_string (
+        GumDictionary *dict,
+        const gchar *key,
+        const gchar *value)
 {
     return gum_dictionary_set (dict, key, g_variant_new_string (value));
 }
 
 /**
  * gum_dictionary_remove:
- * @dict: instance of #GumDictionary
- *
- * @key: key which needs to be removed from the dictionary
- * @value: value to be set
+ * @dict: (transfer none): instance of #GumDictionary
+ * @key: (transfer none): key which needs to be removed from the dictionary
  *
  * Removes key-value pair in the dictionary as per key.
  *
  * Returns: TRUE if successful, FALSE otherwise.
  */
 gboolean
-gum_dictionary_remove (GumDictionary *dict, const gchar *key)
+gum_dictionary_remove (
+        GumDictionary *dict,
+        const gchar *key)
 {
     g_return_val_if_fail (dict != NULL, FALSE);
     g_return_val_if_fail (key != NULL, FALSE);
@@ -387,15 +520,16 @@ gum_dictionary_remove (GumDictionary *dict, const gchar *key)
 
 /**
  * gum_dictionary_copy:
- * @other: instance of #GumDictionary
+ * @other: (transfer none): instance of #GumDictionary
  *
  * Creates a copy of the dictionary.
  *
- * Returns: (transfer full) #GumDictionary object if successful,
+ * Returns: (transfer full): #GumDictionary object if the copy was successful,
  * NULL otherwise.
  */
 GumDictionary *
-gum_dictionary_copy (GumDictionary *other)
+gum_dictionary_copy (
+        GumDictionary *other)
 {
     GumDictionary *dict = NULL;
     GHashTableIter iter;
@@ -413,7 +547,6 @@ gum_dictionary_copy (GumDictionary *other)
     {
         gum_dictionary_set (dict, key, value);
     }
-    
 
     return dict;
 }
index e965cf7..31669f5 100644 (file)
 
 #include "common/gum-error.h"
 
+/**
+ * SECTION:gum-error
+ * @short_description: error definitions and utilities
+ * @title: Errors
+ * @include: gum/common/gum-error.h
+ *
+ * This file provides Gum error definitions and utilities.
+ * When creating an error, use #GUM_ERROR for the error domain and errors
+ * from #GumError for the error code.
+ *
+ * |[
+ *     GError* err = g_error_new(GUM_ERROR, GUM_ERROR_USER_ALREADY_EXISTS,
+ *     "User already exists");
+ * ]|
+ */
+
+/**
+ * GUM_ERROR:
+ *
+ * This macro should be used when creating a #GError (for example with
+ * g_error_new()).
+ */
+
+/**
+ * GumError:
+ * @GUM_ERROR_NONE: No error
+ * @GUM_ERROR_UNKNOWN: Catch-all for errors not distinguished by another error
+ * code
+ * @GUM_ERROR_INTERNAL_SERVER: Server internal error
+ * @GUM_ERROR_PERMISSION_DENIED: The operation cannot be performed due to
+ * insufficient client permissions
+ * @GUM_ERROR_USER_ALREADY_EXISTS: User already exists
+ * @GUM_ERROR_USER_GROUP_ADD_FAILURE: Adding/creating groups for the user
+ * failure
+ * @GUM_ERROR_USER_UID_NOT_AVAILABLE: UID not available in the defined range
+ * @GUM_ERROR_USER_INVALID_USER_TYPE: Usertype is not set
+ * @GUM_ERROR_USER_SECRET_ENCRYPT_FAILURE: Encryption of secret failure
+ * @GUM_ERROR_USER_NOT_FOUND: User not found
+ * @GUM_ERROR_USER_INVALID_DATA: Invalid data provided in the request
+ * @GUM_ERROR_USER_GROUP_DELETE_FAILURE: Deleting group for the user failure
+ * @GUM_ERROR_USER_SELF_DESTRUCTION: Self-destruction is not allowed
+ * @GUM_ERROR_USER_SESSION_TERM_FAILURE: Session termination of a user failure
+ * @GUM_ERROR_USER_NO_CHANGES: No changes specified in the user update request
+ * @GUM_ERROR_USER_LOCK_FAILURE: Unable to lock the user account before doing
+ * any changes
+ * @GUM_ERROR_GROUP_ALREADY_EXISTS: Group already exists
+ * @GUM_ERROR_GROUP_GID_NOT_AVAILABLE: GID mot available in the defined range
+ * @GUM_ERROR_GROUP_INVALID_GROUP_TYPE: Group type not set
+ * @GUM_ERROR_GROUP_SECRET_ENCRYPT_FAILURE: Encryption of group secret failure
+ * @GUM_ERROR_GROUP_NOT_FOUND: Group not found
+ * @GUM_ERROR_GROUP_USER_ALREADY_A_MEMBER: User is already a member of the group
+ * @GUM_ERROR_GROUP_INVALID_DATA: Invalid data is specified in the request
+ * @GUM_ERROR_GROUP_SELF_DESTRUCTION: Self-destruction is not allowed
+ * @GUM_ERROR_GROUP_HAS_USER: Group has (other) user(s)
+ * @GUM_ERROR_GROUP_NO_CHANGES: No changes specified in the group update request
+ * @GUM_ERROR_DB_ALREADY_LOCKED: Database is already locked
+ * @GUM_ERROR_FILE_OPEN: File open error
+ * @GUM_ERROR_FILE_ATTRIBUTE: File attribute error
+ * @GUM_ERROR_FILE_MOVE: File move error
+ * @GUM_ERROR_FILE_WRITE: File write error
+ * @GUM_ERROR_HOME_DIR_CREATE_FAILURE: Directory create failure
+ * @GUM_ERROR_HOME_DIR_DELETE_FAILURE: Directory delete failure
+ * @GUM_ERROR_HOME_DIR_COPY_FAILURE: Directory copy failure
+ * @GUM_ERROR_INVALID_NAME: Invalid name specified
+ * @GUM_ERROR_INVALID_NICKNAME: Invalid nickname specified
+ * @GUM_ERROR_INVALID_SECRET: Invalid secret specified
+ * @GUM_ERROR_INVALID_STR: Invalid string specified
+ * @GUM_ERROR_INVALID_STR_LEN: Invalid string length
+ * @GUM_ERROR_INVALID_INPUT: Invalid input specified
+ * @GUM_ERROR_USER_ERR: Placeholder to rearrange enumeration - User space
+ * specific
+ *
+ * This enum provides a list of errors
+ */
+
+/**
+ * GUM_ERROR_DOMAIN:
+ *
+ * This macro defines the error domain for gum.
+ */
+#define GUM_ERROR_DOMAIN "gum"
+
+/**
+ * GUM_GET_ERROR_FOR_ID:
+ * @code: A #GumError specifying the error
+ * @message: Format string for the error message
+ * @...: parameters for the error string
+ *
+ * A helper macro that creates a #GError with the proper gum domain
+ */
+
+/**
+ * GUM_SET_ERROR:
+ * @code: the error code as listed in #GumError
+ * @err_str: the error message to be set for the #GError
+ * @err: a #GError
+ * @retvar: return variable to hold the return value
+ * @retval: return value to be set to the return variable
+ *
+ * A helper macro that creates a #GError with the proper gum domain, output
+ * the error message to logs, and sets the specified retval to retvar.
+ */
+
+/**
+ * GUM_RETURN_WITH_ERROR:
+ * @code: the error code as listed in #GumError
+ * @err_str: the error message to be set for the #GError
+ * @err: a #GError
+ * @retval: value to be used on return
+ *
+ * A helper macro that creates a #GError with the proper gum domain, output
+ * the error message to logs, and returns with specified retval.
+ */
+
 #define _ERROR_PREFIX "org.tizen.SecurityAccounts.gUserManagement.Error"
 
 GDBusErrorEntry _gum_errors[] =
 {
     {GUM_ERROR_UNKNOWN, _ERROR_PREFIX".Unknown"},
     {GUM_ERROR_INTERNAL_SERVER, _ERROR_PREFIX".InternalServerError"},
-    {GUM_ERROR_INTERNAL_COMMUNICATION,
-            _ERROR_PREFIX".InternalCommunicationError"},
     {GUM_ERROR_PERMISSION_DENIED, _ERROR_PREFIX".PermissionDenied"},
 
     {GUM_ERROR_USER_ALREADY_EXISTS, _ERROR_PREFIX".UserAlreadyExists"},
@@ -51,7 +163,6 @@ GDBusErrorEntry _gum_errors[] =
     {GUM_ERROR_USER_SELF_DESTRUCTION, _ERROR_PREFIX".UserSelfDestruction"},
     {GUM_ERROR_USER_SESSION_TERM_FAILURE,
             _ERROR_PREFIX".UserSessionTermFailure"},
-
     {GUM_ERROR_USER_NO_CHANGES, _ERROR_PREFIX".UserNoChanges"},
     {GUM_ERROR_USER_LOCK_FAILURE, _ERROR_PREFIX".UserLockFailure"},
 
@@ -88,6 +199,13 @@ GDBusErrorEntry _gum_errors[] =
     {GUM_ERROR_INVALID_INPUT, _ERROR_PREFIX".InvalidInput"},
 } ;
 
+ /**
+  * gum_error_quark:
+  *
+  * Creates and returns a domain for Gum errors.
+  *
+  * Returns: #GQuark for Gum errors
+  */
 GQuark
 gum_error_quark (void)
 {
@@ -101,38 +219,13 @@ gum_error_quark (void)
     return (GQuark) quark_volatile;
 }
 
-GString*
-gum_concat_domain_and_error (
-        const gchar *str1,
-        const gchar *str2)
-{
-    GString *str = NULL;
-    g_return_val_if_fail (str1 != NULL && str2 != NULL, NULL);
-    str = g_string_sized_new (strlen(str1)+strlen(str2)-1);
-    g_string_printf (str,"[%s].%s\n",str1,str2);
-    return str;
-}
-
-GString*
-gum_prepend_domain_to_error_msg (const GError *err)
-{
-    GString *msg = NULL;
-    const gchar *domain = NULL;
-    g_return_val_if_fail (err != NULL, NULL);
-    if (err->message != NULL) {
-        domain = g_quark_to_string(err->domain);
-        msg = gum_concat_domain_and_error(domain, err->message);
-    }
-    return msg;
-}
-
 /**
  * gum_error_new_from_variant:
- * @var: instance of #GVariant
+ * @var: (transfer none): instance of #GVariant
  *
  * Converts the GVariant to GError.
  *
- * Returns: (transfer full) #GError object if successful, NULL otherwise.
+ * Returns: (transfer full): #GError object if successful, NULL otherwise.
  */
 GError *
 gum_error_new_from_variant (
@@ -155,7 +248,7 @@ gum_error_new_from_variant (
 
 /**
  * gum_error_to_variant:
- * @error: instance of #GError
+ * @error: (transfer none): instance of #GError
  *
  * Converts the GError to GVariant.
  *
index e999ecc..3912709 100644 (file)
@@ -118,13 +118,13 @@ gum_file_open_db_files (
 {
     if (!origfn || !origf || !(*origf = _open_file (origfn, "r"))) {
         DBG("origfn %s --- orig %p", origfn ? origfn : "NULL", origf);
-        RETURN_WITH_ERROR (GUM_ERROR_FILE_OPEN, "Unable to open orig file",
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_OPEN, "Unable to open orig file",
                 error, FALSE);
     }
 
     if (!newfn || !newf || !(*newf = _open_file (newfn, "w+"))) {
         if (*origf) fclose (*origf);
-        RETURN_WITH_ERROR (GUM_ERROR_FILE_OPEN, "Unable to open new file",
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_OPEN, "Unable to open new file",
                 error, FALSE);
     }
 
@@ -132,7 +132,7 @@ gum_file_open_db_files (
         if (*origf) fclose (*origf);
         if (*newf) fclose (*newf);
         g_unlink (newfn);
-        RETURN_WITH_ERROR (GUM_ERROR_FILE_ATTRIBUTE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_ATTRIBUTE,
                 "Unable to get/set file attributes", error, FALSE);
     }
 
@@ -155,7 +155,7 @@ gum_file_close_db_files (
         fflush (newf) != 0 ||
         fsync (fileno (newf)) != 0 ||
         fclose (newf) != 0) {
-        SET_ERROR (GUM_ERROR_FILE_WRITE, "File write failure", error, retval,
+        GUM_SET_ERROR (GUM_ERROR_FILE_WRITE, "File write failure", error, retval,
                 FALSE);
         goto _close_new;
     }
@@ -164,7 +164,7 @@ gum_file_close_db_files (
     /* Move original file to old file and new file as updated file */
     old_file = g_strdup_printf ("%s.old", origfn);
     if (!old_file) {
-        SET_ERROR (GUM_ERROR_FILE_MOVE, "Unable to create old file", error,
+        GUM_SET_ERROR (GUM_ERROR_FILE_MOVE, "Unable to create old file", error,
                 retval, FALSE);
         goto _close_new;
     }
@@ -172,7 +172,7 @@ gum_file_close_db_files (
     g_unlink (old_file);
     if (link (origfn, old_file) != 0 ||
         g_rename (newfn, origfn) != 0) {
-        SET_ERROR (GUM_ERROR_FILE_MOVE, "Unable to move file", error, retval,
+        GUM_SET_ERROR (GUM_ERROR_FILE_MOVE, "Unable to move file", error, retval,
                 FALSE);
     }
 
@@ -213,7 +213,7 @@ gum_file_update (
 
     /* Update, sync and close file */
     if (!update_func) {
-        SET_ERROR (GUM_ERROR_FILE_WRITE, "File write function not specified",
+        GUM_SET_ERROR (GUM_ERROR_FILE_WRITE, "File write function not specified",
                 error, retval, FALSE);
         goto _close;
     }
@@ -464,14 +464,14 @@ _copy_dir_recursively (
     struct stat stat_entry;
 
     if (!src || !dest) {
-        RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_COPY_FAILURE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_COPY_FAILURE,
                 "Invalid directory path(s)", error, FALSE);
     }
 
     DBG ("copy directory %s -> %s", src, dest);
     src_dir = g_dir_open (src, 0, NULL);
     if (!src_dir) {
-        RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_COPY_FAILURE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_COPY_FAILURE,
                 "Invalid source directory path", error, FALSE);
     }
 
@@ -516,7 +516,7 @@ _free_data:
         GUM_OBJECT_UNREF (src_file);
         GUM_OBJECT_UNREF (dest_file);
         if (stop) {
-            SET_ERROR (GUM_ERROR_HOME_DIR_COPY_FAILURE,
+            GUM_SET_ERROR (GUM_ERROR_HOME_DIR_COPY_FAILURE,
                     "Home directory copy failure", error, retval, FALSE);
             break;
         }
@@ -539,7 +539,7 @@ gum_file_create_home_dir (
                        GUM_CONFIG_GENERAL_UMASK, GUM_UMASK);
 
     if (!usr_home_dir) {
-        RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_CREATE_FAILURE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_CREATE_FAILURE,
                 "Invalid home directory path", error, FALSE);
     }
 
@@ -550,14 +550,14 @@ gum_file_create_home_dir (
         }
 
         if (!g_file_test (usr_home_dir, G_FILE_TEST_IS_DIR)) {
-            RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_CREATE_FAILURE,
+            GUM_RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_CREATE_FAILURE,
                     "Home directory creation failure", error, FALSE);
         }
 
         /* when run in test mode, user may not exist */
 #ifndef ENABLE_TESTS
                if (chown (usr_home_dir, uid, gid) < 0) {
-                       RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_CREATE_FAILURE,
+                       GUM_RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_CREATE_FAILURE,
                                        "Home directory chown failure", error, FALSE);
                }
 #endif
@@ -579,7 +579,7 @@ gum_file_delete_home_dir (
     struct stat sent;
 
     if (!dir || !(gdir = g_dir_open(dir, 0, NULL))) {
-        RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_DELETE_FAILURE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_DELETE_FAILURE,
                 "Invalid home directory path", error, FALSE);
     }
 
@@ -607,14 +607,14 @@ gum_file_delete_home_dir (
         }
         if (retval != 0) {
             g_dir_close (gdir);
-            RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_DELETE_FAILURE,
+            GUM_RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_DELETE_FAILURE,
                 "Unable to delete files in the directory", error, FALSE);
         }
     }
     g_dir_close (gdir);
 
     if (g_remove (dir) != 0) {
-        RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_DELETE_FAILURE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_DELETE_FAILURE,
                 "Unable to delete home directory", error, FALSE);
     }
 
index 3508f41..9893ced 100644 (file)
@@ -41,27 +41,27 @@ gum_validate_name (
     int rval;
     regex_t re;
     if (!name) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_NAME,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_NAME,
                 "Invalid name. len must be > 0 and less than UT_NAMESIZE",
                 error, FALSE);
     }
 
     len = strlen (name);
     if (len == 0 || len > UT_NAMESIZE) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_NAME,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_NAME,
                 "Invalid name len. len must be > 0 and less than UT_NAMESIZE",
                 error, FALSE);
     }
 
     memset (&re, 0, sizeof (regex_t));
     if (regcomp (&re, (const char*)GUM_NAME_PATTERN, 0) != 0) {
-        RETURN_WITH_ERROR (GUM_ERROR_INTERNAL_SERVER, "Internal server error",
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INTERNAL_SERVER, "Internal server error",
                 error, FALSE);
     }
     rval = regexec (&re, name, 0, NULL, 0);
     regfree (&re);
     if (rval != 0) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_NAME,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_NAME,
                 "Name failed pattern match for "
                 GUM_NAME_PATTERN, error, FALSE);
     }
@@ -77,7 +77,7 @@ gum_validate_generate_username (
     GChecksum *hid = NULL;
     gsize len = 0;
     if (!str || (len = strlen (str)) == 0) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_NAME,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_NAME,
                 "Unable to generate name for 0 len str", error, NULL);
     }
 
@@ -106,19 +106,19 @@ gum_validate_db_string_entry_regx (
     int rval;
     regex_t re;
     if (!str) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_STR, "Invalid input str.", error,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_STR, "Invalid input str.", error,
                 FALSE);
     }
 
     memset (&re, 0, sizeof (regex_t));
     if (regcomp (&re, (const char*)GUM_DB_ENTRY_PATTERN, REG_EXTENDED) != 0) {
-        RETURN_WITH_ERROR (GUM_ERROR_INTERNAL_SERVER, "Internal server error",
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INTERNAL_SERVER, "Internal server error",
                 error, FALSE);
     }
     rval = regexec (&re, str, 0, NULL, 0);
     regfree (&re);
     if (rval != 0) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_STR,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_STR,
                 "No control characters or ':' or ',' is allowed."
                 "String failed pattern match for "GUM_DB_ENTRY_PATTERN, error,
                 FALSE);
@@ -142,12 +142,12 @@ gum_validate_db_string_entry (
     };
 
     if (!str) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_STR, "Invalid input str.",
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_STR, "Invalid input str.",
                 error, FALSE);
     }
 
     if (strlen (str) > 0 && strpbrk (str, invalid) != NULL) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_STR,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_STR,
                 "No control characters or ':' or ',' is allowed", error, FALSE);
     }
     return TRUE;
@@ -168,12 +168,12 @@ gum_validate_db_secret_entry (
     };
 
     if (!str) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_SECRET, "Invalid input str.",
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_SECRET, "Invalid input str.",
                 error, FALSE);
     }
 
     if (strpbrk (str, invalid) != NULL) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_SECRET,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_SECRET,
                 "No control characters or ':' is allowed", error, FALSE);
     }
     return TRUE;
index c0bb6c1..6312434 100644 (file)
@@ -576,7 +576,7 @@ _handle_get_group (
                 invocation, gumd_dbus_group_adapter_get_object_path (dbus_group));
     } else {
         if (!error) {
-            error = gum_get_gerror_for_id (GUM_ERROR_GROUP_NOT_FOUND,
+            error = GUM_GET_ERROR_FOR_ID (GUM_ERROR_GROUP_NOT_FOUND,
                     "Group Not Found");
         }
         g_dbus_method_invocation_return_gerror (invocation, error);
@@ -619,7 +619,7 @@ _handle_get_group_by_name (
                        gumd_dbus_group_adapter_get_object_path (dbus_group));
     } else {
         if (!error) {
-            error = gum_get_gerror_for_id (GUM_ERROR_GROUP_NOT_FOUND,
+            error = GUM_GET_ERROR_FOR_ID (GUM_ERROR_GROUP_NOT_FOUND,
                     "Group Not Found");
         }
         g_dbus_method_invocation_return_gerror (invocation, error);
index 4dc3728..a911a62 100644 (file)
@@ -576,7 +576,7 @@ _handle_get_user (
                 invocation, gumd_dbus_user_adapter_get_object_path (dbus_user));
     } else {
         if (!error) {
-            error = gum_get_gerror_for_id (GUM_ERROR_USER_NOT_FOUND,
+            error = GUM_GET_ERROR_FOR_ID (GUM_ERROR_USER_NOT_FOUND,
                     "User Not Found");
         }
         g_dbus_method_invocation_return_gerror (invocation, error);
@@ -619,7 +619,7 @@ _handle_get_user_by_name (
                        gumd_dbus_user_adapter_get_object_path (dbus_user));
     } else {
         if (!error) {
-            error = gum_get_gerror_for_id (GUM_ERROR_USER_NOT_FOUND,
+            error = GUM_GET_ERROR_FOR_ID (GUM_ERROR_USER_NOT_FOUND,
                     "User Not Found");
         }
         g_dbus_method_invocation_return_gerror (invocation, error);
index 2ac7d7e..55b54cf 100644 (file)
@@ -415,12 +415,12 @@ _set_gid (
 
     if (gum_file_getgrnam (self->priv->group->gr_name, self->priv->config)
             != NULL) {
-        RETURN_WITH_ERROR (GUM_ERROR_GROUP_ALREADY_EXISTS,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_ALREADY_EXISTS,
                 "Group already exists", error, FALSE);
     }
 
     if (!_find_free_gid (self, preferred_gid, &gid)){
-        RETURN_WITH_ERROR (GUM_ERROR_GROUP_GID_NOT_AVAILABLE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_GID_NOT_AVAILABLE,
                 "GID not available", error, FALSE);
     }
     _set_gid_property (self, gid);
@@ -446,7 +446,7 @@ _update_daemon_group_entry (
             case GUM_OPTYPE_ADD:
                 if (self->priv->group->gr_gid < entry->gr_gid) {
                     if (putgrent (self->priv->group, newf) < 0) {
-                        RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
+                        GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
                                 "File write failure", error, FALSE);
                     }
                     done = TRUE;
@@ -466,7 +466,7 @@ _update_daemon_group_entry (
                 if (self->priv->group->gr_gid == entry->gr_gid &&
                     g_strcmp0 (old_name, entry->gr_name) == 0) {
                     if (putgrent (self->priv->group, newf) < 0) {
-                        RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
+                        GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
                                 "File write failure", error, FALSE);
                     }
                     done = TRUE;
@@ -479,7 +479,7 @@ _update_daemon_group_entry (
             }
         }
         if (putgrent (entry, newf) < 0) {
-            RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
+            GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
                     error, FALSE);
         }
     }
@@ -487,14 +487,14 @@ _update_daemon_group_entry (
     /* Write entry to file in case it is first entry in the file */
     if (!done && op == GUM_OPTYPE_ADD) {
         if (putgrent (self->priv->group, newf) < 0) {
-            RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
+            GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
                     error, FALSE);
         }
         done = TRUE;
     }
 
     if (!done) {
-        RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure", error,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure", error,
                 FALSE);
     }
 
@@ -519,7 +519,7 @@ _update_gshadow_entry (
             case GUM_OPTYPE_ADD:
                 if (g_strcmp0 (self->priv->gshadow->sg_namp,
                         entry->sg_namp) == 0) {
-                    RETURN_WITH_ERROR (GUM_ERROR_GROUP_ALREADY_EXISTS,
+                    GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_ALREADY_EXISTS,
                             "File write failure", error, FALSE);
                 }
                 break;
@@ -535,7 +535,7 @@ _update_gshadow_entry (
                         self->priv->gshadow->sg_namp;
                 if (g_strcmp0 (old_name, entry->sg_namp) == 0) {
                     if (putsgent (self->priv->gshadow, newf) < 0) {
-                        RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
+                        GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
                                 "File write failure", error, FALSE);
                     }
                     done = TRUE;
@@ -548,7 +548,7 @@ _update_gshadow_entry (
             }
         }
         if (putsgent (entry, newf) < 0) {
-            RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
+            GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
                     error, FALSE);
         }
     }
@@ -556,14 +556,14 @@ _update_gshadow_entry (
     /* Write entry to file in case it is first entry in the file */
     if (!done && op == GUM_OPTYPE_ADD) {
         if (putsgent (self->priv->gshadow, newf) < 0) {
-            RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
+            GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
                     error, FALSE);
         }
         done = TRUE;
     }
 
     if (!done) {
-        RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure", error,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure", error,
                 FALSE);
     }
 
@@ -592,7 +592,7 @@ _set_secret (
     self->priv->gshadow->sg_passwd = gum_crypt_encrypt_secret (
             self->priv->group->gr_passwd, GUM_CRYPT_SHA512);
     if (!self->priv->gshadow->sg_passwd) {
-        RETURN_WITH_ERROR (GUM_ERROR_GROUP_SECRET_ENCRYPT_FAILURE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_SECRET_ENCRYPT_FAILURE,
                 "Secret encryption failed.", error, FALSE);
     }
 
@@ -629,7 +629,7 @@ _check_group_type (
             break;
         case GUM_GROUPTYPE_NONE:
         default:
-            RETURN_WITH_ERROR (GUM_ERROR_GROUP_INVALID_GROUP_TYPE,
+            GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_INVALID_GROUP_TYPE,
                     "Invalid group type", error, FALSE);
             break;
     }
@@ -664,7 +664,7 @@ _get_group (
     if (!grp ||
         (s_gid != G_MAXUINT && s_gid != grp->gr_gid) ||
         (s_name && g_strcmp0 (s_name, grp->gr_name) != 0)) {
-        RETURN_WITH_ERROR (GUM_ERROR_GROUP_NOT_FOUND, "Group not found",
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_NOT_FOUND, "Group not found",
                 error, FALSE);
     }
 
@@ -826,7 +826,7 @@ gumd_daemon_group_add (
     }
 
     if (!gum_lock_pwdf_lock ()) {
-       RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
+       GUM_RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
                "Database already locked", error, FALSE);
     }
 
@@ -871,13 +871,13 @@ gumd_daemon_group_delete (
     const gchar *shadow_file = NULL;
 
     if (!gum_lock_pwdf_lock ()) {
-       RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
+       GUM_RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
                "Database already locked", error, FALSE);
     }
 
     if (self->priv->group->gr_gid == GUM_GROUP_INVALID_GID) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_GROUP_NOT_FOUND, "Group gid invalid",
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_NOT_FOUND, "Group gid invalid",
                 error, FALSE);
     }
 
@@ -888,7 +888,7 @@ gumd_daemon_group_delete (
 
     if (self->priv->group->gr_gid == getegid ()) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_GROUP_SELF_DESTRUCTION,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_SELF_DESTRUCTION,
                        "Self-destruction not possible", error, FALSE);
     }
 
@@ -899,7 +899,7 @@ gumd_daemon_group_delete (
     if (gum_file_find_user_by_gid (self->priv->group->gr_gid,
             self->priv->config) != NULL) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_GROUP_HAS_USER,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_HAS_USER,
                 "Group is a primary group of an existing user", error, FALSE);
     }
 
@@ -939,13 +939,13 @@ gumd_daemon_group_update (
 
     /* Only secret can be updated */
     if (!gum_lock_pwdf_lock ()) {
-        RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
                 "Database already locked", error, FALSE);
     }
 
     if (self->priv->group->gr_gid == GUM_GROUP_INVALID_GID) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_GROUP_NOT_FOUND, "Group gid invalid",
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_NOT_FOUND, "Group gid invalid",
                 error, FALSE);
     }
 
@@ -961,7 +961,7 @@ gumd_daemon_group_update (
         (gshadow && gum_crypt_cmp_secret (self->priv->group->gr_passwd,
                 gshadow->sg_passwd) == 0)) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_GROUP_NO_CHANGES,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_NO_CHANGES,
                 "No changes registered", error, FALSE);
     }
 
@@ -1021,13 +1021,13 @@ gumd_daemon_group_add_member (
     DBG ("");
 
     if (!gum_lock_pwdf_lock ()) {
-        RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
                 "Database already locked", error, FALSE);
     }
 
     if ((pent = gum_file_getpwuid (uid, self->priv->config)) == NULL) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found", error,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found", error,
                 FALSE);
     }
 
@@ -1038,7 +1038,7 @@ gumd_daemon_group_add_member (
 
     if (gum_string_utils_search_stringv (grp->gr_mem, pent->pw_name)) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_GROUP_USER_ALREADY_A_MEMBER,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_USER_ALREADY_A_MEMBER,
                 "User already a member of the group", error, FALSE);
     }
 
@@ -1100,13 +1100,13 @@ gumd_daemon_group_delete_member (
     DBG ("");
 
     if (!gum_lock_pwdf_lock ()) {
-        RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
                 "Database already locked", error, FALSE);
     }
 
     if ((pent = gum_file_getpwuid (uid, self->priv->config)) == NULL) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found", error,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found", error,
                 FALSE);
     }
 
@@ -1117,7 +1117,7 @@ gumd_daemon_group_delete_member (
 
     if (!gum_string_utils_search_stringv (grp->gr_mem, pent->pw_name)) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND,
                 "User not a member of the group", error, FALSE);
     }
 
@@ -1177,7 +1177,7 @@ gumd_daemon_group_delete_user_membership (
     const gchar *origfn = NULL;
 
     if (!config || !user_name) {
-        RETURN_WITH_ERROR (GUM_ERROR_GROUP_INVALID_DATA,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_INVALID_DATA,
                 "Invalid input data", error, FALSE);
     }
 
@@ -1186,7 +1186,7 @@ gumd_daemon_group_delete_user_membership (
     }
 
     if (!gum_lock_pwdf_lock ()) {
-        RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
                 "Database already locked", error, FALSE);
     }
 
@@ -1210,13 +1210,13 @@ gumd_daemon_group_delete_user_membership (
             status = putgrent (gdest, newf);
             _free_daemon_group_entry (gdest);
             if (status < 0) {
-                SET_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
+                GUM_SET_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
                         error, retval, FALSE);
                 break;
             }
 
         } else if (putgrent (gent, newf) < 0) {
-            SET_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
+            GUM_SET_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
                     error, retval, FALSE);
             break;
         }
@@ -1266,13 +1266,13 @@ gumd_daemon_group_delete_user_membership (
             status = putsgent (gsdest, newf);
             _free_gshadow_entry (gsdest);
             if (status < 0) {
-                SET_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
+                GUM_SET_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
                         error, retval, FALSE);
                 break;
             }
 
         } else if (putsgent (gsent, newf) < 0) {
-            SET_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
+            GUM_SET_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
                     error, retval, FALSE);
             break;
         }
index fc53145..9398f7d 100644 (file)
@@ -632,7 +632,7 @@ _set_daemon_user_name (
      * */
     gchar *tname = NULL;
     if (!self->priv->pw->pw_name && !self->priv->nick_name) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_NAME,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_NAME,
                 "User name not specified", error, FALSE);
     }
 
@@ -647,7 +647,7 @@ _set_daemon_user_name (
        g_free (tname);
         return TRUE;
     } else if (self->priv->user_type == GUM_USERTYPE_SYSTEM) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_NAME,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_NAME,
                 "System user name must exist with pattern "
                 GUM_NAME_PATTERN, error, FALSE);
     }
@@ -729,12 +729,12 @@ _set_uid (
 
     if (gum_file_getpwnam (self->priv->pw->pw_name, self->priv->config)
             != NULL) {
-        RETURN_WITH_ERROR (GUM_ERROR_USER_ALREADY_EXISTS,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_ALREADY_EXISTS,
                 "User already exists", error, FALSE);
     }
 
     if (!_find_free_uid (self, &uid)){
-        RETURN_WITH_ERROR (GUM_ERROR_USER_UID_NOT_AVAILABLE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_UID_NOT_AVAILABLE,
                 "UID not available", error, FALSE);
     }
     _set_uid_property (self, uid);
@@ -764,7 +764,7 @@ _check_daemon_user_type (
                        break;
                case GUM_USERTYPE_NONE:
                default:
-                       RETURN_WITH_ERROR (GUM_ERROR_USER_INVALID_USER_TYPE,
+                       GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_INVALID_USER_TYPE,
                                        "Invalid user type", error, FALSE);
                        break;
        }
@@ -795,7 +795,7 @@ _set_secret (
     self->priv->shadow->sp_pwdp = gum_crypt_encrypt_secret (
             self->priv->pw->pw_passwd, GUM_CRYPT_SHA512);
     if (!self->priv->shadow->sp_pwdp) {
-        RETURN_WITH_ERROR (GUM_ERROR_USER_SECRET_ENCRYPT_FAILURE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_SECRET_ENCRYPT_FAILURE,
                 "Secret encryption failed.", error, FALSE);
     }
 
@@ -852,7 +852,7 @@ _update_passwd_entry (
             case GUM_OPTYPE_ADD:
                 if (self->priv->pw->pw_uid < entry->pw_uid) {
                        if (putpwent (self->priv->pw, newf) < 0) {
-                               RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
+                               GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
                                                "File write failure", error, FALSE);
                        }
                        done = TRUE;
@@ -873,7 +873,7 @@ _update_passwd_entry (
                        self->priv->pw->pw_gid == entry->pw_gid &&
                     g_strcmp0 (old_name, entry->pw_name) == 0) {
                        if (putpwent (self->priv->pw, newf) < 0) {
-                               RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
+                               GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
                                                "File write failure", error, FALSE);
                        }
                     done = TRUE;
@@ -886,7 +886,7 @@ _update_passwd_entry (
             }
         }
         if (putpwent (entry, newf) < 0) {
-               RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
+               GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
                                error, FALSE);
         }
     }
@@ -894,14 +894,14 @@ _update_passwd_entry (
     /* Write entry to file in case it is first entry in the file */
     if (!done && op == GUM_OPTYPE_ADD) {
        if (putpwent (self->priv->pw, newf) < 0) {
-               RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "Add entry failure",
+               GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "Add entry failure",
                                error, FALSE);
        }
        done = TRUE;
     }
 
     if (!done) {
-       RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "Operation did not complete",
+       GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "Operation did not complete",
                error, FALSE);
     }
 
@@ -945,7 +945,7 @@ _lock_shadow_entry (
     struct spwd *entry = NULL;
 
     if (!user_data) {
-        RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
                 "File write failure", error, FALSE);
     }
 
@@ -969,7 +969,7 @@ _lock_shadow_entry (
                     ret = putspent (spent, newf);
                     _free_shadow_entry (spent);
                     if (ret < 0) {
-                        RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
+                        GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
                                 "File write failure", error, FALSE);
                     }
                     done = TRUE;
@@ -982,13 +982,13 @@ _lock_shadow_entry (
             }
         }
         if (putspent (entry, newf) < 0) {
-            RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
+            GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
                     error, FALSE);
         }
     }
 
     if (!done) {
-        RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "Operation did not complete",
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "Operation did not complete",
                 error, FALSE);
     }
 
@@ -1014,7 +1014,7 @@ _update_shadow_entry (
             case GUM_OPTYPE_ADD:
                 if (g_strcmp0 (self->priv->shadow->sp_namp,
                         entry->sp_namp) == 0) {
-                    RETURN_WITH_ERROR (GUM_ERROR_USER_ALREADY_EXISTS,
+                    GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_ALREADY_EXISTS,
                             "File write failure", error, FALSE);
                 }
                 break;
@@ -1030,7 +1030,7 @@ _update_shadow_entry (
                         self->priv->shadow->sp_namp;
                 if (g_strcmp0 (old_name, entry->sp_namp) == 0) {
                        if (putspent (self->priv->shadow, newf) < 0) {
-                               RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
+                               GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
                                                "File write failure", error, FALSE);
                        }
                     done = TRUE;
@@ -1043,7 +1043,7 @@ _update_shadow_entry (
             }
         }
         if (putspent (entry, newf) < 0) {
-               RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
+               GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "File write failure",
                                error, FALSE);
         }
     }
@@ -1051,14 +1051,14 @@ _update_shadow_entry (
     /* Write entry to file in case it is first entry in the file */
     if (!done && op == GUM_OPTYPE_ADD) {
        if (putspent (self->priv->shadow, newf) < 0) {
-               RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "Add entry failure",
+               GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "Add entry failure",
                                error, FALSE);
        }
        done = TRUE;
     }
 
     if (!done) {
-       RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "Operation did not complete",
+       GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "Operation did not complete",
                error, FALSE);
     }
 
@@ -1076,7 +1076,7 @@ _set_group (
 
     group = gumd_daemon_group_new (self->priv->config);
     if (!group) {
-        RETURN_WITH_ERROR (GUM_ERROR_USER_GROUP_ADD_FAILURE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_GROUP_ADD_FAILURE,
                         "Group add failure", error, FALSE);
     }
 
@@ -1086,7 +1086,7 @@ _set_group (
             "grouptype", grp_type, NULL);
     if (!(added = gumd_daemon_group_add (group, (gid_t)self->priv->pw->pw_uid,
             &gid, error))) {
-        SET_ERROR (GUM_ERROR_USER_GROUP_ADD_FAILURE,
+        GUM_SET_ERROR (GUM_ERROR_USER_GROUP_ADD_FAILURE,
                         "Group add failure", error, added, FALSE);
         goto _finished;
     }
@@ -1123,7 +1123,7 @@ _set_default_groups (
                 g_object_unref (agroup);
                 if (!added) break;
             } else {
-                RETURN_WITH_ERROR (GUM_ERROR_USER_GROUP_ADD_FAILURE,
+                GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_GROUP_ADD_FAILURE,
                                 "Unable to add default groups", error, FALSE);
             }
             ind++;
@@ -1172,7 +1172,7 @@ _delete_group (
 
     group = gumd_daemon_group_new (self->priv->config);
     if (!group) {
-        RETURN_WITH_ERROR (GUM_ERROR_USER_GROUP_DELETE_FAILURE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_GROUP_DELETE_FAILURE,
                         "Group delete failure - unable to create group obj",
                         error, FALSE);
     }
@@ -1180,7 +1180,7 @@ _delete_group (
     g_object_set (G_OBJECT(group), "groupname", self->priv->pw->pw_name,
             "gid", self->priv->pw->pw_gid, NULL);
     if (!(deleted = gumd_daemon_group_delete (group, error))) {
-        SET_ERROR (GUM_ERROR_USER_GROUP_DELETE_FAILURE,
+        GUM_SET_ERROR (GUM_ERROR_USER_GROUP_DELETE_FAILURE,
                         "Group delete failure", error, deleted, FALSE);
         goto _finished;
     }
@@ -1217,7 +1217,7 @@ _get_passwd (
     if (!pwd ||
         (s_uid != GUM_USER_INVALID_UID && s_uid != pwd->pw_uid) ||
         (s_name && g_strcmp0 (s_name, pwd->pw_name) != 0)) {
-        RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found",
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found",
                 error, FALSE);
     }
 
@@ -1273,7 +1273,7 @@ _copy_passwd_data (
     }
     spent = gum_file_getspnam (pent->pw_name, self->priv->config);
     if (!spent) {
-        RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found",
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found",
                 error, FALSE);
     }
 
@@ -1463,7 +1463,7 @@ gumd_daemon_user_add (
     }
 
     if (!gum_lock_pwdf_lock ()) {
-       RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
+       GUM_RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
                        "Database already locked", error, FALSE);
     }
 
@@ -1523,26 +1523,26 @@ gumd_daemon_user_delete (
     gboolean lock = TRUE;
 
     if (!gum_lock_pwdf_lock ()) {
-       RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
+       GUM_RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
                        "Database already locked", error, FALSE);
     }
 
     if (self->priv->pw->pw_uid == GUM_USER_INVALID_UID) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User uid invalid", error,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User uid invalid", error,
                 FALSE);
     }
 
     if (!_copy_passwd_data (self, error)) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found", error,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found", error,
                 FALSE);
     }
 
        /* deny if user is self-destructing */
     if (self->priv->pw->pw_uid == geteuid ()) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_USER_SELF_DESTRUCTION,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_SELF_DESTRUCTION,
                        "Self-destruction not possible", error, FALSE);
     }
 
@@ -1552,7 +1552,7 @@ gumd_daemon_user_delete (
             gum_config_get_string (self->priv->config,
             GUM_CONFIG_GENERAL_SHADOW_FILE), &lock, error)) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_USER_LOCK_FAILURE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_LOCK_FAILURE,
                 "unable to lock user to login", error, FALSE);
     }
 
@@ -1564,7 +1564,7 @@ gumd_daemon_user_delete (
                     gum_config_get_string (self->priv->config,
                     GUM_CONFIG_GENERAL_SHADOW_FILE), &lock, NULL);
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_USER_SESSION_TERM_FAILURE,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_SESSION_TERM_FAILURE,
                 "unable to terminate user active sessions", error, FALSE);
     }
 
@@ -1618,13 +1618,13 @@ gumd_daemon_user_update (
     /* Only secret, realname, office, officephone, homephone and
      * shell can be updated */
     if (!gum_lock_pwdf_lock ()) {
-        RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_DB_ALREADY_LOCKED,
                 "Database already locked", error, FALSE);
     }
 
     if (self->priv->pw->pw_uid == GUM_USER_INVALID_UID) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User uid invalid", error,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User uid invalid", error,
                 FALSE);
     }
 
@@ -1636,7 +1636,7 @@ gumd_daemon_user_update (
     if ((shadow = gum_file_getspnam (pw->pw_name,
             self->priv->config)) == NULL) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND,
                 "User not found in Shadow", error, FALSE);
     }
 
@@ -1679,7 +1679,7 @@ gumd_daemon_user_update (
 
     if (change == 0) {
         gum_lock_pwdf_unlock ();
-        RETURN_WITH_ERROR (GUM_ERROR_USER_NO_CHANGES,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NO_CHANGES,
                 "No changes registered", error, FALSE);
     }
 
index 0999947..38679f6 100644 (file)
@@ -298,7 +298,7 @@ gumd_daemon_get_user (
 {
     GumdDaemonUser *user = NULL;
     if (!self || !GUMD_IS_DAEMON (self)) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
                 "Daemon object is not valid", error, NULL);
     }
 
@@ -310,7 +310,7 @@ gumd_daemon_get_user (
 
     user = gumd_daemon_user_new_by_uid (uid, self->priv->config);
     if (!user) {
-        RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found", error,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found", error,
                 NULL);
     }
 
@@ -328,13 +328,13 @@ gumd_daemon_get_user_by_name (
 {
     uid_t uid = GUM_USER_INVALID_UID;
     if (!self || !GUMD_IS_DAEMON (self)) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
                 "Daemon object is not valid", error, NULL);
     }
 
     uid = gumd_daemon_user_get_uid_by_name (username, self->priv->config);
     if (uid == GUM_USER_INVALID_UID) {
-        RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found", error,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found", error,
                 NULL);
     }
 
@@ -350,7 +350,7 @@ gumd_daemon_add_user (
     uid_t uid = GUM_USER_INVALID_UID;
 
     if (!self || !GUMD_IS_DAEMON (self) || !user) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
                 "Daemon/usr object not valid", error, FALSE);
     }
 
@@ -377,7 +377,7 @@ gumd_daemon_delete_user (
     uid_t uid = GUM_USER_INVALID_UID;
 
     if (!self || !GUMD_IS_DAEMON (self) || !user) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
                 "Daemon/user object not valid", error, FALSE);
     }
 
@@ -401,7 +401,7 @@ gumd_daemon_update_user (
     uid_t uid = GUM_USER_INVALID_UID;
 
     if (!self || !GUMD_IS_DAEMON (self) || !user) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
                 "Daemon/user object not valid", error, FALSE);
     }
 
@@ -432,7 +432,7 @@ gumd_daemon_get_group (
 {
     GumdDaemonGroup *group = NULL;
     if (!self || !GUMD_IS_DAEMON (self)) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
                 "Daemon object is not valid", error, NULL);
     }
 
@@ -444,7 +444,7 @@ gumd_daemon_get_group (
 
     group = gumd_daemon_group_new_by_gid (gid, self->priv->config);
     if (!group) {
-        RETURN_WITH_ERROR (GUM_ERROR_GROUP_NOT_FOUND, "Group not found", error,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_NOT_FOUND, "Group not found", error,
                 FALSE);
     }
 
@@ -462,13 +462,13 @@ gumd_daemon_get_group_by_name (
 {
     gid_t gid = GUM_GROUP_INVALID_GID;
     if (!self || !GUMD_IS_DAEMON (self)) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
                 "Daemon object is not valid", error, NULL);
     }
 
     gid = gumd_daemon_group_get_gid_by_name (groupname, self->priv->config);
     if (gid == GUM_GROUP_INVALID_GID) {
-        RETURN_WITH_ERROR (GUM_ERROR_GROUP_NOT_FOUND, "User not found", error,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_NOT_FOUND, "User not found", error,
                 NULL);
     }
 
@@ -484,7 +484,7 @@ gumd_daemon_add_group (
     gid_t gid = GUM_GROUP_INVALID_GID;
 
     if (!self || !GUMD_IS_DAEMON (self) || !group) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
                 "Daemon/usr object not valid", error, FALSE);
     }
 
@@ -508,7 +508,7 @@ gumd_daemon_delete_group (
     gid_t gid = GUM_GROUP_INVALID_GID;
 
     if (!self || !GUMD_IS_DAEMON (self) || !group) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
                 "Daemon/group object not valid", error, FALSE);
     }
 
@@ -532,7 +532,7 @@ gumd_daemon_update_group (
     gid_t gid = GUM_GROUP_INVALID_GID;
 
     if (!self || !GUMD_IS_DAEMON (self) || !group) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
                 "Daemon/group object not valid", error, FALSE);
     }
 
@@ -556,7 +556,7 @@ gumd_daemon_add_group_member (
         GError **error)
 {
     if (!self || !GUMD_IS_DAEMON (self) || !group) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
                 "Daemon/group object not valid", error, FALSE);
     }
 
@@ -575,7 +575,7 @@ gumd_daemon_delete_group_member (
         GError **error)
 {
     if (!self || !GUMD_IS_DAEMON (self) || !group) {
-        RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
+        GUM_RETURN_WITH_ERROR (GUM_ERROR_INVALID_INPUT,
                 "Daemon/group object not valid", error, FALSE);
     }
 
index 4b514b6..23cb55c 100644 (file)
 
 /**
  * GumGroupClass:
+ * @parent_class: parent class object
  *
  * Opaque structure for the class.
  */
@@ -310,7 +311,7 @@ gum_group_class_init (
      * GumGroup:grouptype:
      *
      * This property holds a group type that the object corresponds to. Valid
-     * values of group types are; 1 (system), 2 (user).
+     * values of group types are: 1 (system), 2 (user).
      * #GumGroup:grouptype must be specified when adding a new group.
      */
     properties[PROP_GROUPTYPE] =  g_param_spec_uint ("grouptype",
index e527ecb..94e6a08 100644 (file)
 
 /**
  * GumUserClass:
+ * @parent_class: parent class object
  *
  * Opaque structure for the class.
  */
@@ -318,7 +319,7 @@ gum_user_class_init (
      * GumUser:usertype:
      *
      * This property holds a user type that the object corresponds to. Valid
-     * values of user types are; 1 (system), 2 (admin), 3 (guest), 4 (normal).
+     * values of user types are: 1 (system), 2 (admin), 3 (guest), 4 (normal).
      * #GumUser:usertype must be specified when adding a new user.
      */
     properties[PROP_USERTYPE] =  g_param_spec_uint ("usertype",
index a5fbaba..c907117 100644 (file)
@@ -304,7 +304,7 @@ _update_file_entries (
             n_read += n;
         } while (n_read < BLOCKSIZE && n != 0);
         if (n == 0 && ferror (origf))
-            RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "Unable to write file",
+            GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE, "Unable to write file",
                     error, FALSE);
 
         p = buffer;
@@ -312,7 +312,7 @@ _update_file_entries (
         while (n_read > 0) {
             n_written = fwrite (p, 1, n_read, newf);
             if (n_written == -1)
-                RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
+                GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_WRITE,
                         "Unable to write file", error, FALSE);
 
             p += n_written;