static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { Camera *camera = data; int i = 0, filecount = 0; char temp_file[14]; if (cam_has_flash(camera->pl) || cam_has_card(camera->pl) ) { CHECK (spca50x_flash_get_TOC(camera->pl, &filecount)); for (i=0; i<filecount; i++) { CHECK(spca50x_flash_get_file_name (camera->pl, i, temp_file)); gp_list_append (list, temp_file, NULL); } } if (cam_has_sdram(camera->pl)) { if (camera->pl->dirty_sdram) CHECK (spca50x_sdram_get_info (camera->pl)); for (i = 0; i < camera->pl->num_files_on_sdram; i++) { strncpy (temp_file, camera->pl->files[i].name, 12); temp_file[12] = 0; gp_list_append (list, temp_file, NULL); } } return GP_OK; }
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); }
/* extract ascii-encoded number from file name */ static int spca50x_flash_get_number_from_file_name (CameraPrivateLibrary *pl, int index, int *file_number) { char name[14]; CHECK (spca50x_flash_get_file_name (pl, index, name)); if(sscanf(&(name[4]), "%d", file_number) != 1) /* skip "DSC_" */ return GP_ERROR; return GP_OK; }
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; }