aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/msn/msn.c61
-rw-r--r--protocols/msn/msn.h6
-rw-r--r--protocols/msn/ns.c23
-rw-r--r--protocols/msn/sb.c42
-rw-r--r--protocols/nogaim.c10
-rw-r--r--protocols/yahoo/libyahoo2.c2
-rw-r--r--protocols/yahoo/yahoo.c3
-rw-r--r--protocols/yahoo/yahoo_httplib.c2
8 files changed, 78 insertions, 71 deletions
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c
index a2e8519a..046b2772 100644
--- a/protocols/msn/msn.c
+++ b/protocols/msn/msn.c
@@ -112,7 +112,6 @@ static void msn_logout( struct im_connection *ic )
static int msn_buddy_msg( struct im_connection *ic, char *who, char *message, int away )
{
struct msn_switchboard *sb;
- struct msn_data *md = ic->proto_data;
if( ( sb = msn_sb_by_handle( ic, who ) ) )
{
@@ -121,47 +120,13 @@ static int msn_buddy_msg( struct im_connection *ic, char *who, char *message, in
else
{
struct msn_message *m;
- char buf[1024];
/* Create a message. We have to arrange a usable switchboard, and send the message later. */
m = g_new0( struct msn_message, 1 );
m->who = g_strdup( who );
m->text = g_strdup( message );
- /* FIXME: *CHECK* the reliability of using spare sb's! */
- if( ( sb = msn_sb_spare( ic ) ) )
- {
- debug( "Trying to use a spare switchboard to message %s", who );
-
- sb->who = g_strdup( who );
- g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, who );
- if( msn_sb_write( sb, buf, strlen( buf ) ) )
- {
- /* He/She should join the switchboard soon, let's queue the message. */
- sb->msgq = g_slist_append( sb->msgq, m );
- return( 1 );
- }
- }
-
- debug( "Creating a new switchboard to message %s", who );
-
- /* If we reach this line, there was no spare switchboard, so let's make one. */
- g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId );
- if( !msn_write( ic, buf, strlen( buf ) ) )
- {
- g_free( m->who );
- g_free( m->text );
- g_free( m );
-
- return( 0 );
- }
-
- /* And queue the message to md. We'll pick it up when the switchboard comes up. */
- md->msgq = g_slist_append( md->msgq, m );
-
- /* FIXME: If the switchboard creation fails, the message will not be sent. */
-
- return( 1 );
+ return msn_sb_write_msg( ic, m );
}
return( 0 );
@@ -251,8 +216,6 @@ static void msn_chat_leave( struct groupchat *c )
static struct groupchat *msn_chat_with( struct im_connection *ic, char *who )
{
struct msn_switchboard *sb;
- struct msn_data *md = ic->proto_data;
- char buf[1024];
if( ( sb = msn_sb_by_handle( ic, who ) ) )
{
@@ -263,31 +226,13 @@ static struct groupchat *msn_chat_with( struct im_connection *ic, char *who )
{
struct msn_message *m;
- if( ( sb = msn_sb_spare( ic ) ) )
- {
- debug( "Trying to reuse an existing switchboard as a groupchat with %s", who );
- g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, who );
- if( msn_sb_write( sb, buf, strlen( buf ) ) )
- return msn_sb_to_chat( sb );
- }
-
- /* If the stuff above failed for some reason: */
- debug( "Creating a new switchboard to groupchat with %s", who );
-
- /* Request a new switchboard. */
- g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId );
- if( !msn_write( ic, buf, strlen( buf ) ) )
- return( 0 );
-
/* Create a magic message. This is quite hackish, but who cares? :-P */
m = g_new0( struct msn_message, 1 );
m->who = g_strdup( who );
m->text = g_strdup( GROUPCHAT_SWITCHBOARD_MESSAGE );
- /* Queue the magic message and cross your fingers. */
- md->msgq = g_slist_append( md->msgq, m );
-
- /* FIXME: Can I try to return something here already? */
+ msn_sb_write_msg( ic, m );
+
return NULL;
}
diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h
index 63759303..7c849acf 100644
--- a/protocols/msn/msn.h
+++ b/protocols/msn/msn.h
@@ -23,6 +23,9 @@
Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef _MSN_H
+#define _MSN_H
+
/* Some hackish magicstrings to make special-purpose messages/switchboards.
*/
#define TYPING_NOTIFICATION_MESSAGE "\r\r\rBEWARE, ME R TYPINK MESSAGE!!!!\r\r\r"
@@ -175,3 +178,6 @@ int msn_sb_sendmessage( struct msn_switchboard *sb, char *text );
struct groupchat *msn_sb_to_chat( struct msn_switchboard *sb );
void msn_sb_destroy( struct msn_switchboard *sb );
gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond );
+int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m );
+
+#endif //_MSN_H
diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c
index ffaa90a7..fe48f96d 100644
--- a/protocols/msn/ns.c
+++ b/protocols/msn/ns.c
@@ -277,11 +277,25 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )
{
if( num_parts == 5 )
{
- md->buddycount = atoi( cmd[3] );
- md->groupcount = atoi( cmd[4] );
- if( md->groupcount > 0 )
+ int i, groupcount;
+
+ groupcount = atoi( cmd[4] );
+ if( groupcount > 0 )
+ {
+ /* valgrind says this is leaking memory, I'm guessing
+ that this happens during server redirects. */
+ if( md->grouplist )
+ {
+ for( i = 0; i < md->groupcount; i ++ )
+ g_free( md->grouplist[i] );
+ g_free( md->grouplist );
+ }
+
+ md->groupcount = groupcount;
md->grouplist = g_new0( char *, md->groupcount );
+ }
+ md->buddycount = atoi( cmd[3] );
if( !*cmd[3] || md->buddycount == 0 )
msn_logged_in( ic );
}
@@ -664,6 +678,9 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int
{
imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders );
}
+
+ g_free( inbox );
+ g_free( folders );
}
else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 )
{
diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c
index 18c41ef5..e9526234 100644
--- a/protocols/msn/sb.c
+++ b/protocols/msn/sb.c
@@ -47,6 +47,48 @@ int msn_sb_write( struct msn_switchboard *sb, char *s, int len )
return( 1 );
}
+int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m )
+{
+ struct msn_data *md = ic->proto_data;
+ struct msn_switchboard *sb;
+ char buf[1024];
+
+ /* FIXME: *CHECK* the reliability of using spare sb's! */
+ if( ( sb = msn_sb_spare( ic ) ) )
+ {
+ debug( "Trying to use a spare switchboard to message %s", m->who );
+
+ sb->who = g_strdup( m->who );
+ g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, m->who );
+ if( msn_sb_write( sb, buf, strlen( buf ) ) )
+ {
+ /* He/She should join the switchboard soon, let's queue the message. */
+ sb->msgq = g_slist_append( sb->msgq, m );
+ return( 1 );
+ }
+ }
+
+ debug( "Creating a new switchboard to message %s", m->who );
+
+ /* If we reach this line, there was no spare switchboard, so let's make one. */
+ g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId );
+ if( !msn_write( ic, buf, strlen( buf ) ) )
+ {
+ g_free( m->who );
+ g_free( m->text );
+ g_free( m );
+
+ return( 0 );
+ }
+
+ /* And queue the message to md. We'll pick it up when the switchboard comes up. */
+ md->msgq = g_slist_append( md->msgq, m );
+
+ /* FIXME: If the switchboard creation fails, the message will not be sent. */
+
+ return( 1 );
+}
+
struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session )
{
struct msn_data *md = ic->proto_data;
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index 7466e93a..b6f8d6e4 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -266,6 +266,10 @@ void imcb_connected( struct im_connection *ic )
/* Also necessary when we're not away, at least for some of the
protocols. */
imc_set_away( ic, u->away );
+
+ /* Apparently we're connected successfully, so reset the
+ exponential backoff timer. */
+ ic->acc->auto_reconnect_delay = 0;
}
gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond )
@@ -289,6 +293,7 @@ void imc_logout( struct im_connection *ic, int allow_reconnect )
irc_t *irc = ic->irc;
user_t *t, *u;
account_t *a;
+ int delay;
/* Nested calls might happen sometimes, this is probably the best
place to catch them. */
@@ -328,10 +333,9 @@ void imc_logout( struct im_connection *ic, int allow_reconnect )
/* Uhm... This is very sick. */
}
else if( allow_reconnect && set_getbool( &irc->set, "auto_reconnect" ) &&
- set_getbool( &a->set, "auto_reconnect" ) )
+ set_getbool( &a->set, "auto_reconnect" ) &&
+ ( delay = account_reconnect_delay( a ) ) > 0 )
{
- int delay = set_getint( &irc->set, "auto_reconnect_delay" );
-
imcb_log( ic, "Reconnecting in %d seconds..", delay );
a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a );
}
diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c
index 897ba27b..a61955c4 100644
--- a/protocols/yahoo/libyahoo2.c
+++ b/protocols/yahoo/libyahoo2.c
@@ -68,8 +68,6 @@ char *strchr (), *strrchr ();
#ifdef __MINGW32__
# include <winsock2.h>
-# define write(a,b,c) send(a,b,c,0)
-# define read(a,b,c) recv(a,b,c,0)
#endif
#include <stdlib.h>
diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c
index 197d76a1..8d9e95d8 100644
--- a/protocols/yahoo/yahoo.c
+++ b/protocols/yahoo/yahoo.c
@@ -664,9 +664,6 @@ void ext_yahoo_error( int id, const char *err, int fatal, int num )
struct im_connection *ic = byahoo_get_ic_by_id( id );
imcb_error( ic, "%s", err );
-
- if( fatal )
- imc_logout( ic, TRUE );
}
/* TODO: Clear up the mess of inp and d structures */
diff --git a/protocols/yahoo/yahoo_httplib.c b/protocols/yahoo/yahoo_httplib.c
index dbbe2a84..1b084992 100644
--- a/protocols/yahoo/yahoo_httplib.c
+++ b/protocols/yahoo/yahoo_httplib.c
@@ -50,8 +50,6 @@ char *strchr (), *strrchr ();
#include "yahoo_debug.h"
#ifdef __MINGW32__
# include <winsock2.h>
-# define write(a,b,c) send(a,b,c,0)
-# define read(a,b,c) recv(a,b,c,0)
# define snprintf _snprintf
#endif