gboolean cid_check_conf_file_version (const gchar *f) { gchar *cCommand=NULL; gchar line_f1[80], line_f2[80]; FILE *f1, *f2; gchar *cOrigFile = g_strdup_printf("%s/%s",CID_DATA_DIR, CID_CONFIG_FILE); f1 = fopen ((const char *)cOrigFile,"r"); f2 = fopen ((const char *)f,"r"); g_free (cOrigFile); if (!fgets(line_f1,80,f1) || !fgets(line_f2,80,f2)) cid_exit (3,"couldn't read conf file, try to delete it"); fclose (f1); fclose (f2); cid_message ("line_f1 %s / line_f2 %s\n",line_f1,line_f2); if (strcmp(line_f1,line_f2)!=0 || bUnvalidKey) { cid_warning ("bad file version, building a new one\n"); cid_remove_file (f); gchar *cTmpPath = g_strdup_printf("%s/%s",CID_DATA_DIR,CID_CONFIG_FILE); cid_copy_file(cTmpPath,f); g_free (cTmpPath); cid_save_data (); cid_read_key_file (f); return FALSE; } return TRUE; }
void getSongInfos(void) { GHashTable *data_list = NULL; GValue *value; const gchar *data; if(dbus_g_proxy_call (dbus_proxy_shell, "getSongProperties", NULL, G_TYPE_STRING, musicData.playing_uri, G_TYPE_INVALID, dbus_g_type_get_map("GHashTable",G_TYPE_STRING, G_TYPE_VALUE), &data_list, G_TYPE_INVALID)) { g_free (musicData.playing_artist); value = (GValue *) g_hash_table_lookup(data_list, "artist"); if (value != NULL && G_VALUE_HOLDS_STRING(value)) musicData.playing_artist = g_strdup (g_value_get_string(value)); else musicData.playing_artist = NULL; cid_message (" playing_artist <- %s\n", musicData.playing_artist); g_free (musicData.playing_album); value = (GValue *) g_hash_table_lookup(data_list, "album"); if (value != NULL && G_VALUE_HOLDS_STRING(value)) musicData.playing_album = g_strdup (g_value_get_string(value)); else musicData.playing_album = NULL; cid_message (" playing_album <- %s\n", musicData.playing_album); g_free (musicData.playing_title); value = (GValue *) g_hash_table_lookup(data_list, "title"); if (value != NULL && G_VALUE_HOLDS_STRING(value)) musicData.playing_title = g_strdup (g_value_get_string(value)); else musicData.playing_title = NULL; cid_message (" playing_title <- %s\n", musicData.playing_title); value = (GValue *) g_hash_table_lookup(data_list, "track-number"); if (value != NULL && G_VALUE_HOLDS_UINT(value)) musicData.playing_track = g_value_get_uint(value); else musicData.playing_track = 0; cid_message (" playing_track <- %d\n", musicData.playing_track); value = (GValue *) g_hash_table_lookup(data_list, "duration"); if (value != NULL && G_VALUE_HOLDS_UINT(value)) musicData.playing_duration = g_value_get_uint(value); else musicData.playing_duration = 0; cid_message (" playing_duration <- %ds\n", musicData.playing_duration); value = (GValue *) g_hash_table_lookup(data_list, "rb:coverArt-uri"); g_free (musicData.playing_cover); if (value != NULL && G_VALUE_HOLDS_STRING(value)) { GError *erreur = NULL; const gchar *cString = g_value_get_string(value); if (cString != NULL && strncmp (cString, "file://", 7) == 0) { musicData.playing_cover = g_filename_from_uri (cString, NULL, &erreur); if (erreur != NULL) { cid_warning ("Attention : %s\n", erreur->message); g_error_free (erreur); } } else { musicData.playing_cover = g_strdup (cString); } } else { CidDataTable *p_tabFiles = cid_create_datatable(G_TYPE_STRING,"cover","album","albumart", ".folder",".cover","folder","Cover","Folder", G_TYPE_INVALID); gchar *cSongPath = g_filename_from_uri (musicData.playing_uri, NULL, NULL); // on teste d'abord dans le repertoire de la chanson. if (cSongPath != NULL) { gchar *cSongDir = g_path_get_dirname (cSongPath); g_free (cSongPath); musicData.playing_cover = g_strdup_printf ("%s/%s - %s.jpg", cSongDir, musicData.playing_artist, musicData.playing_album); cid_debug (" test de %s\n", musicData.playing_cover); BEGIN_FOREACH_DT(p_tabFiles) if (g_file_test (musicData.playing_cover, G_FILE_TEST_EXISTS)) break; g_free (musicData.playing_cover); musicData.playing_cover = g_strdup_printf ("%s/%s.jpg", cSongDir, p_temp->content->string); cid_debug (" test de %s\n", musicData.playing_cover); END_FOREACH_DT if (! g_file_test (musicData.playing_cover, G_FILE_TEST_EXISTS)) { cid_debug (" test de %s (.gnome2)\n", musicData.playing_cover); g_free (musicData.playing_cover); musicData.playing_cover = g_strdup_printf("%s/.gnome2/rhythmbox/covers/%s - %s.jpg", g_getenv("HOME"),musicData.playing_artist, musicData.playing_album); } if (! g_file_test (musicData.playing_cover, G_FILE_TEST_EXISTS)) { cid_debug (" test de %s (.cache)\n", musicData.playing_cover); g_free (musicData.playing_cover); musicData.playing_cover = g_strdup_printf("%s/.cache/rhythmbox/covers/%s - %s.jpg", g_getenv("HOME"),musicData.playing_artist, musicData.playing_album); } g_free (cSongDir); if (! g_file_test (musicData.playing_cover, G_FILE_TEST_EXISTS)) { cid->runtime->iCheckIter = 0; if (musicData.iSidCheckCover == 0 && cid->config->iPlayer != PLAYER_NONE) { cid_debug ("l'image n'existe pas encore => on boucle.\n"); musicData.iSidCheckCover = g_timeout_add (1 SECONDES, (GSourceFunc) _check_cover_is_present, (gpointer) NULL); } } } }