/soc/2013/ankitkv/gobjectification: 9e186ee25a7a: Merged soc.201...

Ankit Vani a at nevitus.org
Tue Nov 5 05:28:45 EST 2013


Changeset: 9e186ee25a7a5e4902f21371f1445bfedabdeeb9
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-11-05 15:57 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/9e186ee25a7a

Description:

Merged soc.2013.gobjectification branch

diffstat:

 libpurple/protocols/mxit/formcmds.c        |    4 +-
 libpurple/request-datasheet.c              |  113 ++++++++++++++++++++
 libpurple/request-datasheet.h              |  124 ++++++++++++++++++++++-
 pidgin/gtkrequest.c                        |  160 +++++++++++++++++++++++++++-
 pidgin/pixmaps/protocols/16/mxit.png       |  Bin 
 pidgin/pixmaps/protocols/22/mxit.png       |  Bin 
 pidgin/pixmaps/protocols/48/mxit.png       |  Bin 
 pidgin/pixmaps/protocols/scalable/mxit.svg |   41 +++---
 8 files changed, 408 insertions(+), 34 deletions(-)

diffs (truncated from 657 to 300 lines):

diff --git a/libpurple/protocols/mxit/formcmds.c b/libpurple/protocols/mxit/formcmds.c
--- a/libpurple/protocols/mxit/formcmds.c
+++ b/libpurple/protocols/mxit/formcmds.c
@@ -267,7 +267,7 @@ static void command_reply(struct RXMsgDa
 
 	if (nm) {		/* indicates response must be a structured response */
 		gchar*	seltext = g_markup_escape_text(purple_url_decode(selmsg), -1);
-		gchar*	replycmd = g_strdup_printf("type=reply|nm=%s|res=%s|err=0", nm, replymsg);
+		gchar*	replycmd = g_strdup_printf("type=reply|nm=%s|res=%s|err=0", nm, purple_url_decode(replymsg));
 
 		mxit_add_html_link( mx, replycmd, TRUE, seltext );
 
@@ -298,7 +298,7 @@ static void command_platformreq(GHashTab
 	char*	dest;
 
 	selmsg = g_hash_table_lookup(hash, "selmsg");			/* find the selection message */
-	if (selmsg) {
+	if (selmsg && (strlen(selmsg) > 0)) {
 		text = g_markup_escape_text(purple_url_decode(selmsg), -1);
 	}
 
diff --git a/libpurple/request-datasheet.c b/libpurple/request-datasheet.c
--- a/libpurple/request-datasheet.c
+++ b/libpurple/request-datasheet.c
@@ -34,6 +34,7 @@ struct _PurpleRequestDatasheet
 	guint col_count;
 	GArray *col_types;
 	GArray *col_titles;
+	GList *actions;
 
 	GList *record_list;
 	GHashTable *record_li_by_key;
@@ -46,6 +47,17 @@ struct _PurpleRequestDatasheetRecord
 	gchar **data; /* at this point, there is only string data possible */
 };
 
+struct _PurpleRequestDatasheetAction
+{
+	gchar *label;
+
+	PurpleRequestDatasheetActionCb cb;
+	gpointer cb_data;
+
+	PurpleRequestDatasheetActionCheckCb sens_cb;
+	gpointer sens_data;
+};
+
 static void
 purple_request_datasheet_record_free(PurpleRequestDatasheetRecord *rec);
 
@@ -93,6 +105,9 @@ purple_request_datasheet_free(PurpleRequ
 	g_array_free(sheet->col_titles, TRUE);
 	g_array_free(sheet->col_types, TRUE);
 
+	g_list_free_full(sheet->actions,
+		(GDestroyNotify)purple_request_datasheet_action_free);
+
 	g_hash_table_destroy(sheet->record_li_by_key);
 	g_list_free_full(sheet->record_list,
 		(GDestroyNotify)purple_request_datasheet_record_free);
@@ -156,6 +171,104 @@ purple_request_datasheet_get_records(Pur
 	return sheet->record_list;
 }
 
+void
+purple_request_datasheet_add_action(PurpleRequestDatasheet *sheet,
+	PurpleRequestDatasheetAction *action)
+{
+	g_return_if_fail(sheet != NULL);
+	g_return_if_fail(action != NULL);
+
+	sheet->actions = g_list_append(sheet->actions, action);
+}
+
+const GList *
+purple_request_datasheet_get_actions(PurpleRequestDatasheet *sheet)
+{
+	g_return_val_if_fail(sheet != NULL, NULL);
+
+	return sheet->actions;
+}
+
+/***** Datasheet actions API **************************************************/
+
+PurpleRequestDatasheetAction *
+purple_request_datasheet_action_new(void)
+{
+	return g_new0(PurpleRequestDatasheetAction, 1);
+}
+
+void
+purple_request_datasheet_action_free(PurpleRequestDatasheetAction *act)
+{
+	g_return_if_fail(act != NULL);
+	g_free(act->label);
+	g_free(act);
+}
+
+void
+purple_request_datasheet_action_set_label(PurpleRequestDatasheetAction *act,
+	const gchar *label)
+{
+	gchar *new_label;
+
+	g_return_if_fail(act != NULL);
+
+	new_label = g_strdup(label);
+	g_free(act->label);
+	act->label = new_label;
+}
+
+const gchar*
+purple_request_datasheet_action_get_label(PurpleRequestDatasheetAction *act)
+{
+	g_return_val_if_fail(act != NULL, NULL);
+
+	return act->label;
+}
+
+void
+purple_request_datasheet_action_set_cb(PurpleRequestDatasheetAction *act,
+	PurpleRequestDatasheetActionCb cb, gpointer user_data)
+{
+	g_return_if_fail(act != NULL);
+
+	act->cb = cb;
+	act->cb_data = user_data;
+}
+
+void
+purple_request_datasheet_action_call(PurpleRequestDatasheetAction *act,
+	PurpleRequestDatasheetRecord *rec)
+{
+	g_return_if_fail(act != NULL);
+
+	if (act->cb)
+		act->cb(rec, act->cb_data);
+}
+
+void
+purple_request_datasheet_action_set_sens_cb(
+	PurpleRequestDatasheetAction *act,
+	PurpleRequestDatasheetActionCheckCb cb, gpointer user_data)
+{
+	g_return_if_fail(act != NULL);
+
+	act->sens_cb = cb;
+	act->sens_data = user_data;
+}
+
+gboolean
+purple_request_datasheet_action_is_sensitive(PurpleRequestDatasheetAction *act,
+	PurpleRequestDatasheetRecord *rec)
+{
+	g_return_val_if_fail(act != NULL, FALSE);
+
+	if (!act->sens_cb)
+		return (rec != NULL);
+
+	return act->sens_cb(rec, act->cb_data);
+}
+
 /***** Datasheet record API ***************************************************/
 
 static PurpleRequestDatasheetRecord *
diff --git a/libpurple/request-datasheet.h b/libpurple/request-datasheet.h
--- a/libpurple/request-datasheet.h
+++ b/libpurple/request-datasheet.h
@@ -26,8 +26,16 @@
 #ifndef _PURPLE_REQUEST_DATA_H_
 #define _PURPLE_REQUEST_DATA_H_
 
+#include <glib.h>
+
 typedef struct _PurpleRequestDatasheet PurpleRequestDatasheet;
 typedef struct _PurpleRequestDatasheetRecord PurpleRequestDatasheetRecord;
+typedef struct _PurpleRequestDatasheetAction PurpleRequestDatasheetAction;
+
+typedef void (*PurpleRequestDatasheetActionCb)(
+	PurpleRequestDatasheetRecord *rec, gpointer user_data);
+typedef gboolean (*PurpleRequestDatasheetActionCheckCb)(
+	PurpleRequestDatasheetRecord *rec, gpointer user_data);
 
 typedef enum
 {
@@ -35,8 +43,6 @@ typedef enum
 	PURPLE_REQUEST_DATASHEET_COLUMN_IMAGE
 } PurpleRequestDatasheetColumnType;
 
-#include <glib.h>
-
 G_BEGIN_DECLS
 
 /**************************************************************************/
@@ -119,6 +125,120 @@ purple_request_datasheet_get_column_titl
 const GList *
 purple_request_datasheet_get_records(PurpleRequestDatasheet *sheet);
 
+/**
+ * Adds an action to the datasheet.
+ *
+ * Action object is owned by the datasheet since this call.
+ *
+ * @param sheet  The datasheet.
+ * @param action The action.
+ */
+void
+purple_request_datasheet_add_action(PurpleRequestDatasheet *sheet,
+	PurpleRequestDatasheetAction *action);
+
+/**
+ * Returns the list of actions in a datasheet.
+ *
+ * @param sheet The datasheet.
+ *
+ * @constreturn The list of actions.
+ */
+const GList *
+purple_request_datasheet_get_actions(PurpleRequestDatasheet *sheet);
+
+/*@}*/
+
+
+/**************************************************************************/
+/** @name Datasheet actions API                                           */
+/**************************************************************************/
+/*@{*/
+
+/**
+ * Creates new datasheet action.
+ *
+ * @return The new action.
+ */
+PurpleRequestDatasheetAction *
+purple_request_datasheet_action_new(void);
+
+/**
+ * Destroys the datasheet action.
+ *
+ * @param act The action.
+ */
+void
+purple_request_datasheet_action_free(PurpleRequestDatasheetAction *act);
+
+/**
+ * Sets the localized label for the action.
+ *
+ * @param act   The action.
+ * @param label The label.
+ */
+void
+purple_request_datasheet_action_set_label(PurpleRequestDatasheetAction *act,
+	const gchar *label);
+
+/**
+ * Gets the label of action.
+ *
+ * @param act The action.
+ *
+ * @return The localized label text.
+ */
+const gchar*
+purple_request_datasheet_action_get_label(PurpleRequestDatasheetAction *act);
+
+/**
+ * Sets the callback for the action.
+ *
+ * @param act       The action.
+ * @param cb        The callback function.
+ * @param user_data The data to be passed to the callback function.
+ */
+void
+purple_request_datasheet_action_set_cb(PurpleRequestDatasheetAction *act,
+	PurpleRequestDatasheetActionCb cb, gpointer user_data);
+
+/**
+ * Calls the callback of the action.
+ *
+ * @param act The action.
+ * @param rec The user selected record.
+ */
+void
+purple_request_datasheet_action_call(PurpleRequestDatasheetAction *act,
+	PurpleRequestDatasheetRecord *rec);
+
+/**
+ * Sets the sensitivity checker for the action.
+ *
+ * If there is no callback set, default is used: the action is enabled, if any
+ * record is active.
+ *
+ * @param act       The action.
+ * @param cb        The callback function, may be @c NULL.
+ * @param user_data The data to be passed to the callback function.
+ */
+void
+purple_request_datasheet_action_set_sens_cb(
+	PurpleRequestDatasheetAction *act,
+	PurpleRequestDatasheetActionCheckCb cb, gpointer user_data);
+



More information about the Commits mailing list