/soc/2013/ankitkv/gobjectification: 6d45c74af198: Refactored sam...

Ankit Vani a at nevitus.org
Sun Aug 11 20:10:21 EDT 2013


Changeset: 6d45c74af1981ba8314c3d5e62443a95bbc830cf
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-12 05:40 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/6d45c74af198

Description:

Refactored sametime to use the new plugin API

diffstat:

 libpurple/protocols/sametime/sametime.c |  1299 +++++++++++++++---------------
 1 files changed, 636 insertions(+), 663 deletions(-)

diffs (truncated from 1923 to 300 lines):

diff --git a/libpurple/protocols/sametime/sametime.c b/libpurple/protocols/sametime/sametime.c
--- a/libpurple/protocols/sametime/sametime.c
+++ b/libpurple/protocols/sametime/sametime.c
@@ -71,6 +71,7 @@
 /* scratch that, I just added it to the prpl options panel */
 #define PLUGIN_ID        "prpl-meanwhile"
 #define PLUGIN_NAME      "Sametime"
+#define PLUGIN_CATEGORY  "Protocol"
 #define PLUGIN_SUMMARY   "Sametime Protocol Plugin"
 #define PLUGIN_DESC      "Open implementation of a Lotus Sametime client"
 #define PLUGIN_AUTHOR    "Christopher (siege) O'Brien <siege at preoccupied.net>"
@@ -197,7 +198,7 @@ static guint log_handler[2] = { 0, 0 };
 
 /** the purple plugin data.
     available as purple_connection_get_protocol_data(gc) and mwSession_getClientData */
-struct mwPurplePluginData {
+struct mwPurpleProtocolData {
   struct mwSession *session;
 
   struct mwServiceAware *srvc_aware;
@@ -236,9 +237,9 @@ typedef struct {
 
 static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist);
 
-static void blist_store(struct mwPurplePluginData *pd);
-
-static void blist_schedule(struct mwPurplePluginData *pd);
+static void blist_store(struct mwPurpleProtocolData *pd);
+
+static void blist_schedule(struct mwPurpleProtocolData *pd);
 
 static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist);
 
@@ -246,19 +247,19 @@ static void blist_sync(PurpleConnection 
 
 static gboolean buddy_is_external(PurpleBuddy *b);
 
-static void buddy_add(struct mwPurplePluginData *pd, PurpleBuddy *buddy);
+static void buddy_add(struct mwPurpleProtocolData *pd, PurpleBuddy *buddy);
 
 static PurpleBuddy *
 buddy_ensure(PurpleConnection *gc, PurpleGroup *group,
 	     struct mwSametimeUser *stuser);
 
-static void group_add(struct mwPurplePluginData *pd, PurpleGroup *group);
+static void group_add(struct mwPurpleProtocolData *pd, PurpleGroup *group);
 
 static PurpleGroup *
 group_ensure(PurpleConnection *gc, struct mwSametimeGroup *stgroup);
 
 static struct mwAwareList *
-list_ensure(struct mwPurplePluginData *pd, PurpleGroup *group);
+list_ensure(struct mwPurpleProtocolData *pd, PurpleGroup *group);
 
 
 /* session functions */
@@ -272,7 +273,7 @@ static PurpleConnection *session_to_gc(s
 /* conference functions */
 
 static struct mwConference *
-conf_find_by_id(struct mwPurplePluginData *pd, int id);
+conf_find_by_id(struct mwPurpleProtocolData *pd, int id);
 
 
 /* conversation functions */
@@ -316,7 +317,7 @@ static void connect_cb(gpointer data, gi
 
 /** resolves a mwSession from a PurpleConnection */
 static struct mwSession *gc_to_session(PurpleConnection *gc) {
-  struct mwPurplePluginData *pd;
+  struct mwPurpleProtocolData *pd;
 
   g_return_val_if_fail(gc != NULL, NULL);
 
@@ -329,7 +330,7 @@ static struct mwSession *gc_to_session(P
 
 /** resolves a PurpleConnection from a mwSession */
 static PurpleConnection *session_to_gc(struct mwSession *session) {
-  struct mwPurplePluginData *pd;
+  struct mwPurpleProtocolData *pd;
 
   g_return_val_if_fail(session != NULL, NULL);
 
@@ -341,7 +342,7 @@ static PurpleConnection *session_to_gc(s
 
 
 static void write_cb(gpointer data, gint source, PurpleInputCondition cond) {
-  struct mwPurplePluginData *pd = data;
+  struct mwPurpleProtocolData *pd = data;
   PurpleCircularBuffer *circ = pd->sock_buf;
   gsize avail;
   int ret;
@@ -373,7 +374,7 @@ static void write_cb(gpointer data, gint
 
 static int mw_session_io_write(struct mwSession *session,
 			       const guchar *buf, gsize len) {
-  struct mwPurplePluginData *pd;
+  struct mwPurpleProtocolData *pd;
   gssize ret = 0;
   int err = 0;
 
@@ -431,7 +432,7 @@ static int mw_session_io_write(struct mw
 
 
 static void mw_session_io_close(struct mwSession *session) {
-  struct mwPurplePluginData *pd;
+  struct mwPurpleProtocolData *pd;
 
   pd = mwSession_getClientData(session);
   g_return_if_fail(pd != NULL);
@@ -487,7 +488,7 @@ static void mw_aware_list_on_aware(struc
   PurpleConnection *gc;
   PurpleAccount *acct;
 
-  struct mwPurplePluginData *pd;
+  struct mwPurpleProtocolData *pd;
   guint32 idle;
   guint stat;
   const char *id;
@@ -624,7 +625,7 @@ static struct mwAwareListHandler mw_awar
 /** Ensures that an Aware List is associated with the given group, and
     returns that list. */
 static struct mwAwareList *
-list_ensure(struct mwPurplePluginData *pd, PurpleGroup *group) {
+list_ensure(struct mwPurpleProtocolData *pd, PurpleGroup *group) {
 
   struct mwAwareList *list;
 
@@ -741,7 +742,7 @@ static void blist_export(PurpleConnectio
 }
 
 
-static void blist_store(struct mwPurplePluginData *pd) {
+static void blist_store(struct mwPurpleProtocolData *pd) {
 
   struct mwSametimeList *stlist;
   struct mwServiceStorage *srvc;
@@ -794,7 +795,7 @@ static void blist_store(struct mwPurpleP
 
 
 static gboolean blist_save_cb(gpointer data) {
-  struct mwPurplePluginData *pd = data;
+  struct mwPurpleProtocolData *pd = data;
 
   blist_store(pd);
   pd->save_event = 0;
@@ -803,7 +804,7 @@ static gboolean blist_save_cb(gpointer d
 
 
 /** schedules the buddy list to be saved to the server */
-static void blist_schedule(struct mwPurplePluginData *pd) {
+static void blist_schedule(struct mwPurpleProtocolData *pd) {
   if(pd->save_event) return;
 
   pd->save_event = purple_timeout_add_seconds(BLIST_SAVE_SECONDS,
@@ -819,7 +820,7 @@ static gboolean buddy_is_external(Purple
 
 /** Actually add a buddy to the aware service, and schedule the buddy
     list to be saved to the server */
-static void buddy_add(struct mwPurplePluginData *pd,
+static void buddy_add(struct mwPurpleProtocolData *pd,
 		      PurpleBuddy *buddy) {
 
   struct mwAwareIdBlock idb = { mwAware_USER, (char *) purple_buddy_get_name(buddy), NULL };
@@ -848,7 +849,7 @@ static void buddy_add(struct mwPurplePlu
 static PurpleBuddy *buddy_ensure(PurpleConnection *gc, PurpleGroup *group,
 			       struct mwSametimeUser *stuser) {
 
-  struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc);
+  struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc);
   PurpleBuddy *buddy;
   PurpleAccount *acct = purple_connection_get_account(gc);
 
@@ -878,7 +879,7 @@ static PurpleBuddy *buddy_ensure(PurpleC
 
 
 /** add aware watch for a dynamic group */
-static void group_add(struct mwPurplePluginData *pd,
+static void group_add(struct mwPurpleProtocolData *pd,
 		      PurpleGroup *group) {
 
   struct mwAwareIdBlock idb = { mwAware_GROUP, NULL, NULL };
@@ -1227,7 +1228,7 @@ static void fetch_blist_cb(struct mwServ
 			   guint32 result, struct mwStorageUnit *item,
 			   gpointer data) {
 
-  struct mwPurplePluginData *pd = data;
+  struct mwPurpleProtocolData *pd = data;
   struct mwSametimeList *stlist;
 
   struct mwGetBuffer *b;
@@ -1260,7 +1261,7 @@ static void fetch_blist_cb(struct mwServ
 
 /** signal triggered when a conversation is opened in Purple */
 static void conversation_created_cb(PurpleConversation *g_conv,
-				    struct mwPurplePluginData *pd) {
+				    struct mwPurpleProtocolData *pd) {
 
   /* we need to tell the IM service to negotiate features for the
      conversation right away, otherwise it'll wait until the first
@@ -1293,7 +1294,7 @@ static void conversation_created_cb(Purp
 
 
 static void blist_menu_nab(PurpleBlistNode *node, gpointer data) {
-  struct mwPurplePluginData *pd = data;
+  struct mwPurpleProtocolData *pd = data;
   PurpleConnection *gc;
 
   PurpleGroup *group = (PurpleGroup *) node;
@@ -1331,7 +1332,7 @@ static void blist_menu_nab(PurpleBlistNo
     so we use the blist-node-extended-menu signal to trigger this
     handler */
 static void blist_node_menu_cb(PurpleBlistNode *node,
-                               GList **menu, struct mwPurplePluginData *pd) {
+                               GList **menu, struct mwPurpleProtocolData *pd) {
   const char *owner;
   PurpleAccount *acct;
   PurpleMenuAction *act;
@@ -1405,7 +1406,7 @@ static void blist_init(PurpleAccount *ac
 
 
 /** Last thing to happen from a started session */
-static void services_starting(struct mwPurplePluginData *pd) {
+static void services_starting(struct mwPurpleProtocolData *pd) {
 
   PurpleConnection *gc;
   PurpleAccount *acct;
@@ -1457,7 +1458,7 @@ static void services_starting(struct mwP
 
 static void session_loginRedirect(struct mwSession *session,
 				  const char *host) {
-  struct mwPurplePluginData *pd;
+  struct mwPurpleProtocolData *pd;
   PurpleConnection *gc;
   PurpleAccount *account;
   guint port;
@@ -1489,7 +1490,7 @@ static void mw_prpl_set_status(PurpleAcc
 /** called from mw_session_stateChange when the session's state is
     mwSession_STARTED. Any finalizing of start-up stuff should go
     here */
-static void session_started(struct mwPurplePluginData *pd) {
+static void session_started(struct mwPurpleProtocolData *pd) {
   PurpleStatus *status;
   PurpleAccount *acct;
 
@@ -1513,7 +1514,7 @@ static void session_started(struct mwPur
 }
 
 
-static void session_stopping(struct mwPurplePluginData *pd) {
+static void session_stopping(struct mwPurpleProtocolData *pd) {
   /* stop watching the signals from session_started */
   purple_signals_disconnect_by_handle(pd);
 }
@@ -1522,7 +1523,7 @@ static void session_stopping(struct mwPu
 static void mw_session_stateChange(struct mwSession *session,
 				   enum mwSessionState state,
 				   gpointer info) {
-  struct mwPurplePluginData *pd;
+  struct mwPurpleProtocolData *pd;
   PurpleConnection *gc;
   const char *msg = NULL;
 
@@ -1629,7 +1630,7 @@ static void mw_session_stateChange(struc
 
 
 static void mw_session_setPrivacyInfo(struct mwSession *session) {
-  struct mwPurplePluginData *pd;
+  struct mwPurpleProtocolData *pd;
   PurpleConnection *gc;
   PurpleAccount *acct;
   struct mwPrivacyInfo *privacy;
@@ -1675,7 +1676,7 @@ static void mw_session_setPrivacyInfo(st
 
 
 static void mw_session_setUserStatus(struct mwSession *session) {
-  struct mwPurplePluginData *pd;
+  struct mwPurpleProtocolData *pd;
   PurpleConnection *gc;
   struct mwAwareIdBlock idb = { mwAware_USER, NULL, NULL };
   struct mwUserStatus *stat;
@@ -1743,7 +1744,7 @@ static int read_recv(struct mwSession *s
 /** callback triggered from purple_input_add, watches the socked for
     available data to be processed by the session */
 static void read_cb(gpointer data, gint source, PurpleInputCondition cond) {
-  struct mwPurplePluginData *pd = data;
+  struct mwPurpleProtocolData *pd = data;
   int ret = 0, err = 0;
 
   g_return_if_fail(pd != NULL);
@@ -1794,7 +1795,7 @@ static void read_cb(gpointer data, gint 
     in, and if the session logging in receives a redirect message */
 static void connect_cb(gpointer data, gint source, const gchar *error_message) {
 
-  struct mwPurplePluginData *pd = data;
+  struct mwPurpleProtocolData *pd = data;
 
   if(source < 0) {
     /* connection failed */
@@ -1833,7 +1834,7 @@ static void mw_session_announce(struct m



More information about the Commits mailing list