static void _elim_chat_add_users ( PurpleConversation *conv , GList *cbuddies , gboolean new_arrivals ) { char *ID = new_elim_id(); xmlnode *args = xnode_new( "alist" ); xmlnode *list = xnode_new( "list" ); xmlnode *mcall = func_call( "elim-chat-add-users", ID, args ); g_free( ID ); fprintf( stderr, "(_elim_chat_add_users)\n" ); _elim_conv_args( args, conv ); AL_BOOL( args, "new-arrivals" , new_arrivals ); AL_NODE( args, "participants" , list ); fprintf( stderr, "(_elim_chat_add_users)\n" ); for( ; cbuddies; cbuddies = cbuddies->next ) { xmlnode *cbuddy = xnode_new( "alist" ); PurpleConvChatBuddy *pccb = cbuddies->data; AL_STR ( cbuddy, "name" , pccb->name ? pccb->name : "" ); AL_STR ( cbuddy, "alias" , pccb->alias ? pccb->alias : "" ); AL_STR ( cbuddy, "alias-key", pccb->alias_key ? pccb->alias_key : "" ); AL_ENUM( cbuddy, "flags" , pccb->flags , ":conv-chat-buddy-flags" ); AL_BOOL( cbuddy, "on-blist" , pccb->buddy ); xnode_insert_child( list, cbuddy ); } add_outbound_sexp( mcall ); fprintf( stderr, "(_elim_chat_add_users:DONE)\n" ); }
static void _elim_roomlist_add ( PurpleRoomlist *list , PurpleRoomlistRoom *room ) { g_return_if_fail( list && room ); xmlnode *alist = xnode_new( "alist" ); char *ID = new_elim_id(); __roomlist_insert_account( list->account, alist ); AL_PTR ( alist , "roomlist-id" , list ); AL_STR ( alist , "room-name" , room->name ); AL_ENUM( alist , "room-type" , room->type , ":roomlist-room-type" ); AL_PTR ( alist , "room-parent" , room->parent ); AL_BOOL( alist , "room-expanded-once", room->expanded_once ); xmlnode *fields = xnode_new_child( alist, "alist" ); xnode_set_attrib( fields, "name", "fields" ); GList *listf = g_list_first( list->fields ); GList *roomf = g_list_first( room->fields ); #define NNEXTT( a, b ) a = g_list_next( a ), b = g_list_next( b ) #define PTR_TO_BOOL(_p) (_p != NULL) for( ; listf && roomf ; NNEXTT( listf, roomf ) ) { PurpleRoomlistField *f = (PurpleRoomlistField*) listf->data; switch( f->type ) { case PURPLE_ROOMLIST_FIELD_BOOL: AL_BOOL( fields, f->name, PTR_TO_BOOL( roomf->data ) ); break; case PURPLE_ROOMLIST_FIELD_INT: AL_INT ( fields, f->name, roomf->data ); break; case PURPLE_ROOMLIST_FIELD_STRING: AL_STR ( fields, f->name, roomf->data ); break; default: fprintf( stderr, "unsupported room list field type.\n" ); break; } } xmlnode *mcall = func_call( "elim-roomlist-add", ID, alist ); g_free( ID ); add_outbound_sexp( mcall ); }
static void *_elim_request_authorise ( PurpleAccount *account , const char *remote_user , const char *id , const char *alias , const char *message , gboolean on_list , PARA_CB authorize_cb , PARA_CB deny_cb , void *user_data ) { CB_HANDLER *cbh = g_new0( CB_HANDLER, 1 ); AUI_RESP *resp = g_new0( AUI_RESP , 1 ); xmlnode *alist = xnode_new( "alist" ); char *ID = new_elim_id(); fprintf( stderr, "(_elim_request_authorise)\n" ); AL_STR ( alist, "user" , remote_user ); AL_STR ( alist, "id" , id ); AL_STR ( alist, "alias" , alias ); AL_BOOL( alist, "on-list" , on_list ); AL_STR ( alist, "message" , message ); AL_PTR ( alist, "account-uid" , account ); AL_STR ( alist, "account-name", purple_account_get_username ( account ) ); AL_STR ( alist, "im-protocol" , purple_account_get_protocol_id( account ) ); resp->ok = authorize_cb; resp->nok = deny_cb; resp->id = ID; resp->data = user_data; cbh ->func = _elim_request_authorise_cb; cbh ->data = resp; store_cb_data( ID, cbh ); xmlnode *mcall = func_call( "elim-account-request-auth", ID, alist ); add_outbound_sexp( mcall ); return cbh; }
xmlnode * _h_elim_set_prefs ( const char *name , const char *id , SEXP_VALUE *args , gpointer data ) { ASSERT_ALISTP( args, id, name ); elim_ping(); xmlnode *rval = xnode_new( "alist" ); xmlnode *set = xnode_new( "alist" ); GHashTable *prefs = ALIST_VAL_ALIST( args, "prefs" ); SEXP_VALUE *PREFS = ALIST_VAL ( args, "prefs" ); AL_NODE( rval, "prefs", set ); fprintf( stderr, "hash: %p; sexp: %p\n", prefs, PREFS ); if( prefs ) { GList *key = NULL; GList *keys = g_hash_table_get_keys( prefs ); fprintf( stderr, "keys: %p", keys ); for( key = keys; key; key = key->next ) { gboolean done = TRUE; const char *pref = key->data; PurplePrefType type = purple_prefs_get_type( pref ); switch( type ) { case PURPLE_PREF_BOOLEAN: purple_prefs_set_bool ( pref, ALIST_VAL_BOOL( PREFS, pref ) ); break; case PURPLE_PREF_INT: purple_prefs_set_int ( pref, ALIST_VAL_INT ( PREFS, pref ) ); break; case PURPLE_PREF_STRING: purple_prefs_set_string( pref, ALIST_VAL_STR ( PREFS, pref ) ); break; case PURPLE_PREF_PATH: purple_prefs_set_path ( pref, ALIST_VAL_STR ( PREFS, pref ) ); break; default: done = FALSE; } AL_BOOL( set, pref, done ); } g_list_free( keys ); } sexp_val_free( args ); return response_value( 0, id, name, rval ); }
void __roomlist_add_list_field( gpointer _field, gpointer _parent ) { g_return_if_fail( _field && _parent ); PurpleRoomlistField *field = _field; xmlnode *parent = _parent; xmlnode *node = xnode_new( "alist" ); AL_ENUM( node , "field-type" , field->type , ":roomlist-field-type" ); AL_STR ( node , "field-label" , field->label ); AL_STR ( node , "field-name" , field->name ); AL_BOOL( node , "field-hidden", field->hidden ); xnode_insert_child( parent, node ); }
xmlnode * _h_elim_set_icon ( const char *name , const char *id , SEXP_VALUE *args , gpointer data ) { ASSERT_ALISTP( args, id, name ); elim_ping(); const char *aname = ALIST_VAL_STR ( args, "account-name" ); const char *proto = ALIST_VAL_STR ( args, "im-protocol" ); gpointer auid = ALIST_VAL_PTR ( args, "account-uid" ); const char *file = ALIST_VAL_STR ( args, "icon-file" ); GString *img = ALIST_VAL_DATA( args, "icon-data" ); gchar *bytes = NULL; gsize len = 0; gpointer set = NULL; PurpleAccount *acct = auid ? find_acct_by_uid( auid ) : purple_accounts_find( aname, proto ); if( !acct ) { sexp_val_free( args ); return response_error( ENXIO, id, name, "unknown account" ); } if( !img && file && *file ) { g_file_get_contents( file, &bytes, &len, NULL ); } else if( img ) { bytes = g_memdup( img->str, img->len ); len = img->len; } // the imgstore owns `bytes' after this, don't free it: set = purple_buddy_icons_set_account_icon( acct, (guchar *)bytes, len ); xmlnode *rval = xnode_new( "alist" ); AL_PTR ( rval, "account-uid" , acct ); AL_STR ( rval, "account-name", purple_account_get_username ( acct ) ); AL_STR ( rval, "im-protocol" , purple_account_get_protocol_id( acct ) ); AL_BOOL( rval, "has-icon" , set ? TRUE : FALSE ); sexp_val_free( args ); return response_value( 0, id, name, rval ); }
static void _elim_roomlist_in_progress ( PurpleRoomlist *list , gboolean flag ) { g_return_if_fail( list ); xmlnode *alist = xnode_new( "alist" ); char *ID = new_elim_id(); __roomlist_insert_account( list->account, alist ); AL_PTR ( alist , "roomlist-id", list ); AL_BOOL( alist , "in-progress", flag ); xmlnode *mcall = func_call( "elim-roomlist-in-progress", ID, alist ); g_free( ID ); add_outbound_sexp( mcall ); }
static void _elim_status_changed ( PurpleAccount *account , PurpleStatus *status ) { xmlnode *alist = xnode_new( "alist" ); char *ID = new_elim_id(); fprintf( stderr, "(_elim_status_changed)\n" ); PurpleStatusType *type = purple_status_get_type( status ); PurpleStatusPrimitive statp = purple_status_type_get_primitive( type ); AL_PTR ( alist, "account-uid" , account ); AL_STR ( alist, "account-name", purple_account_get_username ( account ) ); AL_STR ( alist, "im-protocol" , purple_account_get_protocol_id( account ) ); AL_STR ( alist, "status-name" , purple_status_get_name ( status ) ); AL_ENUM( alist, "status-type" , statp, ":status-primitive" ); AL_BOOL( alist, "connected" , purple_account_is_connected ( account ) ); xmlnode *mcall = func_call( "elim-account-status-changed", ID, alist ); g_free( ID ); add_outbound_sexp( mcall ); }