summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2008-03-24 20:42:47 +0000
committerMarcus Meissner <marcus@jet.franken.de>2008-03-24 20:42:47 +0000
commitf3e14c2052e886c897b35f78144f73a39a1c7010 (patch)
tree8cf4b7d9e55465fa3bfcac1711593c35ac0a9178
parent21bff557d0daefd9acfdcbece08f6d2244b3b95d (diff)
downloadlibgphoto2-f3e14c2052e886c897b35f78144f73a39a1c7010.tar.gz
merged more from current trunk
- ids - SET_CONTEXT bugfix handling to avoid crashes - configuration updates git-svn-id: https://svn.code.sf.net/p/gphoto/code/branches/libgphoto2-2_4/libgphoto2@11026 67ed7778-7388-44ab-90cf-0a291f65f57c
-rw-r--r--camlibs/ptp2/config.c28
-rw-r--r--camlibs/ptp2/library.c67
2 files changed, 77 insertions, 18 deletions
diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c
index 07c8c1457..81423550d 100644
--- a/camlibs/ptp2/config.c
+++ b/camlibs/ptp2/config.c
@@ -56,6 +56,8 @@
#define CPR(context,result) {short r=(result); if (r!=PTP_RC_OK) {report_result ((context), r, params->deviceinfo.VendorExtensionID); return (translate_ptp_result (r));}}
+#define SET_CONTEXT(camera, ctx) ((PTPData *) camera->pl->params.data)->context = ctx
+
static int
camera_prepare_canon_powershot_capture(Camera *camera, GPContext *context) {
PTPUSBEventContainer event;
@@ -1086,6 +1088,7 @@ static struct deviceproptableu8 canon_flash[] = {
{ N_("off"), 0, 0 },
{ N_("auto"), 1, 0 },
{ N_("on"), 2, 0 },
+ { N_("fill in"), 4, 0 },
{ N_("auto red eye"), 5, 0 },
{ N_("on red eye"), 6, 0 },
};
@@ -1136,6 +1139,7 @@ GENERIC8TABLE(Canon_EOS_PictureStyle,canon_eos_picturestyle)
static struct deviceproptableu16 canon_shutterspeed[] = {
{ "auto",0x0000,0 },
+ { "bulb",0x0004,0 },
{ "30\"",0x0010,0 },
{ "25\"",0x0013,0 },
{ "20\"",0x0015,0 },
@@ -1217,6 +1221,7 @@ static struct deviceproptableu16 canon_isospeed[] = {
{ "400", 0x0058, 0 },
{ "800", 0x0060, 0 },
{ "1600", 0x0068, 0 },
+ { "3200", 0x0070, 0 },
{ N_("Auto"), 0x0000, 0 },
};
GENERIC16TABLE(Canon_ISO,canon_isospeed)
@@ -1747,6 +1752,8 @@ GENERIC16TABLE(Canon_PhotoEffect,canon_photoeffect)
static struct deviceproptableu16 canon_aperture[] = {
{ N_("auto"), 0xffff, 0 },
+ { "1.4", 0x0010, 0 },
+ { "1.6", 0x0013, 0 },
{ "1.8", 0x0015, 0 },
{ "2.0", 0x0018, 0 },
{ "2.2", 0x001b, 0 },
@@ -1770,6 +1777,9 @@ static struct deviceproptableu16 canon_aperture[] = {
{ "18", 0x004b, 0 },
{ "20", 0x004d, 0 },
{ "22", 0x0050, 0 },
+ { "25", 0x0053, 0 },
+ { "29", 0x0055, 0 },
+ { "32", 0x0058, 0 },
};
GENERIC16TABLE(Canon_Aperture,canon_aperture)
@@ -1876,6 +1886,20 @@ _put_UINT32_as_time(CONFIG_PUT_ARGS) {
}
static int
+_get_Canon_SyncTime(CONFIG_GET_ARGS) {
+ gp_widget_new (GP_WIDGET_TOGGLE, _(menu->label), widget);
+ gp_widget_set_name (*widget,menu->name);
+ return (GP_OK);
+}
+
+static int
+_put_Canon_SyncTime(CONFIG_PUT_ARGS) {
+ /* Just set the time if the entry changes. */
+ propval->u32 = time(NULL);
+ return (GP_OK);
+}
+
+static int
_get_STR_as_time(CONFIG_GET_ARGS) {
time_t camtime;
struct tm tm;
@@ -2583,7 +2607,9 @@ static struct submenu camera_settings_menu[] = {
{ N_("Camera Model"), "model", PTP_DPC_CANON_CameraModel, PTP_VENDOR_CANON, PTP_DTC_STR, _get_STR, _put_None },
{ N_("Firmware Version"), "firmwareversion", PTP_DPC_CANON_FirmwareVersion, PTP_VENDOR_CANON, PTP_DTC_UINT32, _get_CANON_FirmwareVersion, _put_None },
{ N_("Camera Time"), "time", PTP_DPC_CANON_UnixTime, PTP_VENDOR_CANON, PTP_DTC_UINT32, _get_UINT32_as_time, _put_UINT32_as_time },
+ { N_("Set camera time to PC time"), "synctime", PTP_DPC_CANON_UnixTime, PTP_VENDOR_CANON, PTP_DTC_UINT32, _get_Canon_SyncTime, _put_Canon_SyncTime },
{ N_("Camera Time"), "eos-time", PTP_DPC_CANON_EOS_CameraTime, PTP_VENDOR_CANON, PTP_DTC_UINT32, _get_UINT32_as_time, _put_UINT32_as_time },
+ { N_("Set camera time to PC time"), "eos-synctime", PTP_DPC_CANON_EOS_CameraTime, PTP_VENDOR_CANON, PTP_DTC_UINT32, _get_Canon_SyncTime, _put_Canon_SyncTime },
{ N_("Camera Time"), "time", PTP_DPC_DateTime, 0, PTP_DTC_STR, _get_STR_as_time, _put_STR_as_time },
{ N_("Beep Mode"), "beep", PTP_DPC_CANON_BeepMode, PTP_VENDOR_CANON, PTP_DTC_UINT8, _get_Canon_BeepMode, _put_Canon_BeepMode },
{ N_("Image Comment"), "imgcomment", PTP_DPC_NIKON_ImageCommentString, PTP_VENDOR_NIKON, PTP_DTC_STR, _get_STR, _put_STR },
@@ -2700,6 +2726,7 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
{
CameraWidget *section, *widget;
int menuno, submenuno, ret;
+ SET_CONTEXT(camera, context);
gp_widget_new (GP_WIDGET_WINDOW, _("Camera and Driver Configuration"), window);
gp_widget_set_name (*window, "main");
@@ -2759,6 +2786,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
{
CameraWidget *section, *widget, *subwindow;
int menuno, submenuno, ret;
+ SET_CONTEXT(camera, context);
ret = gp_widget_get_child_by_label (window, _("Camera and Driver Configuration"), &subwindow);
if (ret != GP_OK)
diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c
index f70a65918..b5da1a17b 100644
--- a/camlibs/ptp2/library.c
+++ b/camlibs/ptp2/library.c
@@ -62,6 +62,9 @@
#define USB_NORMAL_TIMEOUT 20000
#define USB_TIMEOUT_CAPTURE 20000
+#define SET_CONTEXT(camera, ctx) ((PTPData *) camera->pl->params.data)->context = ctx
+#define SET_CONTEXT_P(p, ctx) ((PTPData *) p->data)->context = ctx
+
#define CPR(context,result) {short r=(result); if (r!=PTP_RC_OK) {report_result ((context), r, params->deviceinfo.VendorExtensionID); return (translate_ptp_result (r));}}
#define CPR_free(context,result, freeptr) {\
@@ -549,6 +552,8 @@ static struct {
{"Nikon:DSC D300 (PTP mode)", 0x04b0, 0x041a, PTP_CAP},
/* Sridharan Rengaswamy <sridhar@stsci.edu>, Coolpix L3 */
{"Nikon:Coolpix L3 (PTP mode)", 0x04b0, 0x041a, 0},
+ /* Pat Shanahan, http://sourceforge.net/tracker/index.php?func=detail&aid=1924511&group_id=8874&atid=358874 */
+ {"Nikon:D3 (PTP mode)", 0x04b0, 0x041c, PTP_CAP},
/* Thomas Luzat <thomas.luzat@gmx.net> */
/* this was reported as not working, mass storage only:
@@ -744,6 +749,10 @@ static struct {
{"Canon:Powershot SX100 IS (PTP mode)", 0x04a9, 0x315e, PTPBUG_DELETE_SENDS_EVENT|PTP_CAP|PTP_CAP_PREVIEW},
/* Ruben Vandamme <vandamme.ruben@belgacom.net> */
{"Canon:Digital IXUS 860 IS", 0x04a9, 0x3160, PTPBUG_DELETE_SENDS_EVENT},
+
+ /* Olaf Hering at SUSE */
+ {"Canon:PowerShot A590 IS", 0x04a9, 0x3176, PTPBUG_DELETE_SENDS_EVENT},
+
/* https://sourceforge.net/tracker/?func=detail&atid=358874&aid=1910010&group_id=8874 */
{"Canon:Digital IXUS 80 IS", 0x04a9, 0x3184, PTPBUG_DELETE_SENDS_EVENT},
@@ -800,6 +809,8 @@ static struct {
/* from Mike Meyer <mwm@mired.org> */
{"Apple:iPhone (PTP mode)", 0x05ac, 0x1290, PTPBUG_DCIM_WRONG_PARENT},
+ /* https://sourceforge.net/tracker/index.php?func=detail&aid=1869653&group_id=158745&atid=809061 */
+ {"Pioneer:DVR-LX60D", 0x08e4, 0x0142, 0},
/************ Add MTP devices below this line ***********/
/* This camera speaks _only_ PictBridge, so it is too limited
@@ -1201,6 +1212,7 @@ camera_exit (Camera *camera, GPContext *context)
{
if (camera->pl!=NULL) {
PTPParams *params = &camera->pl->params;
+ SET_CONTEXT_P(params, context);
/* close iconv converters */
iconv_close(camera->pl->params.cd_ucs2_to_locale);
iconv_close(camera->pl->params.cd_locale_to_ucs2);
@@ -1311,14 +1323,17 @@ camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context)
_("Sorry, your Canon camera does not support Canon Viewfinder mode"));
return GP_ERROR_NOT_SUPPORTED;
}
+ SET_CONTEXT_P(params, context);
ret = ptp_canon_viewfinderon (params);
if (ret != PTP_RC_OK) {
gp_context_error (context, _("Canon enable viewfinder failed: %d"), ret);
+ SET_CONTEXT_P(params, NULL);
return GP_ERROR;
}
ret = ptp_canon_getviewfinderimage (params, &data, &size);
if (ret != PTP_RC_OK) {
gp_context_error (context, _("Canon get viewfinder image failed: %d"), ret);
+ SET_CONTEXT_P(params, NULL);
return GP_ERROR;
}
gp_file_set_data_and_size ( file, (char*)data, size );
@@ -1329,8 +1344,10 @@ camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context)
ret = ptp_canon_viewfinderoff (params);
if (ret != PTP_RC_OK) {
gp_context_error (context, _("Canon disable viewfinder failed: %d"), ret);
+ SET_CONTEXT_P(params, NULL);
return GP_ERROR;
}
+ SET_CONTEXT_P(params, NULL);
return GP_OK;
}
return GP_ERROR_NOT_SUPPORTED;
@@ -1728,6 +1745,11 @@ camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path,
uint32_t newobject = 0x0;
int done;
+ /* adjust if we ever do sound or movie capture */
+ if (type != GP_CAPTURE_IMAGE)
+ return GP_ERROR_NOT_SUPPORTED;
+
+ SET_CONTEXT_P(params, context);
if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_NIKON) &&
ptp_operation_issupported(params, PTP_OC_NIKON_Capture)
){
@@ -1749,9 +1771,6 @@ camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path,
return camera_canon_eos_capture (camera, type, path, context);
}
- if (type != GP_CAPTURE_IMAGE)
- return GP_ERROR_NOT_SUPPORTED;
-
if (!ptp_operation_issupported(params,PTP_OC_InitiateCapture)) {
gp_context_error(context,
_("Sorry, your camera does not support generic capture"));
@@ -1891,6 +1910,7 @@ camera_wait_for_event (Camera *camera, int timeout,
int i, oldtimeout;
uint16_t ret;
+ SET_CONTEXT(camera, context);
memset (&event, 0, sizeof(event));
gp_port_get_timeout (camera->port, &oldtimeout);
gp_port_set_timeout (camera->port, timeout);
@@ -2033,7 +2053,7 @@ canon_theme_get (CameraFilesystem *fs, const char *folder, const char *filename,
int i;
struct canon_theme_entry *ent;
- ((PTPData *) camera->pl->params.data)->context = context;
+ SET_CONTEXT(camera, context);
res = ptp_canon_get_customize_data (params, 1, &xdata, &size);
if (res != PTP_RC_OK) {
@@ -2078,6 +2098,7 @@ nikon_curve_get (CameraFilesystem *fs, const char *folder, const char *filename,
char *charptr;
double *doubleptr;
((PTPData *) camera->pl->params.data)->context = context;
+ SET_CONTEXT(camera, context);
res = ptp_nikon_curve_download (params, &xdata, &size);
if (res != PTP_RC_OK) {
@@ -2133,6 +2154,8 @@ camera_summary (Camera* camera, CameraText* summary, GPContext *context)
PTPDeviceInfo pdi;
PTPStorageIDs storageids;
+ SET_CONTEXT(camera, context);
+
spaceleft = sizeof(summary->text);
n = snprintf (summary->text, sizeof (summary->text),
_("Model: %s\n"
@@ -2551,8 +2574,8 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
PTPParams *params = &camera->pl->params;
uint32_t parent, storage=0x0000000;
int i;
+ SET_CONTEXT_P(params, context);
- /*((PTPData *)((Camera *)data)->pl->params.data)->context = context;*/
gp_log (GP_LOG_DEBUG, "ptp2", "file_list_func(%s)", folder);
/* There should be NO files in root folder */
@@ -2612,7 +2635,7 @@ folder_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
int i;
uint32_t handler,storage;
- /*((PTPData *)((Camera *)data)->pl->params.data)->context = context;*/
+ SET_CONTEXT_P(params, context);
gp_log (GP_LOG_DEBUG, "ptp2", "folder_list_func(%s)", folder);
/* add storage pseudofolders in root folder */
@@ -3154,7 +3177,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
PTPObjectInfo * oi;
PTPParams *params = &camera->pl->params;
- ((PTPData *) params->data)->context = context;
+ SET_CONTEXT_P(params, context);
#if 0
/* The new Canons like to switch themselves off in the middle. */
@@ -3310,7 +3333,7 @@ put_file_func (CameraFilesystem *fs, const char *folder, CameraFile *file,
PTPParams* params=&camera->pl->params;
CameraFileType type;
- ((PTPData *) camera->pl->params.data)->context = context;
+ SET_CONTEXT_P(params, context);
gp_file_get_name (file, &filename);
gp_file_get_type (file, &type);
@@ -3422,7 +3445,7 @@ delete_file_func (CameraFilesystem *fs, const char *folder,
uint32_t storage;
PTPParams *params = &camera->pl->params;
- ((PTPData *) params->data)->context = context;
+ SET_CONTEXT_P(params, context);
if (!ptp_operation_issupported(params, PTP_OC_DeleteObject))
return GP_ERROR_NOT_SUPPORTED;
@@ -3489,7 +3512,7 @@ remove_dir_func (CameraFilesystem *fs, const char *folder,
uint32_t storage;
PTPParams *params = &camera->pl->params;
- ((PTPData *) params->data)->context = context;
+ SET_CONTEXT_P(params, context);
if (!ptp_operation_issupported(params, PTP_OC_DeleteObject))
return GP_ERROR_NOT_SUPPORTED;
@@ -3528,7 +3551,7 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *filename,
uint32_t storage;
PTPParams *params = &camera->pl->params;
- ((PTPData *) params->data)->context = context;
+ SET_CONTEXT_P(params, context);
if (!strcmp (folder, "/special"))
return (GP_ERROR_BAD_PARAMETERS); /* for now */
@@ -3624,7 +3647,7 @@ make_dir_func (CameraFilesystem *fs, const char *folder, const char *foldername,
if (!strcmp (folder, "/special"))
return GP_ERROR_NOT_SUPPORTED;
- ((PTPData *) camera->pl->params.data)->context = context;
+ SET_CONTEXT_P(params, context);
memset(&oi, 0, sizeof (PTPObjectInfo));
/* compute storage ID value from folder patch */
@@ -3685,6 +3708,7 @@ storage_info_func (CameraFilesystem *fs,
if (!ptp_operation_issupported (params, PTP_OC_GetStorageIDs))
return (GP_ERROR_NOT_SUPPORTED);
+ SET_CONTEXT_P(params, context);
ret = ptp_getstorageids (params, &sids);
if (ret != PTP_RC_OK)
return translate_ptp_result (ret);
@@ -3786,7 +3810,7 @@ init_ptp_fs (Camera *camera, GPContext *context)
char buf[1024];
uint16_t ret;
- ((PTPData *) params->data)->context = context;
+ SET_CONTEXT_P(params, context);
memset (&params->handles, 0, sizeof(PTPObjectHandles));
/* Nikon supports a fast filesystem retrieval.
@@ -4001,32 +4025,38 @@ init_ptp_fs (Camera *camera, GPContext *context)
i++;
lasthandle = xpl->ObjectHandle;
params->handles.Handler[i] = xpl->ObjectHandle;
+ gp_log (GP_LOG_DEBUG, "ptp2/mtpfast", "objectid %u", xpl->ObjectHandle);
}
switch (xpl->property) {
case PTP_OPC_ParentObject:
oinfos[i].ParentObject = xpl->propval.u32;
+ gp_log (GP_LOG_DEBUG, "ptp2/mtpfast", "parent %u", xpl->propval.u32);
break;
case PTP_OPC_ObjectFormat:
oinfos[i].ObjectFormat = xpl->propval.u16;
+ gp_log (GP_LOG_DEBUG, "ptp2/mtpfast", "ofc %u", xpl->propval.u16);
break;
case PTP_OPC_ObjectSize:
oinfos[i].ObjectCompressedSize = xpl->propval.u32;
+ gp_log (GP_LOG_DEBUG, "ptp2/mtpfast", "objectsize %u", xpl->propval.u32);
break;
case PTP_OPC_StorageID:
oinfos[i].StorageID = xpl->propval.u32;
+ gp_log (GP_LOG_DEBUG, "ptp2/mtpfast", "storageid %u", xpl->propval.u32);
break;
case PTP_OPC_ObjectFileName:
- if (xpl->propval.str)
+ if (xpl->propval.str) {
+ gp_log (GP_LOG_DEBUG, "ptp2/mtpfast", "filename %s", xpl->propval.str);
oinfos[i].Filename = strdup(xpl->propval.str);
- else
+ } else {
oinfos[i].Filename = NULL;
+ }
break;
default:
if ((xpl->property & 0xfff0) == 0xdc00)
- gp_log (GP_LOG_DEBUG, "ptp2/mtpfast", "case %x type %x unhandled.\n", xpl->property, xpl->datatype);
+ gp_log (GP_LOG_DEBUG, "ptp2/mtpfast", "case %x type %x unhandled", xpl->property, xpl->datatype);
break;
}
- xpl = xpl->next;
}
return PTP_RC_OK;
}
@@ -4296,7 +4326,7 @@ camera_init (Camera *camera, GPContext *context)
CR (gp_port_set_timeout (camera->port, USB_START_TIMEOUT));
/* Establish a connection to the camera */
- ((PTPData *) camera->pl->params.data)->context = context;
+ SET_CONTEXT(camera, context);
retried = 0;
while (1) {
@@ -4389,5 +4419,6 @@ camera_init (Camera *camera, GPContext *context)
break;
}
CR (gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera));
+ SET_CONTEXT(camera, NULL);
return (GP_OK);
}