Mercurial > pidgin
changeset 9954:a9fb4493ae22
[gaim-migrate @ 10851]
a combination of the hacking i've been doing on jabber, and the patch datallah just sent me
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sun, 05 Sep 2004 17:10:39 +0000 |
parents | d908907d9441 |
children | 2f132ced82fa |
files | plugins/contact_priority.c plugins/docklet/Makefile.mingw plugins/filectl.c plugins/gaiminc.c plugins/gevolution/gevolution.c plugins/gtk-signals-test.c plugins/ipc-test-client.c plugins/ipc-test-server.c plugins/mailchk.c plugins/pluginpref_example.c plugins/raw.c plugins/signals-test.c plugins/simple.c plugins/win32/transparency/win2ktrans.c plugins/win32/winprefs/winprefs.c src/gtkblist.c src/protocols/jabber/buddy.c src/protocols/jabber/buddy.h src/protocols/jabber/chat.c src/protocols/jabber/jabber.c src/protocols/jabber/jutil.c src/protocols/jabber/jutil.h src/protocols/jabber/presence.c src/protocols/jabber/presence.h src/protocols/jabber/roster.c src/protocols/rendezvous/rendezvous.c src/protocols/toc/toc.c src/protocols/trepia/trepia.c |
diffstat | 28 files changed, 335 insertions(+), 194 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/contact_priority.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/contact_priority.c Sun Sep 05 17:10:39 2004 +0000 @@ -23,6 +23,7 @@ #include "gtkplugin.h" #include "gtkutils.h" #include "prefs.h" +#include "version.h" #define CONTACT_PRIORITY_PLUGIN_ID "gtk-contact-priority" @@ -181,7 +182,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, /**< type */ GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ 0, /**< flags */
--- a/plugins/docklet/Makefile.mingw Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/docklet/Makefile.mingw Sun Sep 05 17:10:39 2004 +0000 @@ -94,7 +94,7 @@ all: $(TARGET).dll -install: +install: all cp $(TARGET).dll $(DLL_INSTALL_DIR)
--- a/plugins/filectl.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/filectl.c Sun Sep 05 17:10:39 2004 +0000 @@ -22,7 +22,7 @@ #include "debug.h" #include "account.h" #include "conversation.h" - +#include "version.h" #define FILECTL_PLUGIN_ID "core-filectl" @@ -211,7 +211,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, /**< type */ NULL, /**< ui_requirement */ 0, /**< flags */
--- a/plugins/gaiminc.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/gaiminc.c Sun Sep 05 17:10:39 2004 +0000 @@ -4,6 +4,7 @@ #include "account.h" #include "connection.h" #include "conversation.h" +#include "version.h" /* include UI for gaim_gtkdialogs_about() */ #include "gtkplugin.h" @@ -76,7 +77,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, /**< type */ NULL, /**< ui_requirement */ 0, /**< flags */
--- a/plugins/gevolution/gevolution.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/gevolution/gevolution.c Sun Sep 05 17:10:39 2004 +0000 @@ -25,6 +25,7 @@ #include "debug.h" #include "prefs.h" #include "signals.h" +#include "version.h" #include "gtkblist.h" #include "gtkconv.h" @@ -454,7 +455,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, /**< type */ GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ 0, /**< flags */
--- a/plugins/gtk-signals-test.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/gtk-signals-test.c Sun Sep 05 17:10:39 2004 +0000 @@ -24,6 +24,7 @@ #include "internal.h" #include "debug.h" +#include "version.h" #include "gtkaccount.h" #include "gtkblist.h" @@ -88,7 +89,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, /**< type */ GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ 0, /**< flags */
--- a/plugins/ipc-test-client.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/ipc-test-client.c Sun Sep 05 17:10:39 2004 +0000 @@ -21,6 +21,7 @@ #include "internal.h" #include "debug.h" #include "plugin.h" +#include "version.h" #define IPC_TEST_CLIENT_PLUGIN_ID "core-ipc-test-client" @@ -73,7 +74,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, /**< type */ NULL, /**< ui_requirement */ 0, /**< flags */
--- a/plugins/ipc-test-server.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/ipc-test-server.c Sun Sep 05 17:10:39 2004 +0000 @@ -23,6 +23,7 @@ #include "internal.h" #include "debug.h" #include "plugin.h" +#include "version.h" static int add_func(int i1, int i2) @@ -60,7 +61,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, /**< type */ NULL, /**< ui_requirement */ 0, /**< flags */
--- a/plugins/mailchk.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/mailchk.c Sun Sep 05 17:10:39 2004 +0000 @@ -5,6 +5,7 @@ #include "debug.h" #include "signals.h" #include "sound.h" +#include "version.h" #include "gtkblist.h" #include "gtkgaim.h" @@ -147,7 +148,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, GAIM_GTK_PLUGIN_TYPE, 0,
--- a/plugins/pluginpref_example.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/pluginpref_example.c Sun Sep 05 17:10:39 2004 +0000 @@ -32,6 +32,7 @@ #include "plugin.h" #include "pluginpref.h" #include "prefs.h" +#include "version.h" static GaimPluginPrefFrame * get_plugin_pref_frame(GaimPlugin *plugin) { @@ -112,7 +113,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, /**< type */ NULL, /**< ui_requirement */ 0, /**< flags */
--- a/plugins/raw.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/raw.c Sun Sep 05 17:10:39 2004 +0000 @@ -1,6 +1,7 @@ #include "conversation.h" #include "debug.h" #include "prpl.h" +#include "version.h" #include "gtkgaim.h" #include "gtkplugin.h" @@ -136,7 +137,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, GAIM_GTK_PLUGIN_TYPE, 0,
--- a/plugins/signals-test.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/signals-test.c Sun Sep 05 17:10:39 2004 +0000 @@ -28,6 +28,7 @@ #include "core.h" #include "debug.h" #include "signals.h" +#include "version.h" /************************************************************************** * Account subsystem signal callbacks @@ -571,7 +572,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, /**< type */ NULL, /**< ui_requirement */ 0, /**< flags */
--- a/plugins/simple.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/simple.c Sun Sep 05 17:10:39 2004 +0000 @@ -1,6 +1,7 @@ #include "internal.h" #include "debug.h" #include "plugin.h" +#include "version.h" static gboolean plugin_load(GaimPlugin *plugin) @@ -20,9 +21,11 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, /**< type */ - NULL, /**< ui_requirement */ + NULL, /**< ui_requirement */ 0, /**< flags */ NULL, /**< dependencies */ GAIM_PRIORITY_DEFAULT, /**< priority */
--- a/plugins/win32/transparency/win2ktrans.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/win32/transparency/win2ktrans.c Sun Sep 05 17:10:39 2004 +0000 @@ -31,6 +31,7 @@ #include "gtkblist.h" #include "gtkutils.h" #include "signals.h" +#include "version.h" /* * MACROS & DEFINES @@ -466,7 +467,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, /**< type */ GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ 0, /**< flags */
--- a/plugins/win32/winprefs/winprefs.c Sun Sep 05 06:29:51 2004 +0000 +++ b/plugins/win32/winprefs/winprefs.c Sun Sep 05 17:10:39 2004 +0000 @@ -29,6 +29,7 @@ #include "prefs.h" #include "debug.h" #include "signals.h" +#include "version.h" #include "gtkplugin.h" #include "gtkutils.h" @@ -394,7 +395,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, GAIM_GTK_PLUGIN_TYPE, 0,
--- a/src/gtkblist.c Sun Sep 05 06:29:51 2004 +0000 +++ b/src/gtkblist.c Sun Sep 05 17:10:39 2004 +0000 @@ -2588,7 +2588,7 @@ } struct _emblem_data { - char *filename; + const char *filename; int x; int y; };
--- a/src/protocols/jabber/buddy.c Sun Sep 05 06:29:51 2004 +0000 +++ b/src/protocols/jabber/buddy.c Sun Sep 05 17:10:39 2004 +0000 @@ -93,8 +93,8 @@ return jbr; } -void jabber_buddy_track_resource(JabberBuddy *jb, const char *resource, - int priority, int state, const char *status) +JabberBuddyResource *jabber_buddy_track_resource(JabberBuddy *jb, const char *resource, + int priority, JabberBuddyState state, const char *status) { JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource); @@ -110,6 +110,8 @@ if(jbr->status) g_free(jbr->status); jbr->status = g_strdup(status); + + return jbr; } void jabber_buddy_resource_free(JabberBuddyResource *jbr) @@ -560,7 +562,7 @@ if(jbr->status) purdy = gaim_strdup_withhtml(jbr->status); g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/>", - _("Status"), jabber_get_state_string(jbr->state), + _("Status"), jabber_buddy_state_get_name(jbr->state), purdy ? ": " : "", purdy ? purdy : ""); if(purdy) @@ -578,7 +580,7 @@ g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", _("Resource"), jbr->name); g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/><br/>", - _("Status"), jabber_get_state_string(jbr->state), + _("Status"), jabber_buddy_state_get_name(jbr->state), purdy ? ": " : "", purdy ? purdy : ""); if(purdy) @@ -823,12 +825,17 @@ GaimStatus *status; JabberBuddy *jb = jabber_buddy_find(js, who, TRUE); xmlnode *presence; + JabberBuddyState state; + const char *msg; + int priority; account = gaim_connection_get_account(js->gc); gpresence = gaim_account_get_presence(account); status = gaim_presence_get_active_status(gpresence); - presence = jabber_presence_create(status); + gaim_status_to_jabber(status, &state, &msg, &priority); + presence = jabber_presence_create(state, msg, priority); + xmlnode_set_attrib(presence, "to", who); if(invisible) { xmlnode_set_attrib(presence, "type", "invisible"); @@ -979,3 +986,69 @@ } +const char * +jabber_buddy_state_get_name(JabberBuddyState state) +{ + switch(state) { + case JABBER_BUDDY_STATE_UNKNOWN: + return _("Unknown"); + case JABBER_BUDDY_STATE_ERROR: + return _("Error"); + case JABBER_BUDDY_STATE_UNAVAILABLE: + return _("Offline"); + case JABBER_BUDDY_STATE_ONLINE: + return _("Online"); + case JABBER_BUDDY_STATE_CHAT: + return _("Chatty"); + case JABBER_BUDDY_STATE_AWAY: + return _("Away"); + case JABBER_BUDDY_STATE_XA: + return _("Extended Away"); + case JABBER_BUDDY_STATE_DND: + return _("Do Not Disturb"); + } + + return _("Unknown"); +} + +JabberBuddyState jabber_buddy_status_id_get_state(const char *id) { + if(!id) + return JABBER_BUDDY_STATE_UNKNOWN; + if(!strcmp(id, "online")) + return JABBER_BUDDY_STATE_ONLINE; + if(!strcmp(id, "chat")) + return JABBER_BUDDY_STATE_CHAT; + if(!strcmp(id, "away")) + return JABBER_BUDDY_STATE_AWAY; + if(!strcmp(id, "xa")) + return JABBER_BUDDY_STATE_XA; + if(!strcmp(id, "dnd")) + return JABBER_BUDDY_STATE_DND; + if(!strcmp(id, "offline")) + return JABBER_BUDDY_STATE_UNAVAILABLE; + if(!strcmp(id, "error")) + return JABBER_BUDDY_STATE_ERROR; + + return JABBER_BUDDY_STATE_UNKNOWN; +} + +const char *jabber_buddy_state_get_status_id(JabberBuddyState state) { + switch(state) { + case JABBER_BUDDY_STATE_CHAT: + return "chat"; + case JABBER_BUDDY_STATE_AWAY: + return "away"; + case JABBER_BUDDY_STATE_XA: + return "xa"; + case JABBER_BUDDY_STATE_DND: + return "dnd"; + case JABBER_BUDDY_STATE_ONLINE: + return "online"; + case JABBER_BUDDY_STATE_UNKNOWN: + case JABBER_BUDDY_STATE_ERROR: + return NULL; + case JABBER_BUDDY_STATE_UNAVAILABLE: + return "offline"; + } + return NULL; +}
--- a/src/protocols/jabber/buddy.h Sun Sep 05 06:29:51 2004 +0000 +++ b/src/protocols/jabber/buddy.h Sun Sep 05 17:10:39 2004 +0000 @@ -24,6 +24,17 @@ #include "jabber.h" +typedef enum { + JABBER_BUDDY_STATE_UNKNOWN = -2, + JABBER_BUDDY_STATE_ERROR = -1, + JABBER_BUDDY_STATE_UNAVAILABLE = 0, + JABBER_BUDDY_STATE_ONLINE, + JABBER_BUDDY_STATE_CHAT, + JABBER_BUDDY_STATE_AWAY, + JABBER_BUDDY_STATE_XA, + JABBER_BUDDY_STATE_DND +} JabberBuddyState; + typedef struct _JabberBuddy { GList *resources; char *error_msg; @@ -46,7 +57,7 @@ JabberBuddy *jb; char *name; int priority; - int state; + JabberBuddyState state; char *status; JabberCapabilities capabilities; char *thread_id; @@ -57,8 +68,8 @@ gboolean create); JabberBuddyResource *jabber_buddy_find_resource(JabberBuddy *jb, const char *resource); -void jabber_buddy_track_resource(JabberBuddy *jb, const char *resource, - int priority, int state, const char *status); +JabberBuddyResource *jabber_buddy_track_resource(JabberBuddy *jb, const char *resource, + int priority, JabberBuddyState state, const char *status); void jabber_buddy_resource_free(JabberBuddyResource *jbr); void jabber_buddy_remove_resource(JabberBuddy *jb, const char *resource); const char *jabber_buddy_get_status_msg(JabberBuddy *jb); @@ -71,4 +82,8 @@ void jabber_set_info(GaimConnection *gc, const char *info); void jabber_setup_set_info(GaimPluginAction *action); +const char *jabber_buddy_state_get_name(JabberBuddyState state); +const char *jabber_buddy_state_get_status_id(JabberBuddyState state); +JabberBuddyState jabber_buddy_status_id_get_state(const char *id); + #endif /* _GAIM_JABBER_BUDDY_H_ */
--- a/src/protocols/jabber/chat.c Sun Sep 05 06:29:51 2004 +0000 +++ b/src/protocols/jabber/chat.c Sun Sep 05 17:10:39 2004 +0000 @@ -196,6 +196,11 @@ xmlnode *presence, *x; char *tmp, *room_jid, *full_jid; JabberStream *js = gc->proto_data; + GaimPresence *gpresence; + GaimStatus *status; + JabberBuddyState state; + const char *msg; + int priority; room = g_hash_table_lookup(data, "room"); server = g_hash_table_lookup(data, "server"); @@ -245,7 +250,12 @@ g_hash_table_insert(js->chats, room_jid, chat); - presence = jabber_presence_create(gc->away_state, gc->away); + gpresence = gaim_account_get_presence(gc->account); + status = gaim_presence_get_active_status(gpresence); + + gaim_status_to_jabber(status, &state, &msg, &priority); + + presence = jabber_presence_create(state, msg, priority); full_jid = g_strdup_printf("%s/%s", room_jid, handle); xmlnode_set_attrib(presence, "to", full_jid); g_free(full_jid); @@ -599,6 +609,11 @@ { xmlnode *presence; char *full_jid; + GaimPresence *gpresence; + GaimStatus *status; + JabberBuddyState state; + const char *msg; + int priority; if(!chat->muc) { gaim_conv_chat_write(GAIM_CONV_CHAT(chat->conv), "", @@ -607,7 +622,12 @@ return; } - presence = jabber_presence_create(chat->js->gc->away_state, chat->js->gc->away); + gpresence = gaim_account_get_presence(chat->js->gc->account); + status = gaim_presence_get_active_status(gpresence); + + gaim_status_to_jabber(status, &state, &msg, &priority); + + presence = jabber_presence_create(state, msg, priority); full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, nick); xmlnode_set_attrib(presence, "to", full_jid); g_free(full_jid);
--- a/src/protocols/jabber/jabber.c Sun Sep 05 06:29:51 2004 +0000 +++ b/src/protocols/jabber/jabber.c Sun Sep 05 17:10:39 2004 +0000 @@ -742,7 +742,7 @@ { JabberStream *js = gc->proto_data; - jabber_presence_send(gc, "unavailable", _("Logged out")); + jabber_presence_send(gc, NULL); /* XXX: FIXME: EEK! */ jabber_send_raw(js, "</stream:stream>", -1); if(js->gsc) { @@ -776,6 +776,9 @@ void jabber_stream_set_state(JabberStream *js, JabberStreamState state) { + GaimPresence *gpresence; + GaimStatus *status; + js->state = state; switch(state) { case JABBER_STREAM_OFFLINE: @@ -807,7 +810,9 @@ case JABBER_STREAM_CONNECTED: gaim_connection_set_state(js->gc, GAIM_CONNECTED); jabber_roster_request(js); - jabber_presence_send(js->gc, js->gc->away_state, js->gc->away); + gpresence = gaim_account_get_presence(js->gc->account); + status = gaim_presence_get_active_status(gpresence); + jabber_presence_send(js->gc, status); jabber_disco_items_server(js); serv_finish_login(js->gc); break; @@ -832,8 +837,8 @@ return "jabber"; } -static void jabber_list_emblems(GaimBuddy *b, char **se, char **sw, - char **nw, char **ne) +static void jabber_list_emblems(GaimBuddy *b, const char **se, const char **sw, + const char **nw, const char **ne) { JabberStream *js; JabberBuddy *jb; @@ -853,22 +858,12 @@ else *se = "offline"; } else { - switch (b->uc) { - case JABBER_STATE_AWAY: - *se = "away"; - break; - case JABBER_STATE_CHAT: - *se = "chat"; - break; - case JABBER_STATE_XA: + GaimStatusType *status_type = gaim_status_get_type(gaim_presence_get_active_status(gaim_buddy_get_presence(b))); + + if(gaim_status_type_get_primitive(status_type) > GAIM_STATUS_ONLINE) { + *se = gaim_status_type_get_id(status_type); + if(!strcmp(*se, "xa")) *se = "extendedaway"; - break; - case JABBER_STATE_DND: - *se = "dnd"; - break; - case JABBER_STATE_ERROR: - *se = "error"; - break; } } } @@ -886,10 +881,12 @@ } else { char *stripped; - stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)); + if(!(stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)))) { + GaimStatus *status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); - if(!stripped && b->uc & UC_UNAVAILABLE) - stripped = g_strdup(jabber_get_state_string(b->uc)); + if(!gaim_status_is_available(status)) + stripped = g_strdup(gaim_status_get_name(status)); + } if(stripped) { ret = g_markup_escape_text(stripped, -1); @@ -937,7 +934,7 @@ g_string_append_printf(ret, "\n<b>%s:</b> %s%s%s", _("Status"), - jabber_get_state_string(jbr->state), + jabber_buddy_state_get_name(jbr->state), text ? ": " : "", text ? text : ""); if(text) @@ -951,21 +948,35 @@ return g_string_free(ret, FALSE); } -static GList *jabber_away_states(GaimConnection *gc) +static GList *jabber_status_types(GaimAccount *account) { - JabberStream *js = gc->proto_data; - GList *m = NULL; + GaimStatusType *type; + GList *types = NULL; + + type = gaim_status_type_new_with_attrs(GAIM_STATUS_OFFLINE, "offline", _("Offline"), TRUE, FALSE, FALSE, "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING)); + types = g_list_append(types, type); + + type = gaim_status_type_new_with_attrs(GAIM_STATUS_ONLINE, "online", _("Online"), TRUE, TRUE, FALSE, "priority", _("Priority"), gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING)); + types = g_list_append(types, type); - m = g_list_append(m, _("Online")); - m = g_list_append(m, _("Chatty")); - m = g_list_append(m, _("Away")); - m = g_list_append(m, _("Extended Away")); - m = g_list_append(m, _("Do Not Disturb")); + type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, "chat", _("Chatty"), TRUE, TRUE, FALSE, "priority", _("Priority"), gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING)); + types = g_list_append(types, type); + + type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, "away", _("Away"), TRUE, TRUE, FALSE, "priority", _("Priority"), gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING)); + types = g_list_append(types, type); + + type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY, "xa", _("Extended Away"), TRUE, TRUE, FALSE, "priority", _("Priority"), gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING)); + types = g_list_append(types, type); + + type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, "dnd", _("Do Not Disturb"), TRUE, TRUE, FALSE, "priority", _("Priority"), gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING)); + types = g_list_append(types, type); + + /* if(js->protocol_version == JABBER_PROTO_0_9) m = g_list_append(m, _("Invisible")); - m = g_list_append(m, GAIM_AWAY_CUSTOM); + */ - return m; + return types; } static void @@ -1488,7 +1499,7 @@ jabber_list_emblems, /* list_emblems */ jabber_status_text, /* status_text */ jabber_tooltip_text, /* tooltip_text */ - jabber_away_states, /* away_states */ + jabber_status_types, /* status_types */ jabber_blist_node_menu, /* blist_node_menu */ jabber_chat_info, /* chat_info */ jabber_chat_info_defaults, /* chat_info_defaults */ @@ -1498,7 +1509,7 @@ jabber_set_info, /* set_info */ jabber_send_typing, /* send_typing */ jabber_buddy_get_info, /* get_info */ - jabber_presence_send, /* set_away */ + NULL, /* set_away */ jabber_idle_set, /* set_idle */ NULL, /* change_passwd */ jabber_roster_add_buddy, /* add_buddy */
--- a/src/protocols/jabber/jutil.c Sun Sep 05 06:29:51 2004 +0000 +++ b/src/protocols/jabber/jutil.c Sun Sep 05 17:10:39 2004 +0000 @@ -26,26 +26,6 @@ #include "presence.h" #include "jutil.h" -const char *jabber_get_state_string(int s) { - switch(s) { - case JABBER_STATE_AWAY: - return _("Away"); - break; - case JABBER_STATE_CHAT: - return _("Chatty"); - break; - case JABBER_STATE_XA: - return _("Extended Away"); - break; - case JABBER_STATE_DND: - return _("Do Not Disturb"); - break; - default: - return _("Available"); - break; - } -} - gboolean jabber_nodeprep_validate(const char *str) { const char *c;
--- a/src/protocols/jabber/jutil.h Sun Sep 05 06:29:51 2004 +0000 +++ b/src/protocols/jabber/jutil.h Sun Sep 05 17:10:39 2004 +0000 @@ -39,8 +39,6 @@ char *jabber_get_resource(const char *jid); char *jabber_get_bare_jid(const char *jid); -const char *jabber_get_state_string(int state); - const char *jabber_normalize(const GaimAccount *account, const char *in); gboolean jabber_nodeprep_validate(const char *);
--- a/src/protocols/jabber/presence.c Sun Sep 05 06:29:51 2004 +0000 +++ b/src/protocols/jabber/presence.c Sun Sep 05 17:10:39 2004 +0000 @@ -24,6 +24,7 @@ #include "notify.h" #include "request.h" #include "server.h" +#include "status.h" #include "util.h" #include "buddy.h" @@ -52,96 +53,81 @@ g_free(chat_full_jid); } -void jabber_presence_fake_to_self(JabberStream *js, const char *away_state, const char *msg) { +void jabber_presence_fake_to_self(JabberStream *js, const GaimStatus *gstatus) { char *my_base_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); if(gaim_find_buddy(js->gc->account, my_base_jid)) { JabberBuddy *jb; JabberBuddyResource *jbr; if((jb = jabber_buddy_find(js, my_base_jid, TRUE))) { - int state = 0; - if(away_state) { - if(!strcmp(away_state, _("Away")) || - (msg && *msg && !strcmp(away_state, GAIM_AWAY_CUSTOM))) - state = JABBER_STATE_AWAY; - else if(!strcmp(away_state, _("Chatty"))) - state = JABBER_STATE_CHAT; - else if(!strcmp(away_state, _("Extended Away"))) - state = JABBER_STATE_XA; - else if(!strcmp(away_state, _("Do Not Disturb"))) - state = JABBER_STATE_DND; - } - - if (away_state && !strcmp(away_state, "unavailable")) { + JabberBuddyState state; + const char *msg; + int priority; + + gaim_status_to_jabber(gstatus, &state, &msg, &priority); + + if (state == JABBER_BUDDY_STATE_UNAVAILABLE) { jabber_buddy_remove_resource(jb, js->user->resource); } else { - jabber_buddy_track_resource(jb, js->user->resource, 0, state, (msg && *msg) ? msg : NULL); + jabber_buddy_track_resource(jb, js->user->resource, priority, state, msg); } - if((jbr = jabber_buddy_find_resource(jb, NULL))) - serv_got_update(js->gc, my_base_jid, TRUE, 0, 0, 0, jbr->state); - else - serv_got_update(js->gc, my_base_jid, FALSE, 0, 0, 0, 0); + if((jbr = jabber_buddy_find_resource(jb, NULL))) { + gaim_prpl_got_user_status(js->gc->account, my_base_jid, jabber_buddy_state_get_status_id(jbr->state), "priority", jbr->priority, jbr->status ? "message" : NULL, jbr->status); + } else { + gaim_prpl_got_user_status(js->gc->account, my_base_jid, "offline", msg ? "message" : NULL, msg); + } } } g_free(my_base_jid); } -void jabber_presence_send(GaimConnection *gc, const char *state, - const char *msg) +void jabber_presence_send(GaimConnection *gc, GaimStatus *status) { JabberStream *js = gc->proto_data; xmlnode *presence; char *stripped = NULL; + const char *msg; + JabberBuddyState state; + int priority; - if(msg) { + gaim_status_to_jabber(status, &state, &msg, &priority); + + if(msg) gaim_markup_html_to_xhtml(msg, NULL, &stripped); - } else if(!state || strcmp(state, GAIM_AWAY_CUSTOM)) { - /* i can't wait until someone re-writes the status/away stuff */ - stripped = g_strdup(""); - } - if(gc->away) - g_free(gc->away); - gc->away = stripped; + presence = jabber_presence_create(state, stripped, priority); + g_free(stripped); - presence = jabber_presence_create(state, stripped); jabber_send(js, presence); g_hash_table_foreach(js->chats, chats_send_presence_foreach, presence); xmlnode_free(presence); - jabber_presence_fake_to_self(js, state, stripped); + jabber_presence_fake_to_self(js, status); + } -xmlnode *jabber_presence_create(const char *state, const char *msg) +xmlnode *jabber_presence_create(JabberBuddyState state, const char *msg, int priority) { xmlnode *show, *status, *presence; + const char *show_string = NULL; presence = xmlnode_new("presence"); - if(state) { - const char *show_string = NULL; - if(!strcmp(state, _("Chatty"))) - show_string = "chat"; - else if(!strcmp(state, _("Away")) || - (msg && !strcmp(state, GAIM_AWAY_CUSTOM))) - show_string = "away"; - else if(!strcmp(state, _("Extended Away"))) - show_string = "xa"; - else if(!strcmp(state, _("Do Not Disturb"))) - show_string = "dnd"; - else if(!strcmp(state, _("Invisible"))) - xmlnode_set_attrib(presence, "type", "invisible"); - else if(!strcmp(state, "unavailable")) - xmlnode_set_attrib(presence, "type", "unavailable"); - if(show_string) { - show = xmlnode_new_child(presence, "show"); - xmlnode_insert_data(show, show_string, -1); - } + if(state == JABBER_BUDDY_STATE_UNAVAILABLE) + xmlnode_set_attrib(presence, "type", "unavailable"); + else if(state != JABBER_BUDDY_STATE_ONLINE && + state != JABBER_BUDDY_STATE_UNKNOWN && + state != JABBER_BUDDY_STATE_ERROR) + show_string = jabber_buddy_state_get_status_id(state); + + if(show_string) { + show = xmlnode_new_child(presence, "show"); + xmlnode_insert_data(show, show_string, -1); } - if(msg && *msg) { + if(msg) { status = xmlnode_new_child(presence, "status"); xmlnode_insert_data(status, msg, -1); } @@ -179,20 +165,6 @@ g_free(jap); } -static int show_to_state(const char *show) { - if(!show) - return 0; - else if(!strcmp(show, "away")) - return JABBER_STATE_AWAY; - else if(!strcmp(show, "chat")) - return JABBER_STATE_CHAT; - else if(!strcmp(show, "xa")) - return JABBER_STATE_XA; - else if(!strcmp(show, "dnd")) - return JABBER_STATE_DND; - return 0; -} - void jabber_presence_parse(JabberStream *js, xmlnode *packet) { const char *from = xmlnode_get_attrib(packet, "from"); @@ -205,12 +177,12 @@ JabberID *jid; JabberChat *chat; JabberBuddy *jb; - JabberBuddyResource *jbr = NULL; + JabberBuddyResource *jbr = NULL, *found_jbr = NULL; GaimConvChatBuddyFlags flags = GAIM_CBFLAGS_NONE; gboolean delayed = FALSE; GaimBuddy *b; char *buddy_name; - int state = 0; + JabberBuddyState state = JABBER_BUDDY_STATE_UNKNOWN; xmlnode *y; gboolean muc = FALSE; @@ -229,7 +201,7 @@ if(type && !strcmp(type, "error")) { char *msg = jabber_parse_error(js, packet); - state = JABBER_STATE_ERROR; + state = JABBER_BUDDY_STATE_ERROR; jb->error_msg = msg ? msg : g_strdup(_("Unknown Error in presence")); } else if(type && !strcmp(type, "subscribe")) { struct _jabber_add_permit *jap = g_new0(struct _jabber_add_permit, 1); @@ -250,10 +222,10 @@ } else { if((y = xmlnode_get_child(packet, "show"))) { char *show = xmlnode_get_data(y); - state = show_to_state(show); + state = jabber_buddy_status_id_get_state(show); g_free(show); } else { - state = 0; + state = JABBER_BUDDY_STATE_ONLINE; } } @@ -318,7 +290,7 @@ static int i = 1; char *room_jid = g_strdup_printf("%s@%s", jid->node, jid->domain); - if(state == JABBER_STATE_ERROR) { + if(state == JABBER_BUDDY_STATE_ERROR) { char *title, *msg = jabber_parse_error(js, packet); if(chat->conv) { @@ -426,7 +398,7 @@ } g_free(room_jid); } else { - if(state != JABBER_STATE_ERROR && !(jb->subscription & JABBER_SUB_TO)) { + if(state != JABBER_BUDDY_STATE_ERROR && !(jb->subscription & JABBER_SUB_TO)) { gaim_debug(GAIM_DEBUG_INFO, "jabber", "got unexpected presence from %s, ignoring\n", from); jabber_id_free(jid); @@ -443,7 +415,7 @@ return; } - if(state == JABBER_STATE_ERROR || + if(state == JABBER_BUDDY_STATE_ERROR || (type && (!strcmp(type, "unavailable") || !strcmp(type, "unsubscribed")))) { GaimConversation *conv; @@ -453,16 +425,17 @@ gaim_conversation_set_name(conv, buddy_name); } else { - jabber_buddy_track_resource(jb, jid->resource, priority, state, - status); + jbr = jabber_buddy_track_resource(jb, jid->resource, priority, + state, status); } - if((jbr = jabber_buddy_find_resource(jb, NULL))) - serv_got_update(js->gc, buddy_name, TRUE, 0, b->signon, b->idle, - jbr->state); - else - serv_got_update(js->gc, buddy_name, FALSE, 0, 0, 0, 0); - + if((found_jbr = jabber_buddy_find_resource(jb, NULL))) { + if(!jbr || jbr == found_jbr) { + gaim_prpl_got_user_status(js->gc->account, buddy_name, jabber_buddy_state_get_status_id(state), "priority", found_jbr->priority, found_jbr->status ? "message" : NULL, found_jbr->status); + } + } else { + gaim_prpl_got_user_status(js->gc->account, buddy_name, "offline", status ? "message" : NULL, status); + } g_free(buddy_name); } g_free(status); @@ -479,3 +452,27 @@ jabber_send(js, presence); xmlnode_free(presence); } + +void gaim_status_to_jabber(const GaimStatus *status, JabberBuddyState *state, const char **msg, int *priority) +{ + const char *status_id; + + if(!status) { + *state = JABBER_BUDDY_STATE_UNKNOWN; + *msg = NULL; + *priority = 0; + return; + } + + if(state) { + status_id = gaim_status_get_id(status); + *state = jabber_buddy_status_id_get_state(status_id); + } + + if(msg) + *msg = gaim_status_get_attr_string(status, "message"); + + if(priority) + *priority = gaim_status_get_attr_int(status, "priority"); + +}
--- a/src/protocols/jabber/presence.h Sun Sep 05 06:29:51 2004 +0000 +++ b/src/protocols/jabber/presence.h Sun Sep 05 17:10:39 2004 +0000 @@ -22,21 +22,16 @@ #ifndef _GAIM_JABBER_PRESENCE_H_ #define _GAIM_JABBER_PRESENCE_H_ +#include "buddy.h" #include "jabber.h" #include "xmlnode.h" -#define JABBER_STATE_AWAY (0x02 | UC_UNAVAILABLE) -#define JABBER_STATE_CHAT (0x04) -#define JABBER_STATE_XA (0x08 | UC_UNAVAILABLE) -#define JABBER_STATE_DND (0x10 | UC_UNAVAILABLE) -#define JABBER_STATE_ERROR (0x20 | UC_UNAVAILABLE) - -void jabber_presence_send(GaimConnection *gc, const char *state, - const char *msg); -xmlnode *jabber_presence_create(GaimStatus *status); +void jabber_presence_send(GaimConnection *gc, GaimStatus *status); +xmlnode *jabber_presence_create(JabberBuddyState state, const char *msg, int priority); void jabber_presence_parse(JabberStream *js, xmlnode *packet); void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type); -void jabber_presence_fake_to_self(JabberStream *js, const char *away_state, const char *msg); +void jabber_presence_fake_to_self(JabberStream *js, const GaimStatus *status); +void gaim_status_to_jabber(const GaimStatus *status, JabberBuddyState *state, const char **msg, int *priority); #endif /* _GAIM_JABBER_PRESENCE_H_ */
--- a/src/protocols/jabber/roster.c Sun Sep 05 06:29:51 2004 +0000 +++ b/src/protocols/jabber/roster.c Sun Sep 05 17:10:39 2004 +0000 @@ -55,7 +55,7 @@ const char *alias, GSList *groups) { GSList *buddies, *g2, *l; - int present =0, idle=0, state=0; + int present =0; buddies = gaim_find_buddies(js->gc->account, jid); @@ -70,8 +70,6 @@ if(buddies) { present = ((GaimBuddy*)buddies->data)->present; - idle = ((GaimBuddy*)buddies->data)->idle; - state = ((GaimBuddy*)buddies->data)->uc; } while(buddies) { @@ -104,9 +102,8 @@ gaim_blist_add_group(g, NULL); } + /* XXX: this hack may need to change */ b->present = present; - b->idle = idle; - b->uc = state; gaim_blist_add_buddy(b, NULL, g, NULL); gaim_blist_alias_buddy(b, alias); @@ -269,12 +266,20 @@ jabber_roster_update(js, who, groups); my_bare_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); - if(!strcmp(who, my_bare_jid)) - jabber_presence_fake_to_self(js, js->gc->away_state, js->gc->away); - else if(!jb || !(jb->subscription & JABBER_SUB_TO)) + if(!strcmp(who, my_bare_jid)) { + GaimPresence *gpresence; + GaimStatus *status; + + gpresence = gaim_account_get_presence(js->gc->account); + status = gaim_presence_get_active_status(gpresence); + jabber_presence_fake_to_self(js, status); + } else if(!jb || !(jb->subscription & JABBER_SUB_TO)) { jabber_presence_subscription_set(js, who, "subscribe"); - else if((jbr =jabber_buddy_find_resource(jb, NULL))) - serv_got_update(gc, who, TRUE, 0, 0, 0, jbr->state); + } else if((jbr =jabber_buddy_find_resource(jb, NULL))) { + gaim_prpl_got_user_status(gc->account, who, + jabber_buddy_state_get_status_id(jbr->state), + "priority", jbr->priority, jbr->status ? "message" : NULL, jbr->status); + } g_free(my_bare_jid); g_free(who);
--- a/src/protocols/rendezvous/rendezvous.c Sun Sep 05 06:29:51 2004 +0000 +++ b/src/protocols/rendezvous/rendezvous.c Sun Sep 05 17:10:39 2004 +0000 @@ -32,6 +32,7 @@ #include "mdns.h" #include "util.h" +#include "version.h" #define RENDEZVOUS_CONNECT_STEPS 2 @@ -641,7 +642,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_PROTOCOL, /**< type */ NULL, /**< ui_requirement */ 0, /**< flags */ @@ -674,7 +677,6 @@ GaimAccountOption *option; char hostname[255]; - prpl_info.api_version = GAIM_PRPL_API_VERSION; prpl_info.options = OPT_PROTO_NO_PASSWORD; prpl_info.icon_spec.format = "jpeg"; prpl_info.icon_spec.min_width = 0;
--- a/src/protocols/toc/toc.c Sun Sep 05 06:29:51 2004 +0000 +++ b/src/protocols/toc/toc.c Sun Sep 05 17:10:39 2004 +0000 @@ -29,6 +29,7 @@ #include "prpl.h" #include "request.h" #include "util.h" +#include "version.h" static GaimPlugin *my_protocol = NULL; @@ -2108,7 +2109,6 @@ static GaimPluginProtocolInfo prpl_info = { - GAIM_PRPL_API_VERSION, 0, NULL, /* user_splits */ NULL, /* protocol_options */ @@ -2171,7 +2171,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_PROTOCOL, /**< type */ NULL, /**< ui_requirement */ 0, /**< flags */
--- a/src/protocols/trepia/trepia.c Sun Sep 05 06:29:51 2004 +0000 +++ b/src/protocols/trepia/trepia.c Sun Sep 05 17:10:39 2004 +0000 @@ -28,6 +28,7 @@ #include "request.h" #include "server.h" #include "util.h" +#include "version.h" #include "md5.h" #include "profile.h" @@ -1196,7 +1197,6 @@ static GaimPluginProtocolInfo prpl_info = { - GAIM_PRPL_API_VERSION, 0, NULL, /* user_splits */ NULL, /* protocol_options */ @@ -1259,7 +1259,9 @@ static GaimPluginInfo info = { - GAIM_PLUGIN_API_VERSION, /**< api_version */ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, GAIM_PLUGIN_PROTOCOL, /**< type */ NULL, /**< ui_requirement */ 0, /**< flags */