aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Makefile2
-rw-r--r--protocols/bee.h5
-rw-r--r--protocols/bee_ft.c66
-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.c2
14 files changed, 103 insertions, 28 deletions
diff --git a/protocols/Makefile b/protocols/Makefile
index 4d461088..46c73559 100644
--- a/protocols/Makefile
+++ b/protocols/Makefile
@@ -9,7 +9,7 @@
-include ../Makefile.settings
# [SH] Program variables
-objects = account.o bee.o bee_user.o 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))
diff --git a/protocols/bee.h b/protocols/bee.h
index 61604265..6f896c51 100644
--- a/protocols/bee.h
+++ b/protocols/bee.h
@@ -70,6 +70,11 @@ typedef struct bee_ui_funcs
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;
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/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 58a6c2e4..4896e380 100644
--- a/protocols/jabber/s5bytestream.c
+++ b/protocols/jabber/s5bytestream.c
@@ -565,7 +565,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! */
@@ -602,7 +602,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 );
}
@@ -642,7 +642,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 );
@@ -658,7 +658,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;
}
@@ -704,7 +704,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 );
@@ -1004,7 +1004,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;
}
@@ -1019,7 +1019,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 1e00d5ab..4521eb32 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -390,7 +390,7 @@ void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char
if( !bu || !fullname ) return;
- if( strcmp( bu->fullname, fullname ) != 0 )
+ if( !bu->fullname || strcmp( bu->fullname, fullname ) != 0 )
{
g_free( bu->fullname );
bu->fullname = g_strdup( fullname );