diff options
author | Ankit Vani <a@nevitus.org> | 2014-02-10 01:09:47 +0530 |
---|---|---|
committer | Ankit Vani <a@nevitus.org> | 2014-02-10 01:09:47 +0530 |
commit | e155574f69f20319e5f8c7810812b49cf0491f90 (patch) | |
tree | ca0edaacbc62b5671a57164c29bf6b36dea6e112 /libpurple/protocols/sametime/sametime.c | |
parent | fb3b6d70be9f1d0e0f623fc8249bde9749918ef6 (diff) | |
parent | e290cbed35f7ce0f9bbe2d8fc4520c3033d6ff42 (diff) | |
download | pidgin-e155574f69f20319e5f8c7810812b49cf0491f90.tar.gz |
Merge gtkdoc-conversion
Diffstat (limited to 'libpurple/protocols/sametime/sametime.c')
-rw-r--r-- | libpurple/protocols/sametime/sametime.c | 686 |
1 files changed, 364 insertions, 322 deletions
diff --git a/libpurple/protocols/sametime/sametime.c b/libpurple/protocols/sametime/sametime.c index 88af90163e..cee0ca99e9 100644 --- a/libpurple/protocols/sametime/sametime.c +++ b/libpurple/protocols/sametime/sametime.c @@ -40,8 +40,8 @@ #include "imgstore.h" #include "mime.h" #include "notify.h" -#include "plugin.h" -#include "prpl.h" +#include "plugins.h" +#include "protocol.h" #include "request.h" #include "util.h" #include "version.h" @@ -65,24 +65,32 @@ #include "sametime.h" -/* considering that there's no display of this information for prpls, +static PurpleProtocol *my_protocol = NULL; + +#define PROTOCOL_ID "prpl-meanwhile" +#define PROTOCOL_NAME "Sametime" + + +/* considering that there's no display of this information for protocols, I don't know why I even bother providing these. Oh valiant reader, I do it all for you. */ -/* scratch that, I just added it to the prpl options panel */ -#define PLUGIN_ID "prpl-meanwhile" -#define PLUGIN_NAME "Sametime" +/* scratch that, I just added it to the protocol options panel */ +#define PLUGIN_ID "prpl-sametime" +#define PLUGIN_NAME "Sametime Protocol" +#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@preoccupied.net>" #define PLUGIN_HOMEPAGE "http://meanwhile.sourceforge.net/" +#define PLUGIN_AUTHORS \ + { "Christopher (siege) O'Brien <siege@preoccupied.net>", NULL } /* plugin preference names */ -#define MW_PRPL_OPT_BASE "/plugins/prpl/meanwhile" -#define MW_PRPL_OPT_BLIST_ACTION MW_PRPL_OPT_BASE "/blist_action" -#define MW_PRPL_OPT_PSYCHIC MW_PRPL_OPT_BASE "/psychic" -#define MW_PRPL_OPT_FORCE_LOGIN MW_PRPL_OPT_BASE "/force_login" -#define MW_PRPL_OPT_SAVE_DYNAMIC MW_PRPL_OPT_BASE "/save_dynamic" +#define MW_PROTOCOL_OPT_BASE "/plugins/prpl/meanwhile" +#define MW_PROTOCOL_OPT_BLIST_ACTION MW_PROTOCOL_OPT_BASE "/blist_action" +#define MW_PROTOCOL_OPT_PSYCHIC MW_PROTOCOL_OPT_BASE "/psychic" +#define MW_PROTOCOL_OPT_FORCE_LOGIN MW_PROTOCOL_OPT_BASE "/force_login" +#define MW_PROTOCOL_OPT_SAVE_DYNAMIC MW_PROTOCOL_OPT_BASE "/save_dynamic" /* stages of connecting-ness */ @@ -162,7 +170,7 @@ enum blist_choice { /* testing for the above */ -#define BLIST_PREF_IS(n) (purple_prefs_get_int(MW_PRPL_OPT_BLIST_ACTION)==(n)) +#define BLIST_PREF_IS(n) (purple_prefs_get_int(MW_PROTOCOL_OPT_BLIST_ACTION)==(n)) #define BLIST_PREF_IS_LOCAL() BLIST_PREF_IS(blist_choice_LOCAL) #define BLIST_PREF_IS_MERGE() BLIST_PREF_IS(blist_choice_MERGE) #define BLIST_PREF_IS_STORE() BLIST_PREF_IS(blist_choice_STORE) @@ -197,7 +205,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 +244,9 @@ typedef struct { static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist); -static void blist_store(struct mwPurplePluginData *pd); +static void blist_store(struct mwPurpleProtocolData *pd); -static void blist_schedule(struct mwPurplePluginData *pd); +static void blist_schedule(struct mwPurpleProtocolData *pd); static void blist_merge(PurpleConnection *gc, struct mwSametimeList *stlist); @@ -246,19 +254,19 @@ static void blist_sync(PurpleConnection *gc, struct mwSametimeList *stlist); 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 +280,7 @@ static PurpleConnection *session_to_gc(struct mwSession *session); /* 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 +324,7 @@ static void connect_cb(gpointer data, gint source, const gchar *error_message); /** 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 +337,7 @@ static struct mwSession *gc_to_session(PurpleConnection *gc) { /** 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 +349,7 @@ static PurpleConnection *session_to_gc(struct mwSession *session) { 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 +381,7 @@ static void write_cb(gpointer data, gint source, PurpleInputCondition cond) { 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 +439,7 @@ static int mw_session_io_write(struct mwSession *session, 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 +495,7 @@ static void mw_aware_list_on_aware(struct mwAwareList *list, PurpleConnection *gc; PurpleAccount *acct; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; guint32 idle; guint stat; const char *id; @@ -592,11 +600,11 @@ static void mw_aware_list_on_aware(struct mwAwareList *list, } if(aware->online) { - purple_prpl_got_user_status(acct, id, status, NULL); - purple_prpl_got_user_idle(acct, id, !!idle, (time_t) idle); + purple_protocol_got_user_status(acct, id, status, NULL); + purple_protocol_got_user_idle(acct, id, !!idle, (time_t) idle); } else { - purple_prpl_got_user_status(acct, id, MW_STATE_OFFLINE, NULL); + purple_protocol_got_user_status(acct, id, MW_STATE_OFFLINE, NULL); } } @@ -624,7 +632,7 @@ static struct mwAwareListHandler mw_aware_list_handler = { /** 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 +749,7 @@ static void blist_export(PurpleConnection *gc, struct mwSametimeList *stlist) { } -static void blist_store(struct mwPurplePluginData *pd) { +static void blist_store(struct mwPurpleProtocolData *pd) { struct mwSametimeList *stlist; struct mwServiceStorage *srvc; @@ -794,7 +802,7 @@ static void blist_store(struct mwPurplePluginData *pd) { static gboolean blist_save_cb(gpointer data) { - struct mwPurplePluginData *pd = data; + struct mwPurpleProtocolData *pd = data; blist_store(pd); pd->save_event = 0; @@ -803,7 +811,7 @@ static gboolean blist_save_cb(gpointer data) { /** 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 +827,7 @@ static gboolean buddy_is_external(PurpleBuddy *b) { /** 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 +856,7 @@ static void buddy_add(struct mwPurplePluginData *pd, 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 +886,7 @@ static PurpleBuddy *buddy_ensure(PurpleConnection *gc, PurpleGroup *group, /** 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 +1235,7 @@ static void fetch_blist_cb(struct mwServiceStorage *srvc, guint32 result, struct mwStorageUnit *item, gpointer data) { - struct mwPurplePluginData *pd = data; + struct mwPurpleProtocolData *pd = data; struct mwSametimeList *stlist; struct mwGetBuffer *b; @@ -1260,7 +1268,7 @@ static void fetch_blist_cb(struct mwServiceStorage *srvc, /** 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 +1301,7 @@ static void conversation_created_cb(PurpleConversation *g_conv, static void blist_menu_nab(PurpleBlistNode *node, gpointer data) { - struct mwPurplePluginData *pd = data; + struct mwPurpleProtocolData *pd = data; PurpleConnection *gc; PurpleGroup *group = (PurpleGroup *) node; @@ -1327,11 +1335,11 @@ static void blist_menu_nab(PurpleBlistNode *node, gpointer data) { } -/** The normal blist menu prpl function doesn't get called for groups, +/** The normal blist menu protocol function doesn't get called for groups, 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 +1413,7 @@ static void blist_init(PurpleAccount *acct) { /** 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 +1465,7 @@ static void services_starting(struct mwPurplePluginData *pd) { static void session_loginRedirect(struct mwSession *session, const char *host) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleConnection *gc; PurpleAccount *account; guint port; @@ -1483,20 +1491,20 @@ static void session_loginRedirect(struct mwSession *session, } -static void mw_prpl_set_status(PurpleAccount *acct, PurpleStatus *status); +static void mw_protocol_set_status(PurpleAccount *acct, PurpleStatus *status); /** 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; /* set out initial status */ acct = purple_connection_get_account(pd->gc); status = purple_account_get_active_status(acct); - mw_prpl_set_status(acct, status); + mw_protocol_set_status(acct, status); /* start watching for new conversations */ purple_signal_connect(purple_conversations_get_handle(), @@ -1513,7 +1521,7 @@ static void session_started(struct mwPurplePluginData *pd) { } -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 +1530,7 @@ static void session_stopping(struct mwPurplePluginData *pd) { 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 +1637,7 @@ static void mw_session_stateChange(struct mwSession *session, static void mw_session_setPrivacyInfo(struct mwSession *session) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleConnection *gc; PurpleAccount *acct; struct mwPrivacyInfo *privacy; @@ -1675,7 +1683,7 @@ static void mw_session_setPrivacyInfo(struct mwSession *session) { 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; @@ -1744,7 +1752,7 @@ static int read_recv(struct mwSession *session, int sock) { /** 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); @@ -1795,7 +1803,7 @@ static void read_cb(gpointer data, gint source, PurpleInputCondition cond) { 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 */ @@ -1834,7 +1842,7 @@ static void mw_session_announce(struct mwSession *s, struct mwLoginInfo *from, gboolean may_reply, const char *text) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleAccount *acct; PurpleIMConversation *im; PurpleBuddy *buddy; @@ -1904,7 +1912,7 @@ static void mw_conf_invited(struct mwConference *conf, struct mwServiceConference *srvc; struct mwSession *session; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleConnection *gc; char *c_inviter, *c_name, *c_topic, *c_invitation; @@ -1953,7 +1961,7 @@ static void mw_conf_invited(struct mwConference *conf, static struct mwConference * -conf_find_by_id(struct mwPurplePluginData *pd, int id) { +conf_find_by_id(struct mwPurpleProtocolData *pd, int id) { struct mwServiceConference *srvc = pd->srvc_conf; struct mwConference *conf = NULL; @@ -1978,7 +1986,7 @@ conf_find_by_id(struct mwPurplePluginData *pd, int id) { static void mw_conf_opened(struct mwConference *conf, GList *members) { struct mwServiceConference *srvc; struct mwSession *session; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleConnection *gc; PurpleChatConversation *g_conf; @@ -2009,7 +2017,7 @@ static void mw_conf_opened(struct mwConference *conf, GList *members) { static void mw_conf_closed(struct mwConference *conf, guint32 reason) { struct mwServiceConference *srvc; struct mwSession *session; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleConnection *gc; const char *n = mwConference_getName(conf); @@ -2068,7 +2076,7 @@ static void mw_conf_text(struct mwConference *conf, struct mwServiceConference *srvc; struct mwSession *session; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleConnection *gc; char *esc; @@ -2162,7 +2170,7 @@ static void mw_ft_offered(struct mwFileTransfer *ft) { struct mwServiceFileTransfer *srvc; struct mwSession *session; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleConnection *gc; PurpleAccount *acct; const char *who; @@ -2401,7 +2409,7 @@ static void convo_data_new(struct mwConversation *conv) { static PurpleIMConversation *convo_get_im(struct mwConversation *conv) { struct mwServiceIm *srvc; struct mwSession *session; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleConnection *gc; PurpleAccount *acct; @@ -2550,7 +2558,7 @@ static void convo_features(struct mwConversation *conv) { static void mw_conversation_opened(struct mwConversation *conv) { struct mwServiceIm *srvc; struct mwSession *session; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleConnection *gc; PurpleAccount *acct; @@ -2625,7 +2633,7 @@ static void mw_conversation_closed(struct mwConversation *conv, static void im_recv_text(struct mwConversation *conv, - struct mwPurplePluginData *pd, + struct mwPurpleProtocolData *pd, const char *msg) { struct mwIdBlock *idb; @@ -2646,7 +2654,7 @@ static void im_recv_text(struct mwConversation *conv, static void im_recv_typing(struct mwConversation *conv, - struct mwPurplePluginData *pd, + struct mwPurpleProtocolData *pd, gboolean typing) { struct mwIdBlock *idb; @@ -2658,7 +2666,7 @@ static void im_recv_typing(struct mwConversation *conv, static void im_recv_html(struct mwConversation *conv, - struct mwPurplePluginData *pd, + struct mwPurpleProtocolData *pd, const char *msg) { struct mwIdBlock *idb; char *t1, *t2; @@ -2682,7 +2690,7 @@ static void im_recv_html(struct mwConversation *conv, static void im_recv_subj(struct mwConversation *conv, - struct mwPurplePluginData *pd, + struct mwPurpleProtocolData *pd, const char *subj) { /** @todo somehow indicate receipt of a conversation subject. It @@ -2711,7 +2719,7 @@ static char *make_cid(const char *cid) { static void im_recv_mime(struct mwConversation *conv, - struct mwPurplePluginData *pd, + struct mwPurpleProtocolData *pd, const char *data) { GHashTable *img_by_cid; @@ -2765,7 +2773,7 @@ static void im_recv_mime(struct mwConversation *conv, g_path_get_basename() and purple_escape_filename() on it before passing it in. This is easy, but it's not clear if there might be other implications because this filename is used elsewhere within - this PRPL. */ + this protocol. */ img = purple_imgstore_new_with_id(d_dat, d_len, cid); /* map the cid to the image store identifier */ @@ -2850,7 +2858,7 @@ static void mw_conversation_recv(struct mwConversation *conv, gconstpointer msg) { struct mwServiceIm *srvc; struct mwSession *session; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; srvc = mwConversation_getService(conv); session = mwService_getSession(MW_SERVICE(srvc)); @@ -2889,7 +2897,7 @@ static void mw_place_invite(struct mwConversation *conv, const char *title, const char *name) { struct mwServiceIm *srvc; struct mwSession *session; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwIdBlock *idb; GHashTable *ht; @@ -2950,7 +2958,7 @@ static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) { static struct mwPlace * -place_find_by_id(struct mwPurplePluginData *pd, int id) { +place_find_by_id(struct mwPurpleProtocolData *pd, int id) { struct mwServicePlace *srvc = pd->srvc_place; struct mwPlace *place = NULL; GList *l; @@ -2973,7 +2981,7 @@ place_find_by_id(struct mwPurplePluginData *pd, int id) { static void mw_place_opened(struct mwPlace *place) { struct mwServicePlace *srvc; struct mwSession *session; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleConnection *gc; PurpleChatConversation *gconf; @@ -3009,7 +3017,7 @@ static void mw_place_opened(struct mwPlace *place) { static void mw_place_closed(struct mwPlace *place, guint32 code) { struct mwServicePlace *srvc; struct mwSession *session; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleConnection *gc; const char *n = mwPlace_getName(place); @@ -3080,7 +3088,7 @@ static void mw_place_message(struct mwPlace *place, const char *msg) { struct mwServicePlace *srvc; struct mwSession *session; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleConnection *gc; char *esc; @@ -3135,13 +3143,13 @@ static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) { } -/** allocate and associate a mwPurplePluginData with a PurpleConnection */ -static struct mwPurplePluginData *mwPurplePluginData_new(PurpleConnection *gc) { - struct mwPurplePluginData *pd; +/** allocate and associate a mwPurpleProtocolData with a PurpleConnection */ +static struct mwPurpleProtocolData *mwPurpleProtocolData_new(PurpleConnection *gc) { + struct mwPurpleProtocolData *pd; g_return_val_if_fail(gc != NULL, NULL); - pd = g_new0(struct mwPurplePluginData, 1); + pd = g_new0(struct mwPurpleProtocolData, 1); pd->gc = gc; pd->session = mwSession_new(&mw_session_handler); pd->srvc_aware = mw_srvc_aware_new(pd->session); @@ -3172,7 +3180,7 @@ static struct mwPurplePluginData *mwPurplePluginData_new(PurpleConnection *gc) { } -static void mwPurplePluginData_free(struct mwPurplePluginData *pd) { +static void mwPurpleProtocolData_free(struct mwPurpleProtocolData *pd) { g_return_if_fail(pd != NULL); purple_connection_set_protocol_data(pd->gc, NULL); @@ -3205,7 +3213,7 @@ static void mwPurplePluginData_free(struct mwPurplePluginData *pd) { } -static const char *mw_prpl_list_icon(PurpleAccount *a, PurpleBuddy *b) { +static const char *mw_protocol_list_icon(PurpleAccount *a, PurpleBuddy *b) { /* my little green dude is a chopped up version of the aim running guy. First, cut off the head and store someplace safe. Then, take the left-half side of the body and throw it away. Make a @@ -3221,7 +3229,7 @@ static const char *mw_prpl_list_icon(PurpleAccount *a, PurpleBuddy *b) { } -static const char* mw_prpl_list_emblem(PurpleBuddy *b) +static const char* mw_protocol_list_emblem(PurpleBuddy *b) { if(buddy_is_external(b)) return "external"; @@ -3230,9 +3238,9 @@ static const char* mw_prpl_list_emblem(PurpleBuddy *b) } -static char *mw_prpl_status_text(PurpleBuddy *b) { +static char *mw_protocol_status_text(PurpleBuddy *b) { PurpleConnection *gc; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwAwareIdBlock t = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; const char *ret = NULL; @@ -3290,9 +3298,9 @@ static char *user_supports_text(struct mwServiceAware *srvc, const char *who) { } -static void mw_prpl_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { +static void mw_protocol_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { PurpleConnection *gc; - struct mwPurplePluginData *pd = NULL; + struct mwPurpleProtocolData *pd = NULL; struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; const char *message = NULL; @@ -3325,7 +3333,7 @@ static void mw_prpl_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info } } -static GList *mw_prpl_status_types(PurpleAccount *acct) +static GList *mw_protocol_status_types(PurpleAccount *acct) { GList *types = NULL; PurpleStatusType *type; @@ -3366,7 +3374,7 @@ static void conf_create_prompt_join(PurpleBuddy *buddy, PurpleRequestFields *fields) { PurpleAccount *acct; PurpleConnection *gc; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwServiceConference *srvc; PurpleRequestField *f; @@ -3531,7 +3539,7 @@ static void blist_menu_conf(PurpleBlistNode *node, gpointer data) { PurpleBuddy *buddy = (PurpleBuddy *) node; PurpleAccount *acct; PurpleConnection *gc; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; GList *l; g_return_if_fail(node != NULL); @@ -3568,7 +3576,7 @@ static void blist_menu_announce(PurpleBlistNode *node, gpointer data) { PurpleBuddy *buddy = (PurpleBuddy *) node; PurpleAccount *acct; PurpleConnection *gc; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwSession *session; char *rcpt_name; GList *rcpt; @@ -3599,7 +3607,7 @@ static void blist_menu_announce(PurpleBlistNode *node, gpointer data) { #endif -static GList *mw_prpl_blist_node_menu(PurpleBlistNode *node) { +static GList *mw_protocol_blist_node_menu(PurpleBlistNode *node) { GList *l = NULL; PurpleMenuAction *act; @@ -3627,11 +3635,11 @@ static GList *mw_prpl_blist_node_menu(PurpleBlistNode *node) { } -static GList *mw_prpl_chat_info(PurpleConnection *gc) { +static GList *mw_protocol_chat_info(PurpleConnection *gc) { GList *l = NULL; - struct proto_chat_entry *pce; + PurpleProtocolChatEntry *pce; - pce = g_new0(struct proto_chat_entry, 1); + pce = g_new0(PurpleProtocolChatEntry, 1); pce->label = _("Topic:"); pce->identifier = CHAT_KEY_TOPIC; l = g_list_append(l, pce); @@ -3640,7 +3648,7 @@ static GList *mw_prpl_chat_info(PurpleConnection *gc) { } -static GHashTable *mw_prpl_chat_info_defaults(PurpleConnection *gc, +static GHashTable *mw_protocol_chat_info_defaults(PurpleConnection *gc, const char *name) { GHashTable *table; @@ -3656,18 +3664,18 @@ static GHashTable *mw_prpl_chat_info_defaults(PurpleConnection *gc, } -static void mw_prpl_login(PurpleAccount *acct); +static void mw_protocol_login(PurpleAccount *acct); -static void mw_prpl_login(PurpleAccount *account) { +static void mw_protocol_login(PurpleAccount *account) { PurpleConnection *gc; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; char *user, *pass, *host; guint port; gc = purple_account_get_connection(account); - pd = mwPurplePluginData_new(gc); + pd = mwPurpleProtocolData_new(gc); /* while we do support images, the default is to not offer it */ purple_connection_set_flags(gc, PURPLE_CONNECTION_FLAG_NO_IMAGES); @@ -3741,8 +3749,8 @@ static void mw_prpl_login(PurpleAccount *account) { } -static void mw_prpl_close(PurpleConnection *gc) { - struct mwPurplePluginData *pd; +static void mw_protocol_close(PurpleConnection *gc) { + struct mwPurpleProtocolData *pd; g_return_if_fail(gc != NULL); @@ -3769,7 +3777,7 @@ static void mw_prpl_close(PurpleConnection *gc) { } /* clean up the rest */ - mwPurplePluginData_free(pd); + mwPurpleProtocolData_free(pd); } @@ -3941,12 +3949,12 @@ static char *im_mime_convert(PurpleConnection *gc, } -static int mw_prpl_send_im(PurpleConnection *gc, +static int mw_protocol_send_im(PurpleConnection *gc, const char *name, const char *message, PurpleMessageFlags flags) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwIdBlock who = { (char *) name, NULL }; struct mwConversation *conv; @@ -4015,11 +4023,11 @@ static int mw_prpl_send_im(PurpleConnection *gc, } -static unsigned int mw_prpl_send_typing(PurpleConnection *gc, +static unsigned int mw_protocol_send_typing(PurpleConnection *gc, const char *name, PurpleIMTypingState state) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwIdBlock who = { (char *) name, NULL }; struct mwConversation *conv; @@ -4108,11 +4116,11 @@ static const char *mw_client_name(guint16 type) { } -static void mw_prpl_get_info(PurpleConnection *gc, const char *who) { +static void mw_protocol_get_info(PurpleConnection *gc, const char *who) { struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleAccount *acct; PurpleBuddy *b; PurpleNotifyUserInfo *user_info; @@ -4181,7 +4189,7 @@ static void mw_prpl_get_info(PurpleConnection *gc, const char *who) { } -static void mw_prpl_set_status(PurpleAccount *acct, PurpleStatus *status) { +static void mw_protocol_set_status(PurpleAccount *acct, PurpleStatus *status) { PurpleConnection *gc; const char *state; char *message = NULL; @@ -4234,7 +4242,7 @@ static void mw_prpl_set_status(PurpleAccount *acct, PurpleStatus *status) { } -static void mw_prpl_set_idle(PurpleConnection *gc, int t) { +static void mw_protocol_set_idle(PurpleConnection *gc, int t) { struct mwSession *session; struct mwUserStatus stat; @@ -4360,7 +4368,7 @@ static void add_buddy_resolved(struct mwServiceResolve *srvc, BuddyAddData *data = b; PurpleBuddy *buddy = NULL; PurpleConnection *gc; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; g_return_if_fail(data != NULL); @@ -4444,12 +4452,12 @@ static void add_buddy_resolved(struct mwServiceResolve *srvc, } -static void mw_prpl_add_buddy(PurpleConnection *gc, +static void mw_protocol_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group, const char *message) { - struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); + struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); struct mwServiceResolve *srvc; GList *query; enum mwResolveFlag flags; @@ -4483,7 +4491,7 @@ static void mw_prpl_add_buddy(PurpleConnection *gc, static void foreach_add_buddies(PurpleGroup *group, GList *buddies, - struct mwPurplePluginData *pd) { + struct mwPurpleProtocolData *pd) { struct mwAwareList *list; list = list_ensure(pd, group); @@ -4492,12 +4500,12 @@ static void foreach_add_buddies(PurpleGroup *group, GList *buddies, } -static void mw_prpl_add_buddies(PurpleConnection *gc, +static void mw_protocol_add_buddies(PurpleConnection *gc, GList *buddies, GList *groups, const char *message) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; GHashTable *group_sets; struct mwAwareIdBlock *idbs, *idb; @@ -4543,10 +4551,10 @@ static void mw_prpl_add_buddies(PurpleConnection *gc, } -static void mw_prpl_remove_buddy(PurpleConnection *gc, +static void mw_protocol_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; struct mwAwareList *list; @@ -4583,9 +4591,9 @@ static void privacy_fill(struct mwPrivacyInfo *priv, } -static void mw_prpl_set_permit_deny(PurpleConnection *gc) { +static void mw_protocol_set_permit_deny(PurpleConnection *gc) { PurpleAccount *acct; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwSession *session; struct mwPrivacyInfo privacy = { @@ -4638,23 +4646,23 @@ static void mw_prpl_set_permit_deny(PurpleConnection *gc) { } -static void mw_prpl_add_permit(PurpleConnection *gc, const char *name) { - mw_prpl_set_permit_deny(gc); +static void mw_protocol_add_permit(PurpleConnection *gc, const char *name) { + mw_protocol_set_permit_deny(gc); } -static void mw_prpl_add_deny(PurpleConnection *gc, const char *name) { - mw_prpl_set_permit_deny(gc); +static void mw_protocol_add_deny(PurpleConnection *gc, const char *name) { + mw_protocol_set_permit_deny(gc); } -static void mw_prpl_rem_permit(PurpleConnection *gc, const char *name) { - mw_prpl_set_permit_deny(gc); +static void mw_protocol_rem_permit(PurpleConnection *gc, const char *name) { + mw_protocol_set_permit_deny(gc); } -static void mw_prpl_rem_deny(PurpleConnection *gc, const char *name) { - mw_prpl_set_permit_deny(gc); +static void mw_protocol_rem_deny(PurpleConnection *gc, const char *name) { + mw_protocol_set_permit_deny(gc); } @@ -4677,10 +4685,10 @@ static struct mwConference *conf_find(struct mwServiceConference *srvc, } -static void mw_prpl_join_chat(PurpleConnection *gc, +static void mw_protocol_join_chat(PurpleConnection *gc, GHashTable *components) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; char *c, *t; pd = purple_connection_get_protocol_data(gc); @@ -4718,10 +4726,10 @@ static void mw_prpl_join_chat(PurpleConnection *gc, } -static void mw_prpl_reject_chat(PurpleConnection *gc, +static void mw_protocol_reject_chat(PurpleConnection *gc, GHashTable *components) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwServiceConference *srvc; char *c; @@ -4742,17 +4750,17 @@ static void mw_prpl_reject_chat(PurpleConnection *gc, } -static char *mw_prpl_get_chat_name(GHashTable *components) { +static char *mw_protocol_get_chat_name(GHashTable *components) { return g_hash_table_lookup(components, CHAT_KEY_NAME); } -static void mw_prpl_chat_invite(PurpleConnection *gc, +static void mw_protocol_chat_invite(PurpleConnection *gc, int id, const char *invitation, const char *who) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwConference *conf; struct mwPlace *place; struct mwIdBlock idb = { (char *) who, NULL }; @@ -4775,10 +4783,10 @@ static void mw_prpl_chat_invite(PurpleConnection *gc, } -static void mw_prpl_chat_leave(PurpleConnection *gc, +static void mw_protocol_chat_leave(PurpleConnection *gc, int id) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwConference *conf; pd = purple_connection_get_protocol_data(gc); @@ -4798,21 +4806,21 @@ static void mw_prpl_chat_leave(PurpleConnection *gc, } -static void mw_prpl_chat_whisper(PurpleConnection *gc, +static void mw_protocol_chat_whisper(PurpleConnection *gc, int id, const char *who, const char *message) { - mw_prpl_send_im(gc, who, message, 0); + mw_protocol_send_im(gc, who, message, 0); } -static int mw_prpl_chat_send(PurpleConnection *gc, +static int mw_protocol_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwConference *conf; char *msg; int ret; @@ -4839,7 +4847,7 @@ static int mw_prpl_chat_send(PurpleConnection *gc, } -static void mw_prpl_keepalive(PurpleConnection *gc) { +static void mw_protocol_keepalive(PurpleConnection *gc) { struct mwSession *session; g_return_if_fail(gc != NULL); @@ -4851,11 +4859,11 @@ static void mw_prpl_keepalive(PurpleConnection *gc) { } -static void mw_prpl_alias_buddy(PurpleConnection *gc, +static void mw_protocol_alias_buddy(PurpleConnection *gc, const char *who, const char *alias) { - struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); + struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); g_return_if_fail(pd != NULL); /* it's a change to the buddy list, so we've gotta reflect that in @@ -4865,7 +4873,7 @@ static void mw_prpl_alias_buddy(PurpleConnection *gc, } -static void mw_prpl_group_buddy(PurpleConnection *gc, +static void mw_protocol_group_buddy(PurpleConnection *gc, const char *who, const char *old_group, const char *new_group) { @@ -4873,7 +4881,7 @@ static void mw_prpl_group_buddy(PurpleConnection *gc, struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; GList *gl = g_list_prepend(NULL, &idb); - struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); + struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); PurpleGroup *group; struct mwAwareList *list; @@ -4894,12 +4902,12 @@ static void mw_prpl_group_buddy(PurpleConnection *gc, } -static void mw_prpl_rename_group(PurpleConnection *gc, +static void mw_protocol_rename_group(PurpleConnection *gc, const char *old, PurpleGroup *group, GList *buddies) { - struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); + struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); g_return_if_fail(pd != NULL); /* it's a change in the buddy list, so we've gotta reflect that in @@ -4912,14 +4920,14 @@ static void mw_prpl_rename_group(PurpleConnection *gc, } -static void mw_prpl_buddy_free(PurpleBuddy *buddy) { +static void mw_protocol_buddy_free(PurpleBuddy *buddy) { /* I don't think we have any cleanup for buddies yet */ ; } -static void mw_prpl_convo_closed(PurpleConnection *gc, const char *who) { - struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); +static void mw_protocol_convo_closed(PurpleConnection *gc, const char *who) { + struct mwPurpleProtocolData *pd = purple_connection_get_protocol_data(gc); struct mwServiceIm *srvc; struct mwConversation *conv; struct mwIdBlock idb = { (char *) who, NULL }; @@ -4937,7 +4945,7 @@ static void mw_prpl_convo_closed(PurpleConnection *gc, const char *who) { } -static const char *mw_prpl_normalize(const PurpleAccount *account, +static const char *mw_protocol_normalize(const PurpleAccount *account, const char *id) { /* code elsewhere assumes that the return value points to different @@ -4950,8 +4958,8 @@ static const char *mw_prpl_normalize(const PurpleAccount *account, } -static void mw_prpl_remove_group(PurpleConnection *gc, PurpleGroup *group) { - struct mwPurplePluginData *pd; +static void mw_protocol_remove_group(PurpleConnection *gc, PurpleGroup *group) { + struct mwPurpleProtocolData *pd; struct mwAwareList *list; pd = purple_connection_get_protocol_data(gc); @@ -4970,9 +4978,9 @@ static void mw_prpl_remove_group(PurpleConnection *gc, PurpleGroup *group) { } -static gboolean mw_prpl_can_receive_file(PurpleConnection *gc, +static gboolean mw_protocol_can_receive_file(PurpleConnection *gc, const char *who) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwServiceAware *srvc; PurpleAccount *acct; @@ -4996,7 +5004,7 @@ static void ft_outgoing_init(PurpleXfer *xfer) { PurpleAccount *acct; PurpleConnection *gc; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwServiceFileTransfer *srvc; struct mwFileTransfer *ft; @@ -5059,7 +5067,7 @@ static void ft_outgoing_cancel(PurpleXfer *xfer) { } -static PurpleXfer *mw_prpl_new_xfer(PurpleConnection *gc, const char *who) { +static PurpleXfer *mw_protocol_new_xfer(PurpleConnection *gc, const char *who) { PurpleAccount *acct; PurpleXfer *xfer; @@ -5075,10 +5083,10 @@ static PurpleXfer *mw_prpl_new_xfer(PurpleConnection *gc, const char *who) { return xfer; } -static void mw_prpl_send_file(PurpleConnection *gc, +static void mw_protocol_send_file(PurpleConnection *gc, const char *who, const char *file) { - PurpleXfer *xfer = mw_prpl_new_xfer(gc, who); + PurpleXfer *xfer = mw_protocol_new_xfer(gc, who); if(file) { DEBUG_INFO("file != NULL\n"); @@ -5090,82 +5098,6 @@ static void mw_prpl_send_file(PurpleConnection *gc, } } - -static PurplePluginProtocolInfo mw_prpl_info = { - sizeof(PurplePluginProtocolInfo), - OPT_PROTO_IM_IMAGE, - NULL, /*< set in mw_plugin_init */ - NULL, /*< set in mw_plugin_init */ - NO_BUDDY_ICONS, - mw_prpl_list_icon, - mw_prpl_list_emblem, - mw_prpl_status_text, - mw_prpl_tooltip_text, - mw_prpl_status_types, - mw_prpl_blist_node_menu, - mw_prpl_chat_info, - mw_prpl_chat_info_defaults, - mw_prpl_login, - mw_prpl_close, - mw_prpl_send_im, - NULL, - mw_prpl_send_typing, - mw_prpl_get_info, - mw_prpl_set_status, - mw_prpl_set_idle, - NULL, - mw_prpl_add_buddy, - mw_prpl_add_buddies, - mw_prpl_remove_buddy, - NULL, - mw_prpl_add_permit, - mw_prpl_add_deny, - mw_prpl_rem_permit, - mw_prpl_rem_deny, - mw_prpl_set_permit_deny, - mw_prpl_join_chat, - mw_prpl_reject_chat, - mw_prpl_get_chat_name, - mw_prpl_chat_invite, - mw_prpl_chat_leave, - mw_prpl_chat_whisper, - mw_prpl_chat_send, - mw_prpl_keepalive, - NULL, - NULL, - mw_prpl_alias_buddy, - mw_prpl_group_buddy, - mw_prpl_rename_group, - mw_prpl_buddy_free, - mw_prpl_convo_closed, - mw_prpl_normalize, - NULL, - mw_prpl_remove_group, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - mw_prpl_can_receive_file, - mw_prpl_send_file, - mw_prpl_new_xfer, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - #if 0 static PurplePluginPrefFrame * mw_plugin_get_plugin_pref_frame(PurplePlugin *plugin) { @@ -5178,7 +5110,7 @@ mw_plugin_get_plugin_pref_frame(PurplePlugin *plugin) { purple_plugin_pref_frame_add(frame, pref); - pref = purple_plugin_pref_new_with_name(MW_PRPL_OPT_BLIST_ACTION); + pref = purple_plugin_pref_new_with_name(MW_PROTOCOL_OPT_BLIST_ACTION); purple_plugin_pref_set_label(pref, _("Buddy List Storage Mode")); purple_plugin_pref_set_pref_type(pref, PURPLE_PLUGIN_PREF_CHOICE); @@ -5225,12 +5157,12 @@ static void st_import_action_cb(PurpleConnection *gc, char *filename) { /** prompts for a file to import blist from */ -static void st_import_action(PurplePluginAction *act) { +static void st_import_action(PurpleProtocolAction *act) { PurpleConnection *gc; PurpleAccount *account; char *title; - gc = act->context; + gc = act->connection; account = purple_connection_get_account(gc); title = g_strdup_printf(_("Import Sametime List for Account %s"), purple_account_get_username(account)); @@ -5265,12 +5197,12 @@ static void st_export_action_cb(PurpleConnection *gc, char *filename) { /** prompts for a file to export blist to */ -static void st_export_action(PurplePluginAction *act) { +static void st_export_action(PurpleProtocolAction *act) { PurpleConnection *gc; PurpleAccount *account; char *title; - gc = act->context; + gc = act->connection; account = purple_connection_get_account(gc); title = g_strdup_printf(_("Export Sametime List for Account %s"), purple_account_get_username(account)); @@ -5306,7 +5238,7 @@ static void remote_group_multi_cleanup(gpointer ignore, } -static void remote_group_done(struct mwPurplePluginData *pd, +static void remote_group_done(struct mwPurpleProtocolData *pd, const char *id, const char *name) { PurpleConnection *gc; PurpleAccount *acct; @@ -5352,7 +5284,7 @@ static void remote_group_done(struct mwPurplePluginData *pd, } -static void remote_group_multi_cb(struct mwPurplePluginData *pd, +static void remote_group_multi_cb(struct mwPurpleProtocolData *pd, PurpleRequestFields *fields) { PurpleRequestField *f; GList *l; @@ -5373,7 +5305,7 @@ static void remote_group_multi_cb(struct mwPurplePluginData *pd, static void remote_group_multi(struct mwResolveResult *result, - struct mwPurplePluginData *pd) { + struct mwPurpleProtocolData *pd) { PurpleRequestFields *fields; PurpleRequestFieldGroup *g; @@ -5429,7 +5361,7 @@ static void remote_group_resolved(struct mwServiceResolve *srvc, struct mwResolveResult *res = NULL; struct mwSession *session; - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; PurpleConnection *gc; session = mwService_getSession(MW_SERVICE(srvc)); @@ -5470,7 +5402,7 @@ static void remote_group_resolved(struct mwServiceResolve *srvc, static void remote_group_action_cb(PurpleConnection *gc, const char *name) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwServiceResolve *srvc; GList *query; enum mwResolveFlag flags; @@ -5492,12 +5424,12 @@ static void remote_group_action_cb(PurpleConnection *gc, const char *name) { } -static void remote_group_action(PurplePluginAction *act) { +static void remote_group_action(PurpleProtocolAction *act) { PurpleConnection *gc; const char *msgA; const char *msgB; - gc = act->context; + gc = act->connection; msgA = _("Notes Address Book Group"); msgB = _("Enter the name of a Notes Address Book group in the field below" @@ -5596,7 +5528,7 @@ static void search_resolved(struct mwServiceResolve *srvc, static void search_action_cb(PurpleConnection *gc, const char *name) { - struct mwPurplePluginData *pd; + struct mwPurpleProtocolData *pd; struct mwServiceResolve *srvc; GList *query; enum mwResolveFlag flags; @@ -5618,12 +5550,12 @@ static void search_action_cb(PurpleConnection *gc, const char *name) { } -static void search_action(PurplePluginAction *act) { +static void search_action(PurpleProtocolAction *act) { PurpleConnection *gc; const char *msgA; const char *msgB; - gc = act->context; + gc = act->connection; msgA = _("Search for a user"); msgB = _("Enter a name or partial ID in the field below to search" @@ -5638,23 +5570,23 @@ static void search_action(PurplePluginAction *act) { } -static GList *mw_plugin_actions(PurplePlugin *plugin, gpointer context) { - PurplePluginAction *act; +static GList *mw_protocol_get_actions(PurpleConnection *gc) { + PurpleProtocolAction *act; GList *l = NULL; - act = purple_plugin_action_new(_("Import Sametime List..."), + act = purple_protocol_action_new(_("Import Sametime List..."), st_import_action); l = g_list_append(l, act); - act = purple_plugin_action_new(_("Export Sametime List..."), + act = purple_protocol_action_new(_("Export Sametime List..."), st_export_action); l = g_list_append(l, act); - act = purple_plugin_action_new(_("Add Notes Address Book Group..."), + act = purple_protocol_action_new(_("Add Notes Address Book Group..."), remote_group_action); l = g_list_append(l, act); - act = purple_plugin_action_new(_("User Search..."), + act = purple_protocol_action_new(_("User Search..."), search_action); l = g_list_append(l, act); @@ -5662,57 +5594,6 @@ static GList *mw_plugin_actions(PurplePlugin *plugin, gpointer context) { } -static gboolean mw_plugin_load(PurplePlugin *plugin) { - return TRUE; -} - - -static gboolean mw_plugin_unload(PurplePlugin *plugin) { - return TRUE; -} - - -static void mw_plugin_destroy(PurplePlugin *plugin) { - g_log_remove_handler(G_LOG_DOMAIN, log_handler[0]); - g_log_remove_handler("meanwhile", log_handler[1]); -} - -static PurplePluginInfo mw_plugin_info = -{ - PURPLE_PLUGIN_MAGIC, - PURPLE_MAJOR_VERSION, - PURPLE_MINOR_VERSION, - PURPLE_PLUGIN_PROTOCOL, /**< type */ - NULL, /**< ui_requirement */ - 0, /**< flags */ - NULL, /**< dependencies */ - PURPLE_PRIORITY_DEFAULT, /**< priority */ - - PLUGIN_ID, /**< id */ - PLUGIN_NAME, /**< name */ - DISPLAY_VERSION, /**< version */ - PLUGIN_SUMMARY, /**< summary */ - PLUGIN_DESC, /**< description */ - PLUGIN_AUTHOR, /**< author */ - PLUGIN_HOMEPAGE, /**< homepage */ - - mw_plugin_load, /**< load */ - mw_plugin_unload, /**< unload */ - mw_plugin_destroy, /**< destroy */ - - NULL, /**< ui_info */ - &mw_prpl_info, /**< extra_info */ - NULL, /**< prefs_info */ - mw_plugin_actions, - - /* padding */ - NULL, - NULL, - NULL, - NULL -}; - - static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, const gchar *msg, gpointer data) { @@ -5731,30 +5612,33 @@ static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, } -static void mw_plugin_init(PurplePlugin *plugin) { +static void +mw_protocol_init(PurpleProtocol *protocol) +{ PurpleAccountUserSplit *split; PurpleAccountOption *opt; GList *l = NULL; - GLogLevelFlags logflags = - G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; + protocol->id = PROTOCOL_ID; + protocol->name = PROTOCOL_NAME; + protocol->options = OPT_PROTO_IM_IMAGE; /* set up the preferences */ - purple_prefs_add_none(MW_PRPL_OPT_BASE); - purple_prefs_add_int(MW_PRPL_OPT_BLIST_ACTION, BLIST_CHOICE_DEFAULT); + purple_prefs_add_none(MW_PROTOCOL_OPT_BASE); + purple_prefs_add_int(MW_PROTOCOL_OPT_BLIST_ACTION, BLIST_CHOICE_DEFAULT); /* set up account ID as user:server */ split = purple_account_user_split_new(_("Server"), MW_PLUGIN_DEFAULT_HOST, ':'); - mw_prpl_info.user_splits = g_list_append(mw_prpl_info.user_splits, split); + protocol->user_splits = g_list_append(protocol->user_splits, split); /* remove dead preferences */ - purple_prefs_remove(MW_PRPL_OPT_PSYCHIC); - purple_prefs_remove(MW_PRPL_OPT_SAVE_DYNAMIC); + purple_prefs_remove(MW_PROTOCOL_OPT_PSYCHIC); + purple_prefs_remove(MW_PROTOCOL_OPT_SAVE_DYNAMIC); /* port to connect to */ opt = purple_account_option_int_new(_("Port"), MW_KEY_PORT, - MW_PLUGIN_DEFAULT_PORT); + MW_PLUGIN_DEFAULT_PORT); l = g_list_append(l, opt); { /* copy the old force login setting from prefs if it's @@ -5763,8 +5647,8 @@ static void mw_plugin_init(PurplePlugin *plugin) { gboolean b = FALSE; const char *label = _("Force login (ignore server redirects)"); - if(purple_prefs_exists(MW_PRPL_OPT_FORCE_LOGIN)) - b = purple_prefs_get_bool(MW_PRPL_OPT_FORCE_LOGIN); + if(purple_prefs_exists(MW_PROTOCOL_OPT_FORCE_LOGIN)) + b = purple_prefs_get_bool(MW_PROTOCOL_OPT_FORCE_LOGIN); opt = purple_account_option_bool_new(label, MW_KEY_FORCE, b); l = g_list_append(l, opt); @@ -5772,24 +5656,182 @@ static void mw_plugin_init(PurplePlugin *plugin) { /* pretend to be Sametime Connect */ opt = purple_account_option_bool_new(_("Hide client identity"), - MW_KEY_FAKE_IT, FALSE); + MW_KEY_FAKE_IT, FALSE); l = g_list_append(l, opt); - mw_prpl_info.protocol_options = l; + protocol->account_options = l; l = NULL; +} + + +static void +mw_protocol_class_init(PurpleProtocolClass *klass) +{ + klass->login = mw_protocol_login; + klass->close = mw_protocol_close; + klass->status_types = mw_protocol_status_types; + klass->list_icon = mw_protocol_list_icon; +} + + +static void +mw_protocol_client_iface_init(PurpleProtocolClientIface *client_iface) +{ + client_iface->get_actions = mw_protocol_get_actions; + client_iface->list_emblem = mw_protocol_list_emblem; + client_iface->status_text = mw_protocol_status_text; + client_iface->tooltip_text = mw_protocol_tooltip_text; + client_iface->blist_node_menu = mw_protocol_blist_node_menu; + client_iface->buddy_free = mw_protocol_buddy_free; + client_iface->convo_closed = mw_protocol_convo_closed; + client_iface->normalize = mw_protocol_normalize; +} + + +static void +mw_protocol_server_iface_init(PurpleProtocolServerIface *server_iface) +{ + server_iface->get_info = mw_protocol_get_info; + server_iface->set_status = mw_protocol_set_status; + server_iface->set_idle = mw_protocol_set_idle; + server_iface->add_buddy = mw_protocol_add_buddy; + server_iface->add_buddies = mw_protocol_add_buddies; + server_iface->remove_buddy = mw_protocol_remove_buddy; + server_iface->keepalive = mw_protocol_keepalive; + server_iface->alias_buddy = mw_protocol_alias_buddy; + server_iface->group_buddy = mw_protocol_group_buddy; + server_iface->rename_group = mw_protocol_rename_group; + server_iface->remove_group = mw_protocol_remove_group; +} + + +static void +mw_protocol_im_iface_init(PurpleProtocolIMIface *im_iface) +{ + im_iface->send = mw_protocol_send_im; + im_iface->send_typing = mw_protocol_send_typing; +} + + +static void +mw_protocol_chat_iface_init(PurpleProtocolChatIface *chat_iface) +{ + chat_iface->info = mw_protocol_chat_info; + chat_iface->info_defaults = mw_protocol_chat_info_defaults; + chat_iface->join = mw_protocol_join_chat; + chat_iface->reject = mw_protocol_reject_chat; + chat_iface->get_name = mw_protocol_get_chat_name; + chat_iface->invite = mw_protocol_chat_invite; + chat_iface->leave = mw_protocol_chat_leave; + chat_iface->whisper = mw_protocol_chat_whisper; + chat_iface->send = mw_protocol_chat_send; +} + + +static void +mw_protocol_privacy_iface_init(PurpleProtocolPrivacyIface *privacy_iface) +{ + privacy_iface->add_permit = mw_protocol_add_permit; + privacy_iface->add_deny = mw_protocol_add_deny; + privacy_iface->rem_permit = mw_protocol_rem_permit; + privacy_iface->rem_deny = mw_protocol_rem_deny; + privacy_iface->set_permit_deny = mw_protocol_set_permit_deny; +} + + +static void +mw_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface) +{ + xfer_iface->can_receive = mw_protocol_can_receive_file; + xfer_iface->send = mw_protocol_send_file; + xfer_iface->new_xfer = mw_protocol_new_xfer; +} + + +PURPLE_DEFINE_TYPE_EXTENDED( + mwProtocol, mw_protocol, PURPLE_TYPE_PROTOCOL, 0, + + PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE, + mw_protocol_client_iface_init) + + PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE, + mw_protocol_server_iface_init) + + PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_IM_IFACE, + mw_protocol_im_iface_init) + + PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CHAT_IFACE, + mw_protocol_chat_iface_init) + + PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE, + mw_protocol_privacy_iface_init) + + PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER_IFACE, + mw_protocol_xfer_iface_init) +); + + +static PurplePluginInfo * +plugin_query(GError **error) +{ + const gchar * const authors[] = PLUGIN_AUTHORS; + + return purple_plugin_info_new( + "id", PLUGIN_ID, + "name", PLUGIN_NAME, + "version", DISPLAY_VERSION, + "category", PLUGIN_CATEGORY, + "summary", PLUGIN_SUMMARY, + "description", PLUGIN_DESC, + "authors", authors, + "website", PLUGIN_HOMEPAGE, + "abi-version", PURPLE_ABI_VERSION, + "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL | + PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD, + NULL + ); +} + + +static gboolean +plugin_load(PurplePlugin *plugin, GError **error) +{ + GLogLevelFlags logflags = + G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; + + mw_protocol_register_type(plugin); + + my_protocol = purple_protocols_add(MW_TYPE_PROTOCOL, error); + if (!my_protocol) + return FALSE; /* forward all our g_log messages to purple. Generally all the logging calls are using purple_log directly, but the g_return macros will get caught here */ log_handler[0] = g_log_set_handler(G_LOG_DOMAIN, logflags, - mw_log_handler, NULL); + mw_log_handler, NULL); /* redirect meanwhile's logging to purple's */ log_handler[1] = g_log_set_handler("meanwhile", logflags, - mw_log_handler, NULL); + mw_log_handler, NULL); + + return TRUE; +} + + +static gboolean +plugin_unload(PurplePlugin *plugin, GError **error) +{ + g_log_remove_handler(G_LOG_DOMAIN, log_handler[0]); + g_log_remove_handler("meanwhile", log_handler[1]); + + if (!purple_protocols_remove(my_protocol, error)) + return FALSE; + + return TRUE; } -PURPLE_INIT_PLUGIN(sametime, mw_plugin_init, mw_plugin_info); +PURPLE_PLUGIN_INIT(sametime, plugin_query, plugin_load, plugin_unload); /* The End. */ |