aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--irc.c18
-rw-r--r--irc_commands.c2
-rw-r--r--protocols/nogaim.c197
-rw-r--r--protocols/nogaim.h6
4 files changed, 117 insertions, 106 deletions
diff --git a/irc.c b/irc.c
index 3cdd03cb..2d35bbb6 100644
--- a/irc.c
+++ b/irc.c
@@ -1010,7 +1010,7 @@ int irc_send( irc_t *irc, char *nick, char *s, int flags )
}
else if( c && c->gc && c->gc->prpl )
{
- return( serv_send_chat( irc, c->gc, c->id, s ) );
+ return( bim_chat_msg( c->gc, c->id, s ) );
}
return( 0 );
@@ -1020,8 +1020,12 @@ gboolean buddy_send_handler_delayed( gpointer data )
{
user_t *u = data;
+ /* Shouldn't happen, but just to be sure. */
+ if( u->sendbuf_len < 2 )
+ return FALSE;
+
u->sendbuf[u->sendbuf_len-2] = 0; /* Cut off the last newline */
- serv_send_im( u->gc->irc, u, u->sendbuf, u->sendbuf_flags );
+ bim_buddy_msg( u->gc, u->handle, u->sendbuf, u->sendbuf_flags );
g_free( u->sendbuf );
u->sendbuf = NULL;
@@ -1029,7 +1033,7 @@ gboolean buddy_send_handler_delayed( gpointer data )
u->sendbuf_timer = 0;
u->sendbuf_flags = 0;
- return( FALSE );
+ return FALSE;
}
void buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags )
@@ -1042,7 +1046,7 @@ void buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags )
if( u->sendbuf_len > 0 && u->sendbuf_flags != flags)
{
- //Flush the buffer
+ /* Flush the buffer */
g_source_remove( u->sendbuf_timer );
buddy_send_handler_delayed( u );
}
@@ -1050,14 +1054,14 @@ void buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags )
if( u->sendbuf_len == 0 )
{
u->sendbuf_len = strlen( msg ) + 2;
- u->sendbuf = g_new (char, u->sendbuf_len );
+ u->sendbuf = g_new( char, u->sendbuf_len );
u->sendbuf[0] = 0;
u->sendbuf_flags = flags;
}
else
{
u->sendbuf_len += strlen( msg ) + 1;
- u->sendbuf = g_renew ( char, u->sendbuf, u->sendbuf_len );
+ u->sendbuf = g_renew( char, u->sendbuf, u->sendbuf_len );
}
strcat( u->sendbuf, msg );
@@ -1073,7 +1077,7 @@ void buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags )
}
else
{
- serv_send_im( irc, u, msg, flags );
+ bim_buddy_msg( u->gc, u->handle, msg, flags );
}
}
diff --git a/irc_commands.c b/irc_commands.c
index 01b01dfb..6447835d 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -447,7 +447,7 @@ static void irc_cmd_away( irc_t *irc, char **cmd )
struct gaim_connection *gc = a->gc;
if( gc && gc->flags & OPT_LOGGED_IN )
- proto_away( gc, u->away );
+ bim_set_away( gc, u->away );
}
}
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index 568afe33..a9b27e92 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -37,19 +37,6 @@
#include "nogaim.h"
#include <ctype.h>
-static char *proto_away_alias[8][5] =
-{
- { "Away from computer", "Away", "Extended away", NULL },
- { "NA", "N/A", "Not available", NULL },
- { "Busy", "Do not disturb", "DND", "Occupied", NULL },
- { "Be right back", "BRB", NULL },
- { "On the phone", "Phone", "On phone", NULL },
- { "Out to lunch", "Lunch", "Food", NULL },
- { "Invisible", "Hidden" },
- { NULL }
-};
-static char *proto_away_alias_find( GList *gcm, char *away );
-
static int remove_chat_buddy_silent( struct conversation *b, char *handle );
GSList *connections;
@@ -157,83 +144,6 @@ void nogaim_init()
GSList *get_connections() { return connections; }
-int proto_away( struct gaim_connection *gc, char *away )
-{
- GList *m, *ms;
- char *s;
-
- if( !away ) away = "";
- ms = m = gc->prpl->away_states( gc );
-
- while( m )
- {
- if( *away )
- {
- if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 )
- break;
- }
- else
- {
- if( g_strcasecmp( m->data, "Available" ) == 0 )
- break;
- if( g_strcasecmp( m->data, "Online" ) == 0 )
- break;
- }
- m = m->next;
- }
-
- if( m )
- {
- gc->prpl->set_away( gc, m->data, *away ? away : NULL );
- }
- else
- {
- s = proto_away_alias_find( ms, away );
- if( s )
- {
- gc->prpl->set_away( gc, s, away );
- if( set_getint( gc->irc, "debug" ) )
- serv_got_crap( gc, "Setting away state to %s", s );
- }
- else
- gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );
- }
-
- g_list_free( ms );
-
- return( 1 );
-}
-
-static char *proto_away_alias_find( GList *gcm, char *away )
-{
- GList *m;
- int i, j;
-
- for( i = 0; *proto_away_alias[i]; i ++ )
- {
- for( j = 0; proto_away_alias[i][j]; j ++ )
- if( g_strncasecmp( away, proto_away_alias[i][j], strlen( proto_away_alias[i][j] ) ) == 0 )
- break;
-
- if( !proto_away_alias[i][j] ) /* If we reach the end, this row */
- continue; /* is not what we want. Next! */
-
- /* Now find an entry in this row which exists in gcm */
- for( j = 0; proto_away_alias[i][j]; j ++ )
- {
- m = gcm;
- while( m )
- {
- if( g_strcasecmp( proto_away_alias[i][j], m->data ) == 0 )
- return( proto_away_alias[i][j] );
- m = m->next;
- }
- }
- }
-
- return( NULL );
-}
-
/* multi.c */
struct gaim_connection *new_gaim_conn( struct aim_user *user )
@@ -358,7 +268,7 @@ void account_online( struct gaim_connection *gc )
/* Also necessary when we're not away, at least for some of the
protocols. */
- proto_away( gc, u->away );
+ bim_set_away( gc, u->away );
}
gboolean auto_reconnect( gpointer data )
@@ -1030,24 +940,30 @@ char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value )
return( set_eval_bool( irc, set, value ) );
}
-int serv_send_im( irc_t *irc, user_t *u, char *msg, int flags )
+
+
+
+/* The plan is to not allow straight calls to prpl functions anymore, but do
+ them all from some wrappers. We'll start to define some down here: */
+
+int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags )
{
char *buf = NULL;
int st;
- if( ( u->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
+ if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
{
buf = escape_html( msg );
msg = buf;
}
- st = ((struct gaim_connection *)u->gc)->prpl->send_im( u->gc, u->handle, msg, strlen( msg ), flags );
+ st = gc->prpl->send_im( gc, handle, msg, strlen( msg ), flags );
g_free( buf );
return st;
}
-int serv_send_chat( irc_t *irc, struct gaim_connection *gc, int id, char *msg )
+int bim_chat_msg( struct gaim_connection *gc, int id, char *msg )
{
char *buf = NULL;
int st;
@@ -1063,3 +979,94 @@ int serv_send_chat( irc_t *irc, struct gaim_connection *gc, int id, char *msg )
return st;
}
+
+static char *bim_away_alias_find( GList *gcm, char *away );
+
+int bim_set_away( struct gaim_connection *gc, char *away )
+{
+ GList *m, *ms;
+ char *s;
+
+ if( !away ) away = "";
+ ms = m = gc->prpl->away_states( gc );
+
+ while( m )
+ {
+ if( *away )
+ {
+ if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 )
+ break;
+ }
+ else
+ {
+ if( g_strcasecmp( m->data, "Available" ) == 0 )
+ break;
+ if( g_strcasecmp( m->data, "Online" ) == 0 )
+ break;
+ }
+ m = m->next;
+ }
+
+ if( m )
+ {
+ gc->prpl->set_away( gc, m->data, *away ? away : NULL );
+ }
+ else
+ {
+ s = bim_away_alias_find( ms, away );
+ if( s )
+ {
+ gc->prpl->set_away( gc, s, away );
+ if( set_getint( gc->irc, "debug" ) )
+ serv_got_crap( gc, "Setting away state to %s", s );
+ }
+ else
+ gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );
+ }
+
+ g_list_free( ms );
+
+ return( 1 );
+}
+
+static char *bim_away_alias_list[8][5] =
+{
+ { "Away from computer", "Away", "Extended away", NULL },
+ { "NA", "N/A", "Not available", NULL },
+ { "Busy", "Do not disturb", "DND", "Occupied", NULL },
+ { "Be right back", "BRB", NULL },
+ { "On the phone", "Phone", "On phone", NULL },
+ { "Out to lunch", "Lunch", "Food", NULL },
+ { "Invisible", "Hidden" },
+ { NULL }
+};
+
+static char *bim_away_alias_find( GList *gcm, char *away )
+{
+ GList *m;
+ int i, j;
+
+ for( i = 0; *bim_away_alias_list[i]; i ++ )
+ {
+ for( j = 0; bim_away_alias_list[i][j]; j ++ )
+ if( g_strncasecmp( away, bim_away_alias_list[i][j], strlen( bim_away_alias_list[i][j] ) ) == 0 )
+ break;
+
+ if( !bim_away_alias_list[i][j] ) /* If we reach the end, this row */
+ continue; /* is not what we want. Next! */
+
+ /* Now find an entry in this row which exists in gcm */
+ for( j = 0; bim_away_alias_list[i][j]; j ++ )
+ {
+ m = gcm;
+ while( m )
+ {
+ if( g_strcasecmp( bim_away_alias_list[i][j], m->data ) == 0 )
+ return( bim_away_alias_list[i][j] );
+ m = m->next;
+ }
+ }
+ }
+
+ return( NULL );
+}
diff --git a/protocols/nogaim.h b/protocols/nogaim.h
index 4251fbaa..3b55fe3b 100644
--- a/protocols/nogaim.h
+++ b/protocols/nogaim.h
@@ -193,11 +193,11 @@ G_MODULE_EXPORT struct prpl *find_protocol(const char *name);
G_MODULE_EXPORT void register_protocol(struct prpl *);
/* nogaim.c */
-int serv_send_im(irc_t *irc, user_t *u, char *msg, int flags);
-int serv_send_chat(irc_t *irc, struct gaim_connection *gc, int id, char *msg );
+int bim_set_away( struct gaim_connection *gc, char *away );
+int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags );
+int bim_chat_msg( struct gaim_connection *gc, int id, char *msg );
void nogaim_init();
-int proto_away( struct gaim_connection *gc, char *away );
char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value );
gboolean auto_reconnect( gpointer data );