gboolean Lyric_SetSearchApp(gint nIndex, AppInfo app) { if (nIndex > Lyric_GetSearchAppCount())return FALSE; ConfigDb *cfgfile = aud_cfg_db_open(); gchar szKey[200] = {0}; sprintf(szKey, "SearchApp_App_%d", nIndex); aud_cfg_db_set_string(cfgfile, PLUGIN_NAME, szKey, app.szApp); sprintf(szKey, "SearchApp_Name_%d", nIndex); aud_cfg_db_set_string(cfgfile, PLUGIN_NAME, szKey, app.szName); if (nIndex == Lyric_GetSearchAppCount()) { aud_cfg_db_set_int(cfgfile, PLUGIN_NAME, "SearchAppCount", nIndex + 1); } aud_cfg_db_close(cfgfile); return TRUE; }
// 保存配置信息 // @pConfigs: 配置信息 gboolean Lyric_SaveConfigs(IN Configs* pConfigs) { // 保存配置信息 ConfigDb *cfgfile = aud_cfg_db_open(); aud_cfg_db_set_string(cfgfile, PLUGIN_NAME, "LyricPath", pConfigs->szLyricPath); aud_cfg_db_set_int(cfgfile, PLUGIN_NAME, "SearchAppIndex", pConfigs->nSearchAppIndex); #define SAVE_COLOR(name, color) do {\ gchar* lpszColor = gdk_color_to_string (&color);\ aud_cfg_db_set_string(cfgfile, PLUGIN_NAME, name, lpszColor);\ free(lpszColor);\ }while(0) SAVE_COLOR("BackgroundColor", pConfigs->colors.background); SAVE_COLOR("NormalColor", pConfigs->colors.normal); SAVE_COLOR("CurrColor", pConfigs->colors.current); SAVE_COLOR("DragColor", pConfigs->colors.drag); SAVE_COLOR("MsgColor", pConfigs->colors.msg); SAVE_COLOR("ErrorColor", pConfigs->colors.error); aud_cfg_db_set_bool(cfgfile, PLUGIN_NAME, "ShowWindowLyric", pConfigs->bShowWindowLyric); aud_cfg_db_set_bool(cfgfile, PLUGIN_NAME, "IsKaLaOK", pConfigs->bIsKaLaOK); aud_cfg_db_set_bool(cfgfile, PLUGIN_NAME, "SmartShowWin", pConfigs->bSmartShowWin); aud_cfg_db_set_bool(cfgfile, PLUGIN_NAME, "ShowBroad", pConfigs->bShowBroad); aud_cfg_db_set_bool(cfgfile, PLUGIN_NAME, "SmartDownLoad", pConfigs->bSmartDownLoad); aud_cfg_db_set_bool(cfgfile, PLUGIN_NAME, "SaveLyricToSongFolder", pConfigs->bSaveLyricToSongFolder); aud_cfg_db_set_bool(cfgfile, PLUGIN_NAME, "SaveLyricAsFileName", pConfigs->bSaveLyricAsFileName); aud_cfg_db_set_int(cfgfile, PLUGIN_NAME, "Opacity", pConfigs->iOpacity); aud_cfg_db_set_int(cfgfile, PLUGIN_NAME, "Pos_iX", pConfigs->pos.iX); aud_cfg_db_set_int(cfgfile, PLUGIN_NAME, "Pos_iY", pConfigs->pos.iY); aud_cfg_db_set_string(cfgfile, PLUGIN_NAME, "LyricFontName", pConfigs->szLyricFontName); aud_cfg_db_set_string(cfgfile, PLUGIN_NAME, "LyricEncode", pConfigs->szLyricEncode); aud_cfg_db_set_bool(cfgfile, PLUGIN_NAME, "ShowOSDLyric", pConfigs->bShowOSDLyric ); aud_cfg_db_set_string(cfgfile, PLUGIN_NAME, "OSD_fake_translucent_bg", pConfigs->OSD.fake_translucent_bg); aud_cfg_db_set_string(cfgfile, PLUGIN_NAME, "OSD_vposition", pConfigs->OSD.vposition); aud_cfg_db_set_string(cfgfile, PLUGIN_NAME, "OSD_halignment", pConfigs->OSD.halignment); aud_cfg_db_set_string(cfgfile, PLUGIN_NAME, "OSD_animations", pConfigs->OSD.animations); aud_cfg_db_set_string(cfgfile, PLUGIN_NAME, "OSD_font", pConfigs->OSD.szFontName); aud_cfg_db_close(cfgfile); return TRUE; }
void write_xmms_config() { /*char tempname[100];*/ char *tempname = (char *)malloc(sizeof(char)*100); int count; GSList *position = cdcover_config.cover_searchpaths; GSList *positionext = cdcover_config.cover_extensions; mcs_handle_t *config; DPRINT (__DEBUG_GENERAL__,"Writing config"); config = aud_cfg_db_open (); if (config) { // Window position aud_cfg_db_set_bool (config,PLUGIN_NAME,"savewindowpos",cdcover_config.save_window_pos); aud_cfg_db_set_int (config,PLUGIN_NAME,"windowposx",cdcover_config.winpos_x); aud_cfg_db_set_int (config,PLUGIN_NAME,"windowposy",cdcover_config.winpos_y); // Aspect ratio aud_cfg_db_set_bool (config,PLUGIN_NAME,"aspectratio",cdcover_config.preserve_aspectratio); // Iterate through the search list and save the paths count=0; while (position!=NULL) { count++; sprintf (tempname,"path%d",count); aud_cfg_db_set_string (config,PLUGIN_NAME,tempname,position->data); //printf("Wrote path %s (%d, %s)\n", (char *)position->data, count, tempname); position = g_slist_next (position); } //printf("Done writing paths\n"); // Delete the next key, so there's a hole and read_xmms_config can stop here // Not too nice, as we probably leave garbage in the xmms config file sprintf (tempname,"path%d",count+1); aud_cfg_db_unset_key (config,PLUGIN_NAME,tempname); // Iterate through the search list and save the extensions count=0; //printf("About to write extensions\n"); while (positionext!=NULL) { count++; sprintf (tempname,"ext%d",count); aud_cfg_db_set_string (config,PLUGIN_NAME,tempname,positionext->data); //printf("Wrote extension %s (%d, %s)\n", (char *)positionext->data, count, tempname); positionext = g_slist_next (positionext); } //printf("Done with the extensions too\n"); // Delete the next key, so there's a hole and read_xmms_config can stop here // Not too nice, as we probably leave garbage in the xmms config file sprintf (tempname,"ext%d",count+1); aud_cfg_db_unset_key (config,PLUGIN_NAME,tempname); // Save the skin if (cdcover_config.skin_path!=NULL) { // Save the user selected skin aud_cfg_db_set_string (config,PLUGIN_NAME,"skinpath",cdcover_config.skin_path); } else { // Built in default skin, delete the key aud_cfg_db_unset_key (config,PLUGIN_NAME,"skinpath"); } // Write and then free the config //printf("About to close config file\n"); aud_cfg_db_close (config); //printf("Closed config file\n"); } else { DPRINT (__DEBUG_GENERAL__,"cannot open config file for writing"); } }