static void load_save_settings(GtkamSave *save) { gchar buf[1024]; gchar *dir; /* directory */ if (gp_setting_get("gtkam","save-dir",buf) == GP_OK) { dir = g_strdup (buf); strcat (buf, G_DIR_SEPARATOR_S); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (save), buf); } else { dir = g_strdup (gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER (save))); } /* prefix entry */ gp_setting_get ("gtkam", "save-prefix", buf); gtk_entry_set_text (GTK_ENTRY (save->priv->prefix_entry), buf); /* toggle buttons */ #define LOAD_TOGGLE(NAME) \ gp_setting_get("gtkam","save-" #NAME,buf); \ gtk_toggle_button_set_active(save->priv->toggle_ ## NAME, atoi(buf)) LOAD_TOGGLE(preview); LOAD_TOGGLE(normal); LOAD_TOGGLE(raw); LOAD_TOGGLE(audio); LOAD_TOGGLE(exif); LOAD_TOGGLE(filename_camera); g_free(dir); }
static int camera_config_get (Camera *camera, CameraWidget **window, GPContext *context) { CameraWidget *section, *turbo; char buf[1024]; int val; gp_widget_new (GP_WIDGET_WINDOW, _("Camera Configuration"), window); gp_widget_set_name (*window, "config"); gp_widget_new (GP_WIDGET_SECTION, _("Driver Settings"), §ion); gp_widget_set_name (section, "driver"); gp_widget_append (*window, section); gp_widget_new (GP_WIDGET_RADIO, _("Turbo mode"), &turbo); gp_widget_set_name (turbo, "turbo"); gp_widget_add_choice (turbo,_("On")); gp_widget_add_choice (turbo,_("Off")); gp_widget_append (section, turbo); if (GP_OK == gp_setting_get("topfield","turbo", buf)) { if (!strcmp(buf,"no")) val = 0; else val = 1; } else { val = 1; /* enabled by default */ } gp_widget_set_value ( turbo, val?_("On"):_("Off")); return GP_OK; }
int camera_init (Camera *camera, GPContext *context) { CameraAbilities a; int ret; char *dump, buf[256]; /* First, set up all the function pointers */ camera->functions->exit = camera_exit; camera->functions->summary = camera_summary; camera->functions->manual = camera_manual; camera->functions->about = camera_about; camera->functions->get_config = camera_get_config; camera->functions->set_config = camera_set_config; /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = calloc (1, sizeof(CameraPrivateLibrary)); if (!camera->pl) return GP_ERROR_NO_MEMORY; ret = gp_setting_get("tp6801", "syncdatetime", buf); if (ret == GP_OK) camera->pl->syncdatetime = buf[0] == '1'; else camera->pl->syncdatetime = 1; CHECK (gp_camera_get_abilities(camera, &a)) dump = getenv("GP_TP6801_DUMP"); if (dump) ret = tp6801_open_dump (camera, dump); else ret = tp6801_open_device (camera); if (ret != GP_OK) { camera_exit (camera, context); return ret; } if (camera->pl->syncdatetime) { struct tm tm; time_t t; t = time (NULL); if (localtime_r (&t , &tm)) { ret = tp6801_set_time_and_date (camera, &tm); if (ret != GP_OK) { camera_exit (camera, context); return ret; } } } return GP_OK; }
/** * ptp_nikon_getwifiguid: * * This command gets the GUID of this machine. If it does not exists, it creates * one. * * params: PTPParams* * * Return values: Some PTP_RC_* code. * **/ void ptp_nikon_getptpipguid (unsigned char* guid) { char buffer[1024]; int i; long val; int valid; char* endptr; char* pos; gp_setting_get("ptp2_ip","guid",buffer); if (strlen(buffer) == 47) { /* 47 = 16*2 (numbers) + 15 (semi-colons) */ pos = buffer; valid = 1; for (i = 0; i < 16; i++) { val = strtol(pos, &endptr, 16); if (((*endptr != ':') && (*endptr != 0)) || (endptr != pos+2)) { valid = 0; break; } guid[i] = (unsigned char)val; pos += 3; } /*printf("GUID "); for (i = 0; i < 16; i++) { printf("%02x:", guid[i]); } printf("\n");*/ if (valid) return; } /*fprintf(stderr, "Invalid GUID\n");*/ /* Generate an ID */ srand(time(NULL)); buffer[0] = 0; pos = buffer; for (i = 0; i < 16; i++) { guid[i] = (unsigned char) ((256.0 * rand()) / RAND_MAX); pos += sprintf(pos, "%02x:", guid[i]); } buffer[47] = 0; /*printf("New GUID: %s\n", buffer);*/ gp_setting_set("ptp2_ip","guid",buffer); }
static int do_cmd_turbo(Camera *camera, char *state, GPContext *context) { int r; int turbo_on = atoi(state); struct tf_packet reply; char buf[1024]; /* check if we want to use turbo mode. Default is YES */ if (GP_OK == gp_setting_get("topfield","turbo", buf)) if (!strcmp(buf,"no")) return GP_OK; if(0 == strcasecmp("ON", state)) turbo_on = 1; r = send_cmd_turbo(camera, turbo_on, context); if(r < 0) return r; r = get_tf_packet(camera, &reply, context); if(r < 0) return r; switch (get_u32(&reply.cmd)) { case SUCCESS: gp_log (GP_LOG_DEBUG, "topfield", "Turbo mode: %s\n", turbo_on ? "ON" : "OFF"); return GP_OK; break; case FAIL: gp_log (GP_LOG_ERROR, "topfield", "ERROR: Device reports %s\n", decode_error(&reply)); break; default: gp_log (GP_LOG_ERROR, "topfield", "ERROR: Unhandled packet\n"); } return GP_ERROR_IO; }
int camera_init (Camera *camera, GPContext *context) { int i, j, ret; #ifdef HAVE_ICONV char *curloc; #endif char buf[256]; st2205_filename clean_name; /* First, set up all the function pointers */ camera->functions->exit = camera_exit; camera->functions->summary = camera_summary; camera->functions->manual = camera_manual; camera->functions->about = camera_about; camera->functions->get_config = camera_get_config; camera->functions->set_config = camera_set_config; /* FIXME add gp_camera_get_storageinfo support */ /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = calloc (1, sizeof(CameraPrivateLibrary)); if (!camera->pl) return GP_ERROR_NO_MEMORY; ret = gp_setting_get("st2205", "syncdatetime", buf); if (ret == GP_OK) camera->pl->syncdatetime = buf[0] == '1'; else camera->pl->syncdatetime = 1; ret = gp_setting_get("st2205", "orientation", buf); if (ret == GP_OK) { ret = string_to_orientation (buf); if (ret >= 0) camera->pl->orientation = ret; } #ifdef HAVE_ICONV curloc = nl_langinfo (CODESET); if (!curloc) curloc="UTF-8"; camera->pl->cd = iconv_open("ASCII", curloc); if (camera->pl->cd == (iconv_t) -1) { gp_log (GP_LOG_ERROR, "iconv", "Failed to create iconv converter"); camera_exit (camera, context); return GP_ERROR_OS_FAILURE; } #endif #if 1 ret = st2205_open_device (camera); #else ret = st2205_open_dump (camera, "/home/hans/st2205tool/memdump.bin", 128, 128); #endif if (ret != GP_OK) { camera_exit (camera, context); return ret; } GP_DEBUG ("st2205 memory size: %d, free: %d", st2205_get_mem_size (camera), st2205_get_free_mem_size (camera)); /* Get the filenames from the picframe */ ret = st2205_get_filenames (camera, camera->pl->filenames); if (ret != GP_OK) { camera_exit (camera, context); return ret; } /* And clean them up and make them unique */ for (i = 0; i < ST2205_MAX_NO_FILES; i++) { if (!camera->pl->filenames[i][0]) continue; /* Filter out non ASCII chars (some frames ship with sample photo's with garbage in the names) */ for (j = 0; camera->pl->filenames[i][j]; j++) { if ((uint8_t)camera->pl->filenames[i][j] < 0x20 || (uint8_t)camera->pl->filenames[i][j] > 0x7E) clean_name[j] = '?'; else clean_name[j] = camera->pl->filenames[i][j]; } clean_name[j] = 0; ST2205_SET_FILENAME(camera->pl->filenames[i], clean_name, i); } /* Sync time if requested */ if (camera->pl->syncdatetime) { struct tm tm; time_t t; t = time (NULL); if (localtime_r (&t , &tm)) { ret = st2205_set_time_and_date (camera, &tm); if (ret != GP_OK) { camera_exit (camera, context); return ret; } } } return GP_OK; }
int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; int ret, selected_speed; char buf[1024]; /* First, set up all the function pointers */ camera->functions->exit = camera_exit; camera->functions->capture = camera_capture; camera->functions->capture_preview = camera_capture_preview; camera->functions->summary = camera_summary; camera->functions->manual = camera_manual; camera->functions->about = camera_about; camera->functions->get_config = camera_get_config; camera->functions->set_config = camera_set_config; /* Get the settings and remember the selected speed */ gp_port_get_settings (camera->port, &settings); selected_speed = settings.serial.speed; /* TODO: camera->pl can probably be allocated at the end to simplify */ camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) { gp_context_error (context, _("Out of memory")); return (GP_ERROR_NO_MEMORY); } /* Set the default exposure */ if (gp_setting_get ("dimera3500", "exposure", buf) == GP_OK) camera->pl->exposure = atoi(buf); else camera->pl->exposure = DEFAULT_EXPOSURE; /* Set automatic exposure enable setting for capture preview mode */ if (gp_setting_get ("dimera3500", "auto_exposure", buf) == GP_OK) camera->pl->auto_exposure = atoi(buf); else camera->pl->auto_exposure = 1; /* Set flag to use flash, if necessary, when capturing picture */ if (gp_setting_get ("dimera3500", "auto_flash", buf) == GP_OK) camera->pl->auto_flash = atoi(buf); else camera->pl->auto_flash = 1; GP_DEBUG("Opening port"); if ( (ret = mesa_port_open(camera->port)) != GP_OK) { ERROR("Camera Open Failed"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("Problem opening port")); return ret; } GP_DEBUG("Resetting camera"); if ( (ret = mesa_reset(camera->port)) != GP_OK ) { ERROR("Camera Reset Failed"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("Problem resetting camera")); return ret; } GP_DEBUG("Setting speed"); if ( (ret = mesa_set_speed(camera->port, selected_speed)) != GP_OK ) { ERROR("Camera Speed Setting Failed"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("Problem setting camera communication speed")); return ret; } GP_DEBUG("Checking for modem"); switch ( ret = mesa_modem_check(camera->port) ) { case GP_ERROR_IO: case GP_ERROR_TIMEOUT: ERROR("No or Unknown Response"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("No response from camera")); return GP_ERROR_TIMEOUT; case GP_ERROR_MODEL_NOT_FOUND: ERROR("Probably a modem"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("Looks like a modem, not a camera")); return GP_ERROR_MODEL_NOT_FOUND; case GP_OK: break; default: /* Hopefully, gp_camera_set_error was called for this error */ return ret; } /* Tell the filesystem where to get listings and info from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); return (GP_OK); }
int camera_init (Camera *camera, GPContext *context) { CameraAbilities a; int i, ret; char *dump, buf[256]; /* First, set up all the function pointers */ camera->functions->exit = camera_exit; camera->functions->summary = camera_summary; camera->functions->manual = camera_manual; camera->functions->about = camera_about; camera->functions->get_config = camera_get_config; camera->functions->set_config = camera_set_config; /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = calloc (1, sizeof(CameraPrivateLibrary)); if (!camera->pl) return GP_ERROR_NO_MEMORY; ret = gp_setting_get("ax203", "syncdatetime", buf); if (ret == GP_OK) camera->pl->syncdatetime = buf[0] == '1'; else camera->pl->syncdatetime = 1; CHECK (gp_camera_get_abilities(camera, &a)) for (i = 0; ax203_devinfo[i].vendor_id; i++) { if ((a.usb_vendor == ax203_devinfo[i].vendor_id) && (a.usb_product == ax203_devinfo[i].product_id)) { camera->pl->frame_version = ax203_devinfo[i].frame_version; break; } } if (!ax203_devinfo[i].vendor_id) { gp_log (GP_LOG_ERROR, "ax203", "Unknown USB ID"); camera_exit (camera, context); return GP_ERROR_BAD_PARAMETERS; } dump = getenv("GP_AX203_DUMP"); if (dump) ret = ax203_open_dump (camera, dump); else ret = ax203_open_device (camera); if (ret != GP_OK) { camera_exit (camera, context); return ret; } GP_DEBUG ("ax203 memory size: %d, free: %d", ax203_get_mem_size (camera), ax203_get_free_mem_size (camera)); if (camera->pl->syncdatetime) { struct tm tm; time_t t; t = time (NULL); if (localtime_r (&t , &tm)) { ret = ax203_set_time_and_date (camera, &tm); if (ret != GP_OK) { camera_exit (camera, context); return ret; } } } return GP_OK; }