diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-09-24 21:25:06 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-09-24 21:25:06 +0200 |
commit | 8e5e2e9a0ef549c94afc8041dc7d99358f51c9bd (patch) | |
tree | 66345fc8d13a8b9403dd09f3dc42b44618336ce6 | |
parent | cfbb3a6e5e11a8d2d162d80958d6ce997104e9d3 (diff) |
Handling of incoming authorization requests, manual block/allow. (Doesn't
seem to be completely like how it works on other IM networks.)
-rw-r--r-- | protocols/jabber/jabber.c | 26 | ||||
-rw-r--r-- | protocols/jabber/jabber.h | 1 | ||||
-rw-r--r-- | protocols/jabber/jabber_util.c | 38 | ||||
-rw-r--r-- | protocols/jabber/presence.c | 15 |
4 files changed, 76 insertions, 4 deletions
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 21633973..05ff8047 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -172,6 +172,24 @@ static void jabber_keepalive( struct gaim_connection *gc ) jabber_write( gc, "\n", 1 ); } +static void jabber_add_permit( struct gaim_connection *gc, char *who ) +{ + presence_send_request( gc, who, "subscribed" ); +} + +static void jabber_rem_permit( struct gaim_connection *gc, char *who ) +{ + presence_send_request( gc, who, "unsubscribed" ); +} + +static void jabber_add_deny( struct gaim_connection *gc, char *who ) +{ +} + +static void jabber_rem_deny( struct gaim_connection *gc, char *who ) +{ +} + void jabber_init() { struct prpl *ret = g_new0( struct prpl, 1 ); @@ -193,10 +211,10 @@ void jabber_init() // ret->chat_leave = jabber_chat_leave; // ret->chat_open = jabber_chat_open; ret->keepalive = jabber_keepalive; -// ret->add_permit = jabber_add_permit; -// ret->rem_permit = jabber_rem_permit; -// ret->add_deny = jabber_add_deny; -// ret->rem_deny = jabber_rem_deny; + ret->add_permit = jabber_add_permit; + ret->rem_permit = jabber_rem_permit; + ret->add_deny = jabber_add_deny; + ret->rem_deny = jabber_rem_deny; // ret->send_typing = jabber_send_typing; ret->handle_cmp = g_strcasecmp; diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 7a2c7783..f05c1c55 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -91,6 +91,7 @@ void jabber_cache_packet( struct gaim_connection *gc, struct xt_node *node ); struct xt_node *jabber_packet_from_cache( struct gaim_connection *gc, char *id ); const struct jabber_away_state *jabber_away_state_by_code( char *code ); const struct jabber_away_state *jabber_away_state_by_name( char *name ); +void jabber_buddy_ask( struct gaim_connection *gc, char *handle ); extern const struct jabber_away_state jabber_away_state_list[]; diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index e7a161cc..3a0d2004 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -148,3 +148,41 @@ const struct jabber_away_state *jabber_away_state_by_name( char *name ) return NULL; } + +struct jabber_buddy_ask_data +{ + struct gaim_connection *gc; + char *handle; + char *realname; +}; + +static void jabber_buddy_ask_yes( gpointer w, struct jabber_buddy_ask_data *bla ) +{ + presence_send_request( bla->gc, bla->handle, "subscribed" ); + + if( find_buddy( bla->gc, bla->handle ) == NULL ) + show_got_added( bla->gc, bla->handle, NULL ); + + g_free( bla->handle ); + g_free( bla ); +} + +static void jabber_buddy_ask_no( gpointer w, struct jabber_buddy_ask_data *bla ) +{ + presence_send_request( bla->gc, bla->handle, "subscribed" ); + + g_free( bla->handle ); + g_free( bla ); +} + +void jabber_buddy_ask( struct gaim_connection *gc, char *handle ) +{ + struct jabber_buddy_ask_data *bla = g_new0( struct jabber_buddy_ask_data, 1 ); + char *buf; + + bla->gc = gc; + bla->handle = g_strdup( handle ); + + buf = g_strdup_printf( "The user %s wants to add you to his/her buddy list.", handle ); + do_ask_dialog( gc, buf, bla, jabber_buddy_ask_yes, jabber_buddy_ask_no ); +} diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c index fa9c1248..1b8008b8 100644 --- a/protocols/jabber/presence.c +++ b/protocols/jabber/presence.c @@ -41,6 +41,21 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) serv_got_update( gc, from, 1, 0, 0, 0, 0, 0 ); else if( strcmp( type, "unavailable" ) == 0 ) serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 ); + else if( strcmp( type, "subscribe" ) == 0 ) + jabber_buddy_ask( gc, from ); + else if( strcmp( type, "subscribed" ) == 0 ) + serv_got_crap( gc, "%s just accepted your authorization request", from ); + else if( strcmp( type, "unsubscribe" ) == 0 || strcmp( type, "unsubscribed" ) == 0 ) + { + /* Do nothing here. Plenty of control freaks or over-curious + souls get excited when they can see who still has them in + their buddy list and who finally removed them. Somehow I + got the impression that those are the people who get + removed from many buddy lists for "some" reason... + + If you're one of those people, this is your chance to write + your first line of code in C... */ + } else { printf( "Received PRES from %s:\n", from ); |