aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2007-04-15 21:01:13 -0700
committerWilmer van der Gaast <wilmer@gaast.net>2007-04-15 21:01:13 -0700
commit6bbb939e953bbe1ca9ed3101a1569abe4521f543 (patch)
tree66ad8cc5189d69c57733a12c6d64c50a86a7ff1d
parent84b045d409f1e8da6d8bf379c6fef7236dcd9bcd (diff)
Split serv_got_update() into imcb_buddy_(status|times). (Well, the second
one isn't implemented yet, but I'll do that later.) At last I got rid of the hack called get_status_string(). And now Yahoo seems to mess up away messages...
-rw-r--r--irc_commands.c2
-rw-r--r--protocols/jabber/iq.c2
-rw-r--r--protocols/jabber/presence.c15
-rw-r--r--protocols/msn/msn.c11
-rw-r--r--protocols/msn/ns.c8
-rw-r--r--protocols/nogaim.c57
-rw-r--r--protocols/nogaim.h24
-rw-r--r--protocols/oscar/oscar.c79
-rw-r--r--protocols/yahoo/yahoo.c101
9 files changed, 140 insertions, 159 deletions
diff --git a/irc_commands.c b/irc_commands.c
index 016b6f84..8d841aaa 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -262,7 +262,7 @@ static void irc_cmd_privmsg( irc_t *irc, char **cmd )
{
irc->is_private = 1;
}
- irc_send( irc, cmd[1], cmd[2], ( g_strcasecmp( cmd[0], "NOTICE" ) == 0 ) ? IM_FLAG_AWAY : 0 );
+ irc_send( irc, cmd[1], cmd[2], ( g_strcasecmp( cmd[0], "NOTICE" ) == 0 ) ? OPT_AWAY : 0 );
}
}
diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c
index 53be819e..46ae9a64 100644
--- a/protocols/jabber/iq.c
+++ b/protocols/jabber/iq.c
@@ -387,7 +387,7 @@ static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *
/* Don't have any API call for this yet! So let's
just try to handle this as well as we can. */
jabber_buddy_remove_bare( ic, jid );
- serv_got_update( ic, jid, 0, 0, 0, 0, 0, 0 );
+ imcb_buddy_status( ic, jid, 0, NULL, NULL );
/* FIXME! */
}
}
diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c
index 4007c84e..6bc8117f 100644
--- a/protocols/jabber/presence.c
+++ b/protocols/jabber/presence.c
@@ -37,6 +37,8 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
if( type == NULL )
{
+ int is_away = 0;
+
if( !( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) )
{
if( set_getbool( &ic->irc->set, "debug" ) )
@@ -51,7 +53,11 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
bud->away_message = NULL;
if( ( c = xt_find_node( node->children, "show" ) ) && c->text_len > 0 )
+ {
bud->away_state = (void*) jabber_away_state_by_code( c->text );
+ if( strcmp( c->text, "chat" ) != 0 )
+ is_away = OPT_AWAY;
+ }
else
{
bud->away_state = NULL;
@@ -65,8 +71,9 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
else
bud->priority = 0;
- serv_got_update( ic, bud->bare_jid, 1, 0, 0, 0,
- bud->away_state ? UC_UNAVAILABLE : 0, 0 );
+ /* FIXME: What to send if there are other resources??? */
+ imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away,
+ bud->away_state->full_name, bud->away_message );
}
else if( strcmp( type, "unavailable" ) == 0 )
{
@@ -86,13 +93,13 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
/* Only count this as offline if there's no other resource
available anymore. */
if( jabber_buddy_by_jid( ic, from, 0 ) == NULL )
- serv_got_update( ic, from, 0, 0, 0, 0, 0, 0 );
+ imcb_buddy_status( ic, from, 0, NULL, NULL );
*s = '/';
}
else
{
- serv_got_update( ic, from, 0, 0, 0, 0, 0, 0 );
+ imcb_buddy_status( ic, from, 0, NULL, NULL );
}
}
else if( strcmp( type, "subscribe" ) == 0 )
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c
index 676a8ad7..5eea68af 100644
--- a/protocols/msn/msn.c
+++ b/protocols/msn/msn.c
@@ -191,16 +191,6 @@ static GList *msn_away_states( struct im_connection *ic )
return l;
}
-static char *msn_get_status_string( struct im_connection *ic, int number )
-{
- const struct msn_away_state *st = msn_away_state_by_number( number );
-
- if( st )
- return( (char*) st->name );
- else
- return( "" );
-}
-
static void msn_set_away( struct im_connection *ic, char *state, char *message )
{
char buf[1024];
@@ -398,7 +388,6 @@ void msn_initmodule()
ret->logout = msn_logout;
ret->send_im = msn_send_im;
ret->away_states = msn_away_states;
- ret->get_status_string = msn_get_status_string;
ret->set_away = msn_set_away;
ret->get_info = msn_get_info;
ret->set_my_name = msn_set_my_name;
diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c
index ba428d82..c80fc177 100644
--- a/protocols/msn/ns.c
+++ b/protocols/msn/ns.c
@@ -399,12 +399,13 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )
st = msn_away_state_list;
}
- serv_got_update( ic, cmd[3], 1, 0, 0, 0, st->number, 0 );
+ imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN |
+ ( st->number ? OPT_AWAY : 0 ), st->name, NULL );
}
else if( strcmp( cmd[0], "FLN" ) == 0 )
{
if( cmd[1] )
- serv_got_update( ic, cmd[1], 0, 0, 0, 0, 0, 0 );
+ imcb_buddy_status( ic, cmd[1], 0, NULL, NULL );
}
else if( strcmp( cmd[0], "NLN" ) == 0 )
{
@@ -427,7 +428,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )
st = msn_away_state_list;
}
- serv_got_update( ic, cmd[2], 1, 0, 0, 0, st->number, 0 );
+ imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN |
+ ( st->number ? OPT_AWAY : 0 ), st->name, NULL );
}
else if( strcmp( cmd[0], "RNG" ) == 0 )
{
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index 6121d398..ef30f749 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -186,7 +186,7 @@ static void serv_got_crap( struct im_connection *ic, char *format, ... )
va_end( params );
if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
- ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
+ ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
strip_html( text );
/* Try to find a different connection on the same protocol. */
@@ -493,32 +493,31 @@ void imcb_ask_add( struct im_connection *ic, char *handle, const char *realname
/* server.c */
-void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps )
+void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message )
{
user_t *u;
int oa, oo;
- u = user_findhandle( ic, handle );
+ u = user_findhandle( ic, (char*) handle );
if( !u )
{
if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 )
{
- add_buddy( ic, NULL, handle, NULL );
- u = user_findhandle( ic, handle );
+ add_buddy( ic, NULL, (char*) handle, NULL );
+ u = user_findhandle( ic, (char*) handle );
}
else
{
if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 )
{
- imcb_log( ic, "serv_got_update() for handle %s:", handle );
- imcb_log( ic, "loggedin = %d, type = %d", loggedin, type );
+ imcb_log( ic, "imcb_buddy_status() for unknown handle %s:", handle );
+ imcb_log( ic, "flags = %d, state = %s, message = %s", flags,
+ state ? state : "NULL", message ? message : "NULL" );
}
return;
}
- /* Why did we have this here....
- return; */
}
oa = u->away != NULL;
@@ -530,12 +529,12 @@ void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int
u->away = NULL;
}
- if( loggedin && !u->online )
+ if( ( flags & OPT_LOGGED_IN ) && !u->online )
{
irc_spawn( ic->irc, u );
u->online = 1;
}
- else if( !loggedin && u->online )
+ else if( !( flags & OPT_LOGGED_IN ) && u->online )
{
struct groupchat *c;
@@ -544,19 +543,29 @@ void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int
/* Remove him/her from the conversations to prevent PART messages after he/she QUIT already */
for( c = ic->conversations; c; c = c->next )
- remove_chat_buddy_silent( c, handle );
+ remove_chat_buddy_silent( c, (char*) handle );
}
- if( ( type & UC_UNAVAILABLE ) && ( strcmp( ic->acc->prpl->name, "oscar" ) == 0 || strcmp( ic->acc->prpl->name, "icq" ) == 0 ) )
- {
- u->away = g_strdup( "Away" );
- }
- else if( ( type & UC_UNAVAILABLE ) && ic->acc->prpl->get_status_string )
+ if( flags & OPT_AWAY )
{
- u->away = g_strdup( ic->acc->prpl->get_status_string( ic, type ) );
+ if( state && message )
+ {
+ u->away = g_strdup_printf( "%s (%s)", state, message );
+ }
+ else if( state )
+ {
+ u->away = g_strdup( state );
+ }
+ else if( message )
+ {
+ u->away = g_strdup( message );
+ }
+ else
+ {
+ u->away = g_strdup( "Away" );
+ }
}
- else
- u->away = NULL;
+ /* else waste_any_state_information_for_now(); */
/* LISPy... */
if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */
@@ -611,7 +620,7 @@ void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 fla
}
if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
- ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
+ ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
strip_html( msg );
while( strlen( msg ) > 425 )
@@ -717,7 +726,7 @@ void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, t
u = user_findhandle( ic, who );
if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
- ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
+ ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
strip_html( msg );
if( c && u )
@@ -924,7 +933,7 @@ int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags
char *buf = NULL;
int st;
- if( ( ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
+ if( ( ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
{
buf = escape_html( msg );
msg = buf;
@@ -940,7 +949,7 @@ int imc_chat_msg( struct groupchat *c, char *msg, int flags )
{
char *buf = NULL;
- if( ( c->ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
+ if( ( c->ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
{
buf = escape_html( msg );
msg = buf;
diff --git a/protocols/nogaim.h b/protocols/nogaim.h
index cc2dcea4..62d8db41 100644
--- a/protocols/nogaim.h
+++ b/protocols/nogaim.h
@@ -5,7 +5,8 @@
\********************************************************************/
/*
- * nogaim
+ * nogaim, soon to be known as im_api. Not a separate product (unless
+ * someone would be interested in such a thing), just a new name.
*
* Gaim without gaim - for BitlBee
*
@@ -14,7 +15,7 @@
*
* Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
* (and possibly other members of the Gaim team)
- * Copyright 2002-2004 Wilmer van der Gaast <wilmer@gaast.net>
+ * Copyright 2002-2007 Wilmer van der Gaast <wilmer@gaast.net>
*/
/*
@@ -43,7 +44,6 @@
#include "md5.h"
#include "sha.h"
-
#define BUF_LEN MSG_LEN
#define BUF_LONG ( BUF_LEN * 2 )
#define MSG_LEN 2048
@@ -53,18 +53,19 @@
#define BUDDY_ALIAS_MAXLEN 388 /* because MSN names can be 387 characters */
#define WEBSITE "http://www.bitlbee.org/"
-#define IM_FLAG_AWAY 0x0020
#define GAIM_AWAY_CUSTOM "Custom"
-#define OPT_CONN_HTML 0x00000001
-#define OPT_LOGGED_IN 0x00010000
-#define OPT_LOGGING_OUT 0x00020000
+/* Sharing flags between buddies and connections. Or planning to, at least... */
+#define OPT_LOGGED_IN 0x00000001
+#define OPT_LOGGING_OUT 0x00000002
+#define OPT_AWAY 0x00000004
+#define OPT_DOES_HTML 0x00000010
/* ok. now the fun begins. first we create a connection structure */
struct im_connection
{
account_t *acc;
- guint32 flags;
+ u_int32_t flags;
/* each connection then can have its own protocol-specific data */
void *proto_data;
@@ -163,9 +164,6 @@ struct prpl {
struct groupchat *
(* chat_join) (struct im_connection *, char *chat, char *nick, char *password);
- /* DIE! */
- char *(* get_status_string) (struct im_connection *ic, int stat);
-
GList *(* away_states)(struct im_connection *ic);
/* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* */
@@ -200,7 +198,6 @@ G_MODULE_EXPORT struct groupchat *serv_got_joined_chat( struct im_connection *ic
G_MODULE_EXPORT void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, time_t mtime );
G_MODULE_EXPORT void serv_got_chat_left( struct groupchat *c );
struct groupchat *chat_by_channel( char *channel );
-struct groupchat *chat_by_id( int id );
/* Buddy management */
G_MODULE_EXPORT void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname );
@@ -208,7 +205,8 @@ G_MODULE_EXPORT struct buddy *find_buddy( struct im_connection *ic, char *handle
G_MODULE_EXPORT void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname );
/* Buddy activity */
-G_MODULE_EXPORT void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps );
+G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message );
+/* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle );
G_MODULE_EXPORT void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len );
G_MODULE_EXPORT void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type );
diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c
index 99f839e4..d05868b0 100644
--- a/protocols/oscar/oscar.c
+++ b/protocols/oscar/oscar.c
@@ -364,7 +364,7 @@ static void oscar_login(account_t *acc) {
Not touching this anymore now that it belongs to account_t!
Let's hope nothing will break. ;-) */
} else {
- ic->flags |= OPT_CONN_HTML;
+ ic->flags |= OPT_DOES_HTML;
}
sess = g_new0(aim_session_t, 1);
@@ -967,45 +967,35 @@ static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) {
struct oscar_data *od = ic->proto_data;
aim_userinfo_t *info;
time_t time_idle = 0, signon = 0;
- int type = 0;
- int caps = 0;
- char *tmp;
+ int flags = OPT_LOGGED_IN;
+ char *tmp, *state_string = NULL;
va_list ap;
va_start(ap, fr);
info = va_arg(ap, aim_userinfo_t *);
va_end(ap);
- if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES)
- caps = info->capabilities;
- if (info->flags & AIM_FLAG_ACTIVEBUDDY)
- type |= UC_AB;
-
if ((!od->icq) && (info->present & AIM_USERINFO_PRESENT_FLAGS)) {
- if (info->flags & AIM_FLAG_UNCONFIRMED)
- type |= UC_UNCONFIRMED;
- if (info->flags & AIM_FLAG_ADMINISTRATOR)
- type |= UC_ADMIN;
- if (info->flags & AIM_FLAG_AOL)
- type |= UC_AOL;
- if (info->flags & AIM_FLAG_FREE)
- type |= UC_NORMAL;
if (info->flags & AIM_FLAG_AWAY)
- type |= UC_UNAVAILABLE;
- if (info->flags & AIM_FLAG_WIRELESS)
- type |= UC_WIRELESS;
+ flags |= OPT_AWAY;
}
+
if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) {
- type = (info->icqinfo.status << 7);
if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) &&
(info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) {
- type |= UC_UNAVAILABLE;
+ flags |= OPT_AWAY;
}
+
+ if( info->icqinfo.status & AIM_ICQ_STATE_DND )
+ state_string = "Do Not Disturb";
+ else if( info->icqinfo.status & AIM_ICQ_STATE_OUT )
+ state_string = "Not Available";
+ else if( info->icqinfo.status & AIM_ICQ_STATE_BUSY )
+ state_string = "Occupied";
+ else if( info->icqinfo.status & AIM_ICQ_STATE_INVISIBLE )
+ state_string = "Invisible";
}
- if (caps & AIM_CAPS_ICQ)
- caps ^= AIM_CAPS_ICQ;
-
if (info->present & AIM_USERINFO_PRESENT_IDLE) {
time(&time_idle);
time_idle -= info->idletime*60;
@@ -1019,8 +1009,8 @@ static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) {
g_snprintf(ic->displayname, sizeof(ic->displayname), "%s", info->sn);
g_free(tmp);
- serv_got_update(ic, info->sn, 1, info->warnlevel/10, signon,
- time_idle, type, caps);
+ imcb_buddy_status(ic, info->sn, flags, state_string, NULL);
+ /* imcb_buddy_times(ic, info->sn, signon, time_idle); */
return 1;
}
@@ -1034,7 +1024,7 @@ static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) {
info = va_arg(ap, aim_userinfo_t *);
va_end(ap);
- serv_got_update(ic, info->sn, 0, 0, 0, 0, 0, 0);
+ imcb_buddy_status(ic, info->sn, 0, NULL, NULL );
return 1;
}
@@ -1045,7 +1035,7 @@ static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_
int flags = 0;
if (args->icbmflags & AIM_IMFLAGS_AWAY)
- flags |= IM_FLAG_AWAY;
+ flags |= OPT_AWAY;
if ((args->icbmflags & AIM_IMFLAGS_UNICODE) || (args->icbmflags & AIM_IMFLAGS_ISO_8859_1)) {
char *src;
@@ -1820,7 +1810,7 @@ static void oscar_keepalive(struct im_connection *ic) {
static int oscar_send_im(struct im_connection *ic, char *name, char *message, int imflags) {
struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
int ret = 0, len = strlen(message);
- if (imflags & IM_FLAG_AWAY) {
+ if (imflags & OPT_AWAY) {
ret = aim_send_im(odata->sess, name, AIM_IMFLAGS_AWAY, message);
} else {
struct aim_sendimext_args args;
@@ -2444,34 +2434,6 @@ int gaim_parsemtn(aim_session_t *sess, aim_frame_t *fr, ...)
return 1;
}
-static char *oscar_get_status_string( struct im_connection *ic, int number )
-{
- struct oscar_data *od = ic->proto_data;
-
- if( ! number & UC_UNAVAILABLE )
- {
- return( NULL );
- }
- else if( od->icq )
- {
- number >>= 7;
- if( number & AIM_ICQ_STATE_DND )
- return( "Do Not Disturb" );
- else if( number & AIM_ICQ_STATE_OUT )
- return( "Not Available" );
- else if( number & AIM_ICQ_STATE_BUSY )
- return( "Occupied" );
- else if( number & AIM_ICQ_STATE_INVISIBLE )
- return( "Invisible" );
- else
- return( "Away" );
- }
- else
- {
- return( "Away" );
- }
-}
-
int oscar_send_typing(struct im_connection *ic, char * who, int typing)
{
struct oscar_data *od = ic->proto_data;
@@ -2632,7 +2594,6 @@ void oscar_initmodule()
ret->rem_permit = oscar_rem_permit;
ret->rem_deny = oscar_rem_deny;
ret->set_permit_deny = oscar_set_permit_deny;
- ret->get_status_string = oscar_get_status_string;
ret->send_typing = oscar_send_typing;
ret->handle_cmp = aim_sncmp;
diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c
index e380d0ae..dec42bdc 100644
--- a/protocols/yahoo/yahoo.c
+++ b/protocols/yahoo/yahoo.c
@@ -292,45 +292,6 @@ static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *grou
}
}
-static char *byahoo_get_status_string( struct im_connection *ic, int stat )
-{
- enum yahoo_status a = stat >> 1;
-
- switch (a)
- {
- case YAHOO_STATUS_BRB:
- return "Be Right Back";
- case YAHOO_STATUS_BUSY:
- return "Busy";
- case YAHOO_STATUS_NOTATHOME:
- return "Not At Home";
- case YAHOO_STATUS_NOTATDESK:
- return "Not At Desk";
- case YAHOO_STATUS_NOTINOFFICE:
- return "Not In Office";
- case YAHOO_STATUS_ONPHONE:
- return "On Phone";
- case YAHOO_STATUS_ONVACATION:
- return "On Vacation";
- case YAHOO_STATUS_OUTTOLUNCH:
- return "Out To Lunch";
- case YAHOO_STATUS_STEPPEDOUT:
- return "Stepped Out";
- case YAHOO_STATUS_INVISIBLE:
- return "Invisible";
- case YAHOO_STATUS_CUSTOM:
- return "Away";
- case YAHOO_STATUS_IDLE:
- return "Idle";
- case YAHOO_STATUS_OFFLINE:
- return "Offline";
- case YAHOO_STATUS_NOTIFY:
- return "Notify";
- default:
- return "Away";
- }
-}
-
static void byahoo_chat_send( struct groupchat *c, char *message, int flags )
{
struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data;
@@ -392,7 +353,6 @@ void byahoo_initmodule( )
ret->set_away = byahoo_set_away;
ret->add_buddy = byahoo_add_buddy;
ret->remove_buddy = byahoo_remove_buddy;
- ret->get_status_string = byahoo_get_status_string;
ret->send_typing = byahoo_send_typing;
ret->chat_send = byahoo_chat_send;
@@ -585,10 +545,65 @@ void ext_yahoo_got_cookies( int id )
void ext_yahoo_status_changed( int id, char *who, int stat, char *msg, int away )
{
struct im_connection *ic = byahoo_get_ic_by_id( id );
+ char *state_string = NULL;
+ int flags = OPT_LOGGED_IN;
+
+ if( away )
+ flags |= OPT_AWAY;
+
+ switch (stat)
+ {
+ case YAHOO_STATUS_BRB:
+ state_string = "Be Right Back";
+ break;
+ case YAHOO_STATUS_BUSY:
+ state_string = "Busy";
+ break;
+ case YAHOO_STATUS_NOTATHOME:
+ state_string = "Not At Home";
+ break;
+ case YAHOO_STATUS_NOTATDESK:
+ state_string = "Not At Desk";
+ break;
+ case YAHOO_STATUS_NOTINOFFICE:
+ state_string = "Not In Office";
+ break;
+ case YAHOO_STATUS_ONPHONE:
+ state_string = "On Phone";
+ break;
+ case YAHOO_STATUS_ONVACATION:
+ state_string = "On Vacation";
+ break;
+ case YAHOO_STATUS_OUTTOLUNCH:
+ state_string = "Out To Lunch";
+ break;
+ case YAHOO_STATUS_STEPPEDOUT:
+ state_string = "Stepped Out";
+ break;
+ case YAHOO_STATUS_INVISIBLE:
+ state_string = "Invisible";
+ break;
+ case YAHOO_STATUS_CUSTOM:
+ state_string = "Away";
+ break;
+ case YAHOO_STATUS_IDLE:
+ state_string = "Idle";
+ break;
+ case YAHOO_STATUS_OFFLINE:
+ state_string = "Offline";
+ flags = 0;
+ break;
+ case YAHOO_STATUS_NOTIFY:
+ state_string = "Notify";
+ break;
+ }
+
+ imcb_buddy_status( ic, who, flags, state_string, msg );
- serv_got_update( ic, who, stat != YAHOO_STATUS_OFFLINE, 0, 0,
- ( stat == YAHOO_STATUS_IDLE ) ? away : 0,
- ( stat != YAHOO_STATUS_AVAILABLE ) | ( stat << 1 ), 0 );
+ /* Not implemented yet...
+ if( stat == YAHOO_STATUS_IDLE )
+ imcb_buddy_times( ic, who, 0, away );
+ */
}
void ext_yahoo_got_im( int id, char *who, char *msg, long tm, int stat, int utf8 )