Changeset d88c92a
- Timestamp:
- 2010-12-06T00:03:49Z (14 years ago)
- Branches:
- master
- Children:
- d76e12f
- Parents:
- a429907
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
irc_im.c
ra429907 rd88c92a 276 276 else 277 277 return FALSE; 278 279 return TRUE; 280 } 281 282 static gboolean bee_irc_user_action_response( bee_t *bee, bee_user_t *bu, const char *action, char * const args[], void *data ) 283 { 284 irc_t *irc = (irc_t *) bee->ui_data; 285 GString *msg = g_string_new( "\001" ); 286 287 g_string_append( msg, action ); 288 while( *args ) 289 { 290 if( strchr( *args, ' ' ) ) 291 g_string_append_printf( msg, " \"%s\"", *args ); 292 else 293 g_string_append_printf( msg, " %s", *args ); 294 args ++; 295 } 296 g_string_append_c( msg, '\001' ); 297 298 irc_send_msg( (irc_user_t *) bu->ui_data, "NOTICE", irc->user->nick, msg->str, NULL ); 278 299 279 300 return TRUE; … … 492 513 } 493 514 } 515 else if( iu->bu && iu->bu->ic && iu->bu->ic->acc->prpl->buddy_action ) 516 { 517 iu->bu->ic->acc->prpl->buddy_action( iu->bu, ctcp[0], ctcp + 1, NULL ); 518 } 494 519 495 520 return FALSE; … … 1041 1066 bee_irc_user_msg, 1042 1067 bee_irc_user_typing, 1068 bee_irc_user_action_response, 1043 1069 1044 1070 bee_irc_chat_new, -
protocols/bee.h
ra429907 rd88c92a 111 111 /* Flags currently defined (OPT_TYPING/THINKING) in nogaim.h. */ 112 112 gboolean (*user_typing)( bee_t *bee, bee_user_t *bu, guint32 flags ); 113 /* CTCP-like stuff (buddy action) response */ 114 gboolean (*user_action_response)( bee_t *bee, bee_user_t *bu, const char *action, char * const args[], void *data ); 113 115 114 116 /* Called at creation time. Don't show to the user until s/he is -
protocols/bee_user.c
ra429907 rd88c92a 281 281 } 282 282 } 283 284 void imcb_buddy_action_response( bee_user_t *bu, const char *action, char * const args[], void *data ) 285 { 286 if( bu->bee->ui->user_action_response ) 287 bu->bee->ui->user_action_response( bu->bee, bu, action, args, data ); 288 } -
protocols/jabber/iq.c
ra429907 rd88c92a 794 794 return XT_HANDLED; 795 795 } 796 797 static xt_status jabber_iq_version_response( struct im_connection *ic, 798 struct xt_node *node, struct xt_node *orig ); 799 800 void jabber_iq_version_send( struct im_connection *ic, struct jabber_buddy *bud, void *data ) 801 { 802 struct xt_node *node, *query; 803 804 node = xt_new_node( "query", NULL, NULL ); 805 xt_add_attr( node, "xmlns", XMLNS_VERSION ); 806 query = jabber_make_packet( "iq", "get", bud->full_jid, node ); 807 jabber_cache_add( ic, query, jabber_iq_version_response ); 808 809 jabber_write_packet( ic, query ); 810 } 811 812 static xt_status jabber_iq_version_response( struct im_connection *ic, 813 struct xt_node *node, struct xt_node *orig ) 814 { 815 struct xt_node *query; 816 GString *rets; 817 char *s; 818 char *ret[2] = {}; 819 bee_user_t *bu; 820 struct jabber_buddy *bud = NULL; 821 822 if( ( s = xt_find_attr( node, "from" ) ) && 823 ( bud = jabber_buddy_by_jid( ic, s, 0 ) ) && 824 ( query = xt_find_node( node->children, "query" ) ) && 825 ( bu = bee_user_by_handle( ic->bee, ic, bud->bare_jid ) ) ) 826 { 827 rets = g_string_new( "Resource " ); 828 g_string_append( rets, bud->resource ); 829 } 830 else 831 return XT_HANDLED; 832 833 for( query = query->children; query; query = query->next ) 834 if( query->text_len > 0 ) 835 g_string_append_printf( rets, " %s: %s,", query->name, query->text ); 836 837 g_string_truncate( rets, rets->len - 1 ); 838 ret[0] = rets->str; 839 imcb_buddy_action_response( bu, "VERSION", ret, NULL ); 840 g_string_free( rets, TRUE ); 841 842 return XT_HANDLED; 843 } -
protocols/jabber/jabber.c
ra429907 rd88c92a 564 564 } 565 565 566 GList *jabber_buddy_action_list( bee_user_t *bu ) 567 { 568 static GList *ret = NULL; 569 570 if( ret == NULL ) 571 { 572 struct buddy_action ba[2] = { 573 { "VERSION", "Get client (version) information" }, 574 }; 575 576 ret = g_list_prepend( ret, ba + 0 ); 577 } 578 579 return ret; 580 } 581 582 void *jabber_buddy_action( struct bee_user *bu, const char *action, char * const args[], void *data ) 583 { 584 if( g_strcasecmp( action, "VERSION" ) == 0 ) 585 { 586 struct jabber_buddy *bud; 587 588 if( ( bud = jabber_buddy_by_ext_jid( bu->ic, bu->handle, 0 ) ) == NULL ) 589 bud = jabber_buddy_by_jid( bu->ic, bu->handle, GET_BUDDY_FIRST ); 590 for( ; bud; bud = bud->next ) 591 jabber_iq_version_send( bu->ic, bud, data ); 592 } 593 594 return NULL; 595 } 596 566 597 void jabber_initmodule() 567 598 { … … 591 622 ret->handle_cmp = g_strcasecmp; 592 623 ret->transfer_request = jabber_si_transfer_request; 624 ret->buddy_action_list = jabber_buddy_action_list; 625 ret->buddy_action = jabber_buddy_action; 593 626 594 627 register_protocol( ret ); -
protocols/jabber/jabber.h
ra429907 rd88c92a 241 241 xt_status jabber_iq_query_features( struct im_connection *ic, char *bare_jid ); 242 242 xt_status jabber_iq_query_server( struct im_connection *ic, char *jid, char *xmlns ); 243 void jabber_iq_version_send( struct im_connection *ic, struct jabber_buddy *bud, void *data ); 243 244 244 245 /* si.c */ -
protocols/nogaim.h
ra429907 rd88c92a 136 136 }; 137 137 138 struct buddy_action { 139 char *name; 140 char *description; 141 }; 142 138 143 struct prpl { 139 144 int options; … … 257 262 void (* buddy_data_free) (struct bee_user *bu); 258 263 264 GList *(* buddy_action_list) (struct bee_user *bu); 265 void *(* buddy_action) (struct bee_user *bu, const char *action, char * const args[], void *data); 266 259 267 /* Some placeholders so eventually older plugins may cooperate with newer BitlBees. */ 260 268 void *resv1; … … 316 324 G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname ); 317 325 G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick ); 326 G_MODULE_EXPORT void imcb_buddy_action_response( bee_user_t *bu, const char *action, char * const args[], void *data ); 318 327 319 328 G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, const char *handle, uint32_t flags );
Note: See TracChangeset
for help on using the changeset viewer.