From f06e3ac0ed0aa7a1b616993512fbd0ed12d01e51 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 19 Aug 2007 15:37:45 +0200 Subject: initial commit --- skype/Makefile | 7 +++ skype/skype.c | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 201 insertions(+) create mode 100644 skype/Makefile create mode 100644 skype/skype.c diff --git a/skype/Makefile b/skype/Makefile new file mode 100644 index 00000000..fe4b7e1d --- /dev/null +++ b/skype/Makefile @@ -0,0 +1,7 @@ +CFLAGS += $(shell pkg-config --cflags bitlbee) -g + +skype.so: skype.c + gcc -o skype.so -shared skype.c $(CFLAGS) + +clean: + rm -f skype.so diff --git a/skype/skype.c b/skype/skype.c new file mode 100644 index 00000000..ff923806 --- /dev/null +++ b/skype/skype.c @@ -0,0 +1,194 @@ +/* + * This is the most simple possible BitlBee plugin. To use, compile it as + * a shared library and place it in the plugin directory: + * + * gcc -o example.so -shared example.c `pkg-config --cflags bitlbee` + * cp example.so /usr/local/lib/bitlbee + */ +#include +#include + +#define SKYPE_PORT_DEFAULT "2727" + +struct skype_data +{ + struct im_connection *ic; + int fd; + char *txq; + int tx_len; + int r_inpa, w_inpa; +}; + +static gboolean skype_write_callback( gpointer data, gint fd, b_input_condition cond ); +static gboolean skype_write_queue( struct im_connection *ic ); + +static void skype_init( account_t *acc ) +{ + set_t *s; + + s = set_add( &acc->set, "port", SKYPE_PORT_DEFAULT, set_eval_int, acc ); + s->flags |= ACC_SET_OFFLINE_ONLY; + + s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); + s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; +} + +int skype_write( struct im_connection *ic, char *buf, int len ) +{ + struct skype_data *sd = ic->proto_data; + gboolean ret; + + if( sd->tx_len == 0 ) + { + sd->tx_len = len; + sd->txq = g_memdup( buf, len ); + if( ( ret = skype_write_queue( ic ) ) && sd->tx_len > 0 ) + sd->w_inpa = b_input_add( sd->fd, GAIM_INPUT_WRITE, skype_write_callback, ic ); + } + else + { + sd->txq = g_renew( char, sd->txq, sd->tx_len + len ); + memcpy( sd->txq + sd->tx_len, buf, len ); + sd->tx_len += len; + ret = TRUE; + } + return ret; +} + +static gboolean skype_write_callback( gpointer data, gint fd, b_input_condition cond ) +{ + struct skype_data *sd = ((struct im_connection *)data)->proto_data; + + return sd->fd != -1 && + skype_write_queue( data ) && + sd->tx_len > 0; +} + +static gboolean skype_write_queue( struct im_connection *ic ) +{ + struct skype_data *sd = ic->proto_data; + int st; + + st = write( sd->fd, sd->txq, sd->tx_len ); + + if( st == sd->tx_len ) + { + /* We wrote everything, clear the buffer. */ + g_free( sd->txq ); + sd->txq = NULL; + sd->tx_len = 0; + + return TRUE; + } + else if( st == 0 || ( st < 0 && !sockerr_again() ) ) + { + /* Set fd to -1 to make sure we won't write to it anymore. */ + closesocket( sd->fd ); /* Shouldn't be necessary after errors? */ + sd->fd = -1; + + imcb_error( ic, "Short write() to server" ); + imc_logout( ic, TRUE ); + return FALSE; + } + else if( st > 0 ) + { + char *s; + + s = g_memdup( sd->txq + st, sd->tx_len - st ); + sd->tx_len -= st; + g_free( sd->txq ); + sd->txq = s; + + return TRUE; + } + else + { + return TRUE; + } +} + +gboolean skype_start_stream( struct im_connection *ic ) +{ + char *buf; + int st; + + buf = g_strdup_printf("SEARCH FRIENDS"); + st = skype_write( ic, buf, strlen( buf ) ); + g_free(buf); + return st; +} + +gboolean skype_connected( gpointer data, gint source, b_input_condition cond ) +{ + struct im_connection *ic = data; + + imcb_connected(ic); + //imcb_add_buddy(ic, "vmiklos_dsd@skype.com", NULL); + //imcb_buddy_status(ic, "vmiklos_dsd@skype.com", OPT_LOGGED_IN, NULL, NULL); + return skype_start_stream(ic); +} + +static void skype_login( account_t *acc ) +{ + struct im_connection *ic = imcb_new( acc ); + struct skype_data *sd = g_new0( struct skype_data, 1 ); + + ic->proto_data = sd; + + imcb_log( ic, "Connecting" ); + printf("%s:%d\n", acc->server, set_getint( &acc->set, "port")); + sd->fd = proxy_connect(acc->server, set_getint( &acc->set, "port" ), skype_connected, ic ); + printf("sd->fd: %d\n", sd->fd); + if( sd->fd < 0 ) + { + imcb_error( ic, "Could not connect to server" ); + imc_logout( ic, TRUE ); + return; + } + + sd->ic = ic; +} + +static void skype_logout( struct im_connection *ic ) +{ + struct skype_data *sd = ic->proto_data; + g_free(sd); +} + +static void skype_set_away( struct im_connection *ic, char *state_txt, char *message ) +{ +} + +static GList *skype_away_states( struct im_connection *ic ) +{ + static GList *l = NULL; + int i; + + l = g_list_append( l, (void*)"Online" ); + return l; +} + +static void skype_add_buddy( struct im_connection *ic, char *who, char *group ) +{ +} + +static void skype_remove_buddy( struct im_connection *ic, char *who, char *group ) +{ +} + +void init_plugin(void) +{ + struct prpl *ret = g_new0( struct prpl, 1 ); + + ret->name = "skype"; + ret->login = skype_login; + ret->init = skype_init; + ret->logout = skype_logout; + ret->away_states = skype_away_states; + ret->add_buddy = skype_add_buddy; + ret->remove_buddy = skype_remove_buddy; + ret->away_states = skype_away_states; + ret->set_away = skype_set_away; + ret->handle_cmp = g_strcasecmp; + register_protocol( ret ); +} -- cgit v1.2.3 From 1323e363b90f525313178a3451d308817bc3f292 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 19 Aug 2007 15:57:32 +0200 Subject: basic read functions --- skype/skype.c | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index ff923806..6bc216cb 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -64,11 +64,41 @@ static gboolean skype_write_callback( gpointer data, gint fd, b_input_condition sd->tx_len > 0; } +static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition cond ) +{ + struct im_connection *ic = data; + struct skype_data *sd = ic->proto_data; + char buf[1024]; + int st; + + if( sd->fd == -1 ) + return FALSE; + st = read( sd->fd, buf, sizeof( buf ) ); + if( st > 0 ) + { + buf[st] = '\0'; + printf("read(): '%s'\n", buf); + } + else if( st == 0 || ( st < 0 && !sockerr_again() ) ) + { + closesocket( sd->fd ); + sd->fd = -1; + + imcb_error( ic, "Error while reading from server" ); + imc_logout( ic, TRUE ); + return FALSE; + } + + /* EAGAIN/etc or a successful read. */ + return TRUE; +} + static gboolean skype_write_queue( struct im_connection *ic ) { struct skype_data *sd = ic->proto_data; int st; + printf("sd->fd: %d\n", sd->fd); st = write( sd->fd, sd->txq, sd->tx_len ); if( st == sd->tx_len ) @@ -109,9 +139,13 @@ static gboolean skype_write_queue( struct im_connection *ic ) gboolean skype_start_stream( struct im_connection *ic ) { + struct skype_data *sd = ic->proto_data; char *buf; int st; + if( sd->r_inpa <= 0 ) + sd->r_inpa = b_input_add( sd->fd, GAIM_INPUT_READ, skype_read_callback, ic ); + buf = g_strdup_printf("SEARCH FRIENDS"); st = skype_write( ic, buf, strlen( buf ) ); g_free(buf); @@ -121,8 +155,15 @@ gboolean skype_start_stream( struct im_connection *ic ) gboolean skype_connected( gpointer data, gint source, b_input_condition cond ) { struct im_connection *ic = data; + struct skype_data *sd = ic->proto_data; imcb_connected(ic); + if( sd->fd < 0 ) + { + imcb_error( ic, "Could not connect to server" ); + imc_logout( ic, TRUE ); + return; + } //imcb_add_buddy(ic, "vmiklos_dsd@skype.com", NULL); //imcb_buddy_status(ic, "vmiklos_dsd@skype.com", OPT_LOGGED_IN, NULL, NULL); return skype_start_stream(ic); @@ -139,12 +180,6 @@ static void skype_login( account_t *acc ) printf("%s:%d\n", acc->server, set_getint( &acc->set, "port")); sd->fd = proxy_connect(acc->server, set_getint( &acc->set, "port" ), skype_connected, ic ); printf("sd->fd: %d\n", sd->fd); - if( sd->fd < 0 ) - { - imcb_error( ic, "Could not connect to server" ); - imc_logout( ic, TRUE ); - return; - } sd->ic = ic; } -- cgit v1.2.3 From 9fd42411191bb42e51c14c24d454c1855f0b4885 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 19 Aug 2007 17:43:14 +0200 Subject: download buddies from the server also remove write queues. i took them from the jabber module and they seem to be a bit unnecessary for skype --- skype/Makefile | 3 +- skype/skype.c | 121 ++++++++++++++++++++++----------------------------------- 2 files changed, 48 insertions(+), 76 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index fe4b7e1d..8733bcba 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,4 +1,5 @@ -CFLAGS += $(shell pkg-config --cflags bitlbee) -g +CFLAGS += $(shell pkg-config --cflags bitlbee) -g -Wall +LDFLAGS += $(shell pkg-config --libs bitlbee) skype.so: skype.c gcc -o skype.so -shared skype.c $(CFLAGS) diff --git a/skype/skype.c b/skype/skype.c index 6bc216cb..582614ae 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -19,9 +19,6 @@ struct skype_data int r_inpa, w_inpa; }; -static gboolean skype_write_callback( gpointer data, gint fd, b_input_condition cond ); -static gboolean skype_write_queue( struct im_connection *ic ); - static void skype_init( account_t *acc ) { set_t *s; @@ -36,32 +33,13 @@ static void skype_init( account_t *acc ) int skype_write( struct im_connection *ic, char *buf, int len ) { struct skype_data *sd = ic->proto_data; - gboolean ret; - if( sd->tx_len == 0 ) - { - sd->tx_len = len; - sd->txq = g_memdup( buf, len ); - if( ( ret = skype_write_queue( ic ) ) && sd->tx_len > 0 ) - sd->w_inpa = b_input_add( sd->fd, GAIM_INPUT_WRITE, skype_write_callback, ic ); - } - else - { - sd->txq = g_renew( char, sd->txq, sd->tx_len + len ); - memcpy( sd->txq + sd->tx_len, buf, len ); - sd->tx_len += len; - ret = TRUE; - } - return ret; -} + printf("write(): %s", buf); + write( sd->fd, buf, len ); -static gboolean skype_write_callback( gpointer data, gint fd, b_input_condition cond ) -{ - struct skype_data *sd = ((struct im_connection *)data)->proto_data; + // TODO: error handling - return sd->fd != -1 && - skype_write_queue( data ) && - sd->tx_len > 0; + return TRUE; } static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition cond ) @@ -70,6 +48,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c struct skype_data *sd = ic->proto_data; char buf[1024]; int st; + char **lines, **lineptr, *line, *ptr; if( sd->fd == -1 ) return FALSE; @@ -78,6 +57,44 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { buf[st] = '\0'; printf("read(): '%s'\n", buf); + lines = g_strsplit(buf, "\n", 0); + lineptr = lines; + while((line = *lineptr)) + { + if(!strlen(line)) + break; + printf("skype_read_callback() new line: '%s'\n", line); + if(!strncmp(line, "USERS ", 6)) + { + char **i; + char **nicks; + + nicks = g_strsplit(line + 6, ", ", 0); + i = nicks; + while(*i) + { + g_snprintf(buf, 1024, "GET USER %s ONLINESTATUS\n", *i); + skype_write( ic, buf, strlen( buf ) ); + i++; + } + g_strfreev(nicks); + } + else if(!strncmp(line, "USER ", 5)) + { + // TODO we should add the buddy even if the status is offline + if((ptr = strrchr(line, ' ')) && strcmp(++ptr, "OFFLINE") != 0) + { + char *user = strchr(line, ' '); + ptr = strchr(++user, ' '); + *ptr = '\0'; + ptr = g_strdup_printf("%s@skype.com", user); + imcb_add_buddy(ic, ptr, NULL); + imcb_buddy_status(ic, ptr, OPT_LOGGED_IN, NULL, NULL); + } + } + lineptr++; + } + g_strfreev(lines); } else if( st == 0 || ( st < 0 && !sockerr_again() ) ) { @@ -93,50 +110,6 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c return TRUE; } -static gboolean skype_write_queue( struct im_connection *ic ) -{ - struct skype_data *sd = ic->proto_data; - int st; - - printf("sd->fd: %d\n", sd->fd); - st = write( sd->fd, sd->txq, sd->tx_len ); - - if( st == sd->tx_len ) - { - /* We wrote everything, clear the buffer. */ - g_free( sd->txq ); - sd->txq = NULL; - sd->tx_len = 0; - - return TRUE; - } - else if( st == 0 || ( st < 0 && !sockerr_again() ) ) - { - /* Set fd to -1 to make sure we won't write to it anymore. */ - closesocket( sd->fd ); /* Shouldn't be necessary after errors? */ - sd->fd = -1; - - imcb_error( ic, "Short write() to server" ); - imc_logout( ic, TRUE ); - return FALSE; - } - else if( st > 0 ) - { - char *s; - - s = g_memdup( sd->txq + st, sd->tx_len - st ); - sd->tx_len -= st; - g_free( sd->txq ); - sd->txq = s; - - return TRUE; - } - else - { - return TRUE; - } -} - gboolean skype_start_stream( struct im_connection *ic ) { struct skype_data *sd = ic->proto_data; @@ -146,7 +119,8 @@ gboolean skype_start_stream( struct im_connection *ic ) if( sd->r_inpa <= 0 ) sd->r_inpa = b_input_add( sd->fd, GAIM_INPUT_READ, skype_read_callback, ic ); - buf = g_strdup_printf("SEARCH FRIENDS"); + // download buddies + buf = g_strdup_printf("SEARCH FRIENDS\n"); st = skype_write( ic, buf, strlen( buf ) ); g_free(buf); return st; @@ -162,10 +136,8 @@ gboolean skype_connected( gpointer data, gint source, b_input_condition cond ) { imcb_error( ic, "Could not connect to server" ); imc_logout( ic, TRUE ); - return; + return FALSE; } - //imcb_add_buddy(ic, "vmiklos_dsd@skype.com", NULL); - //imcb_buddy_status(ic, "vmiklos_dsd@skype.com", OPT_LOGGED_IN, NULL, NULL); return skype_start_stream(ic); } @@ -197,7 +169,6 @@ static void skype_set_away( struct im_connection *ic, char *state_txt, char *mes static GList *skype_away_states( struct im_connection *ic ) { static GList *l = NULL; - int i; l = g_list_append( l, (void*)"Online" ); return l; -- cgit v1.2.3 From be975f86a1b9ab4e41dacad0f6ef5f87edb988ed Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 19 Aug 2007 17:50:22 +0200 Subject: add offline users, too --- skype/skype.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 582614ae..978ceec8 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -81,16 +81,16 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } else if(!strncmp(line, "USER ", 5)) { - // TODO we should add the buddy even if the status is offline - if((ptr = strrchr(line, ' ')) && strcmp(++ptr, "OFFLINE") != 0) - { - char *user = strchr(line, ' '); - ptr = strchr(++user, ' '); - *ptr = '\0'; - ptr = g_strdup_printf("%s@skype.com", user); - imcb_add_buddy(ic, ptr, NULL); + char *status = strrchr(line, ' '); + char *user = strchr(line, ' '); + ptr = strchr(++user, ' '); + *ptr = '\0'; + ptr = g_strdup_printf("%s@skype.com", user); + imcb_add_buddy(ic, ptr, NULL); + // TODO online can be away + if(strcmp(++status, "OFFLINE") != 0) imcb_buddy_status(ic, ptr, OPT_LOGGED_IN, NULL, NULL); - } + g_free(ptr); } lineptr++; } -- cgit v1.2.3 From b6d26acc1e93fec056431788c931e0a452797cf2 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 19 Aug 2007 17:52:55 +0200 Subject: README: add --- skype/README | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 skype/README diff --git a/skype/README b/skype/README new file mode 100644 index 00000000..4fb99b2f --- /dev/null +++ b/skype/README @@ -0,0 +1,15 @@ +What works: + +- Download buddies from Skype + +What needs to be done: + +- Away statuses (now OFFLINE = Offline, anything else is Online) + +- join / parts + +- msg sending + +- msg receiving + +- status change (send / receive) -- cgit v1.2.3 From ddd35025c4b309c9748a4e2a8b13e44a2cecfb46 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 19 Aug 2007 17:54:24 +0200 Subject: README: add link --- skype/README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skype/README b/skype/README index 4fb99b2f..557bf4b5 100644 --- a/skype/README +++ b/skype/README @@ -13,3 +13,7 @@ What needs to be done: - msg receiving - status change (send / receive) + +Shots at: + +http://frugalware.org/~vmiklos/pics/shots/bitlbee-skype/ -- cgit v1.2.3 From adce2deb210d46b6c7a0deeaf81ff16765d97f64 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 19 Aug 2007 19:35:34 +0200 Subject: download away statuses --- skype/README | 4 ++-- skype/skype.c | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/skype/README b/skype/README index 557bf4b5..20fa7b46 100644 --- a/skype/README +++ b/skype/README @@ -1,10 +1,10 @@ What works: -- Download buddies from Skype +- Download nicks and away statuses from Skype What needs to be done: -- Away statuses (now OFFLINE = Offline, anything else is Online) +- Away status changes - join / parts diff --git a/skype/skype.c b/skype/skype.c index 978ceec8..a15916e9 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -19,6 +19,23 @@ struct skype_data int r_inpa, w_inpa; }; +struct skype_away_state +{ + char *code; + char *full_name; +}; + +const struct skype_away_state skype_away_state_list[] = +{ + { "ONLINE", "Online" }, + { "SKYPEME", "Skype Me" }, + { "AWAY", "Away" }, + { "NA", "Not available" }, + { "DND", "Do Not Disturb" }, + { "INVISIBLE", "Invisible" }, + { "OFFLINE", "Offline" } +}; + static void skype_init( account_t *acc ) { set_t *s; @@ -81,15 +98,20 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } else if(!strncmp(line, "USER ", 5)) { + int flags = 0; char *status = strrchr(line, ' '); char *user = strchr(line, ' '); + status++; ptr = strchr(++user, ' '); *ptr = '\0'; ptr = g_strdup_printf("%s@skype.com", user); imcb_add_buddy(ic, ptr, NULL); // TODO online can be away - if(strcmp(++status, "OFFLINE") != 0) - imcb_buddy_status(ic, ptr, OPT_LOGGED_IN, NULL, NULL); + if(strcmp(status, "OFFLINE") != 0) + flags |= OPT_LOGGED_IN; + if(strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0) + flags |= OPT_AWAY; + imcb_buddy_status(ic, ptr, flags, NULL, NULL); g_free(ptr); } lineptr++; @@ -169,8 +191,12 @@ static void skype_set_away( struct im_connection *ic, char *state_txt, char *mes static GList *skype_away_states( struct im_connection *ic ) { static GList *l = NULL; - - l = g_list_append( l, (void*)"Online" ); + int i; + + if( l == NULL ) + for( i = 0; skype_away_state_list[i].full_name; i ++ ) + l = g_list_append( l, (void*) skype_away_state_list[i].full_name ); + return l; } -- cgit v1.2.3 From 592f824863a8f3e46d776c104c3f55167d6744fb Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 19 Aug 2007 19:39:37 +0200 Subject: README: cleanup --- skype/README | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/skype/README b/skype/README index 20fa7b46..ffda8fa2 100644 --- a/skype/README +++ b/skype/README @@ -4,7 +4,7 @@ What works: What needs to be done: -- Away status changes +- Away status changes (send / receive) - join / parts @@ -12,8 +12,6 @@ What needs to be done: - msg receiving -- status change (send / receive) - Shots at: http://frugalware.org/~vmiklos/pics/shots/bitlbee-skype/ -- cgit v1.2.3 From 93ece6639942c625cedd5a4f6df63a59730c5187 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 03:49:06 +0200 Subject: implement skype_buddy_msg() --- skype/README | 6 ++++-- skype/skype.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index ffda8fa2..0db9b7e7 100644 --- a/skype/README +++ b/skype/README @@ -2,16 +2,18 @@ What works: - Download nicks and away statuses from Skype +- Sending messages + What needs to be done: - Away status changes (send / receive) - join / parts -- msg sending - - msg receiving +- add/remove users, detect when somebody wants to add us (maybe detect when we're removed?) + Shots at: http://frugalware.org/~vmiklos/pics/shots/bitlbee-skype/ diff --git a/skype/skype.c b/skype/skype.c index a15916e9..dcbda0ae 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -184,6 +184,21 @@ static void skype_logout( struct im_connection *ic ) g_free(sd); } +static int skype_buddy_msg( struct im_connection *ic, char *who, char *message, int flags ) +{ + char *buf, *ptr; + int st; + + ptr = strchr(who, '@'); + *ptr = '\0'; + + buf = g_strdup_printf("MESSAGE %s %s\n", who, message); + st = skype_write( ic, buf, strlen( buf ) ); + g_free(buf); + + return st; +} + static void skype_set_away( struct im_connection *ic, char *state_txt, char *message ) { } @@ -216,6 +231,7 @@ void init_plugin(void) ret->login = skype_login; ret->init = skype_init; ret->logout = skype_logout; + ret->buddy_msg = skype_buddy_msg; ret->away_states = skype_away_states; ret->add_buddy = skype_add_buddy; ret->remove_buddy = skype_remove_buddy; -- cgit v1.2.3 From 0bb1b7ffcbcb6cc82d7dc4fe1c7661e59218a312 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 03:50:57 +0200 Subject: skype_buddy_msg(): add a missing check --- skype/skype.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index dcbda0ae..a81699f5 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -190,7 +190,8 @@ static int skype_buddy_msg( struct im_connection *ic, char *who, char *message, int st; ptr = strchr(who, '@'); - *ptr = '\0'; + if(ptr) + *ptr = '\0'; buf = g_strdup_printf("MESSAGE %s %s\n", who, message); st = skype_write( ic, buf, strlen( buf ) ); -- cgit v1.2.3 From 77c1abe6e810e3c9ba19181bb4866bcbb7fea6b7 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 06:05:51 +0200 Subject: support receiving messages --- skype/skype.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index a81699f5..c553ea2a 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -17,6 +17,10 @@ struct skype_data char *txq; int tx_len; int r_inpa, w_inpa; + // when we receive a new message id, we query the handle, then the body + // store the handle here + // TODO: it would be nicer to use a hashmap for this or something + char *handle; }; struct skype_away_state @@ -106,7 +110,6 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c *ptr = '\0'; ptr = g_strdup_printf("%s@skype.com", user); imcb_add_buddy(ic, ptr, NULL); - // TODO online can be away if(strcmp(status, "OFFLINE") != 0) flags |= OPT_LOGGED_IN; if(strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0) @@ -114,6 +117,41 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c imcb_buddy_status(ic, ptr, flags, NULL, NULL); g_free(ptr); } + else if(!strncmp(line, "CHATMESSAGE ", 12)) + { + char *id = strchr(line, ' '); + if(++id) + { + char *info = strchr(id, ' '); + *info = '\0'; + info++; + if(!strcmp(info, "STATUS RECEIVED")) + { + // new message, request its body + printf("new received message #%s\n", id); + g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id); + skype_write( ic, buf, strlen( buf ) ); + g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); + skype_write( ic, buf, strlen( buf ) ); + } + else if(!strncmp(info, "FROM_HANDLE ", 12)) + { + info += 12; + // new handle + sd->handle = g_strdup_printf("%s@skype.com", info); + printf("new handle: '%s'\n", info); + } + else if(!strncmp(info, "BODY ", 5)) + { + info += 5; + // new body + printf("<%s> %s\n", sd->handle, info); + imcb_buddy_msg(ic, sd->handle, info, 0, 0); + g_free(sd->handle); + sd->handle = NULL; + } + } + } lineptr++; } g_strfreev(lines); @@ -174,6 +212,9 @@ static void skype_login( account_t *acc ) printf("%s:%d\n", acc->server, set_getint( &acc->set, "port")); sd->fd = proxy_connect(acc->server, set_getint( &acc->set, "port" ), skype_connected, ic ); printf("sd->fd: %d\n", sd->fd); + /*imcb_add_buddy(ic, "test@skype.com", NULL); + imcb_buddy_status(ic, "test@skype.com", OPT_LOGGED_IN, NULL, NULL); + imcb_buddy_msg(ic, "test@skype.com", "test from skype plugin", 0, 0);*/ sd->ic = ic; } @@ -186,14 +227,16 @@ static void skype_logout( struct im_connection *ic ) static int skype_buddy_msg( struct im_connection *ic, char *who, char *message, int flags ) { - char *buf, *ptr; + char *buf, *ptr, *nick; int st; - ptr = strchr(who, '@'); + nick = g_strdup_printf("%s", who); + ptr = strchr(nick, '@'); if(ptr) *ptr = '\0'; - buf = g_strdup_printf("MESSAGE %s %s\n", who, message); + buf = g_strdup_printf("MESSAGE %s %s\n", nick, message); + g_free(nick); st = skype_write( ic, buf, strlen( buf ) ); g_free(buf); -- cgit v1.2.3 From 8dd21bbdb92a1d95f54a015c363938630b1766df Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 06:07:16 +0200 Subject: README: update --- skype/README | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index 0db9b7e7..4143cbf4 100644 --- a/skype/README +++ b/skype/README @@ -4,16 +4,20 @@ What works: - Sending messages +- Receiving messages + What needs to be done: +- mark received messages as read so that skype won't say there are unread messages + - Away status changes (send / receive) - join / parts -- msg receiving - - add/remove users, detect when somebody wants to add us (maybe detect when we're removed?) +- maybe on account on/off, change our state from/to offline? so that we won't miss any message + Shots at: http://frugalware.org/~vmiklos/pics/shots/bitlbee-skype/ -- cgit v1.2.3 From afe221f55da1bf9d48fcdc6d6c1c24016aa8f8fe Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 15:53:22 +0200 Subject: README: some more docs, still incomplete --- skype/README | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 4143cbf4..387ae3f9 100644 --- a/skype/README +++ b/skype/README @@ -1,3 +1,41 @@ +Hello, + +This plugin allows you to add Skype support to BitlBee. It's mainly written by +Miklos Vajna . + +How to set it up: + +- You need the BitlBee bzr branch: + +bzr branch http://code.bitlbee.org/bitlbee/ + +- You need to enable plugin support: + +http://frugalware.org/~vmiklos/patches/bitlbee-configure-plugins.patch + +- To be able to do an install-dev: + +http://frugalware.org/~vmiklos/patches/bitlbee-makefile-headers.patch + +- Now compile and install it: + +./configure --prefix=/usr +make +make install install-dev + +- Get the plugin code: + +git clone http://ftp.frugalware.org/pub/other/people/vmiklos/bitlbee-skype + +- Compile and install it: + +make +cp skype.so /usr/lib/bitlbee + +- Set up the tcp server: + +FIXME + What works: - Download nicks and away statuses from Skype @@ -6,7 +44,9 @@ What works: - Receiving messages -What needs to be done: +What needs to be done (aka. TODO): + +- import the daemon code - mark received messages as read so that skype won't say there are unread messages @@ -18,6 +58,10 @@ What needs to be done: - 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: http://frugalware.org/~vmiklos/pics/shots/bitlbee-skype/ -- cgit v1.2.3 From 440665b8879c003948b650218d13964688e419db Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 15:54:26 +0200 Subject: more todo --- skype/README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/README b/skype/README index 387ae3f9..f7d8b758 100644 --- a/skype/README +++ b/skype/README @@ -48,6 +48,8 @@ What needs to be done (aka. TODO): - import the daemon code +- convert this readme to asciidoc + - mark received messages as read so that skype won't say there are unread messages - Away status changes (send / receive) -- cgit v1.2.3 From 712a284ed72edec751d2789c42771974fe61beb6 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 15:57:13 +0200 Subject: and even more --- skype/README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/README b/skype/README index f7d8b758..57fd6359 100644 --- a/skype/README +++ b/skype/README @@ -50,6 +50,8 @@ What needs to be done (aka. TODO): - convert this readme to asciidoc +- we can't ourselves join to &bitlbee (ignore such a message from skype) + - mark received messages as read so that skype won't say there are unread messages - Away status changes (send / receive) -- cgit v1.2.3 From 4ddda13727a4dd7e8f1398e74193541e05f665a8 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 16:01:18 +0200 Subject: bitlbeed: import the code is from http://forum.skype.com/viewtopic.php?t=42640 (NOTE: i don't know how wrote it, i did not remove his name..) i tried to add as less modicications as possible, so it needs a big cleanup --- skype/bitlbeed.py | 286 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 skype/bitlbeed.py diff --git a/skype/bitlbeed.py b/skype/bitlbeed.py new file mode 100644 index 00000000..3460c6bb --- /dev/null +++ b/skype/bitlbeed.py @@ -0,0 +1,286 @@ +#!/usr/bin/env python +""" GPL """ +import sys +import signal +import locale +import time +import dbus +import dbus.service +import dbus.mainloop.glib +import gobject +import socket + + +SKYPE_SERVICE = 'com.Skype.API' +CLIENT_NAME = 'SkypeApiPythonShell' + +USER_PROPS = ('FULLNAME', 'SEX', 'LANGUAGE', 'COUNTRY', 'CITY', 'ABOUT', + 'ISAUTHORIZED', 'BUDDYSTATUS') + + +local_encoding = "latin2" +need_conv = (local_encoding != 'utf-8') + +# well, this is a bit hackish. we store the socket of the last connected client +# here and notify it. maybe later notify all connected clients? +conn = None + +def utf8_decode(utf8_str): + if need_conv: + return utf8_str.decode('utf-8').encode(local_encoding, 'replace') + else: + return utf8_str + +def utf8_encode(local_str): + if need_conv: + return local_str.decode(local_encoding).encode('utf-8') + else: + return local_str + +def ts(): + return time.strftime('[%H:%M:%S]') + + +def sig_handler(signum, frame): + print '### caught signal %d, exiting' % signum + mainloop.quit() + #sys.exit() + + +def excepthook(type, value, traceback): + mainloop.quit() + return sys.__excepthook__(type, value, traceback) + + +def input_handler(fd, io_condition): + #print '### fd=%d cond=%d' % (fd.fileno(), io_condition) + input = fd.recv(1024) + #if len(input) == 0: # EOF + # mainloop.quit() + # return 0 + for i in input.split("\n"): + do_command(i, fd) + return True + + +def do_command(input, fd): + line = input.strip() + argv = line.split(None, 1) + if len(argv) == 0: # empty command + return 1 + #print '###', argv + + cmd = argv[0] + if cmd == 'q': + mainloop.quit() + return 0 + elif commands.has_key(cmd): + commands[cmd](argv) + else: + # send as-is + print fd + fd.send(skype.send(line) + "\n") + return 1 + + +def cmd_help(argv): + """help""" + print 'q - quit' + for cmd, handler in commands.items(): + if handler.__doc__: + print cmd, '-', handler.__doc__ + print ' - send API to skype' + + +def cmd_list_users(argv): + """list user status""" + reply = skype.send('SEARCH FRIENDS') + if reply.startswith('USERS '): + user_list = reply[6:].split(', ') + online = {} + for user in user_list: + reply = skype.send('GET USER %s ONLINESTATUS' % user) + status = reply.split()[3] + if status != 'SKYPEOUT': + online[user] = status; + for user, status in online.items(): + print '%-16s [%s]' % (user, status) + else: + print reply + + +def cmd_who(argv): + """list who's online""" + reply = skype.send('SEARCH FRIENDS') + if reply.startswith('USERS '): + user_list = reply[6:].split(', ') + who = {} + for user in user_list: + reply = skype.send('GET USER %s ONLINESTATUS' % user) + status = reply.split()[3] + if status != 'SKYPEOUT' and status != 'OFFLINE': + who[user] = status; + for user, status in who.items(): + print '%-16s [%s]' % (user, status) + else: + print reply + + +def cmd_message(argv): + """send message""" + if len(argv) < 2 or argv[1].find(' ') == -1: + print 'usage: m user text...' + else: + (user, text) = argv[1].split(None, 1) + print skype.send(' '.join((skype.msg_cmd, user, text))) + + +def cmd_userinfo(argv): + """show user info""" + if len(argv) == 1: + print 'usage: i user' + else: + user = argv[1] + for prop in USER_PROPS: + reply = skype.send('GET USER %s %s' % (user, prop)) + if reply.startswith('USER '): + res = reply.split(None, 3) + if len(res) > 3: + print '%-13s: %s' % (prop.title(), res[3]) + else: + print reply + + +def cmd_test(argv): + """test""" + print skype.send("MESSAGE echo123 one two three") + + +def cb_message(argv): + args = argv[1].split(None, 3) + msg_cmd = argv[0] + msg_id = args[0] + if args[1] == 'STATUS' and args[2] == 'READ': + reply = skype.send('GET %s %s PARTNER_HANDLE' % (msg_cmd, msg_id)) + user = reply.split(None, 3)[3] + reply = skype.send('GET %s %s BODY' % (msg_cmd, msg_id)) + res = reply.split(None, 3) + print ts(), user, '>', res[3] + + +def cb_call(argv): + args = argv[1].split(None, 3) + call_id = args[0] + if args[1] == 'STATUS': + if args[2] == 'RINGING': + reply = skype.send('GET CALL %s PARTNER_HANDLE' % call_id) + user = reply.split()[3] + reply = skype.send('GET CALL %s TYPE' % call_id) + call_type = reply.split()[3] + call_media = call_type.split('_')[1] + if call_type.startswith('INCOMING'): + print ts(), '*** Incoming', call_media, 'call from', user + elif call_type.startswith('OUTGOING'): + print ts(), '*** Outgoing', call_media, 'call to', user + elif args[2] == 'MISSED': + reply = skype.send('GET CALL %s PARTNER_HANDLE' % call_id) + user = reply.split()[3] + print ts(), '*** missed call from', user + + +def cb_user(argv): + args = argv[1].split(None, 2) + user = args[0] + if args[1] == 'ONLINESTATUS' and args[2] != 'SKYPEOUT': + print ts(), '***', user, 'is', args[2] + + +class SkypeApi(dbus.service.Object): + def __init__(self): + bus = dbus.SessionBus() + + try: + self.skype_api = bus.get_object(SKYPE_SERVICE, '/com/Skype') + except dbus.exceptions.DBusException: + print "Can't find any Skype instance. Are you sure you have started Skype?" + sys.exit(0) + + reply = self.send('NAME ' + CLIENT_NAME) + if reply != 'OK': + sys.exit('Could not bind to Skype client') + + reply = self.send('PROTOCOL 5') + #if reply != 'PROTOCOL 5': + # sys.exit('This test program only supports Skype API protocol version 1') + self.msg_cmd = 'MESSAGE' + + self.callbacks = {'MESSAGE' : cb_message, + 'CHATMESSAGE' : cb_message, + 'USER' : cb_user, + 'CALL' : cb_call} + + dbus.service.Object.__init__(self, bus, "/com/Skype/Client", bus_name='com.Skype.API') + + + # skype -> client (async) + @dbus.service.method(dbus_interface='com.Skype.API') + def Notify(self, msg_text): + global conn + text = utf8_decode(msg_text) + print ts(), '<<<', text + if conn: + conn.send(msg_text + "\n") + argv = text.split(None, 1) + if self.callbacks.has_key(argv[0]): + self.callbacks[argv[0]](argv) + + # client -> skype (sync, 5 sec timeout) + def send(self, msg_text): + print '>> ', msg_text + try: + reply = utf8_decode(self.skype_api.Invoke(utf8_encode(msg_text))) + except dbus.exceptions.DBusException, s: + reply = str(s) + print '<< ', reply + return reply + + +commands = {'?' : cmd_help, + 'l' : cmd_list_users, + 'w' : cmd_who, + 'm' : cmd_message, + 'i' : cmd_userinfo, + 't' : cmd_test} + +dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) +skype = SkypeApi() + +#print skype.send('GET SKYPEVERSION') +#print skype.send('GET USERSTATUS') + +signal.signal(signal.SIGINT, sig_handler) +#gobject.io_add_watch(sys.stdin, +# gobject.IO_IN | gobject.IO_ERR | gobject.IO_HUP, +# input_handler) +#cmd_help(None) + +mainloop = gobject.MainLoop() +sys.excepthook = excepthook + +def server(host, port): + '''Initialize server and start listening.''' + sock = socket.socket() + sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + sock.bind((host, port)) + sock.listen(1) + gobject.io_add_watch(sock, gobject.IO_IN, listener) +def listener(sock, *args): + '''Asynchronous connection listener. Starts a handler for each connection.''' + global conn + conn, addr = sock.accept() + fileno = conn.fileno() + gobject.io_add_watch(conn, gobject.IO_IN, input_handler) + return True +if __name__=='__main__': + server('localhost', 2727) + mainloop.run() -- cgit v1.2.3 From 38fa9883de34bc05fdab2a2f39fff9c7fd23a0ea Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 16:12:32 +0200 Subject: bitlbeed: some cleanup --- skype/bitlbeed.py | 193 +++--------------------------------------------------- 1 file changed, 8 insertions(+), 185 deletions(-) diff --git a/skype/bitlbeed.py b/skype/bitlbeed.py index 3460c6bb..748192a7 100644 --- a/skype/bitlbeed.py +++ b/skype/bitlbeed.py @@ -14,11 +14,7 @@ import socket SKYPE_SERVICE = 'com.Skype.API' CLIENT_NAME = 'SkypeApiPythonShell' -USER_PROPS = ('FULLNAME', 'SEX', 'LANGUAGE', 'COUNTRY', 'CITY', 'ABOUT', - 'ISAUTHORIZED', 'BUDDYSTATUS') - - -local_encoding = "latin2" +local_encoding = locale.getdefaultlocale()[1] need_conv = (local_encoding != 'utf-8') # well, this is a bit hackish. we store the socket of the last connected client @@ -37,164 +33,18 @@ def utf8_encode(local_str): else: return local_str -def ts(): - return time.strftime('[%H:%M:%S]') - - def sig_handler(signum, frame): - print '### caught signal %d, exiting' % signum - mainloop.quit() - #sys.exit() - - -def excepthook(type, value, traceback): + print 'Caught signal %d, exiting.' % signum mainloop.quit() - return sys.__excepthook__(type, value, traceback) - def input_handler(fd, io_condition): - #print '### fd=%d cond=%d' % (fd.fileno(), io_condition) input = fd.recv(1024) - #if len(input) == 0: # EOF - # mainloop.quit() - # return 0 for i in input.split("\n"): - do_command(i, fd) + if i: + fd.send(skype.send(i.strip()) + "\n") return True -def do_command(input, fd): - line = input.strip() - argv = line.split(None, 1) - if len(argv) == 0: # empty command - return 1 - #print '###', argv - - cmd = argv[0] - if cmd == 'q': - mainloop.quit() - return 0 - elif commands.has_key(cmd): - commands[cmd](argv) - else: - # send as-is - print fd - fd.send(skype.send(line) + "\n") - return 1 - - -def cmd_help(argv): - """help""" - print 'q - quit' - for cmd, handler in commands.items(): - if handler.__doc__: - print cmd, '-', handler.__doc__ - print ' - send API to skype' - - -def cmd_list_users(argv): - """list user status""" - reply = skype.send('SEARCH FRIENDS') - if reply.startswith('USERS '): - user_list = reply[6:].split(', ') - online = {} - for user in user_list: - reply = skype.send('GET USER %s ONLINESTATUS' % user) - status = reply.split()[3] - if status != 'SKYPEOUT': - online[user] = status; - for user, status in online.items(): - print '%-16s [%s]' % (user, status) - else: - print reply - - -def cmd_who(argv): - """list who's online""" - reply = skype.send('SEARCH FRIENDS') - if reply.startswith('USERS '): - user_list = reply[6:].split(', ') - who = {} - for user in user_list: - reply = skype.send('GET USER %s ONLINESTATUS' % user) - status = reply.split()[3] - if status != 'SKYPEOUT' and status != 'OFFLINE': - who[user] = status; - for user, status in who.items(): - print '%-16s [%s]' % (user, status) - else: - print reply - - -def cmd_message(argv): - """send message""" - if len(argv) < 2 or argv[1].find(' ') == -1: - print 'usage: m user text...' - else: - (user, text) = argv[1].split(None, 1) - print skype.send(' '.join((skype.msg_cmd, user, text))) - - -def cmd_userinfo(argv): - """show user info""" - if len(argv) == 1: - print 'usage: i user' - else: - user = argv[1] - for prop in USER_PROPS: - reply = skype.send('GET USER %s %s' % (user, prop)) - if reply.startswith('USER '): - res = reply.split(None, 3) - if len(res) > 3: - print '%-13s: %s' % (prop.title(), res[3]) - else: - print reply - - -def cmd_test(argv): - """test""" - print skype.send("MESSAGE echo123 one two three") - - -def cb_message(argv): - args = argv[1].split(None, 3) - msg_cmd = argv[0] - msg_id = args[0] - if args[1] == 'STATUS' and args[2] == 'READ': - reply = skype.send('GET %s %s PARTNER_HANDLE' % (msg_cmd, msg_id)) - user = reply.split(None, 3)[3] - reply = skype.send('GET %s %s BODY' % (msg_cmd, msg_id)) - res = reply.split(None, 3) - print ts(), user, '>', res[3] - - -def cb_call(argv): - args = argv[1].split(None, 3) - call_id = args[0] - if args[1] == 'STATUS': - if args[2] == 'RINGING': - reply = skype.send('GET CALL %s PARTNER_HANDLE' % call_id) - user = reply.split()[3] - reply = skype.send('GET CALL %s TYPE' % call_id) - call_type = reply.split()[3] - call_media = call_type.split('_')[1] - if call_type.startswith('INCOMING'): - print ts(), '*** Incoming', call_media, 'call from', user - elif call_type.startswith('OUTGOING'): - print ts(), '*** Outgoing', call_media, 'call to', user - elif args[2] == 'MISSED': - reply = skype.send('GET CALL %s PARTNER_HANDLE' % call_id) - user = reply.split()[3] - print ts(), '*** missed call from', user - - -def cb_user(argv): - args = argv[1].split(None, 2) - user = args[0] - if args[1] == 'ONLINESTATUS' and args[2] != 'SKYPEOUT': - print ts(), '***', user, 'is', args[2] - - class SkypeApi(dbus.service.Object): def __init__(self): bus = dbus.SessionBus() @@ -202,23 +52,13 @@ class SkypeApi(dbus.service.Object): try: self.skype_api = bus.get_object(SKYPE_SERVICE, '/com/Skype') except dbus.exceptions.DBusException: - print "Can't find any Skype instance. Are you sure you have started Skype?" - sys.exit(0) + sys.exit("Can't find any Skype instance. Are you sure you have started Skype?") reply = self.send('NAME ' + CLIENT_NAME) if reply != 'OK': sys.exit('Could not bind to Skype client') reply = self.send('PROTOCOL 5') - #if reply != 'PROTOCOL 5': - # sys.exit('This test program only supports Skype API protocol version 1') - self.msg_cmd = 'MESSAGE' - - self.callbacks = {'MESSAGE' : cb_message, - 'CHATMESSAGE' : cb_message, - 'USER' : cb_user, - 'CALL' : cb_call} - dbus.service.Object.__init__(self, bus, "/com/Skype/Client", bus_name='com.Skype.API') @@ -227,15 +67,14 @@ class SkypeApi(dbus.service.Object): def Notify(self, msg_text): global conn text = utf8_decode(msg_text) - print ts(), '<<<', text + print '<<', text if conn: conn.send(msg_text + "\n") - argv = text.split(None, 1) - if self.callbacks.has_key(argv[0]): - self.callbacks[argv[0]](argv) # client -> skype (sync, 5 sec timeout) def send(self, msg_text): + if not len(msg_text): + return print '>> ', msg_text try: reply = utf8_decode(self.skype_api.Invoke(utf8_encode(msg_text))) @@ -245,27 +84,11 @@ class SkypeApi(dbus.service.Object): return reply -commands = {'?' : cmd_help, - 'l' : cmd_list_users, - 'w' : cmd_who, - 'm' : cmd_message, - 'i' : cmd_userinfo, - 't' : cmd_test} - dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) skype = SkypeApi() - -#print skype.send('GET SKYPEVERSION') -#print skype.send('GET USERSTATUS') - signal.signal(signal.SIGINT, sig_handler) -#gobject.io_add_watch(sys.stdin, -# gobject.IO_IN | gobject.IO_ERR | gobject.IO_HUP, -# input_handler) -#cmd_help(None) mainloop = gobject.MainLoop() -sys.excepthook = excepthook def server(host, port): '''Initialize server and start listening.''' -- cgit v1.2.3 From cb35add0516ccb39707baf490e1094788790ad74 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 16:13:04 +0200 Subject: bitlbeed -> skyped i was crazy when i imported the daemon as bitlbeed.. --- skype/bitlbeed.py | 109 ------------------------------------------------------ skype/skyped.py | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 109 deletions(-) delete mode 100644 skype/bitlbeed.py create mode 100644 skype/skyped.py diff --git a/skype/bitlbeed.py b/skype/bitlbeed.py deleted file mode 100644 index 748192a7..00000000 --- a/skype/bitlbeed.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python -""" GPL """ -import sys -import signal -import locale -import time -import dbus -import dbus.service -import dbus.mainloop.glib -import gobject -import socket - - -SKYPE_SERVICE = 'com.Skype.API' -CLIENT_NAME = 'SkypeApiPythonShell' - -local_encoding = locale.getdefaultlocale()[1] -need_conv = (local_encoding != 'utf-8') - -# well, this is a bit hackish. we store the socket of the last connected client -# here and notify it. maybe later notify all connected clients? -conn = None - -def utf8_decode(utf8_str): - if need_conv: - return utf8_str.decode('utf-8').encode(local_encoding, 'replace') - else: - return utf8_str - -def utf8_encode(local_str): - if need_conv: - return local_str.decode(local_encoding).encode('utf-8') - else: - return local_str - -def sig_handler(signum, frame): - print 'Caught signal %d, exiting.' % signum - mainloop.quit() - -def input_handler(fd, io_condition): - input = fd.recv(1024) - for i in input.split("\n"): - if i: - fd.send(skype.send(i.strip()) + "\n") - return True - - -class SkypeApi(dbus.service.Object): - def __init__(self): - bus = dbus.SessionBus() - - try: - self.skype_api = bus.get_object(SKYPE_SERVICE, '/com/Skype') - except dbus.exceptions.DBusException: - sys.exit("Can't find any Skype instance. Are you sure you have started Skype?") - - reply = self.send('NAME ' + CLIENT_NAME) - if reply != 'OK': - sys.exit('Could not bind to Skype client') - - reply = self.send('PROTOCOL 5') - dbus.service.Object.__init__(self, bus, "/com/Skype/Client", bus_name='com.Skype.API') - - - # skype -> client (async) - @dbus.service.method(dbus_interface='com.Skype.API') - def Notify(self, msg_text): - global conn - text = utf8_decode(msg_text) - print '<<', text - if conn: - conn.send(msg_text + "\n") - - # client -> skype (sync, 5 sec timeout) - def send(self, msg_text): - if not len(msg_text): - return - print '>> ', msg_text - try: - reply = utf8_decode(self.skype_api.Invoke(utf8_encode(msg_text))) - except dbus.exceptions.DBusException, s: - reply = str(s) - print '<< ', reply - return reply - - -dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) -skype = SkypeApi() -signal.signal(signal.SIGINT, sig_handler) - -mainloop = gobject.MainLoop() - -def server(host, port): - '''Initialize server and start listening.''' - sock = socket.socket() - sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - sock.bind((host, port)) - sock.listen(1) - gobject.io_add_watch(sock, gobject.IO_IN, listener) -def listener(sock, *args): - '''Asynchronous connection listener. Starts a handler for each connection.''' - global conn - conn, addr = sock.accept() - fileno = conn.fileno() - gobject.io_add_watch(conn, gobject.IO_IN, input_handler) - return True -if __name__=='__main__': - server('localhost', 2727) - mainloop.run() diff --git a/skype/skyped.py b/skype/skyped.py new file mode 100644 index 00000000..748192a7 --- /dev/null +++ b/skype/skyped.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python +""" GPL """ +import sys +import signal +import locale +import time +import dbus +import dbus.service +import dbus.mainloop.glib +import gobject +import socket + + +SKYPE_SERVICE = 'com.Skype.API' +CLIENT_NAME = 'SkypeApiPythonShell' + +local_encoding = locale.getdefaultlocale()[1] +need_conv = (local_encoding != 'utf-8') + +# well, this is a bit hackish. we store the socket of the last connected client +# here and notify it. maybe later notify all connected clients? +conn = None + +def utf8_decode(utf8_str): + if need_conv: + return utf8_str.decode('utf-8').encode(local_encoding, 'replace') + else: + return utf8_str + +def utf8_encode(local_str): + if need_conv: + return local_str.decode(local_encoding).encode('utf-8') + else: + return local_str + +def sig_handler(signum, frame): + print 'Caught signal %d, exiting.' % signum + mainloop.quit() + +def input_handler(fd, io_condition): + input = fd.recv(1024) + for i in input.split("\n"): + if i: + fd.send(skype.send(i.strip()) + "\n") + return True + + +class SkypeApi(dbus.service.Object): + def __init__(self): + bus = dbus.SessionBus() + + try: + self.skype_api = bus.get_object(SKYPE_SERVICE, '/com/Skype') + except dbus.exceptions.DBusException: + sys.exit("Can't find any Skype instance. Are you sure you have started Skype?") + + reply = self.send('NAME ' + CLIENT_NAME) + if reply != 'OK': + sys.exit('Could not bind to Skype client') + + reply = self.send('PROTOCOL 5') + dbus.service.Object.__init__(self, bus, "/com/Skype/Client", bus_name='com.Skype.API') + + + # skype -> client (async) + @dbus.service.method(dbus_interface='com.Skype.API') + def Notify(self, msg_text): + global conn + text = utf8_decode(msg_text) + print '<<', text + if conn: + conn.send(msg_text + "\n") + + # client -> skype (sync, 5 sec timeout) + def send(self, msg_text): + if not len(msg_text): + return + print '>> ', msg_text + try: + reply = utf8_decode(self.skype_api.Invoke(utf8_encode(msg_text))) + except dbus.exceptions.DBusException, s: + reply = str(s) + print '<< ', reply + return reply + + +dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) +skype = SkypeApi() +signal.signal(signal.SIGINT, sig_handler) + +mainloop = gobject.MainLoop() + +def server(host, port): + '''Initialize server and start listening.''' + sock = socket.socket() + sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + sock.bind((host, port)) + sock.listen(1) + gobject.io_add_watch(sock, gobject.IO_IN, listener) +def listener(sock, *args): + '''Asynchronous connection listener. Starts a handler for each connection.''' + global conn + conn, addr = sock.accept() + fileno = conn.fileno() + gobject.io_add_watch(conn, gobject.IO_IN, input_handler) + return True +if __name__=='__main__': + server('localhost', 2727) + mainloop.run() -- cgit v1.2.3 From 94bd28f3f2d24028e4287ba4af5691f902b651e0 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 16:26:05 +0200 Subject: skyped: use tabs bitlbee uses tabs, too --- skype/skyped.py | 104 +++++++++++++++++++++++++++----------------------------- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 748192a7..12a54742 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -22,67 +22,65 @@ need_conv = (local_encoding != 'utf-8') conn = None def utf8_decode(utf8_str): - if need_conv: - return utf8_str.decode('utf-8').encode(local_encoding, 'replace') - else: - return utf8_str + if need_conv: + return utf8_str.decode('utf-8').encode(local_encoding, 'replace') + else: + return utf8_str def utf8_encode(local_str): - if need_conv: - return local_str.decode(local_encoding).encode('utf-8') - else: - return local_str + if need_conv: + return local_str.decode(local_encoding).encode('utf-8') + else: + return local_str def sig_handler(signum, frame): - print 'Caught signal %d, exiting.' % signum - mainloop.quit() + print 'Caught signal %d, exiting.' % signum + mainloop.quit() def input_handler(fd, io_condition): - input = fd.recv(1024) - for i in input.split("\n"): - if i: - fd.send(skype.send(i.strip()) + "\n") - return True - + input = fd.recv(1024) + for i in input.split("\n"): + if i: + fd.send(skype.send(i.strip()) + "\n") + return True class SkypeApi(dbus.service.Object): - def __init__(self): - bus = dbus.SessionBus() - - try: - self.skype_api = bus.get_object(SKYPE_SERVICE, '/com/Skype') - except dbus.exceptions.DBusException: - sys.exit("Can't find any Skype instance. Are you sure you have started Skype?") - - reply = self.send('NAME ' + CLIENT_NAME) - if reply != 'OK': - sys.exit('Could not bind to Skype client') - - reply = self.send('PROTOCOL 5') - dbus.service.Object.__init__(self, bus, "/com/Skype/Client", bus_name='com.Skype.API') - - - # skype -> client (async) - @dbus.service.method(dbus_interface='com.Skype.API') - def Notify(self, msg_text): - global conn - text = utf8_decode(msg_text) - print '<<', text - if conn: - conn.send(msg_text + "\n") - - # client -> skype (sync, 5 sec timeout) - def send(self, msg_text): - if not len(msg_text): - return - print '>> ', msg_text - try: - reply = utf8_decode(self.skype_api.Invoke(utf8_encode(msg_text))) - except dbus.exceptions.DBusException, s: - reply = str(s) - print '<< ', reply - return reply - + def __init__(self): + bus = dbus.SessionBus() + + try: + self.skype_api = bus.get_object(SKYPE_SERVICE, '/com/Skype') + except dbus.exceptions.DBusException: + sys.exit("Can't find any Skype instance. Are you sure you have started Skype?") + + reply = self.send('NAME ' + CLIENT_NAME) + if reply != 'OK': + sys.exit('Could not bind to Skype client') + + reply = self.send('PROTOCOL 5') + dbus.service.Object.__init__(self, bus, "/com/Skype/Client", bus_name='com.Skype.API') + + + # skype -> client (async) + @dbus.service.method(dbus_interface='com.Skype.API') + def Notify(self, msg_text): + global conn + text = utf8_decode(msg_text) + print '<<', text + if conn: + conn.send(msg_text + "\n") + + # client -> skype (sync, 5 sec timeout) + def send(self, msg_text): + if not len(msg_text): + return + print '>> ', msg_text + try: + reply = utf8_decode(self.skype_api.Invoke(utf8_encode(msg_text))) + except dbus.exceptions.DBusException, s: + reply = str(s) + print '<< ', reply + return reply dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) skype = SkypeApi() -- cgit v1.2.3 From a316c4e602726f4cf85bee0508a365ce3e28fa7b Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 16:50:50 +0200 Subject: skyped: finish cleanup hopefully no later cosmetics changes will be necessary now --- skype/skyped.py | 73 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 12a54742..7c9afdb8 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -34,39 +34,54 @@ def utf8_encode(local_str): return local_str def sig_handler(signum, frame): - print 'Caught signal %d, exiting.' % signum mainloop.quit() def input_handler(fd, io_condition): input = fd.recv(1024) for i in input.split("\n"): - if i: - fd.send(skype.send(i.strip()) + "\n") + if i: + fd.send(skype.send(i.strip()) + "\n") return True +def server(host, port): + sock = socket.socket() + sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + sock.bind((host, port)) + sock.listen(1) + gobject.io_add_watch(sock, gobject.IO_IN, listener) + +def listener(sock, *args): + global conn + conn, addr = sock.accept() + fileno = conn.fileno() + gobject.io_add_watch(conn, gobject.IO_IN, input_handler) + return True + +def dprint(msg): + if len(sys.argv) > 1 and sys.argv[1] == "-d": + print msg + class SkypeApi(dbus.service.Object): def __init__(self): bus = dbus.SessionBus() + try: + self.skype_api = bus.get_object(SKYPE_SERVICE, '/com/Skype') + except dbus.exceptions.DBusException: + sys.exit("Can't find any Skype instance. Are you sure you have started Skype?") - try: - self.skype_api = bus.get_object(SKYPE_SERVICE, '/com/Skype') - except dbus.exceptions.DBusException: - sys.exit("Can't find any Skype instance. Are you sure you have started Skype?") - - reply = self.send('NAME ' + CLIENT_NAME) - if reply != 'OK': - sys.exit('Could not bind to Skype client') - - reply = self.send('PROTOCOL 5') - dbus.service.Object.__init__(self, bus, "/com/Skype/Client", bus_name='com.Skype.API') + reply = self.send('NAME ' + CLIENT_NAME) + if reply != 'OK': + sys.exit('Could not bind to Skype client') + reply = self.send('PROTOCOL 5') + dbus.service.Object.__init__(self, bus, "/com/Skype/Client", bus_name='com.Skype.API') # skype -> client (async) @dbus.service.method(dbus_interface='com.Skype.API') def Notify(self, msg_text): global conn text = utf8_decode(msg_text) - print '<<', text + dprint('<< ' + text) if conn: conn.send(msg_text + "\n") @@ -74,34 +89,18 @@ class SkypeApi(dbus.service.Object): def send(self, msg_text): if not len(msg_text): return - print '>> ', msg_text + dprint('>> ' + msg_text) try: reply = utf8_decode(self.skype_api.Invoke(utf8_encode(msg_text))) except dbus.exceptions.DBusException, s: reply = str(s) - print '<< ', reply + dprint('<< ' + reply) return reply -dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) -skype = SkypeApi() -signal.signal(signal.SIGINT, sig_handler) - -mainloop = gobject.MainLoop() - -def server(host, port): - '''Initialize server and start listening.''' - sock = socket.socket() - sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - sock.bind((host, port)) - sock.listen(1) - gobject.io_add_watch(sock, gobject.IO_IN, listener) -def listener(sock, *args): - '''Asynchronous connection listener. Starts a handler for each connection.''' - global conn - conn, addr = sock.accept() - fileno = conn.fileno() - gobject.io_add_watch(conn, gobject.IO_IN, input_handler) - return True if __name__=='__main__': + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + skype = SkypeApi() + signal.signal(signal.SIGINT, sig_handler) + mainloop = gobject.MainLoop() server('localhost', 2727) mainloop.run() -- cgit v1.2.3 From ba20c3903ee5c47e5fb83fc17a13e5f5ed319372 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 16:53:05 +0200 Subject: document how to start the daemon --- skype/README | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/skype/README b/skype/README index 57fd6359..d4bf24f8 100644 --- a/skype/README +++ b/skype/README @@ -32,9 +32,12 @@ git clone http://ftp.frugalware.org/pub/other/people/vmiklos/bitlbee-skype make cp skype.so /usr/lib/bitlbee -- Set up the tcp server: +- Start the tcp server: -FIXME +python skyped.py + +NOTE: It's important to start skyped on the same machine and using the same +user as you run Skype as it uses the session DBus for communication! What works: @@ -44,9 +47,9 @@ What works: - Receiving messages -What needs to be done (aka. TODO): +- Writing a tcp daemon that is a gateway between Skype and tcp -- import the daemon code +What needs to be done (aka. TODO): - convert this readme to asciidoc -- cgit v1.2.3 From ed2e37f5b8f597fdd8e4e0a9cafb943d23e5469c Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 18:35:48 +0200 Subject: more error handling, no more SIGPIPE \o/ :) --- skype/README | 8 ++++---- 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 +#include #include #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); } -- cgit v1.2.3 From 0c60f96f5a49d9c8b22359729371d08d1c8d8bd4 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 18:45:05 +0200 Subject: converted README to asciidoc --- skype/Makefile | 5 +++++ skype/README | 36 +++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index 8733bcba..cd922db3 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -6,3 +6,8 @@ skype.so: skype.c clean: rm -f skype.so + +doc: + ln -s README HEADER.txt + asciidoc -a toc -a numbered HEADER.txt + rm HEADER.txt diff --git a/skype/README b/skype/README index 5cfa2020..1847159d 100644 --- a/skype/README +++ b/skype/README @@ -1,45 +1,57 @@ -Hello, += Skype plugin for BitlBee +Miklos Vajna -This plugin allows you to add Skype support to BitlBee. It's mainly written by -Miklos Vajna . - -How to set it up: +== How to set it up: - You need the BitlBee bzr branch: +---- bzr branch http://code.bitlbee.org/bitlbee/ +---- - You need to enable plugin support: +---- http://frugalware.org/~vmiklos/patches/bitlbee-configure-plugins.patch +---- - To be able to do an install-dev: +---- http://frugalware.org/~vmiklos/patches/bitlbee-makefile-headers.patch +---- - Now compile and install it: +---- ./configure --prefix=/usr make make install install-dev +---- - Get the plugin code: +---- git clone http://ftp.frugalware.org/pub/other/people/vmiklos/bitlbee-skype +---- - Compile and install it: +---- make cp skype.so /usr/lib/bitlbee +---- - Start skyped (the tcp server): +---- python skyped.py +---- NOTE: It's important to start skyped on the same machine and using the same user as you run Skype as it uses the session DBus for communication! -What works: +== What works: - Download nicks and away statuses from Skype @@ -51,9 +63,7 @@ What works: - Error handling when skyped is not running and when it exists -What needs to be done (aka. TODO): - -- convert this readme to asciidoc +== What needs to be done (aka. TODO): - we can't ourselves join to &bitlbee (ignore such a message from skype) @@ -67,8 +77,12 @@ 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 +== I would like to have support for ... + If something does not work and it's not in the TODO section, then please contact me! -Shots at: +== Screenshots + +You can reach some screenshots http://frugalware.org/~vmiklos/pics/shots/bitlbee-skype/[here]. -http://frugalware.org/~vmiklos/pics/shots/bitlbee-skype/ +// vim: ft=asciidoc -- cgit v1.2.3 From d1c9e3542d4e1b90b89d4850a4c7692d1b09ec9c Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 18:49:35 +0200 Subject: build the doc only if it's updated --- skype/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index cd922db3..d07993ff 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -7,7 +7,9 @@ skype.so: skype.c clean: rm -f skype.so -doc: +doc: HEADER.html + +HEADER.html: README ln -s README HEADER.txt asciidoc -a toc -a numbered HEADER.txt rm HEADER.txt -- cgit v1.2.3 From 9e03e556f0c34cc9a2876605a228c7ae539cb8de Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 18:55:31 +0200 Subject: minor doc fixes --- skype/README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index 1847159d..99bccdff 100644 --- a/skype/README +++ b/skype/README @@ -1,7 +1,7 @@ = Skype plugin for BitlBee Miklos Vajna -== How to set it up: +== How to set it up - You need the BitlBee bzr branch: @@ -51,7 +51,7 @@ python skyped.py NOTE: It's important to start skyped on the same machine and using the same user as you run Skype as it uses the session DBus for communication! -== What works: +== What works - Download nicks and away statuses from Skype @@ -63,7 +63,7 @@ user as you run Skype as it uses the session DBus for communication! - Error handling when skyped is not running and when it exists -== What needs to be done (aka. TODO): +== What needs to be done (aka. TODO) - we can't ourselves join to &bitlbee (ignore such a message from skype) -- cgit v1.2.3 From 7338d592a1b40de9ef3f0a99a09987b4c617f02b Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 19:12:23 +0200 Subject: doc about how to add your account --- skype/README | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/skype/README b/skype/README index 99bccdff..13bf776b 100644 --- a/skype/README +++ b/skype/README @@ -51,6 +51,18 @@ python skyped.py NOTE: It's important to start skyped on the same machine and using the same user as you run Skype as it uses the session DBus for communication! +- Start your IRC client, connect to BitlBee and add your account: + +---- +account add skype +account set 0/server localhost +---- + +IMPORTANT: should be your skype account name. This way you won't see +yourself joining to `&bitlbee`. + +NOTE: the option is not used currently. + == What works - Download nicks and away statuses from Skype -- cgit v1.2.3 From 39a0d6429bd2a5aac36b6393278acd08b7b95893 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 19:13:24 +0200 Subject: todo update Noticing joins / parts while we're connected implemented in fact i did this implicitly ;) --- skype/README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index 13bf776b..1440810a 100644 --- a/skype/README +++ b/skype/README @@ -67,6 +67,8 @@ NOTE: the option is not used currently. - Download nicks and away statuses from Skype +- Noticing joins / parts while we're connected + - Sending messages - Receiving messages @@ -83,8 +85,6 @@ NOTE: the option is not used currently. - Away status changes (send / receive) -- join / parts - - add/remove users, detect when somebody wants to add us (maybe detect when we're removed?) - maybe on account on/off, change our state from/to offline? so that we won't miss any message -- cgit v1.2.3 From a3d6427d343e5f3de206272a664a126fea1af6bb Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 19:25:32 +0200 Subject: bugfix: we can't join to &bitlbee twice --- skype/README | 2 -- skype/skype.c | 22 ++++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/skype/README b/skype/README index 1440810a..2705de67 100644 --- a/skype/README +++ b/skype/README @@ -79,8 +79,6 @@ NOTE: the option is not used currently. == What needs to be done (aka. TODO) -- we can't ourselves join to &bitlbee (ignore such a message from skype) - - mark received messages as read so that skype won't say there are unread messages - Away status changes (send / receive) diff --git a/skype/skype.c b/skype/skype.c index 3dc96719..e1837063 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -14,6 +14,7 @@ struct skype_data { struct im_connection *ic; + char *username; int fd; char *txq; int tx_len; @@ -107,14 +108,17 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c status++; ptr = strchr(++user, ' '); *ptr = '\0'; - ptr = g_strdup_printf("%s@skype.com", user); - imcb_add_buddy(ic, ptr, NULL); - if(strcmp(status, "OFFLINE") != 0) - flags |= OPT_LOGGED_IN; - if(strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0) - flags |= OPT_AWAY; - imcb_buddy_status(ic, ptr, flags, NULL, NULL); - g_free(ptr); + if(strcmp(user, sd->username) != 0) + { + ptr = g_strdup_printf("%s@skype.com", user); + imcb_add_buddy(ic, ptr, NULL); + if(strcmp(status, "OFFLINE") != 0) + flags |= OPT_LOGGED_IN; + if(strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0) + flags |= OPT_AWAY; + imcb_buddy_status(ic, ptr, flags, NULL, NULL); + g_free(ptr); + } } else if(!strncmp(line, "CHATMESSAGE ", 12)) { @@ -220,6 +224,7 @@ static void skype_login( account_t *acc ) /*imcb_add_buddy(ic, "test@skype.com", NULL); imcb_buddy_status(ic, "test@skype.com", OPT_LOGGED_IN, NULL, NULL); imcb_buddy_msg(ic, "test@skype.com", "test from skype plugin", 0, 0);*/ + sd->username = g_strdup( acc->user ); sd->ic = ic; } @@ -227,6 +232,7 @@ static void skype_login( account_t *acc ) static void skype_logout( struct im_connection *ic ) { struct skype_data *sd = ic->proto_data; + g_free(sd->username); g_free(sd); } -- cgit v1.2.3 From 218ffbd18175cad56805dd5134ac6f41f8dc6cb4 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 19:26:00 +0200 Subject: todo: when someone removes us, we just will see that he/she is offline, no need to handle this --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 2705de67..da81d633 100644 --- a/skype/README +++ b/skype/README @@ -83,7 +83,7 @@ NOTE: the option is not used currently. - Away status changes (send / receive) -- add/remove users, detect when somebody wants to add us (maybe detect when we're removed?) +- add/remove users, detect when somebody wants to add us - maybe on account on/off, change our state from/to offline? so that we won't miss any message -- cgit v1.2.3 From 751b14941fa2a610031c14711ba5b3cd8111b93f Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 19:28:19 +0200 Subject: more docs --- skype/README | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/skype/README b/skype/README index da81d633..59803378 100644 --- a/skype/README +++ b/skype/README @@ -3,6 +3,11 @@ Miklos Vajna == How to set it up +Before you start. The setup is the following: BitlBee can't connect directly to +Skype servers (the company's ones). It needs a running Skype client to do so. +In fact BitlBee will connect to `skyped` (a tcp server, provided in this +package) and `skyped` will connecto to your Skype client. + - You need the BitlBee bzr branch: ---- -- cgit v1.2.3 From 72f697b0e0ea9671f9182a8364d2bf1e97b002b8 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 19:37:56 +0200 Subject: receiving away status changes done --- skype/README | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 59803378..aa32b48e 100644 --- a/skype/README +++ b/skype/README @@ -78,6 +78,8 @@ NOTE: the option is not used currently. - Receiving messages +- Receiving away status changes + - skyped (the tcp daemon that is a gateway between Skype and tcp) - Error handling when skyped is not running and when it exists @@ -86,7 +88,7 @@ NOTE: the option is not used currently. - mark received messages as read so that skype won't say there are unread messages -- Away status changes (send / receive) +- Away status changes (send) - add/remove users, detect when somebody wants to add us -- cgit v1.2.3 From 62bb4e49d4066e7505ee784b404c676906a1ca09 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 20:50:25 +0200 Subject: mark received messages as read so that skype won't say there are unread messages --- skype/README | 8 ++++---- skype/skype.c | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/skype/README b/skype/README index aa32b48e..188ba933 100644 --- a/skype/README +++ b/skype/README @@ -80,13 +80,13 @@ NOTE: the option is not used currently. - Receiving away status changes -- skyped (the 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 +- Error handling when `skyped` is not running and when it exits -== What needs to be done (aka. TODO) +- Marking received messages as seen so that Skype won't say there are unread messages -- mark received messages as read so that skype won't say there are unread messages +== What needs to be done (aka. TODO) - Away status changes (send) diff --git a/skype/skype.c b/skype/skype.c index e1837063..18849fca 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -136,6 +136,8 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c skype_write( ic, buf, strlen( buf ) ); g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); skype_write( ic, buf, strlen( buf ) ); + g_snprintf(buf, 1024, "SET CHATMESSAGE %s SEEN\n", id); + skype_write( ic, buf, strlen( buf ) ); } else if(!strncmp(info, "FROM_HANDLE ", 12)) { -- cgit v1.2.3 From f932b65244885b5eee8917192913b3e6172e3a11 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 20:56:46 +0200 Subject: skyped: some cleanup, no encoding is needed when sending messages --- skype/skyped.py | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 7c9afdb8..d86fca7b 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -14,25 +14,10 @@ import socket SKYPE_SERVICE = 'com.Skype.API' CLIENT_NAME = 'SkypeApiPythonShell' -local_encoding = locale.getdefaultlocale()[1] -need_conv = (local_encoding != 'utf-8') - # well, this is a bit hackish. we store the socket of the last connected client # here and notify it. maybe later notify all connected clients? conn = None -def utf8_decode(utf8_str): - if need_conv: - return utf8_str.decode('utf-8').encode(local_encoding, 'replace') - else: - return utf8_str - -def utf8_encode(local_str): - if need_conv: - return local_str.decode(local_encoding).encode('utf-8') - else: - return local_str - def sig_handler(signum, frame): mainloop.quit() @@ -40,7 +25,7 @@ def input_handler(fd, io_condition): input = fd.recv(1024) for i in input.split("\n"): if i: - fd.send(skype.send(i.strip()) + "\n") + fd.send((skype.send(i.strip()) + "\n").encode(locale.getdefaultlocale()[1])) return True def server(host, port): @@ -80,8 +65,7 @@ class SkypeApi(dbus.service.Object): @dbus.service.method(dbus_interface='com.Skype.API') def Notify(self, msg_text): global conn - text = utf8_decode(msg_text) - dprint('<< ' + text) + dprint('<< ' + msg_text) if conn: conn.send(msg_text + "\n") @@ -91,7 +75,7 @@ class SkypeApi(dbus.service.Object): return dprint('>> ' + msg_text) try: - reply = utf8_decode(self.skype_api.Invoke(utf8_encode(msg_text))) + reply = self.skype_api.Invoke(msg_text) except dbus.exceptions.DBusException, s: reply = str(s) dprint('<< ' + reply) -- cgit v1.2.3 From 565982f80f224045c72332d853f24fcb8534f818 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 21:43:03 +0200 Subject: no idea how to set states --- skype/README | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index 188ba933..57f1f949 100644 --- a/skype/README +++ b/skype/README @@ -88,11 +88,12 @@ NOTE: the option is not used currently. == What needs to be done (aka. TODO) -- Away status changes (send) - - add/remove users, detect when somebody wants to add us -- maybe on account on/off, change our state from/to offline? so that we won't miss any message +- Due to some API limitations, I have no idea how to change status. This affects: + * When you `/away`, Skype will be still show `Online` + * When you `account off`, Skype will not set status to `Offline` + * When you `account on`, Skype will not set status to `Online` == I would like to have support for ... -- cgit v1.2.3 From d5a514a36fc1ad7e54514b84890c2cb7ad36025a Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 21:43:11 +0200 Subject: register skype_set_away() --- skype/skype.c | 1 + 1 file changed, 1 insertion(+) diff --git a/skype/skype.c b/skype/skype.c index 18849fca..2d965ed4 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -289,6 +289,7 @@ void init_plugin(void) ret->init = skype_init; ret->logout = skype_logout; ret->buddy_msg = skype_buddy_msg; + ret->set_away = skype_set_away; ret->away_states = skype_away_states; ret->add_buddy = skype_add_buddy; ret->remove_buddy = skype_remove_buddy; -- cgit v1.2.3 From 314b375c85d1b28382f207850b349fbd41c0d1fa Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 21:45:05 +0200 Subject: ignore test user echo123 --- skype/skype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 2d965ed4..e0c3f22e 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -108,7 +108,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c status++; ptr = strchr(++user, ' '); *ptr = '\0'; - if(strcmp(user, sd->username) != 0) + if(strcmp(user, sd->username) != 0 && strcmp(user, "echo123") != 0) { ptr = g_strdup_printf("%s@skype.com", user); imcb_add_buddy(ic, ptr, NULL); -- cgit v1.2.3 From e23a46e4c994b1c01e75582b32826afebdc4c5fc Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 21:47:13 +0200 Subject: add a changelog --- skype/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index d07993ff..1f682f7c 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -7,9 +7,12 @@ skype.so: skype.c clean: rm -f skype.so -doc: HEADER.html +doc: HEADER.html Changelog HEADER.html: README ln -s README HEADER.txt asciidoc -a toc -a numbered HEADER.txt rm HEADER.txt + +Changelog: .git/refs/heads/master + git log --no-merges > Changelog -- cgit v1.2.3 From a60c3c2bde4e3e4327f4a4815fee43c714da6298 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 21:49:00 +0200 Subject: link the changelog --- skype/README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skype/README b/skype/README index 57f1f949..ab4d0151 100644 --- a/skype/README +++ b/skype/README @@ -103,4 +103,8 @@ If something does not work and it's not in the TODO section, then please contact You can reach some screenshots http://frugalware.org/~vmiklos/pics/shots/bitlbee-skype/[here]. +== Changelog + +You can reach the Changelog link:Changelog[here]. + // vim: ft=asciidoc -- cgit v1.2.3 From 6627d926b16e5c4a92099d9ea896bd00b5b9a680 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 22:58:45 +0200 Subject: implement add/removing contacts --- skype/README | 4 +++- skype/skype.c | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index ab4d0151..e55bd290 100644 --- a/skype/README +++ b/skype/README @@ -86,9 +86,11 @@ NOTE: the option is not used currently. - Marking received messages as seen so that Skype won't say there are unread messages +- Adding / removing contacts + == What needs to be done (aka. TODO) -- add/remove users, detect when somebody wants to add us +- detect when somebody wants to add us - Due to some API limitations, I have no idea how to change status. This affects: * When you `/away`, Skype will be still show `Online` diff --git a/skype/skype.c b/skype/skype.c index e0c3f22e..e0e5901a 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -108,7 +108,8 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c status++; ptr = strchr(++user, ' '); *ptr = '\0'; - if(strcmp(user, sd->username) != 0 && strcmp(user, "echo123") != 0) + ptr++; + if(!strncmp(ptr, "ONLINESTATUS ", 13) && strcmp(user, sd->username) != 0 && strcmp(user, "echo123") != 0) { ptr = g_strdup_printf("%s@skype.com", user); imcb_add_buddy(ic, ptr, NULL); @@ -274,10 +275,30 @@ static GList *skype_away_states( struct im_connection *ic ) static void skype_add_buddy( struct im_connection *ic, char *who, char *group ) { + char *buf, *nick, *ptr; + + nick = g_strdup_printf("%s", who); + ptr = strchr(nick, '@'); + if(ptr) + *ptr = '\0'; + buf = g_strdup_printf("SET USER %s BUDDYSTATUS 2 Please authorize me\n", nick); + skype_write( ic, buf, strlen( buf ) ); + printf("add '%s'\n", nick); + g_free(nick); } static void skype_remove_buddy( struct im_connection *ic, char *who, char *group ) { + char *buf, *nick, *ptr; + + nick = g_strdup_printf("%s", who); + ptr = strchr(nick, '@'); + if(ptr) + *ptr = '\0'; + buf = g_strdup_printf("SET USER %s BUDDYSTATUS 1\n", nick); + skype_write( ic, buf, strlen( buf ) ); + printf("remove '%s'\n", nick); + g_free(nick); } void init_plugin(void) -- cgit v1.2.3 From 7e4f0ca1fedc2762aa1d2231e92b878f53fbecd3 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 22:59:58 +0200 Subject: more docs --- skype/README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/skype/README b/skype/README index e55bd290..65a9f9cf 100644 --- a/skype/README +++ b/skype/README @@ -8,6 +8,9 @@ Skype servers (the company's ones). It needs a running Skype client to do so. In fact BitlBee will connect to `skyped` (a tcp server, provided in this package) and `skyped` will connecto to your Skype client. +NOTE: The order is important. First you have to start Skype. Then `skyped` can +connect to it, finally BitlBee can connect to `skyped`. + - You need the BitlBee bzr branch: ---- -- cgit v1.2.3 From cbec0d6b8cb68fdadaf938922d0062637c6c2e21 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 23:14:52 +0200 Subject: g_strdup_printf("%s" -> g_strdup( --- skype/skype.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index e0e5901a..8d3f7f62 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -244,7 +244,7 @@ static int skype_buddy_msg( struct im_connection *ic, char *who, char *message, char *buf, *ptr, *nick; int st; - nick = g_strdup_printf("%s", who); + nick = g_strdup(who); ptr = strchr(nick, '@'); if(ptr) *ptr = '\0'; @@ -277,7 +277,7 @@ static void skype_add_buddy( struct im_connection *ic, char *who, char *group ) { char *buf, *nick, *ptr; - nick = g_strdup_printf("%s", who); + nick = g_strdup(who); ptr = strchr(nick, '@'); if(ptr) *ptr = '\0'; @@ -291,7 +291,7 @@ static void skype_remove_buddy( struct im_connection *ic, char *who, char *group { char *buf, *nick, *ptr; - nick = g_strdup_printf("%s", who); + nick = g_strdup(who); ptr = strchr(nick, '@'); if(ptr) *ptr = '\0'; -- cgit v1.2.3 From f78f9490712b11b9395d6cf3817a490aeaa85ef3 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 20 Aug 2007 23:27:52 +0200 Subject: known bugs --- skype/README | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 65a9f9cf..494e2d6f 100644 --- a/skype/README +++ b/skype/README @@ -93,7 +93,7 @@ NOTE: the option is not used currently. == What needs to be done (aka. TODO) -- detect when somebody wants to add us +- detect when somebody wants to add us (confirm callback) - Due to some API limitations, I have no idea how to change status. This affects: * When you `/away`, Skype will be still show `Online` @@ -104,6 +104,13 @@ NOTE: the option is not used currently. If something does not work and it's not in the TODO section, then please contact me! +== Known bugs + +- Sometimes when you get a lot of messages in a short time, some of the + messages are dropped. This is a known bug in Skype itself as of version + 1.4.0.99 + (http://forum.skype.com/index.php?s=&showtopic=94545&view=findpost&p=431710[link]). + == Screenshots You can reach some screenshots http://frugalware.org/~vmiklos/pics/shots/bitlbee-skype/[here]. -- cgit v1.2.3 From 23411c64ecb0608a2629083504c8e59458c7e0fa Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 00:00:16 +0200 Subject: implement skype_set_away() --- skype/README | 8 ++++---- skype/skype.c | 34 +++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/skype/README b/skype/README index 494e2d6f..191c06d7 100644 --- a/skype/README +++ b/skype/README @@ -91,14 +91,14 @@ NOTE: the option is not used currently. - Adding / removing contacts +- Set away state when you do a `/away`. + == What needs to be done (aka. TODO) - detect when somebody wants to add us (confirm callback) -- Due to some API limitations, I have no idea how to change status. This affects: - * When you `/away`, Skype will be still show `Online` - * When you `account off`, Skype will not set status to `Offline` - * When you `account on`, Skype will not set status to `Online` +- When you `account off`, Skype will not set status to `Offline` +- When you `account on`, Skype will not set status to `Online` == I would like to have support for ... diff --git a/skype/skype.c b/skype/skype.c index 8d3f7f62..2086c192 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -39,7 +39,8 @@ const struct skype_away_state skype_away_state_list[] = { "NA", "Not available" }, { "DND", "Do Not Disturb" }, { "INVISIBLE", "Invisible" }, - { "OFFLINE", "Offline" } + { "OFFLINE", "Offline" }, + { NULL, NULL} }; static void skype_init( account_t *acc ) @@ -257,18 +258,39 @@ static int skype_buddy_msg( struct im_connection *ic, char *who, char *message, return st; } +const struct skype_away_state *skype_away_state_by_name( char *name ) +{ + int i; + + for( i = 0; skype_away_state_list[i].full_name; i ++ ) + if( g_strcasecmp( skype_away_state_list[i].full_name, name ) == 0 ) + return( skype_away_state_list + i ); + + return NULL; +} + static void skype_set_away( struct im_connection *ic, char *state_txt, char *message ) { + const struct skype_away_state *state; + char *buf; + + if( strcmp( state_txt, GAIM_AWAY_CUSTOM ) == 0 ) + state = skype_away_state_by_name( "Away" ); + else + state = skype_away_state_by_name( state_txt ); + printf("would set to: '%s'\n", state->code); + buf = g_strdup_printf("SET USERSTATUS %s\n", state->code); + skype_write( ic, buf, strlen( buf ) ); + g_free(buf); } static GList *skype_away_states( struct im_connection *ic ) { - static GList *l = NULL; + GList *l = NULL; int i; - if( l == NULL ) - for( i = 0; skype_away_state_list[i].full_name; i ++ ) - l = g_list_append( l, (void*) skype_away_state_list[i].full_name ); + for( i = 0; skype_away_state_list[i].full_name; i ++ ) + l = g_list_append( l, (void*) skype_away_state_list[i].full_name ); return l; } @@ -314,8 +336,6 @@ void init_plugin(void) ret->away_states = skype_away_states; ret->add_buddy = skype_add_buddy; ret->remove_buddy = skype_remove_buddy; - ret->away_states = skype_away_states; - ret->set_away = skype_set_away; ret->handle_cmp = g_strcasecmp; register_protocol( ret ); } -- cgit v1.2.3 From 98bca363574144c9e488812c61249613fcb5e989 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 00:37:17 +0200 Subject: prevent a segfault in skype_read_callback() --- skype/skype.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 2086c192..51c95913 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -72,7 +72,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c int st; char **lines, **lineptr, *line, *ptr; - if( sd->fd == -1 ) + if( !sd || sd->fd == -1 ) return FALSE; st = read( sd->fd, buf, sizeof( buf ) ); if( st > 0 ) @@ -236,8 +236,15 @@ static void skype_login( account_t *acc ) static void skype_logout( struct im_connection *ic ) { struct skype_data *sd = ic->proto_data; + char *buf; + + buf = g_strdup_printf("SET USERSTATUS OFFLINE\n"); + skype_write( ic, buf, strlen( buf ) ); + g_free(buf); + g_free(sd->username); g_free(sd); + ic->proto_data = NULL; } static int skype_buddy_msg( struct im_connection *ic, char *who, char *message, int flags ) -- cgit v1.2.3 From 348a3a20a06744d919f7b0bf0d392d30511d50b1 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 00:38:06 +0200 Subject: use SET USERSTATUS on login/logout --- skype/README | 7 ++++--- skype/skype.c | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index 191c06d7..21d2201e 100644 --- a/skype/README +++ b/skype/README @@ -93,13 +93,14 @@ NOTE: the option is not used currently. - Set away state when you do a `/away`. +- When you `account off`, Skype will set status to `Offline` + +- When you `account on`, Skype will set status to `Online` + == What needs to be done (aka. TODO) - detect when somebody wants to add us (confirm callback) -- When you `account off`, Skype will not set status to `Offline` -- When you `account on`, Skype will not set status to `Online` - == I would like to have support for ... If something does not work and it's not in the TODO section, then please contact me! diff --git a/skype/skype.c b/skype/skype.c index 51c95913..88713e47 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -191,6 +191,9 @@ gboolean skype_start_stream( struct im_connection *ic ) buf = g_strdup_printf("SEARCH FRIENDS\n"); st = skype_write( ic, buf, strlen( buf ) ); g_free(buf); + buf = g_strdup_printf("SET USERSTATUS ONLINE\n"); + skype_write( ic, buf, strlen( buf ) ); + g_free(buf); return st; } -- cgit v1.2.3 From 09be265fcadda0c308952cc46d5dc6c1352292a8 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 00:51:59 +0200 Subject: new ideas: block/allow --- skype/README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/README b/skype/README index 21d2201e..0dd2c4a3 100644 --- a/skype/README +++ b/skype/README @@ -101,6 +101,8 @@ NOTE: the option is not used currently. - detect when somebody wants to add us (confirm callback) +- implement block/allow commands + == I would like to have support for ... If something does not work and it's not in the TODO section, then please contact me! -- cgit v1.2.3 From 1fb89e33a8b514895c22b6476e50616b2c2d907d Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 00:56:56 +0200 Subject: move the poll() usage to skype_write() --- skype/skype.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 88713e47..df8d7679 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -57,7 +57,18 @@ static void skype_init( account_t *acc ) int skype_write( struct im_connection *ic, char *buf, int len ) { struct skype_data *sd = ic->proto_data; + struct pollfd pfd[1]; + + 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; + } printf("write(): %s", buf); write( sd->fd, buf, len ); @@ -184,6 +195,9 @@ gboolean skype_start_stream( struct im_connection *ic ) char *buf; int st; + if(!sd) + return FALSE; + if( sd->r_inpa <= 0 ) sd->r_inpa = b_input_add( sd->fd, GAIM_INPUT_READ, skype_read_callback, ic ); @@ -200,19 +214,6 @@ gboolean skype_start_stream( struct im_connection *ic ) 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]; - - 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); } -- cgit v1.2.3 From d3cbd1725540cb6665df678b28dafa8fe4c1c7d6 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 16:10:25 +0200 Subject: implement skype_buddy_ask() --- skype/README | 11 +++++++---- skype/skype.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/skype/README b/skype/README index 0dd2c4a3..ea918a84 100644 --- a/skype/README +++ b/skype/README @@ -93,16 +93,19 @@ NOTE: the option is not used currently. - Set away state when you do a `/away`. -- When you `account off`, Skype will set status to `Offline` +- When you `account off`, Skype will set status to `Offline` -- When you `account on`, Skype will set status to `Online` +- When you `account on`, Skype will set status to `Online` -== What needs to be done (aka. TODO) +- Detect when somebody wants to add you and ask for confirmation -- detect when somebody wants to add us (confirm callback) +== What needs to be done (aka. TODO) - implement block/allow commands +- when you remove a nick, it'll still shown as being offline (no + `imcb_remove_buddy()`?) + == I would like to have support for ... If something does not work and it's not in the TODO section, then please contact me! diff --git a/skype/skype.c b/skype/skype.c index df8d7679..ab4e05eb 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -43,6 +43,12 @@ const struct skype_away_state skype_away_state_list[] = { NULL, NULL} }; +struct skype_buddy_ask_data +{ + struct im_connection *ic; + char *handle; +}; + static void skype_init( account_t *acc ) { set_t *s; @@ -75,6 +81,37 @@ int skype_write( struct im_connection *ic, char *buf, int len ) return TRUE; } +static void skype_buddy_ask_yes( gpointer w, struct skype_buddy_ask_data *bla ) +{ + char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED TRUE", bla->handle); + skype_write( bla->ic, buf, strlen( buf ) ); + g_free(buf); + g_free(bla->handle); + g_free(bla); +} + +static void skype_buddy_ask_no( gpointer w, struct skype_buddy_ask_data *bla ) +{ + char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED FALSE", bla->handle); + skype_write( bla->ic, buf, strlen( buf ) ); + g_free(buf); + g_free(bla->handle); + g_free(bla); +} + +void skype_buddy_ask( struct im_connection *ic, char *handle, char *message) +{ + struct skype_buddy_ask_data *bla = g_new0( struct skype_buddy_ask_data, 1 ); + char *buf; + + bla->ic = ic; + bla->handle = g_strdup(handle); + + buf = g_strdup_printf( "The user %s wants to add you to his/her buddy list, saying: '%s'.", handle, message); + imcb_ask( ic, buf, bla, skype_buddy_ask_yes, skype_buddy_ask_no ); + g_free( buf ); +} + static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition cond ) { struct im_connection *ic = data; @@ -132,6 +169,22 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c imcb_buddy_status(ic, ptr, flags, NULL, NULL); g_free(ptr); } + else if(!strncmp(ptr, "RECEIVEDAUTHREQUEST ", 20)) + { + char *message = ptr + 20; + if(strlen(message)) + skype_buddy_ask(ic, user, message); + } + else if(!strncmp(ptr, "BUDDYSTATUS ", 12)) + { + char *st = ptr + 12; + if(!strcmp(st, "3")) + { + char *buf = g_strdup_printf("%s@skype.com", user); + imcb_add_buddy(ic, buf, NULL); + g_free(buf); + } + } } else if(!strncmp(line, "CHATMESSAGE ", 12)) { -- cgit v1.2.3 From 89332c580392bc6bac4b68d3e409b03c93a0000d Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 16:17:33 +0200 Subject: remove question about imcb_remove_buddy() quoting jabber/iq.c: /* Don't have any API call for this yet! So let's just try to handle this as well as we can. */ and we already do this (setting userstatus to offline) --- skype/README | 3 --- 1 file changed, 3 deletions(-) diff --git a/skype/README b/skype/README index ea918a84..b11e7e85 100644 --- a/skype/README +++ b/skype/README @@ -103,9 +103,6 @@ NOTE: the option is not used currently. - implement block/allow commands -- when you remove a nick, it'll still shown as being offline (no - `imcb_remove_buddy()`?) - == I would like to have support for ... If something does not work and it's not in the TODO section, then please contact me! -- cgit v1.2.3 From dd8163ebbde5b38fb59c6b73b304a24465b5d2b6 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 18:39:07 +0200 Subject: block/allow commands needs 0 protocl-specific implementation ;) --- skype/README | 2 -- 1 file changed, 2 deletions(-) diff --git a/skype/README b/skype/README index b11e7e85..c3716917 100644 --- a/skype/README +++ b/skype/README @@ -101,8 +101,6 @@ NOTE: the option is not used currently. == What needs to be done (aka. TODO) -- implement block/allow commands - == I would like to have support for ... If something does not work and it's not in the TODO section, then please contact me! -- cgit v1.2.3 From 7daec06ebeafa481e57ef99f558cdf9f05f0d8c4 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 19:02:11 +0200 Subject: cosmetics - add copyright header - beautify comments - remove debug printf()s --- skype/skype.c | 103 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 37 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index ab4e05eb..eb718c3d 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -1,16 +1,38 @@ -/* - * This is the most simple possible BitlBee plugin. To use, compile it as - * a shared library and place it in the plugin directory: +/* + * skype.c - Skype plugin for BitlBee + * + * Copyright (c) 2007 by Miklos Vajna * - * gcc -o example.so -shared example.c `pkg-config --cflags bitlbee` - * cp example.so /usr/local/lib/bitlbee + * Several ideas are used from the BitlBee Jabber plugin, which is + * + * Copyright (c) 2006 by Wilmer van der Gaast + * + * 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. */ + #include #include #include #define SKYPE_PORT_DEFAULT "2727" +/* + * Structures + */ + struct skype_data { struct im_connection *ic; @@ -19,9 +41,9 @@ struct skype_data char *txq; int tx_len; int r_inpa, w_inpa; - // when we receive a new message id, we query the handle, then the body - // store the handle here - // TODO: it would be nicer to use a hashmap for this or something + /* When we receive a new message id, we query the handle, then the + * body. Store the handle here so that we imcb_buddy_msg() when we got + * the body. */ char *handle; }; @@ -31,6 +53,16 @@ struct skype_away_state char *full_name; }; +struct skype_buddy_ask_data +{ + struct im_connection *ic; + char *handle; +}; + +/* + * Tables + */ + const struct skype_away_state skype_away_state_list[] = { { "ONLINE", "Online" }, @@ -43,11 +75,9 @@ const struct skype_away_state skype_away_state_list[] = { NULL, NULL} }; -struct skype_buddy_ask_data -{ - struct im_connection *ic; - char *handle; -}; +/* + * Functions + */ static void skype_init( account_t *acc ) { @@ -68,6 +98,8 @@ int skype_write( struct im_connection *ic, char *buf, int len ) pfd[0].fd = sd->fd; pfd[0].events = POLLOUT; + /* This poll is necessary or we'll get a SIGPIPE when we write() to + * sd->fd. */ poll(pfd, 1, 1000); if(pfd[0].revents & POLLHUP) { @@ -75,7 +107,6 @@ int skype_write( struct im_connection *ic, char *buf, int len ) imc_logout( ic, TRUE ); return FALSE; } - printf("write(): %s", buf); write( sd->fd, buf, len ); return TRUE; @@ -122,18 +153,18 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if( !sd || sd->fd == -1 ) return FALSE; + /* Read the whole data. */ st = read( sd->fd, buf, sizeof( buf ) ); if( st > 0 ) { buf[st] = '\0'; - printf("read(): '%s'\n", buf); + /* Then split it up to lines. */ lines = g_strsplit(buf, "\n", 0); lineptr = lines; while((line = *lineptr)) { if(!strlen(line)) break; - printf("skype_read_callback() new line: '%s'\n", line); if(!strncmp(line, "USERS ", 6)) { char **i; @@ -158,7 +189,9 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c ptr = strchr(++user, ' '); *ptr = '\0'; ptr++; - if(!strncmp(ptr, "ONLINESTATUS ", 13) && strcmp(user, sd->username) != 0 && strcmp(user, "echo123") != 0) + if(!strncmp(ptr, "ONLINESTATUS ", 13) && + strcmp(user, sd->username) != 0 + && strcmp(user, "echo123") != 0) { ptr = g_strdup_printf("%s@skype.com", user); imcb_add_buddy(ic, ptr, NULL); @@ -196,8 +229,11 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c info++; if(!strcmp(info, "STATUS RECEIVED")) { - // new message, request its body - printf("new received message #%s\n", id); + /* New message ID: + * (1) Request its from field + * (2) Request its body + * (3) Mark it as seen + */ g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id); skype_write( ic, buf, strlen( buf ) ); g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); @@ -208,19 +244,22 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c else if(!strncmp(info, "FROM_HANDLE ", 12)) { info += 12; - // new handle + /* New from field value. Store + * it, then we can later use it + * when we got the message's + * body. */ sd->handle = g_strdup_printf("%s@skype.com", info); - printf("new handle: '%s'\n", info); } else if(!strncmp(info, "BODY ", 5)) { info += 5; - // new body - printf("<%s> %s\n", sd->handle, info); if(sd->handle) + { + /* New body, we have everything to use imcb_buddy_msg() now! */ imcb_buddy_msg(ic, sd->handle, info, 0, 0); - g_free(sd->handle); - sd->handle = NULL; + g_free(sd->handle); + sd->handle = NULL; + } } } } @@ -237,8 +276,6 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c imc_logout( ic, TRUE ); return FALSE; } - - /* EAGAIN/etc or a successful read. */ return TRUE; } @@ -254,7 +291,7 @@ gboolean skype_start_stream( struct im_connection *ic ) if( sd->r_inpa <= 0 ) sd->r_inpa = b_input_add( sd->fd, GAIM_INPUT_READ, skype_read_callback, ic ); - // download buddies + /* This will download all buddies. */ buf = g_strdup_printf("SEARCH FRIENDS\n"); st = skype_write( ic, buf, strlen( buf ) ); g_free(buf); @@ -279,12 +316,7 @@ static void skype_login( account_t *acc ) ic->proto_data = sd; imcb_log( ic, "Connecting" ); - printf("%s:%d\n", acc->server, set_getint( &acc->set, "port")); sd->fd = proxy_connect(acc->server, set_getint( &acc->set, "port" ), skype_connected, ic ); - printf("sd->fd: %d\n", sd->fd); - /*imcb_add_buddy(ic, "test@skype.com", NULL); - imcb_buddy_status(ic, "test@skype.com", OPT_LOGGED_IN, NULL, NULL); - imcb_buddy_msg(ic, "test@skype.com", "test from skype plugin", 0, 0);*/ sd->username = g_strdup( acc->user ); sd->ic = ic; @@ -342,7 +374,6 @@ static void skype_set_away( struct im_connection *ic, char *state_txt, char *mes state = skype_away_state_by_name( "Away" ); else state = skype_away_state_by_name( state_txt ); - printf("would set to: '%s'\n", state->code); buf = g_strdup_printf("SET USERSTATUS %s\n", state->code); skype_write( ic, buf, strlen( buf ) ); g_free(buf); @@ -369,7 +400,6 @@ static void skype_add_buddy( struct im_connection *ic, char *who, char *group ) *ptr = '\0'; buf = g_strdup_printf("SET USER %s BUDDYSTATUS 2 Please authorize me\n", nick); skype_write( ic, buf, strlen( buf ) ); - printf("add '%s'\n", nick); g_free(nick); } @@ -383,7 +413,6 @@ static void skype_remove_buddy( struct im_connection *ic, char *who, char *group *ptr = '\0'; buf = g_strdup_printf("SET USER %s BUDDYSTATUS 1\n", nick); skype_write( ic, buf, strlen( buf ) ); - printf("remove '%s'\n", nick); g_free(nick); } @@ -396,8 +425,8 @@ void init_plugin(void) ret->init = skype_init; ret->logout = skype_logout; ret->buddy_msg = skype_buddy_msg; - ret->set_away = skype_set_away; ret->away_states = skype_away_states; + ret->set_away = skype_set_away; ret->add_buddy = skype_add_buddy; ret->remove_buddy = skype_remove_buddy; ret->handle_cmp = g_strcasecmp; -- cgit v1.2.3 From b8b0bfd35dcd26c33c86a4a3a54897084f253582 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 19:39:43 +0200 Subject: mention a bit more patches --- skype/README | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/skype/README b/skype/README index c3716917..ed3506ae 100644 --- a/skype/README +++ b/skype/README @@ -17,18 +17,18 @@ connect to it, finally BitlBee can connect to `skyped`. bzr branch http://code.bitlbee.org/bitlbee/ ---- -- You need to enable plugin support: +- You need some additional patches: ---- http://frugalware.org/~vmiklos/patches/bitlbee-configure-plugins.patch ----- - -- To be able to do an install-dev: - ----- +http://frugalware.org/~vmiklos/patches/bitlbee-global-conf-may-be-null.patch http://frugalware.org/~vmiklos/patches/bitlbee-makefile-headers.patch +http://frugalware.org/~vmiklos/patches/bitlbee-more-verbose-on-plugin-errors.patch ---- +(Yes, I submitted all of them to the +http://bugs.bitlbee.org/bitlbee/[bugtracker] already.) + - Now compile and install it: ---- -- cgit v1.2.3 From 56e4ac49b580773b7b7e67199f11a1b30b102ead Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 19:44:38 +0200 Subject: preface --- skype/README | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/skype/README b/skype/README index ed3506ae..c7ee6e18 100644 --- a/skype/README +++ b/skype/README @@ -1,6 +1,15 @@ = Skype plugin for BitlBee Miklos Vajna +== Status + +One day I browsed the BitlBee bugtracker and found +http://bugs.bitlbee.org/bitlbee/ticket/82[this] ticket. Then after a while I +returned and saw that it's still open. So I wrote it. Not a big deal, I wrote +it in two days or so (and not because I'm a genius or anything ;-) ). I think +it's pretty stable, but it needs wider testing. Also see the 'Known bugs' +section, I really hope those random hangups will be fixed soon by Skype. + == How to set it up Before you start. The setup is the following: BitlBee can't connect directly to -- cgit v1.2.3 From 56b5647801b9993f8ad622bce082050b9ba90e4f Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 19:45:17 +0200 Subject: typo --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index c7ee6e18..9e4dc216 100644 --- a/skype/README +++ b/skype/README @@ -5,7 +5,7 @@ Miklos Vajna One day I browsed the BitlBee bugtracker and found http://bugs.bitlbee.org/bitlbee/ticket/82[this] ticket. Then after a while I -returned and saw that it's still open. So I wrote it. Not a big deal, I wrote +returned and saw that it was still open. So I wrote it. Not a big deal, I wrote it in two days or so (and not because I'm a genius or anything ;-) ). I think it's pretty stable, but it needs wider testing. Also see the 'Known bugs' section, I really hope those random hangups will be fixed soon by Skype. -- cgit v1.2.3 From 877b6f4e6a10e17af08f5bd8ebc93a25d4d9201c Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 19:46:40 +0200 Subject: cleanup in struct skype_data --- skype/skype.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index eb718c3d..a3fec187 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -38,9 +38,7 @@ struct skype_data struct im_connection *ic; char *username; int fd; - char *txq; - int tx_len; - int r_inpa, w_inpa; + int r_inpa; /* When we receive a new message id, we query the handle, then the * body. Store the handle here so that we imcb_buddy_msg() when we got * the body. */ -- cgit v1.2.3 From 75742cc12cf9c59e6b62cf499b62007a00a27603 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 19:51:06 +0200 Subject: link the api docs --- skype/README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/skype/README b/skype/README index 9e4dc216..04989cd6 100644 --- a/skype/README +++ b/skype/README @@ -10,6 +10,9 @@ it in two days or so (and not because I'm a genius or anything ;-) ). I think it's pretty stable, but it needs wider testing. Also see the 'Known bugs' section, I really hope those random hangups will be fixed soon by Skype. +Oh, before I forget. I'm not a wizard, the Skype API documentation is +https://developer.skype.com/Docs/ApiDoc[here] if you're interested. + == How to set it up Before you start. The setup is the following: BitlBee can't connect directly to -- cgit v1.2.3 From 9a4bb33ae748c2221b6eedda24d7defbcdfdef39 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 20:12:37 +0200 Subject: HACKING --- skype/HACKING | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 skype/HACKING diff --git a/skype/HACKING b/skype/HACKING new file mode 100644 index 00000000..e98d9165 --- /dev/null +++ b/skype/HACKING @@ -0,0 +1,8 @@ +I use the following commands to debug bitlbee itself: + +gdb bitlbee +run -v -n -D + +For skyped: + +python skyped.py -d -- cgit v1.2.3 From cd3022cce128e4ff995bd7d76b3013d1909b3332 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 20:18:08 +0200 Subject: skyped: added copyright header --- skype/skyped.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/skype/skyped.py b/skype/skyped.py index d86fca7b..ff275a15 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -1,4 +1,30 @@ #!/usr/bin/env python +# +# skyped.py +# +# Copyright (c) 2007 by Miklos Vajna +# +# It uses several code from a very basic python CLI interface, available at: +# +# http://forum.skype.com/index.php?showtopic=42640 +# +# 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. +# + +# makepkg configuration """ GPL """ import sys import signal -- cgit v1.2.3 From dfec37e7eac14102c6d127b77484cf0eb717eea0 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 20:20:59 +0200 Subject: add a simple skyped client for testing purposes --- skype/Makefile | 2 ++ skype/client.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 skype/client.c diff --git a/skype/Makefile b/skype/Makefile index 1f682f7c..00cc533f 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -4,6 +4,8 @@ LDFLAGS += $(shell pkg-config --libs bitlbee) skype.so: skype.c gcc -o skype.so -shared skype.c $(CFLAGS) +client: client.c + clean: rm -f skype.so diff --git a/skype/client.c b/skype/client.c new file mode 100644 index 00000000..66a3f770 --- /dev/null +++ b/skype/client.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define MESSAGE_LEN 1023 +#define PORTNUM 2727 + +char *invoke(int sock, char *cmd) +{ + char buf[MESSAGE_LEN+1]; + int len; + + write(sock, cmd, strlen(cmd)); + len = recv(sock, buf, MESSAGE_LEN, 0); + buf[len] = '\0'; + return strdup(buf); +} + +int main(int argc, char *argv[]) +{ + int sock; + struct sockaddr_in dest; + char *ptr; + + sock = socket(AF_INET, SOCK_STREAM, 0); + + memset(&dest, 0, sizeof(dest)); + dest.sin_family = AF_INET; + dest.sin_addr.s_addr = inet_addr("127.0.0.1"); + dest.sin_port = htons(PORTNUM); + + connect(sock, (struct sockaddr *)&dest, sizeof(struct sockaddr)); + + ptr = invoke(sock, "SET USER foo ISAUTHORIZED FALSE"); + printf("ptr: '%s'\n", ptr); + close(sock); + return(0); +} -- cgit v1.2.3 From bff265c81bf79b535841ac5774472cb82cd762f0 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 20:46:27 +0200 Subject: new prepare and distclean targets --- skype/Makefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index 00cc533f..2cbf41c8 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,14 +1,22 @@ -CFLAGS += $(shell pkg-config --cflags bitlbee) -g -Wall -LDFLAGS += $(shell pkg-config --libs bitlbee) +-include config.mak skype.so: skype.c - gcc -o skype.so -shared skype.c $(CFLAGS) + $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) client: client.c +prepare: configure.ac + cp /usr/share/automake/install-sh ./ + cp /usr/share/aclocal/pkg.m4 aclocal.m4 + autoconf + clean: rm -f skype.so +distclean: clean + rm -rf autom4te.cache config.log config.mak config.status + rm -f configure install-sh aclocal.m4 + doc: HEADER.html Changelog HEADER.html: README -- cgit v1.2.3 From 68312b81a0adc34e5d868b447393af0ea1fb3ffe Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 20:46:37 +0200 Subject: import configure.ac and config.mak.in --- skype/config.mak.in | 6 ++++++ skype/configure.ac | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 skype/config.mak.in create mode 100644 skype/configure.ac diff --git a/skype/config.mak.in b/skype/config.mak.in new file mode 100644 index 00000000..06dd386a --- /dev/null +++ b/skype/config.mak.in @@ -0,0 +1,6 @@ +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ +INSTALL = @INSTALL@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +libdir = @libdir@ diff --git a/skype/configure.ac b/skype/configure.ac new file mode 100644 index 00000000..36c4fdcd --- /dev/null +++ b/skype/configure.ac @@ -0,0 +1,18 @@ +AC_INIT([Skype plugin for BitlBee], 1.0, [vmiklos@frugalware.org], bitlbee-skype) +AC_PROG_CC +AC_PROG_INSTALL + +AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Enable debug support (default: disabled)]), debug=yes) +AC_MSG_CHECKING(for debug mode request) +if test x$debug = xyes ; then + CFLAGS="-g -Wall -Werror" + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi + +dnl Check for bitlbee +PKG_CHECK_MODULES(BITLBEE, bitlbee) +CFLAGS="$CFLAGS $BITLBEE_CFLAGS" +LDFLAGS="$LDFLAGS $BITLBEE_LIBS" +AC_OUTPUT(config.mak) -- cgit v1.2.3 From bbf1050bd9dc9b92372750aba8dd28d464d247f9 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 20:50:09 +0200 Subject: added an install target --- skype/Makefile | 6 +++++- skype/config.mak.in | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 2cbf41c8..c5e8074f 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,8 +1,12 @@ -include config.mak -skype.so: skype.c +skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) +install: skype.so + $(INSTALL) -d $(DESTDIR)$(plugindir) + $(INSTALL) skype.so $(DESTDIR)$(plugindir) + client: client.c prepare: configure.ac diff --git a/skype/config.mak.in b/skype/config.mak.in index 06dd386a..7a16cbb1 100644 --- a/skype/config.mak.in +++ b/skype/config.mak.in @@ -4,3 +4,4 @@ INSTALL = @INSTALL@ prefix = @prefix@ exec_prefix = @exec_prefix@ libdir = @libdir@ +plugindir = ${libdir}/bitlbee -- cgit v1.2.3 From 8e3058bc70420a21393769de5e98b552bbf16acc Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 20:51:55 +0200 Subject: update documentation for buildsystem changes --- skype/README | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index 04989cd6..6c3bb605 100644 --- a/skype/README +++ b/skype/README @@ -44,7 +44,7 @@ http://bugs.bitlbee.org/bitlbee/[bugtracker] already.) - Now compile and install it: ---- -./configure --prefix=/usr +./configure make make install install-dev ---- @@ -58,8 +58,10 @@ git clone http://ftp.frugalware.org/pub/other/people/vmiklos/bitlbee-skype - Compile and install it: ---- +make prepare +./configure make -cp skype.so /usr/lib/bitlbee +make install ---- - Start skyped (the tcp server): -- cgit v1.2.3 From 2fcad6ee4986bc01d2c526ed84912519d111fa0e Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 20:55:32 +0200 Subject: make install installs skyped --- skype/Makefile | 4 +++- skype/README | 7 +++++-- skype/config.mak.in | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index c5e8074f..34d56c88 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -3,9 +3,11 @@ skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) -install: skype.so +install: skype.so skyped.py $(INSTALL) -d $(DESTDIR)$(plugindir) + $(INSTALL) -d $(DESTDIR)$(sbindir) $(INSTALL) skype.so $(DESTDIR)$(plugindir) + $(INSTALL) skyped.py $(DESTDIR)$(sbindir)/skyped client: client.c diff --git a/skype/README b/skype/README index 6c3bb605..9e4ee474 100644 --- a/skype/README +++ b/skype/README @@ -64,10 +64,11 @@ make make install ---- -- Start skyped (the tcp server): +- Start Skype and `skyped` (the tcp server): ---- -python skyped.py +skype +skyped ---- NOTE: It's important to start skyped on the same machine and using the same @@ -115,6 +116,8 @@ NOTE: the option is not used currently. == What needs to be done (aka. TODO) +- `--daemon` option for `skyped` + == I would like to have support for ... If something does not work and it's not in the TODO section, then please contact me! diff --git a/skype/config.mak.in b/skype/config.mak.in index 7a16cbb1..cfdafe82 100644 --- a/skype/config.mak.in +++ b/skype/config.mak.in @@ -3,5 +3,6 @@ LDFLAGS = @LDFLAGS@ INSTALL = @INSTALL@ prefix = @prefix@ exec_prefix = @exec_prefix@ +sbindir = @sbindir@ libdir = @libdir@ plugindir = ${libdir}/bitlbee -- cgit v1.2.3 From 05c1bedaec6ee8ae71b311892e8287647095f3a0 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 21:01:49 +0200 Subject: added new dist and release targets --- skype/Makefile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/skype/Makefile b/skype/Makefile index 34d56c88..9a451ec9 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,5 +1,7 @@ -include config.mak +VERSION = 0.1.0 + skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) @@ -23,6 +25,21 @@ distclean: clean rm -rf autom4te.cache config.log config.mak config.status rm -f configure install-sh aclocal.m4 +dist: + git-archive --format=tar --prefix=bitlbee-skype-$(VERSION)/ HEAD > bitlbee-skype-$(VERSION).tar + mkdir -p bitlbee-skype-$(VERSION) + git log --no-merges |git name-rev --tags --stdin > bitlbee-skype-$(VERSION)/Changelog + tar rf bitlbee-skype-$(VERSION).tar bitlbee-skype-$(VERSION)/Changelog + rm -rf bitlbee-skype-$(VERSION) + gzip -f -9 bitlbee-skype-$(VERSION).tar + +release: + git tag $(VERSION) + $(MAKE) dist + gpg --comment "See http://ftp.frugalware.org/pub/README.GPG for info" \ + -ba -u 20F55619 bitlbee-skype-$(VERSION).tar.gz + mv bitlbee-skype-$(VERSION).tar.gz{,.asc} ../ + doc: HEADER.html Changelog HEADER.html: README -- cgit v1.2.3 From 7e600c9fe75a14aba48cc23fcc4092e5ecece57e Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 21:02:55 +0200 Subject: update changelog target to include tags --- skype/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 9a451ec9..f0305a70 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -48,4 +48,4 @@ HEADER.html: README rm HEADER.txt Changelog: .git/refs/heads/master - git log --no-merges > Changelog + git log --no-merges |git name-rev --tags --stdin >Changelog -- cgit v1.2.3 From 04064b6b739839ae389948e275652d8e0659e0a6 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 21:04:13 +0200 Subject: do not more the generated tarball/signature --- skype/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index f0305a70..ee411071 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -38,7 +38,6 @@ release: $(MAKE) dist gpg --comment "See http://ftp.frugalware.org/pub/README.GPG for info" \ -ba -u 20F55619 bitlbee-skype-$(VERSION).tar.gz - mv bitlbee-skype-$(VERSION).tar.gz{,.asc} ../ doc: HEADER.html Changelog -- cgit v1.2.3 From 127966f9709beddff018657dcc5dd78b2cbf9cee Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 21:09:47 +0200 Subject: fix dist target --- skype/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/skype/Makefile b/skype/Makefile index ee411071..4cf9ef56 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -29,6 +29,7 @@ dist: git-archive --format=tar --prefix=bitlbee-skype-$(VERSION)/ HEAD > bitlbee-skype-$(VERSION).tar mkdir -p bitlbee-skype-$(VERSION) git log --no-merges |git name-rev --tags --stdin > bitlbee-skype-$(VERSION)/Changelog + make -C bitlbee-skype-$(VERSION) prepare tar rf bitlbee-skype-$(VERSION).tar bitlbee-skype-$(VERSION)/Changelog rm -rf bitlbee-skype-$(VERSION) gzip -f -9 bitlbee-skype-$(VERSION).tar -- cgit v1.2.3 From 1c3f19fea2f75bc8d5f644b75fb3b0118a840e27 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 21:12:00 +0200 Subject: erm, now really --- skype/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index 4cf9ef56..2b549283 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -26,13 +26,12 @@ distclean: clean rm -f configure install-sh aclocal.m4 dist: - git-archive --format=tar --prefix=bitlbee-skype-$(VERSION)/ HEAD > bitlbee-skype-$(VERSION).tar + git-archive --format=tar --prefix=bitlbee-skype-$(VERSION)/ HEAD | tar xf - mkdir -p bitlbee-skype-$(VERSION) git log --no-merges |git name-rev --tags --stdin > bitlbee-skype-$(VERSION)/Changelog make -C bitlbee-skype-$(VERSION) prepare - tar rf bitlbee-skype-$(VERSION).tar bitlbee-skype-$(VERSION)/Changelog + tar czf bitlbee-skype-$(VERSION).tar.gz bitlbee-skype-$(VERSION) rm -rf bitlbee-skype-$(VERSION) - gzip -f -9 bitlbee-skype-$(VERSION).tar release: git tag $(VERSION) -- cgit v1.2.3 From 11eed8f006d66b9904c932d541f7c18bc4ea4288 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 21:17:08 +0200 Subject: mention the fpms --- skype/README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skype/README b/skype/README index 9e4ee474..2cd86ae2 100644 --- a/skype/README +++ b/skype/README @@ -23,6 +23,10 @@ package) and `skyped` will connecto to your Skype client. NOTE: The order is important. First you have to start Skype. Then `skyped` can connect to it, finally BitlBee can connect to `skyped`. +- If you happen to be a happy Frugalware user, you can install the `bitlbee` + and `bitlbee-skype` packages from + http://ftp.frugalware.org/pub/other/people/vmiklos/bmf/[my repo]. + - You need the BitlBee bzr branch: ---- -- cgit v1.2.3 From 0ac1b3e0a5ad6c2d3ecca685f80a30ba1ebc95e3 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 21:20:16 +0200 Subject: more todo --- skype/README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/README b/skype/README index 2cd86ae2..4795fa84 100644 --- a/skype/README +++ b/skype/README @@ -122,6 +122,8 @@ NOTE: the option is not used currently. - `--daemon` option for `skyped` +- document how do I run skype on a server using vnc + == I would like to have support for ... If something does not work and it's not in the TODO section, then please contact me! -- cgit v1.2.3 From 395317200aad6fd04e3355477b8d5fcb1caa45f8 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 23:37:43 +0200 Subject: skyped: automatically reconnect if skype is restarted well, not 100% perfect because we detect the error when we send something. but far better than writing to devnull forever ;) --- skype/skyped.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index ff275a15..12767bdc 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -85,7 +85,10 @@ class SkypeApi(dbus.service.Object): sys.exit('Could not bind to Skype client') reply = self.send('PROTOCOL 5') - dbus.service.Object.__init__(self, bus, "/com/Skype/Client", bus_name='com.Skype.API') + try: + dbus.service.Object.__init__(self, bus, "/com/Skype/Client", bus_name='com.Skype.API') + except KeyError: + sys.exit() # skype -> client (async) @dbus.service.method(dbus_interface='com.Skype.API') @@ -104,13 +107,17 @@ class SkypeApi(dbus.service.Object): reply = self.skype_api.Invoke(msg_text) except dbus.exceptions.DBusException, s: reply = str(s) + if(reply.startswith("org.freedesktop.DBus.Error.ServiceUnknown")): + self.remove_from_connection(dbus.SessionBus(), "/com/Skype/Client") + mainloop.quit() dprint('<< ' + reply) return reply if __name__=='__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) - skype = SkypeApi() signal.signal(signal.SIGINT, sig_handler) mainloop = gobject.MainLoop() server('localhost', 2727) - mainloop.run() + while True: + skype = SkypeApi() + mainloop.run() -- cgit v1.2.3 From 64f8b8eaa606f207a03773082d8c9c6f2d8360dd Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 21 Aug 2007 23:42:33 +0200 Subject: document 3db5410 --- skype/README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 4795fa84..7fc2efe6 100644 --- a/skype/README +++ b/skype/README @@ -21,7 +21,8 @@ In fact BitlBee will connect to `skyped` (a tcp server, provided in this package) and `skyped` will connecto to your Skype client. NOTE: The order is important. First you have to start Skype. Then `skyped` can -connect to it, finally BitlBee can connect to `skyped`. +connect to it, finally BitlBee can connect to `skyped`. (In fact `skyped` +automatically reconnect if you restart Skype.) - If you happen to be a happy Frugalware user, you can install the `bitlbee` and `bitlbee-skype` packages from -- cgit v1.2.3 From 924d0f2ec83887db9ff5c4cf5ded78c29135a9b5 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 22 Aug 2007 00:07:39 +0200 Subject: import NEWS --- skype/NEWS | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 skype/NEWS diff --git a/skype/NEWS b/skype/NEWS new file mode 100644 index 00000000..40e77a93 --- /dev/null +++ b/skype/NEWS @@ -0,0 +1,5 @@ +VERSION DESCRIPTION +----------------------------------------------------------------------------- + - skyped now automatically reconnects on Skype restarts +0.1.0 - initial release + - see README for major features -- cgit v1.2.3 From 8237df502bc3559c4828708e933bb5e5b9632aa9 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 22 Aug 2007 00:33:14 +0200 Subject: skyped: added daemon code --- skype/HACKING | 4 ++-- skype/NEWS | 1 + skype/README | 2 -- skype/skyped.py | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 63 insertions(+), 8 deletions(-) diff --git a/skype/HACKING b/skype/HACKING index e98d9165..037be98f 100644 --- a/skype/HACKING +++ b/skype/HACKING @@ -1,8 +1,8 @@ I use the following commands to debug bitlbee itself: -gdb bitlbee +gdb ./bitlbee run -v -n -D For skyped: -python skyped.py -d +python skyped.py -n -d diff --git a/skype/NEWS b/skype/NEWS index 40e77a93..978c014c 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,6 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- + - skyped now runs as daemon in the background by default - skyped now automatically reconnects on Skype restarts 0.1.0 - initial release - see README for major features diff --git a/skype/README b/skype/README index 7fc2efe6..0b62113d 100644 --- a/skype/README +++ b/skype/README @@ -121,8 +121,6 @@ NOTE: the option is not used currently. == What needs to be done (aka. TODO) -- `--daemon` option for `skyped` - - document how do I run skype on a server using vnc == I would like to have support for ... diff --git a/skype/skyped.py b/skype/skyped.py index 12767bdc..6cf542e0 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -24,9 +24,8 @@ # USA. # -# makepkg configuration -""" GPL """ import sys +import os import signal import locale import time @@ -35,7 +34,9 @@ import dbus.service import dbus.mainloop.glib import gobject import socket +import getopt +__version__ = "0.1.1" SKYPE_SERVICE = 'com.Skype.API' CLIENT_NAME = 'SkypeApiPythonShell' @@ -69,7 +70,9 @@ def listener(sock, *args): return True def dprint(msg): - if len(sys.argv) > 1 and sys.argv[1] == "-d": + global options + + if options.debug: print msg class SkypeApi(dbus.service.Object): @@ -113,11 +116,64 @@ class SkypeApi(dbus.service.Object): dprint('<< ' + reply) return reply +class Options: + def __init__(self): + self.daemon = True + self.debug = False + self.help = False + self.port = 2727 + self.version = False + + def usage(self, ret): + print """Usage: skyped [OPTION]... + +skyped is a daemon that acts as a tcp server on top of a Skype instance. + +Options: + -d --debug enable debug messages + -h --help this help + -n --nofork don't run as daemon in the background + -p --port set the tcp port (default: %d) + -v --version display version information""" % self.port + sys.exit(ret) + if __name__=='__main__': + options = Options() + try: + opts, args = getopt.getopt(sys.argv[1:], "dhnp:v", ["daemon", "help", "nofork", "port=", "version"]) + except getopt.GetoptError: + options.usage(1) + for opt, arg in opts: + if opt in ("-d", "--debug"): + options.debug = True + elif opt in ("-h", "--help"): + options.help = True + elif opt in ("-n", "--nofork"): + options.daemon = False + elif opt in ("-p", "--port"): + options.port = arg + elif opt in ("-v", "--version"): + options.version = True + if options.help: + options.usage(0) + elif options.version: + print "skyped %s" % __version__ + sys.exit(0) + elif options.daemon: + pid = os.fork() + if pid == 0: + nullin = file('/dev/null', 'r') + nullout = file('/dev/null', 'w') + os.dup2(nullin.fileno(), sys.stdin.fileno()) + os.dup2(nullout.fileno(), sys.stdout.fileno()) + os.dup2(nullout.fileno(), sys.stderr.fileno()) + else: + print 'skyped is started on port %s, pid: %d' % (options.port, pid) + sys.exit(0) dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) signal.signal(signal.SIGINT, sig_handler) mainloop = gobject.MainLoop() - server('localhost', 2727) + server('localhost', options.port) while True: skype = SkypeApi() mainloop.run() -- cgit v1.2.3 From 43e2e9d61306e93c8435de5bba6a631a942645cd Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 22 Aug 2007 00:52:53 +0200 Subject: skyped: fix a warning --- skype/skyped.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index 6cf542e0..1a2d3c25 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -111,7 +111,10 @@ class SkypeApi(dbus.service.Object): except dbus.exceptions.DBusException, s: reply = str(s) if(reply.startswith("org.freedesktop.DBus.Error.ServiceUnknown")): - self.remove_from_connection(dbus.SessionBus(), "/com/Skype/Client") + try: + self.remove_from_connection(dbus.SessionBus(), "/com/Skype/Client") + except LookupError: + pass mainloop.quit() dprint('<< ' + reply) return reply -- cgit v1.2.3 From 025da7a0aa83fea9032950983610f86b1b3d0e9b Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 22 Aug 2007 01:24:19 +0200 Subject: updates for 0.1.1 --- skype/Makefile | 2 +- skype/NEWS | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index 2b549283..9bd84160 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.1.0 +VERSION = 0.1.1 skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) diff --git a/skype/NEWS b/skype/NEWS index 978c014c..8a89c140 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,6 +1,6 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- - - skyped now runs as daemon in the background by default +0.1.1 - skyped now runs as daemon in the background by default - skyped now automatically reconnects on Skype restarts 0.1.0 - initial release - see README for major features -- cgit v1.2.3 From c24ae8ea799dabb93fccffd6ee8fbd9a8da95085 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 22 Aug 2007 01:40:06 +0200 Subject: add a .gitignore --- skype/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 skype/.gitignore diff --git a/skype/.gitignore b/skype/.gitignore new file mode 100644 index 00000000..0bd951be --- /dev/null +++ b/skype/.gitignore @@ -0,0 +1,4 @@ +Changelog +HEADER.html +*.gz +*.asc -- cgit v1.2.3 From 23b84e11715e7c743e56d4a10efe603131761bf6 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 22 Aug 2007 02:22:52 +0200 Subject: document the vnc server setup --- skype/README | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index 0b62113d..f2a65d27 100644 --- a/skype/README +++ b/skype/README @@ -91,6 +91,40 @@ yourself joining to `&bitlbee`. NOTE: the option is not used currently. +== Setting up Skype in a VNC server (optional) + +Optionally, if you want to run Skype on a server, you might want to setup up +a VNC server as well. I used `tightvnc` but probably other VNC servers will +work, too. + +First run + +---- +vncpasswd ~/.vnc/passwd +---- + +and create a password. You will need it at least once. + +Now create `~/.vnc/xstartup` with the following contents: + +---- +#!/bin/sh + +/usr/bin/sleep 1 +/usr/bin/skype & +/usr/bin/sleep 5 +/usr/sbin/skyped +---- + +Then start the server: + +---- +vncserver +---- + +Then connect to it, and set up Skype (username, password, enable autologin, and +allow the `SkypeApiPythonShell` client when Skype asks about it). + == What works - Download nicks and away statuses from Skype @@ -121,11 +155,16 @@ NOTE: the option is not used currently. == What needs to be done (aka. TODO) -- document how do I run skype on a server using vnc +- Empty? No, this is not possible. I need more testers! :-) == I would like to have support for ... -If something does not work and it's not in the TODO section, then please contact me! +If something does not work and it's not in the TODO section, then please +contact me! + +In fact, of course, I wrote this documentation after figured out how to do this +setup, so maybe I left out some steps. If you needed 'any' additional tricks, +then it would be nice to include them here. == Known bugs -- cgit v1.2.3 From 57087df72ba6c12ba8e7b9d27a99118d78e3f784 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 22 Aug 2007 02:25:25 +0200 Subject: oops, missing chmod +x --- skype/README | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/skype/README b/skype/README index f2a65d27..8f4ce62d 100644 --- a/skype/README +++ b/skype/README @@ -116,6 +116,12 @@ Now create `~/.vnc/xstartup` with the following contents: /usr/sbin/skyped ---- +Adjust the permissions: + +---- +chmod +x ~/.vnc/xstartup +---- + Then start the server: ---- -- cgit v1.2.3 From ecfbc5d8c2266b0e63a3ff5bfdec93a22984f950 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 22 Aug 2007 18:12:28 +0200 Subject: skype_read_callback(): add notification about calls --- skype/skype.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index a3fec187..5e48fe1e 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -261,6 +261,26 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } } } + else if(!strncmp(line, "CALL ", 5)) + { + char *id = strchr(line, ' '); + if(++id) + { + char *info = strchr(id, ' '); + *info = '\0'; + info++; + if(!strcmp(info, "STATUS RINGING")) + { + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write( ic, buf, strlen( buf ) ); + } + else if(!strncmp(info, "PARTNER_HANDLE ", 15)) + { + info += 15; + imcb_log(ic, "The user %s is currently ringing you.", info); + } + } + } lineptr++; } g_strfreev(lines); -- cgit v1.2.3 From 99426f0428015d8b8bb851b47646baa939c047bf Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 22 Aug 2007 18:21:13 +0200 Subject: fix repo url --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 8f4ce62d..74e44823 100644 --- a/skype/README +++ b/skype/README @@ -57,7 +57,7 @@ make install install-dev - Get the plugin code: ---- -git clone http://ftp.frugalware.org/pub/other/people/vmiklos/bitlbee-skype +git clone http://ftp.frugalware.org/pub/other/people/vmiklos/bitlbee-skype/.git ---- - Compile and install it: -- cgit v1.2.3 From bbba374a5748e2cccca67295aa281a2918a76c2a Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 22 Aug 2007 19:35:09 +0200 Subject: send a notice when a call is missed --- skype/skype.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 5e48fe1e..ff5cf2e4 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -29,6 +29,16 @@ #define SKYPE_PORT_DEFAULT "2727" +/* + * Enumerations + */ + +typedef enum +{ + SKYPE_CALL_RINGING, + SKYPE_CALL_MISSED +} skype_call_status; + /* * Structures */ @@ -43,6 +53,10 @@ struct skype_data * body. Store the handle here so that we imcb_buddy_msg() when we got * the body. */ char *handle; + /* This is necessary because we send a notification when we get the + * handle. So we store the state here and then we can send a + * notification about the handle is in a given status. */ + skype_call_status call_status; }; struct skype_away_state @@ -273,11 +287,26 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); skype_write( ic, buf, strlen( buf ) ); + sd->call_status = SKYPE_CALL_RINGING; + } + else if(!strcmp(info, "STATUS MISSED")) + { + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write( ic, buf, strlen( buf ) ); + sd->call_status = SKYPE_CALL_MISSED; } else if(!strncmp(info, "PARTNER_HANDLE ", 15)) { info += 15; - imcb_log(ic, "The user %s is currently ringing you.", info); + switch(sd->call_status) + { + case SKYPE_CALL_RINGING: + imcb_log(ic, "The user %s is currently ringing you.", info); + break; + case SKYPE_CALL_MISSED: + imcb_log(ic, "You have missed a call from user %s.", info); + break; + } } } } -- cgit v1.2.3 From 53b71d3af1bdc9324090cf435160d07188ba861c Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 22 Aug 2007 19:39:17 +0200 Subject: bind to 0.0.0.0, not to localhost --- skype/skyped.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index 1a2d3c25..6d56cf82 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -176,7 +176,7 @@ if __name__=='__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) signal.signal(signal.SIGINT, sig_handler) mainloop = gobject.MainLoop() - server('localhost', options.port) + server('0.0.0.0', options.port) while True: skype = SkypeApi() mainloop.run() -- cgit v1.2.3 From b8351a2ea35bf7a2479c1cbc0eb5ce41be29809e Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 22 Aug 2007 19:44:54 +0200 Subject: mention the tarballs --- skype/README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/skype/README b/skype/README index 74e44823..9a6979fd 100644 --- a/skype/README +++ b/skype/README @@ -60,6 +60,9 @@ make install install-dev git clone http://ftp.frugalware.org/pub/other/people/vmiklos/bitlbee-skype/.git ---- +(Or you can use the tarballs below, see the Changelog about what +features/bugfixes will you miss in this case). + - Compile and install it: ---- -- cgit v1.2.3 From b7f7100a8ea10d1d213f916b2bfda5e3aa698c30 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 22 Aug 2007 19:46:48 +0200 Subject: add group chat to TODO --- skype/README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 9a6979fd..8a6d4afd 100644 --- a/skype/README +++ b/skype/README @@ -164,7 +164,8 @@ allow the `SkypeApiPythonShell` client when Skype asks about it). == What needs to be done (aka. TODO) -- Empty? No, this is not possible. I need more testers! :-) +- Group chat support. Sadly I'm not too motivated to implement this at the + moment. == I would like to have support for ... -- cgit v1.2.3 From 292be68e450ce919c2b13c8c5d25b1c38e1ae52b Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 29 Aug 2007 16:23:59 +0200 Subject: two new ideas --- skype/README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skype/README b/skype/README index 8a6d4afd..33f5abf2 100644 --- a/skype/README +++ b/skype/README @@ -167,6 +167,10 @@ allow the `SkypeApiPythonShell` client when Skype asks about it). - Group chat support. Sadly I'm not too motivated to implement this at the moment. +- Support for receiving messages which consists of multiple lines. + +- Support for receiving edited messages. + == I would like to have support for ... If something does not work and it's not in the TODO section, then please -- cgit v1.2.3 From 846ceffbdff25eaa601478f12d72bd1163e55592 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 29 Aug 2007 16:30:12 +0200 Subject: one more idea --- skype/README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/README b/skype/README index 33f5abf2..45ab04b8 100644 --- a/skype/README +++ b/skype/README @@ -171,6 +171,8 @@ allow the `SkypeApiPythonShell` client when Skype asks about it). - Support for receiving edited messages. +- Add a question callback for calls. + == I would like to have support for ... If something does not work and it's not in the TODO section, then please -- cgit v1.2.3 From 9c90281593898661e5c35c3c02070102be34cc82 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Fri, 31 Aug 2007 00:48:33 +0200 Subject: README: no more patches are required, wilmer merged them :) --- skype/README | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/skype/README b/skype/README index 45ab04b8..8268b30f 100644 --- a/skype/README +++ b/skype/README @@ -34,17 +34,7 @@ automatically reconnect if you restart Skype.) bzr branch http://code.bitlbee.org/bitlbee/ ---- -- You need some additional patches: - ----- -http://frugalware.org/~vmiklos/patches/bitlbee-configure-plugins.patch -http://frugalware.org/~vmiklos/patches/bitlbee-global-conf-may-be-null.patch -http://frugalware.org/~vmiklos/patches/bitlbee-makefile-headers.patch -http://frugalware.org/~vmiklos/patches/bitlbee-more-verbose-on-plugin-errors.patch ----- - -(Yes, I submitted all of them to the -http://bugs.bitlbee.org/bitlbee/[bugtracker] already.) +NOTE: You no longer need additional patches, as of revision 245. - Now compile and install it: -- cgit v1.2.3 From 478c0518323b48c24ddd2474acc8a870d00c2acb Mon Sep 17 00:00:00 2001 From: VMiklos Date: Fri, 31 Aug 2007 00:56:17 +0200 Subject: updates for 0.1.2 --- skype/Makefile | 2 +- skype/NEWS | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 9bd84160..7d5e6feb 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.1.1 +VERSION = 0.1.2 skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) diff --git a/skype/NEWS b/skype/NEWS index 8a89c140..d70b1fc3 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,8 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.1.2 - notification when a new call arrives in + - more documentation (vnc) + - first release which works with unpatched bitlbee 0.1.1 - skyped now runs as daemon in the background by default - skyped now automatically reconnects on Skype restarts 0.1.0 - initial release -- cgit v1.2.3 From 7de5a608d82e15ca4e37b9ccce728d3fc4e32250 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 2 Sep 2007 00:24:17 +0200 Subject: use permalinks --- skype/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 7d5e6feb..f3122639 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -43,7 +43,7 @@ doc: HEADER.html Changelog HEADER.html: README ln -s README HEADER.txt - asciidoc -a toc -a numbered HEADER.txt + asciidoc -a toc -a numbered -a sectids HEADER.txt rm HEADER.txt Changelog: .git/refs/heads/master -- cgit v1.2.3 From 4eaff412eb4656df5a17a35e770b195f24f046f0 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 3 Sep 2007 14:57:26 +0200 Subject: skype_read_callback(): ignore empty messages skype itself does the same --- skype/skype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index ff5cf2e4..2d4e8676 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -265,7 +265,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c else if(!strncmp(info, "BODY ", 5)) { info += 5; - if(sd->handle) + if(sd->handle && strlen(info)) { /* New body, we have everything to use imcb_buddy_msg() now! */ imcb_buddy_msg(ic, sd->handle, info, 0, 0); -- cgit v1.2.3 From 02a531b69a273c4ead692d18b24b3d7c953996e6 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 3 Sep 2007 23:09:34 +0200 Subject: HACKING: update --- skype/HACKING | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/skype/HACKING b/skype/HACKING index 037be98f..22ca883f 100644 --- a/skype/HACKING +++ b/skype/HACKING @@ -1,8 +1,18 @@ -I use the following commands to debug bitlbee itself: +I use the following tabs during the development: + +1) bitlbee-skype: + +vim, make, etc. + +2) bitlbee: gdb ./bitlbee run -v -n -D -For skyped: +3) skyped: python skyped.py -n -d + +4) skype + +5) irssi -- cgit v1.2.3 From 761367025bcb4a711f07715a91076769a3297531 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 4 Sep 2007 00:22:55 +0200 Subject: handle the case when the input is a multiline message --- skype/skype.c | 4 ++-- skype/skyped.py | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 2d4e8676..7dfd3a26 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -260,6 +260,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c * it, then we can later use it * when we got the message's * body. */ + g_free(sd->handle); sd->handle = g_strdup_printf("%s@skype.com", info); } else if(!strncmp(info, "BODY ", 5)) @@ -269,8 +270,6 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { /* New body, we have everything to use imcb_buddy_msg() now! */ imcb_buddy_msg(ic, sd->handle, info, 0, 0); - g_free(sd->handle); - sd->handle = NULL; } } } @@ -379,6 +378,7 @@ static void skype_logout( struct im_connection *ic ) g_free(buf); g_free(sd->username); + g_free(sd->handle); g_free(sd); ic->proto_data = NULL; } diff --git a/skype/skyped.py b/skype/skyped.py index 6d56cf82..186d38cc 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -52,7 +52,8 @@ def input_handler(fd, io_condition): input = fd.recv(1024) for i in input.split("\n"): if i: - fd.send((skype.send(i.strip()) + "\n").encode(locale.getdefaultlocale()[1])) + for j in skype.send(i.strip()): + fd.send((j + "\n").encode(locale.getdefaultlocale()[1])) return True def server(host, port): @@ -84,7 +85,7 @@ class SkypeApi(dbus.service.Object): sys.exit("Can't find any Skype instance. Are you sure you have started Skype?") reply = self.send('NAME ' + CLIENT_NAME) - if reply != 'OK': + if reply[0] != 'OK': sys.exit('Could not bind to Skype client') reply = self.send('PROTOCOL 5') @@ -116,7 +117,18 @@ class SkypeApi(dbus.service.Object): except LookupError: pass mainloop.quit() - dprint('<< ' + reply) + if "\n" in reply: + # crappy skype prefixes only the first line for + # multiline messages so we need to do so for the other + # lines, too. this is something like: + # 'CHATMESSAGE id BODY first line\nsecond line' -> + # 'CHATMESSAGE id BODY first line\nCHATMESSAGE id BODY second line' + prefix = " ".join(reply.split(" ")[:3]) + reply = ["%s %s" % (prefix, i) for i in " ".join(reply.split(" ")[3:]).split("\n")] + else: + reply = [reply] + for i in reply: + dprint('<< ' + i) return reply class Options: -- cgit v1.2.3 From dab0f8ad3de7ebd043a6a6316591988017952eba Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 4 Sep 2007 00:25:57 +0200 Subject: update TODO --- skype/README | 2 -- 1 file changed, 2 deletions(-) diff --git a/skype/README b/skype/README index 8268b30f..bb8db83f 100644 --- a/skype/README +++ b/skype/README @@ -157,8 +157,6 @@ allow the `SkypeApiPythonShell` client when Skype asks about it). - Group chat support. Sadly I'm not too motivated to implement this at the moment. -- Support for receiving messages which consists of multiple lines. - - Support for receiving edited messages. - Add a question callback for calls. -- cgit v1.2.3 From 5d1b077428f1586d9de15cb37e26b65b7ff6b2c0 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 4 Sep 2007 00:30:15 +0200 Subject: support for edited messages --- skype/README | 2 -- skype/skype.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index bb8db83f..0c21646b 100644 --- a/skype/README +++ b/skype/README @@ -157,8 +157,6 @@ allow the `SkypeApiPythonShell` client when Skype asks about it). - Group chat support. Sadly I'm not too motivated to implement this at the moment. -- Support for receiving edited messages. - - Add a question callback for calls. == I would like to have support for ... diff --git a/skype/skype.c b/skype/skype.c index 7dfd3a26..6aa7259d 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -263,6 +263,17 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c g_free(sd->handle); sd->handle = g_strdup_printf("%s@skype.com", info); } + else if(!strncmp(info, "EDITED_BY ", 10)) + { + info += 10; + /* This is the same as + * FROM_HANDLE, except that we + * never request these lines + * from Skype, we just get + * them. */ + g_free(sd->handle); + sd->handle = g_strdup_printf("%s@skype.com", info); + } else if(!strncmp(info, "BODY ", 5)) { info += 5; -- cgit v1.2.3 From c15f71ad27fb572abc851d6059bf78daa800202d Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 4 Sep 2007 18:59:28 +0200 Subject: skyped: use Skype4Py's X11 api this solves all those weird freezes --- skype/README | 15 ++++++--- skype/skyped.py | 96 +++++++++++++++++++++++---------------------------------- 2 files changed, 50 insertions(+), 61 deletions(-) diff --git a/skype/README b/skype/README index 0c21646b..6a86d19d 100644 --- a/skype/README +++ b/skype/README @@ -62,6 +62,16 @@ make make install ---- +- Install http://skype4py.sourceforge.net/[Skype4Py]. + +(You may remember that previous versions of `skyped` did not require this +package. This because it now uses the X11 interface of Skype (because the +previously used DBus interface had +http://forum.skype.com/index.php?s=&showtopic=94545&view=findpost&p=431710[known +problems]), but I wanted to prevent a large code duplication from that project. +In addition it then no longer requires the `dbus-python` package, just +`pygobject`.) + - Start Skype and `skyped` (the tcp server): ---- @@ -170,10 +180,7 @@ then it would be nice to include them here. == Known bugs -- Sometimes when you get a lot of messages in a short time, some of the - messages are dropped. This is a known bug in Skype itself as of version - 1.4.0.99 - (http://forum.skype.com/index.php?s=&showtopic=94545&view=findpost&p=431710[link]). +- None at this time. == Screenshots diff --git a/skype/skyped.py b/skype/skyped.py index 186d38cc..2fc6e2cd 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -29,12 +29,11 @@ import os import signal import locale import time -import dbus -import dbus.service -import dbus.mainloop.glib import gobject import socket import getopt +import Skype4Py +import threading __version__ = "0.1.1" @@ -45,15 +44,18 @@ CLIENT_NAME = 'SkypeApiPythonShell' # here and notify it. maybe later notify all connected clients? conn = None -def sig_handler(signum, frame): - mainloop.quit() - def input_handler(fd, io_condition): input = fd.recv(1024) for i in input.split("\n"): - if i: - for j in skype.send(i.strip()): - fd.send((j + "\n").encode(locale.getdefaultlocale()[1])) + skype.send(i.strip()) + return True + +def idle_handler(skype): + skype.send("PING") + try: + time.sleep(10) + except KeyboardInterrupt: + sys.exit("Exiting.") return True def server(host, port): @@ -76,60 +78,40 @@ def dprint(msg): if options.debug: print msg -class SkypeApi(dbus.service.Object): +class SkypeApi(): def __init__(self): - bus = dbus.SessionBus() - try: - self.skype_api = bus.get_object(SKYPE_SERVICE, '/com/Skype') - except dbus.exceptions.DBusException: - sys.exit("Can't find any Skype instance. Are you sure you have started Skype?") + self.skype = Skype4Py.Skype() + self.skype._API.Handlers.append(Skype4Py.utils.WeakCallableRef(self.recv)) + self.skype._API._Handler = self.recv + self.skype.Attach() - reply = self.send('NAME ' + CLIENT_NAME) - if reply[0] != 'OK': - sys.exit('Could not bind to Skype client') - - reply = self.send('PROTOCOL 5') - try: - dbus.service.Object.__init__(self, bus, "/com/Skype/Client", bus_name='com.Skype.API') - except KeyError: - sys.exit() - - # skype -> client (async) - @dbus.service.method(dbus_interface='com.Skype.API') - def Notify(self, msg_text): + def recv(self, mode, msg_text): global conn - dprint('<< ' + msg_text) - if conn: - conn.send(msg_text + "\n") - - # client -> skype (sync, 5 sec timeout) - def send(self, msg_text): - if not len(msg_text): + if mode != "rece_api": return - dprint('>> ' + msg_text) - try: - reply = self.skype_api.Invoke(msg_text) - except dbus.exceptions.DBusException, s: - reply = str(s) - if(reply.startswith("org.freedesktop.DBus.Error.ServiceUnknown")): - try: - self.remove_from_connection(dbus.SessionBus(), "/com/Skype/Client") - except LookupError: - pass - mainloop.quit() - if "\n" in reply: + if "\n" in msg_text: # crappy skype prefixes only the first line for # multiline messages so we need to do so for the other # lines, too. this is something like: # 'CHATMESSAGE id BODY first line\nsecond line' -> # 'CHATMESSAGE id BODY first line\nCHATMESSAGE id BODY second line' - prefix = " ".join(reply.split(" ")[:3]) - reply = ["%s %s" % (prefix, i) for i in " ".join(reply.split(" ")[3:]).split("\n")] + prefix = " ".join(msg_text.split(" ")[:3]) + msg_text = ["%s %s" % (prefix, i) for i in " ".join(msg_text.split(" ")[3:]).split("\n")] else: - reply = [reply] - for i in reply: + msg_text = [msg_text] + for i in msg_text: dprint('<< ' + i) - return reply + if conn: + conn.send(i + "\n") + + def send(self, msg_text): + if not len(msg_text): + return + dprint('>> ' + msg_text) + try: + self.skype._DoCommand(msg_text) + except Skype4Py.ISkypeError: + pass class Options: def __init__(self): @@ -185,10 +167,10 @@ if __name__=='__main__': else: print 'skyped is started on port %s, pid: %d' % (options.port, pid) sys.exit(0) - dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) - signal.signal(signal.SIGINT, sig_handler) - mainloop = gobject.MainLoop() server('0.0.0.0', options.port) - while True: + try: skype = SkypeApi() - mainloop.run() + except Skype4Py.errors.ISkypeAPIError, s: + sys.exit("%s. Are you sure you have started Skype?" % s) + gobject.idle_add(idle_handler, skype) + gobject.MainLoop().run() -- cgit v1.2.3 From 40d2dc483898d5dc3c57a90ea6d00e07648eea41 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 4 Sep 2007 19:05:56 +0200 Subject: updates for 0.1.3 --- skype/Makefile | 2 +- skype/NEWS | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index f3122639..4b473e8e 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.1.2 +VERSION = 0.1.3 skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) diff --git a/skype/NEWS b/skype/NEWS index d70b1fc3..0caf2a0e 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,9 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.1.3 - support for edited messages + - ignore empty messages (skype does the same) + - support for multiline messages + - switch to the x11 api instead of dbus (it's much more stable) 0.1.2 - notification when a new call arrives in - more documentation (vnc) - first release which works with unpatched bitlbee -- cgit v1.2.3 From e5c01758b410ff159b9c9c9c563bacb78d9d855e Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 4 Sep 2007 20:48:47 +0200 Subject: mention the tested skype version --- skype/README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/README b/skype/README index 6a86d19d..e1fe1a9f 100644 --- a/skype/README +++ b/skype/README @@ -72,6 +72,8 @@ problems]), but I wanted to prevent a large code duplication from that project. In addition it then no longer requires the `dbus-python` package, just `pygobject`.) +- Install Skype 1.4.0.99. 1.4.0.74 did *not* work for me. + - Start Skype and `skyped` (the tcp server): ---- -- cgit v1.2.3 From 67496f714dace43eb7bd2e2cf123f72b64004454 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 4 Sep 2007 21:07:31 +0200 Subject: handle timeouts --- skype/skyped.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/skyped.py b/skype/skyped.py index 2fc6e2cd..9cf53b7b 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -112,6 +112,8 @@ class SkypeApi(): self.skype._DoCommand(msg_text) except Skype4Py.ISkypeError: pass + except Skype4Py.errors.ISkypeAPIError, s: + dprint("Warning, seding '%s' failed (%s)." % (msg_text, s)) class Options: def __init__(self): -- cgit v1.2.3 From 52d779e215047fab1c438356ade5809189fd1cc1 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 4 Sep 2007 21:29:42 +0200 Subject: skyped: fix receiving / sending accents again --- skype/skyped.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 9cf53b7b..d4af5bda 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -100,20 +100,22 @@ class SkypeApi(): else: msg_text = [msg_text] for i in msg_text: - dprint('<< ' + i) + e = i.encode(locale.getdefaultlocale()[1]) + dprint('<< ' + e) if conn: - conn.send(i + "\n") + conn.send(e + "\n") def send(self, msg_text): if not len(msg_text): return - dprint('>> ' + msg_text) + e = msg_text.decode(locale.getdefaultlocale()[1]) + dprint('>> ' + e) try: - self.skype._DoCommand(msg_text) + self.skype._DoCommand(e) except Skype4Py.ISkypeError: pass except Skype4Py.errors.ISkypeAPIError, s: - dprint("Warning, seding '%s' failed (%s)." % (msg_text, s)) + dprint("Warning, seding '%s' failed (%s)." % (e, s)) class Options: def __init__(self): -- cgit v1.2.3 From f080961134608b9d5ca039f9b8f7d2b8de3499ab Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 4 Sep 2007 21:30:52 +0200 Subject: install skyped to bindir, not to sbindir --- skype/Makefile | 4 ++-- skype/config.mak.in | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index 4b473e8e..3eb2662a 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -7,9 +7,9 @@ skype.so: skype.c config.mak install: skype.so skyped.py $(INSTALL) -d $(DESTDIR)$(plugindir) - $(INSTALL) -d $(DESTDIR)$(sbindir) + $(INSTALL) -d $(DESTDIR)$(bindir) $(INSTALL) skype.so $(DESTDIR)$(plugindir) - $(INSTALL) skyped.py $(DESTDIR)$(sbindir)/skyped + $(INSTALL) skyped.py $(DESTDIR)$(bindir)/skyped client: client.c diff --git a/skype/config.mak.in b/skype/config.mak.in index cfdafe82..28c50513 100644 --- a/skype/config.mak.in +++ b/skype/config.mak.in @@ -3,6 +3,6 @@ LDFLAGS = @LDFLAGS@ INSTALL = @INSTALL@ prefix = @prefix@ exec_prefix = @exec_prefix@ -sbindir = @sbindir@ +bindir = @bindir@ libdir = @libdir@ plugindir = ${libdir}/bitlbee -- cgit v1.2.3 From 19b805c71dd7e942ac8ee05a683ab1ae5dbbee2b Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 4 Sep 2007 21:34:26 +0200 Subject: remove hardwired paths --- skype/README | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/skype/README b/skype/README index e1fe1a9f..8c56a743 100644 --- a/skype/README +++ b/skype/README @@ -115,10 +115,10 @@ Now create `~/.vnc/xstartup` with the following contents: ---- #!/bin/sh -/usr/bin/sleep 1 -/usr/bin/skype & -/usr/bin/sleep 5 -/usr/sbin/skyped +sleep 1 +skype & +sleep 5 +skyped ---- Adjust the permissions: -- cgit v1.2.3 From 22d97b4de81e8f0785ff8c7675bd29de16bf6d01 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 4 Sep 2007 21:51:21 +0200 Subject: add a new 'requirements' section --- skype/README | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index 8c56a743..734f4ee1 100644 --- a/skype/README +++ b/skype/README @@ -13,6 +13,14 @@ section, I really hope those random hangups will be fixed soon by Skype. Oh, before I forget. I'm not a wizard, the Skype API documentation is https://developer.skype.com/Docs/ApiDoc[here] if you're interested. +== Requirements + +* Skype 1.4.0.99. 1.4.0.74 did *not* work for me. +* bitlbee-dev >= rev245. Previous versions need patching. +* Skype4Py >= 0.9.28.1. Previous versions uses DBus by default. +* Python 2.5. Skype4Py does not work with 2.4. +* pygobject + == How to set it up Before you start. The setup is the following: BitlBee can't connect directly to @@ -72,8 +80,6 @@ problems]), but I wanted to prevent a large code duplication from that project. In addition it then no longer requires the `dbus-python` package, just `pygobject`.) -- Install Skype 1.4.0.99. 1.4.0.74 did *not* work for me. - - Start Skype and `skyped` (the tcp server): ---- -- cgit v1.2.3 From d86dfb15f27086bfb0052c89ca5b0e17388ff66b Mon Sep 17 00:00:00 2001 From: VMiklos Date: Tue, 4 Sep 2007 22:20:51 +0200 Subject: hide the ping/pong from the log, it's just spam also set the ping timeout to 2sec, it does not cause a big cpu load but this way skyped is much more interactive --- skype/skyped.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index d4af5bda..e9f2080e 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -51,9 +51,9 @@ def input_handler(fd, io_condition): return True def idle_handler(skype): - skype.send("PING") + skype.skype._DoCommand("PING") try: - time.sleep(10) + time.sleep(2) except KeyboardInterrupt: sys.exit("Exiting.") return True @@ -89,6 +89,8 @@ class SkypeApi(): global conn if mode != "rece_api": return + if msg_text == "PONG": + return if "\n" in msg_text: # crappy skype prefixes only the first line for # multiline messages so we need to do so for the other -- cgit v1.2.3 From 54c269df03f3fb29e5b5f8c7696090ffa4e5a3a9 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 5 Sep 2007 16:34:30 +0200 Subject: README: a note about why a skype instance is still required --- skype/README | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/skype/README b/skype/README index 734f4ee1..3498b7bd 100644 --- a/skype/README +++ b/skype/README @@ -13,6 +13,13 @@ section, I really hope those random hangups will be fixed soon by Skype. Oh, before I forget. I'm not a wizard, the Skype API documentation is https://developer.skype.com/Docs/ApiDoc[here] if you're interested. +NOTE: You will see that this implementation of the Skype plugin still requires +a Skype instance to be running. This is because I'm not motivated to reverse +engineer Skype's +http://en.wikipedia.org/wiki/Skype_Protocol#Obfuscation_Layer[obfuscation +layer]. (Not mentioning that you should ask your lawyer about if it is legal or +not..) + == Requirements * Skype 1.4.0.99. 1.4.0.74 did *not* work for me. -- cgit v1.2.3 From 80d90047d5c60b48dc3bfc7e643b923a9e63d28c Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 5 Sep 2007 16:40:09 +0200 Subject: users should try git before reporting bugs --- skype/README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 3498b7bd..817f8317 100644 --- a/skype/README +++ b/skype/README @@ -187,7 +187,8 @@ allow the `SkypeApiPythonShell` client when Skype asks about it). == I would like to have support for ... If something does not work and it's not in the TODO section, then please -contact me! +contact me! Please also try the git version before reporting a bug, your +problem may be already fixed there. In fact, of course, I wrote this documentation after figured out how to do this setup, so maybe I left out some steps. If you needed 'any' additional tricks, -- cgit v1.2.3 From bfe5a8aa13738e500e7e3ef337455708d11edf9e Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 5 Sep 2007 20:01:15 +0200 Subject: do not use internal functions for sending messages thanks awahlig (from the skype forums) for this suggestion --- skype/skyped.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index e9f2080e..7ff26ced 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -51,7 +51,7 @@ def input_handler(fd, io_condition): return True def idle_handler(skype): - skype.skype._DoCommand("PING") + skype.skype.SendCommand(skype.skype.Command(-1, "PING")) try: time.sleep(2) except KeyboardInterrupt: @@ -113,7 +113,7 @@ class SkypeApi(): e = msg_text.decode(locale.getdefaultlocale()[1]) dprint('>> ' + e) try: - self.skype._DoCommand(e) + self.skype.SendCommand(self.skype.Command(-1, e)) except Skype4Py.ISkypeError: pass except Skype4Py.errors.ISkypeAPIError, s: -- cgit v1.2.3 From 5268bd75760eaf0a7120c878312ed6d26189dcf9 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 5 Sep 2007 20:04:04 +0200 Subject: do not use internal functions for receiving messages thanks awahlig --- skype/skyped.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 7ff26ced..177845d5 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -81,14 +81,11 @@ def dprint(msg): class SkypeApi(): def __init__(self): self.skype = Skype4Py.Skype() - self.skype._API.Handlers.append(Skype4Py.utils.WeakCallableRef(self.recv)) - self.skype._API._Handler = self.recv + self.skype.OnNotify = self.recv self.skype.Attach() - def recv(self, mode, msg_text): + def recv(self, msg_text): global conn - if mode != "rece_api": - return if msg_text == "PONG": return if "\n" in msg_text: -- cgit v1.2.3 From 8b3beefbb63a3e710aaabcd170302d5bdb27c9d9 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 5 Sep 2007 20:11:28 +0200 Subject: don't use internal exceptions either --- skype/skyped.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 177845d5..a40e77c3 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -113,7 +113,7 @@ class SkypeApi(): self.skype.SendCommand(self.skype.Command(-1, e)) except Skype4Py.ISkypeError: pass - except Skype4Py.errors.ISkypeAPIError, s: + except Skype4Py.SkypeAPIError, s: dprint("Warning, seding '%s' failed (%s)." % (e, s)) class Options: @@ -173,7 +173,7 @@ if __name__=='__main__': server('0.0.0.0', options.port) try: skype = SkypeApi() - except Skype4Py.errors.ISkypeAPIError, s: + except Skype4Py.SkypeAPIError, s: sys.exit("%s. Are you sure you have started Skype?" % s) gobject.idle_add(idle_handler, skype) gobject.MainLoop().run() -- cgit v1.2.3 From 65e4020ac3cfc890d8fe4f1194593b57f518692b Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 5 Sep 2007 21:18:23 +0200 Subject: add a 'thanks' list --- skype/README | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/skype/README b/skype/README index 817f8317..1357c775 100644 --- a/skype/README +++ b/skype/README @@ -206,4 +206,14 @@ You can reach some screenshots http://frugalware.org/~vmiklos/pics/shots/bitlbee You can reach the Changelog link:Changelog[here]. +== Thanks + +for the following people: + +* Wilmer van der Gaast, for answering questions about the bitlbee plugin interface + +* awahlig (from the skype forums), for making suggestions to skyped + +* Gabor Adam TOTH, for usable bugreports + // vim: ft=asciidoc -- cgit v1.2.3 From dffa24fe3c6f55ae900cf4950e05622860237ab0 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Fri, 7 Sep 2007 18:29:03 +0200 Subject: flame about skype memleaks --- skype/README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skype/README b/skype/README index 1357c775..421bc692 100644 --- a/skype/README +++ b/skype/README @@ -149,6 +149,10 @@ vncserver Then connect to it, and set up Skype (username, password, enable autologin, and allow the `SkypeApiPythonShell` client when Skype asks about it). +Please be aware about that Skype has serious memory leak issues. After running +with for a few weeks it may eat >300 MB of memory. Just don't forget to restart +your VNC server regularly. (How ugly.) + == What works - Download nicks and away statuses from Skype -- cgit v1.2.3 From af8675fa2a9dacb075e1fee0e492a2ea632a68e1 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 12 Sep 2007 00:11:04 +0200 Subject: skyped: handle a possible IOError --- skype/skyped.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index a40e77c3..a79cd4fd 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -102,7 +102,10 @@ class SkypeApi(): e = i.encode(locale.getdefaultlocale()[1]) dprint('<< ' + e) if conn: - conn.send(e + "\n") + try: + conn.send(e + "\n") + except IOError, s: + dprint("Warning, seding '%s' failed (%s)." % (e, s)) def send(self, msg_text): if not len(msg_text): -- cgit v1.2.3 From 8de38e9b1ec123ad0c73e0db1918eb06b1af3388 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 16 Sep 2007 00:26:41 +0200 Subject: updates for 0.1.4 --- skype/Makefile | 2 +- skype/NEWS | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 3eb2662a..3f6792de 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.1.3 +VERSION = 0.1.4 skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) diff --git a/skype/NEWS b/skype/NEWS index 0caf2a0e..b81fb5c8 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,10 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.1.4 - documentation: mention the version of all deps (requirements + section) + - fix sending / sending accents + - don't use internal functions of skype4py + - skyped no longer dies when skype is killed 0.1.3 - support for edited messages - ignore empty messages (skype does the same) - support for multiline messages -- cgit v1.2.3 From 368861e615827f27fb4897dd378b7ac0ffaa2176 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Fri, 21 Sep 2007 16:16:48 +0200 Subject: skype_data struct: some more comments also renmae r_inpa to bfd --- skype/skype.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 6aa7259d..dc470749 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -47,8 +47,12 @@ struct skype_data { struct im_connection *ic; char *username; + /* The effective file descriptor. We store it here so any function can + * write() to it. */ int fd; - int r_inpa; + /* File descriptor returned by bitlbee. we store it so we know when + * we're connected and when we aren't. */ + int bfd; /* When we receive a new message id, we query the handle, then the * body. Store the handle here so that we imcb_buddy_msg() when we got * the body. */ @@ -345,8 +349,8 @@ gboolean skype_start_stream( struct im_connection *ic ) if(!sd) return FALSE; - if( sd->r_inpa <= 0 ) - sd->r_inpa = b_input_add( sd->fd, GAIM_INPUT_READ, skype_read_callback, ic ); + if( sd->bfd <= 0 ) + sd->bfd = b_input_add( sd->fd, GAIM_INPUT_READ, skype_read_callback, ic ); /* This will download all buddies. */ buf = g_strdup_printf("SEARCH FRIENDS\n"); -- cgit v1.2.3 From 4c3a4c890d3f532aa3b8acb6dac48057a4fecc19 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 24 Sep 2007 20:31:39 +0200 Subject: README: spelling fixes --- skype/README | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/skype/README b/skype/README index 421bc692..ab62927c 100644 --- a/skype/README +++ b/skype/README @@ -13,7 +13,7 @@ section, I really hope those random hangups will be fixed soon by Skype. Oh, before I forget. I'm not a wizard, the Skype API documentation is https://developer.skype.com/Docs/ApiDoc[here] if you're interested. -NOTE: You will see that this implementation of the Skype plugin still requires +NOTE: You will see that this implementation of the Skype plug-in still requires a Skype instance to be running. This is because I'm not motivated to reverse engineer Skype's http://en.wikipedia.org/wiki/Skype_Protocol#Obfuscation_Layer[obfuscation @@ -24,7 +24,7 @@ not..) * Skype 1.4.0.99. 1.4.0.74 did *not* work for me. * bitlbee-dev >= rev245. Previous versions need patching. -* Skype4Py >= 0.9.28.1. Previous versions uses DBus by default. +* Skype4Py >= 0.9.28.1. Previous versions uses `DBus` by default. * Python 2.5. Skype4Py does not work with 2.4. * pygobject @@ -33,7 +33,7 @@ not..) Before you start. The setup is the following: BitlBee can't connect directly to Skype servers (the company's ones). It needs a running Skype client to do so. In fact BitlBee will connect to `skyped` (a tcp server, provided in this -package) and `skyped` will connecto to your Skype client. +package) and `skyped` will connect to to your Skype client. NOTE: The order is important. First you have to start Skype. Then `skyped` can connect to it, finally BitlBee can connect to `skyped`. (In fact `skyped` @@ -81,7 +81,7 @@ make install (You may remember that previous versions of `skyped` did not require this package. This because it now uses the X11 interface of Skype (because the -previously used DBus interface had +previously used `DBus` interface had http://forum.skype.com/index.php?s=&showtopic=94545&view=findpost&p=431710[known problems]), but I wanted to prevent a large code duplication from that project. In addition it then no longer requires the `dbus-python` package, just @@ -94,17 +94,17 @@ skype skyped ---- -NOTE: It's important to start skyped on the same machine and using the same -user as you run Skype as it uses the session DBus for communication! +NOTE: It's important to start `skyped` on the same machine and using the same +user as you run Skype as it uses the session `DBus` for communication! -- Start your IRC client, connect to BitlBee and add your account: +- Start your `IRC` client, connect to BitlBee and add your account: ---- account add skype account set 0/server localhost ---- -IMPORTANT: should be your skype account name. This way you won't see +IMPORTANT: should be your Skype account name. This way you won't see yourself joining to `&bitlbee`. NOTE: the option is not used currently. @@ -112,7 +112,7 @@ NOTE: the option is not used currently. == Setting up Skype in a VNC server (optional) Optionally, if you want to run Skype on a server, you might want to setup up -a VNC server as well. I used `tightvnc` but probably other VNC servers will +a `VNC` server as well. I used `tightvnc` but probably other `VNC` servers will work, too. First run @@ -146,7 +146,7 @@ Then start the server: vncserver ---- -Then connect to it, and set up Skype (username, password, enable autologin, and +Then connect to it, and set up Skype (username, password, enable auto-login, and allow the `SkypeApiPythonShell` client when Skype asks about it). Please be aware about that Skype has serious memory leak issues. After running -- cgit v1.2.3 From 25d87e4d9cedf15e7f1487a437d505f514d97e7e Mon Sep 17 00:00:00 2001 From: VMiklos Date: Mon, 24 Sep 2007 20:36:42 +0200 Subject: README: link gitweb --- skype/README | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index ab62927c..fda87784 100644 --- a/skype/README +++ b/skype/README @@ -206,9 +206,10 @@ then it would be nice to include them here. You can reach some screenshots http://frugalware.org/~vmiklos/pics/shots/bitlbee-skype/[here]. -== Changelog +== Additional resources -You can reach the Changelog link:Changelog[here]. +You can reach the Changelog link:Changelog[here], and a gitweb interface +link:http://git.frugalware.org/gitweb/gitweb.cgi?p=bitlbee-skype.git;a=summary[here]. == Thanks -- cgit v1.2.3 From c5dd164f95107dde963d46fefcffd04afc4b114c Mon Sep 17 00:00:00 2001 From: VMiklos Date: Wed, 3 Oct 2007 21:05:43 +0200 Subject: update group chat status to be honest, today i had to use skype group chat and it was very annoying to use the original skype client for that. so yes, now i plan to add more or less support for it. we'll see. i hope i'll have time for it :) --- skype/README | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index fda87784..d889a576 100644 --- a/skype/README +++ b/skype/README @@ -183,11 +183,18 @@ your VNC server regularly. (How ugly.) == What needs to be done (aka. TODO) -- Group chat support. Sadly I'm not too motivated to implement this at the - moment. +- Group chat support. For an initial support the followings would be needed: + + * Detect if we're invited. + + * Send / receive group chat messages. + + * Handle topic changes. - Add a question callback for calls. +- Somehow at least mention that somebody offers a file for transfer. + == I would like to have support for ... If something does not work and it's not in the TODO section, then please -- cgit v1.2.3 From 7e66424c12563029201e7731cdd6e0301523c0aa Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sat, 6 Oct 2007 16:46:59 +0200 Subject: readme: skype4py 0.9.28.4 has some incompatible changes, mention this also correct an outdated comment about dbus --- skype/README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index d889a576..3b85d16a 100644 --- a/skype/README +++ b/skype/README @@ -24,7 +24,7 @@ not..) * Skype 1.4.0.99. 1.4.0.74 did *not* work for me. * bitlbee-dev >= rev245. Previous versions need patching. -* Skype4Py >= 0.9.28.1. Previous versions uses `DBus` by default. +* Skype4Py >= 0.9.28.1. Previous versions uses `DBus` by default. The latest version I've tested is 0.9.28.3. * Python 2.5. Skype4Py does not work with 2.4. * pygobject @@ -95,7 +95,7 @@ skyped ---- NOTE: It's important to start `skyped` on the same machine and using the same -user as you run Skype as it uses the session `DBus` for communication! +user! - Start your `IRC` client, connect to BitlBee and add your account: -- cgit v1.2.3 From df9255d5cfe8e41220cabb664fe81c922db1f609 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sat, 6 Oct 2007 17:16:06 +0200 Subject: notification when somebody wants to transfer a file --- skype/README | 4 ++-- skype/skype.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/skype/README b/skype/README index 3b85d16a..9be00575 100644 --- a/skype/README +++ b/skype/README @@ -181,6 +181,8 @@ your VNC server regularly. (How ugly.) - Detect when somebody wants to add you and ask for confirmation +- Detect when somebody wants to transfer a file + == What needs to be done (aka. TODO) - Group chat support. For an initial support the followings would be needed: @@ -193,8 +195,6 @@ your VNC server regularly. (How ugly.) - Add a question callback for calls. -- Somehow at least mention that somebody offers a file for transfer. - == I would like to have support for ... If something does not work and it's not in the TODO section, then please diff --git a/skype/skype.c b/skype/skype.c index dc470749..e1fb7293 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -35,10 +35,16 @@ typedef enum { - SKYPE_CALL_RINGING, + SKYPE_CALL_RINGING = 1, SKYPE_CALL_MISSED } skype_call_status; +typedef enum +{ + SKYPE_FILETRANSFER_NEW = 1, + SKYPE_FILETRANSFER_FAILED +} skype_filetransfer_status; + /* * Structures */ @@ -61,6 +67,8 @@ struct skype_data * handle. So we store the state here and then we can send a * notification about the handle is in a given status. */ skype_call_status call_status; + /* Same for file transfers. */ + skype_filetransfer_status filetransfer_status; }; struct skype_away_state @@ -312,14 +320,55 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c else if(!strncmp(info, "PARTNER_HANDLE ", 15)) { info += 15; - switch(sd->call_status) - { - case SKYPE_CALL_RINGING: - imcb_log(ic, "The user %s is currently ringing you.", info); - break; - case SKYPE_CALL_MISSED: - imcb_log(ic, "You have missed a call from user %s.", info); - break; + if(sd->call_status) { + switch(sd->call_status) + { + case SKYPE_CALL_RINGING: + imcb_log(ic, "The user %s is currently ringing you.", info); + break; + case SKYPE_CALL_MISSED: + imcb_log(ic, "You have missed a call from user %s.", info); + break; + } + sd->call_status = 0; + } + } + } + } + else if(!strncmp(line, "FILETRANSFER ", 13)) + { + char *id = strchr(line, ' '); + if(++id) + { + char *info = strchr(id, ' '); + *info = '\0'; + info++; + if(!strcmp(info, "STATUS NEW")) + { + g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); + skype_write( ic, buf, strlen( buf ) ); + sd->filetransfer_status = SKYPE_FILETRANSFER_NEW; + } + else if(!strcmp(info, "STATUS FAILED")) + { + g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); + skype_write( ic, buf, strlen( buf ) ); + sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED; + } + else if(!strncmp(info, "PARTNER_HANDLE ", 15)) + { + info += 15; + if(sd->filetransfer_status) { + switch(sd->filetransfer_status) + { + case SKYPE_FILETRANSFER_NEW: + imcb_log(ic, "The user %s offered a new file for you.", info); + break; + case SKYPE_FILETRANSFER_FAILED: + imcb_log(ic, "Failed to transfer file from user %s.", info); + break; + } + sd->filetransfer_status = 0; } } } -- cgit v1.2.3 From 3922d44e2b9d4c970ed3697189fa63cdc9cbba6d Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sat, 6 Oct 2007 17:25:21 +0200 Subject: handle the case when ping fails (ie: timeout) --- skype/skyped.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index a79cd4fd..7e15b72f 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -51,7 +51,10 @@ def input_handler(fd, io_condition): return True def idle_handler(skype): - skype.skype.SendCommand(skype.skype.Command(-1, "PING")) + try: + skype.skype.SendCommand(skype.skype.Command(-1, "PING")) + except Skype4Py.SkypeAPIError, s: + dprint("Warning, pinging Skype failed (%s)." % (s)) try: time.sleep(2) except KeyboardInterrupt: -- cgit v1.2.3 From a75f2a7a6f57da846ab54d6fe5d52ec0c021a042 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sat, 6 Oct 2007 17:35:55 +0200 Subject: display received messages in utf8, so that we can avoid most UnicodeEncodeErrors --- skype/skyped.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 7e15b72f..22b0b322 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -102,13 +102,18 @@ class SkypeApi(): else: msg_text = [msg_text] for i in msg_text: - e = i.encode(locale.getdefaultlocale()[1]) + # use utf-8 here to solve the following problem: + # people use env vars like LC_ALL=en_US (latin1) then + # they complain about why can't they receive latin2 + # messages.. so here it is: always use utf-8 then + # everybody will be happy + e = i.encode('UTF-8') dprint('<< ' + e) if conn: try: conn.send(e + "\n") except IOError, s: - dprint("Warning, seding '%s' failed (%s)." % (e, s)) + dprint("Warning, sending '%s' failed (%s)." % (e, s)) def send(self, msg_text): if not len(msg_text): @@ -120,7 +125,7 @@ class SkypeApi(): except Skype4Py.ISkypeError: pass except Skype4Py.SkypeAPIError, s: - dprint("Warning, seding '%s' failed (%s)." % (e, s)) + dprint("Warning, sending '%s' failed (%s)." % (e, s)) class Options: def __init__(self): -- cgit v1.2.3 From 2d0780303e487cbca12ac1443a951b77339068b5 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sat, 6 Oct 2007 18:05:44 +0200 Subject: handle topic changes --- skype/README | 4 ++-- skype/skype.c | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index 9be00575..0457c3ea 100644 --- a/skype/README +++ b/skype/README @@ -183,6 +183,8 @@ your VNC server regularly. (How ugly.) - Detect when somebody wants to transfer a file +- Handle topic changes + == What needs to be done (aka. TODO) - Group chat support. For an initial support the followings would be needed: @@ -191,8 +193,6 @@ your VNC server regularly. (How ugly.) * Send / receive group chat messages. - * Handle topic changes. - - Add a question callback for calls. == I would like to have support for ... diff --git a/skype/skype.c b/skype/skype.c index e1fb7293..9658c796 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -69,6 +69,8 @@ struct skype_data skype_call_status call_status; /* Same for file transfers. */ skype_filetransfer_status filetransfer_status; + /* True if the next message will be a topic */ + int topic; }; struct skype_away_state @@ -292,7 +294,13 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if(sd->handle && strlen(info)) { /* New body, we have everything to use imcb_buddy_msg() now! */ - imcb_buddy_msg(ic, sd->handle, info, 0, 0); + if(sd->topic) + { + imcb_log(ic, "%s has changed the chat topic to \"%s\"", sd->handle, info); + sd->topic = 0; + } + else + imcb_buddy_msg(ic, sd->handle, info, 0, 0); } } } @@ -373,6 +381,18 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } } } + else if(!strncmp(line, "CHAT ", 5)) + { + char *id = strchr(line, ' '); + if(++id) + { + char *info = strchr(id, ' '); + *info = '\0'; + info++; + if(!strncmp(info, "TOPIC ", 6)) + sd->topic = 1; + } + } lineptr++; } g_strfreev(lines); -- cgit v1.2.3 From 72aa7f08b94aada5a15ee1185e468d695ef54106 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sat, 6 Oct 2007 21:20:12 +0200 Subject: initial groupchat support read: we detect that we are invited we retreive the nicklist but we can't receive/send messages yet --- skype/skype.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index 9658c796..615fca01 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -26,6 +26,7 @@ #include #include #include +#include #define SKYPE_PORT_DEFAULT "2727" @@ -169,6 +170,19 @@ void skype_buddy_ask( struct im_connection *ic, char *handle, char *message) g_free( buf ); } +struct groupchat *skype_chat_by_name( struct im_connection *ic, char *name ) +{ + struct groupchat *ret; + + for( ret = ic->conversations; ret; ret = ret->next ) + { + if(strcmp(name, ret->title ) == 0 ) + break; + } + + return ret; +} + static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition cond ) { struct im_connection *ic = data; @@ -391,6 +405,29 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c info++; if(!strncmp(info, "TOPIC ", 6)) sd->topic = 1; + else if(!strcmp(info, "STATUS MULTI_SUBSCRIBED")) + { + struct groupchat *gc; + gc = imcb_chat_new( ic, id ); + } + else if(!strncmp(info, "ACTIVEMEMBERS ", 14)) + { + info += 14; + struct groupchat *gc = skype_chat_by_name(ic, id); + if(!gc) + gc = imcb_chat_new( ic, id ); + char **members = g_strsplit(info, " ", 0); + int i; + for(i=0;members[i];i++) + { + if(!strcmp(members[i], sd->username)) + continue; + g_snprintf(buf, 1024, "%s@skype.com", members[i]); + imcb_chat_add_buddy(gc, buf); + } + imcb_chat_add_buddy(gc, sd->username); + g_strfreev(members); + } } } lineptr++; -- cgit v1.2.3 From 66c9558fd9e178ba54a294138effbaca83988920 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sat, 6 Oct 2007 21:59:58 +0200 Subject: new dummy skype_chat_msg() function --- skype/skype.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index 615fca01..da7bf09a 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -584,6 +584,11 @@ static void skype_remove_buddy( struct im_connection *ic, char *who, char *group g_free(nick); } +int skype_chat_msg( struct groupchat *c, char *message, int flags ) +{ + // TODO: this is just here atm to prevent a segfault +} + void init_plugin(void) { struct prpl *ret = g_new0( struct prpl, 1 ); @@ -597,6 +602,7 @@ void init_plugin(void) ret->set_away = skype_set_away; ret->add_buddy = skype_add_buddy; ret->remove_buddy = skype_remove_buddy; + ret->chat_msg = skype_chat_msg; ret->handle_cmp = g_strcasecmp; register_protocol( ret ); } -- cgit v1.2.3 From 5a61e43f470068f98ee7b04685376c23b9468974 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sat, 6 Oct 2007 22:03:49 +0200 Subject: revert "handle topic changes" - this reverts commit b2d9bfa54753bcf0c617cc515d08f0ac46c1d65e. - the proper way will be to query the type of a CHATMESSAGE object, and if it's SETTOPIC, then do the same --- skype/skype.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index da7bf09a..d0d6940f 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -70,8 +70,6 @@ struct skype_data skype_call_status call_status; /* Same for file transfers. */ skype_filetransfer_status filetransfer_status; - /* True if the next message will be a topic */ - int topic; }; struct skype_away_state @@ -308,13 +306,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if(sd->handle && strlen(info)) { /* New body, we have everything to use imcb_buddy_msg() now! */ - if(sd->topic) - { - imcb_log(ic, "%s has changed the chat topic to \"%s\"", sd->handle, info); - sd->topic = 0; - } - else - imcb_buddy_msg(ic, sd->handle, info, 0, 0); + imcb_buddy_msg(ic, sd->handle, info, 0, 0); } } } @@ -403,9 +395,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c char *info = strchr(id, ' '); *info = '\0'; info++; - if(!strncmp(info, "TOPIC ", 6)) - sd->topic = 1; - else if(!strcmp(info, "STATUS MULTI_SUBSCRIBED")) + if(!strcmp(info, "STATUS MULTI_SUBSCRIBED")) { struct groupchat *gc; gc = imcb_chat_new( ic, id ); -- cgit v1.2.3 From 3ef191040a3d88b21e287cf3c64bd9fc7e8c0026 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sat, 6 Oct 2007 22:06:14 +0200 Subject: don't mark messages as seen - they still spams the skype client - unnecessary transfer then --- skype/skype.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index d0d6940f..532196e4 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -270,14 +270,11 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c /* New message ID: * (1) Request its from field * (2) Request its body - * (3) Mark it as seen */ g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id); skype_write( ic, buf, strlen( buf ) ); g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); skype_write( ic, buf, strlen( buf ) ); - g_snprintf(buf, 1024, "SET CHATMESSAGE %s SEEN\n", id); - skype_write( ic, buf, strlen( buf ) ); } else if(!strncmp(info, "FROM_HANDLE ", 12)) { -- cgit v1.2.3 From c81d0ef2f921e16f74aae98320f551d822dac2e1 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sat, 6 Oct 2007 22:28:44 +0200 Subject: receiving group chat messages now works it's a bit agressive. dialogs are not group chats, but i'll fix it later --- skype/skype.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 532196e4..3ba8cc33 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -60,10 +60,11 @@ struct skype_data /* File descriptor returned by bitlbee. we store it so we know when * we're connected and when we aren't. */ int bfd; - /* When we receive a new message id, we query the handle, then the - * body. Store the handle here so that we imcb_buddy_msg() when we got - * the body. */ + /* When we receive a new message id, we query the handle, the body and + * the chatname. Store the handle and the body here so that we + * imcb_buddy_msg() when we got the chatname. */ char *handle; + char *body; /* This is necessary because we send a notification when we get the * handle. So we store the state here and then we can send a * notification about the handle is in a given status. */ @@ -270,11 +271,14 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c /* New message ID: * (1) Request its from field * (2) Request its body + * (3) Query chatname */ g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id); skype_write( ic, buf, strlen( buf ) ); g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); skype_write( ic, buf, strlen( buf ) ); + g_snprintf(buf, 1024, "GET CHATMESSAGE %s CHATNAME\n", id); + skype_write( ic, buf, strlen( buf ) ); } else if(!strncmp(info, "FROM_HANDLE ", 12)) { @@ -300,10 +304,26 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c else if(!strncmp(info, "BODY ", 5)) { info += 5; - if(sd->handle && strlen(info)) + g_free(sd->body); + sd->body = g_strdup(info); + } + else if(!strncmp(info, "CHATNAME ", 9)) + { + info += 9; + if(sd->handle && sd->body && strlen(info)) { - /* New body, we have everything to use imcb_buddy_msg() now! */ - imcb_buddy_msg(ic, sd->handle, info, 0, 0); + struct groupchat *gc = skype_chat_by_name(ic, info); + if(!gc) + { + printf("gc is null, id is '%s'\n", info); + /* Private message */ + imcb_buddy_msg(ic, sd->handle, sd->body, 0, 0); + } + else + { + printf("gc is not null, id is '%s'\n", info); + imcb_chat_msg(gc, sd->handle, sd->body, 0, 0); + } } } } @@ -571,7 +591,7 @@ static void skype_remove_buddy( struct im_connection *ic, char *who, char *group g_free(nick); } -int skype_chat_msg( struct groupchat *c, char *message, int flags ) +void skype_chat_msg( struct groupchat *c, char *message, int flags ) { // TODO: this is just here atm to prevent a segfault } -- cgit v1.2.3 From 548bf76666373f661bef6f4c74c57818d79d973a Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sat, 6 Oct 2007 22:44:00 +0200 Subject: remove debug printfs --- skype/skype.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 3ba8cc33..22f422f2 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -314,16 +314,11 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { struct groupchat *gc = skype_chat_by_name(ic, info); if(!gc) - { - printf("gc is null, id is '%s'\n", info); /* Private message */ imcb_buddy_msg(ic, sd->handle, sd->body, 0, 0); - } else - { - printf("gc is not null, id is '%s'\n", info); + /* Groupchat message */ imcb_chat_msg(gc, sd->handle, sd->body, 0, 0); - } } } } -- cgit v1.2.3 From 79e20f9d125529daa2ae548c1d6f2be3fcb7b863 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sat, 6 Oct 2007 22:44:31 +0200 Subject: implement skype_chat_msg() now sending groupchat messages works, too :) --- skype/skype.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 22f422f2..95aab5d4 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -586,9 +586,13 @@ static void skype_remove_buddy( struct im_connection *ic, char *who, char *group g_free(nick); } -void skype_chat_msg( struct groupchat *c, char *message, int flags ) +void skype_chat_msg( struct groupchat *gc, char *message, int flags ) { - // TODO: this is just here atm to prevent a segfault + struct im_connection *ic = gc->ic; + char *buf; + buf = g_strdup_printf("CHATMESSAGE %s %s\n", gc->title, message); + skype_write( ic, buf, strlen( buf ) ); + g_free(buf); } void init_plugin(void) -- cgit v1.2.3 From 349ee4a168ad83cab3ac71d7fbd0cf908fa10491 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sat, 6 Oct 2007 22:53:32 +0200 Subject: fix agressive groupchat mechanism since 55f2d43, a groupchat was created even for 2 people. this is wrong. we should not create a group chat when receiving an ACTIVEMEMBERS, only when the CHAT's TYPE is MULTICHAT --- skype/skype.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 95aab5d4..dcc50f50 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -416,19 +416,20 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { info += 14; struct groupchat *gc = skype_chat_by_name(ic, id); - if(!gc) - gc = imcb_chat_new( ic, id ); - char **members = g_strsplit(info, " ", 0); - int i; - for(i=0;members[i];i++) + if(gc) { - if(!strcmp(members[i], sd->username)) - continue; - g_snprintf(buf, 1024, "%s@skype.com", members[i]); - imcb_chat_add_buddy(gc, buf); + char **members = g_strsplit(info, " ", 0); + int i; + for(i=0;members[i];i++) + { + if(!strcmp(members[i], sd->username)) + continue; + g_snprintf(buf, 1024, "%s@skype.com", members[i]); + imcb_chat_add_buddy(gc, buf); + } + imcb_chat_add_buddy(gc, sd->username); + g_strfreev(members); } - imcb_chat_add_buddy(gc, sd->username); - g_strfreev(members); } } } -- cgit v1.2.3 From 2a0f99c369161ab405765912c9ebe14e67e27ce7 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 7 Oct 2007 00:23:49 +0200 Subject: handle the topic changes in group chats correctly --- skype/skype.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index dcc50f50..19c2c98f 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -60,11 +60,12 @@ struct skype_data /* File descriptor returned by bitlbee. we store it so we know when * we're connected and when we aren't. */ int bfd; - /* When we receive a new message id, we query the handle, the body and - * the chatname. Store the handle and the body here so that we + /* When we receive a new message id, we query the properties, finally + * the chatname. Store the properties here so that we can use * imcb_buddy_msg() when we got the chatname. */ char *handle; char *body; + char *type; /* This is necessary because we send a notification when we get the * handle. So we store the state here and then we can send a * notification about the handle is in a given status. */ @@ -271,12 +272,15 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c /* New message ID: * (1) Request its from field * (2) Request its body - * (3) Query chatname + * (3) Request its type + * (4) Query chatname */ g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id); skype_write( ic, buf, strlen( buf ) ); g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); skype_write( ic, buf, strlen( buf ) ); + g_snprintf(buf, 1024, "GET CHATMESSAGE %s TYPE\n", id); + skype_write( ic, buf, strlen( buf ) ); g_snprintf(buf, 1024, "GET CHATMESSAGE %s CHATNAME\n", id); skype_write( ic, buf, strlen( buf ) ); } @@ -307,18 +311,33 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c g_free(sd->body); sd->body = g_strdup(info); } + else if(!strncmp(info, "TYPE ", 5)) + { + info += 5; + g_free(sd->type); + sd->type = g_strdup(info); + } else if(!strncmp(info, "CHATNAME ", 9)) { info += 9; - if(sd->handle && sd->body && strlen(info)) + if(sd->handle && sd->body && sd->type) { - struct groupchat *gc = skype_chat_by_name(ic, info); - if(!gc) - /* Private message */ - imcb_buddy_msg(ic, sd->handle, sd->body, 0, 0); - else - /* Groupchat message */ - imcb_chat_msg(gc, sd->handle, sd->body, 0, 0); + if(!strcmp(sd->type, "SAID")) + { + struct groupchat *gc = skype_chat_by_name(ic, info); + if(!gc) + /* Private message */ + imcb_buddy_msg(ic, sd->handle, sd->body, 0, 0); + else + /* Groupchat message */ + imcb_chat_msg(gc, sd->handle, sd->body, 0, 0); + } + else if(!strcmp(sd->type, "SETTOPIC")) + { + struct groupchat *gc = skype_chat_by_name(ic, info); + if(gc) + imcb_log(ic, "%s changed the topic of %s to: %s", sd->handle, gc->title, sd->body); + } } } } -- cgit v1.2.3 From 31870ae4ebd50d79cca9fc18a0ea783c198ff0d3 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 7 Oct 2007 01:12:09 +0200 Subject: handle parts in groupchats --- skype/skype.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 19c2c98f..bf8abc2e 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -322,9 +322,9 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c info += 9; if(sd->handle && sd->body && sd->type) { + struct groupchat *gc = skype_chat_by_name(ic, info); if(!strcmp(sd->type, "SAID")) { - struct groupchat *gc = skype_chat_by_name(ic, info); if(!gc) /* Private message */ imcb_buddy_msg(ic, sd->handle, sd->body, 0, 0); @@ -334,10 +334,14 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } else if(!strcmp(sd->type, "SETTOPIC")) { - struct groupchat *gc = skype_chat_by_name(ic, info); if(gc) imcb_log(ic, "%s changed the topic of %s to: %s", sd->handle, gc->title, sd->body); } + else if(!strcmp(sd->type, "LEFT")) + { + if(gc) + imcb_chat_remove_buddy(gc, sd->handle, NULL); + } } } } -- cgit v1.2.3 From b01dc6cf8e365c0e904fa2b6867021f544d117e4 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 7 Oct 2007 01:38:49 +0200 Subject: implemented skype_chat_leave() --- skype/skype.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index bf8abc2e..3777a37a 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -619,6 +619,15 @@ void skype_chat_msg( struct groupchat *gc, char *message, int flags ) g_free(buf); } +void skype_chat_leave( struct groupchat *gc ) +{ + struct im_connection *ic = gc->ic; + char *buf; + buf = g_strdup_printf("ALTER CHAT %s LEAVE\n", gc->title); + skype_write( ic, buf, strlen( buf ) ); + g_free(buf); +} + void init_plugin(void) { struct prpl *ret = g_new0( struct prpl, 1 ); @@ -633,6 +642,7 @@ void init_plugin(void) ret->add_buddy = skype_add_buddy; ret->remove_buddy = skype_remove_buddy; ret->chat_msg = skype_chat_msg; + ret->chat_leave = skype_chat_leave; ret->handle_cmp = g_strcasecmp; register_protocol( ret ); } -- cgit v1.2.3 From c09d32721e49feda7c459dbba9222252ae56eec7 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 7 Oct 2007 02:27:28 +0200 Subject: avoid nicks joining to a group chat multiple times --- skype/skype.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 3777a37a..dcca7b6f 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -448,7 +448,8 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if(!strcmp(members[i], sd->username)) continue; g_snprintf(buf, 1024, "%s@skype.com", members[i]); - imcb_chat_add_buddy(gc, buf); + if(!g_list_find_custom(gc->in_room, buf, (GCompareFunc)strcmp)) + imcb_chat_add_buddy(gc, buf); } imcb_chat_add_buddy(gc, sd->username); g_strfreev(members); -- cgit v1.2.3 From ec159f19dc1ff109c8876500af19d0952663e9a8 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 7 Oct 2007 03:06:22 +0200 Subject: fix unwanted rejoin after /part --- skype/skype.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index dcca7b6f..d24424d0 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -435,11 +435,21 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c struct groupchat *gc; gc = imcb_chat_new( ic, id ); } + else if(!strcmp(info, "STATUS UNSUBSCRIBED")) + { + struct groupchat *gc = skype_chat_by_name(ic, id); + if(gc) + gc->data = (void*)FALSE; + } else if(!strncmp(info, "ACTIVEMEMBERS ", 14)) { info += 14; struct groupchat *gc = skype_chat_by_name(ic, id); - if(gc) + /* Hack! We set ->data to TRUE + * while we're on the channel + * so that we won't rejoin + * after a /part. */ + if(gc && !gc->data) { char **members = g_strsplit(info, " ", 0); int i; @@ -453,6 +463,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } imcb_chat_add_buddy(gc, sd->username); g_strfreev(members); + gc->data = (void*)TRUE; } } } -- cgit v1.2.3 From 86f2683fd62482f297793aa711704b772fa5c345 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 7 Oct 2007 03:55:17 +0200 Subject: skype_read_callback(): sanity check --- skype/skype.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index d24424d0..5d5854bc 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -428,7 +428,8 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if(++id) { char *info = strchr(id, ' '); - *info = '\0'; + if(info) + *info = '\0'; info++; if(!strcmp(info, "STATUS MULTI_SUBSCRIBED")) { -- cgit v1.2.3 From 760319dd435e3189fd8707fa72ea3a21663e1b69 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 7 Oct 2007 03:55:46 +0200 Subject: implemented skype_chat_invite() --- skype/skype.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 5d5854bc..0937400d 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -464,7 +464,6 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } imcb_chat_add_buddy(gc, sd->username); g_strfreev(members); - gc->data = (void*)TRUE; } } } @@ -639,6 +638,21 @@ void skype_chat_leave( struct groupchat *gc ) buf = g_strdup_printf("ALTER CHAT %s LEAVE\n", gc->title); skype_write( ic, buf, strlen( buf ) ); g_free(buf); + gc->data = (void*)TRUE; +} + +void skype_chat_invite(struct groupchat *gc, char *who, char *message) +{ + struct im_connection *ic = gc->ic; + char *buf, *ptr, *nick; + nick = g_strdup(message); + ptr = strchr(nick, '@'); + if(ptr) + *ptr = '\0'; + buf = g_strdup_printf("ALTER CHAT %s ADDMEMBERS %s\n", gc->title, nick); + skype_write( ic, buf, strlen( buf ) ); + g_free(buf); + g_free(nick); } void init_plugin(void) @@ -656,6 +670,7 @@ void init_plugin(void) ret->remove_buddy = skype_remove_buddy; ret->chat_msg = skype_chat_msg; ret->chat_leave = skype_chat_leave; + ret->chat_invite = skype_chat_invite; ret->handle_cmp = g_strcasecmp; register_protocol( ret ); } -- cgit v1.2.3 From d6a371e841e21ce810205e11fbf392f50c636371 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 7 Oct 2007 04:00:52 +0200 Subject: update documentation --- skype/README | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/skype/README b/skype/README index 0457c3ea..23a383ee 100644 --- a/skype/README +++ b/skype/README @@ -185,16 +185,25 @@ your VNC server regularly. (How ugly.) - Handle topic changes -== What needs to be done (aka. TODO) +- Group chat support: + + * Detect if we're invited + + * Send / receive group chat messages -- Group chat support. For an initial support the followings would be needed: + * Invite others - * Detect if we're invited. + * Part from group chats - * Send / receive group chat messages. +== What needs to be done (aka. TODO) - Add a question callback for calls. +- Notice if foo invites bar. Currently you can see only that bar joined. + +- Currently we can't start a new group chat, just we can join if we're invited + and then invite others. + == I would like to have support for ... If something does not work and it's not in the TODO section, then please -- cgit v1.2.3 From 86278cddbf922a051f22fb328b62ca9ae328c82b Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 7 Oct 2007 16:36:03 +0200 Subject: implement skype_chat_with() so that '/j #nick' is possible: we can start a group chat now, too --- skype/skype.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 0937400d..3f272e1f 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -72,6 +72,9 @@ struct skype_data skype_call_status call_status; /* Same for file transfers. */ skype_filetransfer_status filetransfer_status; + /* Using /j #nick we want to have a groupchat with two people. Usually + * not (default). */ + char* groupchat_with; }; struct skype_away_state @@ -433,8 +436,24 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c info++; if(!strcmp(info, "STATUS MULTI_SUBSCRIBED")) { - struct groupchat *gc; - gc = imcb_chat_new( ic, id ); + imcb_chat_new( ic, id ); + } + else if(!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) + { + struct groupchat *gc = imcb_chat_new( ic, id ); + /* According to the docs this + * is necessary. However it + * does not seem the situation + * and it would open an extra + * window on our client, so + * just leave it out. */ + /*g_snprintf(buf, 1024, "OPEN CHAT %s\n", id); + skype_write(ic, buf, strlen(buf));*/ + g_snprintf(buf, 1024, "%s@skype.com", sd->groupchat_with); + imcb_chat_add_buddy(gc, buf); + imcb_chat_add_buddy(gc, sd->username); + g_free(sd->groupchat_with); + sd->groupchat_with = NULL; } else if(!strcmp(info, "STATUS UNSUBSCRIBED")) { @@ -655,6 +674,22 @@ void skype_chat_invite(struct groupchat *gc, char *who, char *message) g_free(nick); } +struct groupchat *skype_chat_with(struct im_connection *ic, char *who) +{ + struct skype_data *sd = ic->proto_data; + char *ptr, *nick, *buf; + nick = g_strdup(who); + ptr = strchr(nick, '@'); + if(ptr) + *ptr = '\0'; + buf = g_strdup_printf("CHAT CREATE %s\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + sd->groupchat_with = g_strdup(nick); + g_free(nick); + return(NULL); +} + void init_plugin(void) { struct prpl *ret = g_new0( struct prpl, 1 ); @@ -671,6 +706,7 @@ void init_plugin(void) ret->chat_msg = skype_chat_msg; ret->chat_leave = skype_chat_leave; ret->chat_invite = skype_chat_invite; + ret->chat_with = skype_chat_with; ret->handle_cmp = g_strcasecmp; register_protocol( ret ); } -- cgit v1.2.3 From ff584450a8473361fa2ced4ae31ad1641347e9af Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 7 Oct 2007 16:37:34 +0200 Subject: docu update for recent changes --- skype/README | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index 23a383ee..b6a06e02 100644 --- a/skype/README +++ b/skype/README @@ -191,18 +191,19 @@ your VNC server regularly. (How ugly.) * Send / receive group chat messages - * Invite others + * Invite others (using `/invite `) * Part from group chats + * Starting a group chat (using `/j #nick`) + == What needs to be done (aka. TODO) - Add a question callback for calls. - Notice if foo invites bar. Currently you can see only that bar joined. -- Currently we can't start a new group chat, just we can join if we're invited - and then invite others. +- Are there public named chats for Skype? If yes, they are not supported ATM. == I would like to have support for ... -- cgit v1.2.3 From 6adca511491c58f71082f67ec755c83c8a3d1f14 Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 7 Oct 2007 17:13:32 +0200 Subject: update docu for skype-1.4.0.118 --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index b6a06e02..3445b0fb 100644 --- a/skype/README +++ b/skype/README @@ -22,7 +22,7 @@ not..) == Requirements -* Skype 1.4.0.99. 1.4.0.74 did *not* work for me. +* Skype >= 1.4.0.99. (1.4.0.74 did not work for me, 1.4.0.118 seems to be OK.) * bitlbee-dev >= rev245. Previous versions need patching. * Skype4Py >= 0.9.28.1. Previous versions uses `DBus` by default. The latest version I've tested is 0.9.28.3. * Python 2.5. Skype4Py does not work with 2.4. -- cgit v1.2.3 From 5b677eb23a1a29fc218c27bde28138e9b0addd7c Mon Sep 17 00:00:00 2001 From: VMiklos Date: Sun, 7 Oct 2007 22:56:17 +0200 Subject: updates for 0.2.0 --- skype/Makefile | 2 +- skype/NEWS | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 3f6792de..06b1712e 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.1.4 +VERSION = 0.2.0 skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) diff --git a/skype/NEWS b/skype/NEWS index b81fb5c8..e2ff922a 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,8 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.2.0 - group chat support + - ~300 lines of new code, so be careful :) + - the version number mentions that this is not a minor change 0.1.4 - documentation: mention the version of all deps (requirements section) - fix sending / sending accents -- cgit v1.2.3 From 428592094d725fd3795488e52a88c9abf79da0c0 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 14 Oct 2007 01:12:56 +0200 Subject: doc: update about group/public chats --- skype/README | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index 3445b0fb..46af4f47 100644 --- a/skype/README +++ b/skype/README @@ -203,7 +203,9 @@ your VNC server regularly. (How ugly.) - Notice if foo invites bar. Currently you can see only that bar joined. -- Are there public named chats for Skype? If yes, they are not supported ATM. +- Public chats. See link:http://forum.skype.com/index.php?showtopic=98872[this + forum thread], it is still unclear how could it be done for you to be able to + `/join` to a public chat.. == I would like to have support for ... @@ -217,7 +219,9 @@ then it would be nice to include them here. == Known bugs -- None at this time. +- When you join start a group chat, a warning is shown saying creating the + group chat is failed. Indeed it is created. I should improve the API to be + able to suppress that warning. == Screenshots -- cgit v1.2.3 From d601f9bc64776fc065a3bd7de3ef9d7868895893 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 17 Oct 2007 01:09:09 +0200 Subject: use the new imcb_chat_topic() function WARNING: this is not yet in the bitlbee release branch, i'll update the docs when it'll be there --- skype/skype.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 3f272e1f..e5403318 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -338,7 +338,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c else if(!strcmp(sd->type, "SETTOPIC")) { if(gc) - imcb_log(ic, "%s changed the topic of %s to: %s", sd->handle, gc->title, sd->body); + imcb_chat_topic(gc, sd->handle, sd->body); } else if(!strcmp(sd->type, "LEFT")) { @@ -461,6 +461,13 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if(gc) gc->data = (void*)FALSE; } + else if(!strncmp(info, "TOPIC ", 6)) + { + info += 6; + struct groupchat *gc = skype_chat_by_name(ic, id); + if(gc) + imcb_chat_topic(gc, NULL, info); + } else if(!strncmp(info, "ACTIVEMEMBERS ", 14)) { info += 14; -- cgit v1.2.3 From 09e2a69d7a43d15f3c41dc333133f8ad4d1d6ff0 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 17 Oct 2007 01:09:22 +0200 Subject: implement skype_chat_topic() --- skype/skype.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index e5403318..4d6dc7bd 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -681,6 +681,15 @@ void skype_chat_invite(struct groupchat *gc, char *who, char *message) g_free(nick); } +void skype_chat_topic(struct groupchat *gc, char *message) +{ + struct im_connection *ic = gc->ic; + char *buf; + buf = g_strdup_printf("ALTER CHAT %s SETTOPIC %s\n", gc->title, message); + skype_write( ic, buf, strlen( buf ) ); + g_free(buf); +} + struct groupchat *skype_chat_with(struct im_connection *ic, char *who) { struct skype_data *sd = ic->proto_data; @@ -715,5 +724,6 @@ void init_plugin(void) ret->chat_invite = skype_chat_invite; ret->chat_with = skype_chat_with; ret->handle_cmp = g_strcasecmp; + ret->chat_topic = skype_chat_topic; register_protocol( ret ); } -- cgit v1.2.3 From f8674dbaa346e5097d9f56657673edbf80493599 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 17 Oct 2007 02:46:38 +0200 Subject: show topic if it was set before join --- skype/skype.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 4d6dc7bd..4ad6cdb8 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -75,6 +75,8 @@ struct skype_data /* Using /j #nick we want to have a groupchat with two people. Usually * not (default). */ char* groupchat_with; + /* The user who invited us to the chat. */ + char* adder; }; struct skype_away_state @@ -437,6 +439,10 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if(!strcmp(info, "STATUS MULTI_SUBSCRIBED")) { imcb_chat_new( ic, id ); + g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); + skype_write(ic, buf, strlen(buf)); + g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); + skype_write(ic, buf, strlen(buf)); } else if(!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) { @@ -454,6 +460,10 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c imcb_chat_add_buddy(gc, sd->username); g_free(sd->groupchat_with); sd->groupchat_with = NULL; + g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); + skype_write(ic, buf, strlen(buf)); + g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); + skype_write(ic, buf, strlen(buf)); } else if(!strcmp(info, "STATUS UNSUBSCRIBED")) { @@ -461,12 +471,22 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if(gc) gc->data = (void*)FALSE; } + else if(!strncmp(info, "ADDER ", 6)) + { + info += 6; + g_free(sd->adder); + sd->adder = g_strdup_printf("%s@skype.com", info); + } else if(!strncmp(info, "TOPIC ", 6)) { info += 6; struct groupchat *gc = skype_chat_by_name(ic, id); - if(gc) - imcb_chat_topic(gc, NULL, info); + if(gc && sd->adder) + { + imcb_chat_topic(gc, sd->adder, info); + g_free(sd->adder); + sd->adder = NULL; + } } else if(!strncmp(info, "ACTIVEMEMBERS ", 14)) { -- cgit v1.2.3 From a7af5f0501df21053bde7c77e695a544821999cd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Oct 2007 00:59:41 +0200 Subject: fix incoming multiline messages - again i broke it when adding groupchat support --- skype/skype.c | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 4ad6cdb8..33f591ad 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -64,7 +64,8 @@ struct skype_data * the chatname. Store the properties here so that we can use * imcb_buddy_msg() when we got the chatname. */ char *handle; - char *body; + /* List, because of multiline messages. */ + GList *body; char *type; /* This is necessary because we send a notification when we get the * handle. So we store the state here and then we can send a @@ -313,8 +314,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c else if(!strncmp(info, "BODY ", 5)) { info += 5; - g_free(sd->body); - sd->body = g_strdup(info); + sd->body = g_list_append(sd->body, g_strdup(info)); } else if(!strncmp(info, "TYPE ", 5)) { @@ -328,25 +328,32 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if(sd->handle && sd->body && sd->type) { struct groupchat *gc = skype_chat_by_name(ic, info); - if(!strcmp(sd->type, "SAID")) - { - if(!gc) - /* Private message */ - imcb_buddy_msg(ic, sd->handle, sd->body, 0, 0); - else - /* Groupchat message */ - imcb_chat_msg(gc, sd->handle, sd->body, 0, 0); - } - else if(!strcmp(sd->type, "SETTOPIC")) - { - if(gc) - imcb_chat_topic(gc, sd->handle, sd->body); - } - else if(!strcmp(sd->type, "LEFT")) + int i; + for(i=0;ibody);i++) { - if(gc) - imcb_chat_remove_buddy(gc, sd->handle, NULL); + char *body = g_list_nth_data(sd->body, i); + if(!strcmp(sd->type, "SAID")) + { + if(!gc) + /* Private message */ + imcb_buddy_msg(ic, sd->handle, body, 0, 0); + else + /* Groupchat message */ + imcb_chat_msg(gc, sd->handle, body, 0, 0); + } + else if(!strcmp(sd->type, "SETTOPIC")) + { + if(gc) + imcb_chat_topic(gc, sd->handle, body); + } + else if(!strcmp(sd->type, "LEFT")) + { + if(gc) + imcb_chat_remove_buddy(gc, sd->handle, NULL); + } } + g_list_free(sd->body); + sd->body = NULL; } } } -- cgit v1.2.3 From edf09c6436dd5839528312d026b021a9ed07a07d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Oct 2007 01:01:07 +0200 Subject: docu update about /topic --- skype/README | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 46af4f47..571a4735 100644 --- a/skype/README +++ b/skype/README @@ -183,7 +183,13 @@ your VNC server regularly. (How ugly.) - Detect when somebody wants to transfer a file -- Handle topic changes +- Topic changes: + + * Show the current topic (if any) on join + + * Notice when someone changes the topic + + * Support changing the topic using `/topic` - Group chat support: -- cgit v1.2.3 From 56a3616934a8d5f0ed45866cccd131f6bd97ae4c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 26 Oct 2007 16:02:45 +0200 Subject: README: update "thanks to" section --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 571a4735..27e5a5c1 100644 --- a/skype/README +++ b/skype/README @@ -244,7 +244,7 @@ for the following people: * Wilmer van der Gaast, for answering questions about the bitlbee plugin interface -* awahlig (from the skype forums), for making suggestions to skyped +* Arkadiusz Wahlig, author of skype4py, for making suggestions to skyped * Gabor Adam TOTH, for usable bugreports -- cgit v1.2.3 From 760ed1fb8e6248791615c9aa60d2d2c9282e9e30 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 26 Oct 2007 21:30:10 +0200 Subject: doc update: it is now tested under Windows, too --- skype/README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/skype/README b/skype/README index 27e5a5c1..24948289 100644 --- a/skype/README +++ b/skype/README @@ -28,6 +28,9 @@ not..) * Python 2.5. Skype4Py does not work with 2.4. * pygobject +`bitlbee-skype` has been tested under Linux and Windows. Skype is available +under OSX, too, so it probably works, but this has not been tested. + == How to set it up Before you start. The setup is the following: BitlBee can't connect directly to -- cgit v1.2.3 From 3f1a946090bf1b5ff03ca933683e13fdb4cdfdd3 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 29 Oct 2007 12:35:52 +0100 Subject: check out the latest tag before compiling, HEAD won't compile with latest bitlbee --- skype/README | 1 + 1 file changed, 1 insertion(+) diff --git a/skype/README b/skype/README index 24948289..ab6ad861 100644 --- a/skype/README +++ b/skype/README @@ -66,6 +66,7 @@ make install install-dev ---- git clone http://ftp.frugalware.org/pub/other/people/vmiklos/bitlbee-skype/.git +git checkout `git tag -l|tail -n 1` ---- (Or you can use the tarballs below, see the Changelog about what -- cgit v1.2.3 From e103e735bae98a59694429884b802c8e79cead13 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 30 Oct 2007 15:24:56 +0100 Subject: update documentation for 0.2.1 --- skype/README | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/skype/README b/skype/README index ab6ad861..e49963d5 100644 --- a/skype/README +++ b/skype/README @@ -65,13 +65,14 @@ make install install-dev - Get the plugin code: ---- -git clone http://ftp.frugalware.org/pub/other/people/vmiklos/bitlbee-skype/.git -git checkout `git tag -l|tail -n 1` +git clone git://git.frugalware.org/pub/other/people/vmiklos/bitlbee-skype ---- (Or you can use the tarballs below, see the Changelog about what features/bugfixes will you miss in this case). +- Apply a not yet merged patch: http://frugalware.org/~vmiklos/patches/bitlbee-topic-write.patch[download] + - Compile and install it: ---- @@ -187,14 +188,6 @@ your VNC server regularly. (How ugly.) - Detect when somebody wants to transfer a file -- Topic changes: - - * Show the current topic (if any) on join - - * Notice when someone changes the topic - - * Support changing the topic using `/topic` - - Group chat support: * Detect if we're invited @@ -207,6 +200,14 @@ your VNC server regularly. (How ugly.) * Starting a group chat (using `/j #nick`) +- Topic changes in group chats: + + * Show the current topic (if any) on join + + * Notice when someone changes the topic + + * Support changing the topic using `/topic` + == What needs to be done (aka. TODO) - Add a question callback for calls. -- cgit v1.2.3 From c4112c4918209ef178d7efa63fe40d28ba204fd2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 30 Oct 2007 15:26:07 +0100 Subject: updates for 0.2.1 --- skype/Makefile | 2 +- skype/NEWS | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 06b1712e..23569e9a 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.2.0 +VERSION = 0.2.1 skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) diff --git a/skype/NEWS b/skype/NEWS index e2ff922a..24eca753 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,8 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.2.1 - topic support in group chats + - bugfixes for multiline messages + - this version should be again as stable as 0.1.4 was 0.2.0 - group chat support - ~300 lines of new code, so be careful :) - the version number mentions that this is not a minor change -- cgit v1.2.3 From 7cc31b187b141da628919b8044341ec13f733edc Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 11 Nov 2007 21:00:48 +0100 Subject: doc: patch is for bitlbee, not the plugin --- skype/README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index e49963d5..d9e1248e 100644 --- a/skype/README +++ b/skype/README @@ -52,7 +52,9 @@ automatically reconnect if you restart Skype.) bzr branch http://code.bitlbee.org/bitlbee/ ---- -NOTE: You no longer need additional patches, as of revision 245. +//NOTE: You no longer need additional patches, as of revision 245. +- Apply a not yet merged patch: http://frugalware.org/~vmiklos/patches/bitlbee-topic-write.patch[download] + - Now compile and install it: @@ -71,8 +73,6 @@ git clone git://git.frugalware.org/pub/other/people/vmiklos/bitlbee-skype (Or you can use the tarballs below, see the Changelog about what features/bugfixes will you miss in this case). -- Apply a not yet merged patch: http://frugalware.org/~vmiklos/patches/bitlbee-topic-write.patch[download] - - Compile and install it: ---- -- cgit v1.2.3 From 9fcaedc00fe94de64f97347ee55f92f9db970c8d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 15 Nov 2007 15:24:40 +0100 Subject: doc: deepcommand on how to apply the patch http://bugs.bitlbee.org/bitlbee/ticket/82#comment:31 - it seems it's good to mention this --- skype/README | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index d9e1248e..0678fe07 100644 --- a/skype/README +++ b/skype/README @@ -23,7 +23,8 @@ not..) == Requirements * Skype >= 1.4.0.99. (1.4.0.74 did not work for me, 1.4.0.118 seems to be OK.) -* bitlbee-dev >= rev245. Previous versions need patching. +* bitlbee-dev >= rev256. (This is the latest version I've tested, probably + newer versions probably will work, too.) * Skype4Py >= 0.9.28.1. Previous versions uses `DBus` by default. The latest version I've tested is 0.9.28.3. * Python 2.5. Skype4Py does not work with 2.4. * pygobject @@ -53,7 +54,13 @@ bzr branch http://code.bitlbee.org/bitlbee/ ---- //NOTE: You no longer need additional patches, as of revision 245. -- Apply a not yet merged patch: http://frugalware.org/~vmiklos/patches/bitlbee-topic-write.patch[download] +- Apply a not yet merged patch: + +---- +cd bitlbee +wget http://frugalware.org/~vmiklos/patches/bitlbee-topic-write.patch +patch -p0 < bitlbee-topic-write.patch +---- - Now compile and install it: -- cgit v1.2.3 From a5f76a29b323d671458cf86767cd9d785dd95309 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 20 Nov 2007 10:46:35 +0100 Subject: if you change the topic then wait for skype to confirm that it was really changed - ie if you don't have enough permissions, you won't see a fake topic - suggested by wilmer --- skype/skype.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 33f591ad..b80a256c 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -78,6 +78,8 @@ struct skype_data char* groupchat_with; /* The user who invited us to the chat. */ char* adder; + /* If we are waiting for a confirmation about we changed the topic. */ + int topic_wait; }; struct skype_away_state @@ -488,9 +490,14 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { info += 6; struct groupchat *gc = skype_chat_by_name(ic, id); - if(gc && sd->adder) + if(gc && (sd->adder || sd->topic_wait)) { - imcb_chat_topic(gc, sd->adder, info); + if(sd->topic_wait) + { + sd->adder = g_strdup(sd->username); + sd->topic_wait = 0; + } + imcb_chat_topic(gc, sd->adder, info, 0); g_free(sd->adder); sd->adder = NULL; } @@ -711,10 +718,12 @@ void skype_chat_invite(struct groupchat *gc, char *who, char *message) void skype_chat_topic(struct groupchat *gc, char *message) { struct im_connection *ic = gc->ic; + struct skype_data *sd = ic->proto_data; char *buf; buf = g_strdup_printf("ALTER CHAT %s SETTOPIC %s\n", gc->title, message); skype_write( ic, buf, strlen( buf ) ); g_free(buf); + sd->topic_wait = 1; } struct groupchat *skype_chat_with(struct im_connection *ic, char *who) -- cgit v1.2.3 From de2f05ebf0d93193fc8217fc917bc63e9d49b81e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 20 Nov 2007 10:47:43 +0100 Subject: fixes for the recent upstream API changes --- skype/skype.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index b80a256c..739e001c 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -182,7 +182,7 @@ struct groupchat *skype_chat_by_name( struct im_connection *ic, char *name ) { struct groupchat *ret; - for( ret = ic->conversations; ret; ret = ret->next ) + for( ret = ic->groupchats; ret; ret = ret->next ) { if(strcmp(name, ret->title ) == 0 ) break; @@ -346,7 +346,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c else if(!strcmp(sd->type, "SETTOPIC")) { if(gc) - imcb_chat_topic(gc, sd->handle, body); + imcb_chat_topic(gc, sd->handle, body, 0); } else if(!strcmp(sd->type, "LEFT")) { @@ -647,11 +647,12 @@ static void skype_set_away( struct im_connection *ic, char *state_txt, char *mes static GList *skype_away_states( struct im_connection *ic ) { - GList *l = NULL; + static GList *l = NULL; int i; - for( i = 0; skype_away_state_list[i].full_name; i ++ ) - l = g_list_append( l, (void*) skype_away_state_list[i].full_name ); + if( l == NULL ) + for( i = 0; skype_away_state_list[i].full_name; i ++ ) + l = g_list_append( l, (void*) skype_away_state_list[i].full_name ); return l; } -- cgit v1.2.3 From cbb5fb76c0c6adf12512915382c5db42ed5cf74c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 20 Nov 2007 10:54:22 +0100 Subject: doc update: no patching needed again, but a recent snapshot --- skype/README | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/skype/README b/skype/README index 0678fe07..a26a5c3c 100644 --- a/skype/README +++ b/skype/README @@ -23,7 +23,7 @@ not..) == Requirements * Skype >= 1.4.0.99. (1.4.0.74 did not work for me, 1.4.0.118 seems to be OK.) -* bitlbee-dev >= rev256. (This is the latest version I've tested, probably +* bitlbee-dev >= rev264. (This is the latest version I've tested, probably newer versions probably will work, too.) * Skype4Py >= 0.9.28.1. Previous versions uses `DBus` by default. The latest version I've tested is 0.9.28.3. * Python 2.5. Skype4Py does not work with 2.4. @@ -53,15 +53,7 @@ automatically reconnect if you restart Skype.) bzr branch http://code.bitlbee.org/bitlbee/ ---- -//NOTE: You no longer need additional patches, as of revision 245. -- Apply a not yet merged patch: - ----- -cd bitlbee -wget http://frugalware.org/~vmiklos/patches/bitlbee-topic-write.patch -patch -p0 < bitlbee-topic-write.patch ----- - +NOTE: You no longer need additional patches, as of revision 264. - Now compile and install it: -- cgit v1.2.3 From b06e6478dc6c6494f19d444842d1625a1b315ee1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 20 Nov 2007 10:55:35 +0100 Subject: updates for 0.2.2 --- skype/Makefile | 2 +- skype/NEWS | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 23569e9a..8cf2f637 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.2.1 +VERSION = 0.2.2 skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) diff --git a/skype/NEWS b/skype/NEWS index 24eca753..6b5b3bc2 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,8 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.2.2 - don't change the topic if skype does not report a successful + topic change + - fixed for the recent bitlbee API changes 0.2.1 - topic support in group chats - bugfixes for multiline messages - this version should be again as stable as 0.1.4 was -- cgit v1.2.3 From 668a1226df26e9de24c2dd5919c8fb7f79220fd9 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 20 Nov 2007 17:22:38 +0100 Subject: less frugalware references --- skype/README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index a26a5c3c..0644a996 100644 --- a/skype/README +++ b/skype/README @@ -1,5 +1,5 @@ = Skype plugin for BitlBee -Miklos Vajna +Miklos Vajna == Status @@ -66,7 +66,7 @@ make install install-dev - Get the plugin code: ---- -git clone git://git.frugalware.org/pub/other/people/vmiklos/bitlbee-skype +git clone git://vmiklos.hu/~vmiklos/pyrssi ---- (Or you can use the tarballs below, see the Changelog about what @@ -235,7 +235,7 @@ then it would be nice to include them here. == Screenshots -You can reach some screenshots http://frugalware.org/~vmiklos/pics/shots/bitlbee-skype/[here]. +You can reach some screenshots link:shot[here]. == Additional resources -- cgit v1.2.3 From 3d73b027895f5059f695445e1c4f2c21613775a1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 20 Nov 2007 17:28:49 +0100 Subject: fix gitweb url --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 0644a996..370d1e67 100644 --- a/skype/README +++ b/skype/README @@ -240,7 +240,7 @@ You can reach some screenshots link:shot[here]. == Additional resources You can reach the Changelog link:Changelog[here], and a gitweb interface -link:http://git.frugalware.org/gitweb/gitweb.cgi?p=bitlbee-skype.git;a=summary[here]. +http://repo.or.cz/w/bitlbee-skype.git[here]. == Thanks -- cgit v1.2.3 From eb9cbb8fd49380d73161dc197b91dadb974d18e5 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 20 Nov 2007 18:41:41 +0100 Subject: link my projects page --- skype/README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/README b/skype/README index 370d1e67..c3f0f7e3 100644 --- a/skype/README +++ b/skype/README @@ -252,4 +252,6 @@ for the following people: * Gabor Adam TOTH, for usable bugreports +Back to my link:/projects[projects page]. + // vim: ft=asciidoc -- cgit v1.2.3 From 5652d4369f6a807db7301f8d1350b7cc38abd6d1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 24 Nov 2007 00:46:20 +0100 Subject: warning fix in skype_chat_with() fix "when you start a group chat, a warning is shown saying creating the group chat is failed, but in fact it is created" --- skype/README | 4 +--- skype/skype.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/skype/README b/skype/README index c3f0f7e3..c95271dd 100644 --- a/skype/README +++ b/skype/README @@ -229,9 +229,7 @@ then it would be nice to include them here. == Known bugs -- When you join start a group chat, a warning is shown saying creating the - group chat is failed. Indeed it is created. I should improve the API to be - able to suppress that warning. +- None at this time. == Screenshots diff --git a/skype/skype.c b/skype/skype.c index 739e001c..ee9f05f1 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -445,6 +445,10 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if(info) *info = '\0'; info++; + /* Remove fake chat if we created one in skype_chat_with() */ + struct groupchat *gc = skype_chat_by_name(ic, ""); + if(gc) + imcb_chat_free(gc); if(!strcmp(info, "STATUS MULTI_SUBSCRIBED")) { imcb_chat_new( ic, id ); @@ -455,7 +459,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } else if(!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) { - struct groupchat *gc = imcb_chat_new( ic, id ); + gc = imcb_chat_new( ic, id ); /* According to the docs this * is necessary. However it * does not seem the situation @@ -476,7 +480,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } else if(!strcmp(info, "STATUS UNSUBSCRIBED")) { - struct groupchat *gc = skype_chat_by_name(ic, id); + gc = skype_chat_by_name(ic, id); if(gc) gc->data = (void*)FALSE; } @@ -489,7 +493,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c else if(!strncmp(info, "TOPIC ", 6)) { info += 6; - struct groupchat *gc = skype_chat_by_name(ic, id); + gc = skype_chat_by_name(ic, id); if(gc && (sd->adder || sd->topic_wait)) { if(sd->topic_wait) @@ -505,7 +509,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c else if(!strncmp(info, "ACTIVEMEMBERS ", 14)) { info += 14; - struct groupchat *gc = skype_chat_by_name(ic, id); + gc = skype_chat_by_name(ic, id); /* Hack! We set ->data to TRUE * while we're on the channel * so that we won't rejoin @@ -740,7 +744,9 @@ struct groupchat *skype_chat_with(struct im_connection *ic, char *who) g_free(buf); sd->groupchat_with = g_strdup(nick); g_free(nick); - return(NULL); + /* We create a fake chat for now. We will replace it with a real one in + * the real callback. */ + return(imcb_chat_new( ic, "" )); } void init_plugin(void) -- cgit v1.2.3 From fc26bcbfe29942e7f256d3504bbe53dacc690b78 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 24 Nov 2007 00:49:13 +0100 Subject: updates for 0.2.3 --- skype/Makefile | 2 +- skype/NEWS | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 8cf2f637..b2b61ad1 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.2.2 +VERSION = 0.2.3 skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) diff --git a/skype/NEWS b/skype/NEWS index 6b5b3bc2..cc05f419 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,6 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.2.3 - fixed that annoying "creating groupchat failed" warning 0.2.2 - don't change the topic if skype does not report a successful topic change - fixed for the recent bitlbee API changes -- cgit v1.2.3 From e3d8051c0026557c86bcda7cb585d5610e0e6583 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 24 Nov 2007 00:58:27 +0100 Subject: improve gitignore --- skype/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/.gitignore b/skype/.gitignore index 0bd951be..0211d468 100644 --- a/skype/.gitignore +++ b/skype/.gitignore @@ -2,3 +2,5 @@ Changelog HEADER.html *.gz *.asc +.htaccess +shot -- cgit v1.2.3 From d044a5ad221d5c80fef779eb7115868540cc019e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 24 Nov 2007 20:14:36 +0100 Subject: get rid of bzr, there is a tarball version now that works --- skype/README | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/skype/README b/skype/README index c95271dd..9ba3a23d 100644 --- a/skype/README +++ b/skype/README @@ -23,7 +23,7 @@ not..) == Requirements * Skype >= 1.4.0.99. (1.4.0.74 did not work for me, 1.4.0.118 seems to be OK.) -* bitlbee-dev >= rev264. (This is the latest version I've tested, probably +* bitlbee 1.1.1dev. (This is the latest version I've tested, probably newer versions probably will work, too.) * Skype4Py >= 0.9.28.1. Previous versions uses `DBus` by default. The latest version I've tested is 0.9.28.3. * Python 2.5. Skype4Py does not work with 2.4. @@ -47,13 +47,15 @@ automatically reconnect if you restart Skype.) and `bitlbee-skype` packages from http://ftp.frugalware.org/pub/other/people/vmiklos/bmf/[my repo]. -- You need the BitlBee bzr branch: +- You need the BitlBee testing/development version: ---- -bzr branch http://code.bitlbee.org/bitlbee/ +wget http://get.bitlbee.org/src/bitlbee-1.1.1dev.tar.gz +tar xf bitlbee-1.1.1dev.tar.gz +cd bitlbee-1.1.1dev ---- -NOTE: You no longer need additional patches, as of revision 264. +NOTE: You no longer need additional patches, as of version 1.1.1dev. - Now compile and install it: -- cgit v1.2.3 From 1138b25c5134e895ba82310ad09de1eefde23d4e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 24 Nov 2007 20:32:23 +0100 Subject: do not refer to the empty known bugs section --- skype/README | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/skype/README b/skype/README index 9ba3a23d..b4b2c92f 100644 --- a/skype/README +++ b/skype/README @@ -5,13 +5,9 @@ Miklos Vajna One day I browsed the BitlBee bugtracker and found http://bugs.bitlbee.org/bitlbee/ticket/82[this] ticket. Then after a while I -returned and saw that it was still open. So I wrote it. Not a big deal, I wrote -it in two days or so (and not because I'm a genius or anything ;-) ). I think -it's pretty stable, but it needs wider testing. Also see the 'Known bugs' -section, I really hope those random hangups will be fixed soon by Skype. +returned and saw that it was still open. So I wrote it. -Oh, before I forget. I'm not a wizard, the Skype API documentation is -https://developer.skype.com/Docs/ApiDoc[here] if you're interested. +It's pretty stable, I use it for my daily work. NOTE: You will see that this implementation of the Skype plug-in still requires a Skype instance to be running. This is because I'm not motivated to reverse -- cgit v1.2.3 From c09f90f82a3f7750eab01dd8a66df7e37453f7ae Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 24 Nov 2007 20:32:36 +0100 Subject: move the skype api doc link to the resources section --- skype/README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/skype/README b/skype/README index b4b2c92f..962276ad 100644 --- a/skype/README +++ b/skype/README @@ -238,6 +238,9 @@ You can reach some screenshots link:shot[here]. You can reach the Changelog link:Changelog[here], and a gitweb interface http://repo.or.cz/w/bitlbee-skype.git[here]. +The Skype API documentation is +https://developer.skype.com/Docs/ApiDoc[here] if you're interested. + == Thanks for the following people: -- cgit v1.2.3 From 23ba69e1e7e28a265fa0c9f73953b21c9291bb5a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 29 Nov 2007 12:46:25 +0100 Subject: typo in git url --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 962276ad..ec57e7e6 100644 --- a/skype/README +++ b/skype/README @@ -64,7 +64,7 @@ make install install-dev - Get the plugin code: ---- -git clone git://vmiklos.hu/~vmiklos/pyrssi +git clone git://vmiklos.hu/~vmiklos/bitlbee-skype ---- (Or you can use the tarballs below, see the Changelog about what -- cgit v1.2.3 From 4eaadf6de030e402f8c58b2b00341167f2927a70 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 4 Dec 2007 01:23:49 +0100 Subject: README: added a quote, from the closing mail of the skype ticket --- skype/README | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/skype/README b/skype/README index ec57e7e6..58a2ebf9 100644 --- a/skype/README +++ b/skype/README @@ -3,6 +3,15 @@ Miklos Vajna == Status +[Wilmer van der Gaast (author of BitlBee)] +____ +Okay, this exists now, with lots of thanks to vmiklos for his *excellent* +work!! + +It's not in the main BitlBee and it'll never be for various reasons, but +because it's a plugin that shouldn't be a problem. +____ + One day I browsed the BitlBee bugtracker and found http://bugs.bitlbee.org/bitlbee/ticket/82[this] ticket. Then after a while I returned and saw that it was still open. So I wrote it. -- cgit v1.2.3 From 20994cb19ef3a4486b816e387b990f756bc607f1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 9 Dec 2007 22:45:35 +0100 Subject: add a note about no patching is required as today a guy asked on #bitlbee if he need a special branch.. --- skype/README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 58a2ebf9..04263a63 100644 --- a/skype/README +++ b/skype/README @@ -16,7 +16,8 @@ One day I browsed the BitlBee bugtracker and found http://bugs.bitlbee.org/bitlbee/ticket/82[this] ticket. Then after a while I returned and saw that it was still open. So I wrote it. -It's pretty stable, I use it for my daily work. +It's pretty stable, I use it for my daily work. Being a plug-in, you patching +is required, you can just install it after installing BitlBee itself. NOTE: You will see that this implementation of the Skype plug-in still requires a Skype instance to be running. This is because I'm not motivated to reverse -- cgit v1.2.3 From 2042b562628c17ce5771d1c8891029588001373b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 9 Dec 2007 22:46:45 +0100 Subject: typo --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 04263a63..1addf5e4 100644 --- a/skype/README +++ b/skype/README @@ -16,7 +16,7 @@ One day I browsed the BitlBee bugtracker and found http://bugs.bitlbee.org/bitlbee/ticket/82[this] ticket. Then after a while I returned and saw that it was still open. So I wrote it. -It's pretty stable, I use it for my daily work. Being a plug-in, you patching +It's pretty stable, I use it for my daily work. Being a plug-in, no patching is required, you can just install it after installing BitlBee itself. NOTE: You will see that this implementation of the Skype plug-in still requires -- cgit v1.2.3 From 6e97a7af2d31e18f53d528fb3c2e89214d0f4f14 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 10 Dec 2007 22:42:29 +0100 Subject: note about "you can run git whereever you want" as requested by timing on irc --- skype/README | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/skype/README b/skype/README index 1addf5e4..3b30484b 100644 --- a/skype/README +++ b/skype/README @@ -80,9 +80,14 @@ git clone git://vmiklos.hu/~vmiklos/bitlbee-skype (Or you can use the tarballs below, see the Changelog about what features/bugfixes will you miss in this case). +NOTE: It doesn't matter where do you get it, it'll install the plugin to +`/usr/local` by default (that's the location where BitlBee searches for plugins +by default). + - Compile and install it: ---- +cd bitlbee-skype make prepare ./configure make -- cgit v1.2.3 From 05cf92706f26eb672577e22a7c52ee839d58c5f7 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 14 Dec 2007 01:59:42 +0100 Subject: fixup for Skype4Py >= 0.9.28.4 --- skype/README | 3 ++- skype/skyped.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index 3b30484b..6f455a0a 100644 --- a/skype/README +++ b/skype/README @@ -31,7 +31,8 @@ not..) * Skype >= 1.4.0.99. (1.4.0.74 did not work for me, 1.4.0.118 seems to be OK.) * bitlbee 1.1.1dev. (This is the latest version I've tested, probably newer versions probably will work, too.) -* Skype4Py >= 0.9.28.1. Previous versions uses `DBus` by default. The latest version I've tested is 0.9.28.3. +* Skype4Py >= 0.9.28.4. Previous versions report synchronous replies twice. The + latest version I've tested is 0.9.28.7. * Python 2.5. Skype4Py does not work with 2.4. * pygobject diff --git a/skype/skyped.py b/skype/skyped.py index 22b0b322..704a9891 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -121,8 +121,10 @@ class SkypeApi(): e = msg_text.decode(locale.getdefaultlocale()[1]) dprint('>> ' + e) try: - self.skype.SendCommand(self.skype.Command(-1, e)) - except Skype4Py.ISkypeError: + c = self.skype.Command(e, Block=True) + self.skype.SendCommand(c) + self.recv(c.Reply) + except Skype4Py.SkypeError: pass except Skype4Py.SkypeAPIError, s: dprint("Warning, sending '%s' failed (%s)." % (e, s)) -- cgit v1.2.3 From 3d9fd79665242851b84b85ebfa042a78bb116079 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 14 Dec 2007 02:13:21 +0100 Subject: skype2beta tested \o/ --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 6f455a0a..8b3f4349 100644 --- a/skype/README +++ b/skype/README @@ -28,7 +28,7 @@ not..) == Requirements -* Skype >= 1.4.0.99. (1.4.0.74 did not work for me, 1.4.0.118 seems to be OK.) +* Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.27. * bitlbee 1.1.1dev. (This is the latest version I've tested, probably newer versions probably will work, too.) * Skype4Py >= 0.9.28.4. Previous versions report synchronous replies twice. The -- cgit v1.2.3 From bfbb1aac92c4f0d2d26cf23bab9a83b06ae8a743 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 14 Dec 2007 02:14:05 +0100 Subject: updates for 0.2.4 --- skype/Makefile | 2 +- skype/NEWS | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index b2b61ad1..89fe7e3e 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.2.3 +VERSION = 0.2.4 skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) diff --git a/skype/NEWS b/skype/NEWS index cc05f419..47a0ca73 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,9 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.2.4 - improve documentation based on feedback from people on #bitlbee + - fixed for Skype4Py >= 0.9.28.4 + - tested with latest Skype beta, too (the one which supports + video) 0.2.3 - fixed that annoying "creating groupchat failed" warning 0.2.2 - don't change the topic if skype does not report a successful topic change -- cgit v1.2.3 From eb39102f161a6d59533c68c27134200f47b7e982 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 14 Dec 2007 02:26:43 +0100 Subject: fixed skype4py requirement --- skype/README | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/skype/README b/skype/README index 8b3f4349..09f07987 100644 --- a/skype/README +++ b/skype/README @@ -31,8 +31,7 @@ not..) * Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.27. * bitlbee 1.1.1dev. (This is the latest version I've tested, probably newer versions probably will work, too.) -* Skype4Py >= 0.9.28.4. Previous versions report synchronous replies twice. The - latest version I've tested is 0.9.28.7. +* Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. * Python 2.5. Skype4Py does not work with 2.4. * pygobject -- cgit v1.2.3 From 437ddf537f59fba82cb266c3b7ab208297317770 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 14 Dec 2007 02:37:27 +0100 Subject: added "people on #bitlbee" to the thanks section in fact they again and again reported that newer skype4py does not work, so without them i would not fix it :P --- skype/README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/README b/skype/README index 09f07987..e4bf184b 100644 --- a/skype/README +++ b/skype/README @@ -266,6 +266,8 @@ for the following people: * Gabor Adam TOTH, for usable bugreports +* people on `#bitlbee` for feedback + Back to my link:/projects[projects page]. // vim: ft=asciidoc -- cgit v1.2.3 From 31b4793afbb7744c7b72de361fbce840c85ab0d5 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 15 Dec 2007 23:24:39 +0100 Subject: i just noticed we don't support the info command --- skype/README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/README b/skype/README index e4bf184b..b8179287 100644 --- a/skype/README +++ b/skype/README @@ -230,6 +230,8 @@ your VNC server regularly. (How ugly.) forum thread], it is still unclear how could it be done for you to be able to `/join` to a public chat.. +- Implement `info` command. + == I would like to have support for ... If something does not work and it's not in the TODO section, then please -- cgit v1.2.3 From 46e7de3b304e82755d1073471781806b2cfc4bcb Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 03:55:55 +0100 Subject: convert client.c to py it's for testing purposes only and i hate to recompile it again and again ;) --- skype/client.c | 43 ------------------------------------------- skype/client.py | 7 +++++++ 2 files changed, 7 insertions(+), 43 deletions(-) delete mode 100644 skype/client.c create mode 100644 skype/client.py diff --git a/skype/client.c b/skype/client.c deleted file mode 100644 index 66a3f770..00000000 --- a/skype/client.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#define MESSAGE_LEN 1023 -#define PORTNUM 2727 - -char *invoke(int sock, char *cmd) -{ - char buf[MESSAGE_LEN+1]; - int len; - - write(sock, cmd, strlen(cmd)); - len = recv(sock, buf, MESSAGE_LEN, 0); - buf[len] = '\0'; - return strdup(buf); -} - -int main(int argc, char *argv[]) -{ - int sock; - struct sockaddr_in dest; - char *ptr; - - sock = socket(AF_INET, SOCK_STREAM, 0); - - memset(&dest, 0, sizeof(dest)); - dest.sin_family = AF_INET; - dest.sin_addr.s_addr = inet_addr("127.0.0.1"); - dest.sin_port = htons(PORTNUM); - - connect(sock, (struct sockaddr *)&dest, sizeof(struct sockaddr)); - - ptr = invoke(sock, "SET USER foo ISAUTHORIZED FALSE"); - printf("ptr: '%s'\n", ptr); - close(sock); - return(0); -} diff --git a/skype/client.py b/skype/client.py new file mode 100644 index 00000000..378a4660 --- /dev/null +++ b/skype/client.py @@ -0,0 +1,7 @@ +import socket + +client = socket.socket ( socket.AF_INET, socket.SOCK_STREAM ) +client.connect ( ( 'localhost', 2727 ) ) + +client.send("GET USERSTATUS") +print client.recv(1024) -- cgit v1.2.3 From 737e9d99ca5afe80214ccacf3d4a3737cb443188 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 03:55:55 +0100 Subject: remove hardwired command from client tester --- skype/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/client.py b/skype/client.py index 378a4660..62686c22 100644 --- a/skype/client.py +++ b/skype/client.py @@ -1,7 +1,7 @@ -import socket +import socket, sys client = socket.socket ( socket.AF_INET, socket.SOCK_STREAM ) client.connect ( ( 'localhost', 2727 ) ) -client.send("GET USERSTATUS") +client.send(sys.argv[1]) print client.recv(1024) -- cgit v1.2.3 From 67454bd5fa026e9c71ad1fb462d757e5890ffbe4 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 03:55:55 +0100 Subject: initial support for the info command currently it prints only the full name --- skype/skype.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index ee9f05f1..66e5e171 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -80,6 +80,22 @@ struct skype_data char* adder; /* If we are waiting for a confirmation about we changed the topic. */ int topic_wait; + /* These are used by the info command. */ + char *info_fullname; + char *info_phonehome; + char *info_phoneoffice; + char *info_phonemobile; + char *info_nrbuddies; + char *info_tz; + char *info_seen; + char *info_birthday; + char *info_sex; + char *info_language; + char *info_country; + char *info_province; + char *info_city; + char *info_homepage; + char *info_about; }; struct skype_away_state @@ -266,6 +282,22 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c g_free(buf); } } + else if(!strncmp(ptr, "FULLNAME ", 9)) + sd->info_fullname = g_strdup_printf("%s", ptr + 9); + else if(!strncmp(ptr, "ABOUT ", 6)) + { + sd->info_about = g_strdup_printf("%s", ptr + 6); + + GString *st = g_string_new("User Info\n"); + g_string_append_printf(st, "Skype Name: %s\n", user); + if(sd->info_fullname) + { + g_string_append_printf(st, "Full Name: %s\n", sd->info_fullname); + g_free(sd->info_fullname); + } + imcb_log(ic, "%s", st->str); + g_string_free(st, TRUE); + } } else if(!strncmp(line, "CHATMESSAGE ", 12)) { @@ -749,6 +781,60 @@ struct groupchat *skype_chat_with(struct im_connection *ic, char *who) return(imcb_chat_new( ic, "" )); } +static void skype_get_info(struct im_connection *ic, char *who) +{ + char *ptr, *nick, *buf; + nick = g_strdup(who); + ptr = strchr(nick, '@'); + if(ptr) + *ptr = '\0'; + buf = g_strdup_printf("GET USER %s FULLNAME\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s PHONE_HOME\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s PHONE_OFFICE\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s PHONE_MOBILE\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s NROF_AUTHED_BUDDIES\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s TIMEZONE\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s LASTONLINETIMESTAMP\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s BIRTHDAY\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s SEX\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s LANGUAGE\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s COUNTRY\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s PROVINCE\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s CITY\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s HOMEPAGE\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); + buf = g_strdup_printf("GET USER %s ABOUT\n", nick); + skype_write(ic, buf, strlen(buf)); + g_free(buf); +} + void init_plugin(void) { struct prpl *ret = g_new0( struct prpl, 1 ); @@ -758,6 +844,7 @@ void init_plugin(void) ret->init = skype_init; ret->logout = skype_logout; ret->buddy_msg = skype_buddy_msg; + ret->get_info = skype_get_info; ret->away_states = skype_away_states; ret->set_away = skype_set_away; ret->add_buddy = skype_add_buddy; -- cgit v1.2.3 From 93052e1653e20b2d48aaa4b37b6dfe11644a9d58 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 03:55:56 +0100 Subject: added much more info output, need to finetune format --- skype/skype.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 66e5e171..72a45204 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -284,17 +284,129 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } else if(!strncmp(ptr, "FULLNAME ", 9)) sd->info_fullname = g_strdup_printf("%s", ptr + 9); + else if(!strncmp(ptr, "PHONE_HOME ", 11)) + sd->info_phonehome = g_strdup_printf("%s", ptr + 11); + else if(!strncmp(ptr, "PHONE_OFFICE ", 13)) + sd->info_phoneoffice = g_strdup_printf("%s", ptr + 13); + else if(!strncmp(ptr, "PHONE_MOBILE ", 13)) + sd->info_phonemobile = g_strdup_printf("%s", ptr + 13); + else if(!strncmp(ptr, "NROF_AUTHED_BUDDIES ", 20)) + sd->info_nrbuddies = g_strdup_printf("%s", ptr + 20); + else if(!strncmp(ptr, "TIMEZONE ", 9)) + sd->info_tz = g_strdup_printf("%s", ptr + 9); + else if(!strncmp(ptr, "LASTONLINETIMESTAMP ", 20)) + sd->info_seen = g_strdup_printf("%s", ptr + 20); + else if(!strncmp(ptr, "BIRTHDAY ", 9)) + sd->info_birthday = g_strdup_printf("%s", ptr + 9); + else if(!strncmp(ptr, "SEX ", 4)) + sd->info_sex = g_strdup_printf("%s", ptr + 4); + else if(!strncmp(ptr, "LANGUAGE ", 9)) + sd->info_language = g_strdup_printf("%s", ptr + 9); + else if(!strncmp(ptr, "COUNTRY ", 8)) + sd->info_country = g_strdup_printf("%s", ptr + 8); + else if(!strncmp(ptr, "PROVINCE ", 9)) + sd->info_province = g_strdup_printf("%s", ptr + 9); + else if(!strncmp(ptr, "CITY ", 5)) + sd->info_city = g_strdup_printf("%s", ptr + 5); + else if(!strncmp(ptr, "HOMEPAGE ", 9)) + sd->info_homepage = g_strdup_printf("%s", ptr + 9); else if(!strncmp(ptr, "ABOUT ", 6)) { sd->info_about = g_strdup_printf("%s", ptr + 6); - GString *st = g_string_new("User Info\n"); + GString *st = g_string_new("Contact Information\n"); g_string_append_printf(st, "Skype Name: %s\n", user); if(sd->info_fullname) { - g_string_append_printf(st, "Full Name: %s\n", sd->info_fullname); + if(strlen(sd->info_fullname)) + g_string_append_printf(st, "Full Name: %s\n", sd->info_fullname); g_free(sd->info_fullname); } + if(sd->info_phonehome) + { + if(strlen(sd->info_phonehome)) + g_string_append_printf(st, "Home Phone: %s\n", sd->info_phonehome); + g_free(sd->info_phonehome); + } + if(sd->info_phoneoffice) + { + if(strlen(sd->info_phoneoffice)) + g_string_append_printf(st, "Office Phone: %s\n", sd->info_phoneoffice); + g_free(sd->info_phoneoffice); + } + if(sd->info_phonemobile) + { + if(strlen(sd->info_phonemobile)) + g_string_append_printf(st, "Mobile Phone: %s\n", sd->info_phonemobile); + g_free(sd->info_phonemobile); + } + g_string_append_printf(st, "Personal Information\n"); + if(sd->info_nrbuddies) + { + if(strlen(sd->info_nrbuddies)) + g_string_append_printf(st, "Contacts: %s\n", sd->info_nrbuddies); + g_free(sd->info_nrbuddies); + } + if(sd->info_tz) + { + if(strlen(sd->info_tz)) + g_string_append_printf(st, "Local Time: %s\n", sd->info_tz); + g_free(sd->info_tz); + } + if(sd->info_seen) + { + if(strlen(sd->info_seen)) + g_string_append_printf(st, "Last Seen: %s\n", sd->info_seen); + g_free(sd->info_seen); + } + if(sd->info_birthday) + { + if(strlen(sd->info_birthday)) + g_string_append_printf(st, "Birthday: %s\n", sd->info_birthday); + g_free(sd->info_birthday); + } + if(sd->info_sex) + { + if(strlen(sd->info_sex)) + g_string_append_printf(st, "Gender: %s\n", sd->info_sex); + g_free(sd->info_sex); + } + if(sd->info_language) + { + if(strlen(sd->info_language)) + g_string_append_printf(st, "Language: %s\n", sd->info_language); + g_free(sd->info_language); + } + if(sd->info_country) + { + if(strlen(sd->info_country)) + g_string_append_printf(st, "Country: %s\n", sd->info_country); + g_free(sd->info_country); + } + if(sd->info_province) + { + if(strlen(sd->info_province)) + g_string_append_printf(st, "Region: %s\n", sd->info_province); + g_free(sd->info_province); + } + if(sd->info_city) + { + if(strlen(sd->info_city)) + g_string_append_printf(st, "City: %s\n", sd->info_city); + g_free(sd->info_city); + } + if(sd->info_homepage) + { + if(strlen(sd->info_homepage)) + g_string_append_printf(st, "Homepage: %s\n", sd->info_homepage); + g_free(sd->info_homepage); + } + if(sd->info_about) + { + if(strlen(sd->info_about)) + g_string_append_printf(st, "%s\n", sd->info_about); + g_free(sd->info_about); + } imcb_log(ic, "%s", st->str); g_string_free(st, TRUE); } -- cgit v1.2.3 From 885efac6586aa289ce3db2b83313c318715eb09f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 03:55:56 +0100 Subject: fixed country and language format --- skype/skype.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 72a45204..fccd96e3 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -350,37 +350,64 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if(sd->info_tz) { if(strlen(sd->info_tz)) + { + // FIXME secs -> str g_string_append_printf(st, "Local Time: %s\n", sd->info_tz); + } g_free(sd->info_tz); } if(sd->info_seen) { if(strlen(sd->info_seen)) + { + // FIXME unixtimestamp -> str g_string_append_printf(st, "Last Seen: %s\n", sd->info_seen); + } g_free(sd->info_seen); } if(sd->info_birthday) { if(strlen(sd->info_birthday)) + { + // FIXME 19880101 -> str g_string_append_printf(st, "Birthday: %s\n", sd->info_birthday); + g_string_append_printf(st, "Age:\n"); + } g_free(sd->info_birthday); } if(sd->info_sex) { if(strlen(sd->info_sex)) + { + // FIXME: UNKNOWN -> Unknown g_string_append_printf(st, "Gender: %s\n", sd->info_sex); + } g_free(sd->info_sex); } if(sd->info_language) { if(strlen(sd->info_language)) - g_string_append_printf(st, "Language: %s\n", sd->info_language); + { + char *iptr = strchr(sd->info_language, ' '); + if(iptr) + iptr++; + else + iptr = sd->info_language; + g_string_append_printf(st, "Language: %s\n", iptr); + } g_free(sd->info_language); } if(sd->info_country) { if(strlen(sd->info_country)) - g_string_append_printf(st, "Country: %s\n", sd->info_country); + { + char *iptr = strchr(sd->info_country, ' '); + if(iptr) + iptr++; + else + iptr = sd->info_country; + g_string_append_printf(st, "Country: %s\n", sd->iptr); + } g_free(sd->info_country); } if(sd->info_province) -- cgit v1.2.3 From bdde8058f78ab11a3e0bad48c61de97df720dec8 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 03:55:56 +0100 Subject: disable buggy "local time" field --- skype/skype.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index fccd96e3..126fcf7a 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -351,8 +351,8 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { if(strlen(sd->info_tz)) { - // FIXME secs -> str - g_string_append_printf(st, "Local Time: %s\n", sd->info_tz); + /* this is currently buggy, says gmt+12 when I set gmt+1 + g_string_append_printf(st, "Local Time: %s\n", sd->info_tz); */ } g_free(sd->info_tz); } -- cgit v1.2.3 From 3c5adedc913d32af69a62f48bf368c18fb57ffbe Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 03:55:56 +0100 Subject: format last seen output properly --- skype/skype.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 126fcf7a..6bbddf0c 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -360,8 +360,11 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { if(strlen(sd->info_seen)) { - // FIXME unixtimestamp -> str - g_string_append_printf(st, "Last Seen: %s\n", sd->info_seen); + char ib[256]; + time_t it = atoi(sd->info_seen); + struct tm *tm = localtime(&it); + strftime(ib, 256, ("%Y. %m. %d. %H:%M"), tm); + g_string_append_printf(st, "Last Seen: %s\n", ib); } g_free(sd->info_seen); } -- cgit v1.2.3 From 191470d0245cffba19899660f84f77a2a18d08da Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 03:55:56 +0100 Subject: typo fix in country output --- skype/skype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 6bbddf0c..5322d3ac 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -409,7 +409,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c iptr++; else iptr = sd->info_country; - g_string_append_printf(st, "Country: %s\n", sd->iptr); + g_string_append_printf(st, "Country: %s\n", iptr); } g_free(sd->info_country); } -- cgit v1.2.3 From f9c3e7b63c2847e381f29572820c4415afb3efd5 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 03:55:56 +0100 Subject: fixed birthday output --- skype/skype.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 5322d3ac..f0f608a7 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -23,6 +23,7 @@ * USA. */ +#define _XOPEN_SOURCE #include #include #include @@ -372,8 +373,11 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { if(strlen(sd->info_birthday)) { - // FIXME 19880101 -> str - g_string_append_printf(st, "Birthday: %s\n", sd->info_birthday); + char ib[256]; + struct tm tm; + strptime(sd->info_birthday, "%Y%m%d", &tm); + strftime(ib, 256, "%B %d, %Y", &tm); + g_string_append_printf(st, "Birthday: %s\n", ib); g_string_append_printf(st, "Age:\n"); } g_free(sd->info_birthday); -- cgit v1.2.3 From 5b9847d174938e61a76bb19da33ec28f2ca3b931 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 03:55:56 +0100 Subject: fixed age output --- skype/skype.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index f0f608a7..9f1ee607 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -378,7 +378,12 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c strptime(sd->info_birthday, "%Y%m%d", &tm); strftime(ib, 256, "%B %d, %Y", &tm); g_string_append_printf(st, "Birthday: %s\n", ib); - g_string_append_printf(st, "Age:\n"); + + strftime(ib, 256, "%Y", &tm); + int year = atoi(ib); + time_t t = time(NULL); + struct tm *lt = localtime(&t); + g_string_append_printf(st, "Age: %d\n", lt->tm_year+1900-year); } g_free(sd->info_birthday); } -- cgit v1.2.3 From 6b43dd46d96b452d41b6b2581414ffdeb2c32335 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 03:55:56 +0100 Subject: fixed gender output woho, last fixme removed \o/ --- skype/skype.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 9f1ee607..f83d6d1d 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -391,7 +391,9 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { if(strlen(sd->info_sex)) { - // FIXME: UNKNOWN -> Unknown + char *iptr = sd->info_sex; + while(*iptr++) + *iptr = tolower(*iptr); g_string_append_printf(st, "Gender: %s\n", sd->info_sex); } g_free(sd->info_sex); -- cgit v1.2.3 From fb36492f9c1ddc58b8c164c32f7a437b60d5453c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 04:01:40 +0100 Subject: update doc: info is implemented time for a release soon.. --- skype/README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index b8179287..01567a84 100644 --- a/skype/README +++ b/skype/README @@ -220,6 +220,8 @@ your VNC server regularly. (How ugly.) * Support changing the topic using `/topic` +- Viewing the profile using the `info` command. + == What needs to be done (aka. TODO) - Add a question callback for calls. @@ -230,8 +232,6 @@ your VNC server regularly. (How ugly.) forum thread], it is still unclear how could it be done for you to be able to `/join` to a public chat.. -- Implement `info` command. - == I would like to have support for ... If something does not work and it's not in the TODO section, then please -- cgit v1.2.3 From 33cac975a40690c1c2a40a5e3b9d65c23c49893a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 22:04:10 +0100 Subject: add "local time" info output thanks Cristobal Palmer (tarheelcoxn) for testing :) --- skype/skype.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index f83d6d1d..0bbfbcb1 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -352,8 +352,12 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { if(strlen(sd->info_tz)) { - /* this is currently buggy, says gmt+12 when I set gmt+1 - g_string_append_printf(st, "Local Time: %s\n", sd->info_tz); */ + char ib[256]; + time_t t = time(NULL); + t += atoi(sd->info_tz)-(60*60*24); + struct tm *gt = gmtime(&t); + strftime(ib, 256, "%H:%M:%S", gt); + g_string_append_printf(st, "Local Time: %s\n", ib); } g_free(sd->info_tz); } -- cgit v1.2.3 From 969f6437c47d1d4428a501542df614d1213ae811 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 22:06:51 +0100 Subject: handle the case when the birthday is unknown --- skype/skype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 0bbfbcb1..2fcff1e3 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -375,7 +375,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } if(sd->info_birthday) { - if(strlen(sd->info_birthday)) + if(strlen(sd->info_birthday) && strcmp(sd->info_birthday, "0")) { char ib[256]; struct tm tm; -- cgit v1.2.3 From 98345979993a59dacdfea030385a42a842488d5e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 22:10:02 +0100 Subject: readme: update thanks section --- skype/README | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 01567a84..71643a6f 100644 --- a/skype/README +++ b/skype/README @@ -266,7 +266,11 @@ for the following people: * Arkadiusz Wahlig, author of skype4py, for making suggestions to skyped -* Gabor Adam TOTH, for usable bugreports +* Gabor Adam Toth (tg), for noticing extra code is needed to handle multiline + messages + +* Cristobal Palmer (tarheelcoxn), for helping to testing the plugin in a + timezone different to mine * people on `#bitlbee` for feedback -- cgit v1.2.3 From 7f93882d16380c9464923ae32fcbbb0df7313d91 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 23:38:27 +0100 Subject: new todo (i think first i need to do it in bitlbee) --- skype/README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/README b/skype/README index 71643a6f..879b2f2a 100644 --- a/skype/README +++ b/skype/README @@ -232,6 +232,8 @@ your VNC server regularly. (How ugly.) forum thread], it is still unclear how could it be done for you to be able to `/join` to a public chat.. +- Handle skype actions (when the `CHATMESSAGE` has `EMOTED` type) + == I would like to have support for ... If something does not work and it's not in the TODO section, then please -- cgit v1.2.3 From c01edb786c306dcc3bddd750b9cf495cc52fc5e6 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 23:41:54 +0100 Subject: updates for 0.2.5 --- skype/Makefile | 2 +- skype/NEWS | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 89fe7e3e..8b4dc318 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.2.4 +VERSION = 0.2.5 skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) diff --git a/skype/NEWS b/skype/NEWS index 47a0ca73..9ac12ada 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,7 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.2.5 - now bitlbee's info command is supported (it displays full name, + birthday, homepage, age, etc.) 0.2.4 - improve documentation based on feedback from people on #bitlbee - fixed for Skype4Py >= 0.9.28.4 - tested with latest Skype beta, too (the one which supports -- cgit v1.2.3 From 6d0b26bbeadda9a60a51d27fdf4216f4756815dc Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Dec 2007 23:54:36 +0100 Subject: update doc: git url changed --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 879b2f2a..c5b8bdef 100644 --- a/skype/README +++ b/skype/README @@ -74,7 +74,7 @@ make install install-dev - Get the plugin code: ---- -git clone git://vmiklos.hu/~vmiklos/bitlbee-skype +git clone git://vmiklos.hu/bitlbee-skype ---- (Or you can use the tarballs below, see the Changelog about what -- cgit v1.2.3 From c60b864216ada769f66337040a8f436604071a7d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 18 Dec 2007 21:04:55 +0100 Subject: doc update - probably newer python/bitlbee versions work, too - update note about the common dbus session: it should be a common display now --- skype/README | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/skype/README b/skype/README index c5b8bdef..ee00d195 100644 --- a/skype/README +++ b/skype/README @@ -29,10 +29,10 @@ not..) == Requirements * Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.27. -* bitlbee 1.1.1dev. (This is the latest version I've tested, probably +* bitlbee >= 1.1.1dev. (This is the latest version I've tested, probably newer versions probably will work, too.) * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. -* Python 2.5. Skype4Py does not work with 2.4. +* Python >= 2.5. Skype4Py does not work with 2.4. * pygobject `bitlbee-skype` has been tested under Linux and Windows. Skype is available @@ -111,8 +111,8 @@ skype skyped ---- -NOTE: It's important to start `skyped` on the same machine and using the same -user! +NOTE: You should run `skyped` on the same `X11` display, otherwise it won't be +able to connect to Skype! - Start your `IRC` client, connect to BitlBee and add your account: -- cgit v1.2.3 From 4bbd9dbb5bdcda09f05535902dd7ae20f4d4a264 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 10 Jan 2008 17:10:09 +0100 Subject: rename SKYPE_PORT_DEFAULT to SKYPE_DEFAULT_PORT --- skype/skype.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 2fcff1e3..854377bb 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -29,7 +29,7 @@ #include #include -#define SKYPE_PORT_DEFAULT "2727" +#define SKYPE_DEFAULT_PORT "2727" /* * Enumerations @@ -135,7 +135,7 @@ static void skype_init( account_t *acc ) { set_t *s; - s = set_add( &acc->set, "port", SKYPE_PORT_DEFAULT, set_eval_int, acc ); + s = set_add( &acc->set, "port", SKYPE_DEFAULT_PORT, set_eval_int, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); -- cgit v1.2.3 From f5aedd9110935ad7b6ec7d6df4dac125bc0576c4 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 10 Jan 2008 17:10:10 +0100 Subject: added default server "localhost" --- skype/README | 1 - skype/skype.c | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/skype/README b/skype/README index ee00d195..f26a5c1c 100644 --- a/skype/README +++ b/skype/README @@ -118,7 +118,6 @@ able to connect to Skype! ---- account add skype -account set 0/server localhost ---- IMPORTANT: should be your Skype account name. This way you won't see diff --git a/skype/skype.c b/skype/skype.c index 854377bb..92773bbe 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -29,6 +29,7 @@ #include #include +#define SKYPE_DEFAULT_SERVER "localhost" #define SKYPE_DEFAULT_PORT "2727" /* @@ -138,8 +139,8 @@ static void skype_init( account_t *acc ) s = set_add( &acc->set, "port", SKYPE_DEFAULT_PORT, set_eval_int, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; - s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); - s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; + s = set_add( &acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account, acc ); + s->flags |= ACC_SET_OFFLINE_ONLY; } int skype_write( struct im_connection *ic, char *buf, int len ) @@ -774,7 +775,7 @@ static void skype_login( account_t *acc ) ic->proto_data = sd; imcb_log( ic, "Connecting" ); - sd->fd = proxy_connect(acc->server, set_getint( &acc->set, "port" ), skype_connected, ic ); + sd->fd = proxy_connect(set_getstr( &acc->set, "server" ), set_getint( &acc->set, "port" ), skype_connected, ic ); sd->username = g_strdup( acc->user ); sd->ic = ic; -- cgit v1.2.3 From 6abf3ec985d1ce9d9394fa17fbdd1162e4b1b702 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 10 Jan 2008 17:10:10 +0100 Subject: skype_init(): cosmetics --- skype/skype.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 92773bbe..030a471e 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -136,10 +136,10 @@ static void skype_init( account_t *acc ) { set_t *s; - s = set_add( &acc->set, "port", SKYPE_DEFAULT_PORT, set_eval_int, acc ); + s = set_add( &acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; - s = set_add( &acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account, acc ); + s = set_add( &acc->set, "port", SKYPE_DEFAULT_PORT, set_eval_int, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; } -- cgit v1.2.3 From 54e6207a103a521c49582458dc857fd5c6641346 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 10 Jan 2008 17:10:10 +0100 Subject: support for receiving emoted messages --- skype/skype.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 030a471e..c26b489c 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -524,14 +524,22 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c for(i=0;ibody);i++) { char *body = g_list_nth_data(sd->body, i); - if(!strcmp(sd->type, "SAID")) + if(!strcmp(sd->type, "SAID") || !strcmp(sd->type, "EMOTED")) { + char *st; + if(!strcmp(sd->type, "SAID")) + st = g_strdup(body); + else + { + st = g_strdup_printf("/me %s", body); + } if(!gc) /* Private message */ - imcb_buddy_msg(ic, sd->handle, body, 0, 0); + imcb_buddy_msg(ic, sd->handle, st, 0, 0); else /* Groupchat message */ - imcb_chat_msg(gc, sd->handle, body, 0, 0); + imcb_chat_msg(gc, sd->handle, st, 0, 0); + g_free(st); } else if(!strcmp(sd->type, "SETTOPIC")) { -- cgit v1.2.3 From 61728715f9701af2a516f24fee50a379aca0eb6f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 10 Jan 2008 17:10:10 +0100 Subject: added vim modeline --- skype/skype.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index c26b489c..804803d0 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -1023,3 +1023,5 @@ void init_plugin(void) ret->chat_topic = skype_chat_topic; register_protocol( ret ); } + +/* vim: set ts=2 sw=2 noet: */ -- cgit v1.2.3 From 93dffeafa371bc2384dd13229d15fc31fab62d00 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 10 Jan 2008 17:10:10 +0100 Subject: new skype_set_display_name() function - this adds support for setting display_name - also add support for the deprecated nick command in skype_set_my_name() --- skype/skype.c | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 804803d0..4e7c13ba 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -132,17 +132,6 @@ const struct skype_away_state skype_away_state_list[] = * Functions */ -static void skype_init( account_t *acc ) -{ - set_t *s; - - s = set_add( &acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account, acc ); - s->flags |= ACC_SET_OFFLINE_ONLY; - - s = set_add( &acc->set, "port", SKYPE_DEFAULT_PORT, set_eval_int, acc ); - s->flags |= ACC_SET_OFFLINE_ONLY; -} - int skype_write( struct im_connection *ic, char *buf, int len ) { struct skype_data *sd = ic->proto_data; @@ -859,6 +848,19 @@ static GList *skype_away_states( struct im_connection *ic ) return l; } +static char *skype_set_display_name( set_t *set, char *value ) +{ + account_t *acc = set->data; + struct im_connection *ic = acc->ic; + //struct skype_data *sd = ic->proto_data; + char *buf; + + buf = g_strdup_printf("SET PROFILE MOOD_TEXT %s", value); + skype_write( ic, buf, strlen( buf ) ); + g_free(buf); + return(value); +} + static void skype_add_buddy( struct im_connection *ic, char *who, char *group ) { char *buf, *nick, *ptr; @@ -1001,6 +1003,25 @@ static void skype_get_info(struct im_connection *ic, char *who) g_free(buf); } +static void skype_set_my_name( struct im_connection *ic, char *info ) +{ + skype_set_display_name( set_find( &ic->acc->set, "display_name" ), info ); +} + +static void skype_init( account_t *acc ) +{ + set_t *s; + + s = set_add( &acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account, acc ); + s->flags |= ACC_SET_OFFLINE_ONLY; + + s = set_add( &acc->set, "port", SKYPE_DEFAULT_PORT, set_eval_int, acc ); + s->flags |= ACC_SET_OFFLINE_ONLY; + + s = set_add( &acc->set, "display_name", NULL, skype_set_display_name, acc ); + s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; +} + void init_plugin(void) { struct prpl *ret = g_new0( struct prpl, 1 ); @@ -1011,6 +1032,7 @@ void init_plugin(void) ret->logout = skype_logout; ret->buddy_msg = skype_buddy_msg; ret->get_info = skype_get_info; + ret->set_my_name = skype_set_my_name; ret->away_states = skype_away_states; ret->set_away = skype_set_away; ret->add_buddy = skype_add_buddy; -- cgit v1.2.3 From d1eb24c8f34946f47f9e592a75675d2ee01742ab Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 10 Jan 2008 17:35:25 +0100 Subject: updates for 0.2.6 --- skype/Makefile | 2 +- skype/NEWS | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 8b4dc318..721d1209 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.2.5 +VERSION = 0.2.6 skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) diff --git a/skype/NEWS b/skype/NEWS index 9ac12ada..e5f26efe 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,11 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.2.6 - the server setting has a default value, 'localhost' so in most + cases you no longer have to set it explicitly + - support for receiving emoted messages, ie. when the user types + '/me foo' + - support for setting the display name (nick 0 "foo bar") - it + sets the mood text 0.2.5 - now bitlbee's info command is supported (it displays full name, birthday, homepage, age, etc.) 0.2.4 - improve documentation based on feedback from people on #bitlbee -- cgit v1.2.3 From a06a0a55a8040efa5c276ee464025effb30973f9 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 10 Jan 2008 17:38:51 +0100 Subject: todo update --- skype/README | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index f26a5c1c..e2f868ba 100644 --- a/skype/README +++ b/skype/README @@ -221,6 +221,10 @@ your VNC server regularly. (How ugly.) - Viewing the profile using the `info` command. +- Handling skype actions (when the `CHATMESSAGE` has `EMOTED` type) + +- Setting your mood text using the `nick` command. + == What needs to be done (aka. TODO) - Add a question callback for calls. @@ -231,8 +235,6 @@ your VNC server regularly. (How ugly.) forum thread], it is still unclear how could it be done for you to be able to `/join` to a public chat.. -- Handle skype actions (when the `CHATMESSAGE` has `EMOTED` type) - == I would like to have support for ... If something does not work and it's not in the TODO section, then please -- cgit v1.2.3 From 680920f539ba0536c64124dd3ae76bda3f54e8bd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 10 Jan 2008 17:48:39 +0100 Subject: copyright update --- skype/skype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 4e7c13ba..df1d6bee 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -1,7 +1,7 @@ /* * skype.c - Skype plugin for BitlBee * - * Copyright (c) 2007 by Miklos Vajna + * Copyright (c) 2007, 2008 by Miklos Vajna * * Several ideas are used from the BitlBee Jabber plugin, which is * -- cgit v1.2.3 From 7e450c3787005c29658b08c7dd8ba684233d177f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 11 Jan 2008 21:29:28 +0100 Subject: skyped: allow overwriting the host '0.0.0.0' --- skype/skyped.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 704a9891..007d867c 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -134,6 +134,7 @@ class Options: self.daemon = True self.debug = False self.help = False + self.host = "0.0.0.0" self.port = 2727 self.version = False @@ -145,15 +146,16 @@ skyped is a daemon that acts as a tcp server on top of a Skype instance. Options: -d --debug enable debug messages -h --help this help + -H --host set the tcp host (default: %s) -n --nofork don't run as daemon in the background -p --port set the tcp port (default: %d) - -v --version display version information""" % self.port + -v --version display version information""" % (self.host, self.port) sys.exit(ret) if __name__=='__main__': options = Options() try: - opts, args = getopt.getopt(sys.argv[1:], "dhnp:v", ["daemon", "help", "nofork", "port=", "version"]) + opts, args = getopt.getopt(sys.argv[1:], "dhH:np:v", ["daemon", "help", "host=", "nofork", "port=", "version"]) except getopt.GetoptError: options.usage(1) for opt, arg in opts: @@ -161,6 +163,8 @@ if __name__=='__main__': options.debug = True elif opt in ("-h", "--help"): options.help = True + elif opt in ("-H", "--host"): + options.host = arg elif opt in ("-n", "--nofork"): options.daemon = False elif opt in ("-p", "--port"): @@ -183,7 +187,7 @@ if __name__=='__main__': else: print 'skyped is started on port %s, pid: %d' % (options.port, pid) sys.exit(0) - server('0.0.0.0', options.port) + server(options.host, options.port) try: skype = SkypeApi() except Skype4Py.SkypeAPIError, s: -- cgit v1.2.3 From a0b206b4506ec4f1c30d82fab6a054e162bf7a14 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 02:33:27 +0100 Subject: skype_start_stream(): send username/password to skyped --- skype/skype.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index df1d6bee..f9dbf0f5 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -747,6 +747,14 @@ gboolean skype_start_stream( struct im_connection *ic ) if( sd->bfd <= 0 ) sd->bfd = b_input_add( sd->fd, GAIM_INPUT_READ, skype_read_callback, ic ); + /* Log in */ + buf = g_strdup_printf("USERNAME %s\n", ic->acc->user); + st = skype_write( ic, buf, strlen( buf ) ); + g_free(buf); + buf = g_strdup_printf("PASSWORD %s\n", ic->acc->pass); + st = skype_write( ic, buf, strlen( buf ) ); + g_free(buf); + /* This will download all buddies. */ buf = g_strdup_printf("SEARCH FRIENDS\n"); st = skype_write( ic, buf, strlen( buf ) ); -- cgit v1.2.3 From 5245e9d785fced3ef1232e47f1ee5a7fbef396b4 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 02:36:54 +0100 Subject: skyped: add authentication support this is not yet ssl, but better than nothing --- skype/skyped.conf.dist | 4 +++ skype/skyped.py | 81 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 65 insertions(+), 20 deletions(-) create mode 100644 skype/skyped.conf.dist diff --git a/skype/skyped.conf.dist b/skype/skyped.conf.dist new file mode 100644 index 00000000..43faa0c6 --- /dev/null +++ b/skype/skyped.conf.dist @@ -0,0 +1,4 @@ +[skyped] +username = john +# use `echo -n foo|sha1sum` to generate this hash for your password +password = 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33 diff --git a/skype/skyped.py b/skype/skyped.py index 007d867c..c2b102a3 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -34,21 +34,25 @@ import socket import getopt import Skype4Py import threading +import sha +from ConfigParser import ConfigParser __version__ = "0.1.1" SKYPE_SERVICE = 'com.Skype.API' CLIENT_NAME = 'SkypeApiPythonShell' -# well, this is a bit hackish. we store the socket of the last connected client -# here and notify it. maybe later notify all connected clients? -conn = None - def input_handler(fd, io_condition): - input = fd.recv(1024) - for i in input.split("\n"): - skype.send(i.strip()) - return True + global options + if options.buf: + for i in options.buf: + skype.send(i.strip()) + options.buf = None + else: + input = fd.recv(1024) + for i in input.split("\n"): + skype.send(i.strip()) + return True def idle_handler(skype): try: @@ -69,11 +73,28 @@ def server(host, port): gobject.io_add_watch(sock, gobject.IO_IN, listener) def listener(sock, *args): - global conn - conn, addr = sock.accept() - fileno = conn.fileno() - gobject.io_add_watch(conn, gobject.IO_IN, input_handler) - return True + global options + options.conn, addr = sock.accept() + lines = options.conn.recv(512).split('\n') + ret = 0 + nlines = [] + for i in lines: + if i.startswith("USERNAME") and i.split(' ')[1].strip() == options.config.username: + ret += 1 + elif i.startswith("PASSWORD") and sha.sha(i.split(' ')[1].strip()).hexdigest() == options.config.password: + ret += 1 + else: + nlines.append(i) + del lines + if ret == 2: + dprint("Username and password OK.") + options.buf = nlines + input_handler(None, None) + gobject.io_add_watch(options.conn, gobject.IO_IN, input_handler) + return True + else: + dprint("Username and/or password WRONG.") + return False def dprint(msg): global options @@ -88,7 +109,7 @@ class SkypeApi(): self.skype.Attach() def recv(self, msg_text): - global conn + global options if msg_text == "PONG": return if "\n" in msg_text: @@ -109,9 +130,9 @@ class SkypeApi(): # everybody will be happy e = i.encode('UTF-8') dprint('<< ' + e) - if conn: + if options.conn: try: - conn.send(e + "\n") + options.conn.send(e + "\n") except IOError, s: dprint("Warning, sending '%s' failed (%s)." % (e, s)) @@ -131,12 +152,19 @@ class SkypeApi(): class Options: def __init__(self): + self.cfgpath = "/etc/skyped.conf" self.daemon = True self.debug = False self.help = False self.host = "0.0.0.0" self.port = 2727 self.version = False + # well, this is a bit hackish. we store the socket of the last connected client + # here and notify it. maybe later notify all connected clients? + self.conn = None + # this will be read first by the input handler + self.buf = None + def usage(self, ret): print """Usage: skyped [OPTION]... @@ -144,22 +172,25 @@ class Options: skyped is a daemon that acts as a tcp server on top of a Skype instance. Options: + -c --config path to configuration file (default: %s) -d --debug enable debug messages -h --help this help -H --host set the tcp host (default: %s) -n --nofork don't run as daemon in the background -p --port set the tcp port (default: %d) - -v --version display version information""" % (self.host, self.port) + -v --version display version information""" % (self.cfgpath, self.host, self.port) sys.exit(ret) if __name__=='__main__': options = Options() try: - opts, args = getopt.getopt(sys.argv[1:], "dhH:np:v", ["daemon", "help", "host=", "nofork", "port=", "version"]) + opts, args = getopt.getopt(sys.argv[1:], "c:dhH:np:v", ["config=", "daemon", "help", "host=", "nofork", "port=", "version"]) except getopt.GetoptError: options.usage(1) for opt, arg in opts: - if opt in ("-d", "--debug"): + if opt in ("-c", "--config"): + options.cfgpath = arg + elif opt in ("-d", "--debug"): options.debug = True elif opt in ("-h", "--help"): options.help = True @@ -176,7 +207,17 @@ if __name__=='__main__': elif options.version: print "skyped %s" % __version__ sys.exit(0) - elif options.daemon: + # parse our config + if not os.path.exists(options.cfgpath): + print "Can't find configuration file at '%s'." % options.cfgpath + print "Use the -c option to specify an alternate one." + sys.exit(1) + options.config = ConfigParser() + options.config.read(options.cfgpath) + options.config.username = options.config.get('skyped', 'username').split('#')[0] + options.config.password = options.config.get('skyped', 'password').split('#')[0] + dprint("Parsing config file '%s' done, username is '%s'." % (options.cfgpath, options.config.username)) + if options.daemon: pid = os.fork() if pid == 0: nullin = file('/dev/null', 'r') -- cgit v1.2.3 From a3262d1e02907d5f53b2654cd121ce4535a7f412 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 02:41:44 +0100 Subject: install the default skyped config --- skype/Makefile | 3 +++ skype/config.mak.in | 1 + 2 files changed, 4 insertions(+) diff --git a/skype/Makefile b/skype/Makefile index 721d1209..a117dd71 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -8,8 +8,11 @@ skype.so: skype.c config.mak install: skype.so skyped.py $(INSTALL) -d $(DESTDIR)$(plugindir) $(INSTALL) -d $(DESTDIR)$(bindir) + $(INSTALL) -d $(DESTDIR)$(sysconfdir) $(INSTALL) skype.so $(DESTDIR)$(plugindir) $(INSTALL) skyped.py $(DESTDIR)$(bindir)/skyped + sed -i 's|/etc|$(sysconfdir)|' $(DESTDIR)$(bindir)/skyped + $(INSTALL) -m644 skyped.conf.dist $(DESTDIR)$(sysconfdir)/skyped.conf client: client.c diff --git a/skype/config.mak.in b/skype/config.mak.in index 28c50513..4dd6ac47 100644 --- a/skype/config.mak.in +++ b/skype/config.mak.in @@ -2,6 +2,7 @@ CFLAGS = @CFLAGS@ LDFLAGS = @LDFLAGS@ INSTALL = @INSTALL@ prefix = @prefix@ +sysconfdir = @sysconfdir@ exec_prefix = @exec_prefix@ bindir = @bindir@ libdir = @libdir@ -- cgit v1.2.3 From e65ceaa6ba982fbfe14cfa191a56279f61c58a91 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 02:45:59 +0100 Subject: update doc: pass should now patch in bitlbee and skyped.conf --- skype/README | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/skype/README b/skype/README index e2f868ba..54e6f5e3 100644 --- a/skype/README +++ b/skype/README @@ -104,6 +104,11 @@ problems]), but I wanted to prevent a large code duplication from that project. In addition it then no longer requires the `dbus-python` package, just `pygobject`.) +- Edit `/usr/local/etc/skyped.conf`: adjust `username` and `password`. The + `username` should be your Skype login and the `password` can be whatever you + want, but you will have to specify that one when adding the Skype account to + BitlBee (see later). + - Start Skype and `skyped` (the tcp server): ---- @@ -120,10 +125,8 @@ able to connect to Skype! account add skype ---- -IMPORTANT: should be your Skype account name. This way you won't see -yourself joining to `&bitlbee`. - -NOTE: the option is not used currently. + should be your Skype account name, should be the one you declared +in `skyped.conf`. == Setting up Skype in a VNC server (optional) -- cgit v1.2.3 From c7304b27f173fed8e2a68272186b1575937ef98b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 21:07:10 +0100 Subject: auth via ssl - move the config file to sysconfdir/skyped/skyped.conf as there will other config files there, too - autogenerate the ssl paths in skyped.conf.dist - skype plugin: connect via ssl - skyped: listen via ssl --- skype/Makefile | 2 +- skype/config.mak.in | 2 +- skype/configure.ac | 1 + skype/skype.c | 33 +++++++++++++++++++++++++++------ skype/skyped.conf.dist | 4 ---- skype/skyped.conf.dist.in | 6 ++++++ skype/skyped.py | 32 ++++++++++++++++++-------------- 7 files changed, 54 insertions(+), 26 deletions(-) delete mode 100644 skype/skyped.conf.dist create mode 100644 skype/skyped.conf.dist.in diff --git a/skype/Makefile b/skype/Makefile index a117dd71..46165b1d 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -11,7 +11,7 @@ install: skype.so skyped.py $(INSTALL) -d $(DESTDIR)$(sysconfdir) $(INSTALL) skype.so $(DESTDIR)$(plugindir) $(INSTALL) skyped.py $(DESTDIR)$(bindir)/skyped - sed -i 's|/etc|$(sysconfdir)|' $(DESTDIR)$(bindir)/skyped + sed -i 's|/usr/local/etc/skyped|$(sysconfdir)|' $(DESTDIR)$(bindir)/skyped $(INSTALL) -m644 skyped.conf.dist $(DESTDIR)$(sysconfdir)/skyped.conf client: client.c diff --git a/skype/config.mak.in b/skype/config.mak.in index 4dd6ac47..7a63bf35 100644 --- a/skype/config.mak.in +++ b/skype/config.mak.in @@ -2,7 +2,7 @@ CFLAGS = @CFLAGS@ LDFLAGS = @LDFLAGS@ INSTALL = @INSTALL@ prefix = @prefix@ -sysconfdir = @sysconfdir@ +sysconfdir = @sysconfdir@/skyped exec_prefix = @exec_prefix@ bindir = @bindir@ libdir = @libdir@ diff --git a/skype/configure.ac b/skype/configure.ac index 36c4fdcd..08ba6f91 100644 --- a/skype/configure.ac +++ b/skype/configure.ac @@ -16,3 +16,4 @@ PKG_CHECK_MODULES(BITLBEE, bitlbee) CFLAGS="$CFLAGS $BITLBEE_CFLAGS" LDFLAGS="$LDFLAGS $BITLBEE_LIBS" AC_OUTPUT(config.mak) +AC_OUTPUT(skyped.conf.dist) diff --git a/skype/skype.c b/skype/skype.c index f9dbf0f5..7f5be9e7 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #define SKYPE_DEFAULT_SERVER "localhost" @@ -62,6 +63,8 @@ struct skype_data /* File descriptor returned by bitlbee. we store it so we know when * we're connected and when we aren't. */ int bfd; + /* ssl_getfd() uses this to get the file desciptor. */ + void *ssl; /* When we receive a new message id, we query the properties, finally * the chatname. Store the properties here so that we can use * imcb_buddy_msg() when we got the chatname. */ @@ -145,11 +148,10 @@ int skype_write( struct im_connection *ic, char *buf, int len ) poll(pfd, 1, 1000); if(pfd[0].revents & POLLHUP) { - imcb_error( ic, "Could not connect to server" ); imc_logout( ic, TRUE ); return FALSE; } - write( sd->fd, buf, len ); + ssl_write( sd->ssl, buf, len ); return TRUE; } @@ -209,7 +211,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if( !sd || sd->fd == -1 ) return FALSE; /* Read the whole data. */ - st = read( sd->fd, buf, sizeof( buf ) ); + st = ssl_read( sd->ssl, buf, sizeof( buf ) ); if( st > 0 ) { buf[st] = '\0'; @@ -719,6 +721,16 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } } } + else if(!strncmp(line, "PASSWORD ", 9)) + { + if(!strncmp(line+9, "OK", 2)) + imcb_connected(ic); + else + { + imcb_error(ic, "Authentication Failed"); + imc_logout( ic, TRUE ); + } + } lineptr++; } g_strfreev(lines); @@ -765,10 +777,18 @@ gboolean skype_start_stream( struct im_connection *ic ) return st; } -gboolean skype_connected( gpointer data, gint source, b_input_condition cond ) +gboolean skype_connected( gpointer data, void *source, b_input_condition cond ) { struct im_connection *ic = data; - imcb_connected(ic); + struct skype_data *sd = ic->proto_data; + if(!source) + { + sd->ssl = NULL; + imcb_error( ic, "Could not connect to server" ); + imc_logout( ic, TRUE ); + return FALSE; + } + imcb_log( ic, "Connected to server, logging in" ); return skype_start_stream(ic); } @@ -780,7 +800,8 @@ static void skype_login( account_t *acc ) ic->proto_data = sd; imcb_log( ic, "Connecting" ); - sd->fd = proxy_connect(set_getstr( &acc->set, "server" ), set_getint( &acc->set, "port" ), skype_connected, ic ); + sd->ssl = ssl_connect(set_getstr( &acc->set, "server" ), set_getint( &acc->set, "port" ), skype_connected, ic ); + sd->fd = sd->ssl ? ssl_getfd( sd->ssl ) : -1; sd->username = g_strdup( acc->user ); sd->ic = ic; diff --git a/skype/skyped.conf.dist b/skype/skyped.conf.dist deleted file mode 100644 index 43faa0c6..00000000 --- a/skype/skyped.conf.dist +++ /dev/null @@ -1,4 +0,0 @@ -[skyped] -username = john -# use `echo -n foo|sha1sum` to generate this hash for your password -password = 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33 diff --git a/skype/skyped.conf.dist.in b/skype/skyped.conf.dist.in new file mode 100644 index 00000000..a98d5ec8 --- /dev/null +++ b/skype/skyped.conf.dist.in @@ -0,0 +1,6 @@ +[skyped] +username = john +# use `echo -n foo|sha1sum` to generate this hash for your password +password = 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33 +cert = @sysconfdir@/skyped/skyped.cert.pem +key = @sysconfdir@/skyped/skyped.key.pem diff --git a/skype/skyped.py b/skype/skyped.py index c2b102a3..5e80a433 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -36,6 +36,7 @@ import Skype4Py import threading import sha from ConfigParser import ConfigParser +from OpenSSL import SSL __version__ = "0.1.1" @@ -66,7 +67,12 @@ def idle_handler(skype): return True def server(host, port): - sock = socket.socket() + global options + + ctx = SSL.Context(SSL.TLSv1_METHOD) + ctx.use_privatekey_file(options.config.sslkey) + ctx.use_certificate_file(options.config.sslcert) + sock = SSL.Connection(ctx, socket.socket()) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind((host, port)) sock.listen(1) @@ -75,25 +81,21 @@ def server(host, port): def listener(sock, *args): global options options.conn, addr = sock.accept() - lines = options.conn.recv(512).split('\n') ret = 0 - nlines = [] - for i in lines: - if i.startswith("USERNAME") and i.split(' ')[1].strip() == options.config.username: - ret += 1 - elif i.startswith("PASSWORD") and sha.sha(i.split(' ')[1].strip()).hexdigest() == options.config.password: - ret += 1 - else: - nlines.append(i) - del lines + line = options.conn.recv(1024) + if line.startswith("USERNAME") and line.split(' ')[1].strip() == options.config.username: + ret += 1 + line = options.conn.recv(1024) + if line.startswith("PASSWORD") and sha.sha(line.split(' ')[1].strip()).hexdigest() == options.config.password: + ret += 1 if ret == 2: dprint("Username and password OK.") - options.buf = nlines - input_handler(None, None) + options.conn.send("PASSWORD OK\n") gobject.io_add_watch(options.conn, gobject.IO_IN, input_handler) return True else: dprint("Username and/or password WRONG.") + options.conn.send("PASSWORD KO\n") return False def dprint(msg): @@ -152,7 +154,7 @@ class SkypeApi(): class Options: def __init__(self): - self.cfgpath = "/etc/skyped.conf" + self.cfgpath = "/usr/local/etc/skyped/skyped.conf" self.daemon = True self.debug = False self.help = False @@ -216,6 +218,8 @@ if __name__=='__main__': options.config.read(options.cfgpath) options.config.username = options.config.get('skyped', 'username').split('#')[0] options.config.password = options.config.get('skyped', 'password').split('#')[0] + options.config.sslkey = options.config.get('skyped', 'key').split('#')[0] + options.config.sslcert = options.config.get('skyped', 'cert').split('#')[0] dprint("Parsing config file '%s' done, username is '%s'." % (options.cfgpath, options.config.username)) if options.daemon: pid = os.fork() -- cgit v1.2.3 From 55664fc0503182dc27913df8ac2232eb8d979ca4 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 21:09:54 +0100 Subject: add skyped.cnf for easier ssl cert generation --- skype/Makefile | 1 + skype/skyped.cnf | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 skype/skyped.cnf diff --git a/skype/Makefile b/skype/Makefile index 46165b1d..641f1b99 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -13,6 +13,7 @@ install: skype.so skyped.py $(INSTALL) skyped.py $(DESTDIR)$(bindir)/skyped sed -i 's|/usr/local/etc/skyped|$(sysconfdir)|' $(DESTDIR)$(bindir)/skyped $(INSTALL) -m644 skyped.conf.dist $(DESTDIR)$(sysconfdir)/skyped.conf + $(INSTALL) -m644 skyped.cnf $(DESTDIR)$(sysconfdir) client: client.c diff --git a/skype/skyped.cnf b/skype/skyped.cnf new file mode 100644 index 00000000..c7dc9098 --- /dev/null +++ b/skype/skyped.cnf @@ -0,0 +1,40 @@ +# create RSA certs - Server + +RANDFILE = skyped.rnd + +[ req ] +default_bits = 1024 +encrypt_key = yes +distinguished_name = req_dn +x509_extensions = cert_type + +[ req_dn ] +countryName = Country Name (2 letter code) +countryName_default = HU +countryName_min = 2 +countryName_max = 2 + +stateOrProvinceName = State or Province Name (full name) +stateOrProvinceName_default = Some-State + +localityName = Locality Name (eg, city) + +0.organizationName = Organization Name (eg, company) +0.organizationName_default = Stunnel Developers Ltd + +organizationalUnitName = Organizational Unit Name (eg, section) +#organizationalUnitName_default = + +0.commonName = Common Name (FQDN of your server) +0.commonName_default = localhost + +# To create a certificate for more than one name uncomment: +# 1.commonName = DNS alias of your server +# 2.commonName = DNS alias of your server +# ... +# See http://home.netscape.com/eng/security/ssl_2.0_certificate.html +# to see how Netscape understands commonName. + +[ cert_type ] +nsCertType = server + -- cgit v1.2.3 From 52d377d66b103eabecc5ddeab826b51c869b1c43 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 21:12:50 +0100 Subject: update documentation about how to generate ssl certs --- skype/README | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 54e6f5e3..7faeb3d1 100644 --- a/skype/README +++ b/skype/README @@ -104,11 +104,22 @@ problems]), but I wanted to prevent a large code duplication from that project. In addition it then no longer requires the `dbus-python` package, just `pygobject`.) -- Edit `/usr/local/etc/skyped.conf`: adjust `username` and `password`. The +- Edit `/usr/local/etc/skyped/skyped.conf`: adjust `username` and `password`. The `username` should be your Skype login and the `password` can be whatever you want, but you will have to specify that one when adding the Skype account to BitlBee (see later). +NOTE: Here, and later - `/usr/local/etc` can be different on your installation +if you used the `--sysconfdir` switch when running bitlbee-skype's `configure`. + +- Generate the SSL pem files: + +---- +cd /usr/local/etc/skyped +openssl req -new -x509 -days 365 -nodes -config skyped.cnf -out skyped.cert.pem \ + -keyout skyped.key.pem +---- + - Start Skype and `skyped` (the tcp server): ---- -- cgit v1.2.3 From b2fa16be5ab06a2704d03f015ffe06905e0079bc Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 21:17:00 +0100 Subject: updates for 0.3.0 --- skype/Makefile | 2 +- skype/NEWS | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 641f1b99..69f71624 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.2.6 +VERSION = 0.3.0 skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) diff --git a/skype/NEWS b/skype/NEWS index e5f26efe..29025d1e 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,9 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.3.0 - authentication support in skyped via ssl + - ~200 lines of new code, so be careful :) + - upgraders: please read the documentation about how to set up + your config the ssl certificate, this was no necessary till now 0.2.6 - the server setting has a default value, 'localhost' so in most cases you no longer have to set it explicitly - support for receiving emoted messages, ie. when the user types -- cgit v1.2.3 From ccb50f556a067aabcac4a21c9300aadd7443f313 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 21:21:36 +0100 Subject: update docs --- skype/README | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/skype/README b/skype/README index 7faeb3d1..b4fd613e 100644 --- a/skype/README +++ b/skype/README @@ -56,9 +56,9 @@ automatically reconnect if you restart Skype.) - You need the BitlBee testing/development version: ---- -wget http://get.bitlbee.org/src/bitlbee-1.1.1dev.tar.gz -tar xf bitlbee-1.1.1dev.tar.gz -cd bitlbee-1.1.1dev +$ wget http://get.bitlbee.org/src/bitlbee-1.1.1dev.tar.gz +$ tar xf bitlbee-1.1.1dev.tar.gz +$ cd bitlbee-1.1.1dev ---- NOTE: You no longer need additional patches, as of version 1.1.1dev. @@ -66,15 +66,15 @@ NOTE: You no longer need additional patches, as of version 1.1.1dev. - Now compile and install it: ---- -./configure -make -make install install-dev +$ ./configure +$ make +# make install install-dev ---- - Get the plugin code: ---- -git clone git://vmiklos.hu/bitlbee-skype +$ git clone git://vmiklos.hu/bitlbee-skype ---- (Or you can use the tarballs below, see the Changelog about what @@ -87,11 +87,11 @@ by default). - Compile and install it: ---- -cd bitlbee-skype -make prepare -./configure -make -make install +$ cd bitlbee-skype +$ make prepare +$ ./configure +$ make +# make install ---- - Install http://skype4py.sourceforge.net/[Skype4Py]. @@ -115,16 +115,19 @@ if you used the `--sysconfdir` switch when running bitlbee-skype's `configure`. - Generate the SSL pem files: ---- -cd /usr/local/etc/skyped -openssl req -new -x509 -days 365 -nodes -config skyped.cnf -out skyped.cert.pem \ +# cd /usr/local/etc/skyped +# openssl req -new -x509 -days 365 -nodes -config skyped.cnf -out skyped.cert.pem \ -keyout skyped.key.pem ---- +NOTE: Maybe you want to adjust the permissions in the `/usr/local/etc/skyped` +dir. For example make it readable by just your user. + - Start Skype and `skyped` (the tcp server): ---- -skype -skyped +$ skype +$ skyped ---- NOTE: You should run `skyped` on the same `X11` display, otherwise it won't be @@ -148,7 +151,7 @@ work, too. First run ---- -vncpasswd ~/.vnc/passwd +$ vncpasswd ~/.vnc/passwd ---- and create a password. You will need it at least once. @@ -167,13 +170,13 @@ skyped Adjust the permissions: ---- -chmod +x ~/.vnc/xstartup +$ chmod +x ~/.vnc/xstartup ---- Then start the server: ---- -vncserver +$ vncserver ---- Then connect to it, and set up Skype (username, password, enable auto-login, and @@ -239,6 +242,9 @@ your VNC server regularly. (How ugly.) - Setting your mood text using the `nick` command. +- Running Skype on a machine different to BitlBee is possible, the + communication is encrypted. + == What needs to be done (aka. TODO) - Add a question callback for calls. -- cgit v1.2.3 From fdde7d808ddcbfa3d5d823a4e7591d7a61d0716f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 21:22:42 +0100 Subject: one idea for the todo --- skype/README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/skype/README b/skype/README index b4fd613e..48d67f4d 100644 --- a/skype/README +++ b/skype/README @@ -255,6 +255,9 @@ your VNC server regularly. (How ugly.) forum thread], it is still unclear how could it be done for you to be able to `/join` to a public chat.. +- Split skyped from the plugin, so that one could install just the relevant + code if they are not running on the same machine. + == I would like to have support for ... If something does not work and it's not in the TODO section, then please -- cgit v1.2.3 From a74f5b53ebcded2cb5ff06b6036f816b626bae8e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 21:34:25 +0100 Subject: skyped: update copyright year --- skype/skyped.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index 5e80a433..0966efdd 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -2,7 +2,7 @@ # # skyped.py # -# Copyright (c) 2007 by Miklos Vajna +# Copyright (c) 2007, 2008 by Miklos Vajna # # It uses several code from a very basic python CLI interface, available at: # -- cgit v1.2.3 From d96380bd58e419e758cd9776b9b47fa51e5c1f77 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 22:00:35 +0100 Subject: update HACKING --- skype/HACKING | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/HACKING b/skype/HACKING index 22ca883f..dbaa74cc 100644 --- a/skype/HACKING +++ b/skype/HACKING @@ -11,7 +11,7 @@ run -v -n -D 3) skyped: -python skyped.py -n -d +python skyped.py -n -d -c ./skyped.conf 4) skype -- cgit v1.2.3 From 10a42d94c44b245588ee24ac87fb81666ce6007e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 22:05:39 +0100 Subject: put localhost back to readme as it may now more likely that one wants to run skyped on a remote machine --- skype/README | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index 48d67f4d..b870f042 100644 --- a/skype/README +++ b/skype/README @@ -136,11 +136,12 @@ able to connect to Skype! - Start your `IRC` client, connect to BitlBee and add your account: ---- -account add skype +account add skype localhost ---- should be your Skype account name, should be the one you declared -in `skyped.conf`. +in `skyped.conf`. If you want to run skyped on a remote machine, replace +`localhost` with the name of the machine. == Setting up Skype in a VNC server (optional) -- cgit v1.2.3 From eeeb30e43cdc2b3f648040404bebb557e0075422 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jan 2008 22:18:21 +0100 Subject: skyped: catch KeyboardInterrupts everywhere --- skype/skyped.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 0966efdd..15c67dce 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -37,12 +37,22 @@ import threading import sha from ConfigParser import ConfigParser from OpenSSL import SSL +from traceback import print_exception +#from exceptions import KeyboardInterrupt __version__ = "0.1.1" SKYPE_SERVICE = 'com.Skype.API' CLIENT_NAME = 'SkypeApiPythonShell' +def eh(type, value, tb): + if type == KeyboardInterrupt: + sys.exit("Exiting.") + print_exception(type, value, tb) + sys.exit(1) + +sys.excepthook = eh + def input_handler(fd, io_condition): global options if options.buf: @@ -60,10 +70,7 @@ def idle_handler(skype): skype.skype.SendCommand(skype.skype.Command(-1, "PING")) except Skype4Py.SkypeAPIError, s: dprint("Warning, pinging Skype failed (%s)." % (s)) - try: time.sleep(2) - except KeyboardInterrupt: - sys.exit("Exiting.") return True def server(host, port): -- cgit v1.2.3 From 57f04408a7ce65084d5a41221bb4f5ed71895a1f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 15 Jan 2008 04:03:08 +0100 Subject: spelling fix --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index b870f042..72716812 100644 --- a/skype/README +++ b/skype/README @@ -30,7 +30,7 @@ not..) * Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.27. * bitlbee >= 1.1.1dev. (This is the latest version I've tested, probably - newer versions probably will work, too.) + newer versions will work, too.) * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. * Python >= 2.5. Skype4Py does not work with 2.4. * pygobject -- cgit v1.2.3 From 3b495c08bd989f5ef3249a41b2caa37f9dabfa7d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 15 Jan 2008 04:10:35 +0100 Subject: add @version@ magic and prefer tarballs people hate autotools (well, i can understand them as i hate automake as well), so prefer the tarball method where you can avoid make prepare --- skype/Makefile | 1 + skype/README | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index 69f71624..af826985 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -48,6 +48,7 @@ doc: HEADER.html Changelog HEADER.html: README ln -s README HEADER.txt asciidoc -a toc -a numbered -a sectids HEADER.txt + sed -i 's|@VERSION@|$(VERSION)|g' HEADER.html rm HEADER.txt Changelog: .git/refs/heads/master diff --git a/skype/README b/skype/README index 72716812..c9c2a70a 100644 --- a/skype/README +++ b/skype/README @@ -74,15 +74,16 @@ $ make - Get the plugin code: ---- -$ git clone git://vmiklos.hu/bitlbee-skype +$ wget http://vmiklos.hu/project/bitlbee-skype/bitlbee-skype-@VERSION@.tar.gz +$ tar xf bitlbee-skype-@VERSION@.tar.gz +$ cd bitlbee-skype-@VERSION@ ---- -(Or you can use the tarballs below, see the Changelog about what -features/bugfixes will you miss in this case). +NOTE: Alternatively, if you want to test the latest code, you can use `git +clone git://vmiklos.hu/bitlbee-skype` to get the code directly from git. -NOTE: It doesn't matter where do you get it, it'll install the plugin to -`/usr/local` by default (that's the location where BitlBee searches for plugins -by default). +It doesn't matter where do you get it, it'll install the plugin to `/usr/local` +by default (that's the location where BitlBee searches for plugins by default). - Compile and install it: -- cgit v1.2.3 From 15282dc421038974b28259f884e7cdb9f99bbea6 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 15 Jan 2008 04:14:26 +0100 Subject: move the git stuff to HACKING --- skype/HACKING | 10 ++++++++++ skype/README | 5 ----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/skype/HACKING b/skype/HACKING index dbaa74cc..b4442182 100644 --- a/skype/HACKING +++ b/skype/HACKING @@ -1,3 +1,5 @@ +== Tabs + I use the following tabs during the development: 1) bitlbee-skype: @@ -16,3 +18,11 @@ python skyped.py -n -d -c ./skyped.conf 4) skype 5) irssi + +== Get the code from git + +To get the code directly from git, you need: + +git clone git://vmiklos.hu/bitlbee-skype +cd bitlbee-skype +make prepare diff --git a/skype/README b/skype/README index c9c2a70a..035f7ca4 100644 --- a/skype/README +++ b/skype/README @@ -79,17 +79,12 @@ $ tar xf bitlbee-skype-@VERSION@.tar.gz $ cd bitlbee-skype-@VERSION@ ---- -NOTE: Alternatively, if you want to test the latest code, you can use `git -clone git://vmiklos.hu/bitlbee-skype` to get the code directly from git. - It doesn't matter where do you get it, it'll install the plugin to `/usr/local` by default (that's the location where BitlBee searches for plugins by default). - Compile and install it: ---- -$ cd bitlbee-skype -$ make prepare $ ./configure $ make # make install -- cgit v1.2.3 From e72d869f00b464a96718931c37ab0d1d49ce0d37 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 15 Jan 2008 04:17:26 +0100 Subject: link HACKING --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 035f7ca4..bf583ce0 100644 --- a/skype/README +++ b/skype/README @@ -258,7 +258,7 @@ your VNC server regularly. (How ugly.) == I would like to have support for ... If something does not work and it's not in the TODO section, then please -contact me! Please also try the git version before reporting a bug, your +contact me! Please also try the link:HACKING[git version] before reporting a bug, your problem may be already fixed there. In fact, of course, I wrote this documentation after figured out how to do this -- cgit v1.2.3 From 68796a1298da7402560377a5f9cab35d2d4d44e8 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 15 Jan 2008 04:19:43 +0100 Subject: git-archive -> git archive --- skype/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index af826985..587c9832 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -30,7 +30,7 @@ distclean: clean rm -f configure install-sh aclocal.m4 dist: - git-archive --format=tar --prefix=bitlbee-skype-$(VERSION)/ HEAD | tar xf - + git archive --format=tar --prefix=bitlbee-skype-$(VERSION)/ HEAD | tar xf - mkdir -p bitlbee-skype-$(VERSION) git log --no-merges |git name-rev --tags --stdin > bitlbee-skype-$(VERSION)/Changelog make -C bitlbee-skype-$(VERSION) prepare -- cgit v1.2.3 From fcef6e693ab4f8ad4329e1398310b9cd4591d0ba Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 21 Jan 2008 03:21:43 +0100 Subject: skype_set_display_name(): set FULLNAME, not MOOD_TEXT --- skype/skype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 7f5be9e7..3c2ffd22 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -884,7 +884,7 @@ static char *skype_set_display_name( set_t *set, char *value ) //struct skype_data *sd = ic->proto_data; char *buf; - buf = g_strdup_printf("SET PROFILE MOOD_TEXT %s", value); + buf = g_strdup_printf("SET PROFILE FULLNAME %s", value); skype_write( ic, buf, strlen( buf ) ); g_free(buf); return(value); -- cgit v1.2.3 From 3511d80b1706b433aeb61f85e1eb6524162bc406 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 21 Jan 2008 14:49:17 +0100 Subject: update todo --- skype/README | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index bf583ce0..ef618559 100644 --- a/skype/README +++ b/skype/README @@ -244,7 +244,11 @@ your VNC server regularly. (How ugly.) == What needs to be done (aka. TODO) -- Add a question callback for calls. +- Fix `set skype/display_name foo`. It seem to be an upstream issue. (`nick + skype foo` works fine.) + +- Add support for accepting/rejecting and starting calls via settings. (Depends + on the previous fix.) - Notice if foo invites bar. Currently you can see only that bar joined. @@ -252,8 +256,9 @@ your VNC server regularly. (How ugly.) forum thread], it is still unclear how could it be done for you to be able to `/join` to a public chat.. -- Split skyped from the plugin, so that one could install just the relevant - code if they are not running on the same machine. +- Add `--disable-skyped` and `--disable-plugin` switches in case one wants to + build `bitlbee-skype` only for a public server or only for use with a public + server. == I would like to have support for ... -- cgit v1.2.3 From ed88e8e51a4461e1632dbfd7599806ebb63719ac Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 21 Jan 2008 14:52:51 +0100 Subject: updates for 0.3.1 --- skype/Makefile | 2 +- skype/NEWS | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 587c9832..b8ab83e4 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.3.0 +VERSION = 0.3.1 skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) diff --git a/skype/NEWS b/skype/NEWS index 29025d1e..e73855b9 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,10 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.3.1 - beautify output when skyped is interrupted using ^C + - 'nick skype foo' now really sets display name, not the mood + text + - documentation fixups + - this version should be again as stable as 0.2.6 was 0.3.0 - authentication support in skyped via ssl - ~200 lines of new code, so be careful :) - upgraders: please read the documentation about how to set up -- cgit v1.2.3 From ff990901904d48678150c80b965fd964ded5badd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 21 Jan 2008 15:03:50 +0100 Subject: header.html depends on makefile --- skype/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index b8ab83e4..82472047 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -45,7 +45,7 @@ release: doc: HEADER.html Changelog -HEADER.html: README +HEADER.html: README Makefile ln -s README HEADER.txt asciidoc -a toc -a numbered -a sectids HEADER.txt sed -i 's|@VERSION@|$(VERSION)|g' HEADER.html -- cgit v1.2.3 From 6b266f603ae99e0f85e72bfcb75d2ea864067762 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 21 Jan 2008 15:05:20 +0100 Subject: README: typo --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index ef618559..a90fa3d5 100644 --- a/skype/README +++ b/skype/README @@ -237,7 +237,7 @@ your VNC server regularly. (How ugly.) - Handling skype actions (when the `CHATMESSAGE` has `EMOTED` type) -- Setting your mood text using the `nick` command. +- Setting your display name using the `nick` command. - Running Skype on a machine different to BitlBee is possible, the communication is encrypted. -- cgit v1.2.3 From 3fd8b71c09e8100374358dddf2f051d7b1a58093 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 29 Jan 2008 00:29:00 +0100 Subject: it seems some distro does not have an automake symlink in /usr/share --- skype/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 82472047..192e3d5b 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -2,6 +2,8 @@ VERSION = 0.3.1 +AMVERSION = $(shell automake --version|sed 's/.*) //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') + skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) @@ -18,7 +20,7 @@ install: skype.so skyped.py client: client.c prepare: configure.ac - cp /usr/share/automake/install-sh ./ + cp /usr/share/automake-$(AMVERSION)/install-sh ./ cp /usr/share/aclocal/pkg.m4 aclocal.m4 autoconf -- cgit v1.2.3 From 6f01885d51ad19296e0ac78b7560d3a4b5789590 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 17 Feb 2008 19:47:24 +0100 Subject: update gitweb url --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index a90fa3d5..c986185d 100644 --- a/skype/README +++ b/skype/README @@ -281,7 +281,7 @@ You can reach some screenshots link:shot[here]. == Additional resources You can reach the Changelog link:Changelog[here], and a gitweb interface -http://repo.or.cz/w/bitlbee-skype.git[here]. +http://vmiklos.hu/gitweb/?p=bitlbee-skype.git[here]. The Skype API documentation is https://developer.skype.com/Docs/ApiDoc[here] if you're interested. -- cgit v1.2.3 From 1b97fc0982b1e72adb1b224606c0c14781109995 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 19 Feb 2008 14:13:24 +0100 Subject: remove unnecessary import of threading from skyped --- skype/skyped.py | 1 - 1 file changed, 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index 15c67dce..9b54abf5 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -33,7 +33,6 @@ import gobject import socket import getopt import Skype4Py -import threading import sha from ConfigParser import ConfigParser from OpenSSL import SSL -- cgit v1.2.3 From 5e21e0619c0cac4d0634b3831f8e4054c551061d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 19 Feb 2008 15:40:35 +0100 Subject: typo fix in automake version detection thanks Sebastian (schwarz.s at gmx.de) for pointing this out --- skype/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 192e3d5b..d71fbe2a 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -2,7 +2,7 @@ VERSION = 0.3.1 -AMVERSION = $(shell automake --version|sed 's/.*) //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') +AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') skype.so: skype.c config.mak $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) -- cgit v1.2.3 From 6af541d6a5bf951b7f0ee874391f1b4948497d77 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 23 Feb 2008 03:13:59 +0100 Subject: skyped: automatically start skype if necessary --- skype/skyped.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 9b54abf5..af9310fb 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -66,7 +66,8 @@ def input_handler(fd, io_condition): def idle_handler(skype): try: - skype.skype.SendCommand(skype.skype.Command(-1, "PING")) + c = skype.skype.Command("PING", Block=True) + skype.skype.SendCommand(c) except Skype4Py.SkypeAPIError, s: dprint("Warning, pinging Skype failed (%s)." % (s)) time.sleep(2) @@ -114,7 +115,7 @@ class SkypeApi(): def __init__(self): self.skype = Skype4Py.Skype() self.skype.OnNotify = self.recv - self.skype.Attach() + self.skype.Client.Start() def recv(self, msg_text): global options -- cgit v1.2.3 From 833eaeee91bddd0cf21255a4016b1db2c780acf7 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 23 Feb 2008 03:17:06 +0100 Subject: doc update: manual start of skype no longer necessary --- skype/README | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/skype/README b/skype/README index c986185d..4321dbff 100644 --- a/skype/README +++ b/skype/README @@ -45,9 +45,8 @@ Skype servers (the company's ones). It needs a running Skype client to do so. In fact BitlBee will connect to `skyped` (a tcp server, provided in this package) and `skyped` will connect to to your Skype client. -NOTE: The order is important. First you have to start Skype. Then `skyped` can -connect to it, finally BitlBee can connect to `skyped`. (In fact `skyped` -automatically reconnect if you restart Skype.) +NOTE: The order is important. First `skyped` starts Skype. Then `skyped` can +connect to Skype, finally BitlBee can connect to `skyped`. - If you happen to be a happy Frugalware user, you can install the `bitlbee` and `bitlbee-skype` packages from @@ -119,16 +118,12 @@ if you used the `--sysconfdir` switch when running bitlbee-skype's `configure`. NOTE: Maybe you want to adjust the permissions in the `/usr/local/etc/skyped` dir. For example make it readable by just your user. -- Start Skype and `skyped` (the tcp server): +- Start `skyped` (the tcp server): ---- -$ skype $ skyped ---- -NOTE: You should run `skyped` on the same `X11` display, otherwise it won't be -able to connect to Skype! - - Start your `IRC` client, connect to BitlBee and add your account: ---- @@ -159,8 +154,6 @@ Now create `~/.vnc/xstartup` with the following contents: #!/bin/sh sleep 1 -skype & -sleep 5 skyped ---- -- cgit v1.2.3 From e79a94f6d4818767a16c5db50d1b6639accb40ed Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 23 Feb 2008 03:17:51 +0100 Subject: small cleanup --- skype/skyped.py | 1 - 1 file changed, 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index af9310fb..6cc5f4c6 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -37,7 +37,6 @@ import sha from ConfigParser import ConfigParser from OpenSSL import SSL from traceback import print_exception -#from exceptions import KeyboardInterrupt __version__ = "0.1.1" -- cgit v1.2.3 From 3a2a0b247bf3adc77ab5067dd261c24583c97e3f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 23 Feb 2008 03:24:14 +0100 Subject: kill skype on shutdown --- skype/skyped.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 6cc5f4c6..163e9e78 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -44,10 +44,11 @@ SKYPE_SERVICE = 'com.Skype.API' CLIENT_NAME = 'SkypeApiPythonShell' def eh(type, value, tb): - if type == KeyboardInterrupt: - sys.exit("Exiting.") - print_exception(type, value, tb) - sys.exit(1) + if type != KeyboardInterrupt: + print_exception(type, value, tb) + gobject.MainLoop().quit() + skype.skype.Client.Shutdown() + sys.exit("Exiting.") sys.excepthook = eh -- cgit v1.2.3 From 1fb0a30dd661c7e4b1472ad8e5628f28f6174585 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 23 Feb 2008 03:26:04 +0100 Subject: skyped: remove comment, we use skype4py already --- skype/skyped.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 163e9e78..2b0a756f 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -4,10 +4,6 @@ # # Copyright (c) 2007, 2008 by Miklos Vajna # -# It uses several code from a very basic python CLI interface, available at: -# -# http://forum.skype.com/index.php?showtopic=42640 -# # 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 -- cgit v1.2.3 From 4bf5dfe49d470a95779dd4eac5ddc9f3d1441850 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 23 Feb 2008 03:44:23 +0100 Subject: tested with 2.0.0.43 --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 4321dbff..77e094dc 100644 --- a/skype/README +++ b/skype/README @@ -28,7 +28,7 @@ not..) == Requirements -* Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.27. +* Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.43. * bitlbee >= 1.1.1dev. (This is the latest version I've tested, probably newer versions will work, too.) * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. -- cgit v1.2.3 From c47e56652775af5a6b8d170ac472842f95d76ccd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 23 Feb 2008 03:44:56 +0100 Subject: updates for 0.3.2 --- skype/Makefile | 2 +- skype/NEWS | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index d71fbe2a..3e7a18cc 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.3.1 +VERSION = 0.3.2 AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') diff --git a/skype/NEWS b/skype/NEWS index e73855b9..12001068 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,9 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.3.2 - support for Skype 2.0.0.43 + - skyped now automatically starts/shuts down skype + - improved 'make prepare' to handle more automake versions + - documentation improvements 0.3.1 - beautify output when skyped is interrupted using ^C - 'nick skype foo' now really sets display name, not the mood text -- cgit v1.2.3 From e49da2555ce82b009f3e0e25db2acbbf9789a043 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 23 Feb 2008 04:02:35 +0100 Subject: small spelling fixes --- skype/README | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/skype/README b/skype/README index 77e094dc..425a4864 100644 --- a/skype/README +++ b/skype/README @@ -29,14 +29,15 @@ not..) == Requirements * Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.43. -* bitlbee >= 1.1.1dev. (This is the latest version I've tested, probably - newer versions will work, too.) +* BitlBee >= 1.1.1dev. This is the latest version I've tested, probably + newer versions will work, too. * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. * Python >= 2.5. Skype4Py does not work with 2.4. -* pygobject +* PyGObject >= 2.8.0. Older versions are part of PyGTK. (And you don't want to + install GTK for nothing, right?) -`bitlbee-skype` has been tested under Linux and Windows. Skype is available -under OSX, too, so it probably works, but this has not been tested. +`bitlbee-skype` has been tested under Linux and Windows. Skype and Skype4py is +available under OSX, too, so it probably works, but this has not been tested. == How to set it up @@ -283,7 +284,7 @@ https://developer.skype.com/Docs/ApiDoc[here] if you're interested. for the following people: -* Wilmer van der Gaast, for answering questions about the bitlbee plugin interface +* Wilmer van der Gaast, for answering questions about the BitlBee plugin interface * Arkadiusz Wahlig, author of skype4py, for making suggestions to skyped -- cgit v1.2.3 From ceee9c7593da8831d6c713265b1106ca56ae197e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 26 Feb 2008 01:10:52 +0100 Subject: add a new section to the readme ;) --- skype/README | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/skype/README b/skype/README index 425a4864..2f2755d6 100644 --- a/skype/README +++ b/skype/README @@ -280,6 +280,13 @@ http://vmiklos.hu/gitweb/?p=bitlbee-skype.git[here]. The Skype API documentation is https://developer.skype.com/Docs/ApiDoc[here] if you're interested. + +== Testimonials + +---- +00:56 < scathe> vmiklos: I like your skype plugin :) +---- + == Thanks for the following people: -- cgit v1.2.3 From 6774d836e8adf5078932da50f434d6fae1a48cef Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 26 Feb 2008 13:27:29 +0100 Subject: next testemonial --- skype/README | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/skype/README b/skype/README index 2f2755d6..3f3a3c87 100644 --- a/skype/README +++ b/skype/README @@ -287,6 +287,13 @@ https://developer.skype.com/Docs/ApiDoc[here] if you're interested. 00:56 < scathe> vmiklos: I like your skype plugin :) ---- +---- +It's really working great so far. + +Good Job and thank you! +Sebastian +---- + == Thanks for the following people: -- cgit v1.2.3 From 8a2df93eac9fa86d132b709731dc6a3f21af3257 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 00:18:45 +0100 Subject: remove skype from HACKING as skyped now automatically starts it --- skype/HACKING | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/skype/HACKING b/skype/HACKING index b4442182..a08926c4 100644 --- a/skype/HACKING +++ b/skype/HACKING @@ -15,9 +15,7 @@ run -v -n -D python skyped.py -n -d -c ./skyped.conf -4) skype - -5) irssi +4) irssi == Get the code from git -- cgit v1.2.3 From 789d05591e8497b877bf10551c775252c518d011 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 00:21:46 +0100 Subject: suggest account set, server in account add is old --- skype/README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 3f3a3c87..26ac825c 100644 --- a/skype/README +++ b/skype/README @@ -128,7 +128,8 @@ $ skyped - Start your `IRC` client, connect to BitlBee and add your account: ---- -account add skype localhost +account add skype +account set skype/server localhost ---- should be your Skype account name, should be the one you declared -- cgit v1.2.3 From 459160d31d82ae977216f341366aab527fd672d5 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 00:52:09 +0100 Subject: remove an unnecessary comment --- skype/skype.c | 1 - 1 file changed, 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 3c2ffd22..13eef2a7 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -881,7 +881,6 @@ static char *skype_set_display_name( set_t *set, char *value ) { account_t *acc = set->data; struct im_connection *ic = acc->ic; - //struct skype_data *sd = ic->proto_data; char *buf; buf = g_strdup_printf("SET PROFILE FULLNAME %s", value); -- cgit v1.2.3 From b68b0238a35c962d1669d3e0c3e61c9144cebad8 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 00:52:41 +0100 Subject: new account set skype/call nick command to start calls --- skype/skype.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index 13eef2a7..7e1ef142 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -889,6 +889,31 @@ static char *skype_set_display_name( set_t *set, char *value ) return(value); } +static char *skype_set_call( set_t *set, char *value ) +{ + account_t *acc = set->data; + struct im_connection *ic = acc->ic; + char *nick, *ptr, *buf; + user_t *u = user_find(acc->irc, value); + + if(!u) + { + imcb_error(ic, "%s - no such nick", value); + return(value); + } + nick = g_strdup(u->handle); + ptr = strchr(nick, '@'); + if(ptr) + *ptr = '\0'; + + buf = g_strdup_printf("CALL %s", nick); + skype_write( ic, buf, strlen( buf ) ); + g_free(buf); + g_free(nick); + imcb_log(ic, "Ringing the user %s.", value); + return(value); +} + static void skype_add_buddy( struct im_connection *ic, char *who, char *group ) { char *buf, *nick, *ptr; @@ -1048,6 +1073,9 @@ static void skype_init( account_t *acc ) s = set_add( &acc->set, "display_name", NULL, skype_set_display_name, acc ); s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; + + s = set_add( &acc->set, "call", NULL, skype_set_call, acc ); + s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; } void init_plugin(void) -- cgit v1.2.3 From 387884906887f72a3fce5ec8649da018d8339171 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 00:53:04 +0100 Subject: remove item from TODO, fixed upstream --- skype/README | 3 --- 1 file changed, 3 deletions(-) diff --git a/skype/README b/skype/README index 26ac825c..1c143eac 100644 --- a/skype/README +++ b/skype/README @@ -239,9 +239,6 @@ your VNC server regularly. (How ugly.) == What needs to be done (aka. TODO) -- Fix `set skype/display_name foo`. It seem to be an upstream issue. (`nick - skype foo` works fine.) - - Add support for accepting/rejecting and starting calls via settings. (Depends on the previous fix.) -- cgit v1.2.3 From 123e45a0a4dee7ad5b4c3ea0310397f570f2b357 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 00:54:28 +0100 Subject: document account set skype/call --- skype/README | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index 1c143eac..7ca2c5be 100644 --- a/skype/README +++ b/skype/README @@ -178,7 +178,7 @@ Please be aware about that Skype has serious memory leak issues. After running with for a few weeks it may eat >300 MB of memory. Just don't forget to restart your VNC server regularly. (How ugly.) -== What works +== Features - Download nicks and away statuses from Skype @@ -237,10 +237,11 @@ your VNC server regularly. (How ugly.) - Running Skype on a machine different to BitlBee is possible, the communication is encrypted. +- Starting calls: `account set skype/call nick` + == What needs to be done (aka. TODO) -- Add support for accepting/rejecting and starting calls via settings. (Depends - on the previous fix.) +- Add support for accepting/rejecting calls via settings. - Notice if foo invites bar. Currently you can see only that bar joined. -- cgit v1.2.3 From 9db023404848798a90183c8fc27f6ffe890cdb25 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 01:09:22 +0100 Subject: finetune ringing message old: the user foo is ringing you new: you are ringing the user foo or the user foo is ringing you --- skype/skype.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 7e1ef142..82ecc4de 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -40,7 +40,10 @@ typedef enum { SKYPE_CALL_RINGING = 1, - SKYPE_CALL_MISSED + SKYPE_CALL_MISSED, + SKYPE_CALL_UNPLACED, + /* This means we are ringing somebody, not somebody rings us. */ + SKYPE_CALL_RINGING_OUT } skype_call_status; typedef enum @@ -561,7 +564,10 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); skype_write( ic, buf, strlen( buf ) ); - sd->call_status = SKYPE_CALL_RINGING; + if(sd->call_status != SKYPE_CALL_UNPLACED) + sd->call_status = SKYPE_CALL_RINGING; + else + sd->call_status = SKYPE_CALL_RINGING_OUT; } else if(!strcmp(info, "STATUS MISSED")) { @@ -569,6 +575,8 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c skype_write( ic, buf, strlen( buf ) ); sd->call_status = SKYPE_CALL_MISSED; } + else if(!strcmp(info, "STATUS UNPLACED")) + sd->call_status = SKYPE_CALL_UNPLACED; else if(!strncmp(info, "PARTNER_HANDLE ", 15)) { info += 15; @@ -581,6 +589,12 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c case SKYPE_CALL_MISSED: imcb_log(ic, "You have missed a call from user %s.", info); break; + case SKYPE_CALL_RINGING_OUT: + imcb_log(ic, "You are currently ringing the user %s.", info); + break; + default: + /* Don't be noisy, ignore other statuses for now. */ + break; } sd->call_status = 0; } @@ -910,7 +924,6 @@ static char *skype_set_call( set_t *set, char *value ) skype_write( ic, buf, strlen( buf ) ); g_free(buf); g_free(nick); - imcb_log(ic, "Ringing the user %s.", value); return(value); } -- cgit v1.2.3 From 2eb4b1ffbb2e8f78913e81fd0e0090eaa161fcc9 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 01:34:31 +0100 Subject: add support for account set -del skype/call to finish an outgoing call --- skype/README | 5 ++++- skype/skype.c | 62 +++++++++++++++++++++++++++++++++++++++++++++------------ skype/skyped.py | 5 ++++- 3 files changed, 57 insertions(+), 15 deletions(-) diff --git a/skype/README b/skype/README index 7ca2c5be..61334d85 100644 --- a/skype/README +++ b/skype/README @@ -237,7 +237,10 @@ your VNC server regularly. (How ugly.) - Running Skype on a machine different to BitlBee is possible, the communication is encrypted. -- Starting calls: `account set skype/call nick` +- Managing outgoing calls: + + * `account set skype/call nick` + * `account set -del skype/call` == What needs to be done (aka. TODO) diff --git a/skype/skype.c b/skype/skype.c index 82ecc4de..40b43a02 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -42,6 +42,7 @@ typedef enum SKYPE_CALL_RINGING = 1, SKYPE_CALL_MISSED, SKYPE_CALL_UNPLACED, + SKYPE_CALL_CANCELLED, /* This means we are ringing somebody, not somebody rings us. */ SKYPE_CALL_RINGING_OUT } skype_call_status; @@ -79,6 +80,7 @@ struct skype_data * handle. So we store the state here and then we can send a * notification about the handle is in a given status. */ skype_call_status call_status; + char *call_id; /* Same for file transfers. */ skype_filetransfer_status filetransfer_status; /* Using /j #nick we want to have a groupchat with two people. Usually @@ -575,8 +577,20 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c skype_write( ic, buf, strlen( buf ) ); sd->call_status = SKYPE_CALL_MISSED; } + else if(!strcmp(info, "STATUS CANCELLED")) + { + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write( ic, buf, strlen( buf ) ); + sd->call_status = SKYPE_CALL_CANCELLED; + } else if(!strcmp(info, "STATUS UNPLACED")) + { + if(sd->call_id) + g_free(sd->call_id); + /* Save the ID for later usage (Cancel/Finish). */ + sd->call_id = g_strdup(id); sd->call_status = SKYPE_CALL_UNPLACED; + } else if(!strncmp(info, "PARTNER_HANDLE ", 15)) { info += 15; @@ -592,6 +606,9 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c case SKYPE_CALL_RINGING_OUT: imcb_log(ic, "You are currently ringing the user %s.", info); break; + case SKYPE_CALL_CANCELLED: + imcb_log(ic, "You cancelled the call to the user %s.", info); + break; default: /* Don't be noisy, ignore other statuses for now. */ break; @@ -907,23 +924,42 @@ static char *skype_set_call( set_t *set, char *value ) { account_t *acc = set->data; struct im_connection *ic = acc->ic; + struct skype_data *sd = ic->proto_data; char *nick, *ptr, *buf; - user_t *u = user_find(acc->irc, value); - if(!u) + if(value) { - imcb_error(ic, "%s - no such nick", value); - return(value); + user_t *u = user_find(acc->irc, value); + /* We are starting a call */ + if(!u) + { + imcb_error(ic, "%s - no such nick", value); + return(value); + } + nick = g_strdup(u->handle); + ptr = strchr(nick, '@'); + if(ptr) + *ptr = '\0'; + + buf = g_strdup_printf("CALL %s", nick); + skype_write( ic, buf, strlen( buf ) ); + g_free(buf); + g_free(nick); + } + else + { + /* We are ending a call */ + if(sd->call_id) + { + buf = g_strdup_printf("SET CALL %s STATUS FINISHED", sd->call_id); + skype_write( ic, buf, strlen( buf ) ); + g_free(buf); + } + else + { + imcb_error(ic, "There are no active calls currently."); + } } - nick = g_strdup(u->handle); - ptr = strchr(nick, '@'); - if(ptr) - *ptr = '\0'; - - buf = g_strdup_printf("CALL %s", nick); - skype_write( ic, buf, strlen( buf ) ); - g_free(buf); - g_free(nick); return(value); } diff --git a/skype/skyped.py b/skype/skyped.py index 2b0a756f..e285642d 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -55,7 +55,10 @@ def input_handler(fd, io_condition): skype.send(i.strip()) options.buf = None else: - input = fd.recv(1024) + try: + input = fd.recv(1024) + except SysCallError: + return True for i in input.split("\n"): skype.send(i.strip()) return True -- cgit v1.2.3 From 239b036c7fc0eb9e9484e84caeb6e03594cc9eb6 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 01:42:46 +0100 Subject: skyped: don't exit when bitlbee disconnects --- skype/skyped.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index e285642d..271450b7 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -57,7 +57,7 @@ def input_handler(fd, io_condition): else: try: input = fd.recv(1024) - except SysCallError: + except SSL.SysCallError: return True for i in input.split("\n"): skype.send(i.strip()) -- cgit v1.2.3 From acd94789946b2bc83ab529485a3342255a2cdecf Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 01:43:02 +0100 Subject: report 'finished' when call finishes till now we reported only cancelled calls --- skype/skype.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index 40b43a02..299e0768 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -43,6 +43,7 @@ typedef enum SKYPE_CALL_MISSED, SKYPE_CALL_UNPLACED, SKYPE_CALL_CANCELLED, + SKYPE_CALL_FINISHED, /* This means we are ringing somebody, not somebody rings us. */ SKYPE_CALL_RINGING_OUT } skype_call_status; @@ -583,6 +584,12 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c skype_write( ic, buf, strlen( buf ) ); sd->call_status = SKYPE_CALL_CANCELLED; } + else if(!strcmp(info, "STATUS FINISHED")) + { + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write( ic, buf, strlen( buf ) ); + sd->call_status = SKYPE_CALL_FINISHED; + } else if(!strcmp(info, "STATUS UNPLACED")) { if(sd->call_id) @@ -609,6 +616,9 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c case SKYPE_CALL_CANCELLED: imcb_log(ic, "You cancelled the call to the user %s.", info); break; + case SKYPE_CALL_FINISHED: + imcb_log(ic, "You finished the call to the user %s.", info); + break; default: /* Don't be noisy, ignore other statuses for now. */ break; -- cgit v1.2.3 From 48181f05fef4c5c6624a06bcf5ce3648f63576dd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 01:49:43 +0100 Subject: report call duration at the end --- skype/README | 2 +- skype/skype.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index 61334d85..5515ccc7 100644 --- a/skype/README +++ b/skype/README @@ -237,7 +237,7 @@ your VNC server regularly. (How ugly.) - Running Skype on a machine different to BitlBee is possible, the communication is encrypted. -- Managing outgoing calls: +- Managing outgoing calls (with call duration at the end): * `account set skype/call nick` * `account set -del skype/call` diff --git a/skype/skype.c b/skype/skype.c index 299e0768..291233e7 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -82,6 +82,7 @@ struct skype_data * notification about the handle is in a given status. */ skype_call_status call_status; char *call_id; + char *call_duration; /* Same for file transfers. */ skype_filetransfer_status filetransfer_status; /* Using /j #nick we want to have a groupchat with two people. Usually @@ -598,6 +599,12 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c sd->call_id = g_strdup(id); sd->call_status = SKYPE_CALL_UNPLACED; } + else if(!strncmp(info, "DURATION ", 9)) + { + if(sd->call_duration) + g_free(sd->call_duration); + sd->call_duration = g_strdup(info+9); + } else if(!strncmp(info, "PARTNER_HANDLE ", 15)) { info += 15; @@ -617,7 +624,14 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c imcb_log(ic, "You cancelled the call to the user %s.", info); break; case SKYPE_CALL_FINISHED: - imcb_log(ic, "You finished the call to the user %s.", info); + if(sd->call_duration) + { + imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); + } + else + { + imcb_log(ic, "You finished the call to the user %s.", info); + } break; default: /* Don't be noisy, ignore other statuses for now. */ -- cgit v1.2.3 From 9fd72022b3410118c7ee484016f6321c36268ea8 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 01:59:51 +0100 Subject: error out on cancelling a non-existing call --- skype/skype.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index 291233e7..910e8ae6 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -978,6 +978,8 @@ static char *skype_set_call( set_t *set, char *value ) buf = g_strdup_printf("SET CALL %s STATUS FINISHED", sd->call_id); skype_write( ic, buf, strlen( buf ) ); g_free(buf); + g_free(sd->call_id); + sd->call_id = NULL; } else { -- cgit v1.2.3 From a92fb0722c70432fe3176f398556df64cdae98ca Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 02:10:01 +0100 Subject: detect when the call is refused --- skype/skype.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index 910e8ae6..abb92efc 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -44,6 +44,7 @@ typedef enum SKYPE_CALL_UNPLACED, SKYPE_CALL_CANCELLED, SKYPE_CALL_FINISHED, + SKYPE_CALL_REFUSED, /* This means we are ringing somebody, not somebody rings us. */ SKYPE_CALL_RINGING_OUT } skype_call_status; @@ -591,6 +592,12 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c skype_write( ic, buf, strlen( buf ) ); sd->call_status = SKYPE_CALL_FINISHED; } + else if(!strcmp(info, "STATUS REFUSED")) + { + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write( ic, buf, strlen( buf ) ); + sd->call_status = SKYPE_CALL_REFUSED; + } else if(!strcmp(info, "STATUS UNPLACED")) { if(sd->call_id) @@ -623,6 +630,9 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c case SKYPE_CALL_CANCELLED: imcb_log(ic, "You cancelled the call to the user %s.", info); break; + case SKYPE_CALL_REFUSED: + imcb_log(ic, "The user %s refused the call.", info); + break; case SKYPE_CALL_FINISHED: if(sd->call_duration) { -- cgit v1.2.3 From d87daf3e4e73dfbfbb1d669cb990a6325c2fa9d8 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 02:40:12 +0100 Subject: replace the fake SKYPE_CALL_RINGING_OUT with a proper call_out variable --- skype/skype.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index abb92efc..4a808fc1 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -41,12 +41,9 @@ typedef enum { SKYPE_CALL_RINGING = 1, SKYPE_CALL_MISSED, - SKYPE_CALL_UNPLACED, SKYPE_CALL_CANCELLED, SKYPE_CALL_FINISHED, - SKYPE_CALL_REFUSED, - /* This means we are ringing somebody, not somebody rings us. */ - SKYPE_CALL_RINGING_OUT + SKYPE_CALL_REFUSED } skype_call_status; typedef enum @@ -84,6 +81,8 @@ struct skype_data skype_call_status call_status; char *call_id; char *call_duration; + /* If the call is outgoing or not */ + int call_out; /* Same for file transfers. */ skype_filetransfer_status filetransfer_status; /* Using /j #nick we want to have a groupchat with two people. Usually @@ -569,10 +568,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); skype_write( ic, buf, strlen( buf ) ); - if(sd->call_status != SKYPE_CALL_UNPLACED) - sd->call_status = SKYPE_CALL_RINGING; - else - sd->call_status = SKYPE_CALL_RINGING_OUT; + sd->call_status = SKYPE_CALL_RINGING; } else if(!strcmp(info, "STATUS MISSED")) { @@ -582,9 +578,9 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } else if(!strcmp(info, "STATUS CANCELLED")) { - g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write( ic, buf, strlen( buf ) ); - sd->call_status = SKYPE_CALL_CANCELLED; + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write( ic, buf, strlen( buf ) ); + sd->call_status = SKYPE_CALL_CANCELLED; } else if(!strcmp(info, "STATUS FINISHED")) { @@ -604,7 +600,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c g_free(sd->call_id); /* Save the ID for later usage (Cancel/Finish). */ sd->call_id = g_strdup(id); - sd->call_status = SKYPE_CALL_UNPLACED; + sd->call_out = TRUE; } else if(!strncmp(info, "DURATION ", 9)) { @@ -619,29 +615,32 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c switch(sd->call_status) { case SKYPE_CALL_RINGING: - imcb_log(ic, "The user %s is currently ringing you.", info); + if(sd->call_out) + imcb_log(ic, "You are currently ringing the user %s.", info); + else + imcb_log(ic, "The user %s is currently ringing you.", info); break; case SKYPE_CALL_MISSED: imcb_log(ic, "You have missed a call from user %s.", info); break; - case SKYPE_CALL_RINGING_OUT: - imcb_log(ic, "You are currently ringing the user %s.", info); - break; case SKYPE_CALL_CANCELLED: imcb_log(ic, "You cancelled the call to the user %s.", info); + sd->call_status = 0; + sd->call_out = FALSE; break; case SKYPE_CALL_REFUSED: - imcb_log(ic, "The user %s refused the call.", info); + if(sd->call_out) + imcb_log(ic, "The user %s refused the call.", info); + else + imcb_log(ic, "You refused the call from user %s.", info); + sd->call_out = FALSE; break; case SKYPE_CALL_FINISHED: if(sd->call_duration) - { imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); - } else - { imcb_log(ic, "You finished the call to the user %s.", info); - } + sd->call_out = FALSE; break; default: /* Don't be noisy, ignore other statuses for now. */ -- cgit v1.2.3 From e0074cbd96725759cafd3c103213220c65195d8d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 03:08:14 +0100 Subject: manage incoming calls via questions --- skype/README | 5 +++-- skype/skype.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index 5515ccc7..00346539 100644 --- a/skype/README +++ b/skype/README @@ -242,9 +242,10 @@ your VNC server regularly. (How ugly.) * `account set skype/call nick` * `account set -del skype/call` -== What needs to be done (aka. TODO) +- Managing incoming calls via questions, just like when you add / remove + contacts. -- Add support for accepting/rejecting calls via settings. +== What needs to be done (aka. TODO) - Notice if foo invites bar. Currently you can see only that bar joined. diff --git a/skype/skype.c b/skype/skype.c index 4a808fc1..9134fbb0 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -119,6 +119,7 @@ struct skype_away_state struct skype_buddy_ask_data { struct im_connection *ic; + /* This is also used for call IDs for simplicity */ char *handle; }; @@ -194,6 +195,33 @@ void skype_buddy_ask( struct im_connection *ic, char *handle, char *message) g_free( buf ); } +static void skype_call_ask_yes( gpointer w, struct skype_buddy_ask_data *bla ) +{ + char *buf = g_strdup_printf("SET CALL %s STATUS INPROGRESS", bla->handle); + skype_write( bla->ic, buf, strlen( buf ) ); + g_free(buf); + g_free(bla->handle); + g_free(bla); +} + +static void skype_call_ask_no( gpointer w, struct skype_buddy_ask_data *bla ) +{ + char *buf = g_strdup_printf("SET CALL %s STATUS FINISHED", bla->handle); + skype_write( bla->ic, buf, strlen( buf ) ); + g_free(buf); + g_free(bla->handle); + g_free(bla); +} + +void skype_call_ask( struct im_connection *ic, char *call_id, char *message) +{ + struct skype_buddy_ask_data *bla = g_new0( struct skype_buddy_ask_data, 1 ); + + bla->ic = ic; + bla->handle = g_strdup(call_id); + + imcb_ask( ic, message, bla, skype_call_ask_yes, skype_call_ask_no ); +} struct groupchat *skype_chat_by_name( struct im_connection *ic, char *name ) { struct groupchat *ret; @@ -566,6 +594,9 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c info++; if(!strcmp(info, "STATUS RINGING")) { + if(sd->call_id) + g_free(sd->call_id); + sd->call_id = g_strdup(id); g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); skype_write( ic, buf, strlen( buf ) ); sd->call_status = SKYPE_CALL_RINGING; @@ -618,7 +649,10 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if(sd->call_out) imcb_log(ic, "You are currently ringing the user %s.", info); else - imcb_log(ic, "The user %s is currently ringing you.", info); + { + g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); + skype_call_ask(ic, sd->call_id, buf); + } break; case SKYPE_CALL_MISSED: imcb_log(ic, "You have missed a call from user %s.", info); -- cgit v1.2.3 From f5782755d6a73bc1b7524aeed06e54e09feee553 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Feb 2008 03:12:07 +0100 Subject: updates for 0.4.0 --- skype/Makefile | 2 +- skype/NEWS | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 3e7a18cc..f1c0f45f 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.3.2 +VERSION = 0.4.0 AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') diff --git a/skype/NEWS b/skype/NEWS index 12001068..77b4c05d 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,10 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.4.0 - support for starting, accepting and rejecting calls + - also updated documentation (the key is the account set + skype/call command) + - as usual with the .0 releases, be careful, ~200 lines of + new code 0.3.2 - support for Skype 2.0.0.43 - skyped now automatically starts/shuts down skype - improved 'make prepare' to handle more automake versions -- cgit v1.2.3 From df1a59d4562af4806da5463b788310cd35b84058 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 7 Mar 2008 13:38:58 +0100 Subject: add support for osx --- skype/Makefile | 10 +++++----- skype/README | 4 ++-- skype/config.mak.in | 2 ++ skype/configure.ac | 16 ++++++++++++++++ 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index f1c0f45f..0f3c3f9b 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -4,14 +4,14 @@ VERSION = 0.4.0 AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') -skype.so: skype.c config.mak - $(CC) $(CFLAGS) -shared -o skype.so skype.c $(LDFLAGS) +skype.$(SHARED_EXT): skype.c config.mak + $(CC) $(CFLAGS) $(SHARED_FLAGS) -o skype.$(SHARED_EXT) skype.c $(LDFLAGS) -install: skype.so skyped.py +install: skype.$(SHARED_EXT) skyped.py $(INSTALL) -d $(DESTDIR)$(plugindir) $(INSTALL) -d $(DESTDIR)$(bindir) $(INSTALL) -d $(DESTDIR)$(sysconfdir) - $(INSTALL) skype.so $(DESTDIR)$(plugindir) + $(INSTALL) skype.$(SHARED_EXT) $(DESTDIR)$(plugindir) $(INSTALL) skyped.py $(DESTDIR)$(bindir)/skyped sed -i 's|/usr/local/etc/skyped|$(sysconfdir)|' $(DESTDIR)$(bindir)/skyped $(INSTALL) -m644 skyped.conf.dist $(DESTDIR)$(sysconfdir)/skyped.conf @@ -25,7 +25,7 @@ prepare: configure.ac autoconf clean: - rm -f skype.so + rm -f skype.$(SHARED_EXT) distclean: clean rm -rf autom4te.cache config.log config.mak config.status diff --git a/skype/README b/skype/README index 00346539..b05e4eb5 100644 --- a/skype/README +++ b/skype/README @@ -36,8 +36,8 @@ not..) * PyGObject >= 2.8.0. Older versions are part of PyGTK. (And you don't want to install GTK for nothing, right?) -`bitlbee-skype` has been tested under Linux and Windows. Skype and Skype4py is -available under OSX, too, so it probably works, but this has not been tested. +`bitlbee-skype` has been tested under Linux and Mac OS X. Skype and Skype4py is +available under Windows, too, so it probably works, but this has not been tested. == How to set it up diff --git a/skype/config.mak.in b/skype/config.mak.in index 7a63bf35..5f06a5b9 100644 --- a/skype/config.mak.in +++ b/skype/config.mak.in @@ -1,5 +1,7 @@ CFLAGS = @CFLAGS@ LDFLAGS = @LDFLAGS@ +SHARED_FLAGS = @SHARED_FLAGS@ +SHARED_EXT = @SHARED_EXT@ INSTALL = @INSTALL@ prefix = @prefix@ sysconfdir = @sysconfdir@/skyped diff --git a/skype/configure.ac b/skype/configure.ac index 08ba6f91..e169ad69 100644 --- a/skype/configure.ac +++ b/skype/configure.ac @@ -11,6 +11,22 @@ else AC_MSG_RESULT(no) fi +case "`$CC -dumpmachine`" in + *linux*) + SHARED_FLAGS="-shared" + SHARED_EXT="so" + ;; + *apple-darwin*) + SHARED_FLAGS="-dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup" + SHARED_EXT="dynlib" + ;; + *) + AC_MSG_ERROR([Your machine is not yet supported]) + ;; +esac +AC_SUBST(SHARED_FLAGS) +AC_SUBST(SHARED_EXT) + dnl Check for bitlbee PKG_CHECK_MODULES(BITLBEE, bitlbee) CFLAGS="$CFLAGS $BITLBEE_CFLAGS" -- cgit v1.2.3 From 2dbb76888d137405ddeb268a3ca6fe47a45922e0 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 12 Mar 2008 17:21:54 +0100 Subject: update vnc doc --- skype/README | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/skype/README b/skype/README index b05e4eb5..0be9e7f6 100644 --- a/skype/README +++ b/skype/README @@ -155,8 +155,7 @@ Now create `~/.vnc/xstartup` with the following contents: ---- #!/bin/sh -sleep 1 -skyped +twm ---- Adjust the permissions: @@ -171,8 +170,9 @@ Then start the server: $ vncserver ---- -Then connect to it, and set up Skype (username, password, enable auto-login, and -allow the `SkypeApiPythonShell` client when Skype asks about it). +Then connect to it, and set up Skype (username, password, enable +auto-login, start skyped and allow the `SkypeApiPythonShell` client when +Skype asks about it). Please be aware about that Skype has serious memory leak issues. After running with for a few weeks it may eat >300 MB of memory. Just don't forget to restart -- cgit v1.2.3 From 31fe3229c67499e154e14e6ec6307ac525340e44 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 14 Mar 2008 22:41:48 +0100 Subject: tested 2.0.0.63 --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 0be9e7f6..4bb24b98 100644 --- a/skype/README +++ b/skype/README @@ -28,7 +28,7 @@ not..) == Requirements -* Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.43. +* Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.63. * BitlBee >= 1.1.1dev. This is the latest version I've tested, probably newer versions will work, too. * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. -- cgit v1.2.3 From df13c255db8bb08fe1d485fb18353fa6b8d6c21c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 14 Mar 2008 22:44:02 +0100 Subject: avoid ${prefix} in skyped.conf --- skype/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/skype/Makefile b/skype/Makefile index 0f3c3f9b..808d8cab 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -15,6 +15,7 @@ install: skype.$(SHARED_EXT) skyped.py $(INSTALL) skyped.py $(DESTDIR)$(bindir)/skyped sed -i 's|/usr/local/etc/skyped|$(sysconfdir)|' $(DESTDIR)$(bindir)/skyped $(INSTALL) -m644 skyped.conf.dist $(DESTDIR)$(sysconfdir)/skyped.conf + sed -i 's|$${prefix}|$(prefix)|' $(DESTDIR)$(sysconfdir)/skyped.conf $(INSTALL) -m644 skyped.cnf $(DESTDIR)$(sysconfdir) client: client.c -- cgit v1.2.3 From 63405b47c483c2d5d50e09f308461c0df2b52cd0 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 15 Mar 2008 03:29:57 +0100 Subject: ignore more files --- skype/.gitignore | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/skype/.gitignore b/skype/.gitignore index 0211d468..0654b4e2 100644 --- a/skype/.gitignore +++ b/skype/.gitignore @@ -4,3 +4,15 @@ HEADER.html *.asc .htaccess shot +*.swp +aclocal.m4 +autom4te.cache +config.log +config.mak +config.status +configure +etc +install-sh +skype.so +skyped.conf +skyped.conf.dist -- cgit v1.2.3 From 36fbaa0f4110d32274b9b88a18f38a4f19350fc0 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 18 Mar 2008 02:39:46 +0100 Subject: bitlbee 1.2 --- skype/README | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/skype/README b/skype/README index 4bb24b98..f52f3354 100644 --- a/skype/README +++ b/skype/README @@ -29,8 +29,7 @@ not..) == Requirements * Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.63. -* BitlBee >= 1.1.1dev. This is the latest version I've tested, probably - newer versions will work, too. +* BitlBee >= 1.1.1dev. The latest version I've tested is 1.2. * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. * Python >= 2.5. Skype4Py does not work with 2.4. * PyGObject >= 2.8.0. Older versions are part of PyGTK. (And you don't want to @@ -49,16 +48,18 @@ package) and `skyped` will connect to to your Skype client. NOTE: The order is important. First `skyped` starts Skype. Then `skyped` can connect to Skype, finally BitlBee can connect to `skyped`. -- If you happen to be a happy Frugalware user, you can install the `bitlbee` - and `bitlbee-skype` packages from - http://ftp.frugalware.org/pub/other/people/vmiklos/bmf/[my repo]. +- If you happen to be a happy Frugalware user: -- You need the BitlBee testing/development version: +---- +# pacman-g2 -S bitlbee-skype +---- + +- You need the latest stable BitlBee release: ---- -$ wget http://get.bitlbee.org/src/bitlbee-1.1.1dev.tar.gz -$ tar xf bitlbee-1.1.1dev.tar.gz -$ cd bitlbee-1.1.1dev +$ wget http://get.bitlbee.org/src/bitlbee-1.2.tar.gz +$ tar xf bitlbee-1.2.tar.gz +$ cd bitlbee-1.2 ---- NOTE: You no longer need additional patches, as of version 1.1.1dev. -- cgit v1.2.3 From c78476ca65ec085db5bb58169322bd3a82eef7bf Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 18 Mar 2008 02:40:23 +0100 Subject: remove note about dbus-python, it's old --- skype/README | 8 -------- 1 file changed, 8 deletions(-) diff --git a/skype/README b/skype/README index f52f3354..dff100fb 100644 --- a/skype/README +++ b/skype/README @@ -93,14 +93,6 @@ $ make - Install http://skype4py.sourceforge.net/[Skype4Py]. -(You may remember that previous versions of `skyped` did not require this -package. This because it now uses the X11 interface of Skype (because the -previously used `DBus` interface had -http://forum.skype.com/index.php?s=&showtopic=94545&view=findpost&p=431710[known -problems]), but I wanted to prevent a large code duplication from that project. -In addition it then no longer requires the `dbus-python` package, just -`pygobject`.) - - Edit `/usr/local/etc/skyped/skyped.conf`: adjust `username` and `password`. The `username` should be your Skype login and the `password` can be whatever you want, but you will have to specify that one when adding the Skype account to -- cgit v1.2.3 From a317ba64b8fbf85707e7a4e1ecc6a420166b7c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risk=C3=B3=20Gergely?= Date: Mon, 31 Mar 2008 02:20:33 +0200 Subject: skype_set_call(): allow calling the test girl --- skype/skype.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 9134fbb0..1e436074 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -998,12 +998,15 @@ static char *skype_set_call( set_t *set, char *value ) { user_t *u = user_find(acc->irc, value); /* We are starting a call */ - if(!u) + if(!u && strcmp(value, "echo123")) { imcb_error(ic, "%s - no such nick", value); return(value); } - nick = g_strdup(u->handle); + if(!strcmp(value, "echo123")) + nick = g_strdup("echo123"); + else + nick = g_strdup(u->handle); ptr = strchr(nick, '@'); if(ptr) *ptr = '\0'; -- cgit v1.2.3 From e06f40890c40ed5798b88cd406c91870257b0bd0 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 31 Mar 2008 02:20:33 +0200 Subject: add new autoclean target - after clean, you don't have to re-run configure - after distclean, you should not have to re-run make prepare - as a result, only the new autoclean target will remove files created by make prepare --- skype/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index 808d8cab..3328b152 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -29,8 +29,10 @@ clean: rm -f skype.$(SHARED_EXT) distclean: clean - rm -rf autom4te.cache config.log config.mak config.status - rm -f configure install-sh aclocal.m4 + rm -f config.log config.mak config.status + +autoclean: distclean + rm -rf aclocal.m4 autom4te.cache configure install-sh dist: git archive --format=tar --prefix=bitlbee-skype-$(VERSION)/ HEAD | tar xf - -- cgit v1.2.3 From afeb51772c8e801b5ba5c1e3c698529ef6a254e5 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 31 Mar 2008 02:20:33 +0200 Subject: renamed make prepare to make autogen - since it does basically what autogen.sh is for automake-based projects --- skype/HACKING | 2 +- skype/Makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/skype/HACKING b/skype/HACKING index a08926c4..9230a7e8 100644 --- a/skype/HACKING +++ b/skype/HACKING @@ -23,4 +23,4 @@ To get the code directly from git, you need: git clone git://vmiklos.hu/bitlbee-skype cd bitlbee-skype -make prepare +make autogen diff --git a/skype/Makefile b/skype/Makefile index 3328b152..ff3b1bfe 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -20,7 +20,7 @@ install: skype.$(SHARED_EXT) skyped.py client: client.c -prepare: configure.ac +autogen: configure.ac cp /usr/share/automake-$(AMVERSION)/install-sh ./ cp /usr/share/aclocal/pkg.m4 aclocal.m4 autoconf @@ -38,7 +38,7 @@ dist: git archive --format=tar --prefix=bitlbee-skype-$(VERSION)/ HEAD | tar xf - mkdir -p bitlbee-skype-$(VERSION) git log --no-merges |git name-rev --tags --stdin > bitlbee-skype-$(VERSION)/Changelog - make -C bitlbee-skype-$(VERSION) prepare + make -C bitlbee-skype-$(VERSION) autogen tar czf bitlbee-skype-$(VERSION).tar.gz bitlbee-skype-$(VERSION) rm -rf bitlbee-skype-$(VERSION) -- cgit v1.2.3 From c1f3d49c9f7c626f5e17c0c653c56d3d0e7e1831 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 31 Mar 2008 02:37:40 +0200 Subject: updates for 0.4.1 --- skype/Makefile | 2 +- skype/NEWS | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index ff3b1bfe..8a86e788 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.4.0 +VERSION = 0.4.1 AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') diff --git a/skype/NEWS b/skype/NEWS index 77b4c05d..8eb5409a 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,10 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.4.1 - support for building the plugin on Mac OSX + - tested with BitlBee 1.2 and Skype 2.0.0.63 + - avoid ${prefix} (by autoconf) in the config file as we + don't handle such a variable + - now you can call echo123 (patch by Riskó Gergely) 0.4.0 - support for starting, accepting and rejecting calls - also updated documentation (the key is the account set skype/call command) -- cgit v1.2.3 From 51dc72dbd88fec640d9838171a4cc5f5d8430274 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 3 Apr 2008 00:44:01 +0200 Subject: skype_set_call() allow calling anybody - here is the logic: we first try to map nicks to skype user names. on success, we use the username, on failure we use the value we got directly, later skype will return an error if there is no such nick or such other error occures. --- skype/skype.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 1e436074..98de4ff7 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -998,13 +998,8 @@ static char *skype_set_call( set_t *set, char *value ) { user_t *u = user_find(acc->irc, value); /* We are starting a call */ - if(!u && strcmp(value, "echo123")) - { - imcb_error(ic, "%s - no such nick", value); - return(value); - } - if(!strcmp(value, "echo123")) - nick = g_strdup("echo123"); + if(!u) + nick = g_strdup(value); else nick = g_strdup(u->handle); ptr = strchr(nick, '@'); -- cgit v1.2.3 From b054fad92df7f0a843451f1178f1393b0d14e7b2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 3 Apr 2008 00:57:17 +0200 Subject: new skype_call_strerror() function to handle different call errors --- skype/skype.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 98de4ff7..8e041544 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -108,6 +108,9 @@ struct skype_data char *info_city; char *info_homepage; char *info_about; + /* When a call fails, we get the reason and later we get the failure + * event, so store the failure code here till then */ + int failurereason; }; struct skype_away_state @@ -235,6 +238,38 @@ struct groupchat *skype_chat_by_name( struct im_connection *ic, char *name ) return ret; } +static char *skype_call_strerror(int err) +{ + switch(err) { + case 1: + return "Miscellaneous error"; + case 2: + return "User or phone number does not exist."; + case 3: + return "User is offline"; + case 4: + return "No proxy found"; + case 5: + return "Session terminated."; + case 6: + return "No common codec found."; + case 7: + return "Sound I/O error."; + case 8: + return "Problem with remote sound device."; + case 9: + return "Call blocked by recipient."; + case 10: + return "Recipient not a friend."; + case 11: + return "Current user not authorized by recipient."; + case 12: + return "Sound recording error."; + default: + return "Unknown error"; + } +} + static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition cond ) { struct im_connection *ic = data; @@ -592,7 +627,9 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c char *info = strchr(id, ' '); *info = '\0'; info++; - if(!strcmp(info, "STATUS RINGING")) + if(!strncmp(info, "FAILUREREASON ", 14)) + sd->failurereason = atoi(strchr(info, ' ')); + else if(!strcmp(info, "STATUS RINGING")) { if(sd->call_id) g_free(sd->call_id); @@ -633,6 +670,10 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c sd->call_id = g_strdup(id); sd->call_out = TRUE; } + else if(!strcmp(info, "STATUS FAILED")) + { + imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason)); + } else if(!strncmp(info, "DURATION ", 9)) { if(sd->call_duration) -- cgit v1.2.3 From 76eb071c636704c0223dff25ce0109f763f3296d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 3 Apr 2008 01:00:57 +0200 Subject: skype_read_callback(): mark a call ended if it failed --- skype/skype.c | 1 + 1 file changed, 1 insertion(+) diff --git a/skype/skype.c b/skype/skype.c index 8e041544..4666f6cd 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -673,6 +673,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c else if(!strcmp(info, "STATUS FAILED")) { imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason)); + sd->call_id = NULL; } else if(!strncmp(info, "DURATION ", 9)) { -- cgit v1.2.3 From 2af671a788ca8a7b3ec5fd667721438fdc770ee0 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 3 Apr 2008 01:11:21 +0200 Subject: new skype_set_balance() function - it triggers a query from skype for the current balance, but the read callback does not handle it yet --- skype/skype.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index 4666f6cd..a09476f1 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -1029,6 +1029,18 @@ static char *skype_set_display_name( set_t *set, char *value ) return(value); } +static char *skype_set_balance( set_t *set, char *value ) +{ + account_t *acc = set->data; + struct im_connection *ic = acc->ic; + char *buf; + + buf = g_strdup_printf("GET PROFILE PSTN_BALANCE"); + skype_write( ic, buf, strlen( buf ) ); + g_free(buf); + return(value); +} + static char *skype_set_call( set_t *set, char *value ) { account_t *acc = set->data; @@ -1234,6 +1246,9 @@ static void skype_init( account_t *acc ) s = set_add( &acc->set, "call", NULL, skype_set_call, acc ); s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; + + s = set_add( &acc->set, "balance", NULL, skype_set_balance, acc ); + s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; } void init_plugin(void) -- cgit v1.2.3 From b7d3dff7ea68460f1a3e5ce22331d622b4df4d76 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 3 Apr 2008 01:18:05 +0200 Subject: skype_read_callback(): handle a profile's balance --- skype/skype.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skype/skype.c b/skype/skype.c index a09476f1..7a677e86 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -871,6 +871,10 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c imc_logout( ic, TRUE ); } } + else if(!strncmp(line, "PROFILE PSTN_BALANCE ", 21)) + { + imcb_log(ic, "SkypeOut balance value is '%s'.", line+21); + } lineptr++; } g_strfreev(lines); -- cgit v1.2.3 From 9aed2f1db6f8f08c8dd6523a445079582c2951b2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 3 Apr 2008 01:19:37 +0200 Subject: document the new account set skype/balance command --- skype/README | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index dff100fb..627bfc90 100644 --- a/skype/README +++ b/skype/README @@ -230,7 +230,8 @@ your VNC server regularly. (How ugly.) - Running Skype on a machine different to BitlBee is possible, the communication is encrypted. -- Managing outgoing calls (with call duration at the end): +- Managing outgoing calls (with call duration at the end, including + SkypeOut calls if you use a phone number instead of a nick): * `account set skype/call nick` * `account set -del skype/call` @@ -238,6 +239,10 @@ your VNC server regularly. (How ugly.) - Managing incoming calls via questions, just like when you add / remove contacts. +- Querying the current SkypeOut balance: + + * `account set skype/balance query` + == What needs to be done (aka. TODO) - Notice if foo invites bar. Currently you can see only that bar joined. -- cgit v1.2.3 From 483430791a6b81871730258ca42d058c3989f942 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 3 Apr 2008 01:21:49 +0200 Subject: update NEWS --- skype/NEWS | 2 ++ skype/README | 2 ++ 2 files changed, 4 insertions(+) diff --git a/skype/NEWS b/skype/NEWS index 8eb5409a..9a23eac0 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,7 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- + - support for SkypeOut calls + - support for querying the balance from Skype 0.4.1 - support for building the plugin on Mac OSX - tested with BitlBee 1.2 and Skype 2.0.0.63 - avoid ${prefix} (by autoconf) in the config file as we diff --git a/skype/README b/skype/README index 627bfc90..9549b5e3 100644 --- a/skype/README +++ b/skype/README @@ -309,6 +309,8 @@ for the following people: * Cristobal Palmer (tarheelcoxn), for helping to testing the plugin in a timezone different to mine +* Risko Gergely, for his SkypeOut ideas + * people on `#bitlbee` for feedback Back to my link:/projects[projects page]. -- cgit v1.2.3 From d24b73fdab7c4892c93e1f75a094b0f7ebaf97d3 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 4 Apr 2008 16:19:46 +0200 Subject: skype_read_callback(): handle SKYPEOUT nicks as offline as well - you can chat with them and you can stil call them without spamming the user list --- skype/skype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 7a677e86..497d1590 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -322,7 +322,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { ptr = g_strdup_printf("%s@skype.com", user); imcb_add_buddy(ic, ptr, NULL); - if(strcmp(status, "OFFLINE") != 0) + if(strcmp(status, "OFFLINE") != 0 && strcmp(status, "SKYPEOUT") != 0) flags |= OPT_LOGGED_IN; if(strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0) flags |= OPT_AWAY; -- cgit v1.2.3 From bd417a19271d514b66e1abe1bd708634ba1b8400 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 4 Apr 2008 16:35:41 +0200 Subject: new config variable: skypeout_offline for who liked the old behaviour --- skype/skype.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/skype/skype.c b/skype/skype.c index 497d1590..0d5df057 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -322,7 +322,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { ptr = g_strdup_printf("%s@skype.com", user); imcb_add_buddy(ic, ptr, NULL); - if(strcmp(status, "OFFLINE") != 0 && strcmp(status, "SKYPEOUT") != 0) + if(strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") || !set_getbool(&ic->acc->set, "skypeout_offline"))) flags |= OPT_LOGGED_IN; if(strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0) flags |= OPT_AWAY; @@ -1253,6 +1253,8 @@ static void skype_init( account_t *acc ) s = set_add( &acc->set, "balance", NULL, skype_set_balance, acc ); s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; + + s = set_add( &acc->set, "skypeout_offline", "true", set_eval_bool, acc ); } void init_plugin(void) -- cgit v1.2.3 From 9ace502933e8157d3f8e5c33e0ec5d5de64476c8 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 4 Apr 2008 16:37:24 +0200 Subject: document how to set a custom port --- skype/README | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/skype/README b/skype/README index 9549b5e3..429dc517 100644 --- a/skype/README +++ b/skype/README @@ -129,6 +129,12 @@ account set skype/server localhost in `skyped.conf`. If you want to run skyped on a remote machine, replace `localhost` with the name of the machine. +If you are running skyped on a custom port: + +---- +account set skype/port +---- + == Setting up Skype in a VNC server (optional) Optionally, if you want to run Skype on a server, you might want to setup up -- cgit v1.2.3 From 799679477717b682280695b081d4ec1925e82e16 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 4 Apr 2008 16:40:26 +0200 Subject: document skypeout_offline setting --- skype/README | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/skype/README b/skype/README index 429dc517..33506f70 100644 --- a/skype/README +++ b/skype/README @@ -135,6 +135,19 @@ If you are running skyped on a custom port: account set skype/port ---- +If you want to set your full name (optional): + +---- +account set skype/display_name "John Smith" +---- + +If you want to see your skypeout contacts online as well (they are +offline by default): + +---- +account set skype/skypeout_offline false +---- + == Setting up Skype in a VNC server (optional) Optionally, if you want to run Skype on a server, you might want to setup up -- cgit v1.2.3 From 8b0e38863660a743c7bf3cf4f768fc47ba6cf2c2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 5 Apr 2008 01:42:54 +0200 Subject: update news --- skype/NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/skype/NEWS b/skype/NEWS index 9a23eac0..b24b3339 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,7 +1,10 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- + - new skypeout_offline setting for hiding/showing SkypeOut + contacts - support for SkypeOut calls - support for querying the balance from Skype + - all setting should be documented now 0.4.1 - support for building the plugin on Mac OSX - tested with BitlBee 1.2 and Skype 2.0.0.63 - avoid ${prefix} (by autoconf) in the config file as we -- cgit v1.2.3 From 587a921d30ad99260e99f066c795a79f829ac819 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 5 Apr 2008 14:14:52 +0200 Subject: new testemonial --- skype/README | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/skype/README b/skype/README index 33506f70..a9c82e86 100644 --- a/skype/README +++ b/skype/README @@ -314,6 +314,12 @@ Good Job and thank you! Sebastian ---- +---- +Big respect for your work, i really appreciate it. + +Martin +---- + == Thanks for the following people: -- cgit v1.2.3 From 944a941af5b42b669334a9b937067a7e8cd856db Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 6 Apr 2008 20:39:32 +0200 Subject: a fix for python-2.4 compatibility - interesting, it has been reported this is the only problem, though ideally skype4py doesn't work with python-2.4 either ;) --- skype/skyped.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index 271450b7..7726a4dd 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -110,7 +110,7 @@ def dprint(msg): if options.debug: print msg -class SkypeApi(): +class SkypeApi: def __init__(self): self.skype = Skype4Py.Skype() self.skype.OnNotify = self.recv -- cgit v1.2.3 From 93264f042351149eeb2b836beeea6f794397ca0c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 10 Apr 2008 18:57:16 +0200 Subject: new testemonial --- skype/README | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/skype/README b/skype/README index a9c82e86..8d58cb12 100644 --- a/skype/README +++ b/skype/README @@ -320,6 +320,16 @@ Big respect for your work, i really appreciate it. Martin ---- +---- +Thanks for bitlbee-skype. As a blind Linux user, I cannot use the +skype GUI client because qt apps ar not accessible yet with the +available screen readers. bitlbee-skype allows me to make use of skype +without having to interact much with the GUI client, which helps me a +lot. + +Lukas +---- + == Thanks for the following people: -- cgit v1.2.3 From 7f1cf705abd32959b9b949338bf4295c360f3891 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 16 Apr 2008 11:09:59 +0200 Subject: antispam --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 8d58cb12..60aa4081 100644 --- a/skype/README +++ b/skype/README @@ -1,5 +1,5 @@ = Skype plugin for BitlBee -Miklos Vajna +Miklos Vajna == Status -- cgit v1.2.3 From 0fbeef1a74f70c5ee7bd5f408ef7bbd861d3a563 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 20 Apr 2008 22:40:32 +0200 Subject: skyped: use gobject.timeout_add() to make it more responsive --- skype/skyped.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 7726a4dd..9fa6abdd 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -69,7 +69,6 @@ def idle_handler(skype): skype.skype.SendCommand(c) except Skype4Py.SkypeAPIError, s: dprint("Warning, pinging Skype failed (%s)." % (s)) - time.sleep(2) return True def server(host, port): @@ -243,5 +242,5 @@ if __name__=='__main__': skype = SkypeApi() except Skype4Py.SkypeAPIError, s: sys.exit("%s. Are you sure you have started Skype?" % s) - gobject.idle_add(idle_handler, skype) + gobject.timeout_add(2000, idle_handler, skype) gobject.MainLoop().run() -- cgit v1.2.3 From d184f30fb86fbac067a337086ade2a78c2d44d4e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 20 Apr 2008 23:38:16 +0200 Subject: updates for 0.4.2 --- skype/Makefile | 2 +- skype/NEWS | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 8a86e788..cab5cc26 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.4.1 +VERSION = 0.4.2 AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') diff --git a/skype/NEWS b/skype/NEWS index b24b3339..3bf23247 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,6 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.4.2 - skyped should be now more responsive - new skypeout_offline setting for hiding/showing SkypeOut contacts - support for SkypeOut calls -- cgit v1.2.3 From 80dfdce52f8a39ae24e7dc6993a341b559b2f211 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 28 Apr 2008 13:10:28 +0200 Subject: catch any error on send (ie SysCallError as well) --- skype/skyped.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index 9fa6abdd..e46d4ec3 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -140,7 +140,7 @@ class SkypeApi: if options.conn: try: options.conn.send(e + "\n") - except IOError, s: + except Exception, s: dprint("Warning, sending '%s' failed (%s)." % (e, s)) def send(self, msg_text): -- cgit v1.2.3 From 140ffc8762b385cd0caba57ba192faba46b21094 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 1 May 2008 00:07:15 +0200 Subject: and same for receive: catch any error --- skype/skyped.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index e46d4ec3..eab69a32 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -57,7 +57,8 @@ def input_handler(fd, io_condition): else: try: input = fd.recv(1024) - except SSL.SysCallError: + except Exception, s: + dprint("Warning, receiving 1024 bytes failed (%s)." % s) return True for i in input.split("\n"): skype.send(i.strip()) -- cgit v1.2.3 From 4c340e907d611c13bee56393aa782aa954f758fc Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 1 May 2008 00:17:55 +0200 Subject: modularize openssl code - so that later we may use gnutls as well (or other ssl implementations) --- skype/skyped.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index eab69a32..c9375596 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -31,7 +31,6 @@ import getopt import Skype4Py import sha from ConfigParser import ConfigParser -from OpenSSL import SSL from traceback import print_exception __version__ = "0.1.1" @@ -75,10 +74,12 @@ def idle_handler(skype): def server(host, port): global options + from OpenSSL import SSL ctx = SSL.Context(SSL.TLSv1_METHOD) ctx.use_privatekey_file(options.config.sslkey) ctx.use_certificate_file(options.config.sslcert) sock = SSL.Connection(ctx, socket.socket()) + sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind((host, port)) sock.listen(1) -- cgit v1.2.3 From b0d40f5b69100fa89498f0f6f496ce7171352261 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 1 May 2008 01:57:49 +0200 Subject: add python-gnutls support and make it default if available - this change in general should be ok, since openssl has problems when using it from gpl software which is distributed as a binary. - anyway, i hope that this will solve that magic "Fatal Python error: PyEval_RestoreThread: NULL tstate" error. at least it worth a try. --- skype/README | 8 ++++++++ skype/skyped.py | 24 +++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/skype/README b/skype/README index 60aa4081..bf6d98bf 100644 --- a/skype/README +++ b/skype/README @@ -34,6 +34,7 @@ not..) * Python >= 2.5. Skype4Py does not work with 2.4. * PyGObject >= 2.8.0. Older versions are part of PyGTK. (And you don't want to install GTK for nothing, right?) +* pyopenssl or python-gnutls. `bitlbee-skype` has been tested under Linux and Mac OS X. Skype and Skype4py is available under Windows, too, so it probably works, but this has not been tested. @@ -112,6 +113,13 @@ if you used the `--sysconfdir` switch when running bitlbee-skype's `configure`. NOTE: Maybe you want to adjust the permissions in the `/usr/local/etc/skyped` dir. For example make it readable by just your user. +- If both pyopenssl and python-gnutls are available, then python-gnutls + will be used. This behaviour can be overwritten by: + +---- +$ export SKYPED_NO_GNUTLS=1 +---- + - Start `skyped` (the tcp server): ---- diff --git a/skype/skyped.py b/skype/skyped.py index c9375596..ece745f1 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -73,13 +73,21 @@ def idle_handler(skype): def server(host, port): global options - - from OpenSSL import SSL - ctx = SSL.Context(SSL.TLSv1_METHOD) - ctx.use_privatekey_file(options.config.sslkey) - ctx.use_certificate_file(options.config.sslcert) - sock = SSL.Connection(ctx, socket.socket()) - + try: + if "SKYPED_NO_GNUTLS" in os.environ.keys(): + dprint("Warning, using OpenSSL instead of gnutls as requested (not recommended).") + raise ImportError + from gnutls import crypto, connection + cert = crypto.X509Certificate(open(options.config.sslcert).read()) + key = crypto.X509PrivateKey(open(options.config.sslkey).read()) + cred = connection.X509Credentials(cert, key) + sock = connection.ServerSessionFactory(socket.socket(), cred) + except ImportError: + from OpenSSL import SSL + ctx = SSL.Context(SSL.TLSv1_METHOD) + ctx.use_privatekey_file(options.config.sslkey) + ctx.use_certificate_file(options.config.sslcert) + sock = SSL.Connection(ctx, socket.socket()) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind((host, port)) sock.listen(1) @@ -88,6 +96,8 @@ def server(host, port): def listener(sock, *args): global options options.conn, addr = sock.accept() + if hasattr(options.conn, 'handshake'): + options.conn.handshake() ret = 0 line = options.conn.recv(1024) if line.startswith("USERNAME") and line.split(' ')[1].strip() == options.config.username: -- cgit v1.2.3 From e3d0b10cfa542520c1e91ab7248c7309d7c120f1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 6 May 2008 10:09:39 +0200 Subject: added a new testemonial --- skype/README | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/skype/README b/skype/README index bf6d98bf..07a45777 100644 --- a/skype/README +++ b/skype/README @@ -338,6 +338,11 @@ lot. Lukas ---- +---- +02:12 < newton> i must say, i love this little bee ;) +02:15 < newton> tried it out today with the skype plugin, good work! +---- + == Thanks for the following people: -- cgit v1.2.3 From 4966d84194948f553a159cc2898b0895b622d59f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 12 May 2008 01:23:36 +0200 Subject: README: document how to avoid compiling bitlbee from source under deb 01:13 < wilmer> vmiklos: Ok, bitlbee-dev will be in unstable in a few hours! --- skype/README | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 07a45777..ffe3deea 100644 --- a/skype/README +++ b/skype/README @@ -55,7 +55,17 @@ connect to Skype, finally BitlBee can connect to `skyped`. # pacman-g2 -S bitlbee-skype ---- -- You need the latest stable BitlBee release: +and you don't have to compile anything manually. + +- If you use Debian: + +---- +# apt-get install bitlbee-dev +---- + +and you have to install `bitlbee-skype` from source. + +- Otherwise, you need the latest stable BitlBee release: ---- $ wget http://get.bitlbee.org/src/bitlbee-1.2.tar.gz -- cgit v1.2.3 From 71dd27d413dafec9557193b18151235d69547f1c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 12 May 2008 01:30:03 +0200 Subject: doc generation cleanup --- skype/Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index cab5cc26..bdc960e9 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -51,10 +51,8 @@ release: doc: HEADER.html Changelog HEADER.html: README Makefile - ln -s README HEADER.txt - asciidoc -a toc -a numbered -a sectids HEADER.txt + asciidoc -a toc -a numbered -a sectids -o HEADER.html README sed -i 's|@VERSION@|$(VERSION)|g' HEADER.html - rm HEADER.txt Changelog: .git/refs/heads/master git log --no-merges |git name-rev --tags --stdin >Changelog -- cgit v1.2.3 From 52937074a237514547254f8656abc1a2d2dfed6d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 13 May 2008 11:33:31 +0200 Subject: add more detailed info on how to install skype4py --- skype/README | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index ffe3deea..37740c53 100644 --- a/skype/README +++ b/skype/README @@ -52,7 +52,7 @@ connect to Skype, finally BitlBee can connect to `skyped`. - If you happen to be a happy Frugalware user: ---- -# pacman-g2 -S bitlbee-skype +# pacman-g2 -S bitlbee-skype skype4py ---- and you don't have to compile anything manually. @@ -63,7 +63,7 @@ and you don't have to compile anything manually. # apt-get install bitlbee-dev ---- -and you have to install `bitlbee-skype` from source. +and you have to install `bitlbee-skype` and `skype4py` from source. - Otherwise, you need the latest stable BitlBee release: @@ -102,7 +102,13 @@ $ make # make install ---- -- Install http://skype4py.sourceforge.net/[Skype4Py]. +- To install http://skype4py.sourceforge.net/[Skype4Py] from source: + +---- +$ tar -zxvf Skype4Py-x.x.x.x.tar.gz +$ cd Skype4Py-x.x.x.x +# python setup.py install +---- - Edit `/usr/local/etc/skyped/skyped.conf`: adjust `username` and `password`. The `username` should be your Skype login and the `password` can be whatever you -- cgit v1.2.3 From bd85ec5184ac405fa923e592127e761900f043c7 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 16 May 2008 13:09:24 +0200 Subject: skyped: close the socket on read/write error - it turns out that once we have a read/write error we can never use the socket again so just close it then bitlbee will reconnect properly --- skype/skyped.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index ece745f1..d53d02a7 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -58,7 +58,8 @@ def input_handler(fd, io_condition): input = fd.recv(1024) except Exception, s: dprint("Warning, receiving 1024 bytes failed (%s)." % s) - return True + fd.close() + return False for i in input.split("\n"): skype.send(i.strip()) return True @@ -154,6 +155,7 @@ class SkypeApi: options.conn.send(e + "\n") except Exception, s: dprint("Warning, sending '%s' failed (%s)." % (e, s)) + options.conn.close() def send(self, msg_text): if not len(msg_text): -- cgit v1.2.3 From 5588f7c42e76fc4ec72870bc38cc65333ac578cb Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 19 May 2008 15:25:49 +0200 Subject: don't die on failed handshake --- skype/skyped.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index d53d02a7..605b653b 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -98,7 +98,11 @@ def listener(sock, *args): global options options.conn, addr = sock.accept() if hasattr(options.conn, 'handshake'): - options.conn.handshake() + try: + options.conn.handshake() + except Exception: + dprint("Warning, handshake failed, closing connection.") + return False ret = 0 line = options.conn.recv(1024) if line.startswith("USERNAME") and line.split(' ')[1].strip() == options.config.username: -- cgit v1.2.3 From d0a6a8c6632010a01607a2d729d5539451595543 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 19 May 2008 17:24:18 +0200 Subject: update readme to be easier to follow for frugalware/debian users --- skype/README | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/skype/README b/skype/README index 37740c53..df64c8b4 100644 --- a/skype/README +++ b/skype/README @@ -46,10 +46,16 @@ Skype servers (the company's ones). It needs a running Skype client to do so. In fact BitlBee will connect to `skyped` (a tcp server, provided in this package) and `skyped` will connect to to your Skype client. -NOTE: The order is important. First `skyped` starts Skype. Then `skyped` can -connect to Skype, finally BitlBee can connect to `skyped`. +The benefit of this architecture is that you can run Skype and `skyped` +on a machine different to the one where you run BitlBee (it can be even +a public server) and/or your IRC client. -- If you happen to be a happy Frugalware user: +NOTE: The order is important. First `skyped` starts Skype. Then `skyped` +connects to Skype, finally BitlBee can connect to `skyped`. + +=== Installing under Frugalware + +- Install the necessary packages: ---- # pacman-g2 -S bitlbee-skype skype4py @@ -57,7 +63,9 @@ connect to Skype, finally BitlBee can connect to `skyped`. and you don't have to compile anything manually. -- If you use Debian: +=== Installing under Debian + +- Install the necessary development package: ---- # apt-get install bitlbee-dev @@ -65,7 +73,9 @@ and you don't have to compile anything manually. and you have to install `bitlbee-skype` and `skype4py` from source. -- Otherwise, you need the latest stable BitlBee release: +=== Installing from source + +- You need the latest stable BitlBee release: ---- $ wget http://get.bitlbee.org/src/bitlbee-1.2.tar.gz @@ -110,6 +120,8 @@ $ cd Skype4Py-x.x.x.x # python setup.py install ---- +=== Configuring + - Edit `/usr/local/etc/skyped/skyped.conf`: adjust `username` and `password`. The `username` should be your Skype login and the `password` can be whatever you want, but you will have to specify that one when adding the Skype account to -- cgit v1.2.3 From d8919158023fa0d84487973a17f3551f9c325ca5 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 19 May 2008 20:22:03 +0200 Subject: allow setting the port from the config file --- skype/skyped.conf.dist.in | 1 + skype/skyped.py | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/skype/skyped.conf.dist.in b/skype/skyped.conf.dist.in index a98d5ec8..2c23cf70 100644 --- a/skype/skyped.conf.dist.in +++ b/skype/skyped.conf.dist.in @@ -4,3 +4,4 @@ username = john password = 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33 cert = @sysconfdir@/skyped/skyped.cert.pem key = @sysconfdir@/skyped/skyped.key.pem +port = 2727 diff --git a/skype/skyped.py b/skype/skyped.py index 605b653b..272e02e7 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -30,7 +30,7 @@ import socket import getopt import Skype4Py import sha -from ConfigParser import ConfigParser +from ConfigParser import ConfigParser, NoOptionError from traceback import print_exception __version__ = "0.1.1" @@ -182,7 +182,7 @@ class Options: self.debug = False self.help = False self.host = "0.0.0.0" - self.port = 2727 + self.port = None self.version = False # well, this is a bit hackish. we store the socket of the last connected client # here and notify it. maybe later notify all connected clients? @@ -224,7 +224,7 @@ if __name__=='__main__': elif opt in ("-n", "--nofork"): options.daemon = False elif opt in ("-p", "--port"): - options.port = arg + options.port = int(arg) elif opt in ("-v", "--version"): options.version = True if options.help: @@ -243,6 +243,17 @@ if __name__=='__main__': options.config.password = options.config.get('skyped', 'password').split('#')[0] options.config.sslkey = options.config.get('skyped', 'key').split('#')[0] options.config.sslcert = options.config.get('skyped', 'cert').split('#')[0] + # hack: we have to parse the parameters first to locate the + # config file but the -p option should overwrite the value from + # the config file + try: + options.config.port = int(options.config.get('skyped', 'port').split('#')[0]) + if not options.port: + options.port = options.config.port + except NoOptionError: + pass + if not options.port: + options.port = 2727 dprint("Parsing config file '%s' done, username is '%s'." % (options.cfgpath, options.config.username)) if options.daemon: pid = os.fork() @@ -255,6 +266,8 @@ if __name__=='__main__': else: print 'skyped is started on port %s, pid: %d' % (options.port, pid) sys.exit(0) + else: + dprint('skyped is started on port %s' % options.port) server(options.host, options.port) try: skype = SkypeApi() -- cgit v1.2.3 From 96272765923c395e15948a5d76adf036569843ab Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 19 May 2008 20:22:58 +0200 Subject: remove no longer used CLIENT_NAME --- skype/skyped.py | 1 - 1 file changed, 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index 272e02e7..32048fdd 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -36,7 +36,6 @@ from traceback import print_exception __version__ = "0.1.1" SKYPE_SERVICE = 'com.Skype.API' -CLIENT_NAME = 'SkypeApiPythonShell' def eh(type, value, tb): if type != KeyboardInterrupt: -- cgit v1.2.3 From ece66da9a10fecde209c310c7785f266e40cb801 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 21 May 2008 15:05:29 +0200 Subject: document how do i usually start skyped in vnc --- skype/README | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/skype/README b/skype/README index df64c8b4..63a68e9b 100644 --- a/skype/README +++ b/skype/README @@ -218,13 +218,14 @@ Then start the server: $ vncserver ---- -Then connect to it, and set up Skype (username, password, enable -auto-login, start skyped and allow the `SkypeApiPythonShell` client when -Skype asks about it). +Then connect to it, start an `xterm`, set up Skype (username, password, +enable X11 API and allow the `Skype4Py` client), quit from Skype, and +start `skyped`. If you want to watch its traffic, enable debug messages +and foreground mode: -Please be aware about that Skype has serious memory leak issues. After running -with for a few weeks it may eat >300 MB of memory. Just don't forget to restart -your VNC server regularly. (How ugly.) +---- +$ skyped -n -d +---- == Features -- cgit v1.2.3 From 7987be8fae658532b5badaea2b5bc7c08c547e3d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 24 May 2008 02:55:18 +0200 Subject: tested with newer skype version --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 63a68e9b..3b619318 100644 --- a/skype/README +++ b/skype/README @@ -28,7 +28,7 @@ not..) == Requirements -* Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.63. +* Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.68. * BitlBee >= 1.1.1dev. The latest version I've tested is 1.2. * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. * Python >= 2.5. Skype4Py does not work with 2.4. -- cgit v1.2.3 From 8cd185c741d92b585576713322cd49ec1417e22f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 24 May 2008 03:02:27 +0200 Subject: updates for 0.5.0 --- skype/Makefile | 2 +- skype/NEWS | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index bdc960e9..cfb786ea 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.4.2 +VERSION = 0.5.0 AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') diff --git a/skype/NEWS b/skype/NEWS index 3bf23247..232e51e7 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,13 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.5.0 - skyped now uses gnutls if possible, which seem to be + more stable, compared to openssl. + - skyped now tries to handle all read/write errors from/to + clients, and always just warn about failures, never exit. + - installation for Debian users should be more simple + - improved documentation + - this .0 release should be quite stable, only about 100 + lines of new code 0.4.2 - skyped should be now more responsive - new skypeout_offline setting for hiding/showing SkypeOut contacts -- cgit v1.2.3 From 6344674a7d160c8fccdc811bda9f4ae26c90200d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 2 Jun 2008 00:44:26 +0200 Subject: update public chat todo --- skype/README | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index 3b619318..7c9c63b9 100644 --- a/skype/README +++ b/skype/README @@ -303,9 +303,10 @@ $ skyped -n -d - Notice if foo invites bar. Currently you can see only that bar joined. -- Public chats. See link:http://forum.skype.com/index.php?showtopic=98872[this - forum thread], it is still unclear how could it be done for you to be able to - `/join` to a public chat.. +- Public chats. See + link:https://developer.skype.com/jira/browse/SCL-381[this feature + request], this is because it is still not possible (under Linux) to + `join_chat` to a public chat.. - Add `--disable-skyped` and `--disable-plugin` switches in case one wants to build `bitlbee-skype` only for a public server or only for use with a public -- cgit v1.2.3 From eb4b91c99307eca83c8b11c5af8bc00c2ca5c64d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 18 Jun 2008 19:13:29 +0200 Subject: configure: fix "./configure: line 2824: test: too many arguments" --- skype/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/configure.ac b/skype/configure.ac index e169ad69..467f3149 100644 --- a/skype/configure.ac +++ b/skype/configure.ac @@ -4,7 +4,7 @@ AC_PROG_INSTALL AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Enable debug support (default: disabled)]), debug=yes) AC_MSG_CHECKING(for debug mode request) -if test x$debug = xyes ; then +if test "x$debug" = "xyes" ; then CFLAGS="-g -Wall -Werror" AC_MSG_RESULT(yes) else -- cgit v1.2.3 From aa4e3ed9d228d22653b5c39af5a8a71f20043efa Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 18 Jun 2008 19:13:53 +0200 Subject: echo some config output at the end of configure --- skype/configure.ac | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/skype/configure.ac b/skype/configure.ac index 467f3149..8b6d5787 100644 --- a/skype/configure.ac +++ b/skype/configure.ac @@ -33,3 +33,13 @@ CFLAGS="$CFLAGS $BITLBEE_CFLAGS" LDFLAGS="$LDFLAGS $BITLBEE_LIBS" AC_OUTPUT(config.mak) AC_OUTPUT(skyped.conf.dist) + +echo " + compiler flags: $CFLAGS + linker flags: $LDFLAGS + shared object flags: $SHARED_FLAGS + shared object extension: $SHARED_EXT + install program: $INSTALL + prefix: $prefix + sysconfig dir: $sysconfdir/skyped +" -- cgit v1.2.3 From ca911b47bfff4f63ea745f395153f4c882b87256 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 18 Jun 2008 19:15:30 +0200 Subject: configure: update email --- skype/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/configure.ac b/skype/configure.ac index 8b6d5787..637ebc9a 100644 --- a/skype/configure.ac +++ b/skype/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([Skype plugin for BitlBee], 1.0, [vmiklos@frugalware.org], bitlbee-skype) +AC_INIT([Skype plugin for BitlBee], 1.0, [vmiklos@vmiklos.hu], bitlbee-skype) AC_PROG_CC AC_PROG_INSTALL -- cgit v1.2.3 From b7fbeb4da939bc3e0b6aca9a71cf2b738bec2dad Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 18 Jun 2008 19:34:59 +0200 Subject: configure: match prefix with bitlbee's one otherwise bitlbee won't find the plugin --- skype/configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/skype/configure.ac b/skype/configure.ac index 637ebc9a..486427a5 100644 --- a/skype/configure.ac +++ b/skype/configure.ac @@ -31,6 +31,7 @@ dnl Check for bitlbee PKG_CHECK_MODULES(BITLBEE, bitlbee) CFLAGS="$CFLAGS $BITLBEE_CFLAGS" LDFLAGS="$LDFLAGS $BITLBEE_LIBS" +prefix=`$PKG_CONFIG --variable=prefix bitlbee` AC_OUTPUT(config.mak) AC_OUTPUT(skyped.conf.dist) -- cgit v1.2.3 From 89c68c7dcb6e9650af00bfaf336c8db190d762dd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 18 Jun 2008 19:37:28 +0200 Subject: updates for 0.5.1 --- skype/Makefile | 2 +- skype/NEWS | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index cfb786ea..474fd323 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.5.0 +VERSION = 0.5.1 AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') diff --git a/skype/NEWS b/skype/NEWS index 232e51e7..b69f13a4 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,9 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.5.1 - configure now automatically detects the right prefix to + match witl BitlBee's one + - minor documentation improvements (public chats, bug + reporting address) 0.5.0 - skyped now uses gnutls if possible, which seem to be more stable, compared to openssl. - skyped now tries to handle all read/write errors from/to -- cgit v1.2.3 From 21a387fd485dfcdc57047cc134960391e267d17e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 18 Jun 2008 19:47:26 +0200 Subject: docu update --- skype/README | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/skype/README b/skype/README index 7c9c63b9..f3deab01 100644 --- a/skype/README +++ b/skype/README @@ -93,7 +93,8 @@ $ make # make install install-dev ---- -- Get the plugin code: +- Get the plugin code (in an empty dir, or whereever you want, it does + not matter): ---- $ wget http://vmiklos.hu/project/bitlbee-skype/bitlbee-skype-@VERSION@.tar.gz @@ -101,9 +102,6 @@ $ tar xf bitlbee-skype-@VERSION@.tar.gz $ cd bitlbee-skype-@VERSION@ ---- -It doesn't matter where do you get it, it'll install the plugin to `/usr/local` -by default (that's the location where BitlBee searches for plugins by default). - - Compile and install it: ---- @@ -112,6 +110,9 @@ $ make # make install ---- +This will install the plugin to where BitlBee expects them, which is +`/usr/local/lib/bitlbee` if you installed BitlBee from source. + - To install http://skype4py.sourceforge.net/[Skype4Py] from source: ---- -- cgit v1.2.3 From b019c23bdd6e360ef5853f05cc964869c327f3f5 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 28 Jun 2008 02:06:44 +0200 Subject: add note about skype4py-1.x breakage --- skype/README | 1 + 1 file changed, 1 insertion(+) diff --git a/skype/README b/skype/README index f3deab01..5b04946c 100644 --- a/skype/README +++ b/skype/README @@ -31,6 +31,7 @@ not..) * Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.68. * BitlBee >= 1.1.1dev. The latest version I've tested is 1.2. * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. +NOTE: I had not had time yet to add support for 1.x yet. * Python >= 2.5. Skype4Py does not work with 2.4. * PyGObject >= 2.8.0. Older versions are part of PyGTK. (And you don't want to install GTK for nothing, right?) -- cgit v1.2.3 From d276c9a8a1580682b8937b17ff9da3a15c74f803 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 28 Jun 2008 02:07:20 +0200 Subject: readme: syntax fix --- skype/README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skype/README b/skype/README index 5b04946c..97ba0828 100644 --- a/skype/README +++ b/skype/README @@ -31,7 +31,9 @@ not..) * Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.68. * BitlBee >= 1.1.1dev. The latest version I've tested is 1.2. * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. + NOTE: I had not had time yet to add support for 1.x yet. + * Python >= 2.5. Skype4Py does not work with 2.4. * PyGObject >= 2.8.0. Older versions are part of PyGTK. (And you don't want to install GTK for nothing, right?) -- cgit v1.2.3 From f7c6049180a6e3ee702f7af4254981a60d84069d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 28 Jun 2008 02:07:56 +0200 Subject: readme: and a grammar one --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 97ba0828..c87f5329 100644 --- a/skype/README +++ b/skype/README @@ -32,7 +32,7 @@ not..) * BitlBee >= 1.1.1dev. The latest version I've tested is 1.2. * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. -NOTE: I had not had time yet to add support for 1.x yet. +NOTE: I had not had time to add support for 1.x yet. * Python >= 2.5. Skype4Py does not work with 2.4. * PyGObject >= 2.8.0. Older versions are part of PyGTK. (And you don't want to -- cgit v1.2.3 From 039116a68fd1e92ee0869f88d4ee52183349062b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 28 Jun 2008 02:09:25 +0200 Subject: add support for bitlbee-1.2.1 --- skype/README | 3 ++- skype/skype.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/skype/README b/skype/README index c87f5329..8e9bb372 100644 --- a/skype/README +++ b/skype/README @@ -29,7 +29,8 @@ not..) == Requirements * Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.68. -* BitlBee >= 1.1.1dev. The latest version I've tested is 1.2. +* BitlBee >= 1.2.1. Use old versions (<=0.5.1) if you have 1.2 or + 1.1.1dev installed. * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. NOTE: I had not had time to add support for 1.x yet. diff --git a/skype/skype.c b/skype/skype.c index 0d5df057..7c46db33 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -167,8 +167,9 @@ int skype_write( struct im_connection *ic, char *buf, int len ) return TRUE; } -static void skype_buddy_ask_yes( gpointer w, struct skype_buddy_ask_data *bla ) +static void skype_buddy_ask_yes( void *data ) { + struct skype_buddy_ask_data *bla = data; char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED TRUE", bla->handle); skype_write( bla->ic, buf, strlen( buf ) ); g_free(buf); @@ -176,8 +177,9 @@ static void skype_buddy_ask_yes( gpointer w, struct skype_buddy_ask_data *bla ) g_free(bla); } -static void skype_buddy_ask_no( gpointer w, struct skype_buddy_ask_data *bla ) +static void skype_buddy_ask_no( void *data ) { + struct skype_buddy_ask_data *bla = data; char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED FALSE", bla->handle); skype_write( bla->ic, buf, strlen( buf ) ); g_free(buf); @@ -198,8 +200,9 @@ void skype_buddy_ask( struct im_connection *ic, char *handle, char *message) g_free( buf ); } -static void skype_call_ask_yes( gpointer w, struct skype_buddy_ask_data *bla ) +static void skype_call_ask_yes( void *data ) { + struct skype_buddy_ask_data *bla = data; char *buf = g_strdup_printf("SET CALL %s STATUS INPROGRESS", bla->handle); skype_write( bla->ic, buf, strlen( buf ) ); g_free(buf); @@ -207,8 +210,9 @@ static void skype_call_ask_yes( gpointer w, struct skype_buddy_ask_data *bla ) g_free(bla); } -static void skype_call_ask_no( gpointer w, struct skype_buddy_ask_data *bla ) +static void skype_call_ask_no( void *data ) { + struct skype_buddy_ask_data *bla = data; char *buf = g_strdup_printf("SET CALL %s STATUS FINISHED", bla->handle); skype_write( bla->ic, buf, strlen( buf ) ); g_free(buf); -- cgit v1.2.3 From 9765aa67882cebea28e49f8f73bed66dfbd43b15 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 28 Jun 2008 02:10:42 +0200 Subject: updates for 0.6.0 --- skype/Makefile | 2 +- skype/NEWS | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 474fd323..48b9d07b 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.5.1 +VERSION = 0.6.0 AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') diff --git a/skype/NEWS b/skype/NEWS index b69f13a4..8c0d0b80 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,6 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.6.0 - works with BitlBee 1.2.1 0.5.1 - configure now automatically detects the right prefix to match witl BitlBee's one - minor documentation improvements (public chats, bug -- cgit v1.2.3 From 3839517cd8739f4d079ed8573fd58a9244092abe Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 28 Jun 2008 02:11:50 +0200 Subject: change key id --- skype/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index 48b9d07b..c1f7cf8b 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -45,8 +45,8 @@ dist: release: git tag $(VERSION) $(MAKE) dist - gpg --comment "See http://ftp.frugalware.org/pub/README.GPG for info" \ - -ba -u 20F55619 bitlbee-skype-$(VERSION).tar.gz + gpg --comment "See http://vmiklos.hu/gpg/ for info" \ + -ba bitlbee-skype-$(VERSION).tar.gz doc: HEADER.html Changelog -- cgit v1.2.3 From 1d14818c6015adb0ec91264360f710e85f1bdbc0 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 28 Jun 2008 02:16:11 +0200 Subject: doc cleanup --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 8e9bb372..e5f9bf32 100644 --- a/skype/README +++ b/skype/README @@ -62,7 +62,7 @@ connects to Skype, finally BitlBee can connect to `skyped`. - Install the necessary packages: ---- -# pacman-g2 -S bitlbee-skype skype4py +# pacman-g2 -S bitlbee-skype ---- and you don't have to compile anything manually. -- cgit v1.2.3 From 9033a0ab5c23a5031f45ab4982c762809db41cd6 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 10 Jul 2008 10:29:22 +0200 Subject: new todo --- skype/README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/skype/README b/skype/README index e5f9bf32..1fd5ad64 100644 --- a/skype/README +++ b/skype/README @@ -317,6 +317,9 @@ $ skyped -n -d build `bitlbee-skype` only for a public server or only for use with a public server. +- Add some keep-alive traffic so that bitlbee won't disconnect from + skyped when nothing happens for a long time. + == I would like to have support for ... If something does not work and it's not in the TODO section, then please -- cgit v1.2.3 From 4b0092ef36e57d7043720078482d01212749e9f1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jul 2008 22:10:31 +0200 Subject: skyped: send periodically a 'PING' to the client also ignore the 'PONG' output from it (so don't forward it to skype) --- skype/skyped.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 32048fdd..dbbd2e53 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -63,7 +63,7 @@ def input_handler(fd, io_condition): skype.send(i.strip()) return True -def idle_handler(skype): +def skype_idle_handler(skype): try: c = skype.skype.Command("PING", Block=True) skype.skype.SendCommand(c) @@ -71,6 +71,16 @@ def idle_handler(skype): dprint("Warning, pinging Skype failed (%s)." % (s)) return True +def bitlbee_idle_handler(skype): + if options.conn: + try: + e = "PING" + options.conn.send("%s\n" % e) + except Exception, s: + dprint("Warning, sending '%s' failed (%s)." % (e, s)) + options.conn.close() + return True + def server(host, port): global options try: @@ -161,7 +171,7 @@ class SkypeApi: options.conn.close() def send(self, msg_text): - if not len(msg_text): + if not len(msg_text) or msg_text == "PONG": return e = msg_text.decode(locale.getdefaultlocale()[1]) dprint('>> ' + e) @@ -272,5 +282,6 @@ if __name__=='__main__': skype = SkypeApi() except Skype4Py.SkypeAPIError, s: sys.exit("%s. Are you sure you have started Skype?" % s) - gobject.timeout_add(2000, idle_handler, skype) + gobject.timeout_add(2000, skype_idle_handler, skype) + gobject.timeout_add(60000, bitlbee_idle_handler, skype) gobject.MainLoop().run() -- cgit v1.2.3 From 6af3e14971bcc890c01895474b00aeced3d1ce26 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 12 Jul 2008 22:11:10 +0200 Subject: skype.c: respont with a PONG to PING --- skype/README | 3 --- skype/skype.c | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/skype/README b/skype/README index 1fd5ad64..e5f9bf32 100644 --- a/skype/README +++ b/skype/README @@ -317,9 +317,6 @@ $ skyped -n -d build `bitlbee-skype` only for a public server or only for use with a public server. -- Add some keep-alive traffic so that bitlbee won't disconnect from - skyped when nothing happens for a long time. - == I would like to have support for ... If something does not work and it's not in the TODO section, then please diff --git a/skype/skype.c b/skype/skype.c index 7c46db33..470c1035 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -879,6 +879,11 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { imcb_log(ic, "SkypeOut balance value is '%s'.", line+21); } + else if(!strncmp(line, "PING", 4)) + { + g_snprintf(buf, 1024, "PONG\n"); + skype_write(ic, buf, strlen(buf)); + } lineptr++; } g_strfreev(lines); -- cgit v1.2.3 From 9f829c4b71d5c86db7b59a6b7d8f7dc8c5c23295 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 24 Jul 2008 14:56:09 +0200 Subject: fix up syntax for newer asciidoc --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index e5f9bf32..c2960c48 100644 --- a/skype/README +++ b/skype/README @@ -3,7 +3,7 @@ Miklos Vajna == Status -[Wilmer van der Gaast (author of BitlBee)] +[quote, Wilmer van der Gaast (author of BitlBee)] ____ Okay, this exists now, with lots of thanks to vmiklos for his *excellent* work!! -- cgit v1.2.3 From 59bf24f8f0373bf190b90f9a2ca6949857b9dc4e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 29 Jul 2008 18:08:10 +0200 Subject: update note about skype4py-1.x --- skype/README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index c2960c48..032d1c9b 100644 --- a/skype/README +++ b/skype/README @@ -33,7 +33,8 @@ not..) 1.1.1dev installed. * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. -NOTE: I had not had time to add support for 1.x yet. +NOTE: 1.x just does not work for me. I mailed the author but did not +receive any answer so far. * Python >= 2.5. Skype4Py does not work with 2.4. * PyGObject >= 2.8.0. Older versions are part of PyGTK. (And you don't want to -- cgit v1.2.3 From df482d406c71ecc539c77fbc109992433ba0ce42 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 29 Jul 2008 18:12:02 +0200 Subject: next testemonial --- skype/README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skype/README b/skype/README index 032d1c9b..19370ff0 100644 --- a/skype/README +++ b/skype/README @@ -379,6 +379,10 @@ Lukas 02:15 < newton> tried it out today with the skype plugin, good work! ---- +---- +18:10 < miCSu> it works fine +---- + == Thanks for the following people: -- cgit v1.2.3 From 75d5e71882789ec27c0615db0e6125cfc3f186aa Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 29 Jul 2008 21:08:45 +0200 Subject: tested 2.0.0.72 --- skype/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 19370ff0..67f6bbff 100644 --- a/skype/README +++ b/skype/README @@ -28,7 +28,7 @@ not..) == Requirements -* Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.68. +* Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.72. * BitlBee >= 1.2.1. Use old versions (<=0.5.1) if you have 1.2 or 1.1.1dev installed. * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. -- cgit v1.2.3 From 446c6fffaf80d86b6c756c728adb0d5fb5b40110 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 7 Aug 2008 15:19:34 +0200 Subject: typo fix for creating the osx plugin --- skype/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/configure.ac b/skype/configure.ac index 486427a5..4fefe614 100644 --- a/skype/configure.ac +++ b/skype/configure.ac @@ -18,7 +18,7 @@ case "`$CC -dumpmachine`" in ;; *apple-darwin*) SHARED_FLAGS="-dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup" - SHARED_EXT="dynlib" + SHARED_EXT="dylib" ;; *) AC_MSG_ERROR([Your machine is not yet supported]) -- cgit v1.2.3 From 1f59f2f7eaefc001b8c30eff12a8c52b94c9b113 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 15 Aug 2008 18:08:53 +0200 Subject: fix bitlbee compile instructions --- skype/Makefile | 3 +++ skype/README | 12 +++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index c1f7cf8b..53217343 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,8 @@ -include config.mak VERSION = 0.6.0 +# oldest supported one +BITLBEE_VERSION = 1.2.1 AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') @@ -53,6 +55,7 @@ doc: HEADER.html Changelog HEADER.html: README Makefile asciidoc -a toc -a numbered -a sectids -o HEADER.html README sed -i 's|@VERSION@|$(VERSION)|g' HEADER.html + sed -i 's|@BITLBEE_VERSION@|$(BITLBEE_VERSION)|g' HEADER.html Changelog: .git/refs/heads/master git log --no-merges |git name-rev --tags --stdin >Changelog diff --git a/skype/README b/skype/README index 67f6bbff..c55d2334 100644 --- a/skype/README +++ b/skype/README @@ -29,8 +29,8 @@ not..) == Requirements * Skype >= 1.4.0.99. The latest version I've tested is 2.0.0.72. -* BitlBee >= 1.2.1. Use old versions (<=0.5.1) if you have 1.2 or - 1.1.1dev installed. +* BitlBee >= @BITLBEE_VERSION@. Use old versions (0.5.1 or earlier) if + you have older BitlBee installed. * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. NOTE: 1.x just does not work for me. I mailed the author but did not @@ -83,13 +83,11 @@ and you have to install `bitlbee-skype` and `skype4py` from source. - You need the latest stable BitlBee release: ---- -$ wget http://get.bitlbee.org/src/bitlbee-1.2.tar.gz -$ tar xf bitlbee-1.2.tar.gz -$ cd bitlbee-1.2 +$ wget http://get.bitlbee.org/src/bitlbee-@BITLBEE_VERSION@.tar.gz +$ tar xf bitlbee-@BITLBEE_VERSION@.tar.gz +$ cd bitlbee-@BITLBEE_VERSION@ ---- -NOTE: You no longer need additional patches, as of version 1.1.1dev. - - Now compile and install it: ---- -- cgit v1.2.3 From 21978bce030581756d2eac0abf45235ac03a6baa Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 3 Sep 2008 12:44:24 +0200 Subject: don't depen on a version with secbugs --- skype/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 53217343..8d1fb153 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -2,7 +2,7 @@ VERSION = 0.6.0 # oldest supported one -BITLBEE_VERSION = 1.2.1 +BITLBEE_VERSION = 1.2.2 AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') -- cgit v1.2.3 From 15e220045ffd8fdc88a953cf4b4bbfc3ca1c5692 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 3 Sep 2008 12:50:54 +0200 Subject: add a little story about my uptime ;) --- skype/README | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/skype/README b/skype/README index c55d2334..23a1b0e9 100644 --- a/skype/README +++ b/skype/README @@ -16,8 +16,10 @@ One day I browsed the BitlBee bugtracker and found http://bugs.bitlbee.org/bitlbee/ticket/82[this] ticket. Then after a while I returned and saw that it was still open. So I wrote it. -It's pretty stable, I use it for my daily work. Being a plug-in, no patching -is required, you can just install it after installing BitlBee itself. +It's pretty stable (one day I wanted to restart it because of an upgrade +and just noticed it was running for 2+ months without crashing), I use +it for my daily work. Being a plug-in, no patching is required, you can +just install it after installing BitlBee itself. NOTE: You will see that this implementation of the Skype plug-in still requires a Skype instance to be running. This is because I'm not motivated to reverse -- cgit v1.2.3 From 69939608df5a3af1aba01bf78513137758590cf1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 5 Sep 2008 21:54:45 +0200 Subject: check for the skype4py python module and disable skyped if not available --- skype/Makefile | 4 +++- skype/config.mak.in | 1 + skype/configure.ac | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 8d1fb153..fd298f20 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -11,14 +11,16 @@ skype.$(SHARED_EXT): skype.c config.mak install: skype.$(SHARED_EXT) skyped.py $(INSTALL) -d $(DESTDIR)$(plugindir) + $(INSTALL) skype.$(SHARED_EXT) $(DESTDIR)$(plugindir) +ifeq ($(SKYPED),yes) $(INSTALL) -d $(DESTDIR)$(bindir) $(INSTALL) -d $(DESTDIR)$(sysconfdir) - $(INSTALL) skype.$(SHARED_EXT) $(DESTDIR)$(plugindir) $(INSTALL) skyped.py $(DESTDIR)$(bindir)/skyped sed -i 's|/usr/local/etc/skyped|$(sysconfdir)|' $(DESTDIR)$(bindir)/skyped $(INSTALL) -m644 skyped.conf.dist $(DESTDIR)$(sysconfdir)/skyped.conf sed -i 's|$${prefix}|$(prefix)|' $(DESTDIR)$(sysconfdir)/skyped.conf $(INSTALL) -m644 skyped.cnf $(DESTDIR)$(sysconfdir) +endif client: client.c diff --git a/skype/config.mak.in b/skype/config.mak.in index 5f06a5b9..e133ed87 100644 --- a/skype/config.mak.in +++ b/skype/config.mak.in @@ -2,6 +2,7 @@ CFLAGS = @CFLAGS@ LDFLAGS = @LDFLAGS@ SHARED_FLAGS = @SHARED_FLAGS@ SHARED_EXT = @SHARED_EXT@ +SKYPE4PY = @SKYPE4PY@ INSTALL = @INSTALL@ prefix = @prefix@ sysconfdir = @sysconfdir@/skyped diff --git a/skype/configure.ac b/skype/configure.ac index 4fefe614..a168d5ac 100644 --- a/skype/configure.ac +++ b/skype/configure.ac @@ -32,6 +32,19 @@ PKG_CHECK_MODULES(BITLBEE, bitlbee) CFLAGS="$CFLAGS $BITLBEE_CFLAGS" LDFLAGS="$LDFLAGS $BITLBEE_LIBS" prefix=`$PKG_CONFIG --variable=prefix bitlbee` + +dnl Check for Skype4Py +AC_MSG_CHECKING(for Python module Skype4Py) +python -c "import Skype4Py" +if test "$?" != "0"; then + AC_MSG_RESULT(no) + SKYPE4PY="no" +else + AC_MSG_RESULT(yes) + SKYPE4PY="yes" +fi +AC_SUBST(SKYPE4PY) + AC_OUTPUT(config.mak) AC_OUTPUT(skyped.conf.dist) @@ -40,6 +53,7 @@ echo " linker flags: $LDFLAGS shared object flags: $SHARED_FLAGS shared object extension: $SHARED_EXT + skyped: $SKYPE4PY install program: $INSTALL prefix: $prefix sysconfig dir: $sysconfdir/skyped -- cgit v1.2.3 From ef399c287aa73adc0c9bbd587127b1fafd071179 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 5 Sep 2008 21:54:45 +0200 Subject: configure: put the nasty error message in config.log where it belongs --- skype/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/configure.ac b/skype/configure.ac index a168d5ac..ff28e5eb 100644 --- a/skype/configure.ac +++ b/skype/configure.ac @@ -35,7 +35,7 @@ prefix=`$PKG_CONFIG --variable=prefix bitlbee` dnl Check for Skype4Py AC_MSG_CHECKING(for Python module Skype4Py) -python -c "import Skype4Py" +python -c "import Skype4Py" 2>&AS_MESSAGE_LOG_FD if test "$?" != "0"; then AC_MSG_RESULT(no) SKYPE4PY="no" -- cgit v1.2.3 From 752a591bea8d2d3b4e9529a8220f46e54389cc0c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 5 Sep 2008 21:54:45 +0200 Subject: make bitlbee dependency optional as well this way it's possible to build bitlbee-skype on a client where only skyped will be running, so messing with the plugin makes no sense --- skype/Makefile | 5 ++++- skype/config.mak.in | 1 + skype/configure.ac | 48 +++++++++++++++++++++++++++++++++++++----------- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index fd298f20..3a23c488 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -7,11 +7,15 @@ BITLBEE_VERSION = 1.2.2 AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') skype.$(SHARED_EXT): skype.c config.mak +ifeq ($(BITLBEE),yes) $(CC) $(CFLAGS) $(SHARED_FLAGS) -o skype.$(SHARED_EXT) skype.c $(LDFLAGS) +endif install: skype.$(SHARED_EXT) skyped.py +ifeq ($(BITLBEE),yes) $(INSTALL) -d $(DESTDIR)$(plugindir) $(INSTALL) skype.$(SHARED_EXT) $(DESTDIR)$(plugindir) +endif ifeq ($(SKYPED),yes) $(INSTALL) -d $(DESTDIR)$(bindir) $(INSTALL) -d $(DESTDIR)$(sysconfdir) @@ -26,7 +30,6 @@ client: client.c autogen: configure.ac cp /usr/share/automake-$(AMVERSION)/install-sh ./ - cp /usr/share/aclocal/pkg.m4 aclocal.m4 autoconf clean: diff --git a/skype/config.mak.in b/skype/config.mak.in index e133ed87..443343c5 100644 --- a/skype/config.mak.in +++ b/skype/config.mak.in @@ -3,6 +3,7 @@ LDFLAGS = @LDFLAGS@ SHARED_FLAGS = @SHARED_FLAGS@ SHARED_EXT = @SHARED_EXT@ SKYPE4PY = @SKYPE4PY@ +BITLBEE = @BITLBEE@ INSTALL = @INSTALL@ prefix = @prefix@ sysconfdir = @sysconfdir@/skyped diff --git a/skype/configure.ac b/skype/configure.ac index ff28e5eb..8aa5d688 100644 --- a/skype/configure.ac +++ b/skype/configure.ac @@ -28,10 +28,27 @@ AC_SUBST(SHARED_FLAGS) AC_SUBST(SHARED_EXT) dnl Check for bitlbee -PKG_CHECK_MODULES(BITLBEE, bitlbee) -CFLAGS="$CFLAGS $BITLBEE_CFLAGS" -LDFLAGS="$LDFLAGS $BITLBEE_LIBS" -prefix=`$PKG_CONFIG --variable=prefix bitlbee` +AC_MSG_CHECKING(for BitlBee) +pkg-config --exists bitlbee +if test "$?" != "0"; then + AC_MSG_RESULT(no) + BITLBEE="no" +else + AC_MSG_RESULT(yes) + BITLBEE="yes" + if test -z "$CFLAGS"; then + CFLAGS="`pkg-config --cflags bitlbee`" + else + CFLAGS="$CFLAGS `pkg-config --cflags bitlbee`" + fi + if test -z "$LDFLAGS"; then + LDFLAGS="`pkg-config --libs bitlbee`" + else + LDFLAGS="$LDFLAGS `pkg-config --libs bitlbee`" + fi + prefix=`pkg-config --variable=prefix bitlbee` +fi +AC_SUBST(BITLBEE) dnl Check for Skype4Py AC_MSG_CHECKING(for Python module Skype4Py) @@ -45,16 +62,25 @@ else fi AC_SUBST(SKYPE4PY) +if test "$BITLBEE" = "no" -a "$SKYPE4PY" = "no"; then + AC_ERROR([In order to use bitlbee-skype you need at least BitlBee or Skype4Py installed.]) +fi + AC_OUTPUT(config.mak) AC_OUTPUT(skyped.conf.dist) echo " - compiler flags: $CFLAGS - linker flags: $LDFLAGS - shared object flags: $SHARED_FLAGS - shared object extension: $SHARED_EXT + BitlBee plugin: $BITLBEE skyped: $SKYPE4PY - install program: $INSTALL prefix: $prefix - sysconfig dir: $sysconfdir/skyped -" + install program: $INSTALL" +if test "$BITLBEE" = "yes"; then + echo " compiler flags: $CFLAGS + linker flags: $LDFLAGS + shared object flags: $SHARED_FLAGS + shared object extension: $SHARED_EXT" +fi +if test "$SKYPE4PY" = "yes"; then + echo " sysconfig dir: $sysconfdir/skyped" +fi +echo -- cgit v1.2.3 From b414e30b7dbc3d5d0f8a5daea6242a681cc30f56 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 5 Sep 2008 21:54:46 +0200 Subject: fix skyped-only install --- skype/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 3a23c488..1755c588 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -16,7 +16,7 @@ ifeq ($(BITLBEE),yes) $(INSTALL) -d $(DESTDIR)$(plugindir) $(INSTALL) skype.$(SHARED_EXT) $(DESTDIR)$(plugindir) endif -ifeq ($(SKYPED),yes) +ifeq ($(SKYPE4PY),yes) $(INSTALL) -d $(DESTDIR)$(bindir) $(INSTALL) -d $(DESTDIR)$(sysconfdir) $(INSTALL) skyped.py $(DESTDIR)$(bindir)/skyped -- cgit v1.2.3 From 56d88baeb271f851441ef8e23647f22a030c8ede Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 5 Sep 2008 21:54:46 +0200 Subject: docu update and remove todo item --- skype/README | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/skype/README b/skype/README index 23a1b0e9..2583cc79 100644 --- a/skype/README +++ b/skype/README @@ -82,7 +82,12 @@ and you have to install `bitlbee-skype` and `skype4py` from source. === Installing from source -- You need the latest stable BitlBee release: +NOTE: bitlbee-skype by default builds and installs skyped and the +plugin. In case you just want to install the plugin for a public server +or you want to use skyped with a public server, you don't need both. + +- You need the latest stable BitlBee release (unless you want to use a + public server): ---- $ wget http://get.bitlbee.org/src/bitlbee-@BITLBEE_VERSION@.tar.gz @@ -98,6 +103,15 @@ $ make # make install install-dev ---- +- To install http://skype4py.sourceforge.net/[Skype4Py] from source + (unless you want to install the plugin for a public server): + +---- +$ tar -zxvf Skype4Py-x.x.x.x.tar.gz +$ cd Skype4Py-x.x.x.x +# python setup.py install +---- + - Get the plugin code (in an empty dir, or whereever you want, it does not matter): @@ -118,14 +132,6 @@ $ make This will install the plugin to where BitlBee expects them, which is `/usr/local/lib/bitlbee` if you installed BitlBee from source. -- To install http://skype4py.sourceforge.net/[Skype4Py] from source: - ----- -$ tar -zxvf Skype4Py-x.x.x.x.tar.gz -$ cd Skype4Py-x.x.x.x -# python setup.py install ----- - === Configuring - Edit `/usr/local/etc/skyped/skyped.conf`: adjust `username` and `password`. The @@ -314,10 +320,6 @@ $ skyped -n -d request], this is because it is still not possible (under Linux) to `join_chat` to a public chat.. -- Add `--disable-skyped` and `--disable-plugin` switches in case one wants to - build `bitlbee-skype` only for a public server or only for use with a public - server. - == I would like to have support for ... If something does not work and it's not in the TODO section, then please -- cgit v1.2.3 From 038fa18b1c391d0aef97a80be8844fff10cde189 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 5 Sep 2008 21:54:46 +0200 Subject: updates for 0.6.1 --- skype/Makefile | 2 +- skype/NEWS | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 1755c588..49784b9c 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.6.0 +VERSION = 0.6.1 # oldest supported one BITLBEE_VERSION = 1.2.2 diff --git a/skype/NEWS b/skype/NEWS index 8c0d0b80..bd15b8ce 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,11 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.6.1 - added keepalive traffic to avoid disconnects in bitlbee + when there is no traffic for a long time + - now the plugin or skyped is automatically disabled if + the dependencies are not available; useful in case the + plugin is to be installed on a public server, or the + skyped is to be used with a public server only 0.6.0 - works with BitlBee 1.2.1 0.5.1 - configure now automatically detects the right prefix to match witl BitlBee's one -- cgit v1.2.3 From 93f4dacd9a92d47a618dee182b485298819eb364 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 5 Sep 2008 22:03:45 +0200 Subject: install: no longer depend on the plugin if its disabled --- skype/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 49784b9c..73f073ab 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -6,12 +6,18 @@ BITLBEE_VERSION = 1.2.2 AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') +ifeq ($(BITLBEE),yes) +all: skype.$(SHARED_EXT) +else +all: +endif + skype.$(SHARED_EXT): skype.c config.mak ifeq ($(BITLBEE),yes) $(CC) $(CFLAGS) $(SHARED_FLAGS) -o skype.$(SHARED_EXT) skype.c $(LDFLAGS) endif -install: skype.$(SHARED_EXT) skyped.py +install: all ifeq ($(BITLBEE),yes) $(INSTALL) -d $(DESTDIR)$(plugindir) $(INSTALL) skype.$(SHARED_EXT) $(DESTDIR)$(plugindir) -- cgit v1.2.3 From 0ec644d9eb69cf395582104b0072f005a54402b7 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 5 Sep 2008 22:04:45 +0200 Subject: updates for 0.6.2 --- skype/Makefile | 2 +- skype/NEWS | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 73f073ab..28f2ddbd 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.6.1 +VERSION = 0.6.2 # oldest supported one BITLBEE_VERSION = 1.2.2 diff --git a/skype/NEWS b/skype/NEWS index bd15b8ce..15d425ac 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,7 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.6.2 - bugfix: make install required the plugin even in case + its build was disabled 0.6.1 - added keepalive traffic to avoid disconnects in bitlbee when there is no traffic for a long time - now the plugin or skyped is automatically disabled if -- cgit v1.2.3 From 12e1162ec61e614109266884d45bd82f9fdfc90a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 6 Sep 2008 03:35:25 +0200 Subject: use perl instead of sed to avoid portability issues on osx --- skype/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index 28f2ddbd..61f8519c 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -26,9 +26,9 @@ ifeq ($(SKYPE4PY),yes) $(INSTALL) -d $(DESTDIR)$(bindir) $(INSTALL) -d $(DESTDIR)$(sysconfdir) $(INSTALL) skyped.py $(DESTDIR)$(bindir)/skyped - sed -i 's|/usr/local/etc/skyped|$(sysconfdir)|' $(DESTDIR)$(bindir)/skyped + perl -p -i -e 's|/usr/local/etc/skyped|$(sysconfdir)|' $(DESTDIR)$(bindir)/skyped $(INSTALL) -m644 skyped.conf.dist $(DESTDIR)$(sysconfdir)/skyped.conf - sed -i 's|$${prefix}|$(prefix)|' $(DESTDIR)$(sysconfdir)/skyped.conf + perl -p -i -e 's|\$${prefix}|$(prefix)|' $(DESTDIR)$(sysconfdir)/skyped.conf $(INSTALL) -m644 skyped.cnf $(DESTDIR)$(sysconfdir) endif -- cgit v1.2.3 From 58f42365e39a5420726b0d49283b0c8a0615c38a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 6 Sep 2008 03:42:49 +0200 Subject: update gitignore for osx --- skype/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/skype/.gitignore b/skype/.gitignore index 0654b4e2..e90a033b 100644 --- a/skype/.gitignore +++ b/skype/.gitignore @@ -16,3 +16,4 @@ install-sh skype.so skyped.conf skyped.conf.dist +skype.dylib* -- cgit v1.2.3 From 2a8d790c279612dad2f3a0f6ad3732a1cce1a72e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 6 Sep 2008 03:57:22 +0200 Subject: add python-gnutls install instructions --- skype/README | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index 2583cc79..a9ed19d8 100644 --- a/skype/README +++ b/skype/README @@ -75,7 +75,7 @@ and you don't have to compile anything manually. - Install the necessary development package: ---- -# apt-get install bitlbee-dev +# apt-get install bitlbee-dev python-gnutls ---- and you have to install `bitlbee-skype` and `skype4py` from source. @@ -112,6 +112,15 @@ $ cd Skype4Py-x.x.x.x # python setup.py install ---- +- To install http://pypi.python.org/pypi/python-gnutls[python-gnutls] from source + (unless you want to install the plugin for a public server): + +---- +$ tar -zxvf python-gnutls-x.x.x.tar.gz +$ cd python-gnutls-x.x.x +# python setup.py install +---- + - Get the plugin code (in an empty dir, or whereever you want, it does not matter): -- cgit v1.2.3 From 720ae585474d544a25598c6d92f9e9184fec80b2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 6 Sep 2008 04:07:05 +0200 Subject: initial osx instructions --- skype/README | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/skype/README b/skype/README index a9ed19d8..d694e011 100644 --- a/skype/README +++ b/skype/README @@ -80,6 +80,21 @@ and you don't have to compile anything manually. and you have to install `bitlbee-skype` and `skype4py` from source. +=== Installing under OS X + +- Install the necessary packages from ports: + +NOTE: You have to edit the Portfile manually to include the install-dev target, +just append install-dev after install-etc. + +---- +# port -v install bitlbee +# port -v install py25-gobject +---- + +and you have to install `bitlbee-skype`, `skype4py` and `python-gnutls` from +source. + === Installing from source NOTE: bitlbee-skype by default builds and installs skyped and the @@ -121,6 +136,14 @@ $ cd python-gnutls-x.x.x # python setup.py install ---- +NOTE: On OS X you will need the following hacks first: + +---- +$ export LD_LIBRARY_PATH=/opt/local/lib +$ export CFLAGS="-I/opt/local/include" +$ export LDFLAGS="-L/opt/local/lib" +---- + - Get the plugin code (in an empty dir, or whereever you want, it does not matter): -- cgit v1.2.3 From 74159899faae3dd0a01e7d139bda0b6766d466fd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 6 Sep 2008 04:59:03 +0200 Subject: ignore error if not yet started skyped fails to shut down at this points skyped runs fine for me on osx (plugin is not yet tested) --- skype/skyped.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index dbbd2e53..c2773a97 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -41,7 +41,11 @@ def eh(type, value, tb): if type != KeyboardInterrupt: print_exception(type, value, tb) gobject.MainLoop().quit() - skype.skype.Client.Shutdown() + # shut down client if it's running + try: + skype.skype.Client.Shutdown() + except NameError: + pass sys.exit("Exiting.") sys.excepthook = eh -- cgit v1.2.3 From 89949c7b1ff9eeeced6561a507370dd92931ff19 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 6 Sep 2008 16:58:34 +0200 Subject: clean up osx shared_flags --- skype/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/configure.ac b/skype/configure.ac index 8aa5d688..29856fb4 100644 --- a/skype/configure.ac +++ b/skype/configure.ac @@ -17,7 +17,7 @@ case "`$CC -dumpmachine`" in SHARED_EXT="so" ;; *apple-darwin*) - SHARED_FLAGS="-dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup" + SHARED_FLAGS="-dynamiclib -undefined dynamic_lookup" SHARED_EXT="dylib" ;; *) -- cgit v1.2.3 From 85ebf71a809eb9abdfae779bda89c88f6f0f319f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 8 Sep 2008 00:09:28 +0200 Subject: add/usr/local/lib/pkgconfig to PKG_CONFIG_PATH automatically if it makes sense --- skype/configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skype/configure.ac b/skype/configure.ac index 29856fb4..95441c80 100644 --- a/skype/configure.ac +++ b/skype/configure.ac @@ -29,6 +29,10 @@ AC_SUBST(SHARED_EXT) dnl Check for bitlbee AC_MSG_CHECKING(for BitlBee) +if test -d /usr/local/lib/pkgconfig; then + PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig + export PKG_CONFIG_PATH +fi pkg-config --exists bitlbee if test "$?" != "0"; then AC_MSG_RESULT(no) -- cgit v1.2.3 From cc5f8acf5e88f9f207170172a22468847ff95f30 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 8 Sep 2008 00:14:51 +0200 Subject: add a sample public server which has skype support --- skype/README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index d694e011..1a46b2ef 100644 --- a/skype/README +++ b/skype/README @@ -99,7 +99,8 @@ source. NOTE: bitlbee-skype by default builds and installs skyped and the plugin. In case you just want to install the plugin for a public server -or you want to use skyped with a public server, you don't need both. +or you want to use skyped with a public server (like +`bitlbee1.asnetinc.net`), you don't need both. - You need the latest stable BitlBee release (unless you want to use a public server): -- cgit v1.2.3 From 885e563e68673e4c2daee2861766fc8913120158 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 8 Sep 2008 03:10:00 +0200 Subject: skyped: when sending, encode using utf8 if we can't get the system default this fixes a runtime error on osx --- skype/skyped.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index c2773a97..f61583f3 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -177,7 +177,10 @@ class SkypeApi: def send(self, msg_text): if not len(msg_text) or msg_text == "PONG": return - e = msg_text.decode(locale.getdefaultlocale()[1]) + try: + e = msg_text.decode(locale.getdefaultlocale()[1]) + except ValueError: + e = msg_text.decode('UTF-8') dprint('>> ' + e) try: c = self.skype.Command(e, Block=True) -- cgit v1.2.3 From 68c162b44f12aefb11a4c1074ad7366ead1b9846 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 8 Sep 2008 09:31:48 +0200 Subject: updates for 0.6.3 --- skype/Makefile | 6 +++--- skype/NEWS | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index 61f8519c..d7b4b417 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,8 +1,8 @@ -include config.mak -VERSION = 0.6.2 -# oldest supported one -BITLBEE_VERSION = 1.2.2 +VERSION = 0.6.3 +# latest stable +BITLBEE_VERSION = 1.2.3 AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') diff --git a/skype/NEWS b/skype/NEWS index 15d425ac..b885bd66 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,9 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.6.3 - various osx-specific improvements (see the new screenshot!) + - added python-gnutls install instructions + - bitlbee.pc is now searched under + /usr/local/lib/pkgconfig by default to help LFS monkeys ;) 0.6.2 - bugfix: make install required the plugin even in case its build was disabled 0.6.1 - added keepalive traffic to avoid disconnects in bitlbee -- cgit v1.2.3 From c49820d52fc3e1f2b744a7b513fdf4cafa53bf29 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 24 Sep 2008 11:03:55 +0200 Subject: add yasrd to todo --- skype/README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/skype/README b/skype/README index d694e011..7eb48595 100644 --- a/skype/README +++ b/skype/README @@ -352,6 +352,9 @@ $ skyped -n -d request], this is because it is still not possible (under Linux) to `join_chat` to a public chat.. +- Add yasrd (Yet Another Skype-Related Daemon) to allow using a public + server for users who are behind NAT. + == I would like to have support for ... If something does not work and it's not in the TODO section, then please -- cgit v1.2.3 From 7199b745fc49ae5a08bdb880b7631f99191e2c6b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 7 Nov 2008 15:06:28 +0100 Subject: finally a new skype4py 1.x is out which works for me as well --- skype/README | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/skype/README b/skype/README index 65b2808a..ee90ca3a 100644 --- a/skype/README +++ b/skype/README @@ -34,9 +34,7 @@ not..) * BitlBee >= @BITLBEE_VERSION@. Use old versions (0.5.1 or earlier) if you have older BitlBee installed. * Skype4Py >= 0.9.28.7. Previous versions won't work due to API changes. - -NOTE: 1.x just does not work for me. I mailed the author but did not -receive any answer so far. + The latest version I've tested is 1.0.31.0. * Python >= 2.5. Skype4Py does not work with 2.4. * PyGObject >= 2.8.0. Older versions are part of PyGTK. (And you don't want to -- cgit v1.2.3 From c1bf7c5f9041f99934d1932fdd62457b88d4ac36 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 12 Nov 2008 18:47:46 +0100 Subject: handle the case in make autogen when automake is not under /usr/share --- skype/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index d7b4b417..46963651 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -4,7 +4,7 @@ VERSION = 0.6.3 # latest stable BITLBEE_VERSION = 1.2.3 -AMVERSION = $(shell automake --version|sed 's/.* //;s/\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/;q') +AMPATH = $(shell grep automake- $(shell which automake)|sed "s|.*'\(.*\)';|\1|") ifeq ($(BITLBEE),yes) all: skype.$(SHARED_EXT) @@ -35,7 +35,7 @@ endif client: client.c autogen: configure.ac - cp /usr/share/automake-$(AMVERSION)/install-sh ./ + cp $(AMPATH)/install-sh ./ autoconf clean: -- cgit v1.2.3 From 6b9cab1b2a6e9fa743ff3528090bb3a00ce14f71 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Nov 2008 02:16:54 +0100 Subject: skyped: handle the case when even reading the user/pass fails ideally this is rare, i never got a network error right after connect, but you can never be sure.. ;) --- skype/skyped.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index f61583f3..56cdc498 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -117,12 +117,17 @@ def listener(sock, *args): dprint("Warning, handshake failed, closing connection.") return False ret = 0 - line = options.conn.recv(1024) - if line.startswith("USERNAME") and line.split(' ')[1].strip() == options.config.username: - ret += 1 - line = options.conn.recv(1024) - if line.startswith("PASSWORD") and sha.sha(line.split(' ')[1].strip()).hexdigest() == options.config.password: - ret += 1 + try: + line = options.conn.recv(1024) + if line.startswith("USERNAME") and line.split(' ')[1].strip() == options.config.username: + ret += 1 + line = options.conn.recv(1024) + if line.startswith("PASSWORD") and sha.sha(line.split(' ')[1].strip()).hexdigest() == options.config.password: + ret += 1 + except Exception, s: + dprint("Warning, receiving 1024 bytes failed (%s)." % s) + options.conn.close() + return False if ret == 2: dprint("Username and password OK.") options.conn.send("PASSWORD OK\n") -- cgit v1.2.3 From 56ae398cc2d137b669a6ef13f4a5969a9d92b70f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 21 Dec 2008 19:35:24 +0100 Subject: replace /dev/null with os.devnull in skyped --- skype/skyped.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 56cdc498..7161010f 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -279,8 +279,8 @@ if __name__=='__main__': if options.daemon: pid = os.fork() if pid == 0: - nullin = file('/dev/null', 'r') - nullout = file('/dev/null', 'w') + nullin = file(os.devnull, 'r') + nullout = file(os.devnull, 'w') os.dup2(nullin.fileno(), sys.stdin.fileno()) os.dup2(nullout.fileno(), sys.stdout.fileno()) os.dup2(nullout.fileno(), sys.stderr.fileno()) -- cgit v1.2.3 From 7258d34ab4d1b1f55c3b52944a0b5264111ad3a2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 21 Dec 2008 20:19:34 +0100 Subject: replace client.py with client.sh which provides more interactivity --- skype/client.py | 7 ------- skype/client.sh | 1 + 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 skype/client.py create mode 100644 skype/client.sh diff --git a/skype/client.py b/skype/client.py deleted file mode 100644 index 62686c22..00000000 --- a/skype/client.py +++ /dev/null @@ -1,7 +0,0 @@ -import socket, sys - -client = socket.socket ( socket.AF_INET, socket.SOCK_STREAM ) -client.connect ( ( 'localhost', 2727 ) ) - -client.send(sys.argv[1]) -print client.recv(1024) diff --git a/skype/client.sh b/skype/client.sh new file mode 100644 index 00000000..7d7689a8 --- /dev/null +++ b/skype/client.sh @@ -0,0 +1 @@ +openssl s_client -host localhost -port 2727 -verify 0 -- cgit v1.2.3 From 08a355bc2c95bee6ce53b3d6052ccb63684df8a8 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 21 Dec 2008 20:37:59 +0100 Subject: add 'skypeconsole' feature this replaces the old client.py --- skype/README | 8 ++++++++ skype/skype.c | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index ee90ca3a..bf1bda66 100644 --- a/skype/README +++ b/skype/README @@ -342,6 +342,14 @@ $ skyped -n -d * `account set skype/balance query` +- For debug purposes, it's possible to send any command to `skyped`. To + achieve this, you need to: + + * `account set skype/skypeconsole true` + + * then writing `skypeconsole: ` will work in the control + channel. + == What needs to be done (aka. TODO) - Notice if foo invites bar. Currently you can see only that bar joined. diff --git a/skype/skype.c b/skype/skype.c index 470c1035..29d53e39 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -958,6 +958,9 @@ static void skype_login( account_t *acc ) sd->username = g_strdup( acc->user ); sd->ic = ic; + + if (set_getbool(&acc->set, "skypeconsole")) + imcb_add_buddy(ic, "skypeconsole", NULL); } static void skype_logout( struct im_connection *ic ) @@ -985,7 +988,10 @@ static int skype_buddy_msg( struct im_connection *ic, char *who, char *message, if(ptr) *ptr = '\0'; - buf = g_strdup_printf("MESSAGE %s %s\n", nick, message); + if (!strncmp(who, "skypeconsole", 12)) + buf = g_strdup_printf("%s\n", message); + else + buf = g_strdup_printf("MESSAGE %s %s\n", nick, message); g_free(nick); st = skype_write( ic, buf, strlen( buf ) ); g_free(buf); @@ -1264,6 +1270,9 @@ static void skype_init( account_t *acc ) s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; s = set_add( &acc->set, "skypeout_offline", "true", set_eval_bool, acc ); + + s = set_add( &acc->set, "skypeconsole", "false", set_eval_bool, acc ); + s->flags |= ACC_SET_OFFLINE_ONLY; } void init_plugin(void) -- cgit v1.2.3 From 5acf9ab725181e59f475f17d4647b700b36015cd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 21 Dec 2008 21:00:30 +0100 Subject: support autojoin for bookmarked chats --- skype/README | 5 +++++ skype/skype.c | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/skype/README b/skype/README index bf1bda66..6e1cd195 100644 --- a/skype/README +++ b/skype/README @@ -350,6 +350,11 @@ $ skyped -n -d * then writing `skypeconsole: ` will work in the control channel. +- If you want to automatically join bookmarked groupchats right after + you logged in, do: + + * `account set skype/auto_join true` + == What needs to be done (aka. TODO) - Notice if foo invites bar. Currently you can see only that bar joined. diff --git a/skype/skype.c b/skype/skype.c index 29d53e39..86ae3af8 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -884,6 +884,22 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c g_snprintf(buf, 1024, "PONG\n"); skype_write(ic, buf, strlen(buf)); } + else if(!strncmp(line, "CHATS ", 6)) + { + char **i; + char **chats = g_strsplit(line + 6, ", ", 0); + + i = chats; + while (*i) + { + g_snprintf(buf, 1024, "GET CHAT %s STATUS\n", *i); + skype_write( ic, buf, strlen( buf ) ); + g_snprintf(buf, 1024, "GET CHAT %s ACTIVEMEMBERS\n", *i); + skype_write( ic, buf, strlen( buf ) ); + i++; + } + g_strfreev(chats); + } lineptr++; } g_strfreev(lines); @@ -927,6 +943,13 @@ gboolean skype_start_stream( struct im_connection *ic ) buf = g_strdup_printf("SET USERSTATUS ONLINE\n"); skype_write( ic, buf, strlen( buf ) ); g_free(buf); + + /* Auto join to bookmarked chats if requested.*/ + if (set_getbool(&ic->acc->set, "auto_join")) { + buf = g_strdup_printf("SEARCH BOOKMARKEDCHATS\n"); + skype_write( ic, buf, strlen( buf ) ); + g_free(buf); + } return st; } @@ -1273,6 +1296,9 @@ static void skype_init( account_t *acc ) s = set_add( &acc->set, "skypeconsole", "false", set_eval_bool, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; + + s = set_add( &acc->set, "auto_join", "false", set_eval_bool, acc ); + s->flags |= ACC_SET_OFFLINE_ONLY; } void init_plugin(void) -- cgit v1.2.3 From a2ed574e86a997a9e245eb821add1ee786629921 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 21 Dec 2008 21:02:54 +0100 Subject: update NEWS --- skype/NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skype/NEWS b/skype/NEWS index b885bd66..7c631af9 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,9 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- + - made 'make config' more portable + - add 'skypeconsole' buddy for debugging purposes + - support autojoin for bookmarked groupchats + - make hardwired '/dev/null' in skyped portable 0.6.3 - various osx-specific improvements (see the new screenshot!) - added python-gnutls install instructions - bitlbee.pc is now searched under -- cgit v1.2.3 From a5f4040ca3d4d70c593875cfedb3c1f6a249ace4 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 21 Dec 2008 21:08:44 +0100 Subject: remove the 'len' parameter of skype_write() --- skype/skype.c | 119 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 60 insertions(+), 59 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 86ae3af8..893cec48 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -146,10 +146,11 @@ const struct skype_away_state skype_away_state_list[] = * Functions */ -int skype_write( struct im_connection *ic, char *buf, int len ) +int skype_write( struct im_connection *ic, char *buf ) { struct skype_data *sd = ic->proto_data; struct pollfd pfd[1]; + int len = strlen(buf); pfd[0].fd = sd->fd; pfd[0].events = POLLOUT; @@ -171,7 +172,7 @@ static void skype_buddy_ask_yes( void *data ) { struct skype_buddy_ask_data *bla = data; char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED TRUE", bla->handle); - skype_write( bla->ic, buf, strlen( buf ) ); + skype_write( bla->ic, buf ); g_free(buf); g_free(bla->handle); g_free(bla); @@ -181,7 +182,7 @@ static void skype_buddy_ask_no( void *data ) { struct skype_buddy_ask_data *bla = data; char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED FALSE", bla->handle); - skype_write( bla->ic, buf, strlen( buf ) ); + skype_write( bla->ic, buf ); g_free(buf); g_free(bla->handle); g_free(bla); @@ -204,7 +205,7 @@ static void skype_call_ask_yes( void *data ) { struct skype_buddy_ask_data *bla = data; char *buf = g_strdup_printf("SET CALL %s STATUS INPROGRESS", bla->handle); - skype_write( bla->ic, buf, strlen( buf ) ); + skype_write( bla->ic, buf ); g_free(buf); g_free(bla->handle); g_free(bla); @@ -214,7 +215,7 @@ static void skype_call_ask_no( void *data ) { struct skype_buddy_ask_data *bla = data; char *buf = g_strdup_printf("SET CALL %s STATUS FINISHED", bla->handle); - skype_write( bla->ic, buf, strlen( buf ) ); + skype_write( bla->ic, buf ); g_free(buf); g_free(bla->handle); g_free(bla); @@ -306,7 +307,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c while(*i) { g_snprintf(buf, 1024, "GET USER %s ONLINESTATUS\n", *i); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); i++; } g_strfreev(nicks); @@ -539,13 +540,13 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c * (4) Query chatname */ g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_snprintf(buf, 1024, "GET CHATMESSAGE %s TYPE\n", id); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_snprintf(buf, 1024, "GET CHATMESSAGE %s CHATNAME\n", id); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); } else if(!strncmp(info, "FROM_HANDLE ", 12)) { @@ -639,31 +640,31 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c g_free(sd->call_id); sd->call_id = g_strdup(id); g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); sd->call_status = SKYPE_CALL_RINGING; } else if(!strcmp(info, "STATUS MISSED")) { g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); sd->call_status = SKYPE_CALL_MISSED; } else if(!strcmp(info, "STATUS CANCELLED")) { g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); sd->call_status = SKYPE_CALL_CANCELLED; } else if(!strcmp(info, "STATUS FINISHED")) { g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); sd->call_status = SKYPE_CALL_FINISHED; } else if(!strcmp(info, "STATUS REFUSED")) { g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); sd->call_status = SKYPE_CALL_REFUSED; } else if(!strcmp(info, "STATUS UNPLACED")) @@ -742,13 +743,13 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c if(!strcmp(info, "STATUS NEW")) { g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); sd->filetransfer_status = SKYPE_FILETRANSFER_NEW; } else if(!strcmp(info, "STATUS FAILED")) { g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED; } else if(!strncmp(info, "PARTNER_HANDLE ", 15)) @@ -786,9 +787,9 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { imcb_chat_new( ic, id ); g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); } else if(!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) { @@ -800,16 +801,16 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c * window on our client, so * just leave it out. */ /*g_snprintf(buf, 1024, "OPEN CHAT %s\n", id); - skype_write(ic, buf, strlen(buf));*/ + skype_write(ic, buf);*/ g_snprintf(buf, 1024, "%s@skype.com", sd->groupchat_with); imcb_chat_add_buddy(gc, buf); imcb_chat_add_buddy(gc, sd->username); g_free(sd->groupchat_with); sd->groupchat_with = NULL; g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); } else if(!strcmp(info, "STATUS UNSUBSCRIBED")) { @@ -882,7 +883,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c else if(!strncmp(line, "PING", 4)) { g_snprintf(buf, 1024, "PONG\n"); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); } else if(!strncmp(line, "CHATS ", 6)) { @@ -893,9 +894,9 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c while (*i) { g_snprintf(buf, 1024, "GET CHAT %s STATUS\n", *i); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_snprintf(buf, 1024, "GET CHAT %s ACTIVEMEMBERS\n", *i); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); i++; } g_strfreev(chats); @@ -930,24 +931,24 @@ gboolean skype_start_stream( struct im_connection *ic ) /* Log in */ buf = g_strdup_printf("USERNAME %s\n", ic->acc->user); - st = skype_write( ic, buf, strlen( buf ) ); + st = skype_write( ic, buf ); g_free(buf); buf = g_strdup_printf("PASSWORD %s\n", ic->acc->pass); - st = skype_write( ic, buf, strlen( buf ) ); + st = skype_write( ic, buf ); g_free(buf); /* This will download all buddies. */ buf = g_strdup_printf("SEARCH FRIENDS\n"); - st = skype_write( ic, buf, strlen( buf ) ); + st = skype_write( ic, buf ); g_free(buf); buf = g_strdup_printf("SET USERSTATUS ONLINE\n"); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(buf); /* Auto join to bookmarked chats if requested.*/ if (set_getbool(&ic->acc->set, "auto_join")) { buf = g_strdup_printf("SEARCH BOOKMARKEDCHATS\n"); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(buf); } return st; @@ -992,7 +993,7 @@ static void skype_logout( struct im_connection *ic ) char *buf; buf = g_strdup_printf("SET USERSTATUS OFFLINE\n"); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(buf); g_free(sd->username); @@ -1016,7 +1017,7 @@ static int skype_buddy_msg( struct im_connection *ic, char *who, char *message, else buf = g_strdup_printf("MESSAGE %s %s\n", nick, message); g_free(nick); - st = skype_write( ic, buf, strlen( buf ) ); + st = skype_write( ic, buf ); g_free(buf); return st; @@ -1043,7 +1044,7 @@ static void skype_set_away( struct im_connection *ic, char *state_txt, char *mes else state = skype_away_state_by_name( state_txt ); buf = g_strdup_printf("SET USERSTATUS %s\n", state->code); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(buf); } @@ -1066,7 +1067,7 @@ static char *skype_set_display_name( set_t *set, char *value ) char *buf; buf = g_strdup_printf("SET PROFILE FULLNAME %s", value); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(buf); return(value); } @@ -1078,7 +1079,7 @@ static char *skype_set_balance( set_t *set, char *value ) char *buf; buf = g_strdup_printf("GET PROFILE PSTN_BALANCE"); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(buf); return(value); } @@ -1103,7 +1104,7 @@ static char *skype_set_call( set_t *set, char *value ) *ptr = '\0'; buf = g_strdup_printf("CALL %s", nick); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(buf); g_free(nick); } @@ -1113,7 +1114,7 @@ static char *skype_set_call( set_t *set, char *value ) if(sd->call_id) { buf = g_strdup_printf("SET CALL %s STATUS FINISHED", sd->call_id); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(buf); g_free(sd->call_id); sd->call_id = NULL; @@ -1135,7 +1136,7 @@ static void skype_add_buddy( struct im_connection *ic, char *who, char *group ) if(ptr) *ptr = '\0'; buf = g_strdup_printf("SET USER %s BUDDYSTATUS 2 Please authorize me\n", nick); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(nick); } @@ -1148,7 +1149,7 @@ static void skype_remove_buddy( struct im_connection *ic, char *who, char *group if(ptr) *ptr = '\0'; buf = g_strdup_printf("SET USER %s BUDDYSTATUS 1\n", nick); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(nick); } @@ -1157,7 +1158,7 @@ void skype_chat_msg( struct groupchat *gc, char *message, int flags ) struct im_connection *ic = gc->ic; char *buf; buf = g_strdup_printf("CHATMESSAGE %s %s\n", gc->title, message); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(buf); } @@ -1166,7 +1167,7 @@ void skype_chat_leave( struct groupchat *gc ) struct im_connection *ic = gc->ic; char *buf; buf = g_strdup_printf("ALTER CHAT %s LEAVE\n", gc->title); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(buf); gc->data = (void*)TRUE; } @@ -1180,7 +1181,7 @@ void skype_chat_invite(struct groupchat *gc, char *who, char *message) if(ptr) *ptr = '\0'; buf = g_strdup_printf("ALTER CHAT %s ADDMEMBERS %s\n", gc->title, nick); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(buf); g_free(nick); } @@ -1191,7 +1192,7 @@ void skype_chat_topic(struct groupchat *gc, char *message) struct skype_data *sd = ic->proto_data; char *buf; buf = g_strdup_printf("ALTER CHAT %s SETTOPIC %s\n", gc->title, message); - skype_write( ic, buf, strlen( buf ) ); + skype_write( ic, buf ); g_free(buf); sd->topic_wait = 1; } @@ -1205,7 +1206,7 @@ struct groupchat *skype_chat_with(struct im_connection *ic, char *who) if(ptr) *ptr = '\0'; buf = g_strdup_printf("CHAT CREATE %s\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); sd->groupchat_with = g_strdup(nick); g_free(nick); @@ -1222,49 +1223,49 @@ static void skype_get_info(struct im_connection *ic, char *who) if(ptr) *ptr = '\0'; buf = g_strdup_printf("GET USER %s FULLNAME\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s PHONE_HOME\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s PHONE_OFFICE\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s PHONE_MOBILE\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s NROF_AUTHED_BUDDIES\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s TIMEZONE\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s LASTONLINETIMESTAMP\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s BIRTHDAY\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s SEX\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s LANGUAGE\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s COUNTRY\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s PROVINCE\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s CITY\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s HOMEPAGE\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("GET USER %s ABOUT\n", nick); - skype_write(ic, buf, strlen(buf)); + skype_write(ic, buf); g_free(buf); } -- cgit v1.2.3 From 5adcc6514dacb4242c1cc89206f95be4f5a200db Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 21 Dec 2008 21:51:12 +0100 Subject: whitespace cleanup --- skype/skype.c | 816 ++++++++++++++++++++++++---------------------------------- 1 file changed, 340 insertions(+), 476 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 893cec48..819e185e 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -1,12 +1,12 @@ /* * skype.c - Skype plugin for BitlBee - * + * * Copyright (c) 2007, 2008 by Miklos Vajna * * Several ideas are used from the BitlBee Jabber plugin, which is * * Copyright (c) 2006 by Wilmer van der Gaast - * + * * 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 @@ -19,7 +19,7 @@ * * 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, + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ @@ -37,8 +37,7 @@ * Enumerations */ -typedef enum -{ +typedef enum { SKYPE_CALL_RINGING = 1, SKYPE_CALL_MISSED, SKYPE_CALL_CANCELLED, @@ -46,8 +45,7 @@ typedef enum SKYPE_CALL_REFUSED } skype_call_status; -typedef enum -{ +typedef enum { SKYPE_FILETRANSFER_NEW = 1, SKYPE_FILETRANSFER_FAILED } skype_filetransfer_status; @@ -56,8 +54,7 @@ typedef enum * Structures */ -struct skype_data -{ +struct skype_data { struct im_connection *ic; char *username; /* The effective file descriptor. We store it here so any function can @@ -87,9 +84,9 @@ struct skype_data skype_filetransfer_status filetransfer_status; /* Using /j #nick we want to have a groupchat with two people. Usually * not (default). */ - char* groupchat_with; + char *groupchat_with; /* The user who invited us to the chat. */ - char* adder; + char *adder; /* If we are waiting for a confirmation about we changed the topic. */ int topic_wait; /* These are used by the info command. */ @@ -113,14 +110,12 @@ struct skype_data int failurereason; }; -struct skype_away_state -{ +struct skype_away_state { char *code; char *full_name; }; -struct skype_buddy_ask_data -{ +struct skype_buddy_ask_data { struct im_connection *ic; /* This is also used for call IDs for simplicity */ char *handle; @@ -130,8 +125,7 @@ struct skype_buddy_ask_data * Tables */ -const struct skype_away_state skype_away_state_list[] = -{ +const struct skype_away_state skype_away_state_list[] = { { "ONLINE", "Online" }, { "SKYPEME", "Skype Me" }, { "AWAY", "Away" }, @@ -146,7 +140,7 @@ const struct skype_away_state skype_away_state_list[] = * Functions */ -int skype_write( struct im_connection *ic, char *buf ) +int skype_write(struct im_connection *ic, char *buf) { struct skype_data *sd = ic->proto_data; struct pollfd pfd[1]; @@ -158,124 +152,121 @@ int skype_write( struct im_connection *ic, char *buf ) /* This poll is necessary or we'll get a SIGPIPE when we write() to * sd->fd. */ poll(pfd, 1, 1000); - if(pfd[0].revents & POLLHUP) - { - imc_logout( ic, TRUE ); + if (pfd[0].revents & POLLHUP) { + imc_logout(ic, TRUE); return FALSE; } - ssl_write( sd->ssl, buf, len ); + ssl_write(sd->ssl, buf, len); return TRUE; } -static void skype_buddy_ask_yes( void *data ) +static void skype_buddy_ask_yes(void *data) { struct skype_buddy_ask_data *bla = data; char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED TRUE", bla->handle); - skype_write( bla->ic, buf ); + skype_write(bla->ic, buf); g_free(buf); g_free(bla->handle); g_free(bla); } -static void skype_buddy_ask_no( void *data ) +static void skype_buddy_ask_no(void *data) { struct skype_buddy_ask_data *bla = data; char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED FALSE", bla->handle); - skype_write( bla->ic, buf ); + skype_write(bla->ic, buf); g_free(buf); g_free(bla->handle); g_free(bla); } -void skype_buddy_ask( struct im_connection *ic, char *handle, char *message) +void skype_buddy_ask(struct im_connection *ic, char *handle, char *message) { - struct skype_buddy_ask_data *bla = g_new0( struct skype_buddy_ask_data, 1 ); + struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data, 1); char *buf; bla->ic = ic; bla->handle = g_strdup(handle); - buf = g_strdup_printf( "The user %s wants to add you to his/her buddy list, saying: '%s'.", handle, message); - imcb_ask( ic, buf, bla, skype_buddy_ask_yes, skype_buddy_ask_no ); - g_free( buf ); + buf = g_strdup_printf("The user %s wants to add you to his/her buddy list, saying: '%s'.", handle, message); + imcb_ask(ic, buf, bla, skype_buddy_ask_yes, skype_buddy_ask_no); + g_free(buf); } -static void skype_call_ask_yes( void *data ) +static void skype_call_ask_yes(void *data) { struct skype_buddy_ask_data *bla = data; char *buf = g_strdup_printf("SET CALL %s STATUS INPROGRESS", bla->handle); - skype_write( bla->ic, buf ); + skype_write(bla->ic, buf); g_free(buf); g_free(bla->handle); g_free(bla); } -static void skype_call_ask_no( void *data ) +static void skype_call_ask_no(void *data) { struct skype_buddy_ask_data *bla = data; char *buf = g_strdup_printf("SET CALL %s STATUS FINISHED", bla->handle); - skype_write( bla->ic, buf ); + skype_write(bla->ic, buf); g_free(buf); g_free(bla->handle); g_free(bla); } -void skype_call_ask( struct im_connection *ic, char *call_id, char *message) +void skype_call_ask(struct im_connection *ic, char *call_id, char *message) { - struct skype_buddy_ask_data *bla = g_new0( struct skype_buddy_ask_data, 1 ); + struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data, 1); bla->ic = ic; bla->handle = g_strdup(call_id); - imcb_ask( ic, message, bla, skype_call_ask_yes, skype_call_ask_no ); + imcb_ask(ic, message, bla, skype_call_ask_yes, skype_call_ask_no); } -struct groupchat *skype_chat_by_name( struct im_connection *ic, char *name ) +struct groupchat *skype_chat_by_name(struct im_connection *ic, char *name) { struct groupchat *ret; - for( ret = ic->groupchats; ret; ret = ret->next ) - { - if(strcmp(name, ret->title ) == 0 ) + for (ret = ic->groupchats; ret; ret = ret->next) + if (strcmp(name, ret->title) == 0) break; - } return ret; } static char *skype_call_strerror(int err) { - switch(err) { - case 1: - return "Miscellaneous error"; - case 2: - return "User or phone number does not exist."; - case 3: - return "User is offline"; - case 4: - return "No proxy found"; - case 5: - return "Session terminated."; - case 6: - return "No common codec found."; - case 7: - return "Sound I/O error."; - case 8: - return "Problem with remote sound device."; - case 9: - return "Call blocked by recipient."; - case 10: - return "Recipient not a friend."; - case 11: - return "Current user not authorized by recipient."; - case 12: - return "Sound recording error."; - default: - return "Unknown error"; + switch (err) { + case 1: + return "Miscellaneous error"; + case 2: + return "User or phone number does not exist."; + case 3: + return "User is offline"; + case 4: + return "No proxy found"; + case 5: + return "Session terminated."; + case 6: + return "No common codec found."; + case 7: + return "Sound I/O error."; + case 8: + return "Problem with remote sound device."; + case 9: + return "Call blocked by recipient."; + case 10: + return "Recipient not a friend."; + case 11: + return "Current user not authorized by recipient."; + case 12: + return "Sound recording error."; + default: + return "Unknown error"; } } -static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition cond ) +static gboolean skype_read_callback(gpointer data, gint fd, b_input_condition cond) { struct im_connection *ic = data; struct skype_data *sd = ic->proto_data; @@ -283,37 +274,31 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c int st; char **lines, **lineptr, *line, *ptr; - if( !sd || sd->fd == -1 ) + if (!sd || sd->fd == -1) return FALSE; /* Read the whole data. */ - st = ssl_read( sd->ssl, buf, sizeof( buf ) ); - if( st > 0 ) - { + st = ssl_read(sd->ssl, buf, sizeof(buf)); + if (st > 0) { buf[st] = '\0'; /* Then split it up to lines. */ lines = g_strsplit(buf, "\n", 0); lineptr = lines; - while((line = *lineptr)) - { - if(!strlen(line)) + while ((line = *lineptr)) { + if (!strlen(line)) break; - if(!strncmp(line, "USERS ", 6)) - { + if (!strncmp(line, "USERS ", 6)) { char **i; char **nicks; nicks = g_strsplit(line + 6, ", ", 0); i = nicks; - while(*i) - { + while (*i) { g_snprintf(buf, 1024, "GET USER %s ONLINESTATUS\n", *i); - skype_write( ic, buf ); + skype_write(ic, buf); i++; } g_strfreev(nicks); - } - else if(!strncmp(line, "USER ", 5)) - { + } else if (!strncmp(line, "USER ", 5)) { int flags = 0; char *status = strrchr(line, ' '); char *user = strchr(line, ' '); @@ -321,104 +306,89 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c ptr = strchr(++user, ' '); *ptr = '\0'; ptr++; - if(!strncmp(ptr, "ONLINESTATUS ", 13) && + if (!strncmp(ptr, "ONLINESTATUS ", 13) && strcmp(user, sd->username) != 0 - && strcmp(user, "echo123") != 0) - { + && strcmp(user, "echo123") != 0) { ptr = g_strdup_printf("%s@skype.com", user); imcb_add_buddy(ic, ptr, NULL); - if(strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") || !set_getbool(&ic->acc->set, "skypeout_offline"))) + if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") || !set_getbool(&ic->acc->set, "skypeout_offline"))) flags |= OPT_LOGGED_IN; - if(strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0) + if (strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0) flags |= OPT_AWAY; imcb_buddy_status(ic, ptr, flags, NULL, NULL); g_free(ptr); - } - else if(!strncmp(ptr, "RECEIVEDAUTHREQUEST ", 20)) - { + } else if (!strncmp(ptr, "RECEIVEDAUTHREQUEST ", 20)) { char *message = ptr + 20; - if(strlen(message)) + if (strlen(message)) skype_buddy_ask(ic, user, message); - } - else if(!strncmp(ptr, "BUDDYSTATUS ", 12)) - { + } else if (!strncmp(ptr, "BUDDYSTATUS ", 12)) { char *st = ptr + 12; - if(!strcmp(st, "3")) - { + if (!strcmp(st, "3")) { char *buf = g_strdup_printf("%s@skype.com", user); imcb_add_buddy(ic, buf, NULL); g_free(buf); } - } - else if(!strncmp(ptr, "FULLNAME ", 9)) + } else if (!strncmp(ptr, "FULLNAME ", 9)) sd->info_fullname = g_strdup_printf("%s", ptr + 9); - else if(!strncmp(ptr, "PHONE_HOME ", 11)) + else if (!strncmp(ptr, "PHONE_HOME ", 11)) sd->info_phonehome = g_strdup_printf("%s", ptr + 11); - else if(!strncmp(ptr, "PHONE_OFFICE ", 13)) + else if (!strncmp(ptr, "PHONE_OFFICE ", 13)) sd->info_phoneoffice = g_strdup_printf("%s", ptr + 13); - else if(!strncmp(ptr, "PHONE_MOBILE ", 13)) + else if (!strncmp(ptr, "PHONE_MOBILE ", 13)) sd->info_phonemobile = g_strdup_printf("%s", ptr + 13); - else if(!strncmp(ptr, "NROF_AUTHED_BUDDIES ", 20)) + else if (!strncmp(ptr, "NROF_AUTHED_BUDDIES ", 20)) sd->info_nrbuddies = g_strdup_printf("%s", ptr + 20); - else if(!strncmp(ptr, "TIMEZONE ", 9)) + else if (!strncmp(ptr, "TIMEZONE ", 9)) sd->info_tz = g_strdup_printf("%s", ptr + 9); - else if(!strncmp(ptr, "LASTONLINETIMESTAMP ", 20)) + else if (!strncmp(ptr, "LASTONLINETIMESTAMP ", 20)) sd->info_seen = g_strdup_printf("%s", ptr + 20); - else if(!strncmp(ptr, "BIRTHDAY ", 9)) + else if (!strncmp(ptr, "BIRTHDAY ", 9)) sd->info_birthday = g_strdup_printf("%s", ptr + 9); - else if(!strncmp(ptr, "SEX ", 4)) + else if (!strncmp(ptr, "SEX ", 4)) sd->info_sex = g_strdup_printf("%s", ptr + 4); - else if(!strncmp(ptr, "LANGUAGE ", 9)) + else if (!strncmp(ptr, "LANGUAGE ", 9)) sd->info_language = g_strdup_printf("%s", ptr + 9); - else if(!strncmp(ptr, "COUNTRY ", 8)) + else if (!strncmp(ptr, "COUNTRY ", 8)) sd->info_country = g_strdup_printf("%s", ptr + 8); - else if(!strncmp(ptr, "PROVINCE ", 9)) + else if (!strncmp(ptr, "PROVINCE ", 9)) sd->info_province = g_strdup_printf("%s", ptr + 9); - else if(!strncmp(ptr, "CITY ", 5)) + else if (!strncmp(ptr, "CITY ", 5)) sd->info_city = g_strdup_printf("%s", ptr + 5); - else if(!strncmp(ptr, "HOMEPAGE ", 9)) + else if (!strncmp(ptr, "HOMEPAGE ", 9)) sd->info_homepage = g_strdup_printf("%s", ptr + 9); - else if(!strncmp(ptr, "ABOUT ", 6)) - { + else if (!strncmp(ptr, "ABOUT ", 6)) { sd->info_about = g_strdup_printf("%s", ptr + 6); GString *st = g_string_new("Contact Information\n"); g_string_append_printf(st, "Skype Name: %s\n", user); - if(sd->info_fullname) - { - if(strlen(sd->info_fullname)) + if (sd->info_fullname) { + if (strlen(sd->info_fullname)) g_string_append_printf(st, "Full Name: %s\n", sd->info_fullname); g_free(sd->info_fullname); } - if(sd->info_phonehome) - { - if(strlen(sd->info_phonehome)) + if (sd->info_phonehome) { + if (strlen(sd->info_phonehome)) g_string_append_printf(st, "Home Phone: %s\n", sd->info_phonehome); g_free(sd->info_phonehome); } - if(sd->info_phoneoffice) - { - if(strlen(sd->info_phoneoffice)) + if (sd->info_phoneoffice) { + if (strlen(sd->info_phoneoffice)) g_string_append_printf(st, "Office Phone: %s\n", sd->info_phoneoffice); g_free(sd->info_phoneoffice); } - if(sd->info_phonemobile) - { - if(strlen(sd->info_phonemobile)) + if (sd->info_phonemobile) { + if (strlen(sd->info_phonemobile)) g_string_append_printf(st, "Mobile Phone: %s\n", sd->info_phonemobile); g_free(sd->info_phonemobile); } g_string_append_printf(st, "Personal Information\n"); - if(sd->info_nrbuddies) - { - if(strlen(sd->info_nrbuddies)) + if (sd->info_nrbuddies) { + if (strlen(sd->info_nrbuddies)) g_string_append_printf(st, "Contacts: %s\n", sd->info_nrbuddies); g_free(sd->info_nrbuddies); } - if(sd->info_tz) - { - if(strlen(sd->info_tz)) - { + if (sd->info_tz) { + if (strlen(sd->info_tz)) { char ib[256]; time_t t = time(NULL); t += atoi(sd->info_tz)-(60*60*24); @@ -428,10 +398,8 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } g_free(sd->info_tz); } - if(sd->info_seen) - { - if(strlen(sd->info_seen)) - { + if (sd->info_seen) { + if (strlen(sd->info_seen)) { char ib[256]; time_t it = atoi(sd->info_seen); struct tm *tm = localtime(&it); @@ -440,10 +408,8 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } g_free(sd->info_seen); } - if(sd->info_birthday) - { - if(strlen(sd->info_birthday) && strcmp(sd->info_birthday, "0")) - { + if (sd->info_birthday) { + if (strlen(sd->info_birthday) && strcmp(sd->info_birthday, "0")) { char ib[256]; struct tm tm; strptime(sd->info_birthday, "%Y%m%d", &tm); @@ -458,23 +424,19 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } g_free(sd->info_birthday); } - if(sd->info_sex) - { - if(strlen(sd->info_sex)) - { + if (sd->info_sex) { + if (strlen(sd->info_sex)) { char *iptr = sd->info_sex; - while(*iptr++) + while (*iptr++) *iptr = tolower(*iptr); g_string_append_printf(st, "Gender: %s\n", sd->info_sex); } g_free(sd->info_sex); } - if(sd->info_language) - { - if(strlen(sd->info_language)) - { + if (sd->info_language) { + if (strlen(sd->info_language)) { char *iptr = strchr(sd->info_language, ' '); - if(iptr) + if (iptr) iptr++; else iptr = sd->info_language; @@ -482,12 +444,10 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } g_free(sd->info_language); } - if(sd->info_country) - { - if(strlen(sd->info_country)) - { + if (sd->info_country) { + if (strlen(sd->info_country)) { char *iptr = strchr(sd->info_country, ' '); - if(iptr) + if (iptr) iptr++; else iptr = sd->info_country; @@ -495,44 +455,36 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } g_free(sd->info_country); } - if(sd->info_province) - { - if(strlen(sd->info_province)) + if (sd->info_province) { + if (strlen(sd->info_province)) g_string_append_printf(st, "Region: %s\n", sd->info_province); g_free(sd->info_province); } - if(sd->info_city) - { - if(strlen(sd->info_city)) + if (sd->info_city) { + if (strlen(sd->info_city)) g_string_append_printf(st, "City: %s\n", sd->info_city); g_free(sd->info_city); } - if(sd->info_homepage) - { - if(strlen(sd->info_homepage)) + if (sd->info_homepage) { + if (strlen(sd->info_homepage)) g_string_append_printf(st, "Homepage: %s\n", sd->info_homepage); g_free(sd->info_homepage); } - if(sd->info_about) - { - if(strlen(sd->info_about)) + if (sd->info_about) { + if (strlen(sd->info_about)) g_string_append_printf(st, "%s\n", sd->info_about); g_free(sd->info_about); } imcb_log(ic, "%s", st->str); g_string_free(st, TRUE); } - } - else if(!strncmp(line, "CHATMESSAGE ", 12)) - { + } else if (!strncmp(line, "CHATMESSAGE ", 12)) { char *id = strchr(line, ' '); - if(++id) - { + if (++id) { char *info = strchr(id, ' '); *info = '\0'; info++; - if(!strcmp(info, "STATUS RECEIVED")) - { + if (!strcmp(info, "STATUS RECEIVED")) { /* New message ID: * (1) Request its from field * (2) Request its body @@ -540,16 +492,14 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c * (4) Query chatname */ g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id); - skype_write( ic, buf ); + skype_write(ic, buf); g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); - skype_write( ic, buf ); + skype_write(ic, buf); g_snprintf(buf, 1024, "GET CHATMESSAGE %s TYPE\n", id); - skype_write( ic, buf ); + skype_write(ic, buf); g_snprintf(buf, 1024, "GET CHATMESSAGE %s CHATNAME\n", id); - skype_write( ic, buf ); - } - else if(!strncmp(info, "FROM_HANDLE ", 12)) - { + skype_write(ic, buf); + } else if (!strncmp(info, "FROM_HANDLE ", 12)) { info += 12; /* New from field value. Store * it, then we can later use it @@ -557,9 +507,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c * body. */ g_free(sd->handle); sd->handle = g_strdup_printf("%s@skype.com", info); - } - else if(!strncmp(info, "EDITED_BY ", 10)) - { + } else if (!strncmp(info, "EDITED_BY ", 10)) { info += 10; /* This is the same as * FROM_HANDLE, except that we @@ -568,53 +516,38 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c * them. */ g_free(sd->handle); sd->handle = g_strdup_printf("%s@skype.com", info); - } - else if(!strncmp(info, "BODY ", 5)) - { + } else if (!strncmp(info, "BODY ", 5)) { info += 5; sd->body = g_list_append(sd->body, g_strdup(info)); - } - else if(!strncmp(info, "TYPE ", 5)) - { + } else if (!strncmp(info, "TYPE ", 5)) { info += 5; g_free(sd->type); sd->type = g_strdup(info); - } - else if(!strncmp(info, "CHATNAME ", 9)) - { + } else if (!strncmp(info, "CHATNAME ", 9)) { info += 9; - if(sd->handle && sd->body && sd->type) - { + if (sd->handle && sd->body && sd->type) { struct groupchat *gc = skype_chat_by_name(ic, info); int i; - for(i=0;ibody);i++) - { + for (i = 0; i < g_list_length(sd->body); i++) { char *body = g_list_nth_data(sd->body, i); - if(!strcmp(sd->type, "SAID") || !strcmp(sd->type, "EMOTED")) - { + if (!strcmp(sd->type, "SAID") || !strcmp(sd->type, "EMOTED")) { char *st; - if(!strcmp(sd->type, "SAID")) + if (!strcmp(sd->type, "SAID")) st = g_strdup(body); else - { st = g_strdup_printf("/me %s", body); - } - if(!gc) + if (!gc) /* Private message */ imcb_buddy_msg(ic, sd->handle, st, 0, 0); else /* Groupchat message */ imcb_chat_msg(gc, sd->handle, st, 0, 0); g_free(st); - } - else if(!strcmp(sd->type, "SETTOPIC")) - { - if(gc) + } else if (!strcmp(sd->type, "SETTOPIC")) { + if (gc) imcb_chat_topic(gc, sd->handle, body, 0); - } - else if(!strcmp(sd->type, "LEFT")) - { - if(gc) + } else if (!strcmp(sd->type, "LEFT")) { + if (gc) imcb_chat_remove_buddy(gc, sd->handle, NULL); } } @@ -623,177 +556,140 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } } } - } - else if(!strncmp(line, "CALL ", 5)) - { + } else if (!strncmp(line, "CALL ", 5)) { char *id = strchr(line, ' '); - if(++id) - { + if (++id) { char *info = strchr(id, ' '); *info = '\0'; info++; - if(!strncmp(info, "FAILUREREASON ", 14)) + if (!strncmp(info, "FAILUREREASON ", 14)) sd->failurereason = atoi(strchr(info, ' ')); - else if(!strcmp(info, "STATUS RINGING")) - { - if(sd->call_id) + else if (!strcmp(info, "STATUS RINGING")) { + if (sd->call_id) g_free(sd->call_id); sd->call_id = g_strdup(id); g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write( ic, buf ); + skype_write(ic, buf); sd->call_status = SKYPE_CALL_RINGING; - } - else if(!strcmp(info, "STATUS MISSED")) - { + } else if (!strcmp(info, "STATUS MISSED")) { g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write( ic, buf ); + skype_write(ic, buf); sd->call_status = SKYPE_CALL_MISSED; - } - else if(!strcmp(info, "STATUS CANCELLED")) - { + } else if (!strcmp(info, "STATUS CANCELLED")) { g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write( ic, buf ); + skype_write(ic, buf); sd->call_status = SKYPE_CALL_CANCELLED; - } - else if(!strcmp(info, "STATUS FINISHED")) - { + } else if (!strcmp(info, "STATUS FINISHED")) { g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write( ic, buf ); + skype_write(ic, buf); sd->call_status = SKYPE_CALL_FINISHED; - } - else if(!strcmp(info, "STATUS REFUSED")) - { + } else if (!strcmp(info, "STATUS REFUSED")) { g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write( ic, buf ); + skype_write(ic, buf); sd->call_status = SKYPE_CALL_REFUSED; - } - else if(!strcmp(info, "STATUS UNPLACED")) - { - if(sd->call_id) + } else if (!strcmp(info, "STATUS UNPLACED")) { + if (sd->call_id) g_free(sd->call_id); /* Save the ID for later usage (Cancel/Finish). */ sd->call_id = g_strdup(id); sd->call_out = TRUE; - } - else if(!strcmp(info, "STATUS FAILED")) - { + } else if (!strcmp(info, "STATUS FAILED")) { imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason)); sd->call_id = NULL; - } - else if(!strncmp(info, "DURATION ", 9)) - { - if(sd->call_duration) + } else if (!strncmp(info, "DURATION ", 9)) { + if (sd->call_duration) g_free(sd->call_duration); sd->call_duration = g_strdup(info+9); - } - else if(!strncmp(info, "PARTNER_HANDLE ", 15)) - { + } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { info += 15; - if(sd->call_status) { - switch(sd->call_status) - { - case SKYPE_CALL_RINGING: - if(sd->call_out) - imcb_log(ic, "You are currently ringing the user %s.", info); - else - { - g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); - skype_call_ask(ic, sd->call_id, buf); - } - break; - case SKYPE_CALL_MISSED: - imcb_log(ic, "You have missed a call from user %s.", info); - break; - case SKYPE_CALL_CANCELLED: - imcb_log(ic, "You cancelled the call to the user %s.", info); - sd->call_status = 0; - sd->call_out = FALSE; - break; - case SKYPE_CALL_REFUSED: - if(sd->call_out) - imcb_log(ic, "The user %s refused the call.", info); - else - imcb_log(ic, "You refused the call from user %s.", info); - sd->call_out = FALSE; - break; - case SKYPE_CALL_FINISHED: - if(sd->call_duration) - imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); - else - imcb_log(ic, "You finished the call to the user %s.", info); - sd->call_out = FALSE; - break; - default: - /* Don't be noisy, ignore other statuses for now. */ - break; + if (sd->call_status) { + switch (sd->call_status) { + case SKYPE_CALL_RINGING: + if (sd->call_out) + imcb_log(ic, "You are currently ringing the user %s.", info); + else { + g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); + skype_call_ask(ic, sd->call_id, buf); + } + break; + case SKYPE_CALL_MISSED: + imcb_log(ic, "You have missed a call from user %s.", info); + break; + case SKYPE_CALL_CANCELLED: + imcb_log(ic, "You cancelled the call to the user %s.", info); + sd->call_status = 0; + sd->call_out = FALSE; + break; + case SKYPE_CALL_REFUSED: + if (sd->call_out) + imcb_log(ic, "The user %s refused the call.", info); + else + imcb_log(ic, "You refused the call from user %s.", info); + sd->call_out = FALSE; + break; + case SKYPE_CALL_FINISHED: + if (sd->call_duration) + imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); + else + imcb_log(ic, "You finished the call to the user %s.", info); + sd->call_out = FALSE; + break; + default: + /* Don't be noisy, ignore other statuses for now. */ + break; } sd->call_status = 0; } } } - } - else if(!strncmp(line, "FILETRANSFER ", 13)) - { + } else if (!strncmp(line, "FILETRANSFER ", 13)) { char *id = strchr(line, ' '); - if(++id) - { + if (++id) { char *info = strchr(id, ' '); *info = '\0'; info++; - if(!strcmp(info, "STATUS NEW")) - { + if (!strcmp(info, "STATUS NEW")) { g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); - skype_write( ic, buf ); + skype_write(ic, buf); sd->filetransfer_status = SKYPE_FILETRANSFER_NEW; - } - else if(!strcmp(info, "STATUS FAILED")) - { + } else if (!strcmp(info, "STATUS FAILED")) { g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); - skype_write( ic, buf ); + skype_write(ic, buf); sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED; - } - else if(!strncmp(info, "PARTNER_HANDLE ", 15)) - { + } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { info += 15; - if(sd->filetransfer_status) { - switch(sd->filetransfer_status) - { - case SKYPE_FILETRANSFER_NEW: - imcb_log(ic, "The user %s offered a new file for you.", info); - break; - case SKYPE_FILETRANSFER_FAILED: - imcb_log(ic, "Failed to transfer file from user %s.", info); - break; + if (sd->filetransfer_status) { + switch (sd->filetransfer_status) { + case SKYPE_FILETRANSFER_NEW: + imcb_log(ic, "The user %s offered a new file for you.", info); + break; + case SKYPE_FILETRANSFER_FAILED: + imcb_log(ic, "Failed to transfer file from user %s.", info); + break; } sd->filetransfer_status = 0; } } } - } - else if(!strncmp(line, "CHAT ", 5)) - { + } else if (!strncmp(line, "CHAT ", 5)) { char *id = strchr(line, ' '); - if(++id) - { + if (++id) { char *info = strchr(id, ' '); - if(info) + if (info) *info = '\0'; info++; /* Remove fake chat if we created one in skype_chat_with() */ struct groupchat *gc = skype_chat_by_name(ic, ""); - if(gc) + if (gc) imcb_chat_free(gc); - if(!strcmp(info, "STATUS MULTI_SUBSCRIBED")) - { - imcb_chat_new( ic, id ); + if (!strcmp(info, "STATUS MULTI_SUBSCRIBED")) { + imcb_chat_new(ic, id); g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); skype_write(ic, buf); g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); skype_write(ic, buf); - } - else if(!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) - { - gc = imcb_chat_new( ic, id ); + } else if (!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) { + gc = imcb_chat_new(ic, id); /* According to the docs this * is necessary. However it * does not seem the situation @@ -811,27 +707,19 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c skype_write(ic, buf); g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); skype_write(ic, buf); - } - else if(!strcmp(info, "STATUS UNSUBSCRIBED")) - { + } else if (!strcmp(info, "STATUS UNSUBSCRIBED")) { gc = skype_chat_by_name(ic, id); - if(gc) - gc->data = (void*)FALSE; - } - else if(!strncmp(info, "ADDER ", 6)) - { + if (gc) + gc->data = (void *)FALSE; + } else if (!strncmp(info, "ADDER ", 6)) { info += 6; g_free(sd->adder); sd->adder = g_strdup_printf("%s@skype.com", info); - } - else if(!strncmp(info, "TOPIC ", 6)) - { + } else if (!strncmp(info, "TOPIC ", 6)) { info += 6; gc = skype_chat_by_name(ic, id); - if(gc && (sd->adder || sd->topic_wait)) - { - if(sd->topic_wait) - { + if (gc && (sd->adder || sd->topic_wait)) { + if (sd->topic_wait) { sd->adder = g_strdup(sd->username); sd->topic_wait = 0; } @@ -839,25 +727,21 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c g_free(sd->adder); sd->adder = NULL; } - } - else if(!strncmp(info, "ACTIVEMEMBERS ", 14)) - { + } else if (!strncmp(info, "ACTIVEMEMBERS ", 14)) { info += 14; gc = skype_chat_by_name(ic, id); /* Hack! We set ->data to TRUE * while we're on the channel * so that we won't rejoin * after a /part. */ - if(gc && !gc->data) - { + if (gc && !gc->data) { char **members = g_strsplit(info, " ", 0); int i; - for(i=0;members[i];i++) - { - if(!strcmp(members[i], sd->username)) + for (i = 0; members[i]; i++) { + if (!strcmp(members[i], sd->username)) continue; g_snprintf(buf, 1024, "%s@skype.com", members[i]); - if(!g_list_find_custom(gc->in_room, buf, (GCompareFunc)strcmp)) + if (!g_list_find_custom(gc->in_room, buf, (GCompareFunc)strcmp)) imcb_chat_add_buddy(gc, buf); } imcb_chat_add_buddy(gc, sd->username); @@ -865,38 +749,28 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c } } } - } - else if(!strncmp(line, "PASSWORD ", 9)) - { - if(!strncmp(line+9, "OK", 2)) + } else if (!strncmp(line, "PASSWORD ", 9)) { + if (!strncmp(line+9, "OK", 2)) imcb_connected(ic); - else - { + else { imcb_error(ic, "Authentication Failed"); - imc_logout( ic, TRUE ); + imc_logout(ic, TRUE); } - } - else if(!strncmp(line, "PROFILE PSTN_BALANCE ", 21)) - { + } else if (!strncmp(line, "PROFILE PSTN_BALANCE ", 21)) imcb_log(ic, "SkypeOut balance value is '%s'.", line+21); - } - else if(!strncmp(line, "PING", 4)) - { + else if (!strncmp(line, "PING", 4)) { g_snprintf(buf, 1024, "PONG\n"); skype_write(ic, buf); - } - else if(!strncmp(line, "CHATS ", 6)) - { + } else if (!strncmp(line, "CHATS ", 6)) { char **i; char **chats = g_strsplit(line + 6, ", ", 0); i = chats; - while (*i) - { + while (*i) { g_snprintf(buf, 1024, "GET CHAT %s STATUS\n", *i); - skype_write( ic, buf ); + skype_write(ic, buf); g_snprintf(buf, 1024, "GET CHAT %s ACTIVEMEMBERS\n", *i); - skype_write( ic, buf ); + skype_write(ic, buf); i++; } g_strfreev(chats); @@ -904,82 +778,79 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c lineptr++; } g_strfreev(lines); - } - else if( st == 0 || ( st < 0 && !sockerr_again() ) ) - { - closesocket( sd->fd ); + } else if (st == 0 || (st < 0 && !sockerr_again())) { + closesocket(sd->fd); sd->fd = -1; - imcb_error( ic, "Error while reading from server" ); - imc_logout( ic, TRUE ); + imcb_error(ic, "Error while reading from server"); + imc_logout(ic, TRUE); return FALSE; } return TRUE; } -gboolean skype_start_stream( struct im_connection *ic ) +gboolean skype_start_stream(struct im_connection *ic) { struct skype_data *sd = ic->proto_data; char *buf; int st; - if(!sd) + if (!sd) return FALSE; - if( sd->bfd <= 0 ) - sd->bfd = b_input_add( sd->fd, GAIM_INPUT_READ, skype_read_callback, ic ); + if (sd->bfd <= 0) + sd->bfd = b_input_add(sd->fd, GAIM_INPUT_READ, skype_read_callback, ic); /* Log in */ buf = g_strdup_printf("USERNAME %s\n", ic->acc->user); - st = skype_write( ic, buf ); + st = skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("PASSWORD %s\n", ic->acc->pass); - st = skype_write( ic, buf ); + st = skype_write(ic, buf); g_free(buf); /* This will download all buddies. */ buf = g_strdup_printf("SEARCH FRIENDS\n"); - st = skype_write( ic, buf ); + st = skype_write(ic, buf); g_free(buf); buf = g_strdup_printf("SET USERSTATUS ONLINE\n"); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(buf); /* Auto join to bookmarked chats if requested.*/ if (set_getbool(&ic->acc->set, "auto_join")) { buf = g_strdup_printf("SEARCH BOOKMARKEDCHATS\n"); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(buf); } return st; } -gboolean skype_connected( gpointer data, void *source, b_input_condition cond ) +gboolean skype_connected(gpointer data, void *source, b_input_condition cond) { struct im_connection *ic = data; struct skype_data *sd = ic->proto_data; - if(!source) - { + if (!source) { sd->ssl = NULL; - imcb_error( ic, "Could not connect to server" ); - imc_logout( ic, TRUE ); + imcb_error(ic, "Could not connect to server"); + imc_logout(ic, TRUE); return FALSE; } - imcb_log( ic, "Connected to server, logging in" ); + imcb_log(ic, "Connected to server, logging in"); return skype_start_stream(ic); } -static void skype_login( account_t *acc ) +static void skype_login(account_t *acc) { - struct im_connection *ic = imcb_new( acc ); - struct skype_data *sd = g_new0( struct skype_data, 1 ); + struct im_connection *ic = imcb_new(acc); + struct skype_data *sd = g_new0(struct skype_data, 1); ic->proto_data = sd; - imcb_log( ic, "Connecting" ); - sd->ssl = ssl_connect(set_getstr( &acc->set, "server" ), set_getint( &acc->set, "port" ), skype_connected, ic ); - sd->fd = sd->ssl ? ssl_getfd( sd->ssl ) : -1; - sd->username = g_strdup( acc->user ); + imcb_log(ic, "Connecting"); + sd->ssl = ssl_connect(set_getstr(&acc->set, "server"), set_getint(&acc->set, "port"), skype_connected, ic); + sd->fd = sd->ssl ? ssl_getfd(sd->ssl) : -1; + sd->username = g_strdup(acc->user); sd->ic = ic; @@ -987,13 +858,13 @@ static void skype_login( account_t *acc ) imcb_add_buddy(ic, "skypeconsole", NULL); } -static void skype_logout( struct im_connection *ic ) +static void skype_logout(struct im_connection *ic) { struct skype_data *sd = ic->proto_data; char *buf; buf = g_strdup_printf("SET USERSTATUS OFFLINE\n"); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(buf); g_free(sd->username); @@ -1002,14 +873,14 @@ static void skype_logout( struct im_connection *ic ) ic->proto_data = NULL; } -static int skype_buddy_msg( struct im_connection *ic, char *who, char *message, int flags ) +static int skype_buddy_msg(struct im_connection *ic, char *who, char *message, int flags) { char *buf, *ptr, *nick; int st; nick = g_strdup(who); ptr = strchr(nick, '@'); - if(ptr) + if (ptr) *ptr = '\0'; if (!strncmp(who, "skypeconsole", 12)) @@ -1017,159 +888,152 @@ static int skype_buddy_msg( struct im_connection *ic, char *who, char *message, else buf = g_strdup_printf("MESSAGE %s %s\n", nick, message); g_free(nick); - st = skype_write( ic, buf ); + st = skype_write(ic, buf); g_free(buf); return st; } -const struct skype_away_state *skype_away_state_by_name( char *name ) +const struct skype_away_state *skype_away_state_by_name(char *name) { int i; - for( i = 0; skype_away_state_list[i].full_name; i ++ ) - if( g_strcasecmp( skype_away_state_list[i].full_name, name ) == 0 ) - return( skype_away_state_list + i ); + for (i = 0; skype_away_state_list[i].full_name; i++) + if (g_strcasecmp(skype_away_state_list[i].full_name, name) == 0) + return skype_away_state_list + i; return NULL; } -static void skype_set_away( struct im_connection *ic, char *state_txt, char *message ) +static void skype_set_away(struct im_connection *ic, char *state_txt, char *message) { const struct skype_away_state *state; char *buf; - if( strcmp( state_txt, GAIM_AWAY_CUSTOM ) == 0 ) - state = skype_away_state_by_name( "Away" ); + if (strcmp(state_txt, GAIM_AWAY_CUSTOM) == 0) + state = skype_away_state_by_name("Away"); else - state = skype_away_state_by_name( state_txt ); + state = skype_away_state_by_name(state_txt); buf = g_strdup_printf("SET USERSTATUS %s\n", state->code); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(buf); } -static GList *skype_away_states( struct im_connection *ic ) +static GList *skype_away_states(struct im_connection *ic) { - static GList *l = NULL; + static GList *l; int i; - - if( l == NULL ) - for( i = 0; skype_away_state_list[i].full_name; i ++ ) - l = g_list_append( l, (void*) skype_away_state_list[i].full_name ); - + + if (l == NULL) + for (i = 0; skype_away_state_list[i].full_name; i++) + l = g_list_append(l, (void *)skype_away_state_list[i].full_name); + return l; } -static char *skype_set_display_name( set_t *set, char *value ) +static char *skype_set_display_name(set_t *set, char *value) { account_t *acc = set->data; struct im_connection *ic = acc->ic; char *buf; buf = g_strdup_printf("SET PROFILE FULLNAME %s", value); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(buf); - return(value); + return value; } -static char *skype_set_balance( set_t *set, char *value ) +static char *skype_set_balance(set_t *set, char *value) { account_t *acc = set->data; struct im_connection *ic = acc->ic; char *buf; buf = g_strdup_printf("GET PROFILE PSTN_BALANCE"); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(buf); - return(value); + return value; } -static char *skype_set_call( set_t *set, char *value ) +static char *skype_set_call(set_t *set, char *value) { account_t *acc = set->data; struct im_connection *ic = acc->ic; struct skype_data *sd = ic->proto_data; char *nick, *ptr, *buf; - if(value) - { + if (value) { user_t *u = user_find(acc->irc, value); /* We are starting a call */ - if(!u) + if (!u) nick = g_strdup(value); else nick = g_strdup(u->handle); ptr = strchr(nick, '@'); - if(ptr) + if (ptr) *ptr = '\0'; buf = g_strdup_printf("CALL %s", nick); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(buf); g_free(nick); - } - else - { + } else { /* We are ending a call */ - if(sd->call_id) - { + if (sd->call_id) { buf = g_strdup_printf("SET CALL %s STATUS FINISHED", sd->call_id); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(buf); g_free(sd->call_id); sd->call_id = NULL; - } - else - { + } else imcb_error(ic, "There are no active calls currently."); - } } - return(value); + return value; } -static void skype_add_buddy( struct im_connection *ic, char *who, char *group ) +static void skype_add_buddy(struct im_connection *ic, char *who, char *group) { char *buf, *nick, *ptr; nick = g_strdup(who); ptr = strchr(nick, '@'); - if(ptr) + if (ptr) *ptr = '\0'; buf = g_strdup_printf("SET USER %s BUDDYSTATUS 2 Please authorize me\n", nick); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(nick); } -static void skype_remove_buddy( struct im_connection *ic, char *who, char *group ) +static void skype_remove_buddy(struct im_connection *ic, char *who, char *group) { char *buf, *nick, *ptr; nick = g_strdup(who); ptr = strchr(nick, '@'); - if(ptr) + if (ptr) *ptr = '\0'; buf = g_strdup_printf("SET USER %s BUDDYSTATUS 1\n", nick); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(nick); } -void skype_chat_msg( struct groupchat *gc, char *message, int flags ) +void skype_chat_msg(struct groupchat *gc, char *message, int flags) { struct im_connection *ic = gc->ic; char *buf; buf = g_strdup_printf("CHATMESSAGE %s %s\n", gc->title, message); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(buf); } -void skype_chat_leave( struct groupchat *gc ) +void skype_chat_leave(struct groupchat *gc) { struct im_connection *ic = gc->ic; char *buf; buf = g_strdup_printf("ALTER CHAT %s LEAVE\n", gc->title); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(buf); - gc->data = (void*)TRUE; + gc->data = (void *)TRUE; } void skype_chat_invite(struct groupchat *gc, char *who, char *message) @@ -1178,10 +1042,10 @@ void skype_chat_invite(struct groupchat *gc, char *who, char *message) char *buf, *ptr, *nick; nick = g_strdup(message); ptr = strchr(nick, '@'); - if(ptr) + if (ptr) *ptr = '\0'; buf = g_strdup_printf("ALTER CHAT %s ADDMEMBERS %s\n", gc->title, nick); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(buf); g_free(nick); } @@ -1192,7 +1056,7 @@ void skype_chat_topic(struct groupchat *gc, char *message) struct skype_data *sd = ic->proto_data; char *buf; buf = g_strdup_printf("ALTER CHAT %s SETTOPIC %s\n", gc->title, message); - skype_write( ic, buf ); + skype_write(ic, buf); g_free(buf); sd->topic_wait = 1; } @@ -1203,7 +1067,7 @@ struct groupchat *skype_chat_with(struct im_connection *ic, char *who) char *ptr, *nick, *buf; nick = g_strdup(who); ptr = strchr(nick, '@'); - if(ptr) + if (ptr) *ptr = '\0'; buf = g_strdup_printf("CHAT CREATE %s\n", nick); skype_write(ic, buf); @@ -1212,7 +1076,7 @@ struct groupchat *skype_chat_with(struct im_connection *ic, char *who) g_free(nick); /* We create a fake chat for now. We will replace it with a real one in * the real callback. */ - return(imcb_chat_new( ic, "" )); + return imcb_chat_new(ic, ""); } static void skype_get_info(struct im_connection *ic, char *who) @@ -1220,7 +1084,7 @@ static void skype_get_info(struct im_connection *ic, char *who) char *ptr, *nick, *buf; nick = g_strdup(who); ptr = strchr(nick, '@'); - if(ptr) + if (ptr) *ptr = '\0'; buf = g_strdup_printf("GET USER %s FULLNAME\n", nick); skype_write(ic, buf); @@ -1269,42 +1133,42 @@ static void skype_get_info(struct im_connection *ic, char *who) g_free(buf); } -static void skype_set_my_name( struct im_connection *ic, char *info ) +static void skype_set_my_name(struct im_connection *ic, char *info) { - skype_set_display_name( set_find( &ic->acc->set, "display_name" ), info ); + skype_set_display_name(set_find(&ic->acc->set, "display_name"), info); } -static void skype_init( account_t *acc ) +static void skype_init(account_t *acc) { set_t *s; - s = set_add( &acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account, acc ); + s = set_add(&acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account, acc); s->flags |= ACC_SET_OFFLINE_ONLY; - s = set_add( &acc->set, "port", SKYPE_DEFAULT_PORT, set_eval_int, acc ); + s = set_add(&acc->set, "port", SKYPE_DEFAULT_PORT, set_eval_int, acc); s->flags |= ACC_SET_OFFLINE_ONLY; - s = set_add( &acc->set, "display_name", NULL, skype_set_display_name, acc ); + s = set_add(&acc->set, "display_name", NULL, skype_set_display_name, acc); s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; - s = set_add( &acc->set, "call", NULL, skype_set_call, acc ); + s = set_add(&acc->set, "call", NULL, skype_set_call, acc); s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; - s = set_add( &acc->set, "balance", NULL, skype_set_balance, acc ); + s = set_add(&acc->set, "balance", NULL, skype_set_balance, acc); s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; - s = set_add( &acc->set, "skypeout_offline", "true", set_eval_bool, acc ); + s = set_add(&acc->set, "skypeout_offline", "true", set_eval_bool, acc); - s = set_add( &acc->set, "skypeconsole", "false", set_eval_bool, acc ); + s = set_add(&acc->set, "skypeconsole", "false", set_eval_bool, acc); s->flags |= ACC_SET_OFFLINE_ONLY; - s = set_add( &acc->set, "auto_join", "false", set_eval_bool, acc ); + s = set_add(&acc->set, "auto_join", "false", set_eval_bool, acc); s->flags |= ACC_SET_OFFLINE_ONLY; } void init_plugin(void) { - struct prpl *ret = g_new0( struct prpl, 1 ); + struct prpl *ret = g_new0(struct prpl, 1); ret->name = "skype"; ret->login = skype_login; @@ -1323,7 +1187,7 @@ void init_plugin(void) ret->chat_with = skype_chat_with; ret->handle_cmp = g_strcasecmp; ret->chat_topic = skype_chat_topic; - register_protocol( ret ); + register_protocol(ret); } /* vim: set ts=2 sw=2 noet: */ -- cgit v1.2.3 From a349932a6a69d5bb7fbd199b398a1716efd6e5b0 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 22 Dec 2008 00:45:51 +0100 Subject: fix typo in skyped -h --- skype/skyped.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index 7161010f..0347bcdc 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -223,7 +223,7 @@ Options: -h --help this help -H --host set the tcp host (default: %s) -n --nofork don't run as daemon in the background - -p --port set the tcp port (default: %d) + -p --port set the tcp port (default: %s) -v --version display version information""" % (self.cfgpath, self.host, self.port) sys.exit(ret) -- cgit v1.2.3 From 8edfc90fbe2479d7456710139efeab6dc65a9ba5 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 30 Dec 2008 03:39:43 +0100 Subject: skyped: use hashlib instead of sha (python2.6 warning) --- skype/skyped.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/skyped.py b/skype/skyped.py index 0347bcdc..4f274be7 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -29,7 +29,7 @@ import gobject import socket import getopt import Skype4Py -import sha +import hashlib from ConfigParser import ConfigParser, NoOptionError from traceback import print_exception @@ -122,7 +122,7 @@ def listener(sock, *args): if line.startswith("USERNAME") and line.split(' ')[1].strip() == options.config.username: ret += 1 line = options.conn.recv(1024) - if line.startswith("PASSWORD") and sha.sha(line.split(' ')[1].strip()).hexdigest() == options.config.password: + if line.startswith("PASSWORD") and hashlib.sha1(line.split(' ')[1].strip()).hexdigest() == options.config.password: ret += 1 except Exception, s: dprint("Warning, receiving 1024 bytes failed (%s)." % s) -- cgit v1.2.3 From b820226f457d35f6f255252dde80106a95231502 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 01:31:18 +0100 Subject: add new skype/skypeconsole_receive setting for receiving raw data on skypeconsole --- skype/README | 3 +++ skype/skype.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/skype/README b/skype/README index 6e1cd195..f27f4efd 100644 --- a/skype/README +++ b/skype/README @@ -350,6 +350,9 @@ $ skyped -n -d * then writing `skypeconsole: ` will work in the control channel. + * `account set skype/skypeconsole_receive true` will make the + `skypeconsole` account dump all the recieved raw traffic for you + - If you want to automatically join bookmarked groupchats right after you logged in, do: diff --git a/skype/skype.c b/skype/skype.c index 819e185e..c83e9950 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -286,6 +286,8 @@ static gboolean skype_read_callback(gpointer data, gint fd, b_input_condition co while ((line = *lineptr)) { if (!strlen(line)) break; + if (set_getbool(&ic->acc->set, "skypeconsole_receive")) + imcb_buddy_msg(ic, "skypeconsole", line, 0, 0); if (!strncmp(line, "USERS ", 6)) { char **i; char **nicks; @@ -1162,6 +1164,9 @@ static void skype_init(account_t *acc) s = set_add(&acc->set, "skypeconsole", "false", set_eval_bool, acc); s->flags |= ACC_SET_OFFLINE_ONLY; + s = set_add(&acc->set, "skypeconsole_receive", "false", set_eval_bool, acc); + s->flags |= ACC_SET_OFFLINE_ONLY; + s = set_add(&acc->set, "auto_join", "false", set_eval_bool, acc); s->flags |= ACC_SET_OFFLINE_ONLY; } -- cgit v1.2.3 From 83f9aeb3fcac1a90a94631256549bd8f060e0dc1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 01:31:24 +0100 Subject: update HACKING --- skype/HACKING | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skype/HACKING b/skype/HACKING index 9230a7e8..f5e55091 100644 --- a/skype/HACKING +++ b/skype/HACKING @@ -8,8 +8,8 @@ vim, make, etc. 2) bitlbee: -gdb ./bitlbee -run -v -n -D +gdb --args ./bitlbee -v -n -D +run 3) skyped: -- cgit v1.2.3 From 5258dcc95079ee4ae4fab2fa37fb62567f9f2723 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 01:35:14 +0100 Subject: updates for 0.7.0 --- skype/Makefile | 2 +- skype/NEWS | 5 +++-- skype/skype.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/skype/Makefile b/skype/Makefile index 46963651..b838a043 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.6.3 +VERSION = 0.7.0 # latest stable BITLBEE_VERSION = 1.2.3 diff --git a/skype/NEWS b/skype/NEWS index 7c631af9..a755a53a 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,9 +1,10 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- - - made 'make config' more portable +0.7.0 - made 'make config' more portable - add 'skypeconsole' buddy for debugging purposes - support autojoin for bookmarked groupchats - - make hardwired '/dev/null' in skyped portable + - skyped: make hardwired '/dev/null' portable and fix + Python-2.6 warnings 0.6.3 - various osx-specific improvements (see the new screenshot!) - added python-gnutls install instructions - bitlbee.pc is now searched under diff --git a/skype/skype.c b/skype/skype.c index c83e9950..8f1bcf99 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -1,7 +1,7 @@ /* * skype.c - Skype plugin for BitlBee * - * Copyright (c) 2007, 2008 by Miklos Vajna + * Copyright (c) 2007, 2008, 2009 by Miklos Vajna * * Several ideas are used from the BitlBee Jabber plugin, which is * -- cgit v1.2.3 From 8c09bb33fe1bbbfeb820f72fc69026a48f061831 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 01:58:15 +0100 Subject: whitespaces fixes mainly long lines, except in skype_read_callback() --- skype/skype.c | 59 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 8f1bcf99..9a8c0e12 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -164,7 +164,8 @@ int skype_write(struct im_connection *ic, char *buf) static void skype_buddy_ask_yes(void *data) { struct skype_buddy_ask_data *bla = data; - char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED TRUE", bla->handle); + char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED TRUE", + bla->handle); skype_write(bla->ic, buf); g_free(buf); g_free(bla->handle); @@ -174,7 +175,8 @@ static void skype_buddy_ask_yes(void *data) static void skype_buddy_ask_no(void *data) { struct skype_buddy_ask_data *bla = data; - char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED FALSE", bla->handle); + char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED FALSE", + bla->handle); skype_write(bla->ic, buf); g_free(buf); g_free(bla->handle); @@ -183,13 +185,15 @@ static void skype_buddy_ask_no(void *data) void skype_buddy_ask(struct im_connection *ic, char *handle, char *message) { - struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data, 1); + struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data, + 1); char *buf; bla->ic = ic; bla->handle = g_strdup(handle); - buf = g_strdup_printf("The user %s wants to add you to his/her buddy list, saying: '%s'.", handle, message); + buf = g_strdup_printf("The user %s wants to add you to " + "his/her buddy list, saying: '%s'.", handle, message); imcb_ask(ic, buf, bla, skype_buddy_ask_yes, skype_buddy_ask_no); g_free(buf); } @@ -197,7 +201,8 @@ void skype_buddy_ask(struct im_connection *ic, char *handle, char *message) static void skype_call_ask_yes(void *data) { struct skype_buddy_ask_data *bla = data; - char *buf = g_strdup_printf("SET CALL %s STATUS INPROGRESS", bla->handle); + char *buf = g_strdup_printf("SET CALL %s STATUS INPROGRESS", + bla->handle); skype_write(bla->ic, buf); g_free(buf); g_free(bla->handle); @@ -207,7 +212,8 @@ static void skype_call_ask_yes(void *data) static void skype_call_ask_no(void *data) { struct skype_buddy_ask_data *bla = data; - char *buf = g_strdup_printf("SET CALL %s STATUS FINISHED", bla->handle); + char *buf = g_strdup_printf("SET CALL %s STATUS FINISHED", + bla->handle); skype_write(bla->ic, buf); g_free(buf); g_free(bla->handle); @@ -216,7 +222,8 @@ static void skype_call_ask_no(void *data) void skype_call_ask(struct im_connection *ic, char *call_id, char *message) { - struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data, 1); + struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data, + 1); bla->ic = ic; bla->handle = g_strdup(call_id); @@ -266,7 +273,8 @@ static char *skype_call_strerror(int err) } } -static gboolean skype_read_callback(gpointer data, gint fd, b_input_condition cond) +static gboolean skype_read_callback(gpointer data, gint fd, + b_input_condition cond) { struct im_connection *ic = data; struct skype_data *sd = ic->proto_data; @@ -801,7 +809,8 @@ gboolean skype_start_stream(struct im_connection *ic) return FALSE; if (sd->bfd <= 0) - sd->bfd = b_input_add(sd->fd, GAIM_INPUT_READ, skype_read_callback, ic); + sd->bfd = b_input_add(sd->fd, GAIM_INPUT_READ, + skype_read_callback, ic); /* Log in */ buf = g_strdup_printf("USERNAME %s\n", ic->acc->user); @@ -850,7 +859,8 @@ static void skype_login(account_t *acc) ic->proto_data = sd; imcb_log(ic, "Connecting"); - sd->ssl = ssl_connect(set_getstr(&acc->set, "server"), set_getint(&acc->set, "port"), skype_connected, ic); + sd->ssl = ssl_connect(set_getstr(&acc->set, "server"), + set_getint(&acc->set, "port"), skype_connected, ic); sd->fd = sd->ssl ? ssl_getfd(sd->ssl) : -1; sd->username = g_strdup(acc->user); @@ -875,7 +885,8 @@ static void skype_logout(struct im_connection *ic) ic->proto_data = NULL; } -static int skype_buddy_msg(struct im_connection *ic, char *who, char *message, int flags) +static int skype_buddy_msg(struct im_connection *ic, char *who, char *message, + int flags) { char *buf, *ptr, *nick; int st; @@ -907,7 +918,8 @@ const struct skype_away_state *skype_away_state_by_name(char *name) return NULL; } -static void skype_set_away(struct im_connection *ic, char *state_txt, char *message) +static void skype_set_away(struct im_connection *ic, char *state_txt, + char *message) { const struct skype_away_state *state; char *buf; @@ -928,7 +940,8 @@ static GList *skype_away_states(struct im_connection *ic) if (l == NULL) for (i = 0; skype_away_state_list[i].full_name; i++) - l = g_list_append(l, (void *)skype_away_state_list[i].full_name); + l = g_list_append(l, + (void *)skype_away_state_list[i].full_name); return l; } @@ -982,7 +995,8 @@ static char *skype_set_call(set_t *set, char *value) } else { /* We are ending a call */ if (sd->call_id) { - buf = g_strdup_printf("SET CALL %s STATUS FINISHED", sd->call_id); + buf = g_strdup_printf("SET CALL %s STATUS FINISHED", + sd->call_id); skype_write(ic, buf); g_free(buf); g_free(sd->call_id); @@ -1001,7 +1015,8 @@ static void skype_add_buddy(struct im_connection *ic, char *who, char *group) ptr = strchr(nick, '@'); if (ptr) *ptr = '\0'; - buf = g_strdup_printf("SET USER %s BUDDYSTATUS 2 Please authorize me\n", nick); + buf = g_strdup_printf("SET USER %s BUDDYSTATUS 2 Please authorize me\n", + nick); skype_write(ic, buf); g_free(nick); } @@ -1057,7 +1072,8 @@ void skype_chat_topic(struct groupchat *gc, char *message) struct im_connection *ic = gc->ic; struct skype_data *sd = ic->proto_data; char *buf; - buf = g_strdup_printf("ALTER CHAT %s SETTOPIC %s\n", gc->title, message); + buf = g_strdup_printf("ALTER CHAT %s SETTOPIC %s\n", + gc->title, message); skype_write(ic, buf); g_free(buf); sd->topic_wait = 1; @@ -1144,13 +1160,15 @@ static void skype_init(account_t *acc) { set_t *s; - s = set_add(&acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account, acc); + s = set_add(&acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account, + acc); s->flags |= ACC_SET_OFFLINE_ONLY; s = set_add(&acc->set, "port", SKYPE_DEFAULT_PORT, set_eval_int, acc); s->flags |= ACC_SET_OFFLINE_ONLY; - s = set_add(&acc->set, "display_name", NULL, skype_set_display_name, acc); + s = set_add(&acc->set, "display_name", NULL, skype_set_display_name, + acc); s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; s = set_add(&acc->set, "call", NULL, skype_set_call, acc); @@ -1164,7 +1182,8 @@ static void skype_init(account_t *acc) s = set_add(&acc->set, "skypeconsole", "false", set_eval_bool, acc); s->flags |= ACC_SET_OFFLINE_ONLY; - s = set_add(&acc->set, "skypeconsole_receive", "false", set_eval_bool, acc); + s = set_add(&acc->set, "skypeconsole_receive", "false", set_eval_bool, + acc); s->flags |= ACC_SET_OFFLINE_ONLY; s = set_add(&acc->set, "auto_join", "false", set_eval_bool, acc); @@ -1194,5 +1213,3 @@ void init_plugin(void) ret->chat_topic = skype_chat_topic; register_protocol(ret); } - -/* vim: set ts=2 sw=2 noet: */ -- cgit v1.2.3 From 359f4d9ae19a45d0d7d34bc2ba27c41e0ab6730f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 02:02:53 +0100 Subject: do not add new typedefs --- skype/skype.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 9a8c0e12..07529e5c 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -37,7 +37,7 @@ * Enumerations */ -typedef enum { +enum { SKYPE_CALL_RINGING = 1, SKYPE_CALL_MISSED, SKYPE_CALL_CANCELLED, @@ -45,7 +45,7 @@ typedef enum { SKYPE_CALL_REFUSED } skype_call_status; -typedef enum { +enum { SKYPE_FILETRANSFER_NEW = 1, SKYPE_FILETRANSFER_FAILED } skype_filetransfer_status; @@ -75,13 +75,13 @@ struct skype_data { /* This is necessary because we send a notification when we get the * handle. So we store the state here and then we can send a * notification about the handle is in a given status. */ - skype_call_status call_status; + int call_status; char *call_id; char *call_duration; /* If the call is outgoing or not */ int call_out; /* Same for file transfers. */ - skype_filetransfer_status filetransfer_status; + int filetransfer_status; /* Using /j #nick we want to have a groupchat with two people. Usually * not (default). */ char *groupchat_with; -- cgit v1.2.3 From 078b0b909888bb0a39f7b5365c772866a8ff4d46 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 02:10:13 +0100 Subject: introduce skype_parse_users() --- skype/skype.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 07529e5c..5f1210ea 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -273,6 +273,21 @@ static char *skype_call_strerror(int err) } } +static void skype_parse_users(struct im_connection *ic, char *line) +{ + char **i, **nicks, *ptr; + + nicks = g_strsplit(line + 6, ", ", 0); + i = nicks; + while (*i) { + ptr = g_strdup_printf("GET USER %s ONLINESTATUS\n", *i); + skype_write(ic, ptr); + g_free(ptr); + i++; + } + g_strfreev(nicks); +} + static gboolean skype_read_callback(gpointer data, gint fd, b_input_condition cond) { @@ -296,19 +311,9 @@ static gboolean skype_read_callback(gpointer data, gint fd, break; if (set_getbool(&ic->acc->set, "skypeconsole_receive")) imcb_buddy_msg(ic, "skypeconsole", line, 0, 0); - if (!strncmp(line, "USERS ", 6)) { - char **i; - char **nicks; - - nicks = g_strsplit(line + 6, ", ", 0); - i = nicks; - while (*i) { - g_snprintf(buf, 1024, "GET USER %s ONLINESTATUS\n", *i); - skype_write(ic, buf); - i++; - } - g_strfreev(nicks); - } else if (!strncmp(line, "USER ", 5)) { + if (!strncmp(line, "USERS ", 6)) + skype_parse_users(ic, line); + else if (!strncmp(line, "USER ", 5)) { int flags = 0; char *status = strrchr(line, ' '); char *user = strchr(line, ' '); -- cgit v1.2.3 From 8bbe52abe983613d5d25e449d2a3fa58301d7089 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 02:11:44 +0100 Subject: cleanup in skype_parse_users() --- skype/skype.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 5f1210ea..08faa4d7 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -278,12 +278,10 @@ static void skype_parse_users(struct im_connection *ic, char *line) char **i, **nicks, *ptr; nicks = g_strsplit(line + 6, ", ", 0); - i = nicks; - while (*i) { + for (i = nicks; *i; i++) { ptr = g_strdup_printf("GET USER %s ONLINESTATUS\n", *i); skype_write(ic, ptr); g_free(ptr); - i++; } g_strfreev(nicks); } -- cgit v1.2.3 From 6e14204b2d45074d83c850f7b1cdf4b4138e7fb4 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 02:20:57 +0100 Subject: introduce skype_parse_user() and skype_parse_chatmessage() --- skype/skype.c | 533 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 276 insertions(+), 257 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 08faa4d7..5aa07df3 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -286,6 +286,279 @@ static void skype_parse_users(struct im_connection *ic, char *line) g_strfreev(nicks); } +static void skype_parse_user(struct im_connection *ic, char *line) +{ + int flags = 0; + char *ptr; + struct skype_data *sd = ic->proto_data; + char *user = strchr(line, ' '); + char *status = strrchr(line, ' '); + + status++; + ptr = strchr(++user, ' '); + if (!ptr) + return; + *ptr = '\0'; + ptr++; + if (!strncmp(ptr, "ONLINESTATUS ", 13) && + strcmp(user, sd->username) != 0 + && strcmp(user, "echo123") != 0) { + ptr = g_strdup_printf("%s@skype.com", user); + imcb_add_buddy(ic, ptr, NULL); + if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") || !set_getbool(&ic->acc->set, "skypeout_offline"))) + flags |= OPT_LOGGED_IN; + if (strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0) + flags |= OPT_AWAY; + imcb_buddy_status(ic, ptr, flags, NULL, NULL); + g_free(ptr); + } else if (!strncmp(ptr, "RECEIVEDAUTHREQUEST ", 20)) { + char *message = ptr + 20; + if (strlen(message)) + skype_buddy_ask(ic, user, message); + } else if (!strncmp(ptr, "BUDDYSTATUS ", 12)) { + char *st = ptr + 12; + if (!strcmp(st, "3")) { + char *buf = g_strdup_printf("%s@skype.com", user); + imcb_add_buddy(ic, buf, NULL); + g_free(buf); + } + } else if (!strncmp(ptr, "FULLNAME ", 9)) + sd->info_fullname = g_strdup_printf("%s", ptr + 9); + else if (!strncmp(ptr, "PHONE_HOME ", 11)) + sd->info_phonehome = g_strdup_printf("%s", ptr + 11); + else if (!strncmp(ptr, "PHONE_OFFICE ", 13)) + sd->info_phoneoffice = g_strdup_printf("%s", ptr + 13); + else if (!strncmp(ptr, "PHONE_MOBILE ", 13)) + sd->info_phonemobile = g_strdup_printf("%s", ptr + 13); + else if (!strncmp(ptr, "NROF_AUTHED_BUDDIES ", 20)) + sd->info_nrbuddies = g_strdup_printf("%s", ptr + 20); + else if (!strncmp(ptr, "TIMEZONE ", 9)) + sd->info_tz = g_strdup_printf("%s", ptr + 9); + else if (!strncmp(ptr, "LASTONLINETIMESTAMP ", 20)) + sd->info_seen = g_strdup_printf("%s", ptr + 20); + else if (!strncmp(ptr, "BIRTHDAY ", 9)) + sd->info_birthday = g_strdup_printf("%s", ptr + 9); + else if (!strncmp(ptr, "SEX ", 4)) + sd->info_sex = g_strdup_printf("%s", ptr + 4); + else if (!strncmp(ptr, "LANGUAGE ", 9)) + sd->info_language = g_strdup_printf("%s", ptr + 9); + else if (!strncmp(ptr, "COUNTRY ", 8)) + sd->info_country = g_strdup_printf("%s", ptr + 8); + else if (!strncmp(ptr, "PROVINCE ", 9)) + sd->info_province = g_strdup_printf("%s", ptr + 9); + else if (!strncmp(ptr, "CITY ", 5)) + sd->info_city = g_strdup_printf("%s", ptr + 5); + else if (!strncmp(ptr, "HOMEPAGE ", 9)) + sd->info_homepage = g_strdup_printf("%s", ptr + 9); + else if (!strncmp(ptr, "ABOUT ", 6)) { + sd->info_about = g_strdup_printf("%s", ptr + 6); + + GString *st = g_string_new("Contact Information\n"); + g_string_append_printf(st, "Skype Name: %s\n", user); + if (sd->info_fullname) { + if (strlen(sd->info_fullname)) + g_string_append_printf(st, "Full Name: %s\n", sd->info_fullname); + g_free(sd->info_fullname); + } + if (sd->info_phonehome) { + if (strlen(sd->info_phonehome)) + g_string_append_printf(st, "Home Phone: %s\n", sd->info_phonehome); + g_free(sd->info_phonehome); + } + if (sd->info_phoneoffice) { + if (strlen(sd->info_phoneoffice)) + g_string_append_printf(st, "Office Phone: %s\n", sd->info_phoneoffice); + g_free(sd->info_phoneoffice); + } + if (sd->info_phonemobile) { + if (strlen(sd->info_phonemobile)) + g_string_append_printf(st, "Mobile Phone: %s\n", sd->info_phonemobile); + g_free(sd->info_phonemobile); + } + g_string_append_printf(st, "Personal Information\n"); + if (sd->info_nrbuddies) { + if (strlen(sd->info_nrbuddies)) + g_string_append_printf(st, "Contacts: %s\n", sd->info_nrbuddies); + g_free(sd->info_nrbuddies); + } + if (sd->info_tz) { + if (strlen(sd->info_tz)) { + char ib[256]; + time_t t = time(NULL); + t += atoi(sd->info_tz)-(60*60*24); + struct tm *gt = gmtime(&t); + strftime(ib, 256, "%H:%M:%S", gt); + g_string_append_printf(st, "Local Time: %s\n", ib); + } + g_free(sd->info_tz); + } + if (sd->info_seen) { + if (strlen(sd->info_seen)) { + char ib[256]; + time_t it = atoi(sd->info_seen); + struct tm *tm = localtime(&it); + strftime(ib, 256, ("%Y. %m. %d. %H:%M"), tm); + g_string_append_printf(st, "Last Seen: %s\n", ib); + } + g_free(sd->info_seen); + } + if (sd->info_birthday) { + if (strlen(sd->info_birthday) && strcmp(sd->info_birthday, "0")) { + char ib[256]; + struct tm tm; + strptime(sd->info_birthday, "%Y%m%d", &tm); + strftime(ib, 256, "%B %d, %Y", &tm); + g_string_append_printf(st, "Birthday: %s\n", ib); + + strftime(ib, 256, "%Y", &tm); + int year = atoi(ib); + time_t t = time(NULL); + struct tm *lt = localtime(&t); + g_string_append_printf(st, "Age: %d\n", lt->tm_year+1900-year); + } + g_free(sd->info_birthday); + } + if (sd->info_sex) { + if (strlen(sd->info_sex)) { + char *iptr = sd->info_sex; + while (*iptr++) + *iptr = tolower(*iptr); + g_string_append_printf(st, "Gender: %s\n", sd->info_sex); + } + g_free(sd->info_sex); + } + if (sd->info_language) { + if (strlen(sd->info_language)) { + char *iptr = strchr(sd->info_language, ' '); + if (iptr) + iptr++; + else + iptr = sd->info_language; + g_string_append_printf(st, "Language: %s\n", iptr); + } + g_free(sd->info_language); + } + if (sd->info_country) { + if (strlen(sd->info_country)) { + char *iptr = strchr(sd->info_country, ' '); + if (iptr) + iptr++; + else + iptr = sd->info_country; + g_string_append_printf(st, "Country: %s\n", iptr); + } + g_free(sd->info_country); + } + if (sd->info_province) { + if (strlen(sd->info_province)) + g_string_append_printf(st, "Region: %s\n", sd->info_province); + g_free(sd->info_province); + } + if (sd->info_city) { + if (strlen(sd->info_city)) + g_string_append_printf(st, "City: %s\n", sd->info_city); + g_free(sd->info_city); + } + if (sd->info_homepage) { + if (strlen(sd->info_homepage)) + g_string_append_printf(st, "Homepage: %s\n", sd->info_homepage); + g_free(sd->info_homepage); + } + if (sd->info_about) { + if (strlen(sd->info_about)) + g_string_append_printf(st, "%s\n", sd->info_about); + g_free(sd->info_about); + } + imcb_log(ic, "%s", st->str); + g_string_free(st, TRUE); + } +} + +static void skype_parse_chatmessage(struct im_connection *ic, char *line) +{ + struct skype_data *sd = ic->proto_data; + char buf[1024]; + char *id = strchr(line, ' '); + + if (++id) { + char *info = strchr(id, ' '); + + if (!info) + return; + *info = '\0'; + info++; + if (!strcmp(info, "STATUS RECEIVED")) { + /* New message ID: + * (1) Request its from field + * (2) Request its body + * (3) Request its type + * (4) Query chatname + */ + g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id); + skype_write(ic, buf); + g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); + skype_write(ic, buf); + g_snprintf(buf, 1024, "GET CHATMESSAGE %s TYPE\n", id); + skype_write(ic, buf); + g_snprintf(buf, 1024, "GET CHATMESSAGE %s CHATNAME\n", id); + skype_write(ic, buf); + } else if (!strncmp(info, "FROM_HANDLE ", 12)) { + info += 12; + /* New from field value. Store + * it, then we can later use it + * when we got the message's + * body. */ + g_free(sd->handle); + sd->handle = g_strdup_printf("%s@skype.com", info); + } else if (!strncmp(info, "EDITED_BY ", 10)) { + info += 10; + /* This is the same as + * FROM_HANDLE, except that we + * never request these lines + * from Skype, we just get + * them. */ + g_free(sd->handle); + sd->handle = g_strdup_printf("%s@skype.com", info); + } else if (!strncmp(info, "BODY ", 5)) { + info += 5; + sd->body = g_list_append(sd->body, g_strdup(info)); + } else if (!strncmp(info, "TYPE ", 5)) { + info += 5; + g_free(sd->type); + sd->type = g_strdup(info); + } else if (!strncmp(info, "CHATNAME ", 9)) { + info += 9; + if (sd->handle && sd->body && sd->type) { + struct groupchat *gc = skype_chat_by_name(ic, info); + int i; + for (i = 0; i < g_list_length(sd->body); i++) { + char *body = g_list_nth_data(sd->body, i); + if (!strcmp(sd->type, "SAID") || !strcmp(sd->type, "EMOTED")) { + if (!strcmp(sd->type, "SAID")) + g_snprintf(buf, 1024, "%s", body); + else + g_snprintf(buf, 1024, "/me %s", body); + if (!gc) + /* Private message */ + imcb_buddy_msg(ic, sd->handle, buf, 0, 0); + else + /* Groupchat message */ + imcb_chat_msg(gc, sd->handle, buf, 0, 0); + } else if (!strcmp(sd->type, "SETTOPIC")) { + if (gc) + imcb_chat_topic(gc, sd->handle, body, 0); + } else if (!strcmp(sd->type, "LEFT")) { + if (gc) + imcb_chat_remove_buddy(gc, sd->handle, NULL); + } + } + g_list_free(sd->body); + sd->body = NULL; + } + } + } +} + static gboolean skype_read_callback(gpointer data, gint fd, b_input_condition cond) { @@ -293,7 +566,7 @@ static gboolean skype_read_callback(gpointer data, gint fd, struct skype_data *sd = ic->proto_data; char buf[1024]; int st; - char **lines, **lineptr, *line, *ptr; + char **lines, **lineptr, *line; if (!sd || sd->fd == -1) return FALSE; @@ -312,263 +585,9 @@ static gboolean skype_read_callback(gpointer data, gint fd, if (!strncmp(line, "USERS ", 6)) skype_parse_users(ic, line); else if (!strncmp(line, "USER ", 5)) { - int flags = 0; - char *status = strrchr(line, ' '); - char *user = strchr(line, ' '); - status++; - ptr = strchr(++user, ' '); - *ptr = '\0'; - ptr++; - if (!strncmp(ptr, "ONLINESTATUS ", 13) && - strcmp(user, sd->username) != 0 - && strcmp(user, "echo123") != 0) { - ptr = g_strdup_printf("%s@skype.com", user); - imcb_add_buddy(ic, ptr, NULL); - if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") || !set_getbool(&ic->acc->set, "skypeout_offline"))) - flags |= OPT_LOGGED_IN; - if (strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0) - flags |= OPT_AWAY; - imcb_buddy_status(ic, ptr, flags, NULL, NULL); - g_free(ptr); - } else if (!strncmp(ptr, "RECEIVEDAUTHREQUEST ", 20)) { - char *message = ptr + 20; - if (strlen(message)) - skype_buddy_ask(ic, user, message); - } else if (!strncmp(ptr, "BUDDYSTATUS ", 12)) { - char *st = ptr + 12; - if (!strcmp(st, "3")) { - char *buf = g_strdup_printf("%s@skype.com", user); - imcb_add_buddy(ic, buf, NULL); - g_free(buf); - } - } else if (!strncmp(ptr, "FULLNAME ", 9)) - sd->info_fullname = g_strdup_printf("%s", ptr + 9); - else if (!strncmp(ptr, "PHONE_HOME ", 11)) - sd->info_phonehome = g_strdup_printf("%s", ptr + 11); - else if (!strncmp(ptr, "PHONE_OFFICE ", 13)) - sd->info_phoneoffice = g_strdup_printf("%s", ptr + 13); - else if (!strncmp(ptr, "PHONE_MOBILE ", 13)) - sd->info_phonemobile = g_strdup_printf("%s", ptr + 13); - else if (!strncmp(ptr, "NROF_AUTHED_BUDDIES ", 20)) - sd->info_nrbuddies = g_strdup_printf("%s", ptr + 20); - else if (!strncmp(ptr, "TIMEZONE ", 9)) - sd->info_tz = g_strdup_printf("%s", ptr + 9); - else if (!strncmp(ptr, "LASTONLINETIMESTAMP ", 20)) - sd->info_seen = g_strdup_printf("%s", ptr + 20); - else if (!strncmp(ptr, "BIRTHDAY ", 9)) - sd->info_birthday = g_strdup_printf("%s", ptr + 9); - else if (!strncmp(ptr, "SEX ", 4)) - sd->info_sex = g_strdup_printf("%s", ptr + 4); - else if (!strncmp(ptr, "LANGUAGE ", 9)) - sd->info_language = g_strdup_printf("%s", ptr + 9); - else if (!strncmp(ptr, "COUNTRY ", 8)) - sd->info_country = g_strdup_printf("%s", ptr + 8); - else if (!strncmp(ptr, "PROVINCE ", 9)) - sd->info_province = g_strdup_printf("%s", ptr + 9); - else if (!strncmp(ptr, "CITY ", 5)) - sd->info_city = g_strdup_printf("%s", ptr + 5); - else if (!strncmp(ptr, "HOMEPAGE ", 9)) - sd->info_homepage = g_strdup_printf("%s", ptr + 9); - else if (!strncmp(ptr, "ABOUT ", 6)) { - sd->info_about = g_strdup_printf("%s", ptr + 6); - - GString *st = g_string_new("Contact Information\n"); - g_string_append_printf(st, "Skype Name: %s\n", user); - if (sd->info_fullname) { - if (strlen(sd->info_fullname)) - g_string_append_printf(st, "Full Name: %s\n", sd->info_fullname); - g_free(sd->info_fullname); - } - if (sd->info_phonehome) { - if (strlen(sd->info_phonehome)) - g_string_append_printf(st, "Home Phone: %s\n", sd->info_phonehome); - g_free(sd->info_phonehome); - } - if (sd->info_phoneoffice) { - if (strlen(sd->info_phoneoffice)) - g_string_append_printf(st, "Office Phone: %s\n", sd->info_phoneoffice); - g_free(sd->info_phoneoffice); - } - if (sd->info_phonemobile) { - if (strlen(sd->info_phonemobile)) - g_string_append_printf(st, "Mobile Phone: %s\n", sd->info_phonemobile); - g_free(sd->info_phonemobile); - } - g_string_append_printf(st, "Personal Information\n"); - if (sd->info_nrbuddies) { - if (strlen(sd->info_nrbuddies)) - g_string_append_printf(st, "Contacts: %s\n", sd->info_nrbuddies); - g_free(sd->info_nrbuddies); - } - if (sd->info_tz) { - if (strlen(sd->info_tz)) { - char ib[256]; - time_t t = time(NULL); - t += atoi(sd->info_tz)-(60*60*24); - struct tm *gt = gmtime(&t); - strftime(ib, 256, "%H:%M:%S", gt); - g_string_append_printf(st, "Local Time: %s\n", ib); - } - g_free(sd->info_tz); - } - if (sd->info_seen) { - if (strlen(sd->info_seen)) { - char ib[256]; - time_t it = atoi(sd->info_seen); - struct tm *tm = localtime(&it); - strftime(ib, 256, ("%Y. %m. %d. %H:%M"), tm); - g_string_append_printf(st, "Last Seen: %s\n", ib); - } - g_free(sd->info_seen); - } - if (sd->info_birthday) { - if (strlen(sd->info_birthday) && strcmp(sd->info_birthday, "0")) { - char ib[256]; - struct tm tm; - strptime(sd->info_birthday, "%Y%m%d", &tm); - strftime(ib, 256, "%B %d, %Y", &tm); - g_string_append_printf(st, "Birthday: %s\n", ib); - - strftime(ib, 256, "%Y", &tm); - int year = atoi(ib); - time_t t = time(NULL); - struct tm *lt = localtime(&t); - g_string_append_printf(st, "Age: %d\n", lt->tm_year+1900-year); - } - g_free(sd->info_birthday); - } - if (sd->info_sex) { - if (strlen(sd->info_sex)) { - char *iptr = sd->info_sex; - while (*iptr++) - *iptr = tolower(*iptr); - g_string_append_printf(st, "Gender: %s\n", sd->info_sex); - } - g_free(sd->info_sex); - } - if (sd->info_language) { - if (strlen(sd->info_language)) { - char *iptr = strchr(sd->info_language, ' '); - if (iptr) - iptr++; - else - iptr = sd->info_language; - g_string_append_printf(st, "Language: %s\n", iptr); - } - g_free(sd->info_language); - } - if (sd->info_country) { - if (strlen(sd->info_country)) { - char *iptr = strchr(sd->info_country, ' '); - if (iptr) - iptr++; - else - iptr = sd->info_country; - g_string_append_printf(st, "Country: %s\n", iptr); - } - g_free(sd->info_country); - } - if (sd->info_province) { - if (strlen(sd->info_province)) - g_string_append_printf(st, "Region: %s\n", sd->info_province); - g_free(sd->info_province); - } - if (sd->info_city) { - if (strlen(sd->info_city)) - g_string_append_printf(st, "City: %s\n", sd->info_city); - g_free(sd->info_city); - } - if (sd->info_homepage) { - if (strlen(sd->info_homepage)) - g_string_append_printf(st, "Homepage: %s\n", sd->info_homepage); - g_free(sd->info_homepage); - } - if (sd->info_about) { - if (strlen(sd->info_about)) - g_string_append_printf(st, "%s\n", sd->info_about); - g_free(sd->info_about); - } - imcb_log(ic, "%s", st->str); - g_string_free(st, TRUE); - } + skype_parse_user(ic, line); } else if (!strncmp(line, "CHATMESSAGE ", 12)) { - char *id = strchr(line, ' '); - if (++id) { - char *info = strchr(id, ' '); - *info = '\0'; - info++; - if (!strcmp(info, "STATUS RECEIVED")) { - /* New message ID: - * (1) Request its from field - * (2) Request its body - * (3) Request its type - * (4) Query chatname - */ - g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id); - skype_write(ic, buf); - g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); - skype_write(ic, buf); - g_snprintf(buf, 1024, "GET CHATMESSAGE %s TYPE\n", id); - skype_write(ic, buf); - g_snprintf(buf, 1024, "GET CHATMESSAGE %s CHATNAME\n", id); - skype_write(ic, buf); - } else if (!strncmp(info, "FROM_HANDLE ", 12)) { - info += 12; - /* New from field value. Store - * it, then we can later use it - * when we got the message's - * body. */ - g_free(sd->handle); - sd->handle = g_strdup_printf("%s@skype.com", info); - } else if (!strncmp(info, "EDITED_BY ", 10)) { - info += 10; - /* This is the same as - * FROM_HANDLE, except that we - * never request these lines - * from Skype, we just get - * them. */ - g_free(sd->handle); - sd->handle = g_strdup_printf("%s@skype.com", info); - } else if (!strncmp(info, "BODY ", 5)) { - info += 5; - sd->body = g_list_append(sd->body, g_strdup(info)); - } else if (!strncmp(info, "TYPE ", 5)) { - info += 5; - g_free(sd->type); - sd->type = g_strdup(info); - } else if (!strncmp(info, "CHATNAME ", 9)) { - info += 9; - if (sd->handle && sd->body && sd->type) { - struct groupchat *gc = skype_chat_by_name(ic, info); - int i; - for (i = 0; i < g_list_length(sd->body); i++) { - char *body = g_list_nth_data(sd->body, i); - if (!strcmp(sd->type, "SAID") || !strcmp(sd->type, "EMOTED")) { - char *st; - if (!strcmp(sd->type, "SAID")) - st = g_strdup(body); - else - st = g_strdup_printf("/me %s", body); - if (!gc) - /* Private message */ - imcb_buddy_msg(ic, sd->handle, st, 0, 0); - else - /* Groupchat message */ - imcb_chat_msg(gc, sd->handle, st, 0, 0); - g_free(st); - } else if (!strcmp(sd->type, "SETTOPIC")) { - if (gc) - imcb_chat_topic(gc, sd->handle, body, 0); - } else if (!strcmp(sd->type, "LEFT")) { - if (gc) - imcb_chat_remove_buddy(gc, sd->handle, NULL); - } - } - g_list_free(sd->body); - sd->body = NULL; - } - } - } + skype_parse_chatmessage(ic, line); } else if (!strncmp(line, "CALL ", 5)) { char *id = strchr(line, ' '); if (++id) { -- cgit v1.2.3 From 9f2f25fe941c6da70c561c8320b6e0e5d9819027 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 02:23:38 +0100 Subject: introduce skype_parse_call() --- skype/skype.c | 189 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 100 insertions(+), 89 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 5aa07df3..d9f24a59 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -559,6 +559,101 @@ static void skype_parse_chatmessage(struct im_connection *ic, char *line) } } +static void skype_parse_call(struct im_connection *ic, char *line) +{ + struct skype_data *sd = ic->proto_data; + char *id = strchr(line, ' '); + char buf[1024]; + + if (++id) { + char *info = strchr(id, ' '); + + if (!info) + return; + *info = '\0'; + info++; + if (!strncmp(info, "FAILUREREASON ", 14)) + sd->failurereason = atoi(strchr(info, ' ')); + else if (!strcmp(info, "STATUS RINGING")) { + if (sd->call_id) + g_free(sd->call_id); + sd->call_id = g_strdup(id); + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->call_status = SKYPE_CALL_RINGING; + } else if (!strcmp(info, "STATUS MISSED")) { + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->call_status = SKYPE_CALL_MISSED; + } else if (!strcmp(info, "STATUS CANCELLED")) { + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->call_status = SKYPE_CALL_CANCELLED; + } else if (!strcmp(info, "STATUS FINISHED")) { + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->call_status = SKYPE_CALL_FINISHED; + } else if (!strcmp(info, "STATUS REFUSED")) { + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->call_status = SKYPE_CALL_REFUSED; + } else if (!strcmp(info, "STATUS UNPLACED")) { + if (sd->call_id) + g_free(sd->call_id); + /* Save the ID for later usage (Cancel/Finish). */ + sd->call_id = g_strdup(id); + sd->call_out = TRUE; + } else if (!strcmp(info, "STATUS FAILED")) { + imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason)); + sd->call_id = NULL; + } else if (!strncmp(info, "DURATION ", 9)) { + if (sd->call_duration) + g_free(sd->call_duration); + sd->call_duration = g_strdup(info+9); + } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { + info += 15; + if (sd->call_status) { + switch (sd->call_status) { + case SKYPE_CALL_RINGING: + if (sd->call_out) + imcb_log(ic, "You are currently ringing the user %s.", info); + else { + g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); + skype_call_ask(ic, sd->call_id, buf); + } + break; + case SKYPE_CALL_MISSED: + imcb_log(ic, "You have missed a call from user %s.", info); + break; + case SKYPE_CALL_CANCELLED: + imcb_log(ic, "You cancelled the call to the user %s.", info); + sd->call_status = 0; + sd->call_out = FALSE; + break; + case SKYPE_CALL_REFUSED: + if (sd->call_out) + imcb_log(ic, "The user %s refused the call.", info); + else + imcb_log(ic, "You refused the call from user %s.", info); + sd->call_out = FALSE; + break; + case SKYPE_CALL_FINISHED: + if (sd->call_duration) + imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); + else + imcb_log(ic, "You finished the call to the user %s.", info); + sd->call_out = FALSE; + break; + default: + /* Don't be noisy, ignore other statuses for now. */ + break; + } + sd->call_status = 0; + } + } + } +} + static gboolean skype_read_callback(gpointer data, gint fd, b_input_condition cond) { @@ -584,97 +679,13 @@ static gboolean skype_read_callback(gpointer data, gint fd, imcb_buddy_msg(ic, "skypeconsole", line, 0, 0); if (!strncmp(line, "USERS ", 6)) skype_parse_users(ic, line); - else if (!strncmp(line, "USER ", 5)) { + else if (!strncmp(line, "USER ", 5)) skype_parse_user(ic, line); - } else if (!strncmp(line, "CHATMESSAGE ", 12)) { + else if (!strncmp(line, "CHATMESSAGE ", 12)) skype_parse_chatmessage(ic, line); - } else if (!strncmp(line, "CALL ", 5)) { - char *id = strchr(line, ' '); - if (++id) { - char *info = strchr(id, ' '); - *info = '\0'; - info++; - if (!strncmp(info, "FAILUREREASON ", 14)) - sd->failurereason = atoi(strchr(info, ' ')); - else if (!strcmp(info, "STATUS RINGING")) { - if (sd->call_id) - g_free(sd->call_id); - sd->call_id = g_strdup(id); - g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->call_status = SKYPE_CALL_RINGING; - } else if (!strcmp(info, "STATUS MISSED")) { - g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->call_status = SKYPE_CALL_MISSED; - } else if (!strcmp(info, "STATUS CANCELLED")) { - g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->call_status = SKYPE_CALL_CANCELLED; - } else if (!strcmp(info, "STATUS FINISHED")) { - g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->call_status = SKYPE_CALL_FINISHED; - } else if (!strcmp(info, "STATUS REFUSED")) { - g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->call_status = SKYPE_CALL_REFUSED; - } else if (!strcmp(info, "STATUS UNPLACED")) { - if (sd->call_id) - g_free(sd->call_id); - /* Save the ID for later usage (Cancel/Finish). */ - sd->call_id = g_strdup(id); - sd->call_out = TRUE; - } else if (!strcmp(info, "STATUS FAILED")) { - imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason)); - sd->call_id = NULL; - } else if (!strncmp(info, "DURATION ", 9)) { - if (sd->call_duration) - g_free(sd->call_duration); - sd->call_duration = g_strdup(info+9); - } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { - info += 15; - if (sd->call_status) { - switch (sd->call_status) { - case SKYPE_CALL_RINGING: - if (sd->call_out) - imcb_log(ic, "You are currently ringing the user %s.", info); - else { - g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); - skype_call_ask(ic, sd->call_id, buf); - } - break; - case SKYPE_CALL_MISSED: - imcb_log(ic, "You have missed a call from user %s.", info); - break; - case SKYPE_CALL_CANCELLED: - imcb_log(ic, "You cancelled the call to the user %s.", info); - sd->call_status = 0; - sd->call_out = FALSE; - break; - case SKYPE_CALL_REFUSED: - if (sd->call_out) - imcb_log(ic, "The user %s refused the call.", info); - else - imcb_log(ic, "You refused the call from user %s.", info); - sd->call_out = FALSE; - break; - case SKYPE_CALL_FINISHED: - if (sd->call_duration) - imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); - else - imcb_log(ic, "You finished the call to the user %s.", info); - sd->call_out = FALSE; - break; - default: - /* Don't be noisy, ignore other statuses for now. */ - break; - } - sd->call_status = 0; - } - } - } - } else if (!strncmp(line, "FILETRANSFER ", 13)) { + else if (!strncmp(line, "CALL ", 5)) + skype_parse_call(ic, line); + else if (!strncmp(line, "FILETRANSFER ", 13)) { char *id = strchr(line, ' '); if (++id) { char *info = strchr(id, ' '); -- cgit v1.2.3 From e200daf6f8f6d278ea0a3a6ccd7d4395d0a14863 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 02:26:08 +0100 Subject: introduce skype_parse_filetransfer() --- skype/skype.c | 71 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index d9f24a59..308f1041 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -654,6 +654,44 @@ static void skype_parse_call(struct im_connection *ic, char *line) } } +static void skype_parse_filetransfer(struct im_connection *ic, char *line) +{ + struct skype_data *sd = ic->proto_data; + char buf[1024]; + char *id = strchr(line, ' '); + + if (++id) { + char *info = strchr(id, ' '); + + if (!info) + return; + *info = '\0'; + info++; + if (!strcmp(info, "STATUS NEW")) { + g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->filetransfer_status = SKYPE_FILETRANSFER_NEW; + } else if (!strcmp(info, "STATUS FAILED")) { + g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED; + } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { + info += 15; + if (sd->filetransfer_status) { + switch (sd->filetransfer_status) { + case SKYPE_FILETRANSFER_NEW: + imcb_log(ic, "The user %s offered a new file for you.", info); + break; + case SKYPE_FILETRANSFER_FAILED: + imcb_log(ic, "Failed to transfer file from user %s.", info); + break; + } + sd->filetransfer_status = 0; + } + } + } +} + static gboolean skype_read_callback(gpointer data, gint fd, b_input_condition cond) { @@ -685,36 +723,9 @@ static gboolean skype_read_callback(gpointer data, gint fd, skype_parse_chatmessage(ic, line); else if (!strncmp(line, "CALL ", 5)) skype_parse_call(ic, line); - else if (!strncmp(line, "FILETRANSFER ", 13)) { - char *id = strchr(line, ' '); - if (++id) { - char *info = strchr(id, ' '); - *info = '\0'; - info++; - if (!strcmp(info, "STATUS NEW")) { - g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->filetransfer_status = SKYPE_FILETRANSFER_NEW; - } else if (!strcmp(info, "STATUS FAILED")) { - g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED; - } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { - info += 15; - if (sd->filetransfer_status) { - switch (sd->filetransfer_status) { - case SKYPE_FILETRANSFER_NEW: - imcb_log(ic, "The user %s offered a new file for you.", info); - break; - case SKYPE_FILETRANSFER_FAILED: - imcb_log(ic, "Failed to transfer file from user %s.", info); - break; - } - sd->filetransfer_status = 0; - } - } - } - } else if (!strncmp(line, "CHAT ", 5)) { + else if (!strncmp(line, "FILETRANSFER ", 13)) + skype_parse_filetransfer(ic, line); + else if (!strncmp(line, "CHAT ", 5)) { char *id = strchr(line, ' '); if (++id) { char *info = strchr(id, ' '); -- cgit v1.2.3 From c35bf7a7b8b8756ae0388e724c6fba9fe2b0feaf Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 02:29:22 +0100 Subject: introduce skype_parse_chat() --- skype/skype.c | 169 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 90 insertions(+), 79 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 308f1041..2db904c5 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -692,6 +692,93 @@ static void skype_parse_filetransfer(struct im_connection *ic, char *line) } } +static void skype_parse_chat(struct im_connection *ic, char *line) +{ + struct skype_data *sd = ic->proto_data; + char buf[1024]; + char *id = strchr(line, ' '); + + if (++id) { + struct groupchat *gc; + char *info = strchr(id, ' '); + + if (!info) + return; + *info = '\0'; + info++; + /* Remove fake chat if we created one in skype_chat_with() */ + gc = skype_chat_by_name(ic, ""); + if (gc) + imcb_chat_free(gc); + if (!strcmp(info, "STATUS MULTI_SUBSCRIBED")) { + imcb_chat_new(ic, id); + g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); + skype_write(ic, buf); + g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); + skype_write(ic, buf); + } else if (!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) { + gc = imcb_chat_new(ic, id); + /* According to the docs this + * is necessary. However it + * does not seem the situation + * and it would open an extra + * window on our client, so + * just leave it out. */ + /*g_snprintf(buf, 1024, "OPEN CHAT %s\n", id); + skype_write(ic, buf);*/ + g_snprintf(buf, 1024, "%s@skype.com", sd->groupchat_with); + imcb_chat_add_buddy(gc, buf); + imcb_chat_add_buddy(gc, sd->username); + g_free(sd->groupchat_with); + sd->groupchat_with = NULL; + g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); + skype_write(ic, buf); + g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); + skype_write(ic, buf); + } else if (!strcmp(info, "STATUS UNSUBSCRIBED")) { + gc = skype_chat_by_name(ic, id); + if (gc) + gc->data = (void *)FALSE; + } else if (!strncmp(info, "ADDER ", 6)) { + info += 6; + g_free(sd->adder); + sd->adder = g_strdup_printf("%s@skype.com", info); + } else if (!strncmp(info, "TOPIC ", 6)) { + info += 6; + gc = skype_chat_by_name(ic, id); + if (gc && (sd->adder || sd->topic_wait)) { + if (sd->topic_wait) { + sd->adder = g_strdup(sd->username); + sd->topic_wait = 0; + } + imcb_chat_topic(gc, sd->adder, info, 0); + g_free(sd->adder); + sd->adder = NULL; + } + } else if (!strncmp(info, "ACTIVEMEMBERS ", 14)) { + info += 14; + gc = skype_chat_by_name(ic, id); + /* Hack! We set ->data to TRUE + * while we're on the channel + * so that we won't rejoin + * after a /part. */ + if (gc && !gc->data) { + char **members = g_strsplit(info, " ", 0); + int i; + for (i = 0; members[i]; i++) { + if (!strcmp(members[i], sd->username)) + continue; + g_snprintf(buf, 1024, "%s@skype.com", members[i]); + if (!g_list_find_custom(gc->in_room, buf, (GCompareFunc)strcmp)) + imcb_chat_add_buddy(gc, buf); + } + imcb_chat_add_buddy(gc, sd->username); + g_strfreev(members); + } + } + } +} + static gboolean skype_read_callback(gpointer data, gint fd, b_input_condition cond) { @@ -725,85 +812,9 @@ static gboolean skype_read_callback(gpointer data, gint fd, skype_parse_call(ic, line); else if (!strncmp(line, "FILETRANSFER ", 13)) skype_parse_filetransfer(ic, line); - else if (!strncmp(line, "CHAT ", 5)) { - char *id = strchr(line, ' '); - if (++id) { - char *info = strchr(id, ' '); - if (info) - *info = '\0'; - info++; - /* Remove fake chat if we created one in skype_chat_with() */ - struct groupchat *gc = skype_chat_by_name(ic, ""); - if (gc) - imcb_chat_free(gc); - if (!strcmp(info, "STATUS MULTI_SUBSCRIBED")) { - imcb_chat_new(ic, id); - g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); - skype_write(ic, buf); - g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); - skype_write(ic, buf); - } else if (!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) { - gc = imcb_chat_new(ic, id); - /* According to the docs this - * is necessary. However it - * does not seem the situation - * and it would open an extra - * window on our client, so - * just leave it out. */ - /*g_snprintf(buf, 1024, "OPEN CHAT %s\n", id); - skype_write(ic, buf);*/ - g_snprintf(buf, 1024, "%s@skype.com", sd->groupchat_with); - imcb_chat_add_buddy(gc, buf); - imcb_chat_add_buddy(gc, sd->username); - g_free(sd->groupchat_with); - sd->groupchat_with = NULL; - g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); - skype_write(ic, buf); - g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); - skype_write(ic, buf); - } else if (!strcmp(info, "STATUS UNSUBSCRIBED")) { - gc = skype_chat_by_name(ic, id); - if (gc) - gc->data = (void *)FALSE; - } else if (!strncmp(info, "ADDER ", 6)) { - info += 6; - g_free(sd->adder); - sd->adder = g_strdup_printf("%s@skype.com", info); - } else if (!strncmp(info, "TOPIC ", 6)) { - info += 6; - gc = skype_chat_by_name(ic, id); - if (gc && (sd->adder || sd->topic_wait)) { - if (sd->topic_wait) { - sd->adder = g_strdup(sd->username); - sd->topic_wait = 0; - } - imcb_chat_topic(gc, sd->adder, info, 0); - g_free(sd->adder); - sd->adder = NULL; - } - } else if (!strncmp(info, "ACTIVEMEMBERS ", 14)) { - info += 14; - gc = skype_chat_by_name(ic, id); - /* Hack! We set ->data to TRUE - * while we're on the channel - * so that we won't rejoin - * after a /part. */ - if (gc && !gc->data) { - char **members = g_strsplit(info, " ", 0); - int i; - for (i = 0; members[i]; i++) { - if (!strcmp(members[i], sd->username)) - continue; - g_snprintf(buf, 1024, "%s@skype.com", members[i]); - if (!g_list_find_custom(gc->in_room, buf, (GCompareFunc)strcmp)) - imcb_chat_add_buddy(gc, buf); - } - imcb_chat_add_buddy(gc, sd->username); - g_strfreev(members); - } - } - } - } else if (!strncmp(line, "PASSWORD ", 9)) { + else if (!strncmp(line, "CHAT ", 5)) + skype_parse_chat(ic, line); + else if (!strncmp(line, "PASSWORD ", 9)) { if (!strncmp(line+9, "OK", 2)) imcb_connected(ic); else { -- cgit v1.2.3 From 2709f4c2bcc1425e224e1dd917923a40b084746d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 02:31:38 +0100 Subject: introduce skype_parse_password() --- skype/skype.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 2db904c5..9b1ebb58 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -779,6 +779,16 @@ static void skype_parse_chat(struct im_connection *ic, char *line) } } +static void skype_parse_password(struct im_connection *ic, char *line) +{ + if (!strncmp(line+9, "OK", 2)) + imcb_connected(ic); + else { + imcb_error(ic, "Authentication Failed"); + imc_logout(ic, TRUE); + } +} + static gboolean skype_read_callback(gpointer data, gint fd, b_input_condition cond) { @@ -815,12 +825,7 @@ static gboolean skype_read_callback(gpointer data, gint fd, else if (!strncmp(line, "CHAT ", 5)) skype_parse_chat(ic, line); else if (!strncmp(line, "PASSWORD ", 9)) { - if (!strncmp(line+9, "OK", 2)) - imcb_connected(ic); - else { - imcb_error(ic, "Authentication Failed"); - imc_logout(ic, TRUE); - } + skype_parse_password(ic, line); } else if (!strncmp(line, "PROFILE PSTN_BALANCE ", 21)) imcb_log(ic, "SkypeOut balance value is '%s'.", line+21); else if (!strncmp(line, "PING", 4)) { -- cgit v1.2.3 From 607f5e3ad13d20fe4788c0d5bda94578a033ccab Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 02:35:44 +0100 Subject: introduce skype_parse_profile()/skype_parse_ping()/skype_parse_chats() with this checkpatch now reports only 55 ws errors, compared to 182 --- skype/skype.c | 54 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 9b1ebb58..4df800d8 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -789,6 +789,33 @@ static void skype_parse_password(struct im_connection *ic, char *line) } } +static void skype_parse_profile(struct im_connection *ic, char *line) +{ + imcb_log(ic, "SkypeOut balance value is '%s'.", line+21); +} + +static void skype_parse_ping(struct im_connection *ic, char *line) +{ + skype_write(ic, "PONG\n"); +} + +static void skype_parse_chats(struct im_connection *ic, char *line) +{ + char buf[1024]; + char **i; + char **chats = g_strsplit(line + 6, ", ", 0); + + i = chats; + while (*i) { + g_snprintf(buf, 1024, "GET CHAT %s STATUS\n", *i); + skype_write(ic, buf); + g_snprintf(buf, 1024, "GET CHAT %s ACTIVEMEMBERS\n", *i); + skype_write(ic, buf); + i++; + } + g_strfreev(chats); +} + static gboolean skype_read_callback(gpointer data, gint fd, b_input_condition cond) { @@ -824,27 +851,14 @@ static gboolean skype_read_callback(gpointer data, gint fd, skype_parse_filetransfer(ic, line); else if (!strncmp(line, "CHAT ", 5)) skype_parse_chat(ic, line); - else if (!strncmp(line, "PASSWORD ", 9)) { + else if (!strncmp(line, "PASSWORD ", 9)) skype_parse_password(ic, line); - } else if (!strncmp(line, "PROFILE PSTN_BALANCE ", 21)) - imcb_log(ic, "SkypeOut balance value is '%s'.", line+21); - else if (!strncmp(line, "PING", 4)) { - g_snprintf(buf, 1024, "PONG\n"); - skype_write(ic, buf); - } else if (!strncmp(line, "CHATS ", 6)) { - char **i; - char **chats = g_strsplit(line + 6, ", ", 0); - - i = chats; - while (*i) { - g_snprintf(buf, 1024, "GET CHAT %s STATUS\n", *i); - skype_write(ic, buf); - g_snprintf(buf, 1024, "GET CHAT %s ACTIVEMEMBERS\n", *i); - skype_write(ic, buf); - i++; - } - g_strfreev(chats); - } + else if (!strncmp(line, "PROFILE PSTN_BALANCE ", 21)) + skype_parse_profile(ic, line); + else if (!strncmp(line, "PING", 4)) + skype_parse_ping(ic, line); + else if (!strncmp(line, "CHATS ", 6)) + skype_parse_chats(ic, line); lineptr++; } g_strfreev(lines); -- cgit v1.2.3 From ff436bab025f8b23f4518f77b34c0449f0182601 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 02:56:18 +0100 Subject: introduce the parse_map struct --- skype/skype.c | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 4df800d8..f4627af2 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -32,6 +32,7 @@ #define SKYPE_DEFAULT_SERVER "localhost" #define SKYPE_DEFAULT_PORT "2727" +#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) /* * Enumerations @@ -816,14 +817,31 @@ static void skype_parse_chats(struct im_connection *ic, char *line) g_strfreev(chats); } +typedef void (*skype_parser)(struct im_connection *ic, char *line); + static gboolean skype_read_callback(gpointer data, gint fd, b_input_condition cond) { struct im_connection *ic = data; struct skype_data *sd = ic->proto_data; char buf[1024]; - int st; + int st, i; char **lines, **lineptr, *line; + static struct parse_map { + char *k; + skype_parser v; + } parsers[] = { + { "USERS ", skype_parse_users }, + { "USER ", skype_parse_user }, + { "CHATMESSAGE ", skype_parse_chatmessage }, + { "CALL ", skype_parse_call }, + { "FILETRANSFER ", skype_parse_filetransfer }, + { "CHAT ", skype_parse_chat }, + { "PASSWORD ", skype_parse_password }, + { "PROFILE PSTN_BALANCE ", skype_parse_profile }, + { "PING", skype_parse_ping }, + { "CHATS ", skype_parse_chats }, + }; if (!sd || sd->fd == -1) return FALSE; @@ -839,26 +857,12 @@ static gboolean skype_read_callback(gpointer data, gint fd, break; if (set_getbool(&ic->acc->set, "skypeconsole_receive")) imcb_buddy_msg(ic, "skypeconsole", line, 0, 0); - if (!strncmp(line, "USERS ", 6)) - skype_parse_users(ic, line); - else if (!strncmp(line, "USER ", 5)) - skype_parse_user(ic, line); - else if (!strncmp(line, "CHATMESSAGE ", 12)) - skype_parse_chatmessage(ic, line); - else if (!strncmp(line, "CALL ", 5)) - skype_parse_call(ic, line); - else if (!strncmp(line, "FILETRANSFER ", 13)) - skype_parse_filetransfer(ic, line); - else if (!strncmp(line, "CHAT ", 5)) - skype_parse_chat(ic, line); - else if (!strncmp(line, "PASSWORD ", 9)) - skype_parse_password(ic, line); - else if (!strncmp(line, "PROFILE PSTN_BALANCE ", 21)) - skype_parse_profile(ic, line); - else if (!strncmp(line, "PING", 4)) - skype_parse_ping(ic, line); - else if (!strncmp(line, "CHATS ", 6)) - skype_parse_chats(ic, line); + for (i = 0; i < ARRAY_SIZE(parsers); i++) { + if (!strncmp(line, parsers[i].k, strlen(parsers[i].k))) { + parsers[i].v(ic, line); + break; + } + } lineptr++; } g_strfreev(lines); -- cgit v1.2.3 From 9580a6fb235580f333d0913ddcdcf574e92bbd59 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 03:02:20 +0100 Subject: whitespace, fixes checkpatch errors --- skype/skype.c | 78 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index f4627af2..bece96ab 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -615,39 +615,39 @@ static void skype_parse_call(struct im_connection *ic, char *line) info += 15; if (sd->call_status) { switch (sd->call_status) { - case SKYPE_CALL_RINGING: - if (sd->call_out) - imcb_log(ic, "You are currently ringing the user %s.", info); - else { - g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); - skype_call_ask(ic, sd->call_id, buf); - } - break; - case SKYPE_CALL_MISSED: - imcb_log(ic, "You have missed a call from user %s.", info); - break; - case SKYPE_CALL_CANCELLED: - imcb_log(ic, "You cancelled the call to the user %s.", info); - sd->call_status = 0; - sd->call_out = FALSE; - break; - case SKYPE_CALL_REFUSED: - if (sd->call_out) - imcb_log(ic, "The user %s refused the call.", info); - else - imcb_log(ic, "You refused the call from user %s.", info); - sd->call_out = FALSE; - break; - case SKYPE_CALL_FINISHED: - if (sd->call_duration) - imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); - else - imcb_log(ic, "You finished the call to the user %s.", info); - sd->call_out = FALSE; - break; - default: - /* Don't be noisy, ignore other statuses for now. */ - break; + case SKYPE_CALL_RINGING: + if (sd->call_out) + imcb_log(ic, "You are currently ringing the user %s.", info); + else { + g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); + skype_call_ask(ic, sd->call_id, buf); + } + break; + case SKYPE_CALL_MISSED: + imcb_log(ic, "You have missed a call from user %s.", info); + break; + case SKYPE_CALL_CANCELLED: + imcb_log(ic, "You cancelled the call to the user %s.", info); + sd->call_status = 0; + sd->call_out = FALSE; + break; + case SKYPE_CALL_REFUSED: + if (sd->call_out) + imcb_log(ic, "The user %s refused the call.", info); + else + imcb_log(ic, "You refused the call from user %s.", info); + sd->call_out = FALSE; + break; + case SKYPE_CALL_FINISHED: + if (sd->call_duration) + imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); + else + imcb_log(ic, "You finished the call to the user %s.", info); + sd->call_out = FALSE; + break; + default: + /* Don't be noisy, ignore other statuses for now. */ + break; } sd->call_status = 0; } @@ -680,12 +680,12 @@ static void skype_parse_filetransfer(struct im_connection *ic, char *line) info += 15; if (sd->filetransfer_status) { switch (sd->filetransfer_status) { - case SKYPE_FILETRANSFER_NEW: - imcb_log(ic, "The user %s offered a new file for you.", info); - break; - case SKYPE_FILETRANSFER_FAILED: - imcb_log(ic, "Failed to transfer file from user %s.", info); - break; + case SKYPE_FILETRANSFER_NEW: + imcb_log(ic, "The user %s offered a new file for you.", info); + break; + case SKYPE_FILETRANSFER_FAILED: + imcb_log(ic, "Failed to transfer file from user %s.", info); + break; } sd->filetransfer_status = 0; } -- cgit v1.2.3 From 6b9d22abe0ef2ccdc06eced1e82eb8ef35b6d1ed Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 03:10:29 +0100 Subject: remove unnecessary big if blocks, use return instead --- skype/skype.c | 514 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 257 insertions(+), 257 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index bece96ab..5f79b82c 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -481,81 +481,81 @@ static void skype_parse_chatmessage(struct im_connection *ic, char *line) char buf[1024]; char *id = strchr(line, ' '); - if (++id) { - char *info = strchr(id, ' '); - - if (!info) - return; - *info = '\0'; - info++; - if (!strcmp(info, "STATUS RECEIVED")) { - /* New message ID: - * (1) Request its from field - * (2) Request its body - * (3) Request its type - * (4) Query chatname - */ - g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id); - skype_write(ic, buf); - g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); - skype_write(ic, buf); - g_snprintf(buf, 1024, "GET CHATMESSAGE %s TYPE\n", id); - skype_write(ic, buf); - g_snprintf(buf, 1024, "GET CHATMESSAGE %s CHATNAME\n", id); - skype_write(ic, buf); - } else if (!strncmp(info, "FROM_HANDLE ", 12)) { - info += 12; - /* New from field value. Store - * it, then we can later use it - * when we got the message's - * body. */ - g_free(sd->handle); - sd->handle = g_strdup_printf("%s@skype.com", info); - } else if (!strncmp(info, "EDITED_BY ", 10)) { - info += 10; - /* This is the same as - * FROM_HANDLE, except that we - * never request these lines - * from Skype, we just get - * them. */ - g_free(sd->handle); - sd->handle = g_strdup_printf("%s@skype.com", info); - } else if (!strncmp(info, "BODY ", 5)) { - info += 5; - sd->body = g_list_append(sd->body, g_strdup(info)); - } else if (!strncmp(info, "TYPE ", 5)) { - info += 5; - g_free(sd->type); - sd->type = g_strdup(info); - } else if (!strncmp(info, "CHATNAME ", 9)) { - info += 9; - if (sd->handle && sd->body && sd->type) { - struct groupchat *gc = skype_chat_by_name(ic, info); - int i; - for (i = 0; i < g_list_length(sd->body); i++) { - char *body = g_list_nth_data(sd->body, i); - if (!strcmp(sd->type, "SAID") || !strcmp(sd->type, "EMOTED")) { - if (!strcmp(sd->type, "SAID")) - g_snprintf(buf, 1024, "%s", body); - else - g_snprintf(buf, 1024, "/me %s", body); - if (!gc) - /* Private message */ - imcb_buddy_msg(ic, sd->handle, buf, 0, 0); - else - /* Groupchat message */ - imcb_chat_msg(gc, sd->handle, buf, 0, 0); - } else if (!strcmp(sd->type, "SETTOPIC")) { - if (gc) - imcb_chat_topic(gc, sd->handle, body, 0); - } else if (!strcmp(sd->type, "LEFT")) { - if (gc) - imcb_chat_remove_buddy(gc, sd->handle, NULL); - } + if (!++id) + return; + char *info = strchr(id, ' '); + + if (!info) + return; + *info = '\0'; + info++; + if (!strcmp(info, "STATUS RECEIVED")) { + /* New message ID: + * (1) Request its from field + * (2) Request its body + * (3) Request its type + * (4) Query chatname + */ + g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id); + skype_write(ic, buf); + g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); + skype_write(ic, buf); + g_snprintf(buf, 1024, "GET CHATMESSAGE %s TYPE\n", id); + skype_write(ic, buf); + g_snprintf(buf, 1024, "GET CHATMESSAGE %s CHATNAME\n", id); + skype_write(ic, buf); + } else if (!strncmp(info, "FROM_HANDLE ", 12)) { + info += 12; + /* New from field value. Store + * it, then we can later use it + * when we got the message's + * body. */ + g_free(sd->handle); + sd->handle = g_strdup_printf("%s@skype.com", info); + } else if (!strncmp(info, "EDITED_BY ", 10)) { + info += 10; + /* This is the same as + * FROM_HANDLE, except that we + * never request these lines + * from Skype, we just get + * them. */ + g_free(sd->handle); + sd->handle = g_strdup_printf("%s@skype.com", info); + } else if (!strncmp(info, "BODY ", 5)) { + info += 5; + sd->body = g_list_append(sd->body, g_strdup(info)); + } else if (!strncmp(info, "TYPE ", 5)) { + info += 5; + g_free(sd->type); + sd->type = g_strdup(info); + } else if (!strncmp(info, "CHATNAME ", 9)) { + info += 9; + if (sd->handle && sd->body && sd->type) { + struct groupchat *gc = skype_chat_by_name(ic, info); + int i; + for (i = 0; i < g_list_length(sd->body); i++) { + char *body = g_list_nth_data(sd->body, i); + if (!strcmp(sd->type, "SAID") || !strcmp(sd->type, "EMOTED")) { + if (!strcmp(sd->type, "SAID")) + g_snprintf(buf, 1024, "%s", body); + else + g_snprintf(buf, 1024, "/me %s", body); + if (!gc) + /* Private message */ + imcb_buddy_msg(ic, sd->handle, buf, 0, 0); + else + /* Groupchat message */ + imcb_chat_msg(gc, sd->handle, buf, 0, 0); + } else if (!strcmp(sd->type, "SETTOPIC")) { + if (gc) + imcb_chat_topic(gc, sd->handle, body, 0); + } else if (!strcmp(sd->type, "LEFT")) { + if (gc) + imcb_chat_remove_buddy(gc, sd->handle, NULL); } - g_list_free(sd->body); - sd->body = NULL; } + g_list_free(sd->body); + sd->body = NULL; } } } @@ -566,91 +566,91 @@ static void skype_parse_call(struct im_connection *ic, char *line) char *id = strchr(line, ' '); char buf[1024]; - if (++id) { - char *info = strchr(id, ' '); - - if (!info) - return; - *info = '\0'; - info++; - if (!strncmp(info, "FAILUREREASON ", 14)) - sd->failurereason = atoi(strchr(info, ' ')); - else if (!strcmp(info, "STATUS RINGING")) { - if (sd->call_id) - g_free(sd->call_id); - sd->call_id = g_strdup(id); - g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->call_status = SKYPE_CALL_RINGING; - } else if (!strcmp(info, "STATUS MISSED")) { - g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->call_status = SKYPE_CALL_MISSED; - } else if (!strcmp(info, "STATUS CANCELLED")) { - g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->call_status = SKYPE_CALL_CANCELLED; - } else if (!strcmp(info, "STATUS FINISHED")) { - g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->call_status = SKYPE_CALL_FINISHED; - } else if (!strcmp(info, "STATUS REFUSED")) { - g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->call_status = SKYPE_CALL_REFUSED; - } else if (!strcmp(info, "STATUS UNPLACED")) { - if (sd->call_id) - g_free(sd->call_id); - /* Save the ID for later usage (Cancel/Finish). */ - sd->call_id = g_strdup(id); - sd->call_out = TRUE; - } else if (!strcmp(info, "STATUS FAILED")) { - imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason)); - sd->call_id = NULL; - } else if (!strncmp(info, "DURATION ", 9)) { - if (sd->call_duration) - g_free(sd->call_duration); - sd->call_duration = g_strdup(info+9); - } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { - info += 15; - if (sd->call_status) { - switch (sd->call_status) { - case SKYPE_CALL_RINGING: - if (sd->call_out) - imcb_log(ic, "You are currently ringing the user %s.", info); - else { - g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); - skype_call_ask(ic, sd->call_id, buf); - } - break; - case SKYPE_CALL_MISSED: - imcb_log(ic, "You have missed a call from user %s.", info); - break; - case SKYPE_CALL_CANCELLED: - imcb_log(ic, "You cancelled the call to the user %s.", info); - sd->call_status = 0; - sd->call_out = FALSE; - break; - case SKYPE_CALL_REFUSED: - if (sd->call_out) - imcb_log(ic, "The user %s refused the call.", info); - else - imcb_log(ic, "You refused the call from user %s.", info); - sd->call_out = FALSE; - break; - case SKYPE_CALL_FINISHED: - if (sd->call_duration) - imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); - else - imcb_log(ic, "You finished the call to the user %s.", info); - sd->call_out = FALSE; - break; - default: - /* Don't be noisy, ignore other statuses for now. */ - break; + if (!++id) + return; + char *info = strchr(id, ' '); + + if (!info) + return; + *info = '\0'; + info++; + if (!strncmp(info, "FAILUREREASON ", 14)) + sd->failurereason = atoi(strchr(info, ' ')); + else if (!strcmp(info, "STATUS RINGING")) { + if (sd->call_id) + g_free(sd->call_id); + sd->call_id = g_strdup(id); + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->call_status = SKYPE_CALL_RINGING; + } else if (!strcmp(info, "STATUS MISSED")) { + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->call_status = SKYPE_CALL_MISSED; + } else if (!strcmp(info, "STATUS CANCELLED")) { + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->call_status = SKYPE_CALL_CANCELLED; + } else if (!strcmp(info, "STATUS FINISHED")) { + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->call_status = SKYPE_CALL_FINISHED; + } else if (!strcmp(info, "STATUS REFUSED")) { + g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->call_status = SKYPE_CALL_REFUSED; + } else if (!strcmp(info, "STATUS UNPLACED")) { + if (sd->call_id) + g_free(sd->call_id); + /* Save the ID for later usage (Cancel/Finish). */ + sd->call_id = g_strdup(id); + sd->call_out = TRUE; + } else if (!strcmp(info, "STATUS FAILED")) { + imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason)); + sd->call_id = NULL; + } else if (!strncmp(info, "DURATION ", 9)) { + if (sd->call_duration) + g_free(sd->call_duration); + sd->call_duration = g_strdup(info+9); + } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { + info += 15; + if (sd->call_status) { + switch (sd->call_status) { + case SKYPE_CALL_RINGING: + if (sd->call_out) + imcb_log(ic, "You are currently ringing the user %s.", info); + else { + g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); + skype_call_ask(ic, sd->call_id, buf); } + break; + case SKYPE_CALL_MISSED: + imcb_log(ic, "You have missed a call from user %s.", info); + break; + case SKYPE_CALL_CANCELLED: + imcb_log(ic, "You cancelled the call to the user %s.", info); sd->call_status = 0; + sd->call_out = FALSE; + break; + case SKYPE_CALL_REFUSED: + if (sd->call_out) + imcb_log(ic, "The user %s refused the call.", info); + else + imcb_log(ic, "You refused the call from user %s.", info); + sd->call_out = FALSE; + break; + case SKYPE_CALL_FINISHED: + if (sd->call_duration) + imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); + else + imcb_log(ic, "You finished the call to the user %s.", info); + sd->call_out = FALSE; + break; + default: + /* Don't be noisy, ignore other statuses for now. */ + break; } + sd->call_status = 0; } } } @@ -661,34 +661,34 @@ static void skype_parse_filetransfer(struct im_connection *ic, char *line) char buf[1024]; char *id = strchr(line, ' '); - if (++id) { - char *info = strchr(id, ' '); + if (!++id) + return; + char *info = strchr(id, ' '); - if (!info) - return; - *info = '\0'; - info++; - if (!strcmp(info, "STATUS NEW")) { - g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->filetransfer_status = SKYPE_FILETRANSFER_NEW; - } else if (!strcmp(info, "STATUS FAILED")) { - g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); - skype_write(ic, buf); - sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED; - } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { - info += 15; - if (sd->filetransfer_status) { - switch (sd->filetransfer_status) { - case SKYPE_FILETRANSFER_NEW: - imcb_log(ic, "The user %s offered a new file for you.", info); - break; - case SKYPE_FILETRANSFER_FAILED: - imcb_log(ic, "Failed to transfer file from user %s.", info); - break; - } - sd->filetransfer_status = 0; + if (!info) + return; + *info = '\0'; + info++; + if (!strcmp(info, "STATUS NEW")) { + g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->filetransfer_status = SKYPE_FILETRANSFER_NEW; + } else if (!strcmp(info, "STATUS FAILED")) { + g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); + skype_write(ic, buf); + sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED; + } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { + info += 15; + if (sd->filetransfer_status) { + switch (sd->filetransfer_status) { + case SKYPE_FILETRANSFER_NEW: + imcb_log(ic, "The user %s offered a new file for you.", info); + break; + case SKYPE_FILETRANSFER_FAILED: + imcb_log(ic, "Failed to transfer file from user %s.", info); + break; } + sd->filetransfer_status = 0; } } } @@ -699,83 +699,83 @@ static void skype_parse_chat(struct im_connection *ic, char *line) char buf[1024]; char *id = strchr(line, ' '); - if (++id) { - struct groupchat *gc; - char *info = strchr(id, ' '); + if (!++id) + return; + struct groupchat *gc; + char *info = strchr(id, ' '); - if (!info) - return; - *info = '\0'; - info++; - /* Remove fake chat if we created one in skype_chat_with() */ - gc = skype_chat_by_name(ic, ""); + if (!info) + return; + *info = '\0'; + info++; + /* Remove fake chat if we created one in skype_chat_with() */ + gc = skype_chat_by_name(ic, ""); + if (gc) + imcb_chat_free(gc); + if (!strcmp(info, "STATUS MULTI_SUBSCRIBED")) { + imcb_chat_new(ic, id); + g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); + skype_write(ic, buf); + g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); + skype_write(ic, buf); + } else if (!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) { + gc = imcb_chat_new(ic, id); + /* According to the docs this + * is necessary. However it + * does not seem the situation + * and it would open an extra + * window on our client, so + * just leave it out. */ + /*g_snprintf(buf, 1024, "OPEN CHAT %s\n", id); + skype_write(ic, buf);*/ + g_snprintf(buf, 1024, "%s@skype.com", sd->groupchat_with); + imcb_chat_add_buddy(gc, buf); + imcb_chat_add_buddy(gc, sd->username); + g_free(sd->groupchat_with); + sd->groupchat_with = NULL; + g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); + skype_write(ic, buf); + g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); + skype_write(ic, buf); + } else if (!strcmp(info, "STATUS UNSUBSCRIBED")) { + gc = skype_chat_by_name(ic, id); if (gc) - imcb_chat_free(gc); - if (!strcmp(info, "STATUS MULTI_SUBSCRIBED")) { - imcb_chat_new(ic, id); - g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); - skype_write(ic, buf); - g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); - skype_write(ic, buf); - } else if (!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) { - gc = imcb_chat_new(ic, id); - /* According to the docs this - * is necessary. However it - * does not seem the situation - * and it would open an extra - * window on our client, so - * just leave it out. */ - /*g_snprintf(buf, 1024, "OPEN CHAT %s\n", id); - skype_write(ic, buf);*/ - g_snprintf(buf, 1024, "%s@skype.com", sd->groupchat_with); - imcb_chat_add_buddy(gc, buf); - imcb_chat_add_buddy(gc, sd->username); - g_free(sd->groupchat_with); - sd->groupchat_with = NULL; - g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); - skype_write(ic, buf); - g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); - skype_write(ic, buf); - } else if (!strcmp(info, "STATUS UNSUBSCRIBED")) { - gc = skype_chat_by_name(ic, id); - if (gc) - gc->data = (void *)FALSE; - } else if (!strncmp(info, "ADDER ", 6)) { - info += 6; - g_free(sd->adder); - sd->adder = g_strdup_printf("%s@skype.com", info); - } else if (!strncmp(info, "TOPIC ", 6)) { - info += 6; - gc = skype_chat_by_name(ic, id); - if (gc && (sd->adder || sd->topic_wait)) { - if (sd->topic_wait) { - sd->adder = g_strdup(sd->username); - sd->topic_wait = 0; - } - imcb_chat_topic(gc, sd->adder, info, 0); - g_free(sd->adder); - sd->adder = NULL; + gc->data = (void *)FALSE; + } else if (!strncmp(info, "ADDER ", 6)) { + info += 6; + g_free(sd->adder); + sd->adder = g_strdup_printf("%s@skype.com", info); + } else if (!strncmp(info, "TOPIC ", 6)) { + info += 6; + gc = skype_chat_by_name(ic, id); + if (gc && (sd->adder || sd->topic_wait)) { + if (sd->topic_wait) { + sd->adder = g_strdup(sd->username); + sd->topic_wait = 0; } - } else if (!strncmp(info, "ACTIVEMEMBERS ", 14)) { - info += 14; - gc = skype_chat_by_name(ic, id); - /* Hack! We set ->data to TRUE - * while we're on the channel - * so that we won't rejoin - * after a /part. */ - if (gc && !gc->data) { - char **members = g_strsplit(info, " ", 0); - int i; - for (i = 0; members[i]; i++) { - if (!strcmp(members[i], sd->username)) - continue; - g_snprintf(buf, 1024, "%s@skype.com", members[i]); - if (!g_list_find_custom(gc->in_room, buf, (GCompareFunc)strcmp)) - imcb_chat_add_buddy(gc, buf); - } - imcb_chat_add_buddy(gc, sd->username); - g_strfreev(members); + imcb_chat_topic(gc, sd->adder, info, 0); + g_free(sd->adder); + sd->adder = NULL; + } + } else if (!strncmp(info, "ACTIVEMEMBERS ", 14)) { + info += 14; + gc = skype_chat_by_name(ic, id); + /* Hack! We set ->data to TRUE + * while we're on the channel + * so that we won't rejoin + * after a /part. */ + if (gc && !gc->data) { + char **members = g_strsplit(info, " ", 0); + int i; + for (i = 0; members[i]; i++) { + if (!strcmp(members[i], sd->username)) + continue; + g_snprintf(buf, 1024, "%s@skype.com", members[i]); + if (!g_list_find_custom(gc->in_room, buf, (GCompareFunc)strcmp)) + imcb_chat_add_buddy(gc, buf); } + imcb_chat_add_buddy(gc, sd->username); + g_strfreev(members); } } } @@ -857,12 +857,12 @@ static gboolean skype_read_callback(gpointer data, gint fd, break; if (set_getbool(&ic->acc->set, "skypeconsole_receive")) imcb_buddy_msg(ic, "skypeconsole", line, 0, 0); - for (i = 0; i < ARRAY_SIZE(parsers); i++) { - if (!strncmp(line, parsers[i].k, strlen(parsers[i].k))) { + for (i = 0; i < ARRAY_SIZE(parsers); i++) + if (!strncmp(line, parsers[i].k, + strlen(parsers[i].k))) { parsers[i].v(ic, line); break; } - } lineptr++; } g_strfreev(lines); -- cgit v1.2.3 From 62f51ee9e0bac8184fa140fe46f2ca4a2d84038e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 03:29:07 +0100 Subject: last whitespace fixes - checkpatch is now happy ;) - hit me, i also seem to correct away status handling (it set away when the user was online|skype and not the opposite) --- skype/skype.c | 223 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 132 insertions(+), 91 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 5f79b82c..3414c901 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -306,9 +306,10 @@ static void skype_parse_user(struct im_connection *ic, char *line) && strcmp(user, "echo123") != 0) { ptr = g_strdup_printf("%s@skype.com", user); imcb_add_buddy(ic, ptr, NULL); - if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") || !set_getbool(&ic->acc->set, "skypeout_offline"))) + if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") || + !set_getbool(&ic->acc->set, "skypeout_offline"))) flags |= OPT_LOGGED_IN; - if (strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0) + if (strcmp(status, "ONLINE") && strcmp(status, "SKYPEME")) flags |= OPT_AWAY; imcb_buddy_status(ic, ptr, flags, NULL, NULL); g_free(ptr); @@ -358,28 +359,33 @@ static void skype_parse_user(struct im_connection *ic, char *line) g_string_append_printf(st, "Skype Name: %s\n", user); if (sd->info_fullname) { if (strlen(sd->info_fullname)) - g_string_append_printf(st, "Full Name: %s\n", sd->info_fullname); + g_string_append_printf(st, "Full Name: %s\n", + sd->info_fullname); g_free(sd->info_fullname); } if (sd->info_phonehome) { if (strlen(sd->info_phonehome)) - g_string_append_printf(st, "Home Phone: %s\n", sd->info_phonehome); + g_string_append_printf(st, "Home Phone: %s\n", + sd->info_phonehome); g_free(sd->info_phonehome); } if (sd->info_phoneoffice) { if (strlen(sd->info_phoneoffice)) - g_string_append_printf(st, "Office Phone: %s\n", sd->info_phoneoffice); + g_string_append_printf(st, "Office Phone: %s\n", + sd->info_phoneoffice); g_free(sd->info_phoneoffice); } if (sd->info_phonemobile) { if (strlen(sd->info_phonemobile)) - g_string_append_printf(st, "Mobile Phone: %s\n", sd->info_phonemobile); + g_string_append_printf(st, "Mobile Phone: %s\n", + sd->info_phonemobile); g_free(sd->info_phonemobile); } g_string_append_printf(st, "Personal Information\n"); if (sd->info_nrbuddies) { if (strlen(sd->info_nrbuddies)) - g_string_append_printf(st, "Contacts: %s\n", sd->info_nrbuddies); + g_string_append_printf(st, + "Contacts: %s\n", sd->info_nrbuddies); g_free(sd->info_nrbuddies); } if (sd->info_tz) { @@ -389,7 +395,8 @@ static void skype_parse_user(struct im_connection *ic, char *line) t += atoi(sd->info_tz)-(60*60*24); struct tm *gt = gmtime(&t); strftime(ib, 256, "%H:%M:%S", gt); - g_string_append_printf(st, "Local Time: %s\n", ib); + g_string_append_printf(st, + "Local Time: %s\n", ib); } g_free(sd->info_tz); } @@ -399,23 +406,27 @@ static void skype_parse_user(struct im_connection *ic, char *line) time_t it = atoi(sd->info_seen); struct tm *tm = localtime(&it); strftime(ib, 256, ("%Y. %m. %d. %H:%M"), tm); - g_string_append_printf(st, "Last Seen: %s\n", ib); + g_string_append_printf(st, + "Last Seen: %s\n", ib); } g_free(sd->info_seen); } if (sd->info_birthday) { - if (strlen(sd->info_birthday) && strcmp(sd->info_birthday, "0")) { + if (strlen(sd->info_birthday) && + strcmp(sd->info_birthday, "0")) { char ib[256]; struct tm tm; strptime(sd->info_birthday, "%Y%m%d", &tm); strftime(ib, 256, "%B %d, %Y", &tm); - g_string_append_printf(st, "Birthday: %s\n", ib); + g_string_append_printf(st, + "Birthday: %s\n", ib); strftime(ib, 256, "%Y", &tm); int year = atoi(ib); time_t t = time(NULL); struct tm *lt = localtime(&t); - g_string_append_printf(st, "Age: %d\n", lt->tm_year+1900-year); + g_string_append_printf(st, + "Age: %d\n", lt->tm_year+1900-year); } g_free(sd->info_birthday); } @@ -424,7 +435,8 @@ static void skype_parse_user(struct im_connection *ic, char *line) char *iptr = sd->info_sex; while (*iptr++) *iptr = tolower(*iptr); - g_string_append_printf(st, "Gender: %s\n", sd->info_sex); + g_string_append_printf(st, + "Gender: %s\n", sd->info_sex); } g_free(sd->info_sex); } @@ -435,7 +447,8 @@ static void skype_parse_user(struct im_connection *ic, char *line) iptr++; else iptr = sd->info_language; - g_string_append_printf(st, "Language: %s\n", iptr); + g_string_append_printf(st, + "Language: %s\n", iptr); } g_free(sd->info_language); } @@ -446,28 +459,33 @@ static void skype_parse_user(struct im_connection *ic, char *line) iptr++; else iptr = sd->info_country; - g_string_append_printf(st, "Country: %s\n", iptr); + g_string_append_printf(st, + "Country: %s\n", iptr); } g_free(sd->info_country); } if (sd->info_province) { if (strlen(sd->info_province)) - g_string_append_printf(st, "Region: %s\n", sd->info_province); + g_string_append_printf(st, + "Region: %s\n", sd->info_province); g_free(sd->info_province); } if (sd->info_city) { if (strlen(sd->info_city)) - g_string_append_printf(st, "City: %s\n", sd->info_city); + g_string_append_printf(st, + "City: %s\n", sd->info_city); g_free(sd->info_city); } if (sd->info_homepage) { if (strlen(sd->info_homepage)) - g_string_append_printf(st, "Homepage: %s\n", sd->info_homepage); + g_string_append_printf(st, + "Homepage: %s\n", sd->info_homepage); g_free(sd->info_homepage); } if (sd->info_about) { if (strlen(sd->info_about)) - g_string_append_printf(st, "%s\n", sd->info_about); + g_string_append_printf(st, "%s\n", + sd->info_about); g_free(sd->info_about); } imcb_log(ic, "%s", st->str); @@ -535,24 +553,28 @@ static void skype_parse_chatmessage(struct im_connection *ic, char *line) int i; for (i = 0; i < g_list_length(sd->body); i++) { char *body = g_list_nth_data(sd->body, i); - if (!strcmp(sd->type, "SAID") || !strcmp(sd->type, "EMOTED")) { + if (!strcmp(sd->type, "SAID") || + !strcmp(sd->type, "EMOTED")) { if (!strcmp(sd->type, "SAID")) - g_snprintf(buf, 1024, "%s", body); + g_snprintf(buf, 1024, "%s", + body); else - g_snprintf(buf, 1024, "/me %s", body); + g_snprintf(buf, 1024, "/me %s", + body); if (!gc) /* Private message */ - imcb_buddy_msg(ic, sd->handle, buf, 0, 0); + imcb_buddy_msg(ic, + sd->handle, buf, 0, 0); else /* Groupchat message */ - imcb_chat_msg(gc, sd->handle, buf, 0, 0); - } else if (!strcmp(sd->type, "SETTOPIC")) { - if (gc) - imcb_chat_topic(gc, sd->handle, body, 0); - } else if (!strcmp(sd->type, "LEFT")) { - if (gc) - imcb_chat_remove_buddy(gc, sd->handle, NULL); - } + imcb_chat_msg(gc, + sd->handle, buf, 0, 0); + } else if (!strcmp(sd->type, "SETTOPIC") && gc) + imcb_chat_topic(gc, + sd->handle, body, 0); + else if (!strcmp(sd->type, "LEFT") && gc) + imcb_chat_remove_buddy(gc, + sd->handle, NULL); } g_list_free(sd->body); sd->body = NULL; @@ -606,7 +628,8 @@ static void skype_parse_call(struct im_connection *ic, char *line) sd->call_id = g_strdup(id); sd->call_out = TRUE; } else if (!strcmp(info, "STATUS FAILED")) { - imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason)); + imcb_error(ic, "Call failed: %s", + skype_call_strerror(sd->failurereason)); sd->call_id = NULL; } else if (!strncmp(info, "DURATION ", 9)) { if (sd->call_duration) @@ -614,44 +637,57 @@ static void skype_parse_call(struct im_connection *ic, char *line) sd->call_duration = g_strdup(info+9); } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { info += 15; - if (sd->call_status) { - switch (sd->call_status) { - case SKYPE_CALL_RINGING: - if (sd->call_out) - imcb_log(ic, "You are currently ringing the user %s.", info); - else { - g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); - skype_call_ask(ic, sd->call_id, buf); - } - break; - case SKYPE_CALL_MISSED: - imcb_log(ic, "You have missed a call from user %s.", info); - break; - case SKYPE_CALL_CANCELLED: - imcb_log(ic, "You cancelled the call to the user %s.", info); - sd->call_status = 0; - sd->call_out = FALSE; - break; - case SKYPE_CALL_REFUSED: - if (sd->call_out) - imcb_log(ic, "The user %s refused the call.", info); - else - imcb_log(ic, "You refused the call from user %s.", info); - sd->call_out = FALSE; - break; - case SKYPE_CALL_FINISHED: - if (sd->call_duration) - imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); - else - imcb_log(ic, "You finished the call to the user %s.", info); - sd->call_out = FALSE; - break; - default: - /* Don't be noisy, ignore other statuses for now. */ - break; + if (!sd->call_status) + return; + switch (sd->call_status) { + case SKYPE_CALL_RINGING: + if (sd->call_out) + imcb_log(ic, "You are currently ringing " + "the user %s.", info); + else { + g_snprintf(buf, 1024, + "The user %s is currently ringing you.", + info); + skype_call_ask(ic, sd->call_id, buf); } + break; + case SKYPE_CALL_MISSED: + imcb_log(ic, "You have missed a call from user %s.", + info); + break; + case SKYPE_CALL_CANCELLED: + imcb_log(ic, "You cancelled the call to the user %s.", + info); sd->call_status = 0; + sd->call_out = FALSE; + break; + case SKYPE_CALL_REFUSED: + if (sd->call_out) + imcb_log(ic, "The user %s refused the call.", + info); + else + imcb_log(ic, + "You refused the call from user %s.", + info); + sd->call_out = FALSE; + break; + case SKYPE_CALL_FINISHED: + if (sd->call_duration) + imcb_log(ic, + "You finished the call to the user %s " + "(duration: %s seconds).", + info, sd->call_duration); + else + imcb_log(ic, + "You finished the call to the user %s.", + info); + sd->call_out = FALSE; + break; + default: + /* Don't be noisy, ignore other statuses for now. */ + break; } + sd->call_status = 0; } } @@ -670,26 +706,30 @@ static void skype_parse_filetransfer(struct im_connection *ic, char *line) *info = '\0'; info++; if (!strcmp(info, "STATUS NEW")) { - g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); + g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", + id); skype_write(ic, buf); sd->filetransfer_status = SKYPE_FILETRANSFER_NEW; } else if (!strcmp(info, "STATUS FAILED")) { - g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); + g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", + id); skype_write(ic, buf); sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED; } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { info += 15; - if (sd->filetransfer_status) { - switch (sd->filetransfer_status) { - case SKYPE_FILETRANSFER_NEW: - imcb_log(ic, "The user %s offered a new file for you.", info); - break; - case SKYPE_FILETRANSFER_FAILED: - imcb_log(ic, "Failed to transfer file from user %s.", info); - break; - } - sd->filetransfer_status = 0; + if (!sd->filetransfer_status) + return; + switch (sd->filetransfer_status) { + case SKYPE_FILETRANSFER_NEW: + imcb_log(ic, "The user %s offered a new file for you.", + info); + break; + case SKYPE_FILETRANSFER_FAILED: + imcb_log(ic, "Failed to transfer file from user %s.", + info); + break; } + sd->filetransfer_status = 0; } } @@ -764,19 +804,20 @@ static void skype_parse_chat(struct im_connection *ic, char *line) * while we're on the channel * so that we won't rejoin * after a /part. */ - if (gc && !gc->data) { - char **members = g_strsplit(info, " ", 0); - int i; - for (i = 0; members[i]; i++) { - if (!strcmp(members[i], sd->username)) - continue; - g_snprintf(buf, 1024, "%s@skype.com", members[i]); - if (!g_list_find_custom(gc->in_room, buf, (GCompareFunc)strcmp)) - imcb_chat_add_buddy(gc, buf); - } - imcb_chat_add_buddy(gc, sd->username); - g_strfreev(members); + if (!gc || gc->data) + return; + char **members = g_strsplit(info, " ", 0); + int i; + for (i = 0; members[i]; i++) { + if (!strcmp(members[i], sd->username)) + continue; + g_snprintf(buf, 1024, "%s@skype.com", members[i]); + if (!g_list_find_custom(gc->in_room, buf, + (GCompareFunc)strcmp)) + imcb_chat_add_buddy(gc, buf); } + imcb_chat_add_buddy(gc, sd->username); + g_strfreev(members); } } -- cgit v1.2.3 From 16304ab9596145e5b72432769ade8c6b333e82e0 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 03:31:20 +0100 Subject: add a check target --- skype/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skype/Makefile b/skype/Makefile index b838a043..245c1794 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -47,6 +47,10 @@ distclean: clean autoclean: distclean rm -rf aclocal.m4 autom4te.cache configure install-sh +# take this from the kernel +check: + perl checkpatch.pl --no-tree --file skype.c + dist: git archive --format=tar --prefix=bitlbee-skype-$(VERSION)/ HEAD | tar xf - mkdir -p bitlbee-skype-$(VERSION) -- cgit v1.2.3 From bc744df00c65bcebacae04b756392117d4037f2f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 03:36:25 +0100 Subject: whitespace cleanup in skype_away_state_list --- skype/skype.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 3414c901..26ffdb40 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -127,13 +127,13 @@ struct skype_buddy_ask_data { */ const struct skype_away_state skype_away_state_list[] = { - { "ONLINE", "Online" }, - { "SKYPEME", "Skype Me" }, - { "AWAY", "Away" }, - { "NA", "Not available" }, - { "DND", "Do Not Disturb" }, - { "INVISIBLE", "Invisible" }, - { "OFFLINE", "Offline" }, + { "ONLINE", "Online" }, + { "SKYPEME", "Skype Me" }, + { "AWAY", "Away" }, + { "NA", "Not available" }, + { "DND", "Do Not Disturb" }, + { "INVISIBLE", "Invisible" }, + { "OFFLINE", "Offline" }, { NULL, NULL} }; -- cgit v1.2.3 From 5365f84b1694342e9ecef071b5189b8d66a32897 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 7 Jan 2009 03:40:19 +0100 Subject: remove enum names, cleanup no, this is not about hurting wilmer, it's just that the jabber code is now really different. he's still in the readme for a good reason. --- skype/skype.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 26ffdb40..44e94cba 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -3,10 +3,6 @@ * * Copyright (c) 2007, 2008, 2009 by Miklos Vajna * - * Several ideas are used from the BitlBee Jabber plugin, which is - * - * Copyright (c) 2006 by Wilmer van der Gaast - * * 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 @@ -44,12 +40,12 @@ enum { SKYPE_CALL_CANCELLED, SKYPE_CALL_FINISHED, SKYPE_CALL_REFUSED -} skype_call_status; +}; enum { SKYPE_FILETRANSFER_NEW = 1, SKYPE_FILETRANSFER_FAILED -} skype_filetransfer_status; +}; /* * Structures -- cgit v1.2.3 From bc9a9b00627226eb4d10a0f98df24075a491085a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 18 Jan 2009 01:12:55 +0100 Subject: Remove unnecessary includes --- skype/skype.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index 44e94cba..a9e6fa66 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -20,11 +20,9 @@ */ #define _XOPEN_SOURCE -#include #include #include #include -#include #define SKYPE_DEFAULT_SERVER "localhost" #define SKYPE_DEFAULT_PORT "2727" -- cgit v1.2.3 From 3e8a4eac56f85d275785360e9c781647aef0a308 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 19 Jan 2009 14:10:04 +0100 Subject: new testimonial --- skype/README | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/skype/README b/skype/README index f27f4efd..cd41c246 100644 --- a/skype/README +++ b/skype/README @@ -400,7 +400,7 @@ https://developer.skype.com/Docs/ApiDoc[here] if you're interested. == Testimonials ---- -00:56 < scathe> vmiklos: I like your skype plugin :) +00:56 < scathe> I like your skype plugin :) ---- ---- @@ -435,6 +435,12 @@ Lukas 18:10 < miCSu> it works fine ---- +---- +13:56 < seo> i just want to thank you :) +13:56 < seo> for bitlbee-skype +13:57 < seo> it's working very well, so, again, thank you for your work, and for sharing it +---- + == Thanks for the following people: -- cgit v1.2.3 From d7938f9de5b084921f436edeac5de4145aad0e63 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 13 Feb 2009 23:36:27 +0100 Subject: g_strdup_printf("%s", foo) -> g_strdup(foo) --- skype/skype.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/skype/skype.c b/skype/skype.c index a9e6fa66..283c3532 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -319,35 +319,35 @@ static void skype_parse_user(struct im_connection *ic, char *line) g_free(buf); } } else if (!strncmp(ptr, "FULLNAME ", 9)) - sd->info_fullname = g_strdup_printf("%s", ptr + 9); + sd->info_fullname = g_strdup(ptr + 9); else if (!strncmp(ptr, "PHONE_HOME ", 11)) - sd->info_phonehome = g_strdup_printf("%s", ptr + 11); + sd->info_phonehome = g_strdup(ptr + 11); else if (!strncmp(ptr, "PHONE_OFFICE ", 13)) - sd->info_phoneoffice = g_strdup_printf("%s", ptr + 13); + sd->info_phoneoffice = g_strdup(ptr + 13); else if (!strncmp(ptr, "PHONE_MOBILE ", 13)) - sd->info_phonemobile = g_strdup_printf("%s", ptr + 13); + sd->info_phonemobile = g_strdup(ptr + 13); else if (!strncmp(ptr, "NROF_AUTHED_BUDDIES ", 20)) - sd->info_nrbuddies = g_strdup_printf("%s", ptr + 20); + sd->info_nrbuddies = g_strdup(ptr + 20); else if (!strncmp(ptr, "TIMEZONE ", 9)) - sd->info_tz = g_strdup_printf("%s", ptr + 9); + sd->info_tz = g_strdup(ptr + 9); else if (!strncmp(ptr, "LASTONLINETIMESTAMP ", 20)) - sd->info_seen = g_strdup_printf("%s", ptr + 20); + sd->info_seen = g_strdup(ptr + 20); else if (!strncmp(ptr, "BIRTHDAY ", 9)) - sd->info_birthday = g_strdup_printf("%s", ptr + 9); + sd->info_birthday = g_strdup(ptr + 9); else if (!strncmp(ptr, "SEX ", 4)) - sd->info_sex = g_strdup_printf("%s", ptr + 4); + sd->info_sex = g_strdup(ptr + 4); else if (!strncmp(ptr, "LANGUAGE ", 9)) - sd->info_language = g_strdup_printf("%s", ptr + 9); + sd->info_language = g_strdup(ptr + 9); else if (!strncmp(ptr, "COUNTRY ", 8)) - sd->info_country = g_strdup_printf("%s", ptr + 8); + sd->info_country = g_strdup(ptr + 8); else if (!strncmp(ptr, "PROVINCE ", 9)) - sd->info_province = g_strdup_printf("%s", ptr + 9); + sd->info_province = g_strdup(ptr + 9); else if (!strncmp(ptr, "CITY ", 5)) - sd->info_city = g_strdup_printf("%s", ptr + 5); + sd->info_city = g_strdup(ptr + 5); else if (!strncmp(ptr, "HOMEPAGE ", 9)) - sd->info_homepage = g_strdup_printf("%s", ptr + 9); + sd->info_homepage = g_strdup(ptr + 9); else if (!strncmp(ptr, "ABOUT ", 6)) { - sd->info_about = g_strdup_printf("%s", ptr + 6); + sd->info_about = g_strdup(ptr + 6); GString *st = g_string_new("Contact Information\n"); g_string_append_printf(st, "Skype Name: %s\n", user); -- cgit v1.2.3 From 129a6c59cd14c4db8b91412017db900e937e5d11 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 13 Feb 2009 23:39:38 +0100 Subject: updates for 0.7.1 --- skype/Makefile | 2 +- skype/NEWS | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/skype/Makefile b/skype/Makefile index 245c1794..e71e0bb6 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -1,6 +1,6 @@ -include config.mak -VERSION = 0.7.0 +VERSION = 0.7.1 # latest stable BITLBEE_VERSION = 1.2.3 diff --git a/skype/NEWS b/skype/NEWS index a755a53a..70477326 100644 --- a/skype/NEWS +++ b/skype/NEWS @@ -1,5 +1,7 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +0.7.1 - mostly internal changes, the monster read callback is + now replaced by tiny parser functions 0.7.0 - made 'make config' more portable - add 'skypeconsole' buddy for debugging purposes - support autojoin for bookmarked groupchats -- cgit v1.2.3 From 8cb17ff56afc17cd1ce95162cfe1859ae945fe08 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 17 Feb 2009 04:10:09 +0100 Subject: new testemonial --- skype/README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skype/README b/skype/README index cd41c246..0d90ae3f 100644 --- a/skype/README +++ b/skype/README @@ -441,6 +441,10 @@ Lukas 13:57 < seo> it's working very well, so, again, thank you for your work, and for sharing it ---- +---- +22:16 < ecraven> vmiklos: thanks a lot for the skype plugin for bitlbee! +---- + == Thanks for the following people: -- cgit v1.2.3 From 072c0fedea47e7c06b69fdfe7031df0cee43cc39 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 17 Feb 2009 22:12:03 +0100 Subject: skyped: handle the case when LANG and LC_ALL env vars are empty --- skype/skyped.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/skype/skyped.py b/skype/skyped.py index 4f274be7..d5a1582a 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -183,7 +183,10 @@ class SkypeApi: if not len(msg_text) or msg_text == "PONG": return try: - e = msg_text.decode(locale.getdefaultlocale()[1]) + encoding = locale.getdefaultlocale()[1] + if not encoding: + raise ValueError + e = msg_text.decode(encoding) except ValueError: e = msg_text.decode('UTF-8') dprint('>> ' + e) -- cgit v1.2.3 From 25a7eb88368deebb9a595d983570a149e93881dd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 18 Feb 2009 00:31:13 +0100 Subject: Initial testcase. Code is based on ulim's automated live tests. --- skype/t/Makefile | 38 ++ skype/t/bitlbee.conf | 0 skype/t/irssi/livetest-irssi.sh | 109 ++++ skype/t/irssi/skype-login.test | 10 + skype/t/irssi/trigger.pl | 1225 +++++++++++++++++++++++++++++++++++++++ skype/t/livetest-bitlbee.sh | 41 ++ 6 files changed, 1423 insertions(+) create mode 100644 skype/t/Makefile create mode 100644 skype/t/bitlbee.conf create mode 100755 skype/t/irssi/livetest-irssi.sh create mode 100644 skype/t/irssi/skype-login.test create mode 100644 skype/t/irssi/trigger.pl create mode 100755 skype/t/livetest-bitlbee.sh diff --git a/skype/t/Makefile b/skype/t/Makefile new file mode 100644 index 00000000..a65740c2 --- /dev/null +++ b/skype/t/Makefile @@ -0,0 +1,38 @@ +PORT=9876 +BITLBEE=/usr/sbin/bitlbee + +export TEST_SKYPE_ID=bitlbee-skype +export TEST_SKYPE_PASSWORD=:9eQBgoh8 + +testfiles := $(wildcard irssi/*.test) +tests := $(patsubst %.test,%,$(testfiles)) + +.PHONY: checkvars $(tests) + +default: $(tests) + +checkvars: + @for test in irssi/*.test; do NVAR="$$NVAR `irssi/livetest-irssi.sh $$test checkvars`";done;\ + if echo $$NVAR|grep TEST &>/dev/null; then \ + echo Needed variables: ; \ + echo $$NVAR | tr ' ' '\n' | sort | uniq; \ + exit 1; \ + else \ + echo "--- Environment OK ---";\ + fi + +$(tests): % : %.test + @if ! NVARS=`irssi/livetest-irssi.sh $< checkvars`; then echo Need environment variables for $@: $$NVARS;\ + echo Skipping...;exit 0;fi;\ + echo "--- Running test $@ ---"; \ + if ! ./livetest-bitlbee.sh $(BITLBEE) $(PORT) irssi/livetest-irssi.sh $< >$@.log; then \ + echo Test failed, log: ;\ + cat $@.log;\ + exit 1;\ + fi;\ + echo "--- OK ---" ;\ + sleep 1 +clean: + rm -r irssi/*.log bitlbeetest.pid dotirssi livetest + + diff --git a/skype/t/bitlbee.conf b/skype/t/bitlbee.conf new file mode 100644 index 00000000..e69de29b diff --git a/skype/t/irssi/livetest-irssi.sh b/skype/t/irssi/livetest-irssi.sh new file mode 100755 index 00000000..349521a8 --- /dev/null +++ b/skype/t/irssi/livetest-irssi.sh @@ -0,0 +1,109 @@ +#!/bin/bash +ISCRIPT=$1 +OPT=$2 + +[ -n "$ISCRIPT" ] || { echo Syntax: `basename "$0"` irssi-test-script; exit 1; } + +# Load variables from test +eval `sed -e '1,/^###/!d;/^###/d' "$ISCRIPT"` + +#if [ "$OPT" == "checkvars" ]; then echo $TESTNEEDEDVARS; fi +RET=0 + +# Check if we have the neccessary environment variables for this test +for var in $TESTNEEDEDVARS; do + if [ -z `eval echo \$\{$var\}` ]; then + if [ "$OPT" != "checkvars" ]; then + echo Need environment variable "$var" for this test. + exit 66 + else + echo $var + RET=66 + fi + fi +done + +# if we got this far we're OK +if [ "$OPT" == "checkvars" ]; then exit $RET; fi + +[ -n "$PORT" ] || { echo 'Need the bitlbee listening port as environment variable PORT'; exit 1; } + +# Setup the irssi dir +( + rm -r dotirssi + mkdir -p dotirssi/scripts dotirssi/logs + cp "`dirname $0`"/trigger.pl dotirssi/scripts && + echo 'script load trigger.pl' >dotirssi/startup +) &>/dev/null || { echo Failed to setup irssi testdir; exit 1; } + +# write irssi config + +echo ' + +aliases = { + runtest = "'`sed -e "1,/^###/d;s/@LOGIN@/$TESTLOGIN/;s/@PASSWORD@/$TESTPASSWORD/" "$ISCRIPT" | tr '\n' ';'`'"; + expectbee = "/trigger add -publics -channels &bitlbee -regexp"; + expectjoin = "/trigger add -joins -masks *!$0@* $1-"; + expectmsg = "/trigger add -privmsgs -masks *!$0@* $1-"; +}; + +servers = ( { address = "localhost"; chatnet = "local"; port = "'$PORT'"; autoconnect="yes";}); + +settings = { + settings_autosave = "no"; + core = { real_name = "bitlbee-test"; user_name = "bitlbee-test"; nick = "bitlbeetest"; }; + "fe-text" = { actlist_sort = "refnum"; }; +}; + +chatnets = { local = { type = "IRC"; autosendcmd = "/runtest"; }; }; + +logs = { +"dotirssi/logs/status.log" = { auto_open = "yes"; level = "ALL"; items = ( { type = "window"; name = "1"; } ); }; +"dotirssi/logs/control.log" = { auto_open = "yes"; level = "ALL"; items = ( { type = "target"; name = "&bitlbee"; } ); }; +' >dotirssi/config + +for nick in $TESTLOGNICKS; do + echo ' + "dotirssi/logs/'$nick'.log" = { auto_open = "yes"; level = "ALL"; items = ( { type = "target"; name = "'$nick'"; } ); }; + ' >>dotirssi/config +done + +echo '};' >>dotirssi/config + +# Go! + +echo Running irssi... +screen -D -m irssi --config=dotirssi/config --home=dotirssi/ & + +# output logs + +submitlogs() { + sed -i -e "s/$TESTLOGIN/---TESTLOGIN---/;s/$TESTPASSWORD/---TESTPASSWORD---/" dotirssi/logs/*.log + + if [ "$OPT" == "tgz" ]; then + tar czf "`dirname $0`"/"`basename "$ISCRIPT"`".logs.tgz dotirssi/logs/*.log + elif [ "$OPT" == "ctest" ]; then + echo CTEST_FULL_OUTPUT + for log in dotirssi/logs/*.log; do + echo -n '" + done + else + echo Test logs: dotirssi/logs/*.log + fi +} + +# timeout stuff + +t=$TESTDURATION +intval=1 +while (( t >= intval )); do + sleep $intval + kill -0 $! &>/dev/null || { echo screen/irssi terminated.; submitlogs; bash -c "cd dotirssi/logs && $TESTCHECKRESULT" >/dev/null; exit $?; } + t=$(( t - $intval )) +done +echo Killing screen/irssi... +kill $! +submitlogs +exit 22 diff --git a/skype/t/irssi/skype-login.test b/skype/t/irssi/skype-login.test new file mode 100644 index 00000000..6aba2311 --- /dev/null +++ b/skype/t/irssi/skype-login.test @@ -0,0 +1,10 @@ +TESTNEEDEDVARS="TEST_SKYPE_ID TEST_SKYPE_PASSWORD" +TESTDURATION=10 +TESTCHECKRESULT="grep '\[Test Passed\]' status.log" +TESTLOGIN="$TEST_SKYPE_ID" +TESTPASSWORD="$TEST_SKYPE_PASSWORD" +### Test login +/expectbee 'Welcome to the BitlBee' -command 'msg $$C register testing' +/expectbee 'Account successfully created' -command 'msg $$C account add skype @LOGIN@ @PASSWORD@' +/expectbee 'Account successfully added' -command 'msg $$C account on 0' +/expectbee 'Logged in' -command 'quit Test Passed' diff --git a/skype/t/irssi/trigger.pl b/skype/t/irssi/trigger.pl new file mode 100644 index 00000000..02f8951f --- /dev/null +++ b/skype/t/irssi/trigger.pl @@ -0,0 +1,1225 @@ +# trigger.pl - execute a command or replace text, triggered by an event in irssi +# Do /TRIGGER HELP or look at http://wouter.coekaerts.be/irssi/ for help + +# Copyright (C) 2002-2006 Wouter Coekaerts +# +# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +use strict; +use Irssi 20020324 qw(command_bind command_runsub command signal_add_first signal_continue signal_stop signal_remove); +use Text::ParseWords; +use IO::File; +use vars qw($VERSION %IRSSI); + +$VERSION = '1.0'; +%IRSSI = ( + authors => 'Wouter Coekaerts', + contact => 'wouter@coekaerts.be', + name => 'trigger', + description => 'execute a command or replace text, triggered by an event in irssi', + license => 'GPLv2 or later', + url => 'http://wouter.coekaerts.be/irssi/', + changed => '$LastChangedDate: 2006-01-23 13:10:19 +0100 (Mon, 23 Jan 2006) $', +); + +sub cmd_help { + Irssi::print (<<'SCRIPTHELP_EOF', MSGLEVEL_CLIENTCRAP); + +TRIGGER LIST +TRIGGER SAVE +TRIGGER RELOAD +TRIGGER MOVE +TRIGGER DELETE +TRIGGER CHANGE ... +TRIGGER ADD ... + +When to match: +On which types of event to trigger: + These are simply specified by -name_of_the_type + The normal IRC event types are: + publics, %|privmsgs, pubactions, privactions, pubnotices, privnotices, joins, parts, quits, kicks, topics, invites, nick_changes, dcc_msgs, dcc_actions, dcc_ctcps + mode_channel: %|a mode on the (whole) channel (like +t, +i, +b) + mode_nick: %|a mode on someone in the channel (like +o, +v) + -all is an alias for all of those. + Additionally, there is: + rawin: %|raw text incoming from the server + send_command: %|commands you give to irssi + send_text: %|lines you type that aren't commands + beep: %|when irssi beeps + notify_join: %|someone in you notify list comes online + notify_part: %|someone in your notify list goes offline + notify_away: %|someone in your notify list goes away + notify_unaway: %|someone in your notify list goes unaway + notify_unidle: %|someone in your notify list stops idling + +Filters (conditions) the event has to satisfy. They all take one parameter. +If you can give a list, seperate elements by space and use quotes around the list. + -pattern: %|The message must match the given pattern. ? and * can be used as wildcards + -regexp: %|The message must match the given regexp. (see man perlre) + %|if -nocase is given as an option, the regexp or pattern is matched case insensitive + -tags: %|The servertag must be in the given list of tags + -channels: %|The event must be in one of the given list of channels. + Examples: %|-channels '#chan1 #chan2' or -channels 'IRCNet/#channel' + %|-channels 'EFNet/' means every channel on EFNet and is the same as -tags 'EFNet' + -masks: %|The person who triggers it must match one of the given list of masks + -hasmode: %|The person who triggers it must have the give mode + Examples: %|'-o' means not opped, '+ov' means opped OR voiced, '-o&-v' means not opped AND not voiced + -hasflag: %|Only trigger if if friends.pl (friends_shasta.pl) or people.pl is loaded and the person who triggers it has the given flag in the script (same syntax as -hasmode) + -other_masks + -other_hasmode + -other_hasflag: %|Same as above but for the victim for kicks or mode_nick. + +What to do when it matches: + -command: Execute the given Irssi-command + %|You are able to use $1, $2 and so on generated by your regexp pattern. + %|For multiple commands ; (or $;) can be used as seperator + %|The following variables are also expanded: + $T: %|Server tag + $C: %|Channel name + $N: %|Nickname of the person who triggered this command + $A: %|His address (foo@bar.com), + $I: %|His ident (foo) + $H: %|His hostname (bar.com) + $M: %|The complete message + ${other}: %|The victim for kicks or mode_nick + ${mode_type}: %|The type ('+' or '-') for a mode_channel or mode_nick + ${mode_char}: %|The mode char ('o' for ops, 'b' for ban,...) + ${mode_arg} : %|The argument to the mode (if there is one) + %|$\X, with X being one of the above expands (e.g. $\M), escapes all non-alphanumeric characters, so it can be used with /eval or /exec. Don't use /eval or /exec without this, it's not safe. + + -replace: %|replaces the matching part with the given replacement in the event (requires a -regexp or -pattern) + -once: %|remove the trigger if it is triggered, so it only executes once and then is forgotten. + -stop: %|stops the signal. It won't get displayed by Irssi. Like /IGNORE + -debug: %|print some debugging info + +Other options: + -disabled: %|Same as removing it, but keeps it in case you might need it later + -name: %|Give the trigger a name. You can refer to the trigger with this name in add/del/change commands + +Examples: + Knockout people who do a !list: + /TRIGGER ADD %|-publics -channels "#channel1 #channel2" -nocase -regexp ^!list -command "KN $N This is not a warez channel!" + React to !echo commands from people who are +o in your friends-script: + /TRIGGER ADD %|-publics -regexp '^!echo (.*)' -hasflag '+o' -command 'say echo: $1' + Ignore all non-ops on #channel: + /TRIGGER ADD %|-publics -actions -channels "#channel" -hasmode '-o' -stop + Send a mail to yourself every time a topic is changed: + /TRIGGER ADD %|-topics -command 'exec echo $\N changed topic of $\C to: $\M | mail you@somewhere.com -s topic' + + +Examples with -replace: + %|Replace every occurence of shit with sh*t, case insensitive: + /TRIGGER ADD %|-all -nocase -regexp shit -replace sh*t + %|Strip all colorcodes from *!lamer@*: + /TRIGGER ADD %|-all -masks *!lamer@* -regexp '\x03\d?\d?(,\d\d?)?|\x02|\x1f|\x16|\x06' -replace '' + %|Never let *!bot1@foo.bar or *!bot2@foo.bar hilight you + %|(this works by cutting your nick in 2 different parts, 'myn' and 'ick' here) + %|you don't need to understand the -replace argument, just trust that it works if the 2 parts separately don't hilight: + /TRIGGER ADD %|-all masks '*!bot1@foo.bar *!bot2@foo.bar' -regexp '(myn)(ick)' -nocase -replace '$1\x02\x02$2' + %|Avoid being hilighted by !top10 in eggdrops with stats.mod (but show your nick in bold): + /TRIGGER ADD %|-publics -regexp '(Top.0\(.*\): 1.*)(my)(nick)' -replace '$1\x02$2\x02\x02$3\x02' + %|Convert a Windows-1252 Euro to an ISO-8859-15 Euro (same effect as euro.pl): + /TRIGGER ADD %|-regexp '\x80' -replace '\xA4' + %|Show tabs as spaces, not the inverted I (same effect as tab_stop.pl): + /TRIGGER ADD %|-all -regexp '\t' -replace ' ' +SCRIPTHELP_EOF +} # / + +my @triggers; # array of all triggers +my %triggers_by_type; # hash mapping types on triggers of that type +my $recursion_depth = 0; +my $changed_since_last_save = 0; + +############### +### formats ### +############### + +Irssi::theme_register([ + 'trigger_header' => 'Triggers:', + 'trigger_line' => '%#$[-4]0 $1', + 'trigger_added' => 'Trigger $0 added: $1', + 'trigger_not_found' => 'Trigger {hilight $0} not found', + 'trigger_saved' => 'Triggers saved to $0', + 'trigger_loaded' => 'Triggers loaded from $0' +]); + +######################################### +### catch the signals & do your thing ### +######################################### + +# trigger types with a message and a channel +my @allchanmsg_types = qw(publics pubactions pubnotices pubctcps pubctcpreplies parts quits kicks topics); +# trigger types with a message +my @allmsg_types = (@allchanmsg_types, qw(privmsgs privactions privnotices privctcps privctcpreplies dcc_msgs dcc_actions dcc_ctcps)); +# trigger types with a channel +my @allchan_types = (@allchanmsg_types, qw(mode_channel mode_nick joins invites)); +# trigger types in -all +my @all_types = (@allmsg_types, qw(mode_channel mode_nick joins invites nick_changes)); +# trigger types with a server +my @all_server_types = (@all_types, qw(rawin notify_join notify_part notify_away notify_unaway notify_unidle)); +# all trigger types +my @trigger_types = (@all_server_types, qw(send_command send_text beep)); +#trigger types that are not in -all +#my @notall_types = grep {my $a=$_; return (!grep {$_ eq $a} @all_types);} @trigger_types; +my @notall_types = qw(rawin notify_join notify_part notify_away notify_unaway notify_unidle send_command send_text beep); + +my @signals = ( +# "message public", SERVER_REC, char *msg, char *nick, char *address, char *target +{ + 'types' => ['publics'], + 'signal' => 'message public', + 'sub' => sub {check_signal_message(\@_,1,$_[0],$_[4],$_[2],$_[3],'publics');}, +}, +# "message private", SERVER_REC, char *msg, char *nick, char *address +{ + 'types' => ['privmsgs'], + 'signal' => 'message private', + 'sub' => sub {check_signal_message(\@_,1,$_[0],undef,$_[2],$_[3],'privmsgs');}, +}, +# "message irc action", SERVER_REC, char *msg, char *nick, char *address, char *target +{ + 'types' => ['privactions','pubactions'], + 'signal' => 'message irc action', + 'sub' => sub { + if ($_[4] eq $_[0]->{nick}) { + check_signal_message(\@_,1,$_[0],undef,$_[2],$_[3],'privactions'); + } else { + check_signal_message(\@_,1,$_[0],$_[4],$_[2],$_[3],'pubactions'); + } + }, +}, +# "message irc notice", SERVER_REC, char *msg, char *nick, char *address, char *target +{ + 'types' => ['privnotices','pubnotices'], + 'signal' => 'message irc notice', + 'sub' => sub { + if ($_[4] eq $_[0]->{nick}) { + check_signal_message(\@_,1,$_[0],undef,$_[2],$_[3],'privnotices'); + } else { + check_signal_message(\@_,1,$_[0],$_[4],$_[2],$_[3],'pubnotices'); + } + } +}, +# "message join", SERVER_REC, char *channel, char *nick, char *address +{ + 'types' => ['joins'], + 'signal' => 'message join', + 'sub' => sub {check_signal_message(\@_,-1,$_[0],$_[1],$_[2],$_[3],'joins');} +}, +# "message part", SERVER_REC, char *channel, char *nick, char *address, char *reason +{ + 'types' => ['parts'], + 'signal' => 'message part', + 'sub' => sub {check_signal_message(\@_,4,$_[0],$_[1],$_[2],$_[3],'parts');} +}, +# "message quit", SERVER_REC, char *nick, char *address, char *reason +{ + 'types' => ['quits'], + 'signal' => 'message quit', + 'sub' => sub {check_signal_message(\@_,3,$_[0],undef,$_[1],$_[2],'quits');} +}, +# "message kick", SERVER_REC, char *channel, char *nick, char *kicker, char *address, char *reason +{ + 'types' => ['kicks'], + 'signal' => 'message kick', + 'sub' => sub {check_signal_message(\@_,5,$_[0],$_[1],$_[3],$_[4],'kicks',{'other'=>$_[2]});} +}, +# "message topic", SERVER_REC, char *channel, char *topic, char *nick, char *address +{ + 'types' => ['topics'], + 'signal' => 'message topic', + 'sub' => sub {check_signal_message(\@_,2,$_[0],$_[1],$_[3],$_[4],'topics');} +}, +# "message invite", SERVER_REC, char *channel, char *nick, char *address +{ + 'types' => ['invites'], + 'signal' => 'message invite', + 'sub' => sub {check_signal_message(\@_,-1,$_[0],$_[1],$_[2],$_[3],'invites');} +}, +# "message nick", SERVER_REC, char *newnick, char *oldnick, char *address +{ + 'types' => ['nick_changes'], + 'signal' => 'message nick', + 'sub' => sub {check_signal_message(\@_,-1,$_[0],undef,$_[1],$_[3],'nick_changes');} +}, +# "message dcc", DCC_REC *dcc, char *msg +{ + 'types' => ['dcc_msgs'], + 'signal' => 'message dcc', + 'sub' => sub {check_signal_message(\@_,1,$_[0]->{'server'},undef,$_[0]->{'nick'},undef,'dcc_msgs'); + } +}, +# "message dcc action", DCC_REC *dcc, char *msg +{ + 'types' => ['dcc_actions'], + 'signal' => 'message dcc action', + 'sub' => sub {check_signal_message(\@_,1,$_[0]->{'server'},undef,$_[0]->{'nick'},undef,'dcc_actions');} +}, +# "message dcc ctcp", DCC_REC *dcc, char *cmd, char *data +{ + 'types' => ['dcc_ctcps'], + 'signal' => 'message dcc ctcp', + 'sub' => sub {check_signal_message(\@_,1,$_[0]->{'server'},undef,$_[0]->{'nick'},undef,'dcc_ctcps');} +}, +# "server incoming", SERVER_REC, char *data +{ + 'types' => ['rawin'], + 'signal' => 'server incoming', + 'sub' => sub {check_signal_message(\@_,1,$_[0],undef,undef,undef,'rawin');} +}, +# "send command", char *args, SERVER_REC, WI_ITEM_REC +{ + 'types' => ['send_command'], + 'signal' => 'send command', + 'sub' => sub { + sig_send_text_or_command(\@_,1); + } +}, +# "send text", char *line, SERVER_REC, WI_ITEM_REC +{ + 'types' => ['send_text'], + 'signal' => 'send text', + 'sub' => sub { + sig_send_text_or_command(\@_,0); + } +}, +# "beep" +{ + 'types' => ['beep'], + 'signal' => 'beep', + 'sub' => sub {check_signal_message(\@_,-1,undef,undef,undef,undef,'beep');} +}, +# "event ", SERVER_REC, char *args, char *sender_nick, char *sender_address +{ + 'types' => ['mode_channel', 'mode_nick'], + 'signal' => 'event mode', + 'sub' => sub { + my ($server, $event_args, $nickname, $address) = @_; + my ($target, $modes, $modeargs) = split(/ /, $event_args, 3); + return if (!$server->ischannel($target)); + my (@modeargs) = split(/ /,$modeargs); + my ($pos, $type, $event_type, $arg) = (0, '+'); + foreach my $char (split(//,$modes)) { + if ($char eq "+" || $char eq "-") { + $type = $char; + } else { + if ($char =~ /[Oovh]/) { # mode_nick + $event_type = 'mode_nick'; + $arg = $modeargs[$pos++]; + } elsif ($char =~ /[beIqdk]/ || ( $char =~ /[lfJ]/ && $type eq '+')) { # chan_mode with arg + $event_type = 'mode_channel'; + $arg = $modeargs[$pos++]; + } else { # chan_mode without arg + $event_type = 'mode_channel'; + $arg = undef; + } + check_signal_message(\@_,-1,$server,$target,$nickname,$address,$event_type,{ + 'mode_type' => $type, + 'mode_char' => $char, + 'mode_arg' => $arg, + 'other' => ($event_type eq 'mode_nick') ? $arg : undef + }); + } + } + } +}, +# "notifylist joined", SERVER_REC, char *nick, char *user, char *host, char *realname, char *awaymsg +{ + 'types' => ['notify_join'], + 'signal' => 'notifylist joined', + 'sub' => sub {check_signal_message(\@_, 5, $_[0], undef, $_[1], $_[2].'@'.$_[3], 'notify_join', {'realname' => $_[4]});} +}, +{ + 'types' => ['notify_part'], + 'signal' => 'notifylist left', + 'sub' => sub {check_signal_message(\@_, 5, $_[0], undef, $_[1], $_[2].'@'.$_[3], 'notify_left', {'realname' => $_[4]});} +}, +{ + 'types' => ['notify_unidle'], + 'signal' => 'notifylist unidle', + 'sub' => sub {check_signal_message(\@_, 5, $_[0], undef, $_[1], $_[2].'@'.$_[3], 'notify_unidle', {'realname' => $_[4]});} +}, +{ + 'types' => ['notify_away', 'notify_unaway'], + 'signal' => 'notifylist away changed', + 'sub' => sub {check_signal_message(\@_, 5, $_[0], undef, $_[1], $_[2].'@'.$_[3], ($_[5] ? 'notify_away' : 'notify_unaway'), {'realname' => $_[4]});} +}, +# "ctcp msg", SERVER_REC, char *args, char *nick, char *addr, char *target +{ + 'types' => ['pubctcps', 'privctcps'], + 'signal' => 'ctcp msg', + 'sub' => sub { + my ($server, $args, $nick, $addr, $target) = @_; + if ($target eq $server->{'nick'}) { + check_signal_message(\@_, 1, $server, undef, $nick, $addr, 'privctcps'); + } else { + check_signal_message(\@_, 1, $server, $target, $nick, $addr, 'pubctcps'); + } + } +}, +# "ctcp reply", SERVER_REC, char *args, char *nick, char *addr, char *target +{ + 'types' => ['pubctcpreplies', 'privctcpreplies'], + 'signal' => 'ctcp reply', + 'sub' => sub { + my ($server, $args, $nick, $addr, $target) = @_; + if ($target eq $server->{'nick'}) { + check_signal_message(\@_, 1, $server, undef, $nick, $addr, 'privctcps'); + } else { + check_signal_message(\@_, 1, $server, $target, $nick, $addr, 'pubctcps'); + } + } +} +); + +sub sig_send_text_or_command { + my ($signal, $iscommand) = @_; + my ($line, $server, $item) = @$signal; + my ($channelname,$nickname,$address) = (undef,undef,undef); + if ($item && (ref($item) eq 'Irssi::Irc::Channel' || ref($item) eq 'Irssi::Silc::Channel')) { + $channelname = $item->{'name'}; + } elsif ($item && ref($item) eq 'Irssi::Irc::Query') { # TODO Silc query ? + $nickname = $item->{'name'}; + $address = $item->{'address'} + } + # TODO pass context also for non-channels (queries and other stuff) + check_signal_message($signal,0,$server,$channelname,$nickname,$address,$iscommand ? 'send_command' : 'send_text'); + +} + +my %filters = ( +'tags' => { + 'types' => \@all_server_types, + 'sub' => sub { + my ($param, $signal,$parammessage,$server,$channelname,$nickname,$address,$condition,$extra) = @_; + + if (!defined($server)) { + return 0; + } + my $matches = 0; + foreach my $tag (split(/ /,$param)) { + if (lc($server->{'tag'}) eq lc($tag)) { + $matches = 1; + last; + } + } + return $matches; + } +}, +'channels' => { + 'types' => \@allchan_types, + 'sub' => sub { + my ($param, $signal,$parammessage,$server,$channelname,$nickname,$address,$condition,$extra) = @_; + + if (!defined($channelname) || !defined($server)) { + return 0; + } + my $matches = 0; + foreach my $trigger_channel (split(/ /,$param)) { + if (lc($channelname) eq lc($trigger_channel) + || lc($server->{'tag'}.'/'.$channelname) eq lc($trigger_channel) + || lc($server->{'tag'}.'/') eq lc($trigger_channel)) { + $matches = 1; + last; # this channel matches, stop checking channels + } + } + return $matches; + } +}, +'masks' => { + 'types' => \@all_types, + 'sub' => sub { + my ($param, $signal,$parammessage,$server,$channelname,$nickname,$address,$condition,$extra) = @_; + return (defined($nickname) && defined($address) && defined($server) && $server->masks_match($param, $nickname, $address)); + } +}, +'other_masks' => { + 'types' => ['kicks', 'mode_nick'], + 'sub' => sub { + my ($param, $signal,$parammessage,$server,$channelname,$nickname,$address,$condition,$extra) = @_; + return 0 unless defined($extra->{'other'}); + my $other_address = get_address($extra->{'other'}, $server, $channelname); + return defined($other_address) && $server->masks_match($param, $extra->{'other'}, $other_address); + } +}, +'hasmode' => { + 'types' => \@all_types, + 'sub' => sub { + my ($param, $signal,$parammessage,$server,$channelname,$nickname,$address,$condition,$extra) = @_; + return hasmode($param, $nickname, $server, $channelname); + } +}, +'other_hasmode' => { + 'types' => ['kicks', 'mode_nick'], + 'sub' => sub { + my ($param,$signal,$parammessage,$server,$channelname,$nickname,$address,$condition,$extra) = @_; + return defined($extra->{'other'}) && hasmode($param, $extra->{'other'}, $server, $channelname); + } +}, +'hasflag' => { + 'types' => \@all_types, + 'sub' => sub { + my ($param, $signal,$parammessage,$server,$channelname,$nickname,$address,$condition,$extra) = @_; + return 0 unless defined($nickname) && defined($address) && defined($server); + my $flags = get_flags ($server->{'chatnet'},$channelname,$nickname,$address); + return defined($flags) && check_modes($flags,$param); + } +}, +'other_hasflag' => { + 'types' => ['kicks', 'mode_nick'], + 'sub' => sub { + my ($param, $signal,$parammessage,$server,$channelname,$nickname,$address,$condition,$extra) = @_; + return 0 unless defined($extra->{'other'}); + my $other_address = get_address($extra->{'other'}, $server, $channelname); + return 0 unless defined($other_address); + my $flags = get_flags ($server->{'chatnet'},$channelname,$extra->{'other'},$other_address); + return defined($flags) && check_modes($flags,$param); + } +}, +'mode_type' => { + 'types' => ['mode_channel', 'mode_nick'], + 'sub' => sub { + my ($param, $signal,$parammessage,$server,$channelname,$nickname,$address,$condition,$extra) = @_; + return (($param) eq $extra->{'mode_type'}); + } +}, +'mode_char' => { + 'types' => ['mode_channel', 'mode_nick'], + 'sub' => sub { + my ($param, $signal,$parammessage,$server,$channelname,$nickname,$address,$condition,$extra) = @_; + return (($param) eq $extra->{'mode_char'}); + } +}, +'mode_arg' => { + 'types' => ['mode_channel', 'mode_nick'], + 'sub' => sub { + my ($param, $signal,$parammessage,$server,$channelname,$nickname,$address,$condition,$extra) = @_; + return (($param) eq $extra->{'mode_arg'}); + } +} +); + +sub get_address { + my ($nick, $server, $channel) = @_; + my $nickrec = get_nickrec($nick, $server, $channel); + return $nickrec ? $nickrec->{'host'} : undef; +} +sub get_nickrec { + my ($nick, $server, $channel) = @_; + return unless defined($server) && defined($channel) && defined($nick); + my $chanrec = $server->channel_find($channel); + return $chanrec ? $chanrec->nick_find($nick) : undef; +} + +sub hasmode { + my ($param, $nickname, $server, $channelname) = @_; + my $nickrec = get_nickrec($nickname, $server, $channelname); + return 0 unless defined $nickrec; + my $modes = + ($nickrec->{'op'} ? 'o' : '') + . ($nickrec->{'voice'} ? 'v' : '') + . ($nickrec->{'halfop'} ? 'h' : '') + ; + return check_modes($modes, $param); +} + +# list of all switches +my @trigger_switches = (@trigger_types, qw(all nocase stop once debug disabled)); +# parameters (with an argument) +my @trigger_params = qw(pattern regexp command replace name); +# list of all options (including switches) for /TRIGGER ADD +my @trigger_add_options = (@trigger_switches, @trigger_params, keys(%filters)); +# same for /TRIGGER CHANGE, this includes the -no