aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/jabber/conference.c66
-rw-r--r--protocols/jabber/io.c10
-rw-r--r--protocols/jabber/iq.c15
-rw-r--r--protocols/jabber/jabber.c11
-rw-r--r--protocols/jabber/jabber.h22
-rw-r--r--protocols/jabber/jabber_util.c44
-rw-r--r--protocols/jabber/presence.c76
-rw-r--r--protocols/msn/msn.c18
-rw-r--r--protocols/msn/msn.h11
-rw-r--r--protocols/msn/msn_util.c34
-rw-r--r--protocols/msn/ns.c6
-rw-r--r--protocols/msn/sb.c97
-rw-r--r--protocols/nogaim.c75
-rw-r--r--protocols/nogaim.h10
-rw-r--r--protocols/oscar/oscar.c200
-rw-r--r--protocols/oscar/service.c2
-rw-r--r--protocols/oscar/txqueue.c2
-rw-r--r--protocols/yahoo/yahoo.c20
18 files changed, 468 insertions, 251 deletions
diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c
index 074412ec..79fdd053 100644
--- a/protocols/jabber/conference.c
+++ b/protocols/jabber/conference.c
@@ -36,6 +36,8 @@ struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *
node = xt_new_node( "x", NULL, NULL );
xt_add_attr( node, "xmlns", XMLNS_MUC );
node = jabber_make_packet( "presence", NULL, roomjid, node );
+ if( password )
+ xt_add_child( node, xt_new_node( "password", password, NULL ) );
jabber_cache_add( ic, node, jabber_chat_join_failed );
if( !jabber_write_packet( ic, node ) )
@@ -72,17 +74,16 @@ static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_no
char *room;
room = xt_find_attr( orig, "to" );
- if( ( bud = jabber_buddy_by_jid( ic, room, 0 ) ) )
- jabber_chat_free( jabber_chat_by_jid( ic, bud->bare_jid ) );
-
+ bud = jabber_buddy_by_jid( ic, room, 0 );
err = jabber_error_parse( xt_find_node( node->children, "error" ), XMLNS_STANZA_ERROR );
if( err )
{
- imcb_error( ic, "Error joining groupchat %s: %s%s%s",
- bud->bare_jid, err->code, err->text ? ": " : "",
- err->text ? err->text : "" );
+ imcb_error( ic, "Error joining groupchat %s: %s%s%s", room, err->code,
+ err->text ? ": " : "", err->text ? err->text : "" );
jabber_error_free( err );
}
+ if( bud )
+ jabber_chat_free( jabber_chat_by_jid( ic, bud->bare_jid ) );
return XT_HANDLED;
}
@@ -123,6 +124,8 @@ int jabber_chat_msg( struct groupchat *c, char *message, int flags )
struct jabber_chat *jc = c->data;
struct xt_node *node;
+ jc->flags |= JCFLAG_MESSAGE_SENT;
+
node = xt_new_node( "body", message, NULL );
node = jabber_make_packet( "message", "groupchat", jc->name, node );
@@ -295,22 +298,59 @@ void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud
{
struct xt_node *subject = xt_find_node( node->children, "subject" );
struct xt_node *body = xt_find_node( node->children, "body" );
- struct groupchat *chat;
+ struct groupchat *chat = bud ? jabber_chat_by_jid( ic, bud->bare_jid ) : NULL;
+ struct jabber_chat *jc = chat ? chat->data : NULL;
char *s;
- if( bud == NULL )
+ if( bud == NULL || ( jc && ~jc->flags & JCFLAG_MESSAGE_SENT && bud == jc->me ) )
{
+ char *nick;
+
+ if( body == NULL || body->text_len == 0 )
+ /* Meh. Empty messages aren't very interesting, no matter
+ how much some servers love to send them. */
+ return;
+
s = xt_find_attr( node, "from" ); /* pkt_message() already NULL-checked this one. */
- if( strchr( s, '/' ) == NULL )
+ nick = strchr( s, '/' );
+ if( nick )
+ {
+ /* If this message included a resource/nick we don't know,
+ we might still know the groupchat itself. */
+ *nick = 0;
+ chat = jabber_chat_by_jid( ic, s );
+ *nick = '/';
+
+ nick ++;
+ }
+ else
+ {
+ /* message.c uses the EXACT_JID option, so bud should
+ always be NULL here for bare JIDs. */
+ chat = jabber_chat_by_jid( ic, s );
+ }
+
+ if( nick == NULL )
+ {
/* This is fine, the groupchat itself isn't in jd->buddies. */
- imcb_log( ic, "System message from groupchat %s: %s", s, body? body->text : "NULL" );
+ if( chat )
+ imcb_chat_log( chat, "From conference server: %s", body->text );
+ else
+ imcb_log( ic, "System message from unknown groupchat %s: %s", s, body->text );
+ }
else
- /* This, however, isn't fine! */
- imcb_log( ic, "Groupchat message from unknown participant %s: %s", s, body ? body->text : "NULL" );
+ {
+ /* This can happen too, at least when receiving a backlog when
+ just joining a channel. */
+ if( chat )
+ imcb_chat_log( chat, "Message from unknown participant %s: %s", nick, body->text );
+ else
+ imcb_log( ic, "Groupchat message from unknown JID %s: %s", s, body->text );
+ }
return;
}
- else if( ( chat = jabber_chat_by_jid( ic, bud->bare_jid ) ) == NULL )
+ else if( chat == NULL )
{
/* How could this happen?? We could do kill( self, 11 )
now or just wait for the OS to do it. :-) */
diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c
index 29561b86..86c216ef 100644
--- a/protocols/jabber/io.c
+++ b/protocols/jabber/io.c
@@ -248,6 +248,9 @@ gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition c
{
struct im_connection *ic = data;
+ if( g_slist_find( jabber_connections, ic ) == NULL )
+ return FALSE;
+
if( source == -1 )
{
imcb_error( ic, "Could not connect to server" );
@@ -263,7 +266,12 @@ gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition c
gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition cond )
{
struct im_connection *ic = data;
- struct jabber_data *jd = ic->proto_data;
+ struct jabber_data *jd;
+
+ if( g_slist_find( jabber_connections, ic ) == NULL )
+ return FALSE;
+
+ jd = ic->proto_data;
if( source == NULL )
{
diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c
index 2f0959b0..d45b7625 100644
--- a/protocols/jabber/iq.c
+++ b/protocols/jabber/iq.c
@@ -53,7 +53,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
( c = xt_find_node( node->children, "ping" ) ) ) || /* O_o WHAT is wrong with just <query/> ????? */
!( s = xt_find_attr( c, "xmlns" ) ) )
{
- imcb_log( ic, "WARNING: Received incomplete IQ-%s packet", type );
+ imcb_log( ic, "Warning: Received incomplete IQ-%s packet", type );
return XT_HANDLED;
}
@@ -91,7 +91,8 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
}
else if( strcmp( s, XMLNS_DISCO_INFO ) == 0 )
{
- const char *features[] = { XMLNS_VERSION,
+ const char *features[] = { XMLNS_DISCO_INFO,
+ XMLNS_VERSION,
XMLNS_TIME,
XMLNS_CHATSTATES,
XMLNS_MUC,
@@ -131,7 +132,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
} else if( !( c = xt_find_node( node->children, "query" ) ) ||
!( s = xt_find_attr( c, "xmlns" ) ) )
{
- imcb_log( ic, "WARNING: Received incomplete IQ-%s packet", type );
+ imcb_log( ic, "Warning: Received incomplete IQ-%s packet", type );
return XT_HANDLED;
} else if( strcmp( s, XMLNS_ROSTER ) == 0 )
{
@@ -151,7 +152,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
}
else
{
- imcb_log( ic, "WARNING: %s tried to fake a roster push!", s ? s : "(unknown)" );
+ imcb_log( ic, "Warning: %s tried to fake a roster push!", s ? s : "(unknown)" );
xt_free_node( reply );
reply = jabber_make_error_packet( node, "not-allowed", "cancel", NULL );
@@ -219,7 +220,7 @@ static xt_status jabber_do_iq_auth( struct im_connection *ic, struct xt_node *no
if( !( query = xt_find_node( node->children, "query" ) ) )
{
- imcb_log( ic, "WARNING: Received incomplete IQ packet while authenticating" );
+ imcb_log( ic, "Warning: Received incomplete IQ packet while authenticating" );
imc_logout( ic, FALSE );
return XT_HANDLED;
}
@@ -277,7 +278,7 @@ static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node
if( !( type = xt_find_attr( node, "type" ) ) )
{
- imcb_log( ic, "WARNING: Received incomplete IQ packet while authenticating" );
+ imcb_log( ic, "Warning: Received incomplete IQ packet while authenticating" );
imc_logout( ic, FALSE );
return XT_HANDLED;
}
@@ -353,7 +354,7 @@ static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *
if( !( query = xt_find_node( node->children, "query" ) ) )
{
- imcb_log( ic, "WARNING: Received NULL roster packet" );
+ imcb_log( ic, "Warning: Received NULL roster packet" );
return XT_HANDLED;
}
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index d028655a..07d760a5 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -34,6 +34,8 @@
#include "md5.h"
#include "base64.h"
+GSList *jabber_connections;
+
static void jabber_init( account_t *acc )
{
set_t *s;
@@ -70,6 +72,11 @@ static void jabber_login( account_t *acc )
struct ns_srv_reply *srv = NULL;
char *connect_to, *s;
+ /* For now this is needed in the _connected() handlers if using
+ GLib event handling, to make sure we're not handling events
+ on dead connections. */
+ jabber_connections = g_slist_prepend( jabber_connections, ic );
+
jd->ic = ic;
ic->proto_data = jd;
@@ -196,6 +203,8 @@ static void jabber_login( account_t *acc )
{
imcb_error( ic, "Could not connect to server" );
imc_logout( ic, TRUE );
+
+ return;
}
if( set_getbool( &acc->set, "xmlconsole" ) )
@@ -260,6 +269,8 @@ static void jabber_logout( struct im_connection *ic )
g_free( jd->away_message );
g_free( jd->username );
g_free( jd );
+
+ jabber_connections = g_slist_remove( jabber_connections, ic );
}
static int jabber_buddy_msg( struct im_connection *ic, char *who, char *message, int flags )
diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h
index 3251b49b..fc315710 100644
--- a/protocols/jabber/jabber.h
+++ b/protocols/jabber/jabber.h
@@ -29,6 +29,8 @@
#include "xmltree.h"
#include "bitlbee.h"
+extern GSList *jabber_connections;
+
typedef enum
{
JFLAG_STREAM_STARTED = 1, /* Set when we detected the beginning of the stream
@@ -46,13 +48,13 @@ typedef enum
typedef enum
{
- JBFLAG_PROBED_XEP85 = 1, /* Set this when we sent our probe packet to make
+ JBFLAG_PROBED_XEP85 = 1, /* Set this when we sent our probe packet to make
sure it gets sent only once. */
- JBFLAG_DOES_XEP85 = 2, /* Set this when the resource seems to support
+ JBFLAG_DOES_XEP85 = 2, /* Set this when the resource seems to support
XEP85 (typing notification shite). */
- JBFLAG_IS_CHATROOM = 4, /* It's convenient to use this JID thingy for
+ JBFLAG_IS_CHATROOM = 4, /* It's convenient to use this JID thingy for
groupchat state info too. */
- JBFLAG_IS_ANONYMOUS = 8, /* For anonymous chatrooms, when we don't have
+ JBFLAG_IS_ANONYMOUS = 8, /* For anonymous chatrooms, when we don't have
have a real JID. */
} jabber_buddy_flags_t;
@@ -64,6 +66,12 @@ typedef struct
char port[6];
} jabber_streamhost_t;
+typedef enum
+{
+ JCFLAG_MESSAGE_SENT = 1, /* Set this after sending the first message, so
+ we can detect echoes/backlogs. */
+} jabber_chat_flags_t;
+
struct jabber_data
{
struct im_connection *ic;
@@ -104,6 +112,7 @@ typedef xt_status (*jabber_cache_event) ( struct im_connection *ic, struct xt_no
struct jabber_cache_entry
{
+ time_t saved_at;
struct xt_node *node;
jabber_cache_event func;
};
@@ -175,6 +184,10 @@ struct jabber_transfer
#define JABBER_PACKET_ID "BeeP"
#define JABBER_CACHED_ID "BeeC"
+/* The number of seconds to keep cached packets before garbage collecting
+ them. This gc is done on every keepalive (every minute). */
+#define JABBER_CACHE_MAX_AGE 600
+
/* RFC 392[01] stuff */
#define XMLNS_TLS "urn:ietf:params:xml:ns:xmpp-tls"
#define XMLNS_SASL "urn:ietf:params:xml:ns:xmpp-sasl"
@@ -197,6 +210,7 @@ struct jabber_transfer
#define XMLNS_DISCO_ITEMS "http://jabber.org/protocol/disco#items" /* XEP-0030 */
#define XMLNS_MUC "http://jabber.org/protocol/muc" /* XEP-0045 */
#define XMLNS_MUC_USER "http://jabber.org/protocol/muc#user" /* XEP-0045 */
+#define XMLNS_CAPS "http://jabber.org/protocol/caps" /* XEP-0115 */
#define XMLNS_FEATURE "http://jabber.org/protocol/feature-neg" /* XEP-0020 */
#define XMLNS_SI "http://jabber.org/protocol/si" /* XEP-0095 */
#define XMLNS_FILETRANSFER "http://jabber.org/protocol/si/profile/file-transfer" /* XEP-0096 */
diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c
index 7350eaf4..c8470b57 100644
--- a/protocols/jabber/jabber_util.c
+++ b/protocols/jabber/jabber_util.c
@@ -145,6 +145,7 @@ void jabber_cache_add( struct im_connection *ic, struct xt_node *node, jabber_ca
entry->node = node;
entry->func = func;
+ entry->saved_at = time( NULL );
g_hash_table_insert( jd->node_cache, xt_find_attr( node, "id" ), entry );
}
@@ -166,22 +167,17 @@ gboolean jabber_cache_clean_entry( gpointer key, gpointer entry, gpointer nullpo
void jabber_cache_clean( struct im_connection *ic )
{
struct jabber_data *jd = ic->proto_data;
+ time_t threshold = time( NULL ) - JABBER_CACHE_MAX_AGE;
- g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, NULL );
+ g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, &threshold );
}
-gboolean jabber_cache_clean_entry( gpointer key, gpointer entry_, gpointer nullpointer )
+gboolean jabber_cache_clean_entry( gpointer key, gpointer entry_, gpointer threshold_ )
{
struct jabber_cache_entry *entry = entry_;
- struct xt_node *node = entry->node;
+ time_t *threshold = threshold_;
- if( node->flags & XT_SEEN )
- return TRUE;
- else
- {
- node->flags |= XT_SEEN;
- return FALSE;
- }
+ return entry->saved_at < *threshold;
}
xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *node )
@@ -203,7 +199,7 @@ xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *
if( entry == NULL )
{
- imcb_log( ic, "WARNING: Received %s-%s packet with unknown/expired ID %s!",
+ imcb_log( ic, "Warning: Received %s-%s packet with unknown/expired ID %s!",
node->name, xt_find_attr( node, "type" ) ? : "(no type)", s );
}
else if( entry->func )
@@ -402,19 +398,26 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_,
*s = 0;
if( ( bud = g_hash_table_lookup( jd->buddies, jid ) ) )
{
+ /* Just return the first one for this bare JID. */
+ if( flags & GET_BUDDY_FIRST )
+ {
+ *s = '/';
+ g_free( jid );
+ return bud;
+ }
+
/* Is this one of those no-resource buddies? */
if( bud->resource == NULL )
{
+ *s = '/';
g_free( jid );
return NULL;
}
- else
- {
- /* See if there's an exact match. */
- for( ; bud; bud = bud->next )
- if( g_strcasecmp( bud->resource, s + 1 ) == 0 )
- break;
- }
+
+ /* See if there's an exact match. */
+ for( ; bud; bud = bud->next )
+ if( g_strcasecmp( bud->resource, s + 1 ) == 0 )
+ break;
}
else
{
@@ -423,6 +426,8 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_,
for this JID, even if it's an unknown buddy. This
is done to handle conferences properly. */
none_found = 1;
+ /* TODO(wilmer): Find out what I was thinking when I
+ wrote this??? And then fix it. This makes me sad... */
}
if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && ( imcb_find_buddy( ic, jid ) || !none_found ) )
@@ -453,6 +458,9 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_,
else if( ( bud->resource == NULL || bud->next == NULL ) )
/* No need for selection if there's only one option. */
return bud;
+ else if( flags & GET_BUDDY_FIRST )
+ /* Looks like the caller doesn't care about details. */
+ return bud;
best_prio = best_time = bud;
for( ; bud; bud = bud->next )
diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c
index c3d7dced..6fc360b7 100644
--- a/protocols/jabber/presence.c
+++ b/protocols/jabber/presence.c
@@ -28,9 +28,9 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
struct im_connection *ic = data;
char *from = xt_find_attr( node, "from" );
char *type = xt_find_attr( node, "type" ); /* NULL should mean the person is online. */
- struct xt_node *c;
- struct jabber_buddy *bud;
- int is_chat = 0, is_away = 0;
+ struct xt_node *c, *cap;
+ struct jabber_buddy *bud, *send_presence = NULL;
+ int is_chat = 0;
char *s;
if( !from )
@@ -49,7 +49,7 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
if( !( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) )
{
if( set_getbool( &ic->irc->set, "debug" ) )
- imcb_log( ic, "WARNING: Could not handle presence information from JID: %s", from );
+ imcb_log( ic, "Warning: Could not handle presence information from JID: %s", from );
return XT_HANDLED;
}
@@ -62,8 +62,6 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
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
{
@@ -78,19 +76,37 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
else
bud->priority = 0;
+ if( bud && ( cap = xt_find_node( node->children, "c" ) ) &&
+ ( s = xt_find_attr( cap, "xmlns" ) ) && strcmp( s, XMLNS_CAPS ) == 0 )
+ {
+ /* This <presence> stanza includes an XEP-0115
+ capabilities part. Not too interesting, but we can
+ see if it has an ext= attribute. */
+ s = xt_find_attr( cap, "ext" );
+ if( s && ( strstr( s, "cstates" ) || strstr( s, "chatstate" ) ) )
+ bud->flags |= JBFLAG_DOES_XEP85;
+
+ /* This field can contain more information like xhtml
+ support, but we don't support that ourselves.
+ Officially the ext= tag was deprecated, but enough
+ clients do send it.
+
+ (I'm aware that this is not the right way to use
+ this field.) See for an explanation of ext=:
+ http://www.xmpp.org/extensions/attic/xep-0115-1.3.html*/
+ }
+
if( is_chat )
jabber_chat_pkt_presence( ic, bud, node );
- else if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) )
- imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away,
- ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL,
- bud->away_message );
+ else
+ send_presence = jabber_buddy_by_jid( ic, bud->bare_jid, 0 );
}
else if( strcmp( type, "unavailable" ) == 0 )
{
if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) == NULL )
{
if( set_getbool( &ic->irc->set, "debug" ) )
- imcb_log( ic, "WARNING: Received presence information from unknown JID: %s", from );
+ imcb_log( ic, "Warning: Received presence information from unknown JID: %s", from );
return XT_HANDLED;
}
@@ -118,17 +134,7 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
/* If another resource is still available, send its presence
information. */
- if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) )
- {
- if( bud->away_state && ( *bud->away_state->code == 0 ||
- strcmp( bud->away_state->code, "chat" ) == 0 ) )
- is_away = OPT_AWAY;
-
- imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away,
- ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL,
- bud->away_message );
- }
- else
+ if( ( send_presence = jabber_buddy_by_jid( ic, from, 0 ) ) == NULL )
{
/* Otherwise, count him/her as offline now. */
imcb_buddy_status( ic, from, 0, NULL, NULL );
@@ -176,6 +182,20 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
jabber_error_free( err );
} */
}
+
+ if( send_presence )
+ {
+ int is_away = 0;
+
+ if( send_presence->away_state && !( *send_presence->away_state->code == 0 ||
+ strcmp( send_presence->away_state->code, "chat" ) == 0 ) )
+ is_away = OPT_AWAY;
+
+ imcb_buddy_status( ic, send_presence->bare_jid, OPT_LOGGED_IN | is_away,
+ ( is_away && send_presence->away_state ) ?
+ send_presence->away_state->full_name : NULL,
+ send_presence->away_message );
+ }
return XT_HANDLED;
}
@@ -185,7 +205,7 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
int presence_send_update( struct im_connection *ic )
{
struct jabber_data *jd = ic->proto_data;
- struct xt_node *node;
+ struct xt_node *node, *cap;
char *show = jd->away_state->code;
char *status = jd->away_message;
struct groupchat *c;
@@ -198,6 +218,16 @@ int presence_send_update( struct im_connection *ic )
if( status )
xt_add_child( node, xt_new_node( "status", status, NULL ) );
+ /* This makes the packet slightly bigger, but clients interested in
+ capabilities can now cache the discovery info. This reduces the
+ usual post-login iq-flood. See XEP-0115. At least libpurple and
+ Trillian seem to do this right. */
+ cap = xt_new_node( "c", NULL, NULL );
+ xt_add_attr( cap, "xmlns", XMLNS_CAPS );
+ xt_add_attr( cap, "node", "http://bitlbee.org/xmpp/caps" );
+ xt_add_attr( cap, "ver", BITLBEE_VERSION ); /* The XEP wants this hashed, but nobody's doing that. */
+ xt_add_child( node, cap );
+
st = jabber_write_packet( ic, node );
/* Have to send this update to all groupchats too, the server won't
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c
index aa05dbdd..a2e8519a 100644
--- a/protocols/msn/msn.c
+++ b/protocols/msn/msn.c
@@ -34,6 +34,8 @@ static void msn_init( account_t *acc )
s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc );
s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY;
+
+ s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
}
static void msn_login( account_t *acc )
@@ -87,21 +89,7 @@ static void msn_logout( struct im_connection *ic )
while( md->switchboards )
msn_sb_destroy( md->switchboards->data );
- if( md->msgq )
- {
- struct msn_message *m;
-
- for( l = md->msgq; l; l = l->next )
- {
- m = l->data;
-
- imcb_log( ic, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who );
- g_free( m->who );
- g_free( m->text );
- g_free( m );
- }
- g_slist_free( md->msgq );
- }
+ msn_msgq_purge( ic, &md->msgq );
while( md->groupcount > 0 )
g_free( md->grouplist[--md->groupcount] );
diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h
index 721466d6..c8f4f4c6 100644
--- a/protocols/msn/msn.h
+++ b/protocols/msn/msn.h
@@ -28,11 +28,9 @@
#define TYPING_NOTIFICATION_MESSAGE "\r\r\rBEWARE, ME R TYPINK MESSAGE!!!!\r\r\r"
#define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r"
-#ifdef _WIN32
-#define debug
+#ifdef DEBUG
+#define debug( text... ) imcb_log( ic, text );
#else
-#define debug( text... ) irc_usermsg( IRC, text );
-#undef debug
#define debug( text... )
#endif
@@ -65,8 +63,10 @@ struct msn_data
GSList *msgq;
GSList *switchboards;
- const struct msn_away_state *away_state;
+ int sb_failures;
+ time_t first_sb_failure;
+ const struct msn_away_state *away_state;
int buddycount;
int groupcount;
char **grouplist;
@@ -157,6 +157,7 @@ char *msn_findheader( char *text, char *header, int len );
char **msn_linesplit( char *line );
int msn_handler( struct msn_handler_data *h );
char *msn_http_encode( const char *input );
+void msn_msgq_purge( struct im_connection *ic, GSList **list );
/* tables.c */
const struct msn_away_state *msn_away_state_by_number( int number );
diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c
index c9eb5ee2..fae2877d 100644
--- a/protocols/msn/msn_util.c
+++ b/protocols/msn/msn_util.c
@@ -338,3 +338,37 @@ char *msn_http_encode( const char *input )
return ret;
}
+
+void msn_msgq_purge( struct im_connection *ic, GSList **list )
+{
+ struct msn_message *m;
+ GString *ret;
+ GSList *l;
+
+ l = *list;
+ if( l == NULL )
+ return;
+
+ m = l->data;
+ ret = g_string_sized_new( 1024 );
+ g_string_printf( ret, "Warning: Cleaning up MSN (switchboard) connection with unsent "
+ "messages to %s:", m->who ? m->who : "unknown recipient" );
+
+ while( l )
+ {
+ m = l->data;
+
+ g_string_append_printf( ret, "\n%s", m->text );
+
+ g_free( m->who );
+ g_free( m->text );
+ g_free( m );
+
+ l = l->next;
+ }
+ g_slist_free( *list );
+ *list = NULL;
+
+ imcb_log( ic, ret->str );
+ g_string_free( ret, TRUE );
+}
diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c
index 9bd7f152..0bb84a74 100644
--- a/protocols/msn/ns.c
+++ b/protocols/msn/ns.c
@@ -583,7 +583,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )
}
else
{
- debug( "Received unknown command from main server: %s", cmd[0] );
+ /* debug( "Received unknown command from main server: %s", cmd[0] ); */
}
return( 1 );
@@ -642,7 +642,7 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int
char *inbox = msn_findheader( body, "Inbox-Unread:", blen );
char *folders = msn_findheader( body, "Folders-Unread:", blen );
- if( inbox && folders )
+ if( inbox && folders && set_getbool( &ic->acc->set, "mail_notifications" ) )
{
imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders );
}
@@ -652,7 +652,7 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int
char *from = msn_findheader( body, "From-Addr:", blen );
char *fromname = msn_findheader( body, "From:", blen );
- if( from && fromname )
+ if( from && fromname && set_getbool( &ic->acc->set, "mail_notifications" ) )
{
imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from );
}
diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c
index cb9e2cab..18c41ef5 100644
--- a/protocols/msn/sb.c
+++ b/protocols/msn/sb.c
@@ -127,7 +127,7 @@ int msn_sb_sendmessage( struct msn_switchboard *sb, char *text )
/* Build the message. Convert LF to CR-LF for normal messages. */
if( strcmp( text, TYPING_NOTIFICATION_MESSAGE ) != 0 )
{
- buf = g_new0( char, sizeof( MSN_MESSAGE_HEADERS ) + strlen( text ) * 2 );
+ buf = g_new0( char, sizeof( MSN_MESSAGE_HEADERS ) + strlen( text ) * 2 + 1 );
i = strlen( MSN_MESSAGE_HEADERS );
strcpy( buf, MSN_MESSAGE_HEADERS );
@@ -206,25 +206,7 @@ void msn_sb_destroy( struct msn_switchboard *sb )
debug( "Destroying switchboard: %s", sb->who ? sb->who : sb->key ? sb->key : "" );
- if( sb->msgq )
- {
- struct msn_message *m;
- GSList *l;
-
- for( l = sb->msgq; l; l = l->next )
- {
- m = l->data;
-
- g_free( m->who );
- g_free( m->text );
- g_free( m );
- }
- g_slist_free( sb->msgq );
-
- imcb_log( ic, "Warning: Closing down MSN switchboard connection with "
- "unsent message to %s, you'll have to resend it.",
- sb->who ? sb->who : "(unknown)" );
- }
+ msn_msgq_purge( ic, &sb->msgq );
if( sb->key ) g_free( sb->key );
if( sb->who ) g_free( sb->who );
@@ -265,7 +247,7 @@ gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond )
if( source != sb->fd )
{
- debug( "ERROR %d while connecting to switchboard server", 1 );
+ debug( "Error %d while connecting to switchboard server", 1 );
msn_sb_destroy( sb );
return FALSE;
}
@@ -286,7 +268,7 @@ gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond )
if( msn_sb_write( sb, buf, strlen( buf ) ) )
sb->inp = b_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb );
else
- debug( "ERROR %d while connecting to switchboard server", 2 );
+ debug( "Error %d while connecting to switchboard server", 2 );
return FALSE;
}
@@ -294,16 +276,59 @@ gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond )
static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond )
{
struct msn_switchboard *sb = data;
+ struct im_connection *ic = sb->ic;
+ struct msn_data *md = ic->proto_data;
if( msn_handler( sb->handler ) == -1 )
{
- debug( "ERROR: Switchboard died" );
+ time_t now = time( NULL );
+
+ if( now - md->first_sb_failure > 600 )
+ {
+ /* It's not really the first one, but the start of this "series".
+ With this, the warning below will be shown only if this happens
+ at least three times in ten minutes. This algorithm isn't
+ perfect, but for this purpose it will do. */
+ md->first_sb_failure = now;
+ md->sb_failures = 0;
+ }
+
+ debug( "Error: Switchboard died" );
+ if( ++ md->sb_failures >= 3 )
+ imcb_log( ic, "Warning: Many switchboard failures on MSN connection. "
+ "There might be problems delivering your messages." );
+
+ if( sb->msgq != NULL )
+ {
+ char buf[1024];
+
+ if( md->msgq == NULL )
+ {
+ md->msgq = sb->msgq;
+ }
+ else
+ {
+ GSList *l;
+
+ for( l = md->msgq; l->next; l = l->next );
+ l->next = sb->msgq;
+ }
+ sb->msgq = NULL;
+
+ debug( "Moved queued messages back to the main queue, creating a new switchboard to retry." );
+ g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId );
+ if( !msn_write( ic, buf, strlen( buf ) ) )
+ return FALSE;
+ }
+
msn_sb_destroy( sb );
return FALSE;
}
else
+ {
return TRUE;
+ }
}
static int msn_sb_command( gpointer data, char **cmd, int num_parts )
@@ -490,6 +515,17 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts )
return( 0 );
}
}
+ else if( strcmp( cmd[0], "NAK" ) == 0 )
+ {
+ if( sb->who )
+ {
+ imcb_log( ic, "The MSN servers could not deliver one of your messages to %s.", sb->who );
+ }
+ else
+ {
+ imcb_log( ic, "The MSN servers could not deliver one of your groupchat messages to all participants." );
+ }
+ }
else if( strcmp( cmd[0], "BYE" ) == 0 )
{
if( num_parts < 2 )
@@ -543,24 +579,13 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts )
{
if( sb->who )
{
- struct msn_message *m;
- GSList *l;
-
/* Apparently some invitation failed. We might want to use this
board later, so keep it as a spare. */
g_free( sb->who );
sb->who = NULL;
/* Also clear the msgq, otherwise someone else might get them. */
- for( l = sb->msgq; l; l = l->next )
- {
- m = l->data;
- g_free( m->who );
- g_free( m->text );
- g_free( m );
- }
- g_slist_free( sb->msgq );
- sb->msgq = NULL;
+ msn_msgq_purge( ic, &sb->msgq );
}
/* Do NOT return 0 here, we want to keep this sb. */
@@ -568,7 +593,7 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts )
}
else
{
- debug( "Received unknown command from switchboard server: %s", cmd[0] );
+ /* debug( "Received unknown command from switchboard server: %s", cmd[0] ); */
}
return( 1 );
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index 5e698902..3ce15166 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -624,7 +624,7 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags,
}
}
-void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at )
+void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, uint32_t flags, time_t sent_at )
{
irc_t *irc = ic->irc;
char *wrapped;
@@ -675,7 +675,7 @@ void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_
g_free( wrapped );
}
-void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags )
+void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags )
{
user_t *u;
@@ -691,6 +691,31 @@ void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags
}
}
+struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle )
+{
+ struct groupchat *c;
+
+ /* This one just creates the conversation structure, user won't see anything yet */
+
+ if( ic->groupchats )
+ {
+ for( c = ic->groupchats; c->next; c = c->next );
+ c = c->next = g_new0( struct groupchat, 1 );
+ }
+ else
+ ic->groupchats = c = g_new0( struct groupchat, 1 );
+
+ c->ic = ic;
+ c->title = g_strdup( handle );
+ c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ );
+ c->topic = g_strdup_printf( "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->title );
+
+ if( set_getbool( &ic->irc->set, "debug" ) )
+ imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle );
+
+ return c;
+}
+
void imcb_chat_free( struct groupchat *c )
{
struct im_connection *ic = c->ic;
@@ -727,11 +752,12 @@ void imcb_chat_free( struct groupchat *c )
g_list_free( c->in_room );
g_free( c->channel );
g_free( c->title );
+ g_free( c->topic );
g_free( c );
}
}
-void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at )
+void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at )
{
struct im_connection *ic = c->ic;
char *wrapped;
@@ -759,6 +785,24 @@ void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags,
g_free( wrapped );
}
+void imcb_chat_log( struct groupchat *c, char *format, ... )
+{
+ irc_t *irc = c->ic->irc;
+ va_list params;
+ char *text;
+ user_t *u;
+
+ va_start( params, format );
+ text = g_strdup_vprintf( format, params );
+ va_end( params );
+
+ u = user_find( irc, irc->mynick );
+
+ irc_privmsg( irc, u, "PRIVMSG", c->channel, "System message: ", text );
+
+ g_free( text );
+}
+
void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at )
{
struct im_connection *ic = c->ic;
@@ -782,31 +826,6 @@ void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at
irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic );
}
-struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle )
-{
- struct groupchat *c;
-
- /* This one just creates the conversation structure, user won't see anything yet */
-
- if( ic->groupchats )
- {
- for( c = ic->groupchats; c->next; c = c->next );
- c = c->next = g_new0( struct groupchat, 1 );
- }
- else
- ic->groupchats = c = g_new0( struct groupchat, 1 );
-
- c->ic = ic;
- c->title = g_strdup( handle );
- c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ );
- c->topic = g_strdup_printf( "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->channel, c->title );
-
- if( set_getbool( &ic->irc->set, "debug" ) )
- imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle );
-
- return c;
-}
-
/* buddy_chat.c */
diff --git a/protocols/nogaim.h b/protocols/nogaim.h
index f17c5a1e..37232493 100644
--- a/protocols/nogaim.h
+++ b/protocols/nogaim.h
@@ -68,7 +68,7 @@
struct im_connection
{
account_t *acc;
- u_int32_t flags;
+ uint32_t flags;
/* each connection then can have its own protocol-specific data */
void *proto_data;
@@ -285,8 +285,8 @@ G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, char *handl
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 );
/* Call when a handle says something. 'flags' and 'sent_at may be just 0. */
-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 );
+G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, uint32_t flags, time_t sent_at );
+G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags );
G_MODULE_EXPORT void imcb_clean_handle( struct im_connection *ic, char *handle );
/* Groupchats */
@@ -302,7 +302,9 @@ G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, char *handle );
/* To remove a handle from a group chat. Reason can be NULL. */
G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason );
/* To tell BitlBee 'who' said 'msg' in 'c'. 'flags' and 'sent_at' can be 0. */
-G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at );
+G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at );
+/* System messages specific to a groupchat, so they can be displayed in the right context. */
+G_MODULE_EXPORT void imcb_chat_log( struct groupchat *c, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
/* To tell BitlBee 'who' changed the topic of 'c' to 'topic'. */
G_MODULE_EXPORT void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at );
G_MODULE_EXPORT void imcb_chat_free( struct groupchat *c );
diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c
index c4683046..9e5de70a 100644
--- a/protocols/oscar/oscar.c
+++ b/protocols/oscar/oscar.c
@@ -90,6 +90,8 @@ struct oscar_data {
gboolean killme;
gboolean icq;
GSList *evilhack;
+
+ GHashTable *ips;
struct {
guint maxbuddies; /* max users you can watch */
@@ -355,9 +357,10 @@ static void oscar_login(account_t *acc) {
struct im_connection *ic = imcb_new(acc);
struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1);
- if (!isdigit(acc->user[0])) {
+ if (isdigit(acc->user[0]))
+ odata->icq = TRUE;
+ else
ic->flags |= OPT_DOES_HTML;
- }
sess = g_new0(aim_session_t, 1);
@@ -410,6 +413,8 @@ static void oscar_logout(struct im_connection *ic) {
odata->create_rooms = g_slist_remove(odata->create_rooms, cr);
g_free(cr);
}
+ if (odata->ips)
+ g_hash_table_destroy(odata->ips);
if (odata->email)
g_free(odata->email);
if (odata->newp)
@@ -986,6 +991,16 @@ static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) {
if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN)
signon = time(NULL) - info->sessionlen;
+ if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR) {
+ uint32_t *uin = g_new0(uint32_t, 1);
+
+ if (od->ips == NULL)
+ od->ips = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL);
+
+ if (sscanf(info->sn, "%d", uin) == 1)
+ g_hash_table_insert(od->ips, uin, (gpointer) (long) info->icqinfo.ipaddr);
+ }
+
tmp = g_strdup(normalize(ic->acc->user));
if (!strcmp(tmp, normalize(info->sn)))
g_snprintf(ic->displayname, sizeof(ic->displayname), "%s", info->sn);
@@ -1050,12 +1065,14 @@ static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_
} else if (args->mpmsg.numparts == 0) {
g_snprintf(tmp, BUF_LONG, "%s", args->msg);
} else {
- int i;
+ aim_mpmsg_section_t *part;
*tmp = 0;
- for (i = 0; i < args->mpmsg.numparts; i ++) {
- g_strlcat(tmp, (char*) args->mpmsg.parts[i].data, BUF_LONG);
- g_strlcat(tmp, "\n", BUF_LONG);
+ for (part = args->mpmsg.parts; part; part = part->next) {
+ if (part->data) {
+ g_strlcat(tmp, (char*) part->data, BUF_LONG);
+ g_strlcat(tmp, "\n", BUF_LONG);
+ }
}
}
@@ -2218,87 +2235,94 @@ static GList *oscar_away_states(struct im_connection *ic)
static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...)
{
- struct im_connection *ic = sess->aux_data;
- gchar who[16];
- GString *str;
- va_list ap;
- struct aim_icq_info *info;
-
- va_start(ap, fr);
- info = va_arg(ap, struct aim_icq_info *);
- va_end(ap);
-
- if (!info->uin)
- return 0;
-
- str = g_string_sized_new(100);
- g_snprintf(who, sizeof(who), "%u", info->uin);
-
- g_string_sprintfa(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"),
- info->nick ? info->nick : "-");
- info_string_append(str, "\n", _("First Name"), info->first);
- info_string_append(str, "\n", _("Last Name"), info->last);
- info_string_append(str, "\n", _("Email Address"), info->email);
- if (info->numaddresses && info->email2) {
- int i;
- for (i = 0; i < info->numaddresses; i++) {
- info_string_append(str, "\n", _("Email Address"), info->email2[i]);
- }
- }
- info_string_append(str, "\n", _("Mobile Phone"), info->mobile);
- if (info->gender != 0)
- info_string_append(str, "\n", _("Gender"), info->gender==1 ? _("Female") : _("Male"));
- if (info->birthyear || info->birthmonth || info->birthday) {
- char date[30];
- struct tm tm;
- tm.tm_mday = (int)info->birthday;
- tm.tm_mon = (int)info->birthmonth-1;
- tm.tm_year = (int)info->birthyear%100;
- strftime(date, sizeof(date), "%Y-%m-%d", &tm);
- info_string_append(str, "\n", _("Birthday"), date);
- }
- if (info->age) {
- char age[5];
- g_snprintf(age, sizeof(age), "%hhd", info->age);
- info_string_append(str, "\n", _("Age"), age);
- }
- info_string_append(str, "\n", _("Personal Web Page"), info->personalwebpage);
- if (info->info && info->info[0]) {
- g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"),
- info->info, _("End of Additional Information"));
- }
- g_string_sprintfa(str, "\n");
- if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
- g_string_sprintfa(str, "%s:", _("Home Address"));
- info_string_append(str, "\n", _("Address"), info->homeaddr);
- info_string_append(str, "\n", _("City"), info->homecity);
- info_string_append(str, "\n", _("State"), info->homestate);
- info_string_append(str, "\n", _("Zip Code"), info->homezip);
- g_string_sprintfa(str, "\n");
- }
- if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
- g_string_sprintfa(str, "%s:", _("Work Address"));
- info_string_append(str, "\n", _("Address"), info->workaddr);
- info_string_append(str, "\n", _("City"), info->workcity);
- info_string_append(str, "\n", _("State"), info->workstate);
- info_string_append(str, "\n", _("Zip Code"), info->workzip);
- g_string_sprintfa(str, "\n");
- }
- if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
- g_string_sprintfa(str, "%s:", _("Work Information"));
- info_string_append(str, "\n", _("Company"), info->workcompany);
- info_string_append(str, "\n", _("Division"), info->workdivision);
- info_string_append(str, "\n", _("Position"), info->workposition);
- if (info->workwebpage && info->workwebpage[0]) {
- info_string_append(str, "\n", _("Web Page"), info->workwebpage);
- }
- g_string_sprintfa(str, "\n");
- }
-
- imcb_log(ic, "%s\n%s", _("User Info"), str->str);
- g_string_free(str, TRUE);
-
- return 1;
+ struct im_connection *ic = sess->aux_data;
+ struct oscar_data *od = ic->proto_data;
+ gchar who[16];
+ GString *str;
+ va_list ap;
+ struct aim_icq_info *info;
+ uint32_t ip;
+
+ va_start(ap, fr);
+ info = va_arg(ap, struct aim_icq_info *);
+ va_end(ap);
+
+ if (!info->uin)
+ return 0;
+
+ str = g_string_sized_new(512);
+ g_snprintf(who, sizeof(who), "%u", info->uin);
+
+ g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"),
+ info->nick ? info->nick : "-");
+ g_string_append_printf(str, "\n%s: %s", _("First Name"), info->first);
+ g_string_append_printf(str, "\n%s: %s", _("Last Name"), info->last);
+ g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email);
+ if (info->numaddresses && info->email2) {
+ int i;
+ for (i = 0; i < info->numaddresses; i++) {
+ g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email2[i]);
+ }
+ }
+ if ((ip = (long) g_hash_table_lookup(od->ips, &info->uin)) != 0) {
+ g_string_append_printf(str, "\n%s: %d.%d.%d.%d", _("Last used IP address"),
+ (ip >> 24), (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
+ }
+ g_string_append_printf(str, "\n%s: %s", _("Mobile Phone"), info->mobile);
+ if (info->gender != 0)
+ g_string_append_printf(str, "\n%s: %s", _("Gender"), info->gender==1 ? _("Female") : _("Male"));
+ if (info->birthyear || info->birthmonth || info->birthday) {
+ char date[30];
+ struct tm tm;
+ memset(&tm, 0, sizeof(struct tm));
+ tm.tm_mday = (int)info->birthday;
+ tm.tm_mon = (int)info->birthmonth-1;
+ tm.tm_year = (int)info->birthyear%100;
+ strftime(date, sizeof(date), "%Y-%m-%d", &tm);
+ g_string_append_printf(str, "\n%s: %s", _("Birthday"), date);
+ }
+ if (info->age) {
+ char age[5];
+ g_snprintf(age, sizeof(age), "%hhd", info->age);
+ g_string_append_printf(str, "\n%s: %s", _("Age"), age);
+ }
+ g_string_append_printf(str, "\n%s: %s", _("Personal Web Page"), info->personalwebpage);
+ if (info->info && info->info[0]) {
+ g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"),
+ info->info, _("End of Additional Information"));
+ }
+ g_string_append_c(str, '\n');
+ if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
+ g_string_append_printf(str, "%s:", _("Home Address"));
+ g_string_append_printf(str, "\n%s: %s", _("Address"), info->homeaddr);
+ g_string_append_printf(str, "\n%s: %s", _("City"), info->homecity);
+ g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate);
+ g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->homezip);
+ g_string_append_c(str, '\n');
+ }
+ if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
+ g_string_append_printf(str, "%s:", _("Work Address"));
+ g_string_append_printf(str, "\n%s: %s", _("Address"), info->workaddr);
+ g_string_append_printf(str, "\n%s: %s", _("City"), info->workcity);
+ g_string_append_printf(str, "\n%s: %s", _("State"), info->workstate);
+ g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->workzip);
+ g_string_append_c(str, '\n');
+ }
+ if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
+ g_string_append_printf(str, "%s:", _("Work Information"));
+ g_string_append_printf(str, "\n%s: %s", _("Company"), info->workcompany);
+ g_string_append_printf(str, "\n%s: %s", _("Division"), info->workdivision);
+ g_string_append_printf(str, "\n%s: %s", _("Position"), info->workposition);
+ if (info->workwebpage && info->workwebpage[0]) {
+ g_string_append_printf(str, "\n%s: %s", _("Web Page"), info->workwebpage);
+ }
+ g_string_append_c(str, '\n');
+ }
+
+ imcb_log(ic, "%s\n%s", _("User Info"), str->str);
+ g_string_free(str, TRUE);
+
+ return 1;
}
@@ -2432,7 +2456,7 @@ int gaim_parsemtn(aim_session_t *sess, aim_frame_t *fr, ...)
else {
/* User has stopped typing */
imcb_buddy_typing(ic, sn, 0);
- }
+ }
return 1;
}
diff --git a/protocols/oscar/service.c b/protocols/oscar/service.c
index 3a180780..acd09150 100644
--- a/protocols/oscar/service.c
+++ b/protocols/oscar/service.c
@@ -893,7 +893,7 @@ int aim_sendmemblock(aim_session_t *sess, aim_conn_t *conn, guint32 offset, guin
aimbs_put32(&fr->data, 0xecf8427e);
*/
} else
- imcb_error(sess->aux_data, "WARNING: unknown hash request");
+ imcb_error(sess->aux_data, "Warning: unknown hash request");
}
diff --git a/protocols/oscar/txqueue.c b/protocols/oscar/txqueue.c
index 4416025a..d38986d0 100644
--- a/protocols/oscar/txqueue.c
+++ b/protocols/oscar/txqueue.c
@@ -79,7 +79,7 @@ static int aim_tx_enqueue__queuebased(aim_session_t *sess, aim_frame_t *fr)
{
if (!fr->conn) {
- imcb_error(sess->aux_data, "WARNING: enqueueing packet with no connection");
+ imcb_error(sess->aux_data, "Warning: enqueueing packet with no connection");
fr->conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
}
diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c
index 625f3d1c..9f9ffcf7 100644
--- a/protocols/yahoo/yahoo.c
+++ b/protocols/yahoo/yahoo.c
@@ -126,6 +126,11 @@ static char *byahoo_strip( const char *in )
return( g_strndup( in, len ) );
}
+static void byahoo_init( account_t *acc )
+{
+ set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
+}
+
static void byahoo_login( account_t *acc )
{
struct im_connection *ic = imcb_new( acc );
@@ -348,6 +353,7 @@ void byahoo_initmodule( )
{
struct prpl *ret = g_new0(struct prpl, 1);
ret->name = "yahoo";
+ ret->init = byahoo_init;
ret->login = byahoo_login;
ret->keepalive = byahoo_keepalive;
@@ -617,10 +623,14 @@ void ext_yahoo_status_changed( int id, const char *who, int stat, const char *ms
void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8 )
{
struct im_connection *ic = byahoo_get_ic_by_id( id );
- char *m = byahoo_strip( msg );
+ char *m;
- imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 );
- g_free( m );
+ if( msg )
+ {
+ m = byahoo_strip( msg );
+ imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 );
+ g_free( m );
+ }
}
void ext_yahoo_got_file( int id,
@@ -922,7 +932,9 @@ void ext_yahoo_mail_notify( int id, const char *from, const char *subj, int cnt
{
struct im_connection *ic = byahoo_get_ic_by_id( id );
- if( from && subj )
+ if( !set_getbool( &ic->acc->set, "mail_notifications" ) )
+ ; /* The user doesn't care. */
+ else if( from && subj )
imcb_log( ic, "Received e-mail message from %s with subject `%s'", from, subj );
else if( cnt > 0 )
imcb_log( ic, "Received %d new e-mails", cnt );