int dimagev_delete_picture(dimagev_t *dimagev, int file_number) { dimagev_packet *p, *raw; unsigned char command_buffer[3]; char char_buffer = 0; if ( dimagev == NULL ) { GP_DEBUG( "dimagev_delete_picture::unable to use NULL dimagev_t"); return GP_ERROR_BAD_PARAMETERS; } dimagev_dump_camera_status(dimagev->status); /* An image can only be deleted if the card is normal or full. */ if ( dimagev->status->card_status > (unsigned char) 1 ) { GP_DEBUG( "dimagev_delete_picture::memory card does not permit deletion"); return GP_ERROR; } if ( dimagev->data->host_mode != (unsigned char) 1 ) { dimagev->data->host_mode = (unsigned char) 1; if ( dimagev_send_data(dimagev) < GP_OK ) { GP_DEBUG( "dimagev_delete_picture::unable to set host mode"); return GP_ERROR_IO; } } /* First make the command packet. */ command_buffer[0] = 0x05; command_buffer[1] = (unsigned char)( file_number / 256 ); command_buffer[2] = (unsigned char)( file_number % 256 ); if ( ( p = dimagev_make_packet(command_buffer, 3, 0) ) == NULL ) { GP_DEBUG( "dimagev_delete_picture::unable to allocate command packet"); return GP_ERROR_NO_MEMORY; } if ( gp_port_write(dimagev->dev, (char *)p->buffer, p->length) < GP_OK ) { GP_DEBUG( "dimagev_delete_picture::unable to send set_data packet"); free(p); return GP_ERROR_IO; } else if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { GP_DEBUG( "dimagev_delete_picture::no response from camera"); free(p); return GP_ERROR_IO; } free(p); switch ( char_buffer ) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: GP_DEBUG( "dimagev_delete_picture::camera did not acknowledge transmission"); return GP_ERROR_IO; case DIMAGEV_CAN: GP_DEBUG( "dimagev_delete_picture::camera cancels transmission"); return GP_ERROR_IO; default: GP_DEBUG( "dimagev_delete_picture::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) { GP_DEBUG( "dimagev_delete_picture::unable to read packet"); return GP_ERROR_IO; } if ( ( raw = dimagev_strip_packet(p) ) == NULL ) { GP_DEBUG( "dimagev_delete_picture::unable to strip packet"); free(p); return GP_ERROR; } free(p); if ( raw->buffer[0] != (unsigned char) 0 ) { GP_DEBUG( "dimagev_delete_picture::delete returned error code"); free(raw); return GP_ERROR_NO_MEMORY; } free(raw); char_buffer=DIMAGEV_EOT; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { GP_DEBUG( "dimagev_delete_picture::unable to send ACK"); return GP_ERROR_IO; } if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { GP_DEBUG( "dimagev_delete_picture::no response from camera"); return GP_ERROR_IO; } switch ( char_buffer ) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: GP_DEBUG( "dimagev_delete_picture::camera did not acknowledge transmission"); return GP_ERROR_IO; case DIMAGEV_CAN: GP_DEBUG( "dimagev_delete_picture::camera cancels transmission"); return GP_ERROR_IO; default: GP_DEBUG( "dimagev_delete_picture::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } return GP_OK; }
static int camera_summary (Camera *camera, CameraText *summary, GPContext *context) { int i = 0, count = 0; if ( dimagev_get_camera_status(camera->pl) < GP_OK ) { GP_DEBUG( "camera_summary::unable to get camera status"); return GP_ERROR_IO; } if ( dimagev_get_camera_data(camera->pl) < GP_OK ) { GP_DEBUG( "camera_summary::unable to get camera data"); return GP_ERROR_IO; } if ( dimagev_get_camera_info(camera->pl) < GP_OK ) { GP_DEBUG( "camera_summary::unable to get camera info"); return GP_ERROR_IO; } dimagev_dump_camera_status(camera->pl->status); dimagev_dump_camera_data(camera->pl->data); dimagev_dump_camera_info(camera->pl->info); /* Now put all of the information into a reasonably formatted string. */ /* i keeps track of the length. */ i = 0; /* First the stuff from the dimagev_info_t */ #if defined HAVE_SNPRINTF i = snprintf(summary->text, sizeof(summary->text), #else i = sprintf(summary->text, #endif _("Model:\t\t\tMinolta Dimage V (%s)\n" "Hardware Revision:\t%s\nFirmware Revision:\t%s\n"), camera->pl->info->model, camera->pl->info->hardware_rev, camera->pl->info->firmware_rev); if ( i > 0 ) { count += i; } /* Now the stuff from dimagev_data_t */ #if defined HAVE_SNPRINTF i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, #else i = sprintf(&(summary->text[count]), #endif _("Host Mode:\t\t%s\n" "Exposure Correction:\t%s\n" "Exposure Data:\t\t%d\n" "Date Valid:\t\t%s\n" "Date:\t\t\t%d/%02d/%02d %02d:%02d:%02d\n" "Self Timer Set:\t\t%s\n" "Quality Setting:\t%s\n" "Play/Record Mode:\t%s\n" "Card ID Valid:\t\t%s\n" "Card ID:\t\t%d\n" "Flash Mode:\t\t"), ( camera->pl->data->host_mode != (unsigned char) 0 ? _("Remote") : _("Local") ), ( camera->pl->data->exposure_valid != (unsigned char) 0 ? _("Yes") : _("No") ), (signed char)camera->pl->data->exposure_correction, ( camera->pl->data->date_valid != (unsigned char) 0 ? _("Yes") : _("No") ), ( camera->pl->data->year < (unsigned char) 70 ? 2000 + (int) camera->pl->data->year : 1900 + (int) camera->pl->data->year ), camera->pl->data->month, camera->pl->data->day, camera->pl->data->hour, camera->pl->data->minute, camera->pl->data->second, ( camera->pl->data->self_timer_mode != (unsigned char) 0 ? _("Yes") : _("No")), ( camera->pl->data->quality_setting != (unsigned char) 0 ? _("Fine") : _("Standard") ), ( camera->pl->data->play_rec_mode != (unsigned char) 0 ? _("Record") : _("Play") ), ( camera->pl->data->valid != (unsigned char) 0 ? _("Yes") : _("No")), camera->pl->data->id_number ); if ( i > 0 ) { count += i; } /* Flash is a special case, a switch is needed. */ switch ( camera->pl->data->flash_mode ) { case 0: #if defined HAVE_SNPRINTF i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, #else i = sprintf(&(summary->text[count]), #endif _("Automatic\n")); break; case 1: #if defined HAVE_SNPRINTF i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, #else i = sprintf(&(summary->text[count]), #endif _("Force Flash\n")); break; case 2: #if defined HAVE_SNPRINTF i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, #else i = sprintf(&(summary->text[count]), #endif _("Prohibit Flash\n")); break; default: #if defined HAVE_SNPRINTF i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, #else i = sprintf(&(summary->text[count]), #endif _("Invalid Value ( %d )\n"), camera->pl->data->flash_mode); break; } if ( i > 0 ) { count += i; } /* Now for the information in dimagev_status_t */ #if defined HAVE_SNPRINTF i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, #else i = sprintf(&(summary->text[count]), #endif _("Battery Level:\t\t%s\n" "Number of Images:\t%d\n" "Minimum Capacity Left:\t%d\n" "Busy:\t\t\t%s\n" "Flash Charging:\t\t%s\n" "Lens Status:\t\t"), ( camera->pl->status->battery_level ? _("Not Full") : _("Full") ), camera->pl->status->number_images, camera->pl->status->minimum_images_can_take, ( camera->pl->status->busy ? _("Busy") : _("Idle") ), ( camera->pl->status->flash_charging ? _("Charging") : _("Ready") ) ); if ( i > 0 ) { count += i; } /* Lens status is another switch. */ switch ( camera->pl->status->lens_status ) { case 0: i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, _("Normal\n")); break; case 1: case 2: i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, _("Lens direction does not match flash light\n")); break; case 3: i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, _("Lens is not connected\n")); break; default: i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, _("Bad value for lens status %d\n"), camera->pl->status->lens_status); break; } if ( i > 0 ) { count += i; } /* Card status is another switch. */ i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, _("Card Status:\t\t")); if ( i > 0 ) { count += i; } switch ( camera->pl->status->card_status ) { case 0: i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, _("Normal")); break; case 1: i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, _("Full")); break; case 2: i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, _("Write-protected")); break; case 3: i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, _("Unsuitable card")); break; default: i = snprintf(&(summary->text[count]), sizeof(summary->text) - count, _("Bad value for card status %d"), camera->pl->status->card_status); break; } if ( i > 0 ) { count += i; } return GP_OK; }