static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) { int result; int count,oldcount; if (type != GP_CAPTURE_IMAGE) return (GP_ERROR_NOT_SUPPORTED); result = stv0674_file_count(camera->port,&oldcount); result = stv0674_capture(camera->port); if (result < 0) return result; /* Just added a new picture... */ result = stv0674_file_count(camera->port,&count); if (count == oldcount) return GP_ERROR; /* unclear what went wrong ... hmm */ strcpy(path->folder,"/"); sprintf(path->name,"image%03i.jpg",count); /* Tell the filesystem about it */ result = gp_filesystem_append (camera->fs, path->folder, path->name, context); if (result < 0) return (result); return (GP_OK); }
static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) { CameraList *list; int count; const char* name; if (type != GP_CAPTURE_IMAGE) return (GP_ERROR_NOT_SUPPORTED); /* capture a image to flash (note: we do not check if full */ CHECK_RESULT (dc120_capture(camera, path, context)); /* Get the last picture in the Flash memory */ gp_list_new(&list); dc120_get_filenames (camera, 0, 0, list, context); count = gp_list_count(list); gp_list_get_name (list, count - 1, &name); gp_list_free(list); /* Set the filename */ snprintf(path->folder, sizeof(path->folder), "/"); CHECK_RESULT (gp_filesystem_append (camera->fs, path->folder, path->name, context)); return (GP_OK); }
static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { Camera *camera = data; int count; /* We only support root folder */ if (strcmp (folder, "/")) { gp_context_error (context, _("Only root folder is supported - " "you requested a file listing for folder '%s'."), folder); return (GP_ERROR_DIRECTORY_NOT_FOUND); } count = mesa_get_image_count (camera->port); if (count < 0) { gp_context_error (context, _("Problem getting number of images")); return (count); } /* * Create pseudo file names for each picture in the camera, including * the temporary picture in RAM, which, unfortunately, might not always * be available. * * We don't add anything to the filesystem here - the filesystem does * that for us. */ CHECK (gp_filesystem_append (fs, "/", RAM_IMAGE_TEMPLATE, context)); return (gp_list_populate (list, IMAGE_NAME_TEMPLATE, count)); }
static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) { if (type != GP_CAPTURE_IMAGE) return (GP_ERROR_NOT_SUPPORTED); if ( dimagev_shutter(camera->pl) < GP_OK ) { GP_DEBUG( "camera_capture::unable to open shutter"); return GP_ERROR_IO; } /* Now check how many pictures are taken, and return the last one. */ if ( dimagev_get_camera_status(camera->pl) != 0 ) { GP_DEBUG( "camera_capture::unable to get camera status"); return GP_ERROR_IO; } #if defined HAVE_SNPRINTF snprintf(path->folder, sizeof(path->folder), "/"); snprintf(path->name, sizeof(path->name), DIMAGEV_FILENAME_FMT, camera->pl->status->number_images); #else sprintf(path->folder, "/"); sprintf(path->name, DIMAGEV_FILENAME_FMT, camera->pl->status->number_images); #endif /* Tell the CameraFilesystem about this picture */ gp_filesystem_append (camera->fs, path->folder, path->name, context); return GP_OK; }
static int camera_capture (Camera* camera, CameraCaptureType type, CameraFilePath* path, GPContext *context) { int r; CameraFile *file = NULL; CameraFileInfo info; KncCamRes cr; KncCntrlRes cntrl_res; KncImageInfo i; C_NULL (camera && path); /* We only support capturing of images */ if (type != GP_CAPTURE_IMAGE) return (GP_ERROR_NOT_SUPPORTED); /* Stop the timeout, take the picture, and restart the timeout. */ gp_camera_stop_timeout (camera, camera->pl->timeout); gp_file_new (&file); knc_cntrl_set_func_data (camera->pl->c, data_func, file); cntrl_res = knc_take_picture (camera->pl->c, &cr, KNC_SOURCE_CARD, &i); camera->pl->timeout = gp_camera_start_timeout (camera, PING_TIMEOUT, timeout_func); if (cntrl_res) gp_file_unref (file); CR (cntrl_res, context); sprintf (path->name, "%06i.jpeg", (int) i.id); strcpy (path->folder, "/"); r = gp_filesystem_append (camera->fs, path->folder, path->name, context); if (r < 0) { gp_file_unref (file); return r; } info.preview.fields = GP_FILE_INFO_SIZE | GP_FILE_INFO_TYPE; gp_file_get_data_and_size (file, NULL, &info.preview.size); strcpy (info.preview.type, GP_MIME_JPEG); info.file.fields = GP_FILE_INFO_SIZE | GP_FILE_INFO_PERMISSIONS | GP_FILE_INFO_TYPE | GP_FILE_INFO_NAME; info.file.size = i.size; info.file.permissions = GP_FILE_PERM_READ; if (!i.prot) info.file.permissions |= GP_FILE_PERM_DELETE; strcpy (info.file.type, GP_MIME_JPEG); snprintf (info.file.name, sizeof (info.file.name), "%06i.jpeg", (int) i.id); gp_filesystem_set_info_noop (camera->fs, path->folder, info, context); gp_file_set_name (file, info.file.name); gp_file_set_mime_type (file, GP_MIME_JPEG); gp_file_set_type (file, GP_FILE_TYPE_EXIF); gp_filesystem_set_file_noop (camera->fs, path->folder, file, context); gp_file_unref (file); return (GP_OK); }
static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) { if (type && type != GP_CAPTURE_IMAGE){ DC210_DEBUG("Unsupported action 0x%.2X\n", type); return (GP_ERROR_NOT_SUPPORTED); }; if (dc210_capture(camera, path, context) == GP_ERROR) return GP_ERROR; return gp_filesystem_append (camera->fs, path->folder, path->name, context); }
static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { CameraFile *file; CameraFileInfo info; KncStatus status; unsigned int i, id; Camera *camera = data; int result; KncCamRes cr; /* * We can't get the filename from the camera. * But we decide to call the images %6i.jpeg', with the image id as * parameter. Therefore, let's get the image ids. */ CR (knc_get_status (camera->pl->c, &cr, &status), context); CCR (cr, context); id = gp_context_progress_start (context, status.pictures, _("Getting file list...")); for (i = 0; i < status.pictures; i++) { /* Get information */ gp_file_new (&file); result = get_info (camera, i + 1, &info, file, context); if (result < 0) { gp_file_unref (file); return (result); } /* * Append directly to the filesystem instead of to the list, * because we have additional information. */ gp_filesystem_append (camera->fs, folder, info.file.name, context); gp_filesystem_set_info_noop (camera->fs, folder, info, context); gp_filesystem_set_file_noop (camera->fs, folder, file, context); gp_file_unref (file); gp_context_idle (context); gp_context_progress_update (context, id, i + 1); if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) return (GP_ERROR_CANCEL); } gp_context_progress_stop (context, id); return (GP_OK); }
/* * file list function */ static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { Camera *camera = data; CameraFileInfo info; int32_t tpages=0; int pcnt,ecnt; /* pagecounter, entrycounter*/ struct traveler_toc_page toc; int id; /* get number of TOC pages */ CR (sx330z_get_toc_num_pages (camera, context, &tpages)); /* Read the TOC pages */ id = gp_context_progress_start (context, tpages, _("Getting " "information on %i files..."), tpages); for (pcnt = 0; pcnt < tpages; pcnt++) { CR (sx330z_get_toc_page (camera, context, &toc, pcnt)); for (ecnt = 0; ecnt < toc.numEntries; ecnt++) { char fn[20]; info.audio.fields = GP_FILE_INFO_NONE; info.preview.fields = GP_FILE_INFO_TYPE; strcpy (info.preview.type, GP_MIME_EXIF); info.file.fields = GP_FILE_INFO_SIZE | GP_FILE_INFO_TYPE | GP_FILE_INFO_PERMISSIONS; info.file.size = toc.entries[ecnt].size; info.file.permissions = GP_FILE_PERM_READ | GP_FILE_PERM_DELETE; strcpy (info.file.type,GP_MIME_JPEG); sprintf (fn, "%.12s", toc.entries[ecnt].name); /* * Append directly to the filesystem instead of to * the list, because we have additional information. */ gp_filesystem_append (camera->fs, folder, fn, context); gp_filesystem_set_info_noop (camera->fs, folder, fn, info, context); } gp_context_progress_update (context, id, pcnt); if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) return (GP_ERROR_CANCEL); } gp_context_progress_stop (context, id); return (GP_OK); }
static void decode_and_get_info(Camera *camera, const char *folder, struct tf_packet *p, const char *fn, CameraFileInfo *info, GPContext *context) { unsigned short count = (get_u16(&p->length) - PACKET_HEAD_SIZE) / sizeof(struct typefile); struct typefile *entries = (struct typefile *) p->data; int i; char *name; for(i = 0; i < count; i++) { switch (entries[i].filetype) { case 1: break;/*dir*/ case 2: /* file */ name = _convert_and_logname (camera, (char*)entries[i].name); if (!strcmp (name, fn)) { /* the wanted current one */ memset (info, 0, sizeof (*info)); info->file.fields = GP_FILE_INFO_SIZE|GP_FILE_INFO_MTIME; if (strstr (name, ".rec")) { info->file.fields |= GP_FILE_INFO_TYPE; strcpy (info->file.type, GP_MIME_MPEG); } info->file.size = get_u64(&entries[i].size); info->file.mtime = tfdt_to_time(&entries[i].stamp); } else { /* cache the others to avoid further turnarounds */ CameraFileInfo xinfo; memset (&xinfo, 0, sizeof (xinfo)); xinfo.file.fields = GP_FILE_INFO_TYPE|GP_FILE_INFO_SIZE|GP_FILE_INFO_MTIME; strcpy (xinfo.file.type, GP_MIME_MPEG); xinfo.file.size = get_u64(&entries[i].size); xinfo.file.mtime = tfdt_to_time(&entries[i].stamp); gp_filesystem_append (camera->fs, folder, name, context); /* FIXME: might fail if exist? */ gp_filesystem_set_info_noop (camera->fs, folder, name, xinfo, context); } break; default: break; } #if 0 /* This makes the assumption that the timezone of the Toppy and the system * that puppy runs on are the same. Given the limitations on the length of * USB cables, this condition is likely to be satisfied. */ timestamp = tfdt_to_time(&entries[i].stamp); printf("%c %20llu %24.24s %s\n", type, get_u64(&entries[i].size), ctime(×tamp), entries[i].name); #endif } }
static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath * path, GPContext *context) { struct SPCA50xFile *file; CameraAbilities a; /* Not all our cameras support capture */ gp_camera_get_abilities (camera, &a); if (!a.operations & GP_OPERATION_CAPTURE_IMAGE) return GP_ERROR_NOT_SUPPORTED; if (cam_has_flash(camera->pl)) { int fc; char tmp [14]; CHECK(spca500_flash_capture (camera->pl)); CHECK(spca50x_flash_get_TOC (camera->pl, &fc)); /* assume new pic is the last one in the cam...*/ CHECK(spca50x_flash_get_file_name (camera->pl, (fc - 1), tmp)); /* Add new image name to file list */ /* NOTE: these lines moved from below */ strncpy (path->name, tmp, sizeof (path->name) - 1); path->name[sizeof (path->name) - 1] = '\0'; } else { CHECK (spca50x_capture (camera->pl)); CHECK (spca50x_sdram_get_info (camera->pl)); CHECK (spca50x_sdram_get_file_info (camera->pl, camera->pl->num_files_on_sdram - 1, &file)); /* Add new image name to file list */ /* NOTE: these lines moved from below */ strncpy (path->name, file->name, sizeof (path->name) - 1); path->name[sizeof (path->name) - 1] = '\0'; } /* Now tell the frontend where to look for the image */ strncpy (path->folder, "/", sizeof (path->folder) - 1); path->folder[sizeof (path->folder) - 1] = '\0'; CHECK (gp_filesystem_append (camera->fs, path->folder, path->name, context)); return GP_OK; }
static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) { unsigned int n; if (type != GP_CAPTURE_IMAGE) return (GP_ERROR_NOT_SUPPORTED); CR (ricoh_get_num (camera, context, &n)); CR (ricoh_take_pic (camera, context)); sprintf (path->name, "rdc%04i.jpg", n + 1); strcpy (path->folder, "/"); CR (gp_filesystem_append (camera->fs, path->folder, path->name, context)); return (GP_OK); }
static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) { int result; if (type != GP_CAPTURE_IMAGE) return (GP_ERROR_NOT_SUPPORTED); /* Capture the image */ result = dc240_capture (camera, path, context); if (result < 0) return (result); /* Tell the filesystem about it */ result = gp_filesystem_append (camera->fs, path->folder, path->name, context); if (result < 0) return (result); return (GP_OK); }
static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context){ Camera *camera = data; CameraFileInfo info; int ret,n,i,nr_of_blocks; int offset = 64; char *temp; char buffer[512]; FileEntry *file_entry; file_entry = malloc(sizeof(FileEntry)); if ( (nr_of_blocks = pccam600_get_file_list(camera->port, context)) < 0 ){ gp_log(GP_LOG_DEBUG,"pccam600","pccam600->get_file_list return <0"); free (file_entry); return GP_ERROR; } for (n = 0; n != nr_of_blocks; n++) { ret = pccam600_read_data(camera->port, buffer); for (i = offset; i <= 512-32; i=i+32) { memcpy(file_entry,&(buffer)[i],32); /*Fileentry valid? */ if( !((file_entry->state & 0x02) != 2) && !((file_entry->state & 0x08) == 8) ) { info.file.fields = 0; temp = &(file_entry->name)[5]; if (strncmp(temp,"JPG",3) == 0) { memcpy(&(file_entry->name)[5],".jpg",4); strcpy(info.file.type,GP_MIME_JPEG); info.file.fields = GP_FILE_INFO_TYPE; } else if (strncmp(temp,"AVI",3) == 0) { memcpy(&(file_entry->name)[5],".avi",4); info.file.fields = GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT | GP_FILE_INFO_TYPE; info.file.height = 352; info.file.width = 288; strcpy(info.file.type, GP_MIME_AVI); } else if (strncmp(temp,"WAV",3) == 0) { memcpy(&(file_entry->name)[5],".wav",4); strcpy(info.file.type, GP_MIME_WAV); info.file.fields = GP_FILE_INFO_TYPE; info.file.height = 0; } else if (strncmp(temp,"RAW",3) == 0) { memcpy(&(file_entry->name)[5],".raw",4); info.file.width = 1280; info.file.height = 960; info.file.fields = GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT | GP_FILE_INFO_TYPE; strcpy(info.file.type, GP_MIME_RAW); } strcpy(info.file.name,file_entry->name); gp_filesystem_append(fs,folder,info.file.name,context); info.preview.fields = 0; info.file.size = (file_entry->size[1]*256+ file_entry->size[0]) * 256; info.file.permissions = GP_FILE_PERM_READ | GP_FILE_PERM_DELETE; info.file.fields |= GP_FILE_INFO_SIZE | GP_FILE_INFO_PERMISSIONS |GP_FILE_INFO_TYPE | GP_FILE_INFO_NAME ; ret = gp_filesystem_set_info_noop(fs, folder, info, context); } } offset = 0; } return GP_OK; }
static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { Camera *camera = data; unsigned int i, filecount, id, size, type; CameraFile *file; CameraFileInfo info; unsigned char *buffer = NULL; int ret, n_img=0, n_avi=0, n_wav=0; char fn[100]; CHECK (pccam300_get_filecount (camera->port, &filecount)); id = gp_context_progress_start (context, filecount, _("Getting file list...")); for (i = 0; i < filecount; i++) { /* Get information */ gp_file_new (&file); ret = pccam300_get_file (camera->port, context, i, &buffer, &size, &type); if (ret < GP_OK) { gp_file_free (file); return ret; } info.audio.fields = GP_FILE_INFO_NONE; info.preview.fields = GP_FILE_INFO_NONE; info.file.fields = GP_FILE_INFO_SIZE | GP_FILE_INFO_TYPE; info.file.size = size; switch (type) { case PCCAM300_MIME_JPEG: strcpy (info.file.type, GP_MIME_JPEG); sprintf (fn, "Image%03i.jpeg", n_img++); break; case PCCAM300_MIME_AVI: strcpy (info.file.type, GP_MIME_AVI); sprintf (fn, "Movie%03i.UNUSABLE", n_avi++); break; case PCCAM300_MIME_WAV: strcpy (info.file.type, GP_MIME_WAV); sprintf (fn, "Audio%03i.UNUSABLE", n_wav++); break; default: break; } if (file) gp_file_set_data_and_size (file, buffer, size); else free (buffer); /* * Append directly to the filesystem instead of to the list, * because we have additional information. * */ gp_filesystem_append (camera->fs, folder, fn, context); gp_filesystem_set_info_noop (camera->fs, folder, fn, info, context); gp_filesystem_set_file_noop (camera->fs, folder, fn, GP_FILE_TYPE_NORMAL, file, context); gp_file_unref (file); gp_context_idle (context); gp_context_progress_update (context, id, i + 1); if (gp_context_cancel(context) == GP_CONTEXT_FEEDBACK_CANCEL) return (GP_ERROR_CANCEL); } gp_context_progress_stop (context, id); return GP_OK; }
int main () { CameraFilesystem *fs; CameraFileInfo info; CameraList *list; int x, count; const char *name; char *foldername; GPContext *context; #ifdef HAVE_MCHECK_H mtrace(); #endif CHECK (gp_list_new(&list)); gp_log_add_func (GP_LOG_DEBUG, log_func, NULL); context = gp_context_new (); gp_context_set_error_func (context, error_func, NULL); printf ("*** Creating file system...\n"); CHECK (gp_filesystem_new (&fs)); printf ("*** Setting the callbacks...\n"); CHECK (gp_filesystem_set_funcs (fs, &fsfuncs, NULL)); printf ("*** Adding a file...\n"); CHECK (gp_filesystem_append (fs, "/", "my.file", context)); gp_filesystem_dump (fs); printf ("*** Removing this file...\n"); CHECK (gp_filesystem_delete_file (fs, "/", "my.file", context)); gp_filesystem_dump (fs); printf ("*** Resetting...\n"); CHECK (gp_filesystem_reset (fs)); gp_filesystem_dump (fs); printf ("*** Adding /...\n"); CHECK (gp_filesystem_append (fs, "/", NULL, context)); printf ("*** Adding /whatever ...\n"); CHECK (gp_filesystem_append (fs, "/whatever", NULL, context)); printf ("*** Adding /whatever/dir...\n"); CHECK (gp_filesystem_append (fs, "/whatever/dir", NULL, context)); printf ("*** Adding /whatever/dir/file1...\n"); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file1", context)); gp_filesystem_dump (fs); printf ("*** Adding /whatever/dir/file2...\n"); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file2", context)); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file3", context)); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file4", context)); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file5", context)); gp_filesystem_dump (fs); printf ("*** Deleting everything below root...\n"); CHECK (gp_filesystem_delete_all (fs, "/", context)); gp_filesystem_dump (fs); printf ("*** Appending root directory...\n"); CHECK (gp_filesystem_append (fs, "/", NULL, context)); printf ("*** Appending some directories...\n"); CHECK (gp_filesystem_append (fs, "/whatever", NULL, context)); CHECK (gp_filesystem_append (fs, "/whatever/directory", NULL, context)); printf ("*** Adding some files...\n"); CHECK (gp_filesystem_append (fs, "/whatever/directory", "some.file", context)); CHECK (gp_filesystem_append (fs, "/whatever/directory", "some.file2", context)); CHECK (gp_filesystem_append (fs, "/another/directory", "another.file", context)); gp_filesystem_dump (fs); printf ("*** Getting info about a file...\n"); CHECK (gp_filesystem_get_info (fs, "/whatever/directory", "some.file", &info, context)); printf ("*** Getting info again (cache!)...\n"); CHECK (gp_filesystem_get_info (fs, "/whatever/directory", "some.file", &info, context)); printf ("*** Set info about another file...\n"); CHECK (gp_filesystem_set_info (fs, "/whatever/directory", "some.file2", info, context)); printf ("*** Getting info about this file (cache!)...\n"); CHECK (gp_filesystem_get_info (fs, "/whatever/directory", "some.file2", &info, context)); printf ("*** Deleting a file...\n"); CHECK (gp_filesystem_delete_file (fs, "/whatever/directory", "some.file2", context)); gp_filesystem_dump (fs); printf ("*** Resetting the filesystem...\n"); CHECK (gp_filesystem_reset (fs)); gp_filesystem_dump (fs); printf ("*** Getting file list for folder '/whatever/directory'...\n"); CHECK (gp_filesystem_list_folders (fs, "/whatever/directory", list, context)); printf ("*** Getting file list for folder '/whatever/directory' " "again (cached!)...\n"); CHECK (gp_filesystem_list_folders (fs, "/whatever/directory", list, context)); printf ("*** Counting the contents...\n"); CHECK (count = gp_list_count (list)); printf ("*** Listing the contents...\n"); for (x = 0; x < count; x++) { CHECK (gp_list_get_name (list, x, &name)); printf (" %i: '%s'\n", x, name); } printf ("*** Getting folder of 'file1'...\n"); CHECK (gp_filesystem_get_folder (fs, "file1", &foldername, context)); printf ("... found in '%s'.\n", foldername); free(foldername); printf ("*** Deleting a couple of files...\n"); CHECK (gp_filesystem_delete_file (fs, "/whatever", "file5", context)); CHECK (gp_filesystem_delete_file (fs, "/whatever", "file4", context)); CHECK (gp_filesystem_delete_file (fs, "/whatever", "file3", context)); gp_filesystem_dump (fs); printf ("*** Freeing file system...\n"); CHECK (gp_filesystem_free (fs)); gp_context_unref (context); CHECK (gp_list_free(list)); #ifdef HAVE_MCHECK_H muntrace(); #endif return (0); }
/* This function reads all thumbnails at once and initializes the whole * camera filesystem. This can be done, because finding out how much * pictures are on the camera is done by reading the whole preview picture * stream anyway. * And since the file infos are static mostly, why not just set them too at * the same time. */ int jd11_index_reader(GPPort *port, CameraFilesystem *fs, GPContext *context) { int i, id, count, xsize, curread=0, ret=0; unsigned char *indexbuf; ret = jd11_select_index(port); if (ret != GP_OK) return ret; xsize = jd11_imgsize(port); if (!xsize) { /* shortcut, no reading needed */ return GP_OK; } count = xsize/(64*48); xsize = count * (64*48); indexbuf = malloc(xsize); if (!indexbuf) return GP_ERROR_NO_MEMORY; id = gp_context_progress_start (context, xsize, _("Downloading thumbnail...")); _send_cmd(port,0xfff1); while (curread < xsize) { int readsize = xsize-curread; if (readsize>200) readsize = 200; ret=getpacket(port,indexbuf+curread,readsize); if (ret==0) break; curread+=ret; if (ret<200) break; gp_context_progress_update (context, id, curread); if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) { /* What to do...Just free the stuff we allocated for now.*/ free(indexbuf); return GP_ERROR_CANCEL; } _send_cmd(port,0xfff1); } gp_context_progress_stop (context, id); for (i=0;i<count;i++) { CameraFile *file; char fn[20]; unsigned char *src; unsigned char thumb[64*48]; int y; CameraFileInfo info; ret = gp_file_new(&file); if (ret!=GP_OK) { free(indexbuf); return ret; } sprintf(fn,"image%02i.pgm",i); gp_file_set_mime_type(file, GP_MIME_PGM); gp_file_append(file, THUMBHEADER, strlen(THUMBHEADER)); src = indexbuf+(i*64*48); for (y=0;y<48;y++) { int x,off = 64*y; for (x=0;x<64;x++) thumb[47*64-off+(63-x)] = src[off+x]; } ret = gp_file_append(file,(char*)thumb,sizeof(thumb)); if (ret != GP_OK) { gp_file_free (file); return ret; } ret = gp_filesystem_append(fs, "/", fn, context); if (ret != GP_OK) { /* should perhaps remove the entry again */ gp_file_free (file); return ret; } ret = gp_filesystem_set_file_noop(fs, "/", fn, GP_FILE_TYPE_PREVIEW, file, context); if (ret != GP_OK) return ret; /* we also get the fs info for free, so just set it */ info.file.fields = GP_FILE_INFO_TYPE | GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT | GP_FILE_INFO_SIZE; strcpy(info.file.type,GP_MIME_PNM); info.file.width = 640; info.file.height = 480; info.file.size = 640*480*3+strlen(IMGHEADER); info.preview.fields = GP_FILE_INFO_TYPE | GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT | GP_FILE_INFO_SIZE; strcpy(info.preview.type,GP_MIME_PGM); info.preview.width = 64; info.preview.height = 48; info.preview.size = 64*48+strlen(THUMBHEADER); ret = gp_filesystem_set_info_noop(fs, "/", fn, info, context); } free(indexbuf); return GP_OK; }