From 7aacf983b32ecac26bc9707697da622b3ef164a3 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 5 Mar 2011 12:33:49 -0500 Subject: Coding style and whitespace cleanup. --- e-util/e-plugin.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'e-util/e-plugin.c') diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c index db717e8dcd..d3579b7d89 100644 --- a/e-util/e-plugin.c +++ b/e-util/e-plugin.c @@ -154,8 +154,6 @@ ep_construct (EPlugin *ep, xmlNodePtr root) ep->name = e_plugin_xml_prop_domain(root, "name", ep->domain); - pd(printf("creating plugin '%s' '%s'\n", ep->name?ep->name:"un-named", ep->id)); - node = root->children; while (node) { if (strcmp((gchar *)node->name, "hook") == 0) { @@ -173,12 +171,15 @@ ep_construct (EPlugin *ep, xmlNodePtr root) if (ep->enabled && eph_types != NULL - && (type = g_hash_table_lookup (eph_types, class)) != NULL) { + && (type = g_hash_table_lookup ( + eph_types, class)) != NULL) { g_free (class); hook = g_object_new (G_OBJECT_CLASS_TYPE (type), NULL); res = type->construct (hook, ep, node); if (res == -1) { - g_warning("Plugin '%s' failed to load hook", ep->name); + g_warning ( + "Plugin '%s' failed to " + "load hook", ep->name); g_object_unref (hook); goto fail; } else { @@ -188,7 +189,8 @@ ep_construct (EPlugin *ep, xmlNodePtr root) g_free (class); } } else if (strcmp((gchar *)node->name, "description") == 0) { - ep->description = e_plugin_xml_content_domain (node, ep->domain); + ep->description = + e_plugin_xml_content_domain (node, ep->domain); } else if (strcmp((gchar *)node->name, "author") == 0) { gchar *name = e_plugin_xml_prop(node, "name"); gchar *email = e_plugin_xml_prop(node, "email"); @@ -353,7 +355,6 @@ ep_load_plugin (xmlNodePtr root, struct _plugin_doc *pdoc) * which is checked when a new type is registered. */ class = g_hash_table_lookup (ep_types, prop); if (class == NULL) { - pd(printf("Delaying loading of plugin '%s' unknown type '%s'\n", id, prop)); g_free (id); xmlFree (prop); return NULL; @@ -404,22 +405,20 @@ ep_load (const gchar *filename, gint load_level) if ((atoi (plugin_load_level) == load_level) ) { ep = ep_load_plugin (root, pdoc); - if (ep) { - if (load_level == 1) - e_plugin_invoke (ep, "load_plugin_type_register_function", NULL); - } + if (ep && load_level == 1) + e_plugin_invoke (ep, "load_plugin_type_register_function", NULL); } } else if (load_level == 2) { ep = ep_load_plugin (root, pdoc); } if (ep) { - pd(printf ("\nloading plugin [%s] at load_level [%d]\n", ep->name, load_level)); - - /* README: May be we can use load_levels to achieve the same thing. - But it may be confusing for a plugin writer */ - is_system_plugin = e_plugin_xml_prop (root, "system_plugin"); - if (is_system_plugin && !strcmp (is_system_plugin, "true")) { + /* README: Maybe we can use load_levels to + * achieve the same thing. But it may be + * confusing for a plugin writer. */ + is_system_plugin = + e_plugin_xml_prop (root, "system_plugin"); + if (g_strcmp0 (is_system_plugin, "true") == 0) { e_plugin_enable (ep, TRUE); ep->flags |= E_PLUGIN_FLAGS_SYSTEM_PLUGIN; } else @@ -559,8 +558,9 @@ e_plugin_load_plugins (void) while ((d = g_dir_read_name (dir))) { if (g_str_has_suffix (d, ".eplug")) { - gchar * name = g_build_filename (path, d, NULL); + gchar *name; + name = g_build_filename (path, d, NULL); ep_load (name, i); g_free (name); } -- cgit v1.2.3 From 27d6ca4b21e1fc39398825ec689297c824845102 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 18 Apr 2011 19:16:32 -0400 Subject: Bug 647708 - e_plugin_xml_prop() can return libxml2 allocated memory Always copy the xmlChar property into GLib-allocated memory. g_mem_is_system_malloc() has nothing to do with libxml2. --- e-util/e-plugin.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'e-util/e-plugin.c') diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c index d3579b7d89..fa7f0d9d88 100644 --- a/e-util/e-plugin.c +++ b/e-util/e-plugin.c @@ -732,8 +732,7 @@ e_plugin_get_configure_widget (EPlugin *ep) * @id: The name of the property to retrieve. * * A static helper function to look up a property on an XML node, and - * ensure it is allocated in GLib system memory. If GLib isn't using - * the system malloc then it must copy the property value. + * ensure it is allocated in GLib system memory. * * Return value: The property, allocated in GLib memory, or NULL if no * such property exists. @@ -741,17 +740,17 @@ e_plugin_get_configure_widget (EPlugin *ep) gchar * e_plugin_xml_prop (xmlNodePtr node, const gchar *id) { - gchar *p = (gchar *)xmlGetProp (node, (const guchar *)id); + xmlChar *xml_prop; + gchar *glib_prop = NULL; - if (g_mem_is_system_malloc ()) { - return p; - } else { - gchar * out = g_strdup (p); + xml_prop = xmlGetProp (node, (xmlChar *) id); - if (p) - xmlFree (p); - return out; + if (xml_prop != NULL) { + glib_prop = g_strdup ((gchar *) xml_prop); + xmlFree (xml_prop); } + + return glib_prop; } /** -- cgit v1.2.3 From 54da4fc09cf226fdb59b9f0c70555e2e57dc1f91 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 8 May 2011 13:24:42 -0400 Subject: Coding style cleanups. --- e-util/e-plugin.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'e-util/e-plugin.c') diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c index fa7f0d9d88..17e4b50102 100644 --- a/e-util/e-plugin.c +++ b/e-util/e-plugin.c @@ -576,7 +576,7 @@ e_plugin_load_plugins (void) static void ep_list_plugin (gpointer key, gpointer val, gpointer dat) { - GSList **l = (GSList **)dat; + GSList **l = (GSList **) dat; *l = g_slist_prepend(*l, g_object_ref(val)); } @@ -770,7 +770,7 @@ e_plugin_xml_prop_domain (xmlNodePtr node, const gchar *id, const gchar *domain) { gchar *p, *out; - p = (gchar *)xmlGetProp (node, (const guchar *)id); + p = (gchar *) xmlGetProp (node, (const guchar *) id); if (p == NULL) return NULL; @@ -796,7 +796,7 @@ e_plugin_xml_prop_domain (xmlNodePtr node, const gchar *id, const gchar *domain) gint e_plugin_xml_int (xmlNodePtr node, const gchar *id, gint def) { - gchar *p = (gchar *)xmlGetProp (node, (const guchar *)id); + gchar *p = (gchar *) xmlGetProp (node, (const guchar *) id); if (p) return atoi (p); @@ -817,7 +817,7 @@ e_plugin_xml_int (xmlNodePtr node, const gchar *id, gint def) gchar * e_plugin_xml_content (xmlNodePtr node) { - gchar *p = (gchar *)xmlNodeGetContent (node); + gchar *p = (gchar *) xmlNodeGetContent (node); if (g_mem_is_system_malloc ()) { return p; @@ -846,7 +846,7 @@ e_plugin_xml_content_domain (xmlNodePtr node, const gchar *domain) { gchar *p, *out; - p = (gchar *)xmlNodeGetContent (node); + p = (gchar *) xmlNodeGetContent (node); if (p == NULL) return NULL; @@ -935,7 +935,7 @@ e_plugin_hook_mask (xmlNodePtr root, gchar *val, *p, *start, c; guint32 mask = 0; - val = (gchar *)xmlGetProp (root, (const guchar *)prop); + val = (gchar *) xmlGetProp (root, (const guchar *) prop); if (val == NULL) return 0; @@ -988,7 +988,7 @@ e_plugin_hook_id (xmlNodePtr root, gchar *val; gint i; - val = (gchar *)xmlGetProp (root, (const guchar *)prop); + val = (gchar *) xmlGetProp (root, (const guchar *) prop); if (val == NULL) return ~0; -- cgit v1.2.3 From c24038c4f62f37b89d1bda9542ca5ccc843d4ea0 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 27 May 2011 15:23:07 +0200 Subject: Bug #646109 - Fix use of include to make sure translations work --- e-util/e-plugin.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'e-util/e-plugin.c') diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c index 17e4b50102..e0f1aecd22 100644 --- a/e-util/e-plugin.c +++ b/e-util/e-plugin.c @@ -16,7 +16,9 @@ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) */ +#ifdef HAVE_CONFIG_H #include +#endif #include #include -- cgit v1.2.3 From e7954c3f251aabbf95d099159709c8c66dfedc44 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 4 Jun 2011 15:53:10 -0500 Subject: Coding style and whitespace cleanups. --- e-util/e-plugin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'e-util/e-plugin.c') diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c index e0f1aecd22..52bbe101cb 100644 --- a/e-util/e-plugin.c +++ b/e-util/e-plugin.c @@ -408,7 +408,8 @@ ep_load (const gchar *filename, gint load_level) ep = ep_load_plugin (root, pdoc); if (ep && load_level == 1) - e_plugin_invoke (ep, "load_plugin_type_register_function", NULL); + e_plugin_invoke ( + ep, "load_plugin_type_register_function", NULL); } } else if (load_level == 2) { ep = ep_load_plugin (root, pdoc); -- cgit v1.2.3 From 777c1cbd40eb63365f2c28e38f6a93beb2d1c9d1 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 16 Aug 2011 11:25:56 -0400 Subject: Coding style and whitespace cleanup. --- e-util/e-plugin.c | 116 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 47 deletions(-) (limited to 'e-util/e-plugin.c') diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c index 52bbe101cb..17650f045a 100644 --- a/e-util/e-plugin.c +++ b/e-util/e-plugin.c @@ -40,29 +40,29 @@ #define phd(x) /* - - imap - IMAP4 and IMAP4v1 mail store - - - - - PLAIN - SASL PLAIN authentication mechanism - + * + * imap + * IMAP4 and IMAP4v1 mail store + * + * + * + * + * PLAIN + * SASL PLAIN authentication mechanism + * */ /* EPlugin stuff */ @@ -105,7 +105,8 @@ ep_check_enabled (const gchar *id) } static void -ep_set_enabled (const gchar *id, gint state) +ep_set_enabled (const gchar *id, + gint state) { GConfClient *client; @@ -133,7 +134,8 @@ ep_set_enabled (const gchar *id, gint state) } static gint -ep_construct (EPlugin *ep, xmlNodePtr root) +ep_construct (EPlugin *ep, + xmlNodePtr root) { xmlNodePtr node; gint res = -1; @@ -159,7 +161,7 @@ ep_construct (EPlugin *ep, xmlNodePtr root) node = root->children; while (node) { if (strcmp((gchar *)node->name, "hook") == 0) { - struct _EPluginHook *hook; + EPluginHook *hook; EPluginHookClass *type; gchar *class = e_plugin_xml_prop(node, "class"); @@ -213,7 +215,8 @@ fail: } static void -ep_enable (EPlugin *ep, gint state) +ep_enable (EPlugin *ep, + gint state) { GSList *iter; @@ -328,7 +331,8 @@ e_plugin_init (EPlugin *ep) } static EPlugin * -ep_load_plugin (xmlNodePtr root, struct _plugin_doc *pdoc) +ep_load_plugin (xmlNodePtr root, + struct _plugin_doc *pdoc) { gchar *prop, *id; EPluginClass *class; @@ -375,7 +379,8 @@ ep_load_plugin (xmlNodePtr root, struct _plugin_doc *pdoc) } static gint -ep_load (const gchar *filename, gint load_level) +ep_load (const gchar *filename, + gint load_level) { xmlDocPtr doc; xmlNodePtr root; @@ -545,8 +550,8 @@ e_plugin_load_plugins (void) GCONF_VALUE_STRING, NULL); g_object_unref (client); - for (i=0; i < 3; i++) { - for (l = ep_path;l;l = g_slist_next (l)) { + for (i = 0; i < 3; i++) { + for (l = ep_path; l; l = g_slist_next (l)) { GDir *dir; const gchar *d; gchar *path = l->data; @@ -577,7 +582,9 @@ e_plugin_load_plugins (void) } static void -ep_list_plugin (gpointer key, gpointer val, gpointer dat) +ep_list_plugin (gpointer key, + gpointer val, + gpointer dat) { GSList **l = (GSList **) dat; @@ -615,7 +622,8 @@ e_plugin_list_plugins (void) * Return value: The return from the construct virtual method. **/ gint -e_plugin_construct (EPlugin *ep, xmlNodePtr root) +e_plugin_construct (EPlugin *ep, + xmlNodePtr root) { EPluginClass *class; @@ -641,7 +649,9 @@ e_plugin_construct (EPlugin *ep, xmlNodePtr root) * Return value: The return of the plugin invocation. **/ gpointer -e_plugin_invoke (EPlugin *ep, const gchar *name, gpointer data) +e_plugin_invoke (EPlugin *ep, + const gchar *name, + gpointer data) { EPluginClass *class; @@ -668,7 +678,8 @@ e_plugin_invoke (EPlugin *ep, const gchar *name, gpointer data) * Return value: the symbol value, or %NULL if not found **/ gpointer -e_plugin_get_symbol (EPlugin *ep, const gchar *name) +e_plugin_get_symbol (EPlugin *ep, + const gchar *name) { EPluginClass *class; @@ -690,7 +701,8 @@ e_plugin_get_symbol (EPlugin *ep, const gchar *name) * THIS IS NOT FULLY IMPLEMENTED YET **/ void -e_plugin_enable (EPlugin *ep, gint state) +e_plugin_enable (EPlugin *ep, + gint state) { EPluginClass *class; @@ -741,7 +753,8 @@ e_plugin_get_configure_widget (EPlugin *ep) * such property exists. **/ gchar * -e_plugin_xml_prop (xmlNodePtr node, const gchar *id) +e_plugin_xml_prop (xmlNodePtr node, + const gchar *id) { xmlChar *xml_prop; gchar *glib_prop = NULL; @@ -769,7 +782,9 @@ e_plugin_xml_prop (xmlNodePtr node, const gchar *id) * such property exists. **/ gchar * -e_plugin_xml_prop_domain (xmlNodePtr node, const gchar *id, const gchar *domain) +e_plugin_xml_prop_domain (xmlNodePtr node, + const gchar *id, + const gchar *domain) { gchar *p, *out; @@ -797,7 +812,9 @@ e_plugin_xml_prop_domain (xmlNodePtr node, const gchar *id, const gchar *domain) * Return value: The value if set, or @def if not. **/ gint -e_plugin_xml_int (xmlNodePtr node, const gchar *id, gint def) +e_plugin_xml_int (xmlNodePtr node, + const gchar *id, + gint def) { gchar *p = (gchar *) xmlGetProp (node, (const guchar *) id); @@ -845,7 +862,8 @@ e_plugin_xml_content (xmlNodePtr node) * Return value: The node content, allocated in GLib memory. **/ gchar * -e_plugin_xml_content_domain (xmlNodePtr node, const gchar *domain) +e_plugin_xml_content_domain (xmlNodePtr node, + const gchar *domain) { gchar *p, *out; @@ -867,7 +885,9 @@ G_DEFINE_TYPE ( G_TYPE_OBJECT) static gint -eph_construct (EPluginHook *eph, EPlugin *ep, xmlNodePtr root) +eph_construct (EPluginHook *eph, + EPlugin *ep, + xmlNodePtr root) { eph->plugin = ep; @@ -875,7 +895,8 @@ eph_construct (EPluginHook *eph, EPlugin *ep, xmlNodePtr root) } static void -eph_enable (EPluginHook *eph, gint state) +eph_enable (EPluginHook *eph, + gint state) { /* NOOP */ } @@ -903,7 +924,8 @@ e_plugin_hook_init (EPluginHook *hook) * THIS IS NOT FULY IMEPLEMENTED YET **/ void -e_plugin_hook_enable (EPluginHook *eph, gint state) +e_plugin_hook_enable (EPluginHook *eph, + gint state) { EPluginHookClass *class; @@ -932,7 +954,7 @@ e_plugin_hook_enable (EPluginHook *eph, gint state) **/ guint32 e_plugin_hook_mask (xmlNodePtr root, - const struct _EPluginHookTargetKey *map, + const EPluginHookTargetKey *map, const gchar *prop) { gchar *val, *p, *start, c; @@ -952,7 +974,7 @@ e_plugin_hook_mask (xmlNodePtr root, if (start != p) { gint i; - for (i=0;map[i].key;i++) { + for (i = 0; map[i].key; i++) { if (!strcmp (map[i].key, start)) { mask |= map[i].value; break; @@ -985,7 +1007,7 @@ e_plugin_hook_mask (xmlNodePtr root, **/ guint32 e_plugin_hook_id (xmlNodePtr root, - const struct _EPluginHookTargetKey *map, + const EPluginHookTargetKey *map, const gchar *prop) { gchar *val; @@ -995,7 +1017,7 @@ e_plugin_hook_id (xmlNodePtr root, if (val == NULL) return ~0; - for (i=0;map[i].key;i++) { + for (i = 0; map[i].key; i++) { if (!strcmp (map[i].key, val)) { xmlFree (val); return map[i].value; -- cgit v1.2.3 From 8d001181fbaf1350764e75c28f61e1ae3498dbb3 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Wed, 26 Oct 2011 12:29:31 +0200 Subject: Almost no more GConf in e-util --- e-util/e-plugin.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'e-util/e-plugin.c') diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c index a19dc879b3..6eba330893 100644 --- a/e-util/e-plugin.c +++ b/e-util/e-plugin.c @@ -25,8 +25,6 @@ #include -#include - #include #include #include @@ -73,7 +71,7 @@ static GHashTable *ep_types; static GSList *ep_path; /* global table of plugins by plugin.id */ static GHashTable *ep_plugins; -/* the list of disabled plugins from gconf */ +/* the list of disabled plugins from GSettings */ static GSList *ep_disabled; /* All classes which implement EPluginHooks, by class.id */ @@ -108,7 +106,9 @@ static void ep_set_enabled (const gchar *id, gint state) { - GConfClient *client; + GSettings *settings; + GSList *l; + GPtrArray *array; /* Bail out if no change to state, when expressed as a boolean: */ if ((state == 0) == (ep_check_enabled (id) == 0)) @@ -126,11 +126,15 @@ ep_set_enabled (const gchar *id, } else ep_disabled = g_slist_prepend (ep_disabled, g_strdup (id)); - client = gconf_client_get_default (); - gconf_client_set_list ( - client, "/apps/evolution/eplugin/disabled", - GCONF_VALUE_STRING, ep_disabled, NULL); - g_object_unref (client); + settings = g_settings_new ("org.gnome.evolution"); + array = g_ptr_array_new (); + for (l = ep_disabled; l != NULL; l = l->next) + g_ptr_array_add (array, l->data); + g_ptr_array_add (array, NULL); + g_settings_set_strv (settings, "disabled-eplugins", array->pdata); + + g_ptr_array_free (array, TRUE); + g_object_unref (settings); } static gint @@ -523,8 +527,9 @@ plugin_hook_load_subclass (GType type, gint e_plugin_load_plugins (void) { - GConfClient *client; + GSettings *settings; GSList *l; + gchar **strv; gint i; if (eph_types != NULL) @@ -544,11 +549,12 @@ e_plugin_load_plugins (void) E_TYPE_PLUGIN_HOOK, (ETypeFunc) plugin_hook_load_subclass, eph_types); - client = gconf_client_get_default (); - ep_disabled = gconf_client_get_list ( - client, "/apps/evolution/eplugin/disabled", - GCONF_VALUE_STRING, NULL); - g_object_unref (client); + settings = g_settings_new ("org.gnome.evolution"); + strv = g_settings_get_strv (settings, "disabled-eplugins"); + for (i = 0, ep_disabled = NULL; strv[i] != NULL; i++) + ep_disabled = g_slist_append (ep_disabled, g_strdup (strv[i])); + g_strfreev (strv); + g_object_unref (settings); for (i = 0; i < 3; i++) { for (l = ep_path; l; l = g_slist_next (l)) { -- cgit v1.2.3 From c75f58d01bb7bbe139cd73a85894dc5f50185816 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 18 Nov 2011 09:58:44 -0500 Subject: Fix compiler warnings. --- e-util/e-plugin.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'e-util/e-plugin.c') diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c index 6eba330893..f839591cc6 100644 --- a/e-util/e-plugin.c +++ b/e-util/e-plugin.c @@ -131,8 +131,9 @@ ep_set_enabled (const gchar *id, for (l = ep_disabled; l != NULL; l = l->next) g_ptr_array_add (array, l->data); g_ptr_array_add (array, NULL); - g_settings_set_strv (settings, "disabled-eplugins", array->pdata); - + g_settings_set_strv ( + settings, "disabled-eplugins", + (const gchar * const *) array->pdata); g_ptr_array_free (array, TRUE); g_object_unref (settings); } -- cgit v1.2.3 From 0c83b9b25d967ce6d6793ef851e86bc272a2f129 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 18 Nov 2011 09:09:48 -0500 Subject: Miscellaneous cleanups. --- e-util/e-plugin.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'e-util/e-plugin.c') diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c index f839591cc6..a125e6832d 100644 --- a/e-util/e-plugin.c +++ b/e-util/e-plugin.c @@ -107,7 +107,7 @@ ep_set_enabled (const gchar *id, gint state) { GSettings *settings; - GSList *l; + GSList *link; GPtrArray *array; /* Bail out if no change to state, when expressed as a boolean: */ @@ -128,8 +128,8 @@ ep_set_enabled (const gchar *id, settings = g_settings_new ("org.gnome.evolution"); array = g_ptr_array_new (); - for (l = ep_disabled; l != NULL; l = l->next) - g_ptr_array_add (array, l->data); + for (link = ep_disabled; link != NULL; link = link->next) + g_ptr_array_add (array, link->data); g_ptr_array_add (array, NULL); g_settings_set_strv ( settings, "disabled-eplugins", -- cgit v1.2.3