aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Makefile3
-rw-r--r--protocols/account.c360
-rw-r--r--protocols/account.h72
-rw-r--r--protocols/bee.c47
-rw-r--r--protocols/bee.h102
-rw-r--r--protocols/bee_ft.c66
-rw-r--r--protocols/bee_user.c197
-rw-r--r--protocols/chat.c192
-rw-r--r--protocols/chat.h51
-rw-r--r--protocols/ft.h6
-rw-r--r--protocols/jabber/iq.c4
-rw-r--r--protocols/jabber/jabber.c2
-rw-r--r--protocols/jabber/jabber_util.c8
-rw-r--r--protocols/jabber/s5bytestream.c14
-rw-r--r--protocols/jabber/si.c10
-rw-r--r--protocols/msn/Makefile2
-rw-r--r--protocols/msn/msn.c4
-rw-r--r--protocols/msn/msn_util.c3
-rw-r--r--protocols/msn/sb.c3
-rw-r--r--protocols/nogaim.c408
-rw-r--r--protocols/nogaim.h15
-rw-r--r--protocols/oscar/oscar.c7
22 files changed, 1214 insertions, 362 deletions
diff --git a/protocols/Makefile b/protocols/Makefile
index 18d79e8d..46c73559 100644
--- a/protocols/Makefile
+++ b/protocols/Makefile
@@ -9,7 +9,8 @@
-include ../Makefile.settings
# [SH] Program variables
-objects = nogaim.o
+objects = account.o bee.o bee_ft.o bee_user.o nogaim.o
+
# [SH] The next two lines should contain the directory name (in $(subdirs))
# and the name of the object file, which should be linked into
diff --git a/protocols/account.c b/protocols/account.c
new file mode 100644
index 00000000..0bacea74
--- /dev/null
+++ b/protocols/account.c
@@ -0,0 +1,360 @@
+ /********************************************************************\
+ * BitlBee -- An IRC to other IM-networks gateway *
+ * *
+ * Copyright 2002-2010 Wilmer van der Gaast and others *
+ \********************************************************************/
+
+/* Account management functions */
+
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License with
+ the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
+ if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#define BITLBEE_CORE
+#include "bitlbee.h"
+#include "account.h"
+#include "chat.h"
+
+account_t *account_add( bee_t *bee, struct prpl *prpl, char *user, char *pass )
+{
+ account_t *a;
+ set_t *s;
+
+ if( bee->accounts )
+ {
+ for( a = bee->accounts; a->next; a = a->next );
+ a = a->next = g_new0( account_t, 1 );
+ }
+ else
+ {
+ bee->accounts = a = g_new0 ( account_t, 1 );
+ }
+
+ a->prpl = prpl;
+ a->user = g_strdup( user );
+ a->pass = g_strdup( pass );
+ a->auto_connect = 1;
+ a->bee = bee;
+
+ s = set_add( &a->set, "auto_connect", "true", set_eval_account, a );
+ s->flags |= ACC_SET_NOSAVE;
+
+ s = set_add( &a->set, "auto_reconnect", "true", set_eval_bool, a );
+
+ s = set_add( &a->set, "nick_source", "handle", NULL, a );
+
+ s = set_add( &a->set, "password", NULL, set_eval_account, a );
+ s->flags |= ACC_SET_NOSAVE | SET_NULL_OK;
+
+ s = set_add( &a->set, "username", NULL, set_eval_account, a );
+ s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY;
+ set_setstr( &a->set, "username", user );
+
+ a->nicks = g_hash_table_new_full( g_str_hash, g_str_equal, g_free, g_free );
+
+ /* This function adds some more settings (and might want to do more
+ things that have to be done now, although I can't think of anything. */
+ if( prpl->init )
+ prpl->init( a );
+
+ s = set_add( &a->set, "away", NULL, set_eval_account, a );
+ s->flags |= SET_NULL_OK;
+
+ if( a->flags & ACC_FLAG_STATUS_MESSAGE )
+ {
+ s = set_add( &a->set, "status", NULL, set_eval_account, a );
+ s->flags |= SET_NULL_OK;
+ }
+
+ return a;
+}
+
+char *set_eval_account( set_t *set, char *value )
+{
+ account_t *acc = set->data;
+
+ /* Double-check: We refuse to edit on-line accounts. */
+ if( set->flags & ACC_SET_OFFLINE_ONLY && acc->ic )
+ return SET_INVALID;
+
+ if( strcmp( set->key, "server" ) == 0 )
+ {
+ g_free( acc->server );
+ if( value && *value )
+ {
+ acc->server = g_strdup( value );
+ return value;
+ }
+ else
+ {
+ acc->server = g_strdup( set->def );
+ return g_strdup( set->def );
+ }
+ }
+ else if( strcmp( set->key, "username" ) == 0 )
+ {
+ g_free( acc->user );
+ acc->user = g_strdup( value );
+ return value;
+ }
+ else if( strcmp( set->key, "password" ) == 0 )
+ {
+ if( value )
+ {
+ g_free( acc->pass );
+ acc->pass = g_strdup( value );
+ return NULL; /* password shouldn't be visible in plaintext! */
+ }
+ else
+ {
+ /* NULL can (should) be stored in the set_t
+ variable, but is otherwise not correct. */
+ return SET_INVALID;
+ }
+ }
+ else if( strcmp( set->key, "auto_connect" ) == 0 )
+ {
+ if( !is_bool( value ) )
+ return SET_INVALID;
+
+ acc->auto_connect = bool2int( value );
+ return value;
+ }
+ else if( strcmp( set->key, "away" ) == 0 ||
+ strcmp( set->key, "status" ) == 0 )
+ {
+ if( acc->ic && acc->ic->flags & OPT_LOGGED_IN )
+ {
+ /* If we're currently on-line, set the var now already
+ (bit of a hack) and send an update. */
+ g_free( set->value );
+ set->value = g_strdup( value );
+
+ imc_away_send_update( acc->ic );
+ }
+
+ return value;
+ }
+
+ return SET_INVALID;
+}
+
+account_t *account_get( bee_t *bee, char *id )
+{
+ account_t *a, *ret = NULL;
+ char *handle, *s;
+ int nr;
+
+ /* This checks if the id string ends with (...) */
+ if( ( handle = strchr( id, '(' ) ) && ( s = strchr( handle, ')' ) ) && s[1] == 0 )
+ {
+ struct prpl *proto;
+
+ *s = *handle = 0;
+ handle ++;
+
+ if( ( proto = find_protocol( id ) ) )
+ {
+ for( a = bee->accounts; a; a = a->next )
+ if( a->prpl == proto &&
+ a->prpl->handle_cmp( handle, a->user ) == 0 )
+ ret = a;
+ }
+
+ /* Restore the string. */
+ handle --;
+ *handle = '(';
+ *s = ')';
+
+ if( ret )
+ return ret;
+ }
+
+ if( sscanf( id, "%d", &nr ) == 1 && nr < 1000 )
+ {
+ for( a = bee->accounts; a; a = a->next )
+ if( ( nr-- ) == 0 )
+ return( a );
+
+ return( NULL );
+ }
+
+ for( a = bee->accounts; a; a = a->next )
+ {
+ if( g_strcasecmp( id, a->prpl->name ) == 0 )
+ {
+ if( !ret )
+ ret = a;
+ else
+ return( NULL ); /* We don't want to match more than one... */
+ }
+ else if( strstr( a->user, id ) )
+ {
+ if( !ret )
+ ret = a;
+ else
+ return( NULL );
+ }
+ }
+
+ return( ret );
+}
+
+void account_del( bee_t *bee, account_t *acc )
+{
+ account_t *a, *l = NULL;
+
+ if( acc->ic )
+ /* Caller should have checked, accounts still in use can't be deleted. */
+ return;
+
+ for( a = bee->accounts; a; a = (l=a)->next )
+ if( a == acc )
+ {
+ if( l )
+ l->next = a->next;
+ else
+ bee->accounts = a->next;
+
+ /** FIXME
+ for( c = bee->chatrooms; c; c = nc )
+ {
+ nc = c->next;
+ if( acc == c->acc )
+ chat_del( bee, c );
+ }
+ */
+
+ while( a->set )
+ set_del( &a->set, a->set->key );
+
+ g_hash_table_destroy( a->nicks );
+
+ g_free( a->user );
+ g_free( a->pass );
+ g_free( a->server );
+ if( a->reconnect ) /* This prevents any reconnect still queued to happen */
+ cancel_auto_reconnect( a );
+ g_free( a );
+
+ break;
+ }
+}
+
+void account_on( bee_t *bee, account_t *a )
+{
+ if( a->ic )
+ {
+ /* Trying to enable an already-enabled account */
+ return;
+ }
+
+ cancel_auto_reconnect( a );
+
+ a->reconnect = 0;
+ a->prpl->login( a );
+}
+
+void account_off( bee_t *bee, account_t *a )
+{
+ imc_logout( a->ic, FALSE );
+ a->ic = NULL;
+ if( a->reconnect )
+ {
+ /* Shouldn't happen */
+ cancel_auto_reconnect( a );
+ }
+}
+
+struct account_reconnect_delay
+{
+ int start;
+ char op;
+ int step;
+ int max;
+};
+
+int account_reconnect_delay_parse( char *value, struct account_reconnect_delay *p )
+{
+ memset( p, 0, sizeof( *p ) );
+ /* A whole day seems like a sane "maximum maximum". */
+ p->max = 86400;
+
+ /* Format: /[0-9]+([*+][0-9]+(<[0-9+])?)?/ */
+ while( *value && isdigit( *value ) )
+ p->start = p->start * 10 + *value++ - '0';
+
+ /* Sure, call me evil for implementing my own fscanf here, but it's
+ dead simple and I immediately know where to continue parsing. */
+
+ if( *value == 0 )
+ /* If the string ends now, the delay is constant. */
+ return 1;
+ else if( *value != '+' && *value != '*' )
+ /* Otherwise allow either a + or a * */
+ return 0;
+
+ p->op = *value++;
+
+ /* + or * the delay by this number every time. */
+ while( *value && isdigit( *value ) )
+ p->step = p->step * 10 + *value++ - '0';
+
+ if( *value == 0 )
+ /* Use the default maximum (one day). */
+ return 1;
+ else if( *value != '<' )
+ return 0;
+
+ p->max = 0;
+ value ++;
+ while( *value && isdigit( *value ) )
+ p->max = p->max * 10 + *value++ - '0';
+
+ return p->max > 0;
+}
+
+char *set_eval_account_reconnect_delay( set_t *set, char *value )
+{
+ struct account_reconnect_delay p;
+
+ return account_reconnect_delay_parse( value, &p ) ? value : SET_INVALID;
+}
+
+int account_reconnect_delay( account_t *a )
+{
+ char *setting = set_getstr( &a->bee->set, "auto_reconnect_delay" );
+ struct account_reconnect_delay p;
+
+ if( account_reconnect_delay_parse( setting, &p ) )
+ {
+ if( a->auto_reconnect_delay == 0 )
+ a->auto_reconnect_delay = p.start;
+ else if( p.op == '+' )
+ a->auto_reconnect_delay += p.step;
+ else if( p.op == '*' )
+ a->auto_reconnect_delay *= p.step;
+
+ if( a->auto_reconnect_delay > p.max )
+ a->auto_reconnect_delay = p.max;
+ }
+ else
+ {
+ a->auto_reconnect_delay = 0;
+ }
+
+ return a->auto_reconnect_delay;
+}
diff --git a/protocols/account.h b/protocols/account.h
new file mode 100644
index 00000000..be27542e
--- /dev/null
+++ b/protocols/account.h
@@ -0,0 +1,72 @@
+ /********************************************************************\
+ * BitlBee -- An IRC to other IM-networks gateway *
+ * *
+ * Copyright 2002-2004 Wilmer van der Gaast and others *
+ \********************************************************************/
+
+/* Account management functions */
+
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License with
+ the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
+ if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef _ACCOUNT_H
+#define _ACCOUNT_H
+
+typedef struct account
+{
+ struct prpl *prpl;
+ char *user;
+ char *pass;
+ char *server;
+
+ int auto_connect;
+ int auto_reconnect_delay;
+ int reconnect;
+ int flags;
+
+ set_t *set;
+ GHashTable *nicks;
+
+ struct bee *bee;
+ struct im_connection *ic;
+ struct account *next;
+} account_t;
+
+account_t *account_add( bee_t *bee, struct prpl *prpl, char *user, char *pass );
+account_t *account_get( bee_t *bee, char *id );
+void account_del( bee_t *bee, account_t *acc );
+void account_on( bee_t *bee, account_t *a );
+void account_off( bee_t *bee, account_t *a );
+
+char *set_eval_account( set_t *set, char *value );
+char *set_eval_account_reconnect_delay( set_t *set, char *value );
+int account_reconnect_delay( account_t *a );
+
+typedef enum
+{
+ ACC_SET_NOSAVE = 0x01, /* Don't save this setting (i.e. stored elsewhere). */
+ ACC_SET_OFFLINE_ONLY = 0x02, /* Allow changes only if the acct is offline. */
+ ACC_SET_ONLINE_ONLY = 0x04, /* Allow changes only if the acct is online. */
+} account_set_flag_t;
+
+typedef enum
+{
+ ACC_FLAG_AWAY_MESSAGE = 0x01, /* Supports away messages instead of just states. */
+ ACC_FLAG_STATUS_MESSAGE = 0x02, /* Supports status messages (without being away). */
+} account_flag_t;
+
+#endif
diff --git a/protocols/bee.c b/protocols/bee.c
new file mode 100644
index 00000000..3f576b0b
--- /dev/null
+++ b/protocols/bee.c
@@ -0,0 +1,47 @@
+#include "bitlbee.h"
+
+bee_t *bee_new()
+{
+ bee_t *b = g_new0( bee_t, 1 );
+ set_t *s;
+
+ s = set_add( &b->set, "away", NULL, NULL/*set_eval_away_status*/, b );
+ s->flags |= SET_NULL_OK;
+ s = set_add( &b->set, "auto_connect", "true", set_eval_bool, b );
+ s = set_add( &b->set, "auto_reconnect", "true", set_eval_bool, b );
+ s = set_add( &b->set, "auto_reconnect_delay", "5*3<900", NULL/*set_eval_account_reconnect_delay*/, b );
+ s = set_add( &b->set, "debug", "false", set_eval_bool, b );
+ s = set_add( &b->set, "password", NULL, NULL/*set_eval_password*/, b );
+ s->flags |= SET_NULL_OK;
+ s = set_add( &b->set, "save_on_quit", "true", set_eval_bool, b );
+ s = set_add( &b->set, "status", NULL, NULL/*set_eval_away_status*/, b );
+ s->flags |= SET_NULL_OK;
+ s = set_add( &b->set, "strip_html", "true", NULL, b );
+
+ return b;
+}
+
+void bee_free( bee_t *b )
+{
+ account_t *acc = b->accounts;
+
+ while( acc )
+ {
+ if( acc->ic )
+ imc_logout( acc->ic, FALSE );
+ else if( acc->reconnect )
+ cancel_auto_reconnect( acc );
+
+ if( acc->ic == NULL )
+ account_del( b, acc );
+ else
+ /* Nasty hack, but account_del() doesn't work in this
+ case and we don't want infinite loops, do we? ;-) */
+ acc = acc->next;
+ }
+
+ while( b->set )
+ set_del( &b->set, b->set->key );
+
+ g_free( b );
+}
diff --git a/protocols/bee.h b/protocols/bee.h
new file mode 100644
index 00000000..6f896c51
--- /dev/null
+++ b/protocols/bee.h
@@ -0,0 +1,102 @@
+ /********************************************************************\
+ * BitlBee -- An IRC to other IM-networks gateway *
+ * *
+ * Copyright 2002-2010 Wilmer van der Gaast and others *
+ \********************************************************************/
+
+/* Stuff to handle, save and search buddies */
+
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License with
+ the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
+ if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef __BEE_H__
+#define __BEE_H__
+
+struct bee_ui_funcs;
+
+typedef struct bee
+{
+ struct set *set;
+
+ GSList *users;
+ struct account *accounts; /* TODO(wilmer): Use GSList here too? */
+
+ const struct bee_ui_funcs *ui;
+ void *ui_data;
+} bee_t;
+
+bee_t *bee_new();
+void bee_free( bee_t *b );
+
+typedef enum
+{
+ BEE_USER_ONLINE = 1, /* Compatibility with old OPT_LOGGED_IN flag */
+ BEE_USER_AWAY = 4, /* Compatibility with old OPT_AWAY flag */
+} bee_user_flags_t;
+
+typedef struct bee_user
+{
+ struct im_connection *ic;
+ char *handle;
+ char *fullname;
+ char *group;
+
+ bee_user_flags_t flags;
+ char *status;
+ char *status_msg;
+
+ bee_t *bee;
+ void *ui_data;
+} bee_user_t;
+
+typedef struct bee_ui_funcs
+{
+ gboolean (*user_new)( bee_t *bee, struct bee_user *bu );
+ gboolean (*user_free)( bee_t *bee, struct bee_user *bu );
+ gboolean (*user_fullname)( bee_t *bee, bee_user_t *bu );
+ gboolean (*user_status)( bee_t *bee, struct bee_user *bu, struct bee_user *old );
+ gboolean (*user_msg)( bee_t *bee, bee_user_t *bu, const char *msg, time_t sent_at );
+
+ struct file_transfer* (*ft_in_start)( bee_t *bee, bee_user_t *bu, const char *file_name, size_t file_size );
+ gboolean (*ft_out_start)( struct im_connection *ic, struct file_transfer *ft );
+ void (*ft_close)( struct im_connection *ic, struct file_transfer *ft );
+ void (*ft_finished)( struct im_connection *ic, struct file_transfer *ft );
+} bee_ui_funcs_t;
+
+
+/* bee.c */
+bee_t *bee_new();
+void bee_free( bee_t *b );
+
+/* bee_user.c */
+bee_user_t *bee_user_new( bee_t *bee, struct im_connection *ic, const char *handle );
+int bee_user_free( bee_t *bee, struct im_connection *ic, const char *handle );
+bee_user_t *bee_user_by_handle( bee_t *bee, struct im_connection *ic, const char *handle );
+int bee_user_msg( bee_t *bee, bee_user_t *bu, const char *msg, int flags );
+
+/* Callbacks from IM modules to core: */
+/* Buddy activity */
+/* To manipulate the status of a handle.
+ * - flags can be |='d with OPT_* constants. You will need at least:
+ * OPT_LOGGED_IN and OPT_AWAY.
+ * - 'state' and 'message' can be NULL */
+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, const char *handle, char *msg, guint32 flags, time_t sent_at );
+
+#endif /* __BEE_H__ */
diff --git a/protocols/bee_ft.c b/protocols/bee_ft.c
new file mode 100644
index 00000000..1026eab3
--- /dev/null
+++ b/protocols/bee_ft.c
@@ -0,0 +1,66 @@
+/********************************************************************\
+* BitlBee -- An IRC to other IM-networks gateway *
+* *
+* Copyright 2010 Wilmer van der Gaast <wilmer@gaast.net> *
+\********************************************************************/
+
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License with
+ the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
+ if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#define BITLBEE_CORE
+#include "bitlbee.h"
+#include "ft.h"
+
+file_transfer_t *imcb_file_send_start( struct im_connection *ic, char *handle, char *file_name, size_t file_size )
+{
+ bee_t *bee = ic->bee;
+ bee_user_t *bu = bee_user_by_handle( bee, ic, handle );
+
+ if( bee->ui->ft_in_start )
+ return bee->ui->ft_in_start( bee, bu, file_name, file_size );
+ else
+ return NULL;
+}
+
+gboolean imcb_file_recv_start( struct im_connection *ic, file_transfer_t *ft )
+{
+ bee_t *bee = ic->bee;
+
+ if( bee->ui->ft_out_start )
+ return bee->ui->ft_out_start( ic, ft );
+ else
+ return FALSE;
+}
+
+void imcb_file_canceled( struct im_connection *ic, file_transfer_t *file, char *reason )
+{
+ bee_t *bee = ic->bee;
+
+ if( file->canceled )
+ file->canceled( file, reason );
+
+ if( bee->ui->ft_close )
+ bee->ui->ft_close( ic, file );
+}
+
+void imcb_file_finished( struct im_connection *ic, file_transfer_t *file )
+{
+ bee_t *bee = ic->bee;
+
+ if( bee->ui->ft_finished )
+ bee->ui->ft_finished( ic, file );
+}
diff --git a/protocols/bee_user.c b/protocols/bee_user.c
new file mode 100644
index 00000000..20c760a9
--- /dev/null
+++ b/protocols/bee_user.c
@@ -0,0 +1,197 @@
+ /********************************************************************\
+ * BitlBee -- An IRC to other IM-networks gateway *
+ * *
+ * Copyright 2002-2010 Wilmer van der Gaast and others *
+ \********************************************************************/
+
+/* Stuff to handle, save and search buddies */
+
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License with
+ the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
+ if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#define BITLBEE_CORE
+#include "bitlbee.h"
+
+bee_user_t *bee_user_new( bee_t *bee, struct im_connection *ic, const char *handle )
+{
+ bee_user_t *bu;
+
+ if( bee_user_by_handle( bee, ic, handle ) != NULL )
+ return NULL;
+
+ bu = g_new0( bee_user_t, 1 );
+ bu->bee = bee;
+ bu->ic = ic;
+ bu->handle = g_strdup( handle );
+ bee->users = g_slist_prepend( bee->users, bu );
+
+ if( bee->ui->user_new )
+ bee->ui->user_new( bee, bu );
+
+ return bu;
+}
+
+int bee_user_free( bee_t *bee, struct im_connection *ic, const char *handle )
+{
+ bee_user_t *bu;
+
+ if( ( bu = bee_user_by_handle( bee, ic, handle ) ) == NULL )
+ return 0;
+
+ if( bee->ui->user_free )
+ bee->ui->user_free( bee, bu );
+
+ g_free( bu->handle );
+ g_free( bu->fullname );
+ g_free( bu->group );
+ g_free( bu->status );
+ g_free( bu->status_msg );
+
+ bee->users = g_slist_remove( bee->users, bu );
+
+ return 1;
+}
+
+bee_user_t *bee_user_by_handle( bee_t *bee, struct im_connection *ic, const char *handle )
+{
+ GSList *l;
+
+ for( l = bee->users; l; l = l->next )
+ {
+ bee_user_t *bu = l->data;
+
+ if( bu->ic == ic && ic->acc->prpl->handle_cmp( bu->handle, handle ) == 0 )
+ return bu;
+ }
+
+ return NULL;
+}
+
+int bee_user_msg( bee_t *bee, bee_user_t *bu, const char *msg, int flags )
+{
+ char *buf = NULL;
+ int st;
+
+ if( ( bu->ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
+ {
+ buf = escape_html( msg );
+ msg = buf;
+ }
+ else
+ buf = g_strdup( msg );
+
+ st = bu->ic->acc->prpl->buddy_msg( bu->ic, bu->handle, buf, flags );
+ g_free( buf );
+
+ return st;
+}
+
+
+/* IM->UI callbacks */
+void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message )
+{
+ bee_t *bee = ic->bee;
+ bee_user_t *bu, *old;
+
+ if( !( bu = bee_user_by_handle( bee, ic, handle ) ) )
+ {
+ if( g_strcasecmp( set_getstr( &ic->bee->set, "handle_unknown" ), "add" ) == 0 )
+ {
+ bu = bee_user_new( bee, ic, handle );
+ }
+ else
+ {
+ if( g_strcasecmp( set_getstr( &ic->bee->set, "handle_unknown" ), "ignore" ) != 0 )
+ {
+ imcb_log( ic, "imcb_buddy_status() for unknown handle %s:\n"
+ "flags = %d, state = %s, message = %s", handle, flags,
+ state ? state : "NULL", message ? message : "NULL" );
+ }
+
+ return;
+ }
+ }
+
+ /* May be nice to give the UI something to compare against. */
+ old = g_memdup( bu, sizeof( bee_user_t ) );
+
+ /* TODO(wilmer): OPT_AWAY, or just state == NULL ? */
+ bu->flags = flags;
+ bu->status = g_strdup( ( flags & OPT_AWAY ) && state == NULL ? "Away" : state );
+ bu->status_msg = g_strdup( message );
+
+ if( bee->ui->user_status )
+ bee->ui->user_status( bee, bu, old );
+
+ g_free( old->status_msg );
+ g_free( old->status );
+ g_free( old );
+#if 0
+ /* LISPy... */
+ if( ( set_getbool( &ic->bee->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */
+ ( u->online ) && /* Don't touch offline people */
+ ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */
+ ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */
+ {
+ char *from;
+
+ if( set_getbool( &ic->bee->set, "simulate_netsplit" ) )
+ {
+ from = g_strdup( ic->irc->myhost );
+ }
+ else
+ {
+ from = g_strdup_printf( "%s!%s@%s", ic->irc->mynick, ic->irc->mynick,
+ ic->irc->myhost );
+ }
+ irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel,
+ u->away?'-':'+', u->nick );
+ g_free( from );
+ }
+#endif
+}
+
+void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at )
+{
+ bee_t *bee = ic->bee;
+ bee_user_t *bu;
+
+ bu = bee_user_by_handle( bee, ic, handle );
+
+ if( !bu )
+ {
+ char *h = set_getstr( &bee->set, "handle_unknown" );
+
+ if( g_strcasecmp( h, "ignore" ) == 0 )
+ {
+ return;
+ }
+ else if( g_strncasecmp( h, "add", 3 ) == 0 )
+ {
+ bu = bee_user_new( bee, ic, handle );
+ }
+ }
+
+ if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||
+ ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )
+ strip_html( msg );
+
+ if( bee->ui->user_msg && bu )
+ bee->ui->user_msg( bee, bu, msg, sent_at );
+ else
+ imcb_log( ic, "Message from unknown handle %s:\n%s", handle, msg );
+}
diff --git a/protocols/chat.c b/protocols/chat.c
new file mode 100644
index 00000000..8c5ce0bc
--- /dev/null
+++ b/protocols/chat.c
@@ -0,0 +1,192 @@
+ /********************************************************************\
+ * BitlBee -- An IRC to other IM-networks gateway *
+ * *
+ * Copyright 2002-2008 Wilmer van der Gaast and others *
+ \********************************************************************/
+
+/* Keep track of chatrooms the user is interested in */
+
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License with
+ the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
+ if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "bitlbee.h"
+#include "chat.h"
+
+struct chat *chat_add( irc_t *irc, account_t *acc, char *handle, char *channel )
+{
+ struct chat *c, *l;
+ set_t *s;
+
+ if( acc->prpl->chat_join == NULL || !chat_chanok( channel ) ||
+ chat_chancmp( channel, irc->channel ) == 0 )
+ {
+ return NULL;
+ }
+
+ for( c = irc->chatrooms; c; c = c->next )
+ {
+ if( chat_chancmp( channel, c->channel ) == 0 )
+ return NULL;
+
+ if( acc == c->acc && g_strcasecmp( handle, c->handle ) == 0 )
+ return NULL;
+
+ l = c;
+ }
+
+ if( irc->chatrooms == NULL )
+ irc->chatrooms = c = g_new0( struct chat, 1 );
+ else
+ l->next = c = g_new0( struct chat, 1 );
+
+ c->acc = acc;
+ c->handle = g_strdup( handle );
+ c->channel = g_strdup( channel );
+
+ s = set_add( &c->set, "auto_join", "false", set_eval_bool, c );
+ /* s = set_add( &c->set, "auto_rejoin", "false", set_eval_bool, c ); */
+ s = set_add( &c->set, "nick", NULL, NULL, c );
+ s->flags |= SET_NULL_OK;
+
+ return c;
+}
+
+struct chat *chat_byhandle( irc_t *irc, account_t *acc, char *handle )
+{
+ struct chat *c;
+
+ for( c = irc->chatrooms; c; c = c->next )
+ {
+ if( acc == c->acc && g_strcasecmp( handle, c->handle ) == 0 )
+ break;
+ }
+
+ return c;
+}
+
+struct chat *chat_bychannel( irc_t *irc, char *channel )
+{
+ struct chat *c;
+
+ for( c = irc->chatrooms; c; c = c->next )
+ {
+ if( chat_chancmp( channel, c->channel ) == 0 )
+ break;
+ }
+
+ return c;
+}
+
+struct chat *chat_get( irc_t *irc, char *id )
+{
+ struct chat *c, *ret = NULL;
+ int nr;
+
+ if( sscanf( id, "%d", &nr ) == 1 && nr < 1000 )
+ {
+ for( c = irc->chatrooms; c; c = c->next )
+ if( ( nr-- ) == 0 )
+ return c;
+
+ return NULL;
+ }
+
+ for( c = irc->chatrooms; c; c = c->next )
+ {
+ if( strstr( c->handle, id ) )
+ {
+ if( !ret )
+ ret = c;
+ else
+ return NULL;
+ }
+ else if( strstr( c->channel, id ) )
+ {
+ if( !ret )
+ ret = c;
+ else
+ return NULL;
+ }
+ }
+
+ return ret;
+}
+
+int chat_del( irc_t *irc, struct chat *chat )
+{
+ struct chat *c, *l = NULL;
+
+ for( c = irc->chatrooms; c; c = (l=c)->next )
+ if( c == chat )
+ break;
+
+ if( c == NULL )
+ return 0;
+ else if( l == NULL )
+ irc->chatrooms = c->next;
+ else
+ l->next = c->next;
+
+ while( c->set )
+ set_del( &c->set, c->set->key );
+
+ g_free( c->handle );
+ g_free( c->channel );
+ g_free( c );
+
+ return 1;
+}
+
+int chat_chancmp( char *a, char *b )
+{
+ if( !chat_chanok( a ) || !chat_chanok( b ) )
+ return 0;
+
+ if( a[0] == b[0] )
+ return nick_cmp( a + 1, b + 1 );
+ else
+ return -1;
+}
+
+int chat_chanok( char *a )
+{
+ if( strchr( CTYPES, a[0] ) != NULL )
+ return nick_ok( a + 1 );
+ else
+ return 0;
+}
+
+int chat_join( irc_t *irc, struct chat *c, const char *password )
+{
+ struct groupchat *gc;
+ char *nick = set_getstr( &c->set, "nick" );
+
+ if( c->acc->ic == NULL || c->acc->prpl->chat_join == NULL )
+ return 0;
+
+ if( nick == NULL )
+ nick = irc->nick;
+
+ if( ( gc = c->acc->prpl->chat_join( c->acc->ic, c->handle, nick, password ) ) )
+ {
+ g_free( gc->channel );
+ gc->channel = g_strdup( c->channel );
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/protocols/chat.h b/protocols/chat.h
new file mode 100644
index 00000000..7196aea8
--- /dev/null
+++ b/protocols/chat.h
@@ -0,0 +1,51 @@
+ /********************************************************************\
+ * BitlBee -- An IRC to other IM-networks gateway *
+ * *
+ * Copyright 2002-2008 Wilmer van der Gaast and others *
+ \********************************************************************/
+
+/* Keep track of chatrooms the user is interested in */
+
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License with
+ the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
+ if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef _CHAT_H
+#define _CHAT_H
+
+struct chat
+{
+ account_t *acc;
+
+ char *handle;
+ char *channel;
+ set_t *set;
+
+ struct chat *next;
+};
+
+struct chat *chat_add( irc_t *irc, account_t *acc, char *handle, char *channel );
+struct chat *chat_byhandle( irc_t *irc, account_t *acc, char *handle );
+struct chat *chat_bychannel( irc_t *irc, char *channel );
+struct chat *chat_get( irc_t *irc, char *id );
+int chat_del( irc_t *irc, struct chat *chat );
+
+int chat_chancmp( char *a, char *b );
+int chat_chanok( char *a );
+
+int chat_join( irc_t *irc, struct chat *c, const char *password );
+
+#endif
diff --git a/protocols/ft.h b/protocols/ft.h
index 1155f06f..c1ee2b49 100644
--- a/protocols/ft.h
+++ b/protocols/ft.h
@@ -167,9 +167,9 @@ file_transfer_t *imcb_file_send_start( struct im_connection *ic, char *user_nick
* This should be called by a protocol when the transfer is canceled. Note that
* the canceled() and free() callbacks given in file will be called by this function.
*/
-void imcb_file_canceled( file_transfer_t *file, char *reason );
+void imcb_file_canceled( struct im_connection *ic, file_transfer_t *file, char *reason );
-gboolean imcb_file_recv_start( file_transfer_t *ft );
+gboolean imcb_file_recv_start( struct im_connection *ic, file_transfer_t *ft );
-void imcb_file_finished( file_transfer_t *file );
+void imcb_file_finished( struct im_connection *ic, file_transfer_t *file );
#endif
diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c
index f5fbdc13..bdedeb08 100644
--- a/protocols/jabber/iq.c
+++ b/protocols/jabber/iq.c
@@ -391,7 +391,7 @@ static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *
{
if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) )
{
- if( initial || imcb_find_buddy( ic, jid ) == NULL )
+ if( initial || bee_user_by_handle( ic->bee, ic, jid ) == NULL )
imcb_add_buddy( ic, jid, ( group && group->text_len ) ?
group->text : NULL );
@@ -589,7 +589,7 @@ static xt_status jabber_add_to_roster_callback( struct im_connection *ic, struct
( s = xt_find_attr( node, "type" ) ) &&
strcmp( s, "result" ) == 0 )
{
- if( imcb_find_buddy( ic, jid ) == NULL )
+ if( bee_user_by_handle( ic->bee, ic, jid ) == NULL )
imcb_add_buddy( ic, jid, NULL );
}
else
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index 956769b7..acad525e 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -266,7 +266,7 @@ static void jabber_logout( struct im_connection *ic )
struct jabber_data *jd = ic->proto_data;
while( jd->filetransfers )
- imcb_file_canceled( ( ( struct jabber_transfer *) jd->filetransfers->data )->ft, "Logging out" );
+ imcb_file_canceled( ic, ( ( struct jabber_transfer *) jd->filetransfers->data )->ft, "Logging out" );
while( jd->streamhosts )
{
diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c
index bd2fbe8c..6f58f124 100644
--- a/protocols/jabber/jabber_util.c
+++ b/protocols/jabber/jabber_util.c
@@ -278,8 +278,7 @@ static void jabber_buddy_ask_yes( void *data )
presence_send_request( bla->ic, bla->handle, "subscribed" );
- if( imcb_find_buddy( bla->ic, bla->handle ) == NULL )
- imcb_ask_add( bla->ic, bla->handle, NULL );
+ imcb_ask_add( bla->ic, bla->handle, NULL );
g_free( bla->handle );
g_free( bla );
@@ -461,7 +460,7 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_,
}
if( bud == NULL && ( flags & GET_BUDDY_CREAT ) &&
- ( bare_exists || imcb_find_buddy( ic, jid ) ) )
+ ( bare_exists || bee_user_by_handle( ic->bee, ic, jid ) ) )
{
*s = '/';
bud = jabber_buddy_add( ic, jid );
@@ -482,7 +481,8 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_,
if( bud == NULL )
/* No match. Create it now? */
- return ( ( flags & GET_BUDDY_CREAT ) && imcb_find_buddy( ic, jid_ ) ) ?
+ return ( ( flags & GET_BUDDY_CREAT ) &&
+ bee_user_by_handle( ic->bee, ic, jid_ ) ) ?
jabber_buddy_add( ic, jid_ ) : NULL;
else if( bud->resource && ( flags & GET_BUDDY_EXACT ) )
/* We want an exact match, so in thise case there shouldn't be a /resource. */
diff --git a/protocols/jabber/s5bytestream.c b/protocols/jabber/s5bytestream.c
index 36a2e438..7d993529 100644
--- a/protocols/jabber/s5bytestream.c
+++ b/protocols/jabber/s5bytestream.c
@@ -566,7 +566,7 @@ gboolean jabber_bs_recv_handshake_abort( struct bs_transfer *bt, char *error )
imcb_log( tf->ic, "WARNING: Error transmitting bytestream response" );
xt_free_node( reply );
- imcb_file_canceled( tf->ft, "couldn't connect to any streamhosts" );
+ imcb_file_canceled( tf->ic, tf->ft, "couldn't connect to any streamhosts" );
bt->tf->watch_in = 0;
/* MUST always return FALSE! */
@@ -603,7 +603,7 @@ void jabber_bs_recv_answer_request( struct bs_transfer *bt )
xt_add_attr( reply, "id", tf->iq_id );
if( !jabber_write_packet( tf->ic, reply ) )
- imcb_file_canceled( tf->ft, "Error transmitting bytestream response" );
+ imcb_file_canceled( tf->ic, tf->ft, "Error transmitting bytestream response" );
xt_free_node( reply );
}
@@ -643,7 +643,7 @@ gboolean jabber_bs_recv_read( gpointer data, gint fd, b_input_condition cond )
tf->bytesread += ret;
if( tf->bytesread >= tf->ft->file_size )
- imcb_file_finished( tf->ft );
+ imcb_file_finished( tf->ic, tf->ft );
tf->ft->write( tf->ft, tf->ft->buffer, ret );
@@ -659,7 +659,7 @@ gboolean jabber_bs_recv_write_request( file_transfer_t *ft )
if( tf->watch_in )
{
- imcb_file_canceled( ft, "BUG in jabber file transfer: write_request called when already watching for input" );
+ imcb_file_canceled( tf->ic, ft, "BUG in jabber file transfer: write_request called when already watching for input" );
return FALSE;
}
@@ -705,7 +705,7 @@ gboolean jabber_bs_send_write( file_transfer_t *ft, char *buffer, unsigned int l
return jabber_bs_abort( bt, "send() sent %d instead of %d (send buffer too big!)", ret, len );
if( tf->byteswritten >= ft->file_size )
- imcb_file_finished( ft );
+ imcb_file_finished( tf->ic, ft );
else
bt->tf->watch_out = b_input_add( tf->fd, GAIM_INPUT_WRITE, jabber_bs_send_can_write, bt );
@@ -1005,7 +1005,7 @@ gboolean jabber_bs_send_request( struct jabber_transfer *tf, GSList *streamhosts
jabber_cache_add( tf->ic, iq, jabber_bs_send_handle_reply );
if( !jabber_write_packet( tf->ic, iq ) )
- imcb_file_canceled( tf->ft, "Error transmitting bytestream request" );
+ imcb_file_canceled( tf->ic, tf->ft, "Error transmitting bytestream request" );
return TRUE;
}
@@ -1020,7 +1020,7 @@ gboolean jabber_bs_send_handshake_abort(struct bs_transfer *bt, char *error )
error );
if( jd->streamhosts==NULL ) /* we're done here unless we have a proxy to try */
- imcb_file_canceled( tf->ft, error );
+ imcb_file_canceled( tf->ic, tf->ft, error );
/* MUST always return FALSE! */
return FALSE;
diff --git a/protocols/jabber/si.c b/protocols/jabber/si.c
index bfb64f11..58c0e17f 100644
--- a/protocols/jabber/si.c
+++ b/protocols/jabber/si.c
@@ -90,11 +90,11 @@ int jabber_si_check_features( struct jabber_transfer *tf, GSList *features ) {
}
if( !foundft )
- imcb_file_canceled( tf->ft, "Buddy's client doesn't feature file transfers" );
+ imcb_file_canceled( tf->ic, tf->ft, "Buddy's client doesn't feature file transfers" );
else if( !foundbt )
- imcb_file_canceled( tf->ft, "Buddy's client doesn't feature byte streams (required)" );
+ imcb_file_canceled( tf->ic, tf->ft, "Buddy's client doesn't feature byte streams (required)" );
else if( !foundsi )
- imcb_file_canceled( tf->ft, "Buddy's client doesn't feature stream initiation (required)" );
+ imcb_file_canceled( tf->ic, tf->ft, "Buddy's client doesn't feature stream initiation (required)" );
return foundft && foundbt && foundsi;
}
@@ -108,7 +108,7 @@ void jabber_si_transfer_start( struct jabber_transfer *tf ) {
jabber_si_send_request( tf->ic, tf->bud->full_jid, tf );
/* and start the receive logic */
- imcb_file_recv_start( tf->ft );
+ imcb_file_recv_start( tf->ic, tf->ft );
}
@@ -155,7 +155,7 @@ void jabber_si_transfer_request( struct im_connection *ic, file_transfer_t *ft,
if( bud == NULL )
{
- imcb_file_canceled( ft, "Couldn't find buddy (BUG?)" );
+ imcb_file_canceled( ic, ft, "Couldn't find buddy (BUG?)" );
return;
}
diff --git a/protocols/msn/Makefile b/protocols/msn/Makefile
index 5d199b9e..6a588613 100644
--- a/protocols/msn/Makefile
+++ b/protocols/msn/Makefile
@@ -9,7 +9,7 @@
-include ../../Makefile.settings
# [SH] Program variables
-objects = invitation.o msn.o msn_util.o ns.o passport.o sb.o tables.o
+objects = msn.o msn_util.o ns.o passport.o sb.o tables.o
CFLAGS += -Wall
LFLAGS += -r
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c
index 3a8b8f7b..8b73f103 100644
--- a/protocols/msn/msn.c
+++ b/protocols/msn/msn.c
@@ -80,9 +80,11 @@ static void msn_logout( struct im_connection *ic )
if( md )
{
+ /** Disabling MSN ft support for now.
while( md->filetransfers ) {
imcb_file_canceled( md->filetransfers->data, "Closing connection" );
}
+ */
if( md->fd >= 0 )
closesocket( md->fd );
@@ -343,7 +345,7 @@ void msn_initmodule()
ret->rem_deny = msn_rem_deny;
ret->send_typing = msn_send_typing;
ret->handle_cmp = g_strcasecmp;
- ret->transfer_request = msn_ftp_transfer_request;
+ //ret->transfer_request = msn_ftp_transfer_request;
register_protocol(ret);
}
diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c
index 668a8b8a..f85981e5 100644
--- a/protocols/msn/msn_util.c
+++ b/protocols/msn/msn_util.c
@@ -95,8 +95,7 @@ static void msn_buddy_ask_yes( void *data )
msn_buddy_list_add( bla->ic, "AL", bla->handle, bla->realname );
- if( imcb_find_buddy( bla->ic, bla->handle ) == NULL )
- imcb_ask_add( bla->ic, bla->handle, NULL );
+ imcb_ask_add( bla->ic, bla->handle, NULL );
g_free( bla->handle );
g_free( bla->realname );
diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c
index c3302e57..a935ce97 100644
--- a/protocols/msn/sb.c
+++ b/protocols/msn/sb.c
@@ -690,6 +690,8 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int
/* PANIC! */
}
}
+#if 0
+ // Disable MSN ft support for now.
else if( g_strncasecmp( ct, "text/x-msmsgsinvite", 19 ) == 0 )
{
char *command = msn_findheader( body, "Invitation-Command:", blen );
@@ -722,6 +724,7 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int
g_free( command );
}
+#endif
else if( g_strncasecmp( ct, "application/x-msnmsgrp2p", 24 ) == 0 )
{
imcb_error( sb->ic, "Cannot receive file from %s: BitlBee does not "
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index c326e378..4521eb32 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -37,8 +37,6 @@
#include "nogaim.h"
#include "chat.h"
-static int remove_chat_buddy_silent( struct groupchat *b, const char *handle );
-
GSList *connections;
#ifdef WITH_PLUGINS
@@ -91,8 +89,6 @@ void load_plugins(void)
}
#endif
-/* nogaim.c */
-
GList *protocols = NULL;
void register_protocol (struct prpl *p)
@@ -124,7 +120,6 @@ struct prpl *find_protocol(const char *name)
return NULL;
}
-/* nogaim.c */
void nogaim_init()
{
extern void msn_initmodule();
@@ -155,15 +150,13 @@ void nogaim_init()
GSList *get_connections() { return connections; }
-/* multi.c */
-
struct im_connection *imcb_new( account_t *acc )
{
struct im_connection *ic;
ic = g_new0( struct im_connection, 1 );
- ic->irc = acc->irc;
+ ic->bee = acc->bee;
ic->acc = acc;
acc->ic = ic;
@@ -177,7 +170,7 @@ void imc_free( struct im_connection *ic )
account_t *a;
/* Destroy the pointer to this connection from the account list */
- for( a = ic->irc->accounts; a; a = a->next )
+ for( a = ic->bee->accounts; a; a = a->next )
if( a->ic == ic )
{
a->ic = NULL;
@@ -198,20 +191,21 @@ static void serv_got_crap( struct im_connection *ic, char *format, ... )
text = g_strdup_vprintf( format, params );
va_end( params );
- if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
- ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
+ if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||
+ ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )
strip_html( text );
/* Try to find a different connection on the same protocol. */
- for( a = ic->irc->accounts; a; a = a->next )
+ for( a = ic->bee->accounts; a; a = a->next )
if( a->prpl == ic->acc->prpl && a->ic != ic )
break;
/* If we found one, include the screenname in the message. */
if( a )
- irc_usermsg( ic->irc, "%s(%s) - %s", ic->acc->prpl->name, ic->acc->user, text );
+ /* FIXME(wilmer): ui_log callback or so */
+ irc_usermsg( ic->bee->ui_data, "%s(%s) - %s", ic->acc->prpl->name, ic->acc->user, text );
else
- irc_usermsg( ic->irc, "%s - %s", ic->acc->prpl->name, text );
+ irc_usermsg( ic->bee->ui_data, "%s - %s", ic->acc->prpl->name, text );
g_free( text );
}
@@ -262,18 +256,12 @@ static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond )
void imcb_connected( struct im_connection *ic )
{
- irc_t *irc = ic->irc;
- struct chat *c;
- user_t *u;
-
/* MSN servers sometimes redirect you to a different server and do
the whole login sequence again, so these "late" calls to this
function should be handled correctly. (IOW, ignored) */
if( ic->flags & OPT_LOGGED_IN )
return;
- u = user_find( ic->irc, ic->irc->nick );
-
imcb_log( ic, "Logged in" );
ic->keepalive = b_timeout_add( 60000, send_keepalive, ic );
@@ -286,6 +274,7 @@ void imcb_connected( struct im_connection *ic )
exponential backoff timer. */
ic->acc->auto_reconnect_delay = 0;
+ /*
for( c = irc->chatrooms; c; c = c->next )
{
if( c->acc != ic->acc )
@@ -294,6 +283,7 @@ void imcb_connected( struct im_connection *ic )
if( set_getbool( &c->set, "auto_join" ) )
chat_join( irc, c, NULL );
}
+ */
}
gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond )
@@ -301,7 +291,7 @@ gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond )
account_t *a = data;
a->reconnect = 0;
- account_on( a->irc, a );
+ account_on( a->bee, a );
return( FALSE ); /* Only have to run the timeout once */
}
@@ -314,9 +304,9 @@ void cancel_auto_reconnect( account_t *a )
void imc_logout( struct im_connection *ic, int allow_reconnect )
{
- irc_t *irc = ic->irc;
- user_t *t, *u;
+ bee_t *bee = ic->bee;
account_t *a;
+ GSList *l;
int delay;
/* Nested calls might happen sometimes, this is probably the best
@@ -336,22 +326,17 @@ void imc_logout( struct im_connection *ic, int allow_reconnect )
g_free( ic->away );
ic->away = NULL;
- u = irc->users;
- while( u )
+ for( l = bee->users; l; l = l->next )
{
- if( u->ic == ic )
- {
- t = u->next;
- user_del( irc, u->nick );
- u = t;
- }
- else
- u = u->next;
+ bee_user_t *bu = l->data;
+
+ if( bu->ic == ic )
+ bee_user_free( bee, ic, bu->handle );
}
- query_del_by_conn( ic->irc, ic );
+ //query_del_by_conn( ic->irc, ic );
- for( a = irc->accounts; a; a = a->next )
+ for( a = bee->accounts; a; a = a->next )
if( a->ic == ic )
break;
@@ -359,7 +344,7 @@ 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" ) &&
+ else if( allow_reconnect && set_getbool( &bee->set, "auto_reconnect" ) &&
set_getbool( &a->set, "auto_reconnect" ) &&
( delay = account_reconnect_delay( a ) ) > 0 )
{
@@ -370,27 +355,20 @@ void imc_logout( struct im_connection *ic, int allow_reconnect )
imc_free( ic );
}
-
-/* dialogs.c */
-
void imcb_ask( struct im_connection *ic, char *msg, void *data,
query_callback doit, query_callback dont )
{
- query_add( ic->irc, ic, msg, doit, dont, data );
+ //query_add( ic->irc, ic, msg, doit, dont, data );
}
-
-/* list.c */
-
void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *group )
{
- user_t *u;
- char nick[MAX_NICK_LENGTH+1], *s;
- irc_t *irc = ic->irc;
+ bee_user_t *bu;
+ bee_t *bee = ic->bee;
- if( user_findhandle( ic, handle ) )
+ if( bee_user_by_handle( bee, ic, handle ) )
{
- if( set_getbool( &irc->set, "debug" ) )
+ if( set_getbool( &bee->set, "debug" ) )
imcb_log( ic, "User already exists, ignoring add request: %s", handle );
return;
@@ -401,108 +379,37 @@ void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *g
even support groups so let's silently ignore this for now. */
}
- memset( nick, 0, MAX_NICK_LENGTH + 1 );
- strcpy( nick, nick_get( ic->acc, handle ) );
-
- u = user_add( ic->irc, nick );
-
-// if( !realname || !*realname ) realname = nick;
-// u->realname = g_strdup( realname );
-
- if( ( s = strchr( handle, '@' ) ) )
- {
- u->host = g_strdup( s + 1 );
- u->user = g_strndup( handle, s - handle );
- }
- else if( ic->acc->server )
- {
- u->host = g_strdup( ic->acc->server );
- u->user = g_strdup( handle );
-
- /* s/ /_/ ... important for AOL screennames */
- for( s = u->user; *s; s ++ )
- if( *s == ' ' )
- *s = '_';
- }
- else
- {
- u->host = g_strdup( ic->acc->prpl->name );
- u->user = g_strdup( handle );
- }
-
- u->ic = ic;
- u->handle = g_strdup( handle );
- if( group ) u->group = g_strdup( group );
- u->send_handler = buddy_send_handler;
- u->last_typing_notice = 0;
+ bu = bee_user_new( bee, ic, handle );
+ bu->group = g_strdup( group );
}
-struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle )
+void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *fullname )
{
- static struct buddy b[1];
- user_t *u;
-
- u = user_findhandle( ic, handle );
-
- if( !u )
- return( NULL );
+ bee_t *bee = ic->bee;
+ bee_user_t *bu = bee_user_by_handle( bee, ic, handle );
- memset( b, 0, sizeof( b ) );
- strncpy( b->name, handle, 80 );
- strncpy( b->show, u->realname, BUDDY_ALIAS_MAXLEN );
- b->present = u->online;
- b->ic = u->ic;
+ if( !bu || !fullname ) return;
- return( b );
-}
-
-void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname )
-{
- user_t *u = user_findhandle( ic, handle );
- char *set;
-
- if( !u || !realname ) return;
-
- if( g_strcasecmp( u->realname, realname ) != 0 )
+ if( !bu->fullname || strcmp( bu->fullname, fullname ) != 0 )
{
- if( u->realname != u->nick ) g_free( u->realname );
-
- u->realname = g_strdup( realname );
+ g_free( bu->fullname );
+ bu->fullname = g_strdup( fullname );
- if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) )
- imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname );
- }
-
- set = set_getstr( &ic->acc->set, "nick_source" );
- if( strcmp( set, "handle" ) != 0 )
- {
- char *name = g_strdup( realname );
-
- if( strcmp( set, "first_name" ) == 0 )
- {
- int i;
- for( i = 0; name[i] && !isspace( name[i] ); i ++ ) {}
- name[i] = '\0';
- }
-
- imcb_buddy_nick_hint( ic, handle, name );
-
- g_free( name );
+ if( bee->ui->user_fullname )
+ bee->ui->user_fullname( bee, bu );
}
}
void imcb_remove_buddy( struct im_connection *ic, const char *handle, char *group )
{
- user_t *u;
-
- if( ( u = user_findhandle( ic, handle ) ) )
- user_del( ic->irc, u->nick );
+ bee_user_free( ic->bee, ic, handle );
}
/* Mainly meant for ICQ (and now also for Jabber conferences) to allow IM
modules to suggest a nickname for a handle. */
void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick )
{
+#if 0
user_t *u = user_findhandle( ic, handle );
char newnick[MAX_NICK_LENGTH+1], *orig_nick;
@@ -517,7 +424,7 @@ void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const c
/* Some processing to make sure this string is a valid IRC nickname. */
nick_strip( newnick );
- if( set_getbool( &ic->irc->set, "lcnicks" ) )
+ if( set_getbool( &ic->bee->set, "lcnicks" ) )
nick_lc( newnick );
if( strcmp( u->nick, newnick ) != 0 )
@@ -534,6 +441,7 @@ void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const c
g_free( orig_nick );
}
}
+#endif
}
@@ -543,6 +451,7 @@ struct imcb_ask_cb_data
char *handle;
};
+#if 0
static void imcb_ask_auth_cb_no( void *data )
{
struct imcb_ask_cb_data *cbd = data;
@@ -562,9 +471,11 @@ static void imcb_ask_auth_cb_yes( void *data )
g_free( cbd->handle );
g_free( cbd );
}
+#endif
void imcb_ask_auth( struct im_connection *ic, const char *handle, const char *realname )
{
+#if 0
struct imcb_ask_cb_data *data = g_new0( struct imcb_ask_cb_data, 1 );
char *s, *realname_ = NULL;
@@ -579,9 +490,11 @@ void imcb_ask_auth( struct im_connection *ic, const char *handle, const char *re
data->ic = ic;
data->handle = g_strdup( handle );
query_add( ic->irc, ic, s, imcb_ask_auth_cb_yes, imcb_ask_auth_cb_no, data );
+#endif
}
+#if 0
static void imcb_ask_add_cb_no( void *data )
{
g_free( ((struct imcb_ask_cb_data*)data)->handle );
@@ -596,9 +509,11 @@ static void imcb_ask_add_cb_yes( void *data )
return imcb_ask_add_cb_no( data );
}
+#endif
void imcb_ask_add( struct im_connection *ic, const char *handle, const char *realname )
{
+#if 0
struct imcb_ask_cb_data *data = g_new0( struct imcb_ask_cb_data, 1 );
char *s;
@@ -611,165 +526,15 @@ void imcb_ask_add( struct im_connection *ic, const char *handle, const char *rea
data->ic = ic;
data->handle = g_strdup( handle );
query_add( ic->irc, ic, s, imcb_ask_add_cb_yes, imcb_ask_add_cb_no, data );
-}
-
-
-/* server.c */
-
-void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message )
-{
- user_t *u;
- int oa, oo;
-
- u = user_findhandle( ic, (char*) handle );
-
- if( !u )
- {
- if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 )
- {
- imcb_add_buddy( ic, (char*) handle, NULL );
- u = user_findhandle( ic, (char*) handle );
- }
- else
- {
- if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 )
- {
- imcb_log( ic, "imcb_buddy_status() for unknown handle %s:", handle );
- imcb_log( ic, "flags = %d, state = %s, message = %s", flags,
- state ? state : "NULL", message ? message : "NULL" );
- }
-
- return;
- }
- }
-
- oa = u->away != NULL;
- oo = u->online;
-
- g_free( u->away );
- g_free( u->status_msg );
- u->away = u->status_msg = NULL;
-
- if( ( flags & OPT_LOGGED_IN ) && !u->online )
- {
- irc_spawn( ic->irc, u );
- u->online = 1;
- }
- else if( !( flags & OPT_LOGGED_IN ) && u->online )
- {
- struct groupchat *c;
-
- irc_kill( ic->irc, u );
- u->online = 0;
-
- /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */
- for( c = ic->groupchats; c; c = c->next )
- remove_chat_buddy_silent( c, handle );
- }
-
- if( flags & OPT_AWAY )
- {
- if( state && message )
- {
- u->away = g_strdup_printf( "%s (%s)", state, message );
- }
- else if( state )
- {
- u->away = g_strdup( state );
- }
- else if( message )
- {
- u->away = g_strdup( message );
- }
- else
- {
- u->away = g_strdup( "Away" );
- }
- }
- else
- {
- u->status_msg = g_strdup( message );
- }
-
- /* LISPy... */
- if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */
- ( u->online ) && /* Don't touch offline people */
- ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */
- ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */
- {
- char *from;
-
- if( set_getbool( &ic->irc->set, "simulate_netsplit" ) )
- {
- from = g_strdup( ic->irc->myhost );
- }
- else
- {
- from = g_strdup_printf( "%s!%s@%s", ic->irc->mynick, ic->irc->mynick,
- ic->irc->myhost );
- }
- irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel,
- u->away?'-':'+', u->nick );
- g_free( from );
- }
-}
-
-void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at )
-{
- irc_t *irc = ic->irc;
- char *wrapped;
- user_t *u;
-
- u = user_findhandle( ic, handle );
-
- if( !u )
- {
- char *h = set_getstr( &irc->set, "handle_unknown" );
-
- if( g_strcasecmp( h, "ignore" ) == 0 )
- {
- if( set_getbool( &irc->set, "debug" ) )
- imcb_log( ic, "Ignoring message from unknown handle %s", handle );
-
- return;
- }
- else if( g_strncasecmp( h, "add", 3 ) == 0 )
- {
- int private = set_getbool( &irc->set, "private" );
-
- if( h[3] )
- {
- if( g_strcasecmp( h + 3, "_private" ) == 0 )
- private = 1;
- else if( g_strcasecmp( h + 3, "_channel" ) == 0 )
- private = 0;
- }
-
- imcb_add_buddy( ic, handle, NULL );
- u = user_findhandle( ic, handle );
- u->is_private = private;
- }
- else
- {
- imcb_log( ic, "Message from unknown handle %s:", handle );
- u = user_find( irc, irc->mynick );
- }
- }
-
- if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
- ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
- strip_html( msg );
-
- wrapped = word_wrap( msg, 425 );
- irc_msgfrom( irc, u->nick, wrapped );
- g_free( wrapped );
+#endif
}
void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags )
{
+#if 0
user_t *u;
- if( !set_getbool( &ic->irc->set, "typing_notice" ) )
+ if( !set_getbool( &ic->bee->set, "typing_notice" ) )
return;
if( ( u = user_findhandle( ic, handle ) ) )
@@ -779,10 +544,17 @@ void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags )
g_snprintf( buf, 256, "\1TYPING %d\1", ( flags >> 8 ) & 3 );
irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf );
}
+#endif
+}
+
+struct bee_user *imcb_buddy_by_handle( struct im_connection *ic, const char *handle )
+{
+ return bee_user_by_handle( ic->bee, ic, handle );
}
struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle )
{
+#if 0
struct groupchat *c;
/* This one just creates the conversation structure, user won't see anything yet */
@@ -800,19 +572,22 @@ struct groupchat *imcb_chat_new( struct im_connection *ic, const char *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" ) )
+ if( set_getbool( &ic->bee->set, "debug" ) )
imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle );
return c;
+#endif
+ return NULL;
}
void imcb_chat_free( struct groupchat *c )
{
+#if 0
struct im_connection *ic = c->ic;
struct groupchat *l;
GList *ir;
- if( set_getbool( &ic->irc->set, "debug" ) )
+ if( set_getbool( &ic->bee->set, "debug" ) )
imcb_log( ic, "You were removed from conversation %p", c );
if( c )
@@ -845,10 +620,12 @@ void imcb_chat_free( struct groupchat *c )
g_free( c->topic );
g_free( c );
}
+#endif
}
void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at )
{
+#if 0
struct im_connection *ic = c->ic;
char *wrapped;
user_t *u;
@@ -859,8 +636,8 @@ void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t fl
u = user_findhandle( ic, who );
- if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
- ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
+ if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||
+ ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )
strip_html( msg );
wrapped = word_wrap( msg, 425 );
@@ -873,10 +650,12 @@ void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t fl
imcb_log( ic, "Message from/to conversation %s@%p (unknown conv/user): %s", who, c, wrapped );
}
g_free( wrapped );
+#endif
}
void imcb_chat_log( struct groupchat *c, char *format, ... )
{
+#if 0
irc_t *irc = c->ic->irc;
va_list params;
char *text;
@@ -891,10 +670,12 @@ void imcb_chat_log( struct groupchat *c, char *format, ... )
irc_privmsg( irc, u, "PRIVMSG", c->channel, "System message: ", text );
g_free( text );
+#endif
}
void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at )
{
+#if 0
struct im_connection *ic = c->ic;
user_t *u = NULL;
@@ -905,8 +686,8 @@ void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at
else
u = user_findhandle( ic, who );
- if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
- ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
+ if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||
+ ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )
strip_html( topic );
g_free( c->topic );
@@ -914,17 +695,16 @@ void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at
if( c->joined && u )
irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic );
+#endif
}
-
-/* buddy_chat.c */
-
void imcb_chat_add_buddy( struct groupchat *b, const char *handle )
{
+#if 0
user_t *u = user_findhandle( b->ic, handle );
int me = 0;
- if( set_getbool( &b->ic->irc->set, "debug" ) )
+ if( set_getbool( &b->ic->bee->set, "debug" ) )
imcb_log( b->ic, "User %s added to conversation %p", handle, b );
/* It might be yourself! */
@@ -951,15 +731,17 @@ void imcb_chat_add_buddy( struct groupchat *b, const char *handle )
irc_join( b->ic->irc, u, b->channel );
b->in_room = g_list_append( b->in_room, g_strdup( handle ) );
}
+#endif
}
/* This function is one BIG hack... :-( EREWRITE */
void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason )
{
+#if 0
user_t *u;
int me = 0;
- if( set_getbool( &b->ic->irc->set, "debug" ) )
+ if( set_getbool( &b->ic->bee->set, "debug" ) )
imcb_log( b->ic, "User %s removed from conversation %p (%s)", handle, b, reason ? reason : "" );
/* It might be yourself! */
@@ -979,8 +761,10 @@ void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char
if( me || ( remove_chat_buddy_silent( b, handle ) && b->joined && u ) )
irc_part( b->ic->irc, u, b->channel );
+#endif
}
+#if 0
static int remove_chat_buddy_silent( struct groupchat *b, const char *handle )
{
GList *i;
@@ -999,12 +783,13 @@ static int remove_chat_buddy_silent( struct groupchat *b, const char *handle )
i = i->next;
}
- return( 0 );
+ return 0;
}
+#endif
/* Misc. BitlBee stuff which shouldn't really be here */
-
+#if 0
char *set_eval_away_devoice( set_t *set, char *value )
{
irc_t *irc = set->data;
@@ -1017,7 +802,7 @@ char *set_eval_away_devoice( set_t *set, char *value )
/* Horror.... */
- if( st != set_getbool( &irc->set, "away_devoice" ) )
+ if( st != set_getbool( &irc->b->set, "away_devoice" ) )
{
char list[80] = "";
user_t *u = irc->users;
@@ -1059,30 +844,13 @@ char *set_eval_away_devoice( set_t *set, char *value )
return value;
}
-
+#endif
/* 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 imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags )
-{
- char *buf = NULL;
- int st;
-
- if( ( ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
- {
- buf = escape_html( msg );
- msg = buf;
- }
-
- st = ic->acc->prpl->buddy_msg( ic, handle, msg, flags );
- g_free( buf );
-
- return st;
-}
-
int imc_chat_msg( struct groupchat *c, char *msg, int flags )
{
char *buf = NULL;
@@ -1106,7 +874,7 @@ int imc_away_send_update( struct im_connection *ic )
char *away, *msg = NULL;
away = set_getstr( &ic->acc->set, "away" ) ?
- : set_getstr( &ic->irc->set, "away" );
+ : set_getstr( &ic->bee->set, "away" );
if( away && *away )
{
GList *m = ic->acc->prpl->away_states( ic );
@@ -1117,7 +885,7 @@ int imc_away_send_update( struct im_connection *ic )
{
away = NULL;
msg = set_getstr( &ic->acc->set, "status" ) ?
- : set_getstr( &ic->irc->set, "status" );
+ : set_getstr( &ic->bee->set, "status" );
}
ic->acc->prpl->set_away( ic, away, msg );
diff --git a/protocols/nogaim.h b/protocols/nogaim.h
index 324a2b46..a93dc5d2 100644
--- a/protocols/nogaim.h
+++ b/protocols/nogaim.h
@@ -1,7 +1,7 @@
/********************************************************************\
* BitlBee -- An IRC to other IM-networks gateway *
* *
- * Copyright 2002-2004 Wilmer van der Gaast and others *
+ * Copyright 2002-2010 Wilmer van der Gaast and others *
\********************************************************************/
/*
@@ -86,7 +86,7 @@ struct im_connection
int evil;
/* BitlBee */
- irc_t *irc;
+ bee_t *bee;
struct groupchat *groupchats;
};
@@ -285,16 +285,8 @@ G_MODULE_EXPORT struct buddy *imcb_find_buddy( struct im_connection *ic, char *h
G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname );
G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick );
-/* Buddy activity */
-/* To manipulate the status of a handle.
- * - flags can be |='d with OPT_* constants. You will need at least:
- * OPT_LOGGED_IN and OPT_AWAY.
- * - 'state' and 'message' can be NULL */
-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, const 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 struct bee_user *imcb_buddy_by_handle( struct im_connection *ic, const char *handle );
G_MODULE_EXPORT void imcb_clean_handle( struct im_connection *ic, char *handle );
/* Groupchats */
@@ -319,7 +311,6 @@ G_MODULE_EXPORT void imcb_chat_free( struct groupchat *c );
/* Actions, or whatever. */
int imc_away_send_update( struct im_connection *ic );
-int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags );
int imc_chat_msg( struct groupchat *c, char *msg, int flags );
void imc_add_allow( struct im_connection *ic, char *handle );
diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c
index e0c32257..a5ca1ac8 100644
--- a/protocols/oscar/oscar.c
+++ b/protocols/oscar/oscar.c
@@ -1189,8 +1189,7 @@ static void gaim_icq_authgrant(void *data_) {
message = 0;
aim_ssi_auth_reply(od->sess, od->conn, uin, 1, "");
// aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHGRANTED, &message);
- if(imcb_find_buddy(data->ic, uin) == NULL)
- imcb_ask_add(data->ic, uin, NULL);
+ imcb_ask_add(data->ic, uin, NULL);
g_free(uin);
g_free(data);
@@ -1951,11 +1950,13 @@ static void oscar_get_info(struct im_connection *g, char *name) {
static void oscar_get_away(struct im_connection *g, char *who) {
struct oscar_data *odata = (struct oscar_data *)g->proto_data;
if (odata->icq) {
+ /** FIXME(wilmer): Hmm, lost the ability to get away msgs here, do we care to get that back?
struct buddy *budlight = imcb_find_buddy(g, who);
if (budlight)
if ((budlight->uc & 0xff80) >> 7)
if (budlight->caps & AIM_CAPS_ICQSERVERRELAY)
aim_send_im_ch2_geticqmessage(odata->sess, who, (budlight->uc & 0xff80) >> 7);
+ */
} else
aim_getinfo(odata->sess, odata->conn, who, AIM_GETINFO_AWAYMESSAGE);
}
@@ -2093,7 +2094,7 @@ static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) {
switch (curitem->type) {
case 0x0000: /* Buddy */
- if ((curitem->name) && (!imcb_find_buddy(ic, nrm))) {
+ if ((curitem->name) && (!imcb_buddy_by_handle(ic, nrm))) {
char *realname = NULL;
if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1))