GSList *search_skins_indirectory (char *dirname,GSList *skinlist) { DIR *dirhandle; struct dirent *direntry; mcs_handle_t *config; gchar *skin_path; dirhandle = opendir (dirname); if (dirhandle>0) { while ((direntry=readdir(dirhandle))) { if (fnmatch("*.ini",direntry->d_name,0)==0) { // Construct the skin path skin_path = g_strconcat (dirname,DIR_SEPARATOR_STRING,direntry->d_name,NULL); // We found a inifile, read the data //config = xmms_cfg_open_file (skin_path); config = aud_cfg_db_open (); if (config) { gchar *skin_type,*skin_author,*skin_path_copy,*skin_title; _skinsearch_entry *skinentry = malloc (sizeof(_skinsearch_entry)); skin_type=skin_author=skin_title=NULL; // Test the skin type aud_cfg_db_get_string (config,"SKIN","skintype",&skin_type); if (skin_type==NULL) break; if (strcmp(skin_type,SKIN_TYPE_IDENTIFIER)) break; // Read in the author aud_cfg_db_get_string (config,"SKIN","author",&skin_author); skinentry->skin_author = skin_author; // Read in the title aud_cfg_db_get_string (config,"SKIN","title",&skin_title); skinentry->skin_title = skin_title; // Save the skin path skin_path_copy = strdup (skin_path); skinentry->skin_path = skin_path_copy; DPRINT (__DEBUG_GENERAL__,"Found skin: '%s','%s','%s'", skinentry->skin_title,skinentry->skin_author,skinentry->skin_path); // Save the new entry to our skinlist skinlist = g_slist_append (skinlist,skinentry); // Free the unused skin_type and free config g_free (skin_type); aud_cfg_db_close (config); } g_free (skin_path); } } closedir (dirhandle); } return skinlist; }
gboolean Lyric_GetSearchApp(gint nIndex, AppInfo* pApp) { if (nIndex >= Lyric_GetSearchAppCount()) return FALSE; ConfigDb *cfgfile = aud_cfg_db_open(); gchar *lpszTmp= NULL; gchar szKey[200] = {0}; sprintf(szKey, "SearchApp_App_%d", nIndex); aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, szKey, &lpszTmp); strncpy(pApp->szApp, lpszTmp, MAX_PATH); sprintf(szKey, "SearchApp_Name_%d", nIndex); aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, szKey, &lpszTmp); strncpy(pApp->szName, lpszTmp, MAX_PATH); aud_cfg_db_close(cfgfile); return TRUE; }
// 加载配置信息 // @pConfigs: 配置信息 gboolean Lyric_LoadConfigs(OUT Configs* pConfigs) { int iTmp = 0; // 加载配置信息 ConfigDb *cfgfile = aud_cfg_db_open(); gchar *lpszTmp= NULL; if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "LyricPath", &lpszTmp)) { strncpy(pConfigs->szLyricPath, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_int(cfgfile, PLUGIN_NAME, "SearchAppIndex", &iTmp)) pConfigs->nSearchAppIndex = iTmp; #define LOAD_COLOR(name, to) if(aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, name, &lpszTmp)) {\ gdk_color_parse(lpszTmp, &to);\ } LOAD_COLOR("BackgroundColor", pConfigs->colors.background); LOAD_COLOR("NormalColor", pConfigs->colors.normal); LOAD_COLOR("CurrColor", pConfigs->colors.current); LOAD_COLOR("DragColor", pConfigs->colors.drag); LOAD_COLOR("MsgColor", pConfigs->colors.msg); LOAD_COLOR("ErrorColor", pConfigs->colors.error); gboolean bTmp = FALSE; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "ShowWindowLyric", &bTmp)) pConfigs->bShowWindowLyric = bTmp; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "SmartShowWin", &bTmp)) pConfigs->bSmartShowWin = bTmp; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "SmartDownLoad", &bTmp)) pConfigs->bSmartDownLoad = bTmp; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "ShowBroad", &bTmp)) pConfigs->bShowBroad = bTmp; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "SaveLyricToSongFolder", &bTmp)) pConfigs->bSaveLyricToSongFolder = bTmp; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "SaveLyricAsFileName", &bTmp)) { pConfigs->bSaveLyricAsFileName = bTmp; } if (aud_cfg_db_get_int(cfgfile, PLUGIN_NAME, "Opacity", &iTmp)) pConfigs->iOpacity = iTmp; if (aud_cfg_db_get_int(cfgfile, PLUGIN_NAME, "Pos_iX", &iTmp)) pConfigs->pos.iX = iTmp; if (aud_cfg_db_get_int(cfgfile, PLUGIN_NAME, "Pos_iY", &iTmp)) pConfigs->pos.iY = iTmp; if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "LyricFontName", &lpszTmp)) { strncpy(pConfigs->szLyricFontName, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "LyricEncode", &lpszTmp)) { strncpy(pConfigs->szLyricEncode, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "ShowOSDLyric", &bTmp)) pConfigs->bShowOSDLyric = bTmp; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "IsKaLaOK", &bTmp)) pConfigs->bIsKaLaOK = bTmp; if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "OSD_fake_translucent_bg", &lpszTmp)) { strncpy(pConfigs->OSD.fake_translucent_bg, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "OSD_vposition", &lpszTmp)) { strncpy(pConfigs->OSD.vposition, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "OSD_halignment", &lpszTmp)) { strncpy(pConfigs->OSD.halignment, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "OSD_animations", &lpszTmp)) { strncpy(pConfigs->OSD.animations, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "OSD_font", &lpszTmp)) { strncpy(pConfigs->OSD.szFontName, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } aud_cfg_db_close(cfgfile); return TRUE; }
void read_xmms_config() { int count; /*char tempname[100];*/ char *tempname = (char *)malloc(sizeof(char)*100); gchar *path; gchar *ext; mcs_handle_t *config; DPRINT (__DEBUG_GENERAL__,"Starting to read xmms config"); // empty cover search list, the plugin is probably initialized twice by the user g_slist_free (cdcover_config.cover_searchpaths); cdcover_config.cover_searchpaths = NULL; // empty extension search list, the plugin is probably initialized twice by the user g_slist_free (cdcover_config.cover_extensions); cdcover_config.cover_extensions = NULL; config = aud_cfg_db_open (); if (config) { // Window position aud_cfg_db_get_bool (config,PLUGIN_NAME,"savewindowpos",&cdcover_config.save_window_pos); aud_cfg_db_get_int (config,PLUGIN_NAME,"windowposx",&cdcover_config.winpos_x); aud_cfg_db_get_int (config,PLUGIN_NAME,"windowposy",&cdcover_config.winpos_y); // Aspect ratio aud_cfg_db_get_bool (config,PLUGIN_NAME,"aspectratio",&cdcover_config.preserve_aspectratio); // Skin if (!aud_cfg_db_get_string (config,PLUGIN_NAME,"skinpath",&cdcover_config.skin_path)) { cdcover_config.skin_path = NULL; } // Read in the paths sprintf (tempname,"path1"); count=1; while (aud_cfg_db_get_string (config,PLUGIN_NAME,tempname,&path)) { // save the pointer to this resource string in the list cdcover_config.cover_searchpaths = g_slist_append (cdcover_config.cover_searchpaths,path); //printf("Got path '%s' with var %s\n", path, tempname); // construct next path variable count++; sprintf (tempname,"path%d",count); } // Where we able to read any search paths ? if (g_slist_length(cdcover_config.cover_searchpaths)==0) { // Some default paths to start with // Allocate memory, so we can free it on shutdown //printf("No paths found, populating with defaults\n"); gchar *path1 = g_strconcat ("?PATH?/cover.jpg",NULL); gchar *path2 = g_strconcat ("?PATH?/?BASE?.jpg",NULL); gchar *path3 = g_strconcat ("?PATH?/media/?FILENAME?.jpg",NULL); gchar *path4 = g_strconcat ("?PATH?/*.jpg",NULL); cdcover_config.cover_searchpaths = g_slist_append (cdcover_config.cover_searchpaths,path1); cdcover_config.cover_searchpaths = g_slist_append (cdcover_config.cover_searchpaths,path2); cdcover_config.cover_searchpaths = g_slist_append (cdcover_config.cover_searchpaths,path3); cdcover_config.cover_searchpaths = g_slist_append (cdcover_config.cover_searchpaths,path4); } // Read in the extensions sprintf (tempname,"ext1"); count=1; while (aud_cfg_db_get_string (config,PLUGIN_NAME,tempname,&ext)) { // save the pointer to this resource string in the list cdcover_config.cover_extensions = g_slist_append (cdcover_config.cover_extensions,ext); //printf("Got ext '%s' with var %s\n", ext, tempname); // construct next path variable count++; sprintf (tempname,"ext%d",count); } // Were we able to read any extensions? if (g_slist_length(cdcover_config.cover_extensions)==0) { // Some default extensions to start with // Allocate memory, so we can free it on shutdown //printf("No extensions found, populating with defaults\n"); gchar *ext1 = g_strconcat ("png",NULL); gchar *ext2 = g_strconcat ("jpg",NULL); gchar *ext3 = g_strconcat ("gif",NULL); cdcover_config.cover_extensions = g_slist_append(cdcover_config.cover_extensions,ext1); cdcover_config.cover_extensions = g_slist_append(cdcover_config.cover_extensions,ext2); cdcover_config.cover_extensions = g_slist_append(cdcover_config.cover_extensions,ext3); } // Free config handle aud_cfg_db_close (config); } else { DPRINT (__DEBUG_GENERAL__,"Cannot open config file"); } }