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 ); }
void purple_prefs_init(void) { void *handle = purple_prefs_get_handle(); prefs_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); purple_prefs_connect_callback(handle, "/", prefs_save_cb, NULL); purple_prefs_add_none("/purple"); purple_prefs_add_none("/plugins"); purple_prefs_add_none("/plugins/core"); purple_prefs_add_none("/plugins/lopl"); purple_prefs_add_none("/plugins/prpl"); /* Away */ purple_prefs_add_none("/purple/away"); purple_prefs_add_string("/purple/away/idle_reporting", "system"); purple_prefs_add_bool("/purple/away/away_when_idle", TRUE); purple_prefs_add_int("/purple/away/mins_before_away", 5); /* Away -> Auto-Reply */ if (!purple_prefs_exists("/purple/away/auto_response/enabled") || !purple_prefs_exists("/purple/away/auto_response/idle_only")) { purple_prefs_add_string("/purple/away/auto_reply", "awayidle"); } else { if (!purple_prefs_get_bool("/purple/away/auto_response/enabled")) { purple_prefs_add_string("/purple/away/auto_reply", "never"); } else { if (purple_prefs_get_bool("/purple/away/auto_response/idle_only")) { purple_prefs_add_string("/purple/away/auto_reply", "awayidle"); } else { purple_prefs_add_string("/purple/away/auto_reply", "away"); } } } /* Buddies */ purple_prefs_add_none("/purple/buddies"); /* Contact Priority Settings */ purple_prefs_add_none("/purple/contact"); purple_prefs_add_bool("/purple/contact/last_match", FALSE); purple_prefs_remove("/purple/contact/offline_score"); purple_prefs_remove("/purple/contact/away_score"); purple_prefs_remove("/purple/contact/idle_score"); purple_prefs_load(); purple_prefs_update_old(); }
static void init_libpurple(void) { /* Set a custom user directory (optional) */ purple_util_set_user_dir(CUSTOM_USER_DIRECTORY); /* Set path to search for plugins. The core (libpurple) takes care of loading the * core-plugins, which includes the protocol-plugins. So it is not essential to add * any path here, but it might be desired, especially for ui-specific plugins. */ purple_plugins_add_search_path(CUSTOM_PLUGIN_PATH); /* We do not want any debugging for now to keep the noise to a minimum. */ if (g_debug) purple_debug_set_enabled(TRUE); else purple_debug_set_enabled(FALSE); /* Set the core-uiops, which is used to * - initialize the ui specific preferences. * - initialize the debug ui. * - initialize the ui components for all the modules. * - uninitialize the ui components for all the modules when the core terminates. */ purple_core_set_ui_ops(&null_core_uiops); /* Set the uiops for the eventloop. If your client is glib-based, you can safely * copy this verbatim. */ purple_eventloop_set_ui_ops(null_eventloop_get_ui_ops()); /* Now that all the essential stuff has been set, let's try to init the core. It's * necessary to provide a non-NULL name for the current ui to the core. This name * is used by stuff that depends on this ui, for example the ui-specific plugins. */ if (!purple_core_init(UI_ID)) { /* Initializing the core failed. Terminate. */ fprintf(stderr, "libpurple initialization failed. Dumping core.\n" "Please report this!\n"); abort(); } /* Create and load the buddylist. */ purple_set_blist(purple_blist_new()); purple_blist_load(); /* Load the preferences. */ purple_prefs_load(); /* Load the desired plugins. The client should save the list of loaded plugins in * the preferences using purple_plugins_save_loaded(PLUGIN_SAVE_PREF) */ purple_plugins_load_saved(PLUGIN_SAVE_PREF); /* Load the pounces. */ purple_pounces_load(); }
static VALUE init(int argc, VALUE *argv, VALUE self) { VALUE debug, path, settings; rb_scan_args(argc, argv, "01", &settings); if (argc == 0) { debug = Qnil; path = Qnil; } else { settings = rb_convert_type(settings, T_HASH, "Hash", "to_hash"); debug = rb_hash_aref(settings, ID2SYM(DEBUG)); path = rb_hash_aref(settings, ID2SYM(USER_DIR)); } signal(SIGCHLD, SIG_IGN); signal(SIGPIPE, SIG_IGN); signal(SIGINT, sighandler); signal(SIGQUIT, sighandler); signal(SIGTERM, sighandler); data_hash_table = g_hash_table_new(NULL, NULL); fd_hash_table = g_hash_table_new(NULL, NULL); purple_debug_set_enabled(RTEST(debug) ? TRUE : FALSE); if (path != Qnil) { purple_util_set_user_dir(StringValueCStr(path)); } purple_core_set_ui_ops(&core_uiops); purple_eventloop_set_ui_ops(&glib_eventloops); if (!purple_core_init(UI_ID)) { rb_raise(rb_eRuntimeError, "libpurple initialization failed"); } /* Create and load the buddylist. */ purple_set_blist(purple_blist_new()); purple_blist_load(); /* Load the preferences. */ purple_prefs_load(); /* Load the pounces. */ purple_pounces_load(); return Qnil; }
static VALUE init(int argc, VALUE* argv, VALUE self) { VALUE debug, path; const char *prefs_path = NULL; if( rb_cv_get( self, "@@prefs_path" ) != Qnil ) { prefs_path = RSTRING_PTR( rb_cv_get( self, "@@prefs_path" ) ); } rb_scan_args(argc, argv, "02", &debug, &path); signal(SIGCHLD, SIG_IGN); signal(SIGPIPE, SIG_IGN); signal(SIGINT, sighandler); signal(SIGQUIT, sighandler); signal(SIGTERM, sighandler); data_hash_table = g_hash_table_new(NULL, NULL); fd_hash_table = g_hash_table_new(NULL, NULL); purple_debug_set_enabled((NIL_P(debug) || debug == Qfalse) ? FALSE : TRUE); if (!NIL_P(path)) { Check_Type(path, T_STRING); purple_util_set_user_dir(RSTRING_PTR(path)); } purple_core_set_ui_ops(&core_uiops); purple_eventloop_set_ui_ops(&glib_eventloops); if (!purple_core_init(UI_ID)) { rb_raise(rb_eRuntimeError, "libpurple initialization failed"); } purple_util_set_user_dir( (const char *) prefs_path ); /* Create and load the buddylist. */ purple_set_blist(purple_blist_new()); purple_blist_load(); /* Load the preferences. */ purple_prefs_load(); purple_prefs_set_bool( "/purple/logging/log_ims", FALSE ); purple_prefs_set_bool( "/purple/logging/log_chats", FALSE ); /* Load the pounces. */ purple_pounces_load(); return Qnil; }
static void purple_init( account_t *acc ) { PurplePlugin *prpl = purple_plugins_find_with_id( (char*) acc->prpl->data ); PurplePluginProtocolInfo *pi = prpl->info->extra_info; PurpleAccount *pa; GList *i, *st; set_t *s; char help_title[64]; GString *help; static gboolean dir_fixed = FALSE; /* Layer violation coming up: Making an exception for libpurple here. Dig in the IRC state a bit to get a username. Ideally we should check if s/he identified but this info doesn't seem *that* important. It's just that fecking libpurple can't *not* store this shit. Remember that libpurple is not really meant to be used on public servers anyway! */ if( !dir_fixed ) { irc_t *irc = acc->bee->ui_data; char *dir; dir = g_strdup_printf( "%s/purple/%s", global.conf->configdir, irc->user->nick ); purple_util_set_user_dir( dir ); g_free( dir ); purple_blist_load(); purple_prefs_load(); dir_fixed = TRUE; } help = g_string_new( "" ); g_string_printf( help, "BitlBee libpurple module %s (%s).\n\nSupported settings:", (char*) acc->prpl->name, prpl->info->name ); if( pi->user_splits ) { GList *l; g_string_append_printf( help, "\n* username: Username" ); for( l = pi->user_splits; l; l = l->next ) g_string_append_printf( help, "%c%s", purple_account_user_split_get_separator( l->data ), purple_account_user_split_get_text( l->data ) ); } /* Convert all protocol_options into per-account setting variables. */ for( i = pi->protocol_options; i; i = i->next ) { PurpleAccountOption *o = i->data; const char *name; char *def = NULL; set_eval eval = NULL; void *eval_data = NULL; GList *io = NULL; GSList *opts = NULL; name = purple_account_option_get_setting( o ); switch( purple_account_option_get_type( o ) ) { case PURPLE_PREF_STRING: def = g_strdup( purple_account_option_get_default_string( o ) ); g_string_append_printf( help, "\n* %s (%s), %s, default: %s", name, purple_account_option_get_text( o ), "string", def ); break; case PURPLE_PREF_INT: def = g_strdup_printf( "%d", purple_account_option_get_default_int( o ) ); eval = set_eval_int; g_string_append_printf( help, "\n* %s (%s), %s, default: %s", name, purple_account_option_get_text( o ), "integer", def ); break; case PURPLE_PREF_BOOLEAN: if( purple_account_option_get_default_bool( o ) ) def = g_strdup( "true" ); else def = g_strdup( "false" ); eval = set_eval_bool; g_string_append_printf( help, "\n* %s (%s), %s, default: %s", name, purple_account_option_get_text( o ), "boolean", def ); break; case PURPLE_PREF_STRING_LIST: def = g_strdup( purple_account_option_get_default_list_value( o ) ); g_string_append_printf( help, "\n* %s (%s), %s, default: %s", name, purple_account_option_get_text( o ), "list", def ); g_string_append( help, "\n Possible values: " ); for( io = purple_account_option_get_list( o ); io; io = io->next ) { PurpleKeyValuePair *kv = io->data; opts = g_slist_append( opts, kv->value ); /* TODO: kv->value is not a char*, WTF? */ if( strcmp( kv->value, kv->key ) != 0 ) g_string_append_printf( help, "%s (%s), ", (char*) kv->value, kv->key ); else g_string_append_printf( help, "%s, ", (char*) kv->value ); } g_string_truncate( help, help->len - 2 ); eval = set_eval_list; eval_data = opts; break; default: /** No way to talk to the user right now, invent one when this becomes important. irc_rootmsg( acc->irc, "Setting with unknown type: %s (%d) Expect stuff to break..\n", name, purple_account_option_get_type( o ) ); */ g_string_append_printf( help, "\n* [%s] UNSUPPORTED (type %d)", name, purple_account_option_get_type( o ) ); name = NULL; } if( name != NULL ) { s = set_add( &acc->set, name, def, eval, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; s->eval_data = eval_data; g_free( def ); } } g_snprintf( help_title, sizeof( help_title ), "purple %s", (char*) acc->prpl->name ); help_add_mem( &global.help, help_title, help->str ); g_string_free( help, TRUE ); s = set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc ); s->flags |= ACC_SET_ONLINE_ONLY; if( pi->options & OPT_PROTO_MAIL_CHECK ) { s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; } if( strcmp( prpl->info->name, "Gadu-Gadu" ) == 0 ) s = set_add( &acc->set, "gg_sync_contacts", "true", set_eval_bool, acc ); /* Go through all away states to figure out if away/status messages are possible. */ pa = purple_account_new( acc->user, (char*) acc->prpl->data ); for( st = purple_account_get_status_types( pa ); st; st = st->next ) { PurpleStatusPrimitive prim = purple_status_type_get_primitive( st->data ); if( prim == PURPLE_STATUS_AVAILABLE ) { if( purple_status_type_get_attr( st->data, "message" ) ) acc->flags |= ACC_FLAG_STATUS_MESSAGE; } else if( prim != PURPLE_STATUS_OFFLINE ) { if( purple_status_type_get_attr( st->data, "message" ) ) acc->flags |= ACC_FLAG_AWAY_MESSAGE; } } purple_accounts_remove( pa ); }
void IMInvoker::initLibPurple(void *userdata, const std::string event) { _initMutex.lock(); _uiInfo = g_hash_table_new(g_str_hash, g_str_equal); // g_hash_table_insert(_uiInfo, "name", (char*)"uscxml"); // g_hash_table_insert(_uiInfo, "version", "0.0.3"); // g_hash_table_insert(_uiInfo, "website", "http://uscxml.tk.informatik.tu-darmstadt.de"); // g_hash_table_insert(_uiInfo, "dev_website", "http://uscxml.tk.informatik.tu-darmstadt.de"); // g_hash_table_insert(_uiInfo, "client_type", "pc"); _gRand = g_rand_new(); /* Set a custom user directory (optional) */ //purple_util_set_user_dir(CUSTOM_USER_DIRECTORY); /* We do not want any debugging for now to keep the noise to a minimum. */ purple_debug_set_enabled(false); purple_core_set_ui_ops(&_uiCoreOps); purple_eventloop_set_ui_ops(&_uiEventLoopOps); purple_plugins_add_search_path("/usr/local/lib/purple-3"); // purple_plugins_probe(G_MODULE_SUFFIX); if (!purple_core_init("uscxml")) { LOG(ERROR) << "libpurple initialization failed." << std::endl; return; } /* Load the preferences. */ purple_prefs_load(); purple_plugins_load_saved("/purple/uscxml/plugins/saved"); GList *l; PurplePlugin *plugin; for (l = purple_plugins_get_all(); l != NULL; l = l->next) { plugin = (PurplePlugin *)l->data; Data pluginData; if (plugin->info->id) pluginData.compound["id"] = Data(plugin->info->id, Data::VERBATIM); if (plugin->info->homepage) pluginData.compound["homepage"] = Data(plugin->info->homepage, Data::VERBATIM); if (plugin->info->author) pluginData.compound["author"] = Data(plugin->info->author, Data::VERBATIM); if (plugin->info->description) pluginData.compound["description"] = Data(plugin->info->description, Data::VERBATIM); if (plugin->info->name) pluginData.compound["name"] = Data(plugin->info->name, Data::VERBATIM); if (plugin->info->summary) pluginData.compound["summary"] = Data(plugin->info->summary, Data::VERBATIM); if (plugin->info->version) pluginData.compound["version"] = Data(plugin->info->version, Data::VERBATIM); if (plugin->info->major_version) pluginData.compound["majorVersion"] = Data(toStr(plugin->info->major_version), Data::VERBATIM); if (plugin->info->minor_version) pluginData.compound["minorVersion"] = Data(toStr(plugin->info->minor_version), Data::VERBATIM); if (plugin->info->type == PURPLE_PLUGIN_PROTOCOL) { _pluginData.compound["protocol"].compound[plugin->info->id] = pluginData; } else if (plugin->info->type == PURPLE_PLUGIN_STANDARD) { // _pluginData.compound["standard"].compound[plugin->info->id] = pluginData; } else if (plugin->info->type == PURPLE_PLUGIN_LOADER) { // _pluginData.compound["loader"].compound[plugin->info->id] = pluginData; } } _initMutex.unlock(); _initCond.notify_all(); }