aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/msn
diff options
context:
space:
mode:
authorulim <a.sporto+bee@gmail.com>2008-02-15 18:38:57 +0100
committerulim <a.sporto+bee@gmail.com>2008-02-15 18:38:57 +0100
commit1ba7e8f1d28c4876ea0b787f1e4ebb5607f48895 (patch)
tree5ba8bed0e1ba83c56a855059e88e3d2a205fe88c /protocols/msn
parent0fbd3a6d26d8fe747bd5e061748e75f397801064 (diff)
parenteeb85a8a880fefe655eb31b6322136b61ee969e2 (diff)
Merged with upstream r328
Wilmer van der Gaast 2008-02-11 Got rid of some noise at startup: complaining when the default configuration Wilmer van der Gaast 2008-02-10 Added support for password-protected Jabber chatrooms. Wilmer van der Gaast 2008-02-10 Making AI_ADDRCONFIG optional, it doesn't exist on at least NetBSD and Wilmer van der Gaast 2008-02-09 Restored "add -tmp". A bit hackish, but it will do for now. Wilmer van der Gaast 2008-02-07 Fixed getnameinfo() calls, this fixes Solaris stability issues. Thanks to Wilmer van der Gaast 2008-02-04 Added bogus G_GNUC_MALLOC to restore GLib 2.4 compatibility (hopefully). Wilmer van der Gaast 2008-02-03 Messages from the user are also included in backlogs when joining a Jabber Wilmer van der Gaast 2008-02-03 Disabling "Unknown command" warnings since they're very noisy and pretty Wilmer van der Gaast 2008-02-03 Implemented XEP-0115. This adds some info to the <presence/> tags so Wilmer van der Gaast 2008-02-03 Saner garbage collection of cached packets in the Jabber module. Now Wilmer van der Gaast 2008-02-02 Added help_free() and cleaned up some very stale help-related stuff I Wilmer van der Gaast 2008-01-30 Fixed handling of OSCAR multi-part messages... They're not arrays, they're Wilmer van der Gaast 2008-01-24 Keeping track of valid Jabber connections so _connected() events will be Wilmer van der Gaast 2008-01-24 Fixed two valgrind warnings (partially uninitialized "struct tm" vars.) Wilmer van der Gaast 2008-01-20 The Jabber module now uses imcb_chat_log() instead of imcb_log() where Wilmer van der Gaast 2008-01-20 Added imcb_chat_log() for chatroom system messages, so they can be Wilmer van der Gaast 2008-01-20 GET_BUDDY_FIRST wasn't actually implemented, even though it was in use Wilmer van der Gaast 2008-01-19 Using test -f instead of test -e. This breaks if the include files are Wilmer van der Gaast 2008-01-19 Added byte swapping code to the new MD5 checksumming code to make it work Wilmer van der Gaast 2008-01-18 Moving imcb_chat_new() to a saner location (no code changes) and fixing Wilmer van der Gaast 2008-01-17 Apparently ext_yahoo_got_im can be called with msg=NULL, so it should be Wilmer van der Gaast 2008-01-17 Fixing some Solaris compiler warnings (u_int->uint, adding some typecasts Wilmer van der Gaast 2008-01-13 Fixed handing of failed groupchat joins. Wilmer van der Gaast 2008-01-13 Fixed "Conditional jump or move depends on uninitialised value(s)" at Wilmer van der Gaast 2008-01-13 Fixed quickstart2. (Bug #349.) Wilmer van der Gaast 2008-01-13 Different handling of charset mismatches before login time. Ignoring a Wilmer van der Gaast 2008-01-12 When a switchboard connection dies (at the TCP level) and there are still Wilmer van der Gaast 2008-01-12 Killed info_string_append() and now showing the IP address of ICQ users Wilmer van der Gaast 2008-01-11 Fixing bug #344, now away states should always be correct, even when people Wilmer van der Gaast 2008-01-11 Adding own handle to protocol name in blist output for people with multiple Wilmer van der Gaast 2008-01-10 Now setting odata->icq properly again, this got lost some time ago, which Wilmer van der Gaast 2008-01-06 More consistency in error/warning errors. Until now "WARNING:" was usually Wilmer van der Gaast 2008-01-06 Changed warning message about unsent MSN messages. It should show the actual Wilmer van der Gaast 2008-01-05 Added "mail_notifications" setting. Who needs those notifications anyway? Wilmer van der Gaast 2008-01-05 Build fix from vmiklos. Wilmer van der Gaast 2008-01-05 Added handling of MSN switchboard NAK messages. Untested, but hey, it Wilmer van der Gaast 2008-01-05 Removed closure->result. I was planning to add some more stuff, but will Miklos Vajna 2007-12-31 encode: md5.c is no longer in protocols/, it's in lib/ Wilmer van der Gaast 2007-12-28 Fixed return value check in proxy_connect(), since on some systems Wilmer van der Gaast 2007-12-28 Added missing return in jabber_login(). Wilmer van der Gaast 2007-12-16 Implemented XEP-0199 (patch from misc@mandriva.org). Wilmer van der Gaast 2007-12-12 Checking conn->xcred before trying to clean it up since GnuTLS doesn't Wilmer van der Gaast 2007-12-12 Killed the <server> parameter to "account add" and changed the default Wilmer van der Gaast 2007-12-12 Fixed sockerr_again() usage in Jabber module to (hopefully) fix a 100% CPU Wilmer van der Gaast 2007-12-10 Don't allow nicks that start with a number. Wilmer van der Gaast 2007-12-10 Fixed "set xxx" syntax (it showed all settings instead of just xxx). Wilmer van der Gaast 2007-12-09 If I keep forgetting to credit people in commit msgs I should probably add Wilmer van der Gaast 2007-12-09 Added /invite support for Jabber chatrooms (and fixed the argument order
Diffstat (limited to 'protocols/msn')
-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
5 files changed, 107 insertions, 59 deletions
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 );