コード例 #1
0
ファイル: library.c プロジェクト: Dvizhenka/libgphoto2
static int
camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
{
	CameraWidget *child;
	int ret;

	GP_DEBUG ("*** camera_set_config");

	ret = gp_widget_get_child_by_label (window,
			_("Synchronize frame data and time with PC"), &child);
	if (ret == GP_OK)
		gp_widget_get_value (child, &camera->pl->syncdatetime);

	ret = gp_widget_get_child_by_label (window, _("Orientation"), &child);
	if (ret == GP_OK) {
		char *value;
		int orientation;
		gp_widget_get_value (child, &value);
		orientation = string_to_orientation (value);
		if (orientation < 0) return orientation;
		camera->pl->orientation = orientation;
	}

	return GP_OK;
}
コード例 #2
0
static OrientationUp
get_prev_orientation(struct udev_device *dev)
{
	const char *value;

	value = udev_device_get_property_value(dev, "ID_INPUT_ACCELEROMETER_ORIENTATION");
	if (value == NULL)
		return ORIENTATION_UNDEFINED;
	return string_to_orientation(value);
}
コード例 #3
0
ファイル: library.c プロジェクト: Dvizhenka/libgphoto2
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;
}