示例#1
0
xmlnode * _h_elim_init ( const char *name ,
                         const char *id   ,
                         SEXP_VALUE *args ,
                         gpointer data    )
{
    ASSERT_ALISTP( args, id, name );

    char    *dir = ALIST_VAL_STRING( args, "dot-dir" );
    char    *ui  = ALIST_VAL_STRING( args, "ui-id"   );
    gboolean dbg = ALIST_VAL_BOOL  ( args, "debug"   );

    if( !ui ) { ui = "elim"; }

    // libpurple initialisation:
    purple_util_set_user_dir       ( dir  );
    purple_util_init               ();
    purple_core_set_ui_ops         ( &elim_core_ui_ops         );
    purple_eventloop_set_ui_ops    ( &elim_eventloop_ui_ops    );
    purple_blist_set_ui_ops        ( &elim_blist_ui_ops        );
    purple_accounts_set_ui_ops     ( &elim_account_ui_ops      );
    purple_request_set_ui_ops      ( &elim_request_ui_ops      );
    purple_idle_set_ui_ops         ( &elim_idle_ui_ops         );
    purple_connections_set_ui_ops  ( &elim_connections_ui_ops  );
    purple_conversations_set_ui_ops( &elim_conversation_ui_ops );
    purple_notify_set_ui_ops       ( &elim_notify_ui_ops       );

    // load any data for init:    
    if( purple_get_core() == NULL )
    {
        // purple debug goes to stdout if we don't divert it here:
        g_set_print_handler( (GPrintFunc)_h_elim_warning );
        // look for plugins in user specified directory tree:
        char *ppath = g_build_filename( purple_user_dir(), "plugins", NULL );
        purple_plugins_add_search_path ( ppath );
        purple_debug_set_enabled( dbg );
        purple_core_init ( ui );
        purple_set_blist ( purple_blist_new() );
        purple_prefs_load();
        purple_blist_load();
        // glib signal initialisation:
        elim_ft_signals_init();
        // tidy up:
        g_free( ppath );
    }
    else
    {
        const char *cur_ui = purple_core_get_ui();
        if( strcmp( cur_ui, name ) )
        {
            sexp_val_free( args );
            return response_error( EINVAL, id, name, 
                                   "purple has already been initialised" );
        }
    }

    sexp_val_free( args );
    xmlnode *rval = xnode_new( "alist" );
    AL_STR( rval, "ui-id", purple_core_get_ui() );
    return response_value( 0, id, name, rval );
}
示例#2
0
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 );
}
示例#3
0
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;
}