Beispiel #1
0
int
main (int argc, char *argv[])
{
    Itdb_Device *device;
    char *fwid;

    if (argc < 2) {
        char *basename = g_path_get_basename(argv[0]);
        g_print ("Usage: %s <mountpoint>\n", basename);
        g_free (basename);
        return 1;

    }
 
    g_type_init ();

    device = itdb_device_new ();
    if (device == NULL) {
        return 1;
    }

    itdb_device_set_mountpoint (device, argv[1]);

    fwid = itdb_device_get_sysinfo (device, "FirewireGuid");
    if (fwid == NULL) {
        g_print ("Couldn't find firewire ID\n");
        return 1;
    } else {
	g_print ("FireWire ID: %s\n", fwid);
    }

    return 0;
}
nsresult
sbIPDDevice::DBConnect()
{
  // Operate under the request lock.
  nsAutoMonitor autoDBLock(mDBLock);

  // Function variables.
  GError   *gError = nsnull;
  nsresult rv;

  // Get the utf8 form of the mount path.
  nsCString mountPath = NS_ConvertUTF16toUTF8(mMountPath);

  // Initialize the iPod database device data record. */
  mITDBDevice = itdb_device_new();
  NS_ENSURE_TRUE(mITDBDevice, NS_ERROR_OUT_OF_MEMORY);
  itdb_device_set_mountpoint(mITDBDevice, mountPath.get());

  // If the device file system is not supported, dispatch an event and return
  // with a failure.
  if (!IsFileSystemSupported()) {
    CreateAndDispatchEvent
      (sbIIPDDeviceEvent::EVENT_IPOD_UNSUPPORTED_FILE_SYSTEM,
       sbIPDVariant(NS_ISUPPORTS_CAST(sbIDevice*, this)).get());
    NS_ENSURE_SUCCESS(NS_ERROR_FAILURE, NS_ERROR_FAILURE);
  }
Beispiel #3
0
/**
 * itdb_photodb_parse:
 * @mp: mountpoint of the iPod
 * @error: will contain the error description when an error occured.
 *
 * Parses the photo database of an iPod mounted at @mp.
 *
 * Return value: the imported PhotoDB or NULL in case of an error.
 **/
Itdb_PhotoDB *itdb_photodb_parse (const gchar *mp, GError **error)
{
    gchar *photos_dir;
    Itdb_PhotoDB *photodb = NULL;

    photos_dir = itdb_get_photos_dir (mp);

    if (!photos_dir)
    {
	error_no_photos_dir (mp, error);
	return NULL;
    }
    g_free (photos_dir);

    photodb = itdb_photodb_new ();
    itdb_device_set_mountpoint (photodb->device, mp);
    ipod_parse_photo_db (photodb);

    /* if photodb is empty, create a valid photodb including the main
       Photo Library album */
    if (!photodb->photos && !photodb->photoalbums)
    {
	itdb_photodb_free (photodb);
	photodb = itdb_photodb_create (mp);
    }

    return photodb;
}
Beispiel #4
0
bool
IpodDeviceHelper::initializeIpod( const QString &mountPoint,
                                  const Ui::IpodConfiguration *configureDialogUi,
                                  QString &errorMessage )
{
    DEBUG_BLOCK
    bool success = true;

    int currentModelIndex = configureDialogUi->modelComboBox->currentIndex();
    QByteArray modelNumber = configureDialogUi->modelComboBox->itemData( currentModelIndex ).toString().toUtf8();
    if( !modelNumber.isEmpty() )
    {
        modelNumber.prepend( 'x' );  // ModelNumStr should start with x
        const char *modelNumberRaw = modelNumber.constData();
        Itdb_Device *device = itdb_device_new();
        // following call reads existing SysInfo
        itdb_device_set_mountpoint( device, QFile::encodeName( mountPoint ) );
        const char *field = "ModelNumStr";
        debug() << "Setting SysInfo field" << field << "to value" << modelNumberRaw;
        itdb_device_set_sysinfo( device, field, modelNumberRaw );
        GError *error = 0;
        success = itdb_device_write_sysinfo( device, &error );
        if( !success )
        {
            if( error )
            {
                errorMessage = i18nc( "Do not translate SysInfo",
                                      "Failed to write SysInfo: %1", error->message );
                g_error_free( error );
            }
            else
                errorMessage = i18nc( "Do not translate SysInfo",
                    "Failed to write SysInfo file due to an unreported error" );
        }
        itdb_device_free( device );
        if( !success )
            return success;
    }

    QString name = configureDialogUi->nameLineEdit->text();
    if( name.isEmpty() )
        name = ipodName( 0 ); // return fallback name

    GError *error = 0;
    success = itdb_init_ipod( QFile::encodeName( mountPoint ), 0 /* model number */,
                              name.toUtf8(), &error );
    errorMessage.clear();
    if( error )
    {
        errorMessage = QString::fromUtf8( error->message );
        g_error_free( error );
        error = 0;
    }
    if( !success && errorMessage.isEmpty() )
        errorMessage = i18n( "Cannot initialize iPod due to an unreported error." );
    return success;
}
Beispiel #5
0
/**
 * itdb_photodb_create:
 * @mountpoint: mountpoint or NULL.
 *
 * Creates a new Itdb_PhotoDB. If mountpoint is NULL, you will have to
 * set it manually later by calling itdb_device_set_mountpoint().
 *
 * Return value: a newly created Itdb_PhotoDB to be freed with
 * itdb_photodb_free() when it's no longer needed. The Photo Library
 * Album is created automatically.
 **/
Itdb_PhotoDB *itdb_photodb_create (const gchar *mountpoint)
{
    Itdb_PhotoDB *photodb = itdb_photodb_new ();
    Itdb_PhotoAlbum *album;

    album = itdb_photodb_photoalbum_create (photodb, _("Photo Library"), -1);
    album->album_type = 1; /* Photo Library */

    if (mountpoint)
    {
	itdb_device_set_mountpoint (photodb->device, mountpoint);
    }

    return photodb;
}
static void
fill_model_combo (GtkWidget *combo, const char *mount_path)
{
	GHashTable *models;
	Itdb_Device *device;
	GtkTreeStore *store;
	const Itdb_IpodInfo *ipod_info;
	GtkCellRenderer *renderer;
	struct FillModelContext ctx;

	device = itdb_device_new ();
	itdb_device_set_mountpoint (device, mount_path);
	itdb_device_read_sysinfo (device);
	ipod_info = itdb_device_get_ipod_info (device);
	itdb_device_free (device);

	store = gtk_tree_store_new (1, G_TYPE_POINTER);
	gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));

	ctx.combo = combo;
	ctx.store = store;
	ctx.ipod_info = ipod_info;
	models = build_model_table (mount_path);
	g_hash_table_foreach (models, fill_one_generation, &ctx);
	g_hash_table_destroy (models);
	g_object_unref (store);

	gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
					    renderer,
					    set_cell,
					    NULL, NULL);
}