Beispiel #1
0
void UploadDialog::startTransfer()
{
    if( !m_itdb || !m_uploadList->model()->hasChildren() )
        return;

    QTreeWidgetItem* selected = m_ipodAlbumList->currentItem();
    IpodAlbumItem* ipodAlbum  = dynamic_cast<IpodAlbumItem*>( selected );

    if( !selected || !ipodAlbum )
        return;

    m_transferring         = true;
    Itdb_PhotoAlbum* album = ipodAlbum->photoAlbum();

    enableButton(User1, false);
    enableButton(Close, false);

    GError* err = 0;

    while( QTreeWidgetItem* item = m_uploadList->takeTopLevelItem(0) )
    {
#define item static_cast<ImageListItem*>(item)
        kDebug() << "Uploading "      << item->pathSrc()
                 << " to ipod album " << album->name ;

        Itdb_Artwork* art = itdb_photodb_add_photo( m_itdb, QFile::encodeName( item->pathSrc() ), 0, 0, &err );

        if( !art )
        {
            if( err )
            {
                kDebug() << "Error adding photo " << item->pathSrc() << " to database:"
                              << err->message ;
                err = 0;
            }
        }
        else
        {
            itdb_photodb_photoalbum_add_photo( m_itdb, album, art, 0 );
        }

        delete item;
#undef item
    }

    itdb_photodb_write( m_itdb, &err );
    if( err ) kDebug() << "Failed with error: " << err->message ;

    reloadIpodAlbum( ipodAlbum, album );

    IpodAlbumItem* library = static_cast<IpodAlbumItem*>( m_ipodAlbumList->topLevelItem(0) );
    reloadIpodAlbum( library, library->photoAlbum() );

    m_transferring = false;

    enableButtons();
}
Beispiel #2
0
static int do_add (int argc, char **argv)
{
    GError *error = NULL;
    Itdb_PhotoAlbum *album = NULL;
    Itdb_PhotoDB *db;
    gint i; 

    if (argc < 4)
    {
	g_print (_("Insufficient number of command line arguments.\n"));
	usage (argc, argv);
	return 1;
    }

    db = itdb_photodb_parse (argv[2], &error);
    if (db == NULL)
    {
	if (error)
	{
	    g_print (_("Error reading iPod photo database (%s).\nWill attempt to create a new database.\n"), error->message);
	    g_error_free (error);
	    error = NULL;
	}
	else
	{
	    g_print (_("Error reading iPod photo database, will attempt to create a new database\n"));
	}
	db = itdb_photodb_create (argv[2]);
    }

    /* Find or create specified photoalbum */
    if (strcmp (argv[3], "NULL") != 0)
    {
	album = itdb_photodb_photoalbum_by_name (db, argv[3]);
	if (!album)
	{
	    album = itdb_photodb_photoalbum_create (db, argv[3], -1);
	}
    }

    for (i=4; i<argc; ++i)
    {
	Itdb_Artwork *photo;
	
	photo = itdb_photodb_add_photo (db, argv[i],
					-1, GDK_PIXBUF_ROTATE_NONE, &error);
	if (photo == NULL)
	{
	    if (error)
	    {
		g_print (_("Error adding photo (%s) to photo database: %s\n"),
			 argv[i], error->message);
		g_error_free (error);
		error = NULL;
	    }
	}
	else
	{
	    if (album)
	    {
		itdb_photodb_photoalbum_add_photo (db, album, photo, -1);
	    }
	}
    }

    itdb_photodb_write (db, NULL);
    itdb_photodb_free (db);
    return 0;
}