Changeset 0ac1a375 for protocols/purple
- Timestamp:
- 2009-11-25T00:19:45Z (15 years ago)
- Branches:
- master
- Children:
- e5d8d21
- Parents:
- 45a19e5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/purple/purple.c
r45a19e5 r0ac1a375 24 24 #include "bitlbee.h" 25 25 26 #include <stdarg.h> 27 26 28 #include <glib.h> 27 29 #include <purple.h> 28 30 29 31 GSList *purple_connections; 32 33 /* This makes me VERY sad... :-( But some libpurple callbacks come in without 34 any context so this is the only way to get that. Don't want to support 35 libpurple in daemon mode anyway. */ 36 static irc_t *local_irc; 30 37 31 38 static struct im_connection *purple_ic_by_pa( PurpleAccount *pa ) … … 134 141 { 135 142 struct im_connection *ic = imcb_new( acc ); 136 static void *irc_check = NULL;137 143 PurpleAccount *pa; 138 144 139 if( irc_check != NULL && irc_check != acc->irc ) 140 { 141 irc_usermsg( acc->irc, "Daemon mode detected. Do *not* try to use libpurple in daemon mode! Please use inetd or ForkDaemon mode instead." ); 145 if( local_irc != NULL && local_irc != acc->irc ) 146 { 147 irc_usermsg( acc->irc, "Daemon mode detected. Do *not* try to use libpurple in daemon mode! " 148 "Please use inetd or ForkDaemon mode instead." ); 142 149 return; 143 150 } 144 irc_check= acc->irc;151 local_irc = acc->irc; 145 152 146 153 /* For now this is needed in the _connected() handlers if using … … 407 414 }; 408 415 416 struct prplcb_request_action_data 417 { 418 void *user_data, *bee_data; 419 PurpleRequestActionCb yes, no; 420 int yes_i, no_i; 421 }; 422 423 static void prplcb_request_action_yes( void *data ) 424 { 425 struct prplcb_request_action_data *pqad = data; 426 427 pqad->yes( pqad->user_data, pqad->yes_i ); 428 g_free( pqad ); 429 } 430 431 static void prplcb_request_action_no( void *data ) 432 { 433 struct prplcb_request_action_data *pqad = data; 434 435 pqad->no( pqad->user_data, pqad->no_i ); 436 g_free( pqad ); 437 } 438 439 static void *prplcb_request_action( const char *title, const char *primary, const char *secondary, 440 int default_action, PurpleAccount *account, const char *who, 441 PurpleConversation *conv, void *user_data, size_t action_count, 442 va_list actions ) 443 { 444 struct prplcb_request_action_data *pqad; 445 int i; 446 char *q; 447 448 pqad = g_new0( struct prplcb_request_action_data, 1 ); 449 450 for( i = 0; i < action_count; i ++ ) 451 { 452 char *caption; 453 void *fn; 454 455 caption = va_arg( actions, char* ); 456 fn = va_arg( actions, void* ); 457 458 if( strcmp( caption, "Accept" ) == 0 ) 459 { 460 pqad->yes = fn; 461 pqad->yes_i = i; 462 } 463 else if( strcmp( caption, "Reject" ) == 0 ) 464 { 465 pqad->no = fn; 466 pqad->no_i = i; 467 } 468 } 469 470 pqad->user_data = user_data; 471 472 q = g_strdup_printf( "Request: %s\n\n%s\n\n%s", title, primary, secondary ); 473 pqad->bee_data = query_add( local_irc, purple_ic_by_pa( account ), q, 474 prplcb_request_action_yes, prplcb_request_action_no, pqad ); 475 476 g_free( q ); 477 } 478 479 static PurpleRequestUiOps bee_request_uiops = 480 { 481 NULL, 482 NULL, 483 prplcb_request_action, 484 NULL, 485 NULL, 486 NULL, 487 NULL, 488 }; 489 409 490 static void prplcb_debug_print( PurpleDebugLevel level, const char *category, const char *arg_s ) 410 491 { … … 446 527 purple_connections_set_ui_ops( &bee_conn_uiops ); 447 528 purple_conversations_set_ui_ops( &bee_conv_uiops ); 529 purple_request_set_ui_ops( &bee_request_uiops ); 448 530 //purple_debug_set_ui_ops( &bee_debug_uiops ); 449 531 }
Note: See TracChangeset
for help on using the changeset viewer.