diff options
author | VMiklos <vmiklos@frugalware.org> | 2007-08-21 16:10:25 +0200 |
---|---|---|
committer | VMiklos <vmiklos@frugalware.org> | 2007-08-21 16:10:25 +0200 |
commit | d3cbd1725540cb6665df678b28dafa8fe4c1c7d6 (patch) | |
tree | b21b09b9522b45b2eb5eaf6ec284f45cad7e00f8 | |
parent | 1fb89e33a8b514895c22b6476e50616b2c2d907d (diff) |
implement skype_buddy_ask()
-rw-r--r-- | skype/README | 11 | ||||
-rw-r--r-- | 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 <pass> 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)) { |