aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/jabber/jabber.c2
-rw-r--r--protocols/msn/msn.c4
-rw-r--r--protocols/msn/sb.c5
-rw-r--r--protocols/oscar/oscar.c1
-rw-r--r--protocols/oscar/rxqueue.c9
-rw-r--r--protocols/oscar/service.c2
-rw-r--r--protocols/ssl_openssl.c86
-rw-r--r--protocols/yahoo/Makefile2
-rw-r--r--protocols/yahoo/yahoo.c17
-rw-r--r--protocols/yahoo/yahoo_list.c236
-rw-r--r--protocols/yahoo/yahoo_list.h68
11 files changed, 58 insertions, 374 deletions
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index d4b5bde5..ba652b8a 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -412,7 +412,7 @@ static void gjab_recv(gjconn gjc)
XML_Parse(gjc->parser, buf, len, 0);
if (jd->die)
signoff(GJ_GC(gjc));
- } else if (len < 0 || errno != EAGAIN) {
+ } else if (len == 0 || (len < 0 && (!sockerr_again() || gjc->ssl))) {
STATE_EVT(JCONN_STATE_OFF)
}
}
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c
index b03c898e..3c7064f8 100644
--- a/protocols/msn/msn.c
+++ b/protocols/msn/msn.c
@@ -83,13 +83,13 @@ static void msn_close( struct gaim_connection *gc )
for( l = md->msgq; l; l = l->next )
{
m = l->data;
+
+ serv_got_crap( gc, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who );
g_free( m->who );
g_free( m->text );
g_free( m );
}
g_slist_free( md->msgq );
-
- serv_got_crap( gc, "Warning: Closing down MSN connection with unsent message(s), you'll have to resend them." );
}
for( l = gc->permit; l; l = l->next )
diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c
index 9e7ef841..deaceba1 100644
--- a/protocols/msn/sb.c
+++ b/protocols/msn/sb.c
@@ -212,13 +212,16 @@ void msn_sb_destroy( struct msn_switchboard *sb )
for( l = sb->msgq; l; l = l->next )
{
m = l->data;
+
g_free( m->who );
g_free( m->text );
g_free( m );
}
g_slist_free( sb->msgq );
- serv_got_crap( gc, "Warning: Closing down MSN switchboard connection with unsent message(s), you'll have to resend them." );
+ serv_got_crap( gc, "Warning: Closing down MSN switchboard connection with "
+ "unsent message to %s, you'll have to resend it.",
+ m->who ? m->who : "(unknown)" );
}
if( sb->chat )
diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c
index b4bfb220..4e552bce 100644
--- a/protocols/oscar/oscar.c
+++ b/protocols/oscar/oscar.c
@@ -607,6 +607,7 @@ static void damn_you(gpointer data, gint source, GaimInputCondition c)
g_free(pos);
return;
}
+ /* [WvG] Wheeeee! Who needs error checking anyway? ;-) */
read(pos->fd, m, 16);
m[16] = '\0';
gaim_input_remove(pos->inpa);
diff --git a/protocols/oscar/rxqueue.c b/protocols/oscar/rxqueue.c
index d8adaa73..6e8dd29c 100644
--- a/protocols/oscar/rxqueue.c
+++ b/protocols/oscar/rxqueue.c
@@ -352,8 +352,15 @@ int aim_get_command(aim_session_t *sess, aim_conn_t *conn)
if (conn->fd == -1)
return -1; /* its a aim_conn_close()'d connection */
- if (conn->fd < 3) /* can happen when people abuse the interface */
+ /* KIDS, THIS IS WHAT HAPPENS IF YOU USE CODE WRITTEN FOR GUIS IN A DAEMON!
+
+ And wouldn't it make sense to return something that prevents this function
+ from being called again IMMEDIATELY (and making the program suck up all
+ CPU time)?...
+
+ if (conn->fd < 3)
return 0;
+ */
if (conn->status & AIM_CONN_STATUS_INPROGRESS)
return aim_conn_completeconnect(sess, conn);
diff --git a/protocols/oscar/service.c b/protocols/oscar/service.c
index 875a2eb0..573e1983 100644
--- a/protocols/oscar/service.c
+++ b/protocols/oscar/service.c
@@ -736,8 +736,6 @@ int aim_setextstatus(aim_session_t *sess, aim_conn_t *conn, guint32 status)
tlvlen = aim_addtlvtochain32(&tl, 0x0006, data);
- printf("%d\n", tlvlen);
-
if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 8)))
return -ENOMEM;
diff --git a/protocols/ssl_openssl.c b/protocols/ssl_openssl.c
index ae55f3f9..e62f95b9 100644
--- a/protocols/ssl_openssl.c
+++ b/protocols/ssl_openssl.c
@@ -4,7 +4,7 @@
* Copyright 2002-2004 Wilmer van der Gaast and others *
\********************************************************************/
-/* SSL module - GnuTLS version */
+/* SSL module - OpenTLS version */
/*
This program is free software; you can redistribute it and/or modify
@@ -40,13 +40,11 @@ static gboolean initialized = FALSE;
struct scd
{
- ssl_input_function func;
+ SslInputFunction func;
gpointer data;
int fd;
gboolean established;
- int inpa;
- int lasterr; /* Necessary for SSL_get_error */
SSL *ssl;
SSL_CTX *ssl_ctx;
};
@@ -55,7 +53,7 @@ static void ssl_connected( gpointer data, gint source, GaimInputCondition cond )
-void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
+void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data )
{
struct scd *conn = g_new0( struct scd, 1 );
SSL_METHOD *meth;
@@ -94,45 +92,19 @@ void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data
return( conn );
}
-static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond );
-
static void ssl_connected( gpointer data, gint source, GaimInputCondition cond )
{
struct scd *conn = data;
if( source == -1 )
- return ssl_handshake( data, -1, cond );
+ goto ssl_connected_failure;
- /* Make it non-blocking at least during the handshake... */
- sock_make_nonblocking( conn->fd );
SSL_set_fd( conn->ssl, conn->fd );
- return ssl_handshake( data, source, cond );
-}
-
-static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond )
-{
- struct scd *conn = data;
- int st;
-
- if( conn->inpa != -1 )
- {
- gaim_input_remove( conn->inpa );
- conn->inpa = -1;
- }
-
- if( ( st = SSL_connect( conn->ssl ) ) < 0 )
- {
- conn->lasterr = SSL_get_error( conn->ssl, st );
- if( conn->lasterr != SSL_ERROR_WANT_READ && conn->lasterr != SSL_ERROR_WANT_WRITE )
- goto ssl_connected_failure;
-
- conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ), ssl_handshake, data );
- return;
- }
+ if( SSL_connect( conn->ssl ) < 0 )
+ goto ssl_connected_failure;
conn->established = TRUE;
- sock_make_blocking( conn->fd ); /* For now... */
conn->func( conn->data, conn, cond );
return;
@@ -154,57 +126,24 @@ ssl_connected_failure:
int ssl_read( void *conn, char *buf, int len )
{
- int st;
-
if( !((struct scd*)conn)->established )
- {
- ssl_errno = SSL_NOHANDSHAKE;
- return -1;
- }
-
- st = SSL_read( ((struct scd*)conn)->ssl, buf, len );
+ return( 0 );
- ssl_errno = SSL_OK;
- if( st <= 0 )
- {
- ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st );
- if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE )
- ssl_errno = SSL_AGAIN;
- }
-
- return st;
+ return( SSL_read( ((struct scd*)conn)->ssl, buf, len ) );
}
int ssl_write( void *conn, const char *buf, int len )
{
- int st;
-
if( !((struct scd*)conn)->established )
- {
- ssl_errno = SSL_NOHANDSHAKE;
- return -1;
- }
-
- st = SSL_write( ((struct scd*)conn)->ssl, buf, len );
+ return( 0 );
- ssl_errno = SSL_OK;
- if( st <= 0 )
- {
- ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st );
- if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE )
- ssl_errno = SSL_AGAIN;
- }
-
- return st;
+ return( SSL_write( ((struct scd*)conn)->ssl, buf, len ) );
}
void ssl_disconnect( void *conn_ )
{
struct scd *conn = conn_;
- if( conn->inpa != -1 )
- gaim_input_remove( conn->inpa );
-
if( conn->established )
SSL_shutdown( conn->ssl );
@@ -219,8 +158,3 @@ int ssl_getfd( void *conn )
{
return( ((struct scd*)conn)->fd );
}
-
-GaimInputCondition ssl_getdirection( void *conn )
-{
- return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? GAIM_INPUT_WRITE : GAIM_INPUT_READ );
-}
diff --git a/protocols/yahoo/Makefile b/protocols/yahoo/Makefile
index e594cc1f..b4014f8a 100644
--- a/protocols/yahoo/Makefile
+++ b/protocols/yahoo/Makefile
@@ -9,7 +9,7 @@
-include ../../Makefile.settings
# [SH] Program variables
-objects = yahoo.o crypt.o libyahoo2.o yahoo_fn.o yahoo_httplib.o yahoo_list.o yahoo_util.o
+objects = yahoo.o crypt.o libyahoo2.o yahoo_fn.o yahoo_httplib.o yahoo_util.o
CFLAGS += -Wall -DSTDC_HEADERS -DHAVE_STRING_H -DHAVE_STRCHR -DHAVE_MEMCPY -DHAVE_GLIB
LFLAGS += -r
diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c
index 832d1ab4..4f257d99 100644
--- a/protocols/yahoo/yahoo.c
+++ b/protocols/yahoo/yahoo.c
@@ -188,18 +188,18 @@ static int byahoo_send_typing( struct gaim_connection *gc, char *who, int typing
static void byahoo_set_away( struct gaim_connection *gc, char *state, char *msg )
{
struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
-
+
gc->away = NULL;
-
- if (msg)
+
+ if( msg )
{
yd->current_status = YAHOO_STATUS_CUSTOM;
gc->away = "";
}
- else if (state)
+ if( state )
{
gc->away = "";
- if( g_strcasecmp(state, "Available" ) == 0 )
+ if( g_strcasecmp( state, "Available" ) == 0 )
{
yd->current_status = YAHOO_STATUS_AVAILABLE;
gc->away = NULL;
@@ -234,12 +234,15 @@ static void byahoo_set_away( struct gaim_connection *gc, char *state, char *msg
gc->away = NULL;
}
}
- else if ( gc->is_idle )
+ else if( gc->is_idle )
yd->current_status = YAHOO_STATUS_IDLE;
else
yd->current_status = YAHOO_STATUS_AVAILABLE;
- yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL );
+ if( yd->current_status == YAHOO_STATUS_INVISIBLE )
+ yahoo_set_away( yd->y2_id, yd->current_status, NULL, gc->away != NULL );
+ else
+ yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL );
}
static GList *byahoo_away_states( struct gaim_connection *gc )
diff --git a/protocols/yahoo/yahoo_list.c b/protocols/yahoo/yahoo_list.c
deleted file mode 100644
index cda631c6..00000000
--- a/protocols/yahoo/yahoo_list.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * yahoo_list.c: linked list routines
- *
- * Some code copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
- * Other code copyright Meredydd Luff <meredydd AT everybuddy.com>
- *
- * 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
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Some of this code was borrowed from elist.c in the eb-lite sources
- *
- */
-
-#include <stdlib.h>
-
-#include "yahoo_list.h"
-
-YList *y_list_append(YList * list, void *data)
-{
- YList *n;
- YList *new_list = malloc(sizeof(YList));
- YList *attach_to = NULL;
-
- new_list->next = NULL;
- new_list->data = data;
-
- for (n = list; n != NULL; n = n->next) {
- attach_to = n;
- }
-
- if (attach_to == NULL) {
- new_list->prev = NULL;
- return new_list;
- } else {
- new_list->prev = attach_to;
- attach_to->next = new_list;
- return list;
- }
-}
-
-YList *y_list_prepend(YList * list, void *data)
-{
- YList *n = malloc(sizeof(YList));
-
- n->next = list;
- n->prev = NULL;
- n->data = data;
- if (list)
- list->prev = n;
-
- return n;
-}
-
-YList *y_list_concat(YList * list, YList * add)
-{
- YList *l;
-
- if(!list)
- return add;
-
- if(!add)
- return list;
-
- for (l = list; l->next; l = l->next)
- ;
-
- l->next = add;
- add->prev = l;
-
- return list;
-}
-
-YList *y_list_remove(YList * list, void *data)
-{
- YList *n;
-
- for (n = list; n != NULL; n = n->next) {
- if (n->data == data) {
- list=y_list_remove_link(list, n);
- y_list_free_1(n);
- break;
- }
- }
-
- return list;
-}
-
-/* Warning */
-/* link MUST be part of list */
-/* caller must free link using y_list_free_1 */
-YList *y_list_remove_link(YList * list, const YList * link)
-{
- if (!link)
- return list;
-
- if (link->next)
- link->next->prev = link->prev;
- if (link->prev)
- link->prev->next = link->next;
-
- if (link == list)
- list = link->next;
-
- return list;
-}
-
-int y_list_length(const YList * list)
-{
- int retval = 0;
- const YList *n = list;
-
- for (n = list; n != NULL; n = n->next) {
- retval++;
- }
-
- return retval;
-}
-
-/* well, you could just check for list == NULL, but that would be
- * implementation dependent
- */
-int y_list_empty(const YList * list)
-{
- if(!list)
- return 1;
- else
- return 0;
-}
-
-int y_list_singleton(const YList * list)
-{
- if(!list || list->next)
- return 0;
- return 1;
-}
-
-YList *y_list_copy(YList * list)
-{
- YList *n;
- YList *copy = NULL;
-
- for (n = list; n != NULL; n = n->next) {
- copy = y_list_append(copy, n->data);
- }
-
- return copy;
-}
-
-void y_list_free_1(YList * list)
-{
- free(list);
-}
-
-void y_list_free(YList * list)
-{
- YList *n = list;
-
- while (n != NULL) {
- YList *next = n->next;
- free(n);
- n = next;
- }
-}
-
-YList *y_list_find(YList * list, const void *data)
-{
- YList *l;
- for (l = list; l && l->data != data; l = l->next)
- ;
-
- return l;
-}
-
-void y_list_foreach(YList * list, YListFunc fn, void * user_data)
-{
- for (; list; list = list->next)
- fn(list->data, user_data);
-}
-
-YList *y_list_find_custom(YList * list, const void *data, YListCompFunc comp)
-{
- YList *l;
- for (l = list; l; l = l->next)
- if (comp(l->data, data) == 0)
- return l;
-
- return NULL;
-}
-
-YList *y_list_nth(YList * list, int n)
-{
- int i=n;
- for ( ; list && i; list = list->next, i--)
- ;
-
- return list;
-}
-
-YList *y_list_insert_sorted(YList * list, void *data, YListCompFunc comp)
-{
- YList *l, *n, *prev = NULL;
- if (!list)
- return y_list_append(list, data);
-
- n = malloc(sizeof(YList));
- n->data = data;
- for (l = list; l && comp(l->data, n->data) <= 0; l = l->next)
- prev = l;
-
- if (l) {
- n->prev = l->prev;
- l->prev = n;
- } else
- n->prev = prev;
-
- n->next = l;
-
- if(n->prev) {
- n->prev->next = n;
- return list;
- } else {
- return n;
- }
-
-}
diff --git a/protocols/yahoo/yahoo_list.h b/protocols/yahoo/yahoo_list.h
index a7a69635..0d335acd 100644
--- a/protocols/yahoo/yahoo_list.h
+++ b/protocols/yahoo/yahoo_list.h
@@ -20,55 +20,29 @@
*
*/
-/*
- * This is a replacement for the GList. It only provides functions that
- * we use in Ayttm. Thanks to Meredyyd from everybuddy dev for doing
- * most of it.
- */
-
#ifndef __YLIST_H__
#define __YLIST_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct _YList {
- struct _YList *next;
- struct _YList *prev;
- void *data;
-} YList;
-
-typedef int (*YListCompFunc) (const void *, const void *);
-typedef void (*YListFunc) (void *, void *);
-
-YList *y_list_append(YList * list, void *data);
-YList *y_list_prepend(YList * list, void *data);
-YList *y_list_remove_link(YList * list, const YList * link);
-YList *y_list_remove(YList * list, void *data);
-
-YList *y_list_insert_sorted(YList * list, void * data, YListCompFunc comp);
+/* GLib has linked list already, so I don't see why libyahoo2 has to copy this... */
+
+typedef GList YList;
+
+#define y_list_append g_list_append
+#define y_list_concat g_list_concat
+#define y_list_copy g_list_copy
+#define y_list_empty g_list_empty
+#define y_list_find g_list_find
+#define y_list_find_custom g_list_find_custom
+#define y_list_foreach g_list_foreach
+#define y_list_free g_list_free
+#define y_list_free_1 g_list_free_1
+#define y_list_insert_sorted g_list_insert_sorted
+#define y_list_length g_list_length
+#define y_list_next g_list_next
+#define y_list_nth g_list_nth
+#define y_list_prepend g_list_prepend
+#define y_list_remove g_list_remove
+#define y_list_remove_link g_list_remove_link
+#define y_list_singleton g_list_singleton
-YList *y_list_copy(YList * list);
-
-YList *y_list_concat(YList * list, YList * add);
-
-YList *y_list_find(YList * list, const void *data);
-YList *y_list_find_custom(YList * list, const void *data, YListCompFunc comp);
-
-YList *y_list_nth(YList * list, int n);
-
-void y_list_foreach(YList * list, YListFunc fn, void *user_data);
-
-void y_list_free_1(YList * list);
-void y_list_free(YList * list);
-int y_list_length(const YList * list);
-int y_list_empty(const YList * list);
-int y_list_singleton(const YList * list);
-
-#define y_list_next(list) list->next
-
-#ifdef __cplusplus
-}
-#endif
#endif