Esempio n. 1
0
static int
get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
	       CameraFileType type, CameraFile *file, void *user_data,
	       GPContext *context)
{
	Camera *camera = user_data;
	int n;
	unsigned int size;
	unsigned char *data;

	CR (n = gp_filesystem_number (fs, folder, filename, context));
	n++;

	switch (type) {
	case GP_FILE_TYPE_NORMAL:
		CR (ricoh_get_pic (camera, context, n,
				   RICOH_FILE_TYPE_NORMAL, &data, &size));
		gp_file_set_mime_type (file, GP_MIME_EXIF);
		break;
	case GP_FILE_TYPE_PREVIEW:
		CR (ricoh_get_pic (camera, context, n,
				   RICOH_FILE_TYPE_PREVIEW, &data, &size));
		gp_file_set_mime_type (file, GP_MIME_TIFF);
		break;		
	default:
		return (GP_ERROR_NOT_SUPPORTED);
	}

	gp_file_set_data_and_size (file, (char*)data, size);

	return (GP_OK);
}
Esempio n. 2
0
static int get_info_func (CameraFilesystem *fs, const char *folder,
		const char *filename, CameraFileInfo *info, void *data,
		GPContext *context)
{
	Camera *camera = data;
	int n;
	struct jamcam_file *jc_file;

	GP_DEBUG ("* get_info_func");
	GP_DEBUG ("*** folder: %s", folder);
	GP_DEBUG ("*** filename: %s",filename);

	/* Get the file number from the CameraFileSystem */
	CHECK (n = gp_filesystem_number (camera->fs, folder,
					 filename, context));

	jc_file = jamcam_file_info( camera, n );

	/* fixme, get file size also */
	info->file.fields = GP_FILE_INFO_TYPE;
	strcpy (info->file.type, GP_MIME_PPM);
	info->file.width = jc_file->width;
	info->file.height = jc_file->height;

	info->preview.fields = GP_FILE_INFO_TYPE;
	strcpy (info->preview.type, GP_MIME_PPM);
	info->preview.width = 80;
	info->preview.height = 60;

	return (GP_OK);
}
Esempio n. 3
0
static int get_file_func (CameraFilesystem *fs, const char *folder,
			  const char *filename, CameraFileType type,
			  CameraFile *file, void *user_data, GPContext *context)
{
	Camera *camera = user_data;
	int image_no, result;

	image_no = gp_filesystem_number(camera->fs, folder, filename, context);
	if(image_no < 0)
		return image_no;

	gp_file_set_mime_type (file, GP_MIME_JPEG);
	switch (type) {
	case GP_FILE_TYPE_NORMAL:
		result = stv0674_get_image (camera->port, image_no, file);
		break;
	case GP_FILE_TYPE_RAW:
		result = stv0674_get_image_raw (camera->port, image_no, file);
		break;
	case GP_FILE_TYPE_PREVIEW:
		result = stv0674_get_image_preview (camera->port, image_no, file);
		break;
	default:
		return (GP_ERROR_NOT_SUPPORTED);
	}
	return result;
}
Esempio n. 4
0
static int get_file_func (CameraFilesystem *fs, const char *folder,
			  const char *filename, CameraFileType type,
			  CameraFile *file, void *data, GPContext *context) 
{
	Camera *camera = data;
	int file_number=0, result;

	file_number = gp_filesystem_number(fs, folder, filename, context);
	if (file_number < 0)
		return (file_number);

	switch (type) {
	case GP_FILE_TYPE_NORMAL:
		gp_file_set_mime_type (file, GP_MIME_JPEG);
		result = dimagev_get_picture (camera->pl, file_number + 1, file);
		break;
	case GP_FILE_TYPE_PREVIEW:
		gp_file_set_mime_type (file, GP_MIME_PPM);
		result = dimagev_get_thumbnail (camera->pl, file_number + 1, file);
		break;
	default:
		return (GP_ERROR_NOT_SUPPORTED);
	}

	if (result < 0) {
		GP_DEBUG( "camera_file_get::unable to retrieve image file");
		return result;
	}

	sleep(2);
	return GP_OK;
}
Esempio n. 5
0
static int
get_file_func (CameraFilesystem *fs, const char *folder,
	       const char *filename, CameraFileType type,
	       CameraFile *file, void *data, GPContext *context)
{
	Camera *camera = data;
	int n;
	unsigned char *d;
	unsigned int size;

	/* We need file numbers starting with 1 */
	CR (n = gp_filesystem_number (camera->fs, folder, filename, context));
	n++;

	switch (type) {
	case GP_FILE_TYPE_NORMAL:
		CR (fuji_pic_get (camera, n, &d, &size, context));
		break;
	case GP_FILE_TYPE_PREVIEW:
		CR (fuji_pic_get_thumb (camera, n, &d, &size, context));
		break;
	default:
		return (GP_ERROR_NOT_SUPPORTED);
	}
	CR (gp_file_set_data_and_size (file, (char *)d, size));
	CR (gp_file_set_mime_type (file, GP_MIME_JPEG));

	return (GP_OK);
}
Esempio n. 6
0
static int
get_info_func (CameraFilesystem *fs, const char *folder,
	       const char *filename, CameraFileInfo *info, void *data, 
	       GPContext *context)
{
	Camera *camera = data;
	int n;
	struct GsmartFile *file;

	/* Get the file number from the CameraFileSystem */
	CHECK (n = gp_filesystem_number (camera->fs, folder, filename, 
				         context));

	CHECK (gsmart300_get_file_info (camera->pl, n, &file));

	info->file.fields = GP_FILE_INFO_TYPE 
		| GP_FILE_INFO_WIDTH 
		| GP_FILE_INFO_HEIGHT;
	if (file->mime_type == GSMART_FILE_TYPE_IMAGE) {
		strcpy (info->file.type, GP_MIME_JPEG);
		info->preview.width = 80;
		info->preview.height = 60;
	}
	info->file.width = file->width;
	info->file.height = file->height;

	info->preview.fields = GP_FILE_INFO_TYPE 
		| GP_FILE_INFO_WIDTH 
		| GP_FILE_INFO_HEIGHT;
	strcpy (info->preview.type, GP_MIME_BMP);

	return (GP_OK);
}
Esempio n. 7
0
static int
get_info_func (CameraFilesystem *fs, const char *folder, const char *filename,
         CameraFileInfo *info, void *data, GPContext *context)
{
	Camera *camera = data;
	int n;
	const char *name;

	CR (n = gp_filesystem_number (fs, folder, filename, context));
	n++;
	
	info->audio.fields = GP_FILE_INFO_NONE; 	/* no info anbout audio files */
	
	info->preview.width = 80;
	info->preview.height = 60;
	info->preview.fields = GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT; 
	
	CR (ricoh_get_pic_name (camera, context, n, &name));
	CR (ricoh_get_pic_date (camera, context, n, &info->file.mtime));
	CR (ricoh_get_pic_size (camera, context, n, &info->file.size));
	strcpy (info->file.type, GP_MIME_EXIF);
	info->file.fields = GP_FILE_INFO_SIZE | GP_FILE_INFO_MTIME
		| GP_FILE_INFO_TYPE;
	
	return (GP_OK);
}
Esempio n. 8
0
/*
 * File operations 
 */
static int
get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
	       CameraFileType type, CameraFile *file, void *data,
	       GPContext *context)
{


	Camera *camera = data;
        int image_no, result;

	char* img_data=NULL;
        int   img_size=-1;

        image_no = gp_filesystem_number(fs, folder, filename, context);
        gp_log(GP_LOG_DEBUG, "enigma13","Index of image %d is %s",image_no, filename);
        switch (type) {
        case GP_FILE_TYPE_NORMAL:
        {
                gp_log(GP_LOG_DEBUG, "enigma13","Downloading raw image");

                CHECK(enigma13_download_img(camera, enigma13_static_toc, image_no, &img_data, &img_size));
                result = gp_file_append( file, img_data, img_size);
 
		break;
	}
	default:
                result = GP_ERROR_NOT_SUPPORTED;
		break;
        }
        if (result < 0)
                return result;
        return (GP_OK);
}
Esempio n. 9
0
static int
get_file_func (CameraFilesystem *fs, const char *folder,
	       const char *filename, CameraFileType type,
	       CameraFile *file, void *user_data, GPContext *context)
{
	Camera *camera = user_data;
	int number, filetype;

	CHECK (number = gp_filesystem_number (camera->fs, folder, filename, 
				              context));
	switch (type) {
		case GP_FILE_TYPE_NORMAL:
			CHECK (gsmart300_request_file (camera->pl, file, number));
			break;
		case GP_FILE_TYPE_PREVIEW:
			CHECK (gsmart300_request_thumbnail
			       (camera->pl, file, number, &filetype));
			if (filetype == GSMART_FILE_TYPE_IMAGE) {
				CHECK (gp_file_set_mime_type (file, GP_MIME_BMP));
			}
			break;
		default:
			return GP_ERROR_NOT_SUPPORTED;
	}
	return GP_OK;
}
Esempio n. 10
0
static int
delete_file_func (CameraFilesystem *fs, const char *folder,
		  const char *filename, void *data, GPContext *context)
{
	Camera *camera = data;
	int ret,nr ;

	nr = gp_filesystem_number(fs, folder, filename, context);
	if (nr < 0)
	    return nr;

	ret = mdc800_setTarget (camera,1);
	if (ret!=GP_OK)
	{
		printAPIError ("(mdc800_delete_image) can't set Target\n");
		return ret;
	}
	ret = mdc800_io_sendCommand(camera->port, COMMAND_DELETE_IMAGE,nr/100,(nr%100)/10,nr%10,0,0);
	if (ret != GP_OK)
	{
		printAPIError ("(mdc800_delete_image ) deleting Image %i fails !.\n",nr);
		return ret;
	}
	return GP_OK;
}
Esempio n. 11
0
static int
get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
	       CameraFileType type, CameraFile *file, void *user_data,
	       GPContext *context)
{
   Camera *camera = user_data;
   int size,image_no,result;
   unsigned char *data;
   
   image_no = gp_filesystem_number(fs, folder, filename, context);
   if (image_no < GP_OK)
     return image_no;

   switch (type) {
    case GP_FILE_TYPE_NORMAL:
      result = ultrapocket_getpicture(camera,context,&data,&size,filename);
      gp_file_set_mime_type (file, GP_MIME_PPM);
      break;
    case GP_FILE_TYPE_RAW:
      result = ultrapocket_getrawpicture(camera, context, 
		      &data, &size, filename);
      gp_file_set_mime_type (file, GP_MIME_PPM);
      break;
    case GP_FILE_TYPE_PREVIEW:
    default:
      return (GP_ERROR_NOT_SUPPORTED);
   }
   if (result < 0)
     return result;
   
   CHECK_RESULT(gp_file_set_data_and_size (file, (char *)data, size));
   
   return (GP_OK);
}
Esempio n. 12
0
static int
get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
	       CameraFileType type, CameraFile *file, void *data,
	       GPContext *context)
{
	Camera *camera = data;
	int	size, nr, result;

	nr = gp_filesystem_number(fs, folder, filename, context);
	if(nr < 0)
		return nr;

	switch (type) {
#if 0
	case GP_FILE_TYPE_RAW:
		result =  jd11_get_image_full (camera, nr, &data, (int*) &size, 1);
		break;
#endif
	case GP_FILE_TYPE_NORMAL:
		result = mdc800_getImage(camera,nr,&data,&size);
		break;
	case GP_FILE_TYPE_PREVIEW:
		result = mdc800_getThumbnail(camera,nr,&data,&size);
		break;
	default:
		return (GP_ERROR_NOT_SUPPORTED);
	}
	if (result < 0)
		return result;

	gp_file_set_mime_type (file, GP_MIME_JPEG);
	gp_file_set_data_and_size(file, data, size);
	return (GP_OK);
}
Esempio n. 13
0
static int
get_file_func (CameraFilesystem *fs, const char *folder,
               const char *filename, CameraFileType type,
               CameraFile *file, void *user_data, GPContext *context)
{
	Camera *camera = user_data;
	unsigned char *data = NULL;
	unsigned int size, mimetype;
	int index;

	size = 0;
	index = gp_filesystem_number (fs, folder, filename, context);
	if (index < 0)
		return index;
	switch (type) {
		case GP_FILE_TYPE_NORMAL:
			CHECK (pccam300_get_file (camera->port, context,
			                          index, &data, &size,
			                          &mimetype));
			break;
		default:
			return GP_ERROR_NOT_SUPPORTED;
	}
	return gp_file_set_data_and_size (file, data, size);
}
Esempio n. 14
0
static int
get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
	       CameraFileType type, CameraFile *file, void *user_data,
	       GPContext *context)
{
	Camera *camera = user_data; 

        int k;
	char *data;
	int len;

	k = gp_filesystem_number(camera->fs, "/", filename, context);

	switch (type) {
	case GP_FILE_TYPE_PREVIEW:
		return GP_ERROR_NOT_SUPPORTED;
	case GP_FILE_TYPE_NORMAL:
		len = lg_gsm_get_picture_size (camera->port, k);
		GP_DEBUG("len = %i\n", len);
		data = malloc(len);
		if (!data) {
			GP_DEBUG("malloc failed\n");
			return GP_ERROR_NO_MEMORY;
		}
		lg_gsm_read_picture_data (camera->port, data, len, k);
		gp_file_append (file, data, len);
		free (data);
		break;
	default:
		return GP_ERROR_NOT_SUPPORTED;

	}

	return GP_OK;
}
static int
get_sony_file_id(Camera *camera, const char *folder,
                 const char *filename, GPContext *context,
                 int *sony_id, SonyFileType *sony_type)
{
    int num = gp_filesystem_number(camera->fs, folder, filename, context);
    if (num < 0)
        return (num);

    num++;

    if (sony_is_mpeg_file_name(filename)) {
        const char *name_found;
        int mpeg_num = 0;
        do {
            mpeg_num++;
            gp_filesystem_name(camera->fs, folder, num-mpeg_num, &name_found, context);
        }
        while (sony_is_mpeg_file_name(name_found)
                && (mpeg_num<=num));
        mpeg_num--;

        *sony_type = SONY_FILE_MPEG;
        *sony_id = mpeg_num;
    }
    else {
        *sony_type = SONY_FILE_IMAGE;
        *sony_id = num;
    }
    return GP_OK;
}
Esempio n. 16
0
static int
get_info_func (CameraFilesystem *fs, const char *folder,
	       const char *filename, CameraFileInfo *info, void *data,
	       GPContext *context)
{
	Camera *camera = data;
	int n, flash_file_count = 0;
	struct SPCA50xFile *file;
	char name[14];
	int w,h;

	/* Get the file number from the CameraFileSystem */
	CHECK (n =
	       gp_filesystem_number (camera->fs, folder, filename, context));

	if (cam_has_flash(camera->pl) || cam_has_card(camera->pl) ) {
		CHECK (spca50x_flash_get_TOC(camera->pl,
					&flash_file_count));
	}
	if (n < flash_file_count) {
		CHECK (spca50x_flash_get_file_name(camera->pl,
					n, name));
		CHECK (spca50x_flash_get_file_dimensions(
					camera->pl, n, &w, &h));
		strcpy (info->file.type, GP_MIME_JPEG);
		info->file.width = w;
		info->file.height = h;
		info->preview.width = w/8;
		info->preview.height = h/8;
	}
	if (cam_has_sdram (camera->pl) && n >= flash_file_count ){
		CHECK (spca50x_sdram_get_file_info (camera->pl,
					n-flash_file_count, &file));
		if (file->mime_type == SPCA50X_FILE_TYPE_IMAGE) {
			strcpy (info->file.type, GP_MIME_JPEG);
			info->preview.width = 160;
			info->preview.height = 120;
		} else if (file->mime_type == SPCA50X_FILE_TYPE_AVI) {
			strcpy (info->file.type, GP_MIME_AVI);
			info->preview.width = 320;
			info->preview.height = 240;
		}
		info->file.width = file->width;
		info->file.height = file->height;

	}
	info->file.fields =
		GP_FILE_INFO_TYPE
		| GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT;

	info->file.mtime = 0;
	info->file.fields |= GP_FILE_INFO_MTIME;

	info->preview.fields =
		GP_FILE_INFO_TYPE | GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT;
	strcpy (info->preview.type, GP_MIME_BMP);
	return (GP_OK);
}
Esempio n. 17
0
static int
delete_file_func (CameraFilesystem *fs, const char *folder,
		  const char *filename, void *data, GPContext *context)
{
	int picNum;
	Camera *camera = data;

	picNum = gp_filesystem_number(fs, folder, filename, context) + 1;
	return pdrm11_delete_file(camera->port, picNum);
}
Esempio n. 18
0
static int delete_file_func(CameraFilesystem *fs, const char *folder,
			    const char *filename, void *data, GPContext *context){
  int index,ret;

  Camera *camera = data;
  index = gp_filesystem_number(fs, folder, filename, context);
  gp_log(GP_LOG_DEBUG,"pccam","deleting '%s' in '%s'.. index:%d",filename, folder,index);
  ret = pccam600_delete_file(camera->port, context, index);
  return GP_OK;
}
Esempio n. 19
0
static int delete_file_func (CameraFilesystem *fs, const char *folder, 
			     const char *filename, void *data,
			     GPContext *context) 
{
	Camera *camera = data;
	int file_number=0;

	file_number = gp_filesystem_number(camera->fs, folder, filename, context);
	if (file_number < 0)
		return (file_number);

	return dimagev_delete_picture(camera->pl, (file_number + 1 ));
}
Esempio n. 20
0
static int
del_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
	       void *user_data, GPContext *context)
{
	Camera *camera = user_data;
	int n;

	CR (n = gp_filesystem_number (fs, folder, filename, context));
	n++;

	CR (ricoh_del_pic (camera, context, n));

	return (GP_OK);
}
Esempio n. 21
0
static int
delete_file_func (CameraFilesystem *fs, const char *folder,
		  const char *filename, void *data, GPContext *context)
{
   Camera *camera = data;
   int image_no;
   
   image_no = gp_filesystem_number(fs, folder, filename, context);
   if (image_no < GP_OK)
     return image_no;

   CHECK_RESULT(ultrapocket_deletefile(camera, filename));
   
   return (GP_OK);
}
Esempio n. 22
0
/*
 * Get informations about an image
 */
static int
get_info_func (CameraFilesystem *fs, const char *folder, const char *filename,
	       CameraFileInfo *info, void *data, GPContext *context)
{
	int image_no;

	GP_DEBUG ("*** ENTER: get_info_func ***");

        image_no = gp_filesystem_number(fs, folder, filename, context);
	if (image_no < 0)
		return image_no;
	image_no++;

	return (k_info_img(image_no, data, info, NULL));
}
Esempio n. 23
0
static int
del_file_func (CameraFilesystem *fs, const char *folder,
	       const char *filename, void *data, GPContext *context)
{
	Camera *camera = data;
	int n;

	/* We need file numbers starting with 1 */
	CR (n = gp_filesystem_number (camera->fs, folder, filename, context));
	n++;

	CR (fuji_pic_del (camera, n, context));

	return (GP_OK);
}
Esempio n. 24
0
/*
 * Delete one image
 * The image mustn't be protected
 */
static int
delete_file_func (CameraFilesystem *fs, const char *folder, 
		const char *filename, void *data, GPContext *context)
{
	Camera *camera = data;
	CameraFileInfo file_info;
	unsigned char cmd[7], ack;
	int image_no;
	int ret;

	GP_DEBUG ("*** ENTER: delete_file_func ***");

        image_no = gp_filesystem_number(fs, folder, filename, context);
	if (image_no < 0) return image_no;

	image_no++;
	ret = k_info_img (image_no, data, (CameraFileInfo *)&file_info, 
		&image_no);
	if (ret < GP_OK)
		return ret;

	/* Now, check if the image isn't protected */
	if (file_info.file.permissions == GP_FILE_PERM_READ) {
		gp_context_error(context, _("Image %s is delete protected."),
			filename);
		return (GP_ERROR);
	}

	/* Erase the image */
	cmd[0] = ESC;
	cmd[1] = ERASEIMAGE_CMD1;
	cmd[2] = IMAGE_CMD2;
	cmd[3] = 0x30 + ((image_no/1000)%10);
	cmd[4] = 0x30 + ((image_no/100 )%10);
	cmd[5] = 0x30 + ((image_no/10  )%10);
	cmd[6] = 0x30 + ( image_no      %10);
	ret = gp_port_write (camera->port, (char*)cmd, sizeof(cmd));
	if (ret<GP_OK) return ret;
	ret = gp_port_read (camera->port, (char*)&ack, ACK_LEN);
	if (ret<GP_OK) return ret;
	if (ack != ACK) {
		gp_context_error(context, _("Can't delete image %s."),filename);
		return (GP_ERROR);
	}	
	return (GP_OK);
}
Esempio n. 25
0
static int
get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
	       CameraFileType type, CameraFile *file, void *data,
	       GPContext *context)
{
	int picNum;
	Camera *camera = data;
	
	switch(type){
	case GP_FILE_TYPE_PREVIEW:
	case GP_FILE_TYPE_NORMAL:
		picNum = gp_filesystem_number(fs, folder, filename, context) + 1;
		return pdrm11_get_file (fs, filename, type, file, camera->port, picNum);
	default:
		return GP_ERROR_NOT_SUPPORTED;
	}
}
Esempio n. 26
0
static int get_file_func (CameraFilesystem *fs, const char *folder,
			  const char *filename, CameraFileType type,
			  CameraFile *file, void *data, GPContext *context) 
{
	Camera *camera = data;
	int file_number=0, result;
	char buffer[128];

	file_number = gp_filesystem_number(fs, folder, filename, context);
	if (file_number < 0)
		return (file_number);

	switch (type) {
	case GP_FILE_TYPE_NORMAL:
		gp_file_set_mime_type (file, GP_MIME_JPEG);
		gp_file_set_name (file, filename);
		result = dimagev_get_picture (camera->pl, file_number + 1, file);
		break;
	case GP_FILE_TYPE_PREVIEW:
		gp_file_set_mime_type (file, GP_MIME_PPM);
#if defined HAVE_SNPRINTF
		snprintf(buffer, sizeof(buffer), DIMAGEV_THUMBNAIL_FMT, ( file_number + 1) );
#else
		sprintf(buffer, DIMAGEV_THUMBNAIL_FMT, ( file_number + 1) );
#endif 
		gp_file_set_name (file, buffer);
		result = dimagev_get_thumbnail (camera->pl, file_number + 1, file);
		break;
	default:
		return (GP_ERROR_NOT_SUPPORTED);
	}

	if (result < 0) {
		GP_DEBUG( "camera_file_get::unable to retrieve image file");
		return result;
	}

	sleep(2);
	return GP_OK;
}
Esempio n. 27
0
static int
get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
	       CameraFileType type, CameraFile *file, void *user_data,
	       GPContext *context)
{
    	Camera *camera = user_data;
        int n, len;
	char *data, *data_start;

	n = gp_filesystem_number(camera->fs, "/", filename, context);
	if (n<GP_OK)
		return n;

	len = ez200_get_picture_size (camera->port, n);
	GP_DEBUG("len = %i", len);

	data = (char *)malloc(len + HEADER_SIZE + 1);
	if (!data) return GP_ERROR_NO_MEMORY;

	data_start = data + (HEADER_SIZE - DATA_HEADER_SIZE);
	GP_DEBUG("data - data_start : %p %p : %lx",data, data_start, (long) (data_start - data));

    	ez200_read_picture_data   (camera->port, data_start, len, n);
	ez200_read_picture_header (camera->port, data);
	switch (type) {
	case GP_FILE_TYPE_PREVIEW:
	case GP_FILE_TYPE_NORMAL:
		gp_file_set_mime_type (file, GP_MIME_JPEG);
		gp_file_set_data_and_size (file, data, len + HEADER_SIZE + 1);
		break;
	case GP_FILE_TYPE_RAW:
		gp_file_set_data_and_size (file, data, len);
		gp_file_set_mime_type (file, GP_MIME_RAW);
		gp_file_adjust_name_for_mime_type(file);
		break;
	default:
		return (GP_ERROR_NOT_SUPPORTED);
	}
	return GP_OK;
}
Esempio n. 28
0
static int delete_file_func (CameraFilesystem *fs, const char *folder,
			     const char *filename, void *data,
			     GPContext *context) {

	Camera *camera = data;
	int		index;
	int		result;

	GP_DEBUG ("Delete File %s", filename);

	/* index is the 0-based image number on the camera */
	index = gp_filesystem_number (camera->fs, folder, filename, context);
	if (index < 0)
		return (index);

	result = l859_delete (camera, index);
	if (result < 0)
		return (result);

	GP_DEBUG ("Delete File Done");

	return GP_OK;
}
Esempio n. 29
0
static int get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo *info, void *data, GPContext *context) {

	Camera *camera = data;
	int num, std_res;

	num = gp_filesystem_number (fs, folder, filename, context);
	if (num < 0)
		return num;

	if ( (std_res = mesa_read_image_info( camera->port, num, NULL )) < 0 )
	{
		ERROR("Can't get Image Info");
		gp_context_error (context, _("Problem getting image information"));
		return std_res;
	}

	info->preview.fields = GP_FILE_INFO_ALL;
	strcpy(info->preview.type, GP_MIME_PGM);
	info->preview.size = MESA_THUMB_SZ + sizeof( Dimera_thumbhdr ) - 1;
	info->preview.width = 64;
	info->preview.height = 48;

	info->file.fields = GP_FILE_INFO_TYPE|GP_FILE_INFO_PERMISSIONS|GP_FILE_INFO_WIDTH|GP_FILE_INFO_HEIGHT|GP_FILE_INFO_SIZE;
	strcpy(info->file.type, GP_MIME_PPM);
	info->file.permissions = GP_FILE_PERM_READ;

	if (std_res) {
	    info->file.width = 320;
	    info->file.height = 240;
	} else {
	    info->file.width = 640;
	    info->file.height = 480;
	}
	info->file.size = info->file.height*info->file.width*3 + sizeof( Dimera_finehdr ) - 1;

	return GP_OK;
}
Esempio n. 30
0
static int
delete_file_func (CameraFilesystem *fs, const char *folder,
		  const char *filename, void *data, GPContext *context)
{
	Camera *camera = data;
	int n, c, flash_file_count;

	/* FIXME deleting a single file for flash/card cams should work */
	/* Get the file number from the CameraFileSystem */
	CHECK (n =
	       gp_filesystem_number (camera->fs, folder, filename, context));

	if (cam_has_flash(camera->pl) || cam_has_card(camera->pl) ) {
		CHECK (spca50x_flash_get_filecount
					(camera->pl, &flash_file_count));
	} else {
		/* should not happen really */
		return GP_ERROR;
	}
	if (n < flash_file_count) {
		return spca500_flash_delete_file (camera->pl, n);
	}

	CHECK (c = gp_filesystem_count (camera->fs, folder, context));
	if (n + 1 != c) {
		const char *name;

		gp_filesystem_name (fs, "/", c - 1, &name, context);
		gp_context_error (context,
				  _("Your camera only supports deleting the "
				   "last file on the camera. In this case, this "
				   "is file '%s'."), name);
		return (GP_ERROR);
	}
	CHECK (spca50x_sdram_delete_file (camera->pl, n));
	return GP_OK;
}