diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-05-23 10:09:16 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-05-23 10:09:16 +0200 |
commit | da3b53657c8e554fc8c28c8ef61ef44492da24dd (patch) | |
tree | 35c434510dec74965229340f9b804511a5a608b5 | |
parent | 226fce105c1189bde1aa321b494494d49b463e90 (diff) |
Added bim_ functions for block/allow list management to keep gc->permit/deny
up-to-date at run-time.
-rw-r--r-- | protocols/nogaim.c | 46 | ||||
-rw-r--r-- | protocols/nogaim.h | 5 | ||||
-rw-r--r-- | root_commands.c | 12 |
3 files changed, 57 insertions, 6 deletions
diff --git a/protocols/nogaim.c b/protocols/nogaim.c index a9b27e92..04d48236 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -1070,3 +1070,49 @@ static char *bim_away_alias_find( GList *gcm, char *away ) return( NULL ); } + +void bim_add_allow( struct gaim_connection *gc, char *handle ) +{ + if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) + { + gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) ); + } + + gc->prpl->add_permit( gc, handle ); +} + +void bim_rem_allow( struct gaim_connection *gc, char *handle ) +{ + GSList *l; + + if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) + { + g_free( l->data ); + gc->permit = g_slist_delete_link( gc->permit, l ); + } + + gc->prpl->rem_permit( gc, handle ); +} + +void bim_add_block( struct gaim_connection *gc, char *handle ) +{ + if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) + { + gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) ); + } + + gc->prpl->add_deny( gc, handle ); +} + +void bim_rem_block( struct gaim_connection *gc, char *handle ) +{ + GSList *l; + + if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) + { + g_free( l->data ); + gc->deny = g_slist_delete_link( gc->deny, l ); + } + + gc->prpl->rem_deny( gc, handle ); +} diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 3b55fe3b..54a1835b 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -197,6 +197,11 @@ int bim_set_away( struct gaim_connection *gc, char *away ); int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags ); int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ); +void bim_add_allow( struct gaim_connection *gc, char *handle ); +void bim_rem_allow( struct gaim_connection *gc, char *handle ); +void bim_add_block( struct gaim_connection *gc, char *handle ); +void bim_rem_block( struct gaim_connection *gc, char *handle ); + void nogaim_init(); char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ); diff --git a/root_commands.c b/root_commands.c index 24423958..0e12e9ab 100644 --- a/root_commands.c +++ b/root_commands.c @@ -557,9 +557,9 @@ static void cmd_block( irc_t *irc, char **cmd ) } else { - gc->prpl->rem_permit( gc, cmd[2] ); - gc->prpl->add_deny( gc, cmd[2] ); - irc_usermsg( irc, "Buddy `%s' moved from your permit- to your deny-list", cmd[2] ); + bim_rem_allow( gc, cmd[2] ); + bim_add_block( gc, cmd[2] ); + irc_usermsg( irc, "Buddy `%s' moved from your allow- to your block-list", cmd[2] ); } } @@ -616,10 +616,10 @@ static void cmd_allow( irc_t *irc, char **cmd ) } else { - gc->prpl->rem_deny( gc, cmd[2] ); - gc->prpl->add_permit( gc, cmd[2] ); + bim_rem_block( gc, cmd[2] ); + bim_add_allow( gc, cmd[2] ); - irc_usermsg( irc, "Buddy `%s' moved from your deny- to your permit-list", cmd[2] ); + irc_usermsg( irc, "Buddy `%s' moved from your block- to your allow-list", cmd[2] ); } } |