diff options
author | VMiklos <vmiklos@frugalware.org> | 2007-08-20 18:35:48 +0200 |
---|---|---|
committer | VMiklos <vmiklos@frugalware.org> | 2007-08-20 18:35:48 +0200 |
commit | ed2e37f5b8f597fdd8e4e0a9cafb943d23e5469c (patch) | |
tree | f62092587a872f795258aa6d045896b002f99897 | |
parent | ba20c3903ee5c47e5fb83fc17a13e5f5ed319372 (diff) |
more error handling, no more SIGPIPE \o/ :)
-rw-r--r-- | skype/README | 8 | ||||
-rw-r--r-- | skype/skype.c | 15 |
2 files changed, 14 insertions, 9 deletions
diff --git a/skype/README b/skype/README index d4bf24f8..5cfa2020 100644 --- a/skype/README +++ b/skype/README @@ -32,7 +32,7 @@ git clone http://ftp.frugalware.org/pub/other/people/vmiklos/bitlbee-skype make cp skype.so /usr/lib/bitlbee -- Start the tcp server: +- Start skyped (the tcp server): python skyped.py @@ -47,7 +47,9 @@ What works: - Receiving messages -- Writing a tcp daemon that is a gateway between Skype and tcp +- skyped (the tcp daemon that is a gateway between Skype and tcp) + +- Error handling when skyped is not running and when it exists What needs to be done (aka. TODO): @@ -65,8 +67,6 @@ What needs to be done (aka. TODO): - maybe on account on/off, change our state from/to offline? so that we won't miss any message -- handle the case when the tcp server is not running (currently SIGPIPE is not handled at all by the plugin) - If something does not work and it's not in the TODO section, then please contact me! Shots at: diff --git a/skype/skype.c b/skype/skype.c index c553ea2a..3dc96719 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -6,6 +6,7 @@ * cp example.so /usr/local/lib/bitlbee */ #include <stdio.h> +#include <poll.h> #include <bitlbee.h> #define SKYPE_PORT_DEFAULT "2727" @@ -58,8 +59,6 @@ int skype_write( struct im_connection *ic, char *buf, int len ) printf("write(): %s", buf); write( sd->fd, buf, len ); - // TODO: error handling - return TRUE; } @@ -146,7 +145,8 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c info += 5; // new body printf("<%s> %s\n", sd->handle, info); - imcb_buddy_msg(ic, sd->handle, info, 0, 0); + if(sd->handle) + imcb_buddy_msg(ic, sd->handle, info, 0, 0); g_free(sd->handle); sd->handle = NULL; } @@ -190,14 +190,19 @@ gboolean skype_connected( gpointer data, gint source, b_input_condition cond ) { struct im_connection *ic = data; struct skype_data *sd = ic->proto_data; + struct pollfd pfd[1]; - imcb_connected(ic); - if( sd->fd < 0 ) + pfd[0].fd = sd->fd; + pfd[0].events = POLLOUT; + + poll(pfd, 1, 1000); + if(pfd[0].revents & POLLHUP) { imcb_error( ic, "Could not connect to server" ); imc_logout( ic, TRUE ); return FALSE; } + imcb_connected(ic); return skype_start_stream(ic); } |