/soc/2013/ankitkv/gobjectification: 62148e91059f: Refactored pid...
Ankit Vani
a at nevitus.org
Thu Sep 19 10:59:35 EDT 2013
Changeset: 62148e91059f2036f2b520d88f0207095507c33f
Author: Ankit Vani <a at nevitus.org>
Date: 2013-09-19 20:29 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/62148e91059f
Description:
Refactored pidgin gevolution plugin to use the new plugin API
diffstat:
pidgin/plugins/gevolution/Makefile.am | 2 +-
pidgin/plugins/gevolution/assoc-buddy.c | 15 +-
pidgin/plugins/gevolution/eds-utils.c | 6 +-
pidgin/plugins/gevolution/gevo-util.c | 12 +-
pidgin/plugins/gevolution/gevolution.c | 177 ++++++++++---------------
pidgin/plugins/gevolution/new_person_dialog.c | 2 +-
6 files changed, 89 insertions(+), 125 deletions(-)
diffs (truncated from 369 to 300 lines):
diff --git a/pidgin/plugins/gevolution/Makefile.am b/pidgin/plugins/gevolution/Makefile.am
--- a/pidgin/plugins/gevolution/Makefile.am
+++ b/pidgin/plugins/gevolution/Makefile.am
@@ -15,7 +15,7 @@ gevolution_la_SOURCES = \
new_person_dialog.c \
eds-utils.c
-gevolution_la_LIBADD = $(EVOLUTION_ADDRESSBOOK_LIBS) $(GTK_LIBS)
+gevolution_la_LIBADD = $(EVOLUTION_ADDRESSBOOK_LIBS) $(GPLUGIN_LIBS) $(GTK_LIBS)
endif
diff --git a/pidgin/plugins/gevolution/assoc-buddy.c b/pidgin/plugins/gevolution/assoc-buddy.c
--- a/pidgin/plugins/gevolution/assoc-buddy.c
+++ b/pidgin/plugins/gevolution/assoc-buddy.c
@@ -134,7 +134,6 @@ populate_treeview(GevoAssociateBuddyDial
{
EBook *book;
EBookQuery *query;
- const char *protocol_id;
gboolean status;
GList *cards, *c;
GError *err = NULL;
@@ -188,8 +187,6 @@ populate_treeview(GevoAssociateBuddyDial
return;
}
- protocol_id = purple_account_get_protocol_id(dialog->buddy->account);
-
for (c = cards; c != NULL; c = c->next)
{
EContact *contact = E_CONTACT(c->data);
@@ -207,7 +204,7 @@ populate_treeview(GevoAssociateBuddyDial
-1);
/* See if this user has the buddy in its list. */
- protocol_field = gevo_protocol_get_field(dialog->buddy->account,
+ protocol_field = gevo_protocol_get_field(purple_buddy_get_account(dialog->buddy),
dialog->buddy);
if (protocol_field > 0)
@@ -218,7 +215,7 @@ populate_treeview(GevoAssociateBuddyDial
for (l = ims; l != NULL; l = l->next)
{
- if (!strcmp(l->data, dialog->buddy->name))
+ if (!strcmp(l->data, purple_buddy_get_name(dialog->buddy)))
{
GtkTreeSelection *selection;
@@ -256,8 +253,8 @@ addrbook_change_cb(GtkComboBox *combo, G
static void
new_person_cb(GtkWidget *w, GevoAssociateBuddyDialog *dialog)
{
- gevo_new_person_dialog_show(dialog->book, NULL, dialog->buddy->account,
- dialog->buddy->name, NULL, dialog->buddy,
+ gevo_new_person_dialog_show(dialog->book, NULL, purple_buddy_get_account(dialog->buddy),
+ purple_buddy_get_name(dialog->buddy), NULL, dialog->buddy,
TRUE);
delete_win_cb(NULL, NULL, dialog);
@@ -289,13 +286,13 @@ assoc_buddy_cb(GtkWidget *w, GevoAssocia
COLUMN_DATA, &contact,
-1);
- protocol_field = gevo_protocol_get_field(dialog->buddy->account, dialog->buddy);
+ protocol_field = gevo_protocol_get_field(purple_buddy_get_account(dialog->buddy), dialog->buddy);
if (protocol_field == 0)
return; /* XXX */
list = e_contact_get(contact, protocol_field);
- list = g_list_append(list, g_strdup(dialog->buddy->name));
+ list = g_list_append(list, g_strdup(purple_buddy_get_name(dialog->buddy)));
e_contact_set(contact, protocol_field, list);
diff --git a/pidgin/plugins/gevolution/eds-utils.c b/pidgin/plugins/gevolution/eds-utils.c
--- a/pidgin/plugins/gevolution/eds-utils.c
+++ b/pidgin/plugins/gevolution/eds-utils.c
@@ -177,7 +177,7 @@ gevo_search_buddy_in_contacts(PurpleBudd
EBookQuery *full_query;
GSList *groups, *g;
EContact *result;
- EContactField protocol_field = gevo_protocol_get_field(buddy->account, buddy);
+ EContactField protocol_field = gevo_protocol_get_field(purple_buddy_get_account(buddy), buddy);
if (protocol_field == 0)
return NULL;
@@ -187,7 +187,7 @@ gevo_search_buddy_in_contacts(PurpleBudd
EBookQuery *queries[2];
queries[0] = query;
- queries[1] = e_book_query_field_test(protocol_field, E_BOOK_QUERY_IS, buddy->name);
+ queries[1] = e_book_query_field_test(protocol_field, E_BOOK_QUERY_IS, purple_buddy_get_name(buddy));
if (queries[1] == NULL)
{
purple_debug_error("evolution", "Error in creating protocol query\n");
@@ -199,7 +199,7 @@ gevo_search_buddy_in_contacts(PurpleBudd
}
else
{
- full_query = e_book_query_field_test(protocol_field, E_BOOK_QUERY_IS, buddy->name);
+ full_query = e_book_query_field_test(protocol_field, E_BOOK_QUERY_IS, purple_buddy_get_name(buddy));
if (full_query == NULL)
{
purple_debug_error("evolution", "Error in creating protocol query\n");
diff --git a/pidgin/plugins/gevolution/gevo-util.c b/pidgin/plugins/gevolution/gevo-util.c
--- a/pidgin/plugins/gevolution/gevo-util.c
+++ b/pidgin/plugins/gevolution/gevo-util.c
@@ -29,11 +29,11 @@ void
gevo_add_buddy(PurpleAccount *account, const char *group_name,
const char *buddy_name, const char *alias)
{
- PurpleConversation *conv = NULL;
+ PurpleIMConversation *im = NULL;
PurpleBuddy *buddy;
PurpleGroup *group;
- conv = purple_conversations_find_im_with_account(buddy_name, account);
+ im = purple_conversations_find_im_with_account(buddy_name, account);
group = purple_blist_find_group(group_name);
if (group == NULL)
@@ -51,10 +51,10 @@ gevo_add_buddy(PurpleAccount *account, c
purple_account_add_buddy(account, buddy, NULL);
- if (conv != NULL)
+ if (im != NULL)
{
- purple_buddy_icon_update(purple_im_conversation_get_icon(PURPLE_CONV_IM(conv)));
- purple_conversation_update(conv, PURPLE_CONVERSATION_UPDATE_ADD);
+ purple_buddy_icon_update(purple_im_conversation_get_icon(im));
+ purple_conversation_update(PURPLE_CONVERSATION(im), PURPLE_CONVERSATION_UPDATE_ADD);
}
}
@@ -81,7 +81,7 @@ gevo_get_groups(void)
if (PURPLE_IS_GROUP(gnode))
{
g = PURPLE_GROUP(gnode);
- list = g_list_append(list, g->name);
+ list = g_list_append(list, (gpointer)purple_group_get_name(g));
}
}
}
diff --git a/pidgin/plugins/gevolution/gevolution.c b/pidgin/plugins/gevolution/gevolution.c
--- a/pidgin/plugins/gevolution/gevolution.c
+++ b/pidgin/plugins/gevolution/gevolution.c
@@ -333,62 +333,6 @@ load_timeout(gpointer data)
return FALSE;
}
-static gboolean
-plugin_load(PurplePlugin *plugin)
-{
-#if 0
- bonobo_activate();
-#endif
-
- backup_blist_ui_ops = purple_blist_get_ui_ops();
-
- blist_ui_ops = g_memdup(backup_blist_ui_ops, sizeof(PurpleBlistUiOps));
- blist_ui_ops->request_add_buddy = request_add_buddy;
-
- purple_blist_set_ui_ops(blist_ui_ops);
-
- purple_signal_connect(purple_connections_get_handle(), "signed-on",
- plugin, PURPLE_CALLBACK(signed_on_cb), NULL);
-
- timer = g_timeout_add(1, load_timeout, plugin);
-
- return TRUE;
-}
-
-static gboolean
-plugin_unload(PurplePlugin *plugin)
-{
- purple_blist_set_ui_ops(backup_blist_ui_ops);
-
- g_free(blist_ui_ops);
-
- backup_blist_ui_ops = NULL;
- blist_ui_ops = NULL;
-
- if (book_view != NULL)
- {
- e_book_view_stop(book_view);
- g_object_unref(book_view);
- book_view = NULL;
- }
-
- if (book != NULL)
- {
- g_object_unref(book);
- book = NULL;
- }
-
- return TRUE;
-}
-
-static void
-plugin_destroy(PurplePlugin *plugin)
-{
-#if 0
- bonobo_debug_shutdown();
-#endif
-}
-
static void
autoadd_toggled_cb(GtkCellRendererToggle *renderer, gchar *path_str,
gpointer data)
@@ -512,56 +456,31 @@ get_config_frame(PurplePlugin *plugin)
return ret;
}
-static PidginPluginUiInfo ui_info =
+static PidginPluginInfo *
+plugin_query(GError **error)
{
- get_config_frame, /**< get_config_frame */
- 0, /**< page_num */
- /* Padding */
- NULL,
- NULL,
- NULL,
- NULL
-};
+ const gchar * const authors[] = {
+ "Christian Hammond <chipx86 at chipx86.com>",
+ NULL
+ };
-static PurplePluginInfo info =
-{
- PURPLE_PLUGIN_MAGIC,
- PURPLE_MAJOR_VERSION,
- PURPLE_MINOR_VERSION,
- PURPLE_PLUGIN_STANDARD, /**< type */
- PIDGIN_PLUGIN_TYPE, /**< ui_requirement */
- 0, /**< flags */
- NULL, /**< dependencies */
- PURPLE_PRIORITY_DEFAULT, /**< priority */
+ return pidgin_plugin_info_new(
+ "id", GEVOLUTION_PLUGIN_ID,
+ "name", N_("Evolution Integration"),
+ "version", DISPLAY_VERSION,
+ "category", N_("Integration"),
+ "summary", N_("Provides integration with Evolution."),
+ "description", N_("Provides integration with Evolution."),
+ "authors", authors,
+ "website", PURPLE_WEBSITE,
+ "abi-version", PURPLE_ABI_VERSION,
+ "pidgin-config-frame", get_config_frame,
+ NULL
+ );
+}
- GEVOLUTION_PLUGIN_ID, /**< id */
- N_("Evolution Integration"), /**< name */
- DISPLAY_VERSION, /**< version */
- /** summary */
- N_("Provides integration with Evolution."),
- /** description */
- N_("Provides integration with Evolution."),
- "Christian Hammond <chipx86 at chipx86.com>", /**< author */
- PURPLE_WEBSITE, /**< homepage */
-
- plugin_load, /**< load */
- plugin_unload, /**< unload */
- plugin_destroy, /**< destroy */
-
- &ui_info, /**< ui_info */
- NULL, /**< extra_info */
- NULL,
- NULL,
-
- /* Padding */
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
+static gboolean
+plugin_load(PurplePlugin *plugin, GError **error)
{
/* TODO: Change to core-remote when possible. */
/* info.dependencies = g_list_append(info.dependencies, "gtk-remote"); */
@@ -584,7 +503,8 @@ init_plugin(PurplePlugin *plugin)
* at all, so the above explanation is suspect. This is required even with
* e-d-s >= 2.29.1 where bonobo is no longer in the picture.
*/
- g_module_make_resident(plugin->handle);
+ g_module_make_resident(gplugin_native_plugin_get_module(
+ GPLUGIN_NATIVE_PLUGIN(plugin)));
More information about the Commits
mailing list