diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2007-04-16 21:49:17 -0700 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2007-04-16 21:49:17 -0700 |
commit | 9624fdf0d6f170d8caa7948fb1b3a138b05e1d8c (patch) | |
tree | aa75862ae3adae1dcdfb689361528289edaeea12 | |
parent | 717e3bf045e5ebfb9b71e9260c8e573daefa7900 (diff) |
API cleanup pretty much complete. Fixed pretty much everything except the
buddy/groupchat related functions.
-rw-r--r-- | protocols/jabber/message.c | 8 | ||||
-rw-r--r-- | protocols/msn/sb.c | 6 | ||||
-rw-r--r-- | protocols/nogaim.c | 25 | ||||
-rw-r--r-- | protocols/nogaim.h | 14 | ||||
-rw-r--r-- | protocols/oscar/oscar.c | 16 | ||||
-rw-r--r-- | protocols/yahoo/yahoo.c | 15 |
6 files changed, 38 insertions, 46 deletions
diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index 6c105d1d..19edbdfd 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -75,7 +75,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) fullmsg = g_string_append( fullmsg, body->text ); if( fullmsg->len > 0 ) - serv_got_im( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len ); + imcb_buddy_msg( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0 ); g_string_free( fullmsg, TRUE ); @@ -83,18 +83,18 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) if( xt_find_node( node->children, "composing" ) ) { bud->flags |= JBFLAG_DOES_XEP85; - serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 1 ); + imcb_buddy_typing( ic, bud ? bud->bare_jid : from, OPT_TYPING ); } /* No need to send a "stopped typing" signal when there's a message. */ else if( xt_find_node( node->children, "active" ) && ( body == NULL ) ) { bud->flags |= JBFLAG_DOES_XEP85; - serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 0 ); + imcb_buddy_typing( ic, bud ? bud->bare_jid : from, 0 ); } else if( xt_find_node( node->children, "paused" ) ) { bud->flags |= JBFLAG_DOES_XEP85; - serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 2 ); + imcb_buddy_typing( ic, bud ? bud->bare_jid : from, OPT_THINKING ); } if( s ) diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index 614fb79c..c3eaef60 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -606,7 +606,7 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int if( sb->who ) { - serv_got_im( ic, cmd[1], body, 0, 0, blen ); + imcb_buddy_msg( ic, cmd[1], body, 0, 0 ); } else if( sb->chat ) { @@ -665,7 +665,7 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int if( sb->who ) { - serv_got_im( ic, cmd[1], buf, 0, 0, strlen( buf ) ); + imcb_buddy_msg( ic, cmd[1], buf, 0, 0 ); } else if( sb->chat ) { @@ -682,7 +682,7 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int if( who ) { - serv_got_typing( ic, who, 5, 1 ); + imcb_buddy_typing( ic, who, OPT_TYPING ); g_free( who ); } diff --git a/protocols/nogaim.c b/protocols/nogaim.c index ef30f749..2a452e57 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -423,7 +423,7 @@ struct buddy *find_buddy( struct im_connection *ic, char *handle ) if( !u ) return( NULL ); - + memset( b, 0, sizeof( b ) ); strncpy( b->name, handle, 80 ); strncpy( b->show, u->realname, BUDDY_ALIAS_MAXLEN ); @@ -574,11 +574,11 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ { irc_write( ic->irc, ":%s MODE %s %cv %s", ic->irc->myhost, - ic->irc->channel, u->away?'-':'+', u->nick ); + ic->irc->channel, u->away?'-':'+', u->nick ); } } -void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len ) +void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at ) { irc_t *irc = ic->irc; user_t *u; @@ -656,24 +656,19 @@ void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 fla irc_msgfrom( irc, u->nick, msg ); } -void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type ) +void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags ) { user_t *u; if( !set_getbool( &ic->irc->set, "typing_notice" ) ) return; - if( ( u = user_findhandle( ic, handle ) ) ) { - /* If type is: - * 0: user has stopped typing - * 1: user is actively typing - * 2: user has entered text, but is not actively typing - */ - if (type == 0 || type == 1 || type == 2) { - char buf[256]; - g_snprintf(buf, 256, "\1TYPING %d\1", type); - irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf ); - } + if( ( u = user_findhandle( ic, handle ) ) ) + { + char buf[256]; + + g_snprintf( buf, 256, "\1TYPING %d\1", ( flags >> 8 ) & 3 ); + irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf ); } } diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 62d8db41..e249ae0e 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -49,17 +49,19 @@ #define MSG_LEN 2048 #define BUF_LEN MSG_LEN -#define SELF_ALIAS_LEN 400 #define BUDDY_ALIAS_MAXLEN 388 /* because MSN names can be 387 characters */ #define WEBSITE "http://www.bitlbee.org/" #define GAIM_AWAY_CUSTOM "Custom" -/* Sharing flags between buddies and connections. Or planning to, at least... */ +/* Sharing flags between all kinds of things. I just hope I won't hit any + limits before 32-bit machines become extinct. ;-) */ #define OPT_LOGGED_IN 0x00000001 #define OPT_LOGGING_OUT 0x00000002 #define OPT_AWAY 0x00000004 #define OPT_DOES_HTML 0x00000010 +#define OPT_TYPING 0x00000100 +#define OPT_THINKING 0x00000200 /* ok. now the fun begins. first we create a connection structure */ struct im_connection @@ -135,7 +137,7 @@ struct prpl { int (* send_im) (struct im_connection *, char *to, char *message, int flags); void (* set_away) (struct im_connection *, char *state, char *message); void (* get_away) (struct im_connection *, char *who); - int (* send_typing) (struct im_connection *, char *who, int typing); + int (* send_typing) (struct im_connection *, char *who, int flags); /* For now BitlBee doesn't really handle groups, just set it to NULL. */ void (* add_buddy) (struct im_connection *, char *name, char *group); @@ -170,8 +172,6 @@ struct prpl { int (* handle_cmp) (const char *who1, const char *who2); }; -#define UC_UNAVAILABLE 1 - /* im_api core stuff. */ void nogaim_init(); G_MODULE_EXPORT GSList *get_connections(); @@ -207,8 +207,8 @@ G_MODULE_EXPORT void serv_buddy_rename( struct im_connection *ic, char *handle, /* Buddy activity */ 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 ); +G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at ); +G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags ); /* Actions, or whatever. */ int imc_set_away( struct im_connection *ic, char *away ); diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index d05868b0..407aba7f 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -1069,7 +1069,7 @@ static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_ g_snprintf(tmp, BUF_LONG, "%s", args->msg); strip_linefeed(tmp); - serv_got_im(ic, userinfo->sn, tmp, flags, time(NULL), -1); + imcb_buddy_msg(ic, userinfo->sn, tmp, flags, 0); g_free(tmp); return 1; @@ -1166,7 +1166,7 @@ static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_ uin = g_strdup_printf("%u", args->uin); message = g_strdup(args->msg); strip_linefeed(message); - serv_got_im(ic, uin, message, 0, time(NULL), -1); + imcb_buddy_msg(ic, uin, message, 0, 0); g_free(uin); g_free(message); } break; @@ -1185,7 +1185,7 @@ static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_ } strip_linefeed(message); - serv_got_im(ic, uin, message, 0, time(NULL), -1); + imcb_buddy_msg(ic, uin, message, 0, 0); g_free(uin); g_free(m); g_free(message); @@ -1747,7 +1747,7 @@ static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) { time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); g_snprintf(sender, sizeof(sender), "%u", msg->sender); strip_linefeed(dialog_msg); - serv_got_im(ic, sender, dialog_msg, 0, t, -1); + imcb_buddy_msg(ic, sender, dialog_msg, 0, t); g_free(dialog_msg); } break; @@ -1768,7 +1768,7 @@ static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) { } strip_linefeed(dialog_msg); - serv_got_im(ic, sender, dialog_msg, 0, t, -1); + imcb_buddy_msg(ic, sender, dialog_msg, 0, t); g_free(dialog_msg); g_free(m); } break; @@ -2420,15 +2420,15 @@ int gaim_parsemtn(aim_session_t *sess, aim_frame_t *fr, ...) if(type2 == 0x0002) { /* User is typing */ - serv_got_typing(ic, sn, 0, 1); + imcb_buddy_typing(ic, sn, OPT_TYPING); } else if (type2 == 0x0001) { /* User has typed something, but is not actively typing (stale) */ - serv_got_typing(ic, sn, 0, 2); + imcb_buddy_typing(ic, sn, OPT_THINKING); } else { /* User has stopped typing */ - serv_got_typing(ic, sn, 0, 0); + imcb_buddy_typing(ic, sn, 0); } return 1; diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index aad9d2df..191a197c 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -617,7 +617,7 @@ void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg, struct im_connection *ic = byahoo_get_ic_by_id( id ); char *m = byahoo_strip( msg ); - serv_got_im( ic, (char*) who, (char*) m, 0, 0, strlen( m ) ); + imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 ); g_free( m ); } @@ -633,14 +633,11 @@ void ext_yahoo_got_file( int id, void ext_yahoo_typing_notify( int id, const char *ignored, const char *who, int stat ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); - if (stat == 1) { - /* User is typing */ - serv_got_typing( ic, (char*) who, 1, 1 ); - } - else { - /* User stopped typing */ - serv_got_typing( ic, (char*) who, 1, 0 ); - } + + if( stat == 1 ) + imcb_buddy_typing( ic, (char*) who, OPT_TYPING ); + else + imcb_buddy_typing( ic, (char*) who, 0 ); } void ext_yahoo_system_message( int id, const char *msg ) |