xmlnode * _h_elim_image ( const char *name , const char *id , SEXP_VALUE *args , gpointer data ) { ASSERT_ALISTP( args, id, name ); xmlnode *rval = xnode_new( "alist" ); int image_id = (int)ALIST_VAL_INT( args, "image-id" ); if( image_id <= 0 ) { sexp_val_free( args ); return response_error( EINVAL, id, name, "bad image ID" ); } fprintf( stderr, "searching for image id %d\n", image_id ); PurpleStoredImage *image = purple_imgstore_find_by_id( image_id ); if( !image ) { sexp_val_free( args ); return response_error( ENOENT, id, name, "image ID not found" ); } size_t size = IGET( image , size ); AL_INT ( rval, "image-id" , image_id ); AL_INT ( rval, "image-size", size ); AL_STR ( rval, "image-file", IGET( image, filename ) ); AL_STR ( rval, "image-type", IGET( image, extension ) ); AL_DATA( rval, "image-data", IGET( image, data ) , size ); sexp_val_free( args ); return response_value( 0, id, name, rval ); }
xmlnode * _h_elim_notify_search_callback ( const char *name , const char *id , SEXP_VALUE *args , gpointer data ) { GList *item = NULL; xmlnode *rval = NULL; const char *sid = ALIST_VAL_STR( args, "search-id" ); CB_HANDLER *cbh = check_cb_data( sid ); NOTIFY_RESP *resp = cbh ? cbh->data : NULL; if( ( (cbh ->type) == CB_TYPE_NOTIFY_SEARCH ) && ( (resp->type) == PURPLE_NOTIFY_SEARCHRESULTS ) ) { GList *row = NULL; PNSB *btn = NULL; PNSR *res = resp->sres; GList *rows = resp->rows; PA *auid = ALIST_VAL_PTR( args, "account-uid" ); PNSRCB cbid = ALIST_VAL_PTR( args, "callback" ); gint ridx = ALIST_VAL_INT( args, "row-index" ); PA *acct = find_acct_by_uid( auid ); PC *gc = purple_account_get_connection( acct ); gint i; fprintf( stderr, "cached row data: %p\n", rows ); for( item = rows; item; item = item->next ) { GList *cell; fprintf( stderr, "|" ); for( cell = item->data; cell; cell = cell->next ) fprintf( stderr, " %s |", (char *)cell->data ); fprintf( stderr, "\n" ); } if( gc && rows ) { for( i = 0, item = rows; item; item = item->next, i++ ) if( i == ridx ) { row = item; break; } for( item = res->buttons; item; item = item->next ) if( ((PNSB *)item->data)->callback == cbid ) { btn = item->data; break; } } fprintf( stderr, "+ search-row: %s\n", (gchar *)row->data ); if( gc && row && btn && btn->callback ) ( btn->callback )( gc, row->data, resp->user_data ); } sexp_val_free( args ); return rval; }
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 ); }
xmlnode * _h_elim_status ( const char *name , const char *id , SEXP_VALUE *args , gpointer data ) { fprintf(stderr, "(elim-debug entered _h_elim_status)"); ASSERT_ALISTP( args, id, name ); elim_ping(); const char *sid = ALIST_VAL_STR( args, "status-id" ); const char *mesg = ALIST_VAL_STR( args, "status-message" ); signed int _stype = ALIST_VAL_INT( args, "status-type" ); PurpleSavedStatus *status = purple_savedstatus_find( sid ); PurpleStatusPrimitive stype = PURPLE_STATUS_UNSET; // create a new status: if( !status ) { CHECK_STATUS ( args, id, name, stype, _stype ); status = purple_savedstatus_new( sid, stype ); if( status ) { if ( mesg ) purple_savedstatus_set_message( status, mesg ); else if( sid ) purple_savedstatus_set_message( status, sid ); } } else { if( mesg ) purple_savedstatus_set_message( status, mesg ); } if( !status ) { sexp_val_free( args ); return response_error( EINVAL, id, name, "Could not create status" ); } purple_savedstatus_activate( status ); xmlnode *rval = xnode_new( "alist" ); AL_STR ( rval, "status-id" , purple_savedstatus_get_title (status) ); AL_STR ( rval, "status-message", purple_savedstatus_get_message(status) ); AL_ENUM( rval, "status-type" , purple_savedstatus_get_type (status) , ":status-primitive" ); sexp_val_free( args ); fprintf(stderr, "(elim-debug leaving _h_elim_status)"); return response_value( 0, id, name, rval ); }
static xmlnode * _elim_request_authorise_cb( gpointer ptr, SEXP_VALUE *args ) { AUI_RESP *handle = ptr; if( handle && args && (args->type == SEXP_ALIST) ) { gpointer data = handle->data; int status = ALIST_VAL_INT( args, "status" ); if( status == 0 ) { gboolean ok = ALIST_VAL_BOOL( args, "value" ); ( ok ? handle->ok : handle->nok )( data ); } } if( handle ) g_free( handle ); if( args ) sexp_val_free( args ); return NULL; }