コード例 #1
0
ファイル: test-write-covers.c プロジェクト: amboxer21/libgpod
int
main (int argc, char **argv)
{
	Itdb_iTunesDB *db;
	GList *it;
	GList *covers;
	int nb_covers;

	if (argc < 3) {
		g_print ("Usage: %s mountpoint image-dir\n", argv[0]);
		return 1;
	}
	
	setlocale (LC_ALL, "");
#if !GLIB_CHECK_VERSION(2, 36, 0)
	g_type_init ();
#endif
	covers = get_cover_list (argv[2]);
	if (covers == NULL) {
		g_print ("Error, %s should be a directory containing pictures\n", argv[2]);
		return 1;
	}
	nb_covers = g_list_length (covers);
	db = itdb_parse (argv[1], NULL);
	if (db == NULL) {
		g_print ("Error reading iPod database\n");
		return 1;
	}
	for (it = db->tracks; it != NULL; it = it->next) {
		Itdb_Track *song;
		const char *coverpath;

		song = (Itdb_Track*)it->data;
		itdb_artwork_remove_thumbnails (song->artwork);

		coverpath = g_list_nth_data (covers, 
					     g_random_int_range (0, nb_covers));
		itdb_track_set_thumbnails (song, coverpath);
/*		g_print ("%s - %s - %s gets %s\n",  
		song->artist, song->album, song->title, coverpath);*/

	}
/*	if (db->tracks != NULL) {
		Itdb_Track *song;
		const char *coverpath;
		
		song = (Itdb_Track *)db->tracks->data;
		coverpath = g_list_nth_data (covers, 
					     g_random_int_range (0, nb_covers));
		itdb_track_remove_thumbnail (song);
		itdb_track_set_thumbnail (song, coverpath);
		}*/

	itdb_write (db, NULL);
	itdb_free (db);
	g_list_foreach (covers, (GFunc)g_free, NULL);
	g_list_free (covers);

	return 0;
}
コード例 #2
0
ファイル: gpoddb.cpp プロジェクト: ForNeVeR/leechcraft
	bool GpodDb::Save () const
	{
		qDebug () << Q_FUNC_INFO;
		GError *gerr = nullptr;
		itdb_write (DB_, &gerr);

		if (!gerr)
			return true;

		qDebug () << Q_FUNC_INFO
				<< gerr->message;
		g_error_free (gerr);
		return false;
	}
コード例 #3
0
static void
rb_itdb_save (RbIpodDb *ipod_db, GError **error)
{
	RbIpodDbPrivate *priv = IPOD_DB_GET_PRIVATE (ipod_db);
	GError *err = NULL;

	rb_debug ("Writing iPod database to disk");
	if (itdb_write (priv->itdb, &err) == FALSE) {
		g_warning ("Could not write database to iPod: %s", err->message);
		g_propagate_error (error, err);
		return;
	}
	if (priv->needs_shuffle_db) {
		itdb_shuffle_write (priv->itdb, error);
	}
}
コード例 #4
0
ファイル: gpoddevice.cpp プロジェクト: Aceler/Clementine
void GPodDevice::WriteDatabase(bool success) {
  if (success) {
    // Write the itunes database
    GError* error = nullptr;
    itdb_write(db_, &error);
    if (error) {
      qLog(Error) << "writing database failed:" << error->message;
      app_->AddError(QString::fromUtf8(error->message));
      g_error_free(error);
    } else {
      FinaliseDatabase();

      // Update the library model
      if (!songs_to_add_.isEmpty()) backend_->AddOrUpdateSongs(songs_to_add_);
      if (!songs_to_remove_.isEmpty()) backend_->DeleteSongs(songs_to_remove_);
    }
  }

  songs_to_add_.clear();
  songs_to_remove_.clear();
  db_busy_.unlock();
}