~ubuntu-branches/ubuntu/precise/libmtp/precise-proposed

« back to all changes in this revision

Viewing changes to src/ptp.c

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2009-12-14 22:32:10 UTC
  • mto: (16.1.3 sid) (0.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: james.westby@ubuntu.com-20091214223210-vekc5340wzmz54bw
Tags: upstream-1.0.1
ImportĀ upstreamĀ versionĀ 1.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 */
23
23
 
24
24
#define _BSD_SOURCE
25
 
#include <config.h>
 
25
#include "config.h"
26
26
#include "ptp.h"
27
27
 
28
28
#include <stdlib.h>
138
138
                uint16_t flags, unsigned int sendlen,
139
139
                PTPDataHandler *handler
140
140
) {
 
141
        int tries;
 
142
 
141
143
        if ((params==NULL) || (ptp==NULL)) 
142
144
                return PTP_ERROR_BADPARAM;
143
145
 
181
183
        default:
182
184
                return PTP_ERROR_BADPARAM;
183
185
        }
184
 
        /* get response */
185
 
        CHECK_PTP_RC(params->getresp_func(params, ptp));
186
 
        if (ptp->Transaction_ID != params->transaction_id-1) {
187
 
                ptp_error (params,
188
 
                        "PTP: Sequence number mismatch %d vs expected %d.",
189
 
                        ptp->Transaction_ID, params->transaction_id-1
190
 
                );
191
 
                return PTP_ERROR_BADPARAM;
 
186
        tries = 3;
 
187
        while (1) {
 
188
                /* get response */
 
189
                CHECK_PTP_RC(params->getresp_func(params, ptp));
 
190
                if (ptp->Transaction_ID != params->transaction_id-1) {
 
191
                        /* try to clean up potential left overs from previous session */
 
192
                        if ((ptp->Code == PTP_OC_OpenSession) && tries--)
 
193
                                continue;
 
194
                        ptp_error (params,
 
195
                                "PTP: Sequence number mismatch %d vs expected %d.",
 
196
                                ptp->Transaction_ID, params->transaction_id-1
 
197
                        );
 
198
                        return PTP_ERROR_BADPARAM;
 
199
                }
 
200
                break;
192
201
        }
193
202
        return ptp->Code;
194
203
}
237
246
ptp_init_recv_memory_handler(PTPDataHandler *handler) {
238
247
        PTPMemHandlerPrivate* priv;
239
248
        priv = malloc (sizeof(PTPMemHandlerPrivate));
240
 
        handler->private = priv;
 
249
        handler->priv = priv;
241
250
        handler->getfunc = memory_getfunc;
242
251
        handler->putfunc = memory_putfunc;
243
252
        priv->data = NULL;
257
266
        priv = malloc (sizeof(PTPMemHandlerPrivate));
258
267
        if (!priv)
259
268
                return PTP_RC_GeneralError;
260
 
        handler->private = priv;
 
269
        handler->priv = priv;
261
270
        handler->getfunc = memory_getfunc;
262
271
        handler->putfunc = memory_putfunc;
263
272
        priv->data = data;
269
278
/* free private struct + data */
270
279
static uint16_t
271
280
ptp_exit_send_memory_handler (PTPDataHandler *handler) {
272
 
        PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->private;
 
281
        PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->priv;
273
282
        /* data is owned by caller */
274
283
        free (priv);
275
284
        return PTP_RC_OK;
280
289
ptp_exit_recv_memory_handler (PTPDataHandler *handler,
281
290
        unsigned char **data, unsigned long *size
282
291
) {
283
 
        PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->private;
 
292
        PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->priv;
284
293
        *data = priv->data;
285
294
        *size = priv->size;
286
295
        free (priv);
328
337
ptp_init_fd_handler(PTPDataHandler *handler, int fd) {
329
338
        PTPFDHandlerPrivate* priv;
330
339
        priv = malloc (sizeof(PTPFDHandlerPrivate));
331
 
        handler->private = priv;
 
340
        handler->priv = priv;
332
341
        handler->getfunc = fd_getfunc;
333
342
        handler->putfunc = fd_putfunc;
334
343
        priv->fd = fd;
337
346
 
338
347
static uint16_t
339
348
ptp_exit_fd_handler (PTPDataHandler *handler) {
340
 
        PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)handler->private;
 
349
        PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)handler->priv;
341
350
        free (priv);
342
351
        return PTP_RC_OK;
343
352
}
410
419
        len=0;
411
420
        ret=ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler);
412
421
        ptp_exit_recv_memory_handler (&handler, &di, &len);
 
422
        if (!di) ret = PTP_RC_GeneralError;
413
423
        if (ret == PTP_RC_OK) ptp_unpack_DI(params, di, deviceinfo, len);
414
424
        free(di);
415
425
        return ret;
416
426
}
417
427
 
418
428
uint16_t
419
 
ptp_canon_eos_getdeviceinfo (PTPParams* params, unsigned char**di, unsigned long *len )
 
429
ptp_canon_eos_getdeviceinfo (PTPParams* params, PTPCanonEOSDeviceInfo*di)
420
430
{
421
431
        uint16_t        ret;
422
432
        PTPContainer    ptp;
423
433
        PTPDataHandler  handler;
 
434
        unsigned long   len;
 
435
        unsigned char   *data;
424
436
 
425
437
        ptp_init_recv_memory_handler (&handler);
426
438
        PTP_CNT_INIT(ptp);
427
439
        ptp.Code=PTP_OC_CANON_EOS_GetDeviceInfoEx;
428
440
        ptp.Nparam=0;
429
 
        *len=0;
 
441
        len=0;
 
442
        data=NULL;
430
443
        ret=ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler);
431
 
        ptp_exit_recv_memory_handler (&handler, di, len);
 
444
        ptp_exit_recv_memory_handler (&handler, &data, &len);
 
445
        if (ret == PTP_RC_OK) ptp_unpack_EOS_DI(params, data, di, len);
 
446
        free (data);
432
447
        return ret;
433
448
}
434
449
 
435
450
/**
 
451
 * ptp_generic_no_data:
 
452
 * params:      PTPParams*
 
453
 *              code    PTP OP Code
 
454
 *              n_param count of parameters
 
455
 *              ... variable argument list ...
 
456
 *
 
457
 * Emits a generic PTP command without any data transfer.
 
458
 *
 
459
 * Return values: Some PTP_RC_* code.
 
460
 **/
 
461
uint16_t
 
462
ptp_generic_no_data (PTPParams* params, uint16_t code, unsigned int n_param, ...)
 
463
{
 
464
        PTPContainer ptp;
 
465
        va_list args;
 
466
        int i;
 
467
 
 
468
        if( n_param > 5 )
 
469
                return PTP_RC_InvalidParameter;
 
470
 
 
471
        PTP_CNT_INIT(ptp);
 
472
        ptp.Code=code;
 
473
        ptp.Nparam=n_param;
 
474
 
 
475
        va_start(args, n_param);
 
476
        for( i=0; i<n_param; ++i )
 
477
                (&ptp.Param1)[i] = va_arg(args, uint32_t);
 
478
        va_end(args);
 
479
 
 
480
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
 
481
}
 
482
 
 
483
/**
436
484
 * ptp_opensession:
437
485
 * params:      PTPParams*
438
486
 *              session                 - session number 
460
508
        /* no split headers */
461
509
        params->split_header_data = 0;
462
510
 
463
 
        
464
511
        PTP_CNT_INIT(ptp);
465
512
        ptp.Code=PTP_OC_OpenSession;
466
513
        ptp.Param1=session;
472
519
}
473
520
 
474
521
/**
475
 
 * ptp_closesession:
476
 
 * params:      PTPParams*
477
 
 *
478
 
 * Closes session.
479
 
 *
480
 
 * Return values: Some PTP_RC_* code.
481
 
 **/
482
 
uint16_t
483
 
ptp_closesession (PTPParams* params)
484
 
{
485
 
        PTPContainer ptp;
486
 
 
487
 
        ptp_debug(params,"PTP: Closing session");
488
 
 
489
 
        /* free any dangling response packet */
490
 
        if (params->response_packet_size > 0) {
491
 
                free(params->response_packet);
492
 
                params->response_packet = NULL;
493
 
                params->response_packet_size = 0;
494
 
        }
495
 
        PTP_CNT_INIT(ptp);
496
 
        ptp.Code=PTP_OC_CloseSession;
497
 
        ptp.Nparam=0;
498
 
        return ptp_transaction_new(params, &ptp, PTP_DP_NODATA, 0, NULL);
499
 
}
500
 
 
501
 
/**
502
522
 * ptp_free_params:
503
523
 * params:      PTPParams*
504
524
 *
510
530
ptp_free_params (PTPParams *params) {
511
531
        int i;
512
532
 
513
 
        for (i=0;i<params->nrofprops;i++) {
514
 
                MTPProperties   *xpl = &params->props[i];
515
 
 
516
 
                if ((xpl->datatype == PTP_DTC_STR) && (xpl->propval.str))
517
 
                        free (xpl->propval.str);
518
 
        }
519
 
        if (params->props) free (params->props);
520
 
        if (params->canon_flags) free (params->canon_flags);
521
533
        if (params->cameraname) free (params->cameraname);
522
534
        if (params->wifi_profiles) free (params->wifi_profiles);
523
 
        free (params->handles.Handler);
524
 
        for (i=0;i<params->handles.n;i++)
525
 
                ptp_free_objectinfo (&params->objectinfo[i]);
526
 
        free (params->objectinfo);
 
535
        for (i=0;i<params->nrofobjects;i++)
 
536
                ptp_free_object (&params->objects[i]);
 
537
        free (params->objects);
527
538
        ptp_free_DI (&params->deviceinfo);
528
539
}
529
540
 
530
541
/**
531
 
 * ptp_resetdevice:
532
 
 * params:      PTPParams*
533
 
 *              
534
 
 * Uses the built-in function to reset the device
535
 
 *
536
 
 * Return values: Some PTP_RC_* code.
537
 
 *
538
 
 */
539
 
uint16_t
540
 
ptp_resetdevice (PTPParams* params)
541
 
{
542
 
        PTPContainer ptp;
543
 
 
544
 
        PTP_CNT_INIT(ptp);
545
 
        ptp.Code=PTP_OC_ResetDevice;
546
 
        ptp.Nparam=0;
547
 
 
548
 
        return ptp_transaction_new(params, &ptp, PTP_DP_NODATA, 0, NULL);
549
 
}
550
 
 
551
 
/**
552
542
 * ptp_getststorageids:
553
543
 * params:      PTPParams*
554
544
 *
605
595
}
606
596
 
607
597
/**
608
 
 * ptp_formatstore:
609
 
 * params:      PTPParams*
610
 
 *              storageid               - StorageID
611
 
 *
612
 
 * Formats the storage on the device.
613
 
 *
614
 
 * Return values: Some PTP_RC_* code.
615
 
 **/
616
 
uint16_t
617
 
ptp_formatstore (PTPParams* params, uint32_t storageid)
618
 
{
619
 
        PTPContainer ptp;
620
 
 
621
 
        PTP_CNT_INIT(ptp);
622
 
        ptp.Code=PTP_OC_FormatStore;
623
 
        ptp.Param1=storageid;
624
 
        ptp.Param2=PTP_FST_Undefined;
625
 
        ptp.Nparam=2;
626
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
627
 
}
628
 
 
629
 
/**
630
598
 * ptp_getobjecthandles:
631
599
 * params:      PTPParams*
632
600
 *              storage                 - StorageID
951
919
}
952
920
 
953
921
/**
954
 
 * ptp_setobjectprotection:
955
 
 * params:      PTPParams*
956
 
 *              uint16_t newprot        - object protection flag
957
 
 *              
958
 
 * Set protection of object.
959
 
 *
960
 
 * Return values: Some PTP_RC_* code.
961
 
 *
962
 
 */
963
 
uint16_t
964
 
ptp_setobjectprotection (PTPParams* params, uint32_t oid, uint16_t newprot)
965
 
{
966
 
        PTPContainer ptp;
967
 
 
968
 
        PTP_CNT_INIT(ptp);
969
 
        ptp.Code = PTP_OC_SetObjectProtection;
970
 
        ptp.Param1 = oid;
971
 
        ptp.Param2 = newprot;
972
 
        ptp.Nparam = 2;
973
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
974
 
}
975
 
 
976
 
 
977
 
/**
978
922
 * ptp_sendobject:
979
923
 * params:      PTPParams*
980
924
 *              char*   object          - contains the object that is to be sent
1048
992
}
1049
993
 
1050
994
 
1051
 
/**
1052
 
 * ptp_initiatecapture:
1053
 
 * params:      PTPParams*
1054
 
 *              storageid               - destination StorageID on Responder
1055
 
 *              ofc                     - object format code
1056
 
 * 
1057
 
 * Causes device to initiate the capture of one or more new data objects
1058
 
 * according to its current device properties, storing the data into store
1059
 
 * indicated by storageid. If storageid is 0x00000000, the object(s) will
1060
 
 * be stored in a store that is determined by the capturing device.
1061
 
 * The capturing of new data objects is an asynchronous operation.
1062
 
 *
1063
 
 * Return values: Some PTP_RC_* code.
1064
 
 **/
1065
 
 
1066
 
uint16_t
1067
 
ptp_initiatecapture (PTPParams* params, uint32_t storageid,
1068
 
                        uint32_t ofc)
1069
 
{
1070
 
        PTPContainer ptp;
1071
 
 
1072
 
        PTP_CNT_INIT(ptp);
1073
 
        ptp.Code=PTP_OC_InitiateCapture;
1074
 
        ptp.Param1=storageid;
1075
 
        ptp.Param2=ofc;
1076
 
        ptp.Nparam=2;
1077
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1078
 
}
1079
 
 
1080
995
uint16_t
1081
996
ptp_getdevicepropdesc (PTPParams* params, uint16_t propcode, 
1082
997
                        PTPDevicePropDesc* devicepropertydesc)
1442
1357
}
1443
1358
 
1444
1359
/**
1445
 
 * ptp_canon_setobjectarchive:
1446
 
 *
1447
 
 * params:      PTPParams*
1448
 
 *              uint32_t        objectid
1449
 
 *              uint32_t        flags
1450
 
 *
1451
 
 * Return values: Some PTP_RC_* code.
1452
 
 *
1453
 
 **/
1454
 
uint16_t
1455
 
ptp_canon_setobjectarchive (PTPParams* params, uint32_t oid, uint32_t flags)
1456
 
{
1457
 
        PTPContainer ptp;
1458
 
 
1459
 
        PTP_CNT_INIT(ptp);
1460
 
        ptp.Code=PTP_OC_CANON_SetObjectArchive;
1461
 
        ptp.Nparam=2;
1462
 
        ptp.Param1=oid;
1463
 
        ptp.Param2=flags;
1464
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1465
 
}
1466
 
 
1467
 
 
1468
 
/**
1469
 
 * ptp_canon_startshootingmode:
1470
 
 * params:      PTPParams*
1471
 
 * 
1472
 
 * Starts shooting session. It emits a StorageInfoChanged
1473
 
 * event via the interrupt pipe and pushes the StorageInfoChanged
1474
 
 * and CANON_CameraModeChange events onto the event stack
1475
 
 * (see operation PTP_OC_CANON_CheckEvent).
1476
 
 *
1477
 
 * Return values: Some PTP_RC_* code.
1478
 
 *
1479
 
 **/
1480
 
uint16_t
1481
 
ptp_canon_startshootingmode (PTPParams* params)
1482
 
{
1483
 
        PTPContainer ptp;
1484
 
        
1485
 
        PTP_CNT_INIT(ptp);
1486
 
        ptp.Code=PTP_OC_CANON_InitiateReleaseControl;
1487
 
        ptp.Nparam=0;
1488
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1489
 
}
1490
 
 
1491
 
/**
1492
1360
 * ptp_canon_gettreeinfo:
1493
1361
 * params:      PTPParams*
1494
1362
 *              uint32_t *out
1584
1452
        free (out);
1585
1453
        return PTP_RC_OK;
1586
1454
}
1587
 
/**
1588
 
 * ptp_canon_endshootingmode:
1589
 
 * params:      PTPParams*
1590
 
 * 
1591
 
 * This operation is observed after pressing the Disconnect 
1592
 
 * button on the Remote Capture app. It emits a StorageInfoChanged 
1593
 
 * event via the interrupt pipe and pushes the StorageInfoChanged
1594
 
 * and CANON_CameraModeChange events onto the event stack
1595
 
 * (see operation PTP_OC_CANON_CheckEvent).
1596
 
 *
1597
 
 * Return values: Some PTP_RC_* code.
1598
 
 *
1599
 
 **/
1600
 
uint16_t
1601
 
ptp_canon_endshootingmode (PTPParams* params)
1602
 
{
1603
 
        PTPContainer ptp;
1604
 
        
1605
 
        PTP_CNT_INIT(ptp);
1606
 
        ptp.Code=PTP_OC_CANON_TerminateReleaseControl;
1607
 
        ptp.Nparam=0;
1608
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1609
 
}
1610
 
 
1611
 
/**
1612
 
 * ptp_canon_viewfinderon:
1613
 
 * params:      PTPParams*
1614
 
 * 
1615
 
 * Prior to start reading viewfinder images, one  must call this operation.
1616
 
 * Supposedly, this operation affects the value of the CANON_ViewfinderMode
1617
 
 * property.
1618
 
 *
1619
 
 * Return values: Some PTP_RC_* code.
1620
 
 *
1621
 
 **/
1622
 
uint16_t
1623
 
ptp_canon_viewfinderon (PTPParams* params)
1624
 
{
1625
 
        PTPContainer ptp;
1626
 
        
1627
 
        PTP_CNT_INIT(ptp);
1628
 
        ptp.Code=PTP_OC_CANON_ViewfinderOn;
1629
 
        ptp.Nparam=0;
1630
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1631
 
}
1632
 
 
1633
 
/**
1634
 
 * ptp_canon_viewfinderoff:
1635
 
 * params:      PTPParams*
1636
 
 * 
1637
 
 * Before changing the shooting mode, or when one doesn't need to read
1638
 
 * viewfinder images any more, one must call this operation.
1639
 
 * Supposedly, this operation affects the value of the CANON_ViewfinderMode
1640
 
 * property.
1641
 
 *
1642
 
 * Return values: Some PTP_RC_* code.
1643
 
 *
1644
 
 **/
1645
 
uint16_t
1646
 
ptp_canon_viewfinderoff (PTPParams* params)
1647
 
{
1648
 
        PTPContainer ptp;
1649
 
        
1650
 
        PTP_CNT_INIT(ptp);
1651
 
        ptp.Code=PTP_OC_CANON_ViewfinderOff;
1652
 
        ptp.Nparam=0;
1653
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1654
 
}
1655
 
 
1656
 
/**
1657
 
 * ptp_canon_reset_aeafawb:
1658
 
 * params:      PTPParams*
1659
 
 *              uint32_t flags  - what shall be reset.
1660
 
 *                      1 - autoexposure
1661
 
 *                      2 - autofocus
1662
 
 *                      4 - autowhitebalance
1663
 
 * 
1664
 
 * Called "Reset AeAfAwb" (auto exposure, focus, white balance)
1665
 
 *
1666
 
 * Return values: Some PTP_RC_* code.
1667
 
 **/
1668
 
uint16_t
1669
 
ptp_canon_reset_aeafawb (PTPParams* params, uint32_t flags)
1670
 
{
1671
 
        PTPContainer ptp;
1672
 
        
1673
 
        PTP_CNT_INIT(ptp);
1674
 
        ptp.Code=PTP_OC_CANON_DoAeAfAwb;
1675
 
        ptp.Param1=flags;
1676
 
        ptp.Nparam=1;
1677
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1678
 
}
1679
 
 
1680
1455
 
1681
1456
/**
1682
1457
 * ptp_canon_checkevent:
1698
1473
 *                                                or 0 otherwise
1699
1474
 **/
1700
1475
uint16_t
1701
 
ptp_canon_checkevent (PTPParams* params, PTPUSBEventContainer* event, int* isevent)
 
1476
ptp_canon_checkevent (PTPParams* params, PTPContainer* event, int* isevent)
1702
1477
{
1703
1478
        uint16_t ret;
1704
1479
        PTPContainer ptp;
1721
1496
        return ret;
1722
1497
}
1723
1498
 
1724
 
 
1725
 
/**
1726
 
 * ptp_canon_focuslock:
1727
 
 *
1728
 
 * This operation locks the focus. It is followed by the CANON_GetChanges(?)
1729
 
 * operation in the log. 
1730
 
 * It affects the CANON_MacroMode property. 
1731
 
 *
1732
 
 * params:      PTPParams*
1733
 
 *
1734
 
 * Return values: Some PTP_RC_* code.
1735
 
 *
1736
 
 **/
1737
 
uint16_t
1738
 
ptp_canon_focuslock (PTPParams* params)
1739
 
{
1740
 
        PTPContainer ptp;
1741
 
        
1742
 
        PTP_CNT_INIT(ptp);
1743
 
        ptp.Code=PTP_OC_CANON_FocusLock;
1744
 
        ptp.Nparam=0;
1745
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1746
 
}
1747
 
 
1748
 
/**
1749
 
 * ptp_canon_focusunlock:
1750
 
 *
1751
 
 * This operation unlocks the focus. It is followed by the CANON_GetChanges(?)
1752
 
 * operation in the log. 
1753
 
 * It sets the CANON_MacroMode property value to 1 (where it occurs in the log).
1754
 
 * 
1755
 
 * params:      PTPParams*
1756
 
 *
1757
 
 * Return values: Some PTP_RC_* code.
1758
 
 *
1759
 
 **/
1760
 
uint16_t
1761
 
ptp_canon_focusunlock (PTPParams* params)
1762
 
{
1763
 
        PTPContainer ptp;
1764
 
        
1765
 
        PTP_CNT_INIT(ptp);
1766
 
        ptp.Code=PTP_OC_CANON_FocusUnlock;
1767
 
        ptp.Nparam=0;
1768
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1769
 
}
1770
 
 
1771
 
/**
1772
 
 * ptp_canon_keepdeviceon:
1773
 
 *
1774
 
 * This operation sends a "ping" style message to the camera.
1775
 
 * 
1776
 
 * params:      PTPParams*
1777
 
 *
1778
 
 * Return values: Some PTP_RC_* code.
1779
 
 *
1780
 
 **/
1781
 
uint16_t
1782
 
ptp_canon_keepdeviceon (PTPParams* params)
1783
 
{
1784
 
        PTPContainer ptp;
1785
 
        
1786
 
        PTP_CNT_INIT(ptp);
1787
 
        ptp.Code=PTP_OC_CANON_KeepDeviceOn;
1788
 
        ptp.Nparam=0;
1789
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1790
 
}
1791
 
 
1792
 
/**
1793
 
 * ptp_canon_initiatecaptureinmemory:
1794
 
 * 
1795
 
 * This operation starts the image capture according to the current camera
1796
 
 * settings. When the capture has happened, the camera emits a CaptureComplete
1797
 
 * event via the interrupt pipe and pushes the CANON_RequestObjectTransfer,
1798
 
 * CANON_DeviceInfoChanged and CaptureComplete events onto the event stack
1799
 
 * (see operation CANON_CheckEvent). From the CANON_RequestObjectTransfer
1800
 
 * event's parameter one can learn the just captured image's ObjectHandle.
1801
 
 * The image is stored in the camera's own RAM.
1802
 
 * On the next capture the image will be overwritten!
1803
 
 *
1804
 
 * params:      PTPParams*
1805
 
 *
1806
 
 * Return values: Some PTP_RC_* code.
1807
 
 *
1808
 
 **/
1809
 
uint16_t
1810
 
ptp_canon_initiatecaptureinmemory (PTPParams* params)
1811
 
{
1812
 
        PTPContainer ptp;
1813
 
        
1814
 
        PTP_CNT_INIT(ptp);
1815
 
        ptp.Code=PTP_OC_CANON_InitiateCaptureInMemory;
1816
 
        ptp.Nparam=0;
1817
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1818
 
}
1819
 
 
1820
 
/**
1821
 
 * ptp_canon_eos_capture:
1822
 
 * 
1823
 
 * This starts a EOS400D style capture. You have to use the
1824
 
 * 0x9116 command to poll for its completion.
1825
 
 * The image is saved on the CF Card currently.
1826
 
 *
1827
 
 * params:      PTPParams*
1828
 
 *
1829
 
 * Return values: Some PTP_RC_* code.
1830
 
 *
1831
 
 **/
1832
 
uint16_t
1833
 
ptp_canon_eos_capture (PTPParams* params)
1834
 
{
1835
 
        PTPContainer ptp;
1836
 
        
1837
 
        PTP_CNT_INIT(ptp);
1838
 
        ptp.Code=PTP_OC_CANON_EOS_RemoteRelease;
1839
 
        ptp.Nparam=0;
1840
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
 
1499
uint16_t
 
1500
ptp_check_event (PTPParams *params) {
 
1501
        PTPContainer            event;
 
1502
        uint16_t                ret;
 
1503
 
 
1504
        if (    (params->deviceinfo.VendorExtensionID == PTP_VENDOR_NIKON) &&
 
1505
                ptp_operation_issupported(params, PTP_OC_NIKON_CheckEvent)
 
1506
        ) {
 
1507
                int evtcnt;
 
1508
                PTPContainer    *xevent = NULL;
 
1509
 
 
1510
                ret = ptp_nikon_check_event(params, &xevent, &evtcnt);
 
1511
                if (ret != PTP_RC_OK)
 
1512
                        return ret;
 
1513
 
 
1514
                if (evtcnt) {
 
1515
                        if (params->nrofevents)
 
1516
                                params->events = realloc(params->events, sizeof(PTPContainer)*(evtcnt+params->nrofevents));
 
1517
                        else
 
1518
                                params->events = malloc(sizeof(PTPContainer)*evtcnt);
 
1519
                        memcpy (&params->events[params->nrofevents],xevent,evtcnt*sizeof(PTPContainer));
 
1520
                        params->nrofevents += evtcnt;
 
1521
                        free (xevent);
 
1522
                }
 
1523
                return PTP_RC_OK;
 
1524
        }
 
1525
        if (    (params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) &&
 
1526
                ptp_operation_issupported(params, PTP_OC_CANON_CheckEvent)
 
1527
        ) {
 
1528
                int isevent;
 
1529
 
 
1530
                ret = ptp_canon_checkevent (params,&event,&isevent);
 
1531
                if (ret!=PTP_RC_OK)
 
1532
                        return ret;
 
1533
                if (isevent)
 
1534
                        goto store_event;
 
1535
                /* FIXME: fallthrough or return? */
 
1536
        }
 
1537
        ret = params->event_check(params,&event);
 
1538
 
 
1539
store_event:
 
1540
        if (ret == PTP_RC_OK) {
 
1541
                ptp_debug (params, "event: nparams=0x%X, code=0x%X, trans_id=0x%X, p1=0x%X, p2=0x%X, p3=0x%X", event.Nparam,event.Code,event.Transaction_ID, event.Param1, event.Param2, event.Param3);
 
1542
                if (params->nrofevents)
 
1543
                        params->events = realloc(params->events, sizeof(PTPContainer)*(params->nrofevents+1));
 
1544
                else
 
1545
                        params->events = malloc(sizeof(PTPContainer)*1);
 
1546
                memcpy (&params->events[params->nrofevents],&event,1*sizeof(PTPContainer));
 
1547
                params->nrofevents += 1;
 
1548
        }
 
1549
        if (ret == PTP_ERROR_TIMEOUT) /* ok, just new events */
 
1550
                ret = PTP_RC_OK;
 
1551
        return ret;
 
1552
}
 
1553
 
 
1554
int
 
1555
ptp_get_one_event(PTPParams *params, PTPContainer *event) {
 
1556
        if (!params->nrofevents)
 
1557
                return 0;
 
1558
        memcpy (event, params->events, sizeof(PTPContainer));
 
1559
        memmove (params->events, params->events+1, sizeof(PTPContainer)*(params->nrofevents-1));
 
1560
        /* do not realloc on shrink. */
 
1561
        params->nrofevents--;
 
1562
        return 1;
1841
1563
}
1842
1564
 
1843
1565
/**
1890
1612
                        params->canon_props[i].dpd.FORM.Enum.SupportedValue,
1891
1613
                        sizeof (PTPPropertyValue)*dpd->FORM.Enum.NumberOfValues
1892
1614
                );
1893
 
                /* FIXME: duplicate strings if type is STR. */
1894
 
        }
 
1615
        }
 
1616
        if (dpd->DataType == PTP_DTC_STR) {
 
1617
                dpd->FactoryDefaultValue.str = strdup( params->canon_props[i].dpd.FactoryDefaultValue.str );
 
1618
                dpd->CurrentValue.str = strdup( params->canon_props[i].dpd.CurrentValue.str );
 
1619
        }
 
1620
 
1895
1621
        return PTP_RC_OK;
1896
1622
}
1897
1623
 
1962
1688
        return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, &size);
1963
1689
}
1964
1690
 
1965
 
/**
1966
 
 * ptp_canon_eos_transfercomplete:
1967
 
 * 
1968
 
 * This ends a direct object transfer from an EOS camera.
1969
 
 *
1970
 
 * params:      PTPParams*
1971
 
 *              oid             Object ID
1972
 
 *
1973
 
 * Return values: Some PTP_RC_* code.
1974
 
 *
1975
 
 */
1976
 
uint16_t
1977
 
ptp_canon_eos_transfercomplete (PTPParams* params, uint32_t oid)
1978
 
{
1979
 
        PTPContainer    ptp;
1980
 
 
1981
 
        PTP_CNT_INIT(ptp);
1982
 
        ptp.Code        = PTP_OC_CANON_EOS_TransferComplete;
1983
 
        ptp.Nparam      = 1;
1984
 
        ptp.Param1      = oid;
1985
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1986
 
}
1987
 
 
1988
1691
uint16_t
1989
1692
ptp_canon_eos_setdevicepropvalueex (PTPParams* params, unsigned char* data, unsigned int size)
1990
1693
{
2014
1717
                        break;
2015
1718
        if (params->nrofcanon_props == i)
2016
1719
                return PTP_RC_Undefined;
2017
 
        if (datatype != PTP_DTC_STR) {
2018
 
                data = calloc(sizeof(uint32_t),3);
2019
 
                size = sizeof(uint32_t)*3;
2020
 
        } else {
2021
 
                 /* FIXME! */
2022
 
                return PTP_RC_Undefined;
 
1720
 
 
1721
        switch (propcode) {
 
1722
        case PTP_DPC_CANON_EOS_ImageFormat:
 
1723
        case PTP_DPC_CANON_EOS_ImageFormatCF:
 
1724
        case PTP_DPC_CANON_EOS_ImageFormatSD:
 
1725
        case PTP_DPC_CANON_EOS_ImageFormatExtHD:
 
1726
                /* special handling of ImageFormat properties */
 
1727
                size = 8 + ptp_pack_EOS_ImageFormat( params, NULL, value->u16 );
 
1728
                data = malloc( size );
 
1729
                params->canon_props[i].dpd.CurrentValue.u16 = value->u16;
 
1730
                ptp_pack_EOS_ImageFormat( params, data + 8, value->u16 );
 
1731
                break;
 
1732
        default:
 
1733
                if (datatype != PTP_DTC_STR) {
 
1734
                        data = calloc(sizeof(uint32_t),3);
 
1735
                        size = sizeof(uint32_t)*3;
 
1736
                } else {
 
1737
                        size = strlen(value->str) + 1 + 8;
 
1738
                        data = calloc(sizeof(char),size);
 
1739
                }
 
1740
                switch (datatype) {
 
1741
                case PTP_DTC_UINT8:
 
1742
                        /*fprintf (stderr, "%x -> %d\n", propcode, value->u8);*/
 
1743
                        htod8a(&data[8], value->u8);
 
1744
                        params->canon_props[i].dpd.CurrentValue.u8 = value->u8;
 
1745
                        break;
 
1746
                case PTP_DTC_UINT16:
 
1747
                        /*fprintf (stderr, "%x -> %d\n", propcode, value->u16);*/
 
1748
                        htod16a(&data[8], value->u16);
 
1749
                        params->canon_props[i].dpd.CurrentValue.u16 = value->u16;
 
1750
                        break;
 
1751
                case PTP_DTC_UINT32:
 
1752
                        /*fprintf (stderr, "%x -> %d\n", propcode, value->u32);*/
 
1753
                        htod32a(&data[8], value->u32);
 
1754
                        params->canon_props[i].dpd.CurrentValue.u32 = value->u32;
 
1755
                        break;
 
1756
                case PTP_DTC_STR:
 
1757
                        strcpy((char*)data + 8, value->str);
 
1758
                        free (params->canon_props[i].dpd.CurrentValue.str);
 
1759
                        params->canon_props[i].dpd.CurrentValue.str = strdup(value->str);
 
1760
                        break;
 
1761
                }
2023
1762
        }
 
1763
 
2024
1764
        htod32a(&data[0], size);
2025
1765
        htod32a(&data[4], propcode);
2026
 
        switch (datatype) {
2027
 
        case PTP_DTC_UINT8:
2028
 
                /*fprintf (stderr, "%x -> %d\n", propcode, value->u8);*/
2029
 
                htod8a(&data[8], value->u8);
2030
 
                params->canon_props[i].dpd.CurrentValue.u8 = value->u8;
2031
 
                break;
2032
 
        case PTP_DTC_UINT16:
2033
 
                /*fprintf (stderr, "%x -> %d\n", propcode, value->u16);*/
2034
 
                htod16a(&data[8], value->u16);
2035
 
                params->canon_props[i].dpd.CurrentValue.u16 = value->u16;
2036
 
                break;
2037
 
        case PTP_DTC_UINT32:
2038
 
                /*fprintf (stderr, "%x -> %d\n", propcode, value->u32);*/
2039
 
                htod32a(&data[8], value->u32);
2040
 
                params->canon_props[i].dpd.CurrentValue.u32 = value->u32;
2041
 
                break;
2042
 
        }
 
1766
 
2043
1767
        ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
2044
1768
        free (data);
2045
1769
        return ret;
2046
1770
}
2047
1771
 
2048
 
uint16_t
2049
 
ptp_canon_eos_pchddcapacity (PTPParams* params, uint32_t p1, uint32_t p2, uint32_t p3)
2050
 
{
2051
 
        PTPContainer    ptp;
2052
 
 
2053
 
        PTP_CNT_INIT(ptp);
2054
 
        ptp.Code        = PTP_OC_CANON_EOS_PCHDDCapacity;
2055
 
        ptp.Nparam      = 3;
2056
 
        ptp.Param1      = p1;
2057
 
        ptp.Param2      = p2;
2058
 
        ptp.Param3      = p3;
2059
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
2060
 
}
2061
 
 
2062
 
 
2063
 
uint16_t
2064
 
ptp_canon_eos_setremotemode (PTPParams* params, uint32_t p1)
2065
 
{
2066
 
        PTPContainer    ptp;
2067
 
 
2068
 
        PTP_CNT_INIT(ptp);
2069
 
        ptp.Code        = PTP_OC_CANON_EOS_SetRemoteMode;
2070
 
        ptp.Nparam      = 1;
2071
 
        ptp.Param1      = p1;
2072
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
2073
 
}
2074
 
 
2075
 
 
2076
 
uint16_t
2077
 
ptp_canon_eos_seteventmode (PTPParams* params, uint32_t p1)
2078
 
{
2079
 
        PTPContainer    ptp;
2080
 
 
2081
 
        PTP_CNT_INIT(ptp);
2082
 
        ptp.Code        = PTP_OC_CANON_EOS_SetEventMode;
2083
 
        ptp.Nparam      = 1;
2084
 
        ptp.Param1      = p1;
2085
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
2086
 
}
2087
 
 
2088
 
 
2089
 
uint16_t
2090
 
ptp_canon_9012 (PTPParams* params)
2091
 
{
2092
 
        PTPContainer ptp;
2093
 
        
2094
 
        PTP_CNT_INIT(ptp);
2095
 
        ptp.Code=0x9012;
2096
 
        ptp.Nparam=0;
2097
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
2098
 
}
2099
 
 
2100
1772
/**
2101
1773
 * ptp_canon_getpartialobject:
2102
1774
 *
2347
2019
        return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); 
2348
2020
}
2349
2021
 
 
2022
/**
 
2023
 * ptp_canon_get_vendorpropcodes:
 
2024
 *
 
2025
 * This command downloads the vendor specific property codes.
 
2026
 *  
 
2027
 * params:      PTPParams*
 
2028
 *
 
2029
 * Return values: Some PTP_RC_* code.
 
2030
 *      unsigned char **data - pointer to data pointer
 
2031
 *      unsigned int  *size - size of data returned
 
2032
 *
 
2033
 **/
 
2034
uint16_t
 
2035
ptp_nikon_get_vendorpropcodes (PTPParams* params, uint16_t **props, unsigned int *size) {
 
2036
        PTPContainer    ptp;
 
2037
        uint16_t        ret;
 
2038
        unsigned char   *xdata;
 
2039
        unsigned int    xsize;
 
2040
 
 
2041
        *props = NULL;
 
2042
        *size = 0;
 
2043
        PTP_CNT_INIT(ptp);
 
2044
        ptp.Code        = PTP_OC_NIKON_GetVendorPropCodes;
 
2045
        ptp.Nparam      = 0;
 
2046
        ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &xdata, &xsize); 
 
2047
        if (ret == PTP_RC_OK)
 
2048
                *size = ptp_unpack_uint16_t_array(params,xdata,0,props);
 
2049
        return ret;
 
2050
}
 
2051
 
2350
2052
uint16_t
2351
2053
ptp_nikon_getfileinfoinblock ( PTPParams* params,
2352
2054
        uint32_t p1, uint32_t p2, uint32_t p3,
2365
2067
}
2366
2068
 
2367
2069
/**
2368
 
 * ptp_nikon_setcontrolmode:
2369
 
 *
2370
 
 * This command can switch the camera to full PC control mode.
2371
 
 *  
2372
 
 * params:      PTPParams*
2373
 
 *      uint32_t mode - mode
2374
 
 *
2375
 
 * Return values: Some PTP_RC_* code.
2376
 
 *
2377
 
 **/
2378
 
uint16_t
2379
 
ptp_nikon_setcontrolmode (PTPParams* params, uint32_t mode)
2380
 
{
2381
 
        PTPContainer ptp;
2382
 
        
2383
 
        PTP_CNT_INIT(ptp);
2384
 
        ptp.Code=PTP_OC_NIKON_SetControlMode;
2385
 
        ptp.Param1=mode;
2386
 
        ptp.Nparam=1;
2387
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
2388
 
}
2389
 
 
2390
 
/**
2391
 
 * ptp_nikon_afdrive:
2392
 
 *
2393
 
 * This command runs (drives) the lens autofocus.
2394
 
 *  
2395
 
 * params:      PTPParams*
2396
 
 *
2397
 
 * Return values: Some PTP_RC_* code.
2398
 
 *
2399
 
 **/
2400
 
uint16_t
2401
 
ptp_nikon_afdrive (PTPParams* params)
2402
 
{
2403
 
        PTPContainer ptp;
2404
 
        
2405
 
        PTP_CNT_INIT(ptp);
2406
 
        ptp.Code=PTP_OC_NIKON_AfDrive;
2407
 
        ptp.Nparam=0;
2408
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
2409
 
}
2410
 
/**
2411
 
 * ptp_nikon_capture:
2412
 
 *
2413
 
 * This command captures a picture on the Nikon.
2414
 
 *  
2415
 
 * params:      PTPParams*
2416
 
 *      uint32_t x - unknown parameter. seen to be -1.
2417
 
 *
2418
 
 * Return values: Some PTP_RC_* code.
2419
 
 *
2420
 
 **/
2421
 
uint16_t
2422
 
ptp_nikon_capture (PTPParams* params, uint32_t x)
2423
 
{
2424
 
        PTPContainer ptp;
2425
 
        
2426
 
        PTP_CNT_INIT(ptp);
2427
 
        ptp.Code=PTP_OC_NIKON_Capture;
2428
 
        ptp.Param1=x;
2429
 
        ptp.Nparam=1;
2430
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
2431
 
}
2432
 
 
2433
 
/**
2434
 
 * ptp_nikon_capture_sdram:
2435
 
 *
2436
 
 * This command captures a picture on the Nikon.
2437
 
 *  
2438
 
 * params:      PTPParams*
2439
 
 *
2440
 
 * Return values: Some PTP_RC_* code.
2441
 
 *
2442
 
 **/
2443
 
uint16_t
2444
 
ptp_nikon_capture_sdram (PTPParams* params)
2445
 
{
2446
 
        PTPContainer ptp;
2447
 
        
2448
 
        PTP_CNT_INIT(ptp);
2449
 
        ptp.Code=PTP_OC_NIKON_AfCaptureSDRAM;
2450
 
        ptp.Nparam=0;
2451
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
 
2070
 * ptp_nikon_get_liveview_image:
 
2071
 *
 
2072
 * This command gets a LiveView image from newer Nikons DSLRs.
 
2073
 *  
 
2074
 * params:      PTPParams*
 
2075
 *
 
2076
 * Return values: Some PTP_RC_* code.
 
2077
 *
 
2078
 **/
 
2079
uint16_t
 
2080
ptp_nikon_get_liveview_image (PTPParams* params, unsigned char **data, unsigned int *size)
 
2081
{
 
2082
        PTPContainer ptp;
 
2083
        
 
2084
        PTP_CNT_INIT(ptp);
 
2085
        ptp.Code=PTP_OC_NIKON_GetLiveViewImg;
 
2086
        ptp.Nparam=0;
 
2087
        return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
 
2088
}
 
2089
 
 
2090
/**
 
2091
 * ptp_nikon_get_preview_image:
 
2092
 *
 
2093
 * This command gets a Preview image from newer Nikons DSLRs.
 
2094
 *  
 
2095
 * params:      PTPParams*
 
2096
 *
 
2097
 * Return values: Some PTP_RC_* code.
 
2098
 *
 
2099
 **/
 
2100
uint16_t
 
2101
ptp_nikon_get_preview_image (PTPParams* params, unsigned char **xdata, unsigned int *xsize,
 
2102
        uint32_t *handle)
 
2103
{
 
2104
        PTPContainer    ptp;
 
2105
        uint16_t        ret;
 
2106
        
 
2107
        PTP_CNT_INIT(ptp);
 
2108
        ptp.Code=PTP_OC_NIKON_GetPreviewImg;
 
2109
        ptp.Nparam=0;
 
2110
        ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, xdata, xsize);
 
2111
        if (ret == PTP_RC_OK) {
 
2112
                if (ptp.Nparam > 0)
 
2113
                        *handle = ptp.Param1;
 
2114
        }
 
2115
        return ret;
 
2116
}
 
2117
 
 
2118
/**
 
2119
 * ptp_canon_eos_get_viewfinder_image:
 
2120
 *
 
2121
 * This command gets a Viewfinder image from newer Nikons DSLRs.
 
2122
 *  
 
2123
 * params:      PTPParams*
 
2124
 *
 
2125
 * Return values: Some PTP_RC_* code.
 
2126
 *
 
2127
 **/
 
2128
uint16_t
 
2129
ptp_canon_eos_get_viewfinder_image (PTPParams* params, unsigned char **data, unsigned int *size)
 
2130
{
 
2131
        PTPContainer ptp;
 
2132
        
 
2133
        PTP_CNT_INIT(ptp);
 
2134
        ptp.Code=PTP_OC_CANON_EOS_GetViewFinderData;
 
2135
        ptp.Nparam=1;
 
2136
        ptp.Param1=0x00100000; /* from trace */
 
2137
        return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
2452
2138
}
2453
2139
 
2454
2140
/**
2464
2150
 *
2465
2151
 **/
2466
2152
uint16_t
2467
 
ptp_nikon_check_event (PTPParams* params, PTPUSBEventContainer** event, int* evtcnt)
 
2153
ptp_nikon_check_event (PTPParams* params, PTPContainer** event, int* evtcnt)
2468
2154
{
2469
2155
        PTPContainer ptp;
2470
2156
        uint16_t ret;
2484
2170
}
2485
2171
 
2486
2172
/**
2487
 
 * ptp_nikon_device_ready:
2488
 
 *
2489
 
 * This command checks if the device is ready. Used after
2490
 
 * a capture.
2491
 
 *  
2492
 
 * params:      PTPParams*
2493
 
 *
2494
 
 * Return values: Some PTP_RC_* code.
2495
 
 *
2496
 
 **/
2497
 
uint16_t
2498
 
ptp_nikon_device_ready (PTPParams* params)
2499
 
{
2500
 
        PTPContainer ptp;
2501
 
        
2502
 
        PTP_CNT_INIT(ptp);
2503
 
        ptp.Code=PTP_OC_NIKON_DeviceReady;
2504
 
        ptp.Nparam=0;
2505
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
2506
 
}
2507
 
 
2508
 
/**
2509
2173
 * ptp_nikon_getptpipinfo:
2510
2174
 *
2511
2175
 * This command gets the ptpip info data.
2626
2290
}
2627
2291
 
2628
2292
/**
2629
 
 * ptp_nikon_deletewifiprofile:
2630
 
 *
2631
 
 * This command deletes a wifi profile.
2632
 
 *  
2633
 
 * params:      PTPParams*
2634
 
 *      unsigned int profilenr  - profile number
2635
 
 *
2636
 
 * Return values: Some PTP_RC_* code.
2637
 
 *
2638
 
 **/
2639
 
uint16_t
2640
 
ptp_nikon_deletewifiprofile (PTPParams* params, uint32_t profilenr)
2641
 
{
2642
 
        PTPContainer ptp;
2643
 
 
2644
 
        PTP_CNT_INIT(ptp);
2645
 
        ptp.Code=PTP_OC_NIKON_DeleteProfile;
2646
 
        ptp.Nparam=1;
2647
 
        ptp.Param1=profilenr;
2648
 
        return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
2649
 
}
2650
 
 
2651
 
/**
2652
2293
 * ptp_nikon_writewifiprofile:
2653
2294
 *
2654
2295
 * This command gets the ptpip info data.
3129
2770
        free (oi->Keywords); oi->Keywords = NULL;
3130
2771
}
3131
2772
 
 
2773
void
 
2774
ptp_free_object (PTPObject *ob)
 
2775
{
 
2776
        int i;
 
2777
        if (!ob) return;
 
2778
 
 
2779
        ptp_free_objectinfo (&ob->oi);
 
2780
        for (i=0;i<ob->nrofmtpprops;i++)
 
2781
                ptp_destroy_object_prop(&ob->mtpprops[i]);
 
2782
        ob->flags = 0;
 
2783
}
 
2784
 
3132
2785
void 
3133
2786
ptp_perror(PTPParams* params, uint16_t error) {
3134
2787
 
3342
2995
                 N_("Shooting Bank Name C")},
3343
2996
                {PTP_DPC_NIKON_ShootingBankNameD,               /* 0xD014 */
3344
2997
                 N_("Shooting Bank Name D")},
 
2998
                {PTP_DPC_NIKON_ResetBank0,                      /* 0xD015 */
 
2999
                 N_("Reset Bank 0")},
3345
3000
                {PTP_DPC_NIKON_RawCompression,                  /* 0xD016 */
3346
3001
                 N_("Raw Compression")},
3347
3002
                {PTP_DPC_NIKON_WhiteBalanceAutoBias,            /* 0xD017 */
3362
3017
                 N_("White Balance Colour Temperature")},
3363
3018
                {PTP_DPC_NIKON_WhiteBalancePresetNo,            /* 0xD01f */
3364
3019
                 N_("White Balance Preset Number")},
 
3020
                {PTP_DPC_NIKON_WhiteBalancePresetName0,         /* 0xD020 */
 
3021
                 N_("White Balance Preset Name 0")},
 
3022
                {PTP_DPC_NIKON_WhiteBalancePresetName1,         /* 0xD021 */
 
3023
                 N_("White Balance Preset Name 1")},
 
3024
                {PTP_DPC_NIKON_WhiteBalancePresetName2,         /* 0xD022 */
 
3025
                 N_("White Balance Preset Name 2")},
 
3026
                {PTP_DPC_NIKON_WhiteBalancePresetName3,         /* 0xD023 */
 
3027
                 N_("White Balance Preset Name 3")},
 
3028
                {PTP_DPC_NIKON_WhiteBalancePresetName4,         /* 0xD024 */
 
3029
                 N_("White Balance Preset Name 4")},
3365
3030
                {PTP_DPC_NIKON_WhiteBalancePresetVal0,          /* 0xD025 */
3366
3031
                 N_("White Balance Preset Value 0")},
3367
3032
                {PTP_DPC_NIKON_WhiteBalancePresetVal1,          /* 0xD026 */
3383
3048
                {PTP_DPC_NIKON_NonCPULensDataFocalLength,       /* 0xD02e */
3384
3049
                 N_("Lens Focal Length (Non CPU)")},
3385
3050
                {PTP_DPC_NIKON_NonCPULensDataMaximumAperture,   /* 0xD02f */
3386
 
                 N_("Lens Max. Aperture (Non CPU)")},
 
3051
                 N_("Lens Maximum Aperture (Non CPU)")},
 
3052
                {PTP_DPC_NIKON_ShootingMode,                    /* 0xD030 */
 
3053
                 N_("Shooting Mode")},
 
3054
                {PTP_DPC_NIKON_JPEG_Compression_Policy,         /* 0xD031 */
 
3055
                 N_("JPEG Compression Policy")},
 
3056
                {PTP_DPC_NIKON_ColorSpace,                      /* 0xD032 */
 
3057
                 N_("Color Space")},
 
3058
                {PTP_DPC_NIKON_AutoDXCrop,                      /* 0xD033 */
 
3059
                 N_("Auto DX Crop")},
3387
3060
                {PTP_DPC_NIKON_CSMMenuBankSelect,               /* 0xD040 */
3388
3061
                 "PTP_DPC_NIKON_CSMMenuBankSelect"},
3389
3062
                {PTP_DPC_NIKON_MenuBankNameA,                   /* 0xD041 */
3404
3077
                 "PTP_DPC_NIKON_A3GroupDynamicAF"},
3405
3078
                {PTP_DPC_NIKON_A4AFActivation,                  /* 0xD04b */
3406
3079
                 "PTP_DPC_NIKON_A4AFActivation"},
3407
 
                {PTP_DPC_NIKON_A5FocusAreaIllumManualFocus,     /* 0xD04c */
3408
 
                 "PTP_DPC_NIKON_A5FocusAreaIllumManualFocus"},
 
3080
                {PTP_DPC_NIKON_FocusAreaIllumManualFocus,       /* 0xD04c */
 
3081
                 "PTP_DPC_NIKON_FocusAreaIllumManualFocus"},
3409
3082
                {PTP_DPC_NIKON_FocusAreaIllumContinuous,        /* 0xD04d */
3410
3083
                 "PTP_DPC_NIKON_FocusAreaIllumContinuous"},
3411
3084
                {PTP_DPC_NIKON_FocusAreaIllumWhenSelected,      /* 0xD04e */
3412
3085
                 "PTP_DPC_NIKON_FocusAreaIllumWhenSelected"},
3413
3086
                {PTP_DPC_NIKON_FocusAreaWrap,                   /* 0xD04f */
3414
3087
                 N_("Focus Area Wrap")},
3415
 
                {PTP_DPC_NIKON_A7VerticalAFON,                  /* 0xD050 */
 
3088
                {PTP_DPC_NIKON_VerticalAFON,                    /* 0xD050 */
3416
3089
                 N_("Vertical AF On")},
 
3090
                {PTP_DPC_NIKON_AFLockOn,                        /* 0xD051 */
 
3091
                 N_("AF Lock On")},
 
3092
                {PTP_DPC_NIKON_FocusAreaZone,                   /* 0xD052 */
 
3093
                 N_("Focus Area Zone")},
 
3094
                {PTP_DPC_NIKON_EnableCopyright,                 /* 0xD053 */
 
3095
                 N_("Enable Copyright")},
3417
3096
                {PTP_DPC_NIKON_ISOAuto,                         /* 0xD054 */
3418
3097
                 N_("Auto ISO")},
3419
 
                {PTP_DPC_NIKON_B2ISOStep,                       /* 0xD055 */
3420
 
                 N_("ISO Step")},
 
3098
                {PTP_DPC_NIKON_EVISOStep,                       /* 0xD055 */
 
3099
                 N_("Exposure ISO Step")},
3421
3100
                {PTP_DPC_NIKON_EVStep,                          /* 0xD056 */
3422
3101
                 N_("Exposure Step")},
3423
 
                {PTP_DPC_NIKON_B4ExposureCompEv,                /* 0xD057 */
 
3102
                {PTP_DPC_NIKON_EVStepExposureComp,              /* 0xD057 */
3424
3103
                 N_("Exposure Compensation (EV)")},
3425
3104
                {PTP_DPC_NIKON_ExposureCompensation,            /* 0xD058 */
3426
3105
                 N_("Exposure Compensation")},
3427
3106
                {PTP_DPC_NIKON_CenterWeightArea,                /* 0xD059 */
3428
3107
                 N_("Centre Weight Area")},
3429
 
                {PTP_DPC_NIKON_AELockMode,                      /* 0xD05e */
 
3108
                {PTP_DPC_NIKON_ExposureBaseMatrix,              /* 0xD05A */
 
3109
                 N_("Exposure Base Matrix")},
 
3110
                {PTP_DPC_NIKON_ExposureBaseCenter,              /* 0xD05B */
 
3111
                 N_("Exposure Base Center")},
 
3112
                {PTP_DPC_NIKON_ExposureBaseSpot,                /* 0xD05C */
 
3113
                 N_("Exposure Base Spot")},
 
3114
                {PTP_DPC_NIKON_LiveViewAF,                      /* 0xD05D */
 
3115
                 N_("Live View AF")},
 
3116
                {PTP_DPC_NIKON_AELockMode,                      /* 0xD05E */
3430
3117
                 N_("Exposure Lock")},
3431
 
                {PTP_DPC_NIKON_AELAFLMode,                      /* 0xD05f */
 
3118
                {PTP_DPC_NIKON_AELAFLMode,                      /* 0xD05F */
3432
3119
                 N_("Focus Lock")},
3433
3120
                {PTP_DPC_NIKON_MeterOff,                        /* 0xD062 */
3434
3121
                 N_("Auto Meter Off Time")},
3436
3123
                 N_("Self Timer Delay")},
3437
3124
                {PTP_DPC_NIKON_MonitorOff,                      /* 0xD064 */
3438
3125
                 N_("LCD Off Time")},
 
3126
                {PTP_DPC_NIKON_ImgConfTime,                     /* 0xD065 */
 
3127
                 N_("Img Conf Time")},
 
3128
                {PTP_DPC_NIKON_AngleLevel,                      /* 0xD067 */
 
3129
                 N_("Angle Level")},
3439
3130
                {PTP_DPC_NIKON_D1ShootingSpeed,                 /* 0xD068 */
3440
3131
                 N_("Shooting Speed")},
3441
3132
                {PTP_DPC_NIKON_D2MaximumShots,                  /* 0xD069 */
3442
3133
                 N_("Maximum Shots")},
3443
 
                {PTP_DPC_NIKON_D3ExpDelayMode,                  /* 0xD06a */
3444
 
                 "PTP_DPC_NIKON_D3ExpDelayMode"},
3445
 
                {PTP_DPC_NIKON_LongExposureNoiseReduction,      /* 0xD06b */
 
3134
                {PTP_DPC_NIKON_D3ExpDelayMode,                  /* 0xD06A */
 
3135
                 N_("Exposure delay mode")},
 
3136
                {PTP_DPC_NIKON_LongExposureNoiseReduction,      /* 0xD06B */
3446
3137
                 N_("Long Exposure Noise Reduction")},
3447
 
                {PTP_DPC_NIKON_FileNumberSequence,              /* 0xD06c */
 
3138
                {PTP_DPC_NIKON_FileNumberSequence,              /* 0xD06C */
3448
3139
                 N_("File Number Sequencing")},
3449
 
                {PTP_DPC_NIKON_D6ControlPanelFinderRearControl, /* 0xD06d */
3450
 
                 "PTP_DPC_NIKON_D6ControlPanelFinderRearControl"},
3451
 
                {PTP_DPC_NIKON_ControlPanelFinderViewfinder,    /* 0xD06e */
 
3140
                {PTP_DPC_NIKON_ControlPanelFinderRearControl,   /* 0xD06D */
 
3141
                 "PTP_DPC_NIKON_ControlPanelFinderRearControl"},
 
3142
                {PTP_DPC_NIKON_ControlPanelFinderViewfinder,    /* 0xD06E */
3452
3143
                 "PTP_DPC_NIKON_ControlPanelFinderViewfinder"},
3453
 
                {PTP_DPC_NIKON_D7Illumination,                  /* 0xD06f */
3454
 
                 "PTP_DPC_NIKON_D7Illumination"},
3455
 
                {PTP_DPC_NIKON_E1FlashSyncSpeed,                /* 0xD074 */
 
3144
                {PTP_DPC_NIKON_D7Illumination,                  /* 0xD06F */
 
3145
                 N_("LCD Illumination")},
 
3146
                {PTP_DPC_NIKON_NrHighISO,                       /* 0xD070 */
 
3147
                 N_("High ISO noise reduction")},
 
3148
                {PTP_DPC_NIKON_SHSET_CH_GUID_DISP,              /* 0xD071 */
 
3149
                 N_("On screen tips")},
 
3150
                {PTP_DPC_NIKON_ArtistName,                      /* 0xD072 */
 
3151
                 N_("Artist Name")},
 
3152
                {PTP_DPC_NIKON_CopyrightInfo,                   /* 0xD073 */
 
3153
                 N_("Copyright Information")},
 
3154
                {PTP_DPC_NIKON_FlashSyncSpeed,                  /* 0xD074 */
3456
3155
                 N_("Flash Sync. Speed")},
3457
3156
                {PTP_DPC_NIKON_FlashShutterSpeed,               /* 0xD075 */
3458
3157
                 N_("Flash Shutter Speed")},
3464
3163
                 N_("Bracket Set")},
3465
3164
                {PTP_DPC_NIKON_E6ManualModeBracketing,          /* 0xD079 */
3466
3165
                 N_("Manual Mode Bracketing")},
3467
 
                {PTP_DPC_NIKON_BracketOrder,                    /* 0xD07a */
 
3166
                {PTP_DPC_NIKON_BracketOrder,                    /* 0xD07A */
3468
3167
                 N_("Bracket Order")},
3469
 
                {PTP_DPC_NIKON_E8AutoBracketSelection,          /* 0xD07b */
 
3168
                {PTP_DPC_NIKON_E8AutoBracketSelection,          /* 0xD07B */
3470
3169
                 N_("Auto Bracket Selection")},
3471
3170
                {PTP_DPC_NIKON_BracketingSet, N_("NIKON Auto Bracketing Set")}, /* 0xD07C */
3472
3171
                {PTP_DPC_NIKON_F1CenterButtonShootingMode,      /* 0xD080 */
3489
3188
                 N_("Menus and Playback")},
3490
3189
                {PTP_DPC_NIKON_F6ButtonsAndDials,               /* 0xD089 */
3491
3190
                 N_("Buttons and Dials")},
3492
 
                {PTP_DPC_NIKON_NoCFCard,                        /* 0xD08a */
 
3191
                {PTP_DPC_NIKON_NoCFCard,                        /* 0xD08A */
3493
3192
                 N_("No CF Card Release")},
 
3193
                {PTP_DPC_NIKON_CenterButtonZoomRatio,           /* 0xD08B */
 
3194
                 N_("Center Button Zoom Ratio")},
 
3195
                {PTP_DPC_NIKON_FunctionButton2,                 /* 0xD08C */
 
3196
                 N_("Function Button 2")},
 
3197
                {PTP_DPC_NIKON_AFAreaPoint,                     /* 0xD08D */
 
3198
                 N_("AF Area Point")},
 
3199
                {PTP_DPC_NIKON_NormalAFOn,                      /* 0xD08E */
 
3200
                 N_("Normal AF On")},
3494
3201
                {PTP_DPC_NIKON_ImageCommentString,              /* 0xD090 */
3495
3202
                 N_("Image Comment String")},
3496
3203
                {PTP_DPC_NIKON_ImageCommentEnable,              /* 0xD091 */
3497
3204
                 N_("Image Comment Enable")},
3498
3205
                {PTP_DPC_NIKON_ImageRotation,                   /* 0xD092 */
3499
3206
                 N_("Image Rotation")},
3500
 
                {PTP_DPC_NIKON_Bracketing,                      /* 0xD0c0 */
 
3207
                {PTP_DPC_NIKON_ManualSetLensNo,                 /* 0xD093 */
 
3208
                 N_("Manual Set Lens Number")},
 
3209
                {PTP_DPC_NIKON_MovScreenSize,                   /* 0xD0A0 */
 
3210
                 N_("Movie Screen Size")},
 
3211
                {PTP_DPC_NIKON_MovVoice,                        /* 0xD0A1 */
 
3212
                 N_("Movie Voice")},
 
3213
                {PTP_DPC_NIKON_Bracketing,                      /* 0xD0C0 */
3501
3214
                 N_("Bracketing Enable")},
3502
 
                {PTP_DPC_NIKON_AutoExposureBracketStep,         /* 0xD0c1 */
 
3215
                {PTP_DPC_NIKON_AutoExposureBracketStep,         /* 0xD0C1 */
3503
3216
                 N_("Exposure Bracketing Step")},
3504
 
                {PTP_DPC_NIKON_AutoExposureBracketProgram,      /* 0xD0c2 */
 
3217
                {PTP_DPC_NIKON_AutoExposureBracketProgram,      /* 0xD0C2 */
3505
3218
                 N_("Exposure Bracketing Program")},
3506
 
                {PTP_DPC_NIKON_AutoExposureBracketCount,        /* 0xD0c3 */
 
3219
                {PTP_DPC_NIKON_AutoExposureBracketCount,        /* 0xD0C3 */
3507
3220
                 N_("Auto Exposure Bracket Count")},
3508
3221
                {PTP_DPC_NIKON_WhiteBalanceBracketStep, N_("White Balance Bracket Step")}, /* 0xD0C4 */
3509
3222
                {PTP_DPC_NIKON_WhiteBalanceBracketProgram, N_("White Balance Bracket Program")}, /* 0xD0C5 */
3521
3234
                 N_("Max. Aperture at Min. Focal Length")},
3522
3235
                {PTP_DPC_NIKON_MaxApAtMaxFocalLength,           /* 0xD0E6 */
3523
3236
                 N_("Max. Aperture at Max. Focal Length")},
 
3237
                {PTP_DPC_NIKON_FinderISODisp,                   /* 0xD0F0 */
 
3238
                 N_("Finder ISO Display")},
 
3239
                {PTP_DPC_NIKON_AutoOffPhoto,                    /* 0xD0F2 */
 
3240
                 N_("Auto Off Photo")},
 
3241
                {PTP_DPC_NIKON_AutoOffMenu,                     /* 0xD0F3 */
 
3242
                 N_("Auto Off Menu")},
 
3243
                {PTP_DPC_NIKON_AutoOffInfo,                     /* 0xD0F4 */
 
3244
                 N_("Auto Off Info")},
 
3245
                {PTP_DPC_NIKON_SelfTimerShootNum,               /* 0xD0F5 */
 
3246
                 N_("Self Timer Shot Number")},
 
3247
                {PTP_DPC_NIKON_VignetteCtrl,                    /* 0xD0F7 */
 
3248
                 N_("Vignette Control")},
3524
3249
                {PTP_DPC_NIKON_ExposureTime,                    /* 0xD100 */
3525
3250
                 N_("Nikon Exposure Time")},
3526
3251
                {PTP_DPC_NIKON_ACPower, N_("AC Power")},        /* 0xD101 */
3536
3261
                 N_("Active AF Sensor")},
3537
3262
                {PTP_DPC_NIKON_FlexibleProgram,                 /* 0xD109 */
3538
3263
                 N_("Flexible Program")},
3539
 
                {PTP_DPC_NIKON_LightMeter,                      /* 0xD10a */
 
3264
                {PTP_DPC_NIKON_LightMeter,                      /* 0xD10A */
3540
3265
                 N_("Exposure Meter")},
3541
 
                {PTP_DPC_NIKON_CameraOrientation,               /* 0xD10e */
 
3266
                {PTP_DPC_NIKON_RecordingMedia,                  /* 0xD10B */
 
3267
                 N_("Recording Media")},
 
3268
                {PTP_DPC_NIKON_USBSpeed,                        /* 0xD10C */
 
3269
                 N_("USB Speed")},
 
3270
                {PTP_DPC_NIKON_CCDNumber,                       /* 0xD10D */
 
3271
                 N_("CCD Serial Number")},
 
3272
                {PTP_DPC_NIKON_CameraOrientation,               /* 0xD10E */
3542
3273
                 N_("Camera Orientation")},
 
3274
                {PTP_DPC_NIKON_GroupPtnType,                    /* 0xD10F */
 
3275
                 N_("Group PTN Type")},
 
3276
                {PTP_DPC_NIKON_FNumberLock,                     /* 0xD110 */
 
3277
                 N_("FNumber Lock")},
3543
3278
                {PTP_DPC_NIKON_ExposureApertureLock,            /* 0xD111 */
3544
3279
                 N_("Exposure Aperture Lock")},
 
3280
                {PTP_DPC_NIKON_TVLockSetting,                   /* 0xD112 */
 
3281
                 N_("TV Lock Setting")},
 
3282
                {PTP_DPC_NIKON_AVLockSetting,                   /* 0xD113 */
 
3283
                 N_("AV Lock Setting")},
 
3284
                {PTP_DPC_NIKON_IllumSetting,                    /* 0xD114 */
 
3285
                 N_("Illum Setting")},
 
3286
                {PTP_DPC_NIKON_FocusPointBright,                /* 0xD115 */
 
3287
                 N_("Focus Point Bright")},
3545
3288
                {PTP_DPC_NIKON_ExternalFlashAttached,           /* 0xD120 */
3546
3289
                 N_("External Flash Attached")},
3547
3290
                {PTP_DPC_NIKON_ExternalFlashStatus,             /* 0xD121 */
3548
3291
                 N_("External Flash Status")},
3549
3292
                {PTP_DPC_NIKON_ExternalFlashSort,               /* 0xD122 */
3550
3293
                 N_("External Flash Sort")},
 
3294
                {PTP_DPC_NIKON_ExternalFlashMode,               /* 0xD123 */
 
3295
                 N_("External Flash Mode")},
3551
3296
                {PTP_DPC_NIKON_ExternalFlashCompensation,       /* 0xD124 */
3552
3297
                 N_("External Flash Compensation")},
3553
3298
                {PTP_DPC_NIKON_NewExternalFlashMode,            /* 0xD125 */
3558
3303
                 N_("Optimize Image")},
3559
3304
                {PTP_DPC_NIKON_Saturation,                      /* 0xD142 */
3560
3305
                 N_("Saturation")},
 
3306
                {PTP_DPC_NIKON_BW_FillerEffect,                 /* 0xD143 */
 
3307
                 N_("BW Filler Effect")},
 
3308
                {PTP_DPC_NIKON_BW_Sharpness,                    /* 0xD144 */
 
3309
                 N_("BW Sharpness")},
 
3310
                {PTP_DPC_NIKON_BW_Contrast,                     /* 0xD145 */
 
3311
                 N_("BW Contrast")},
 
3312
                {PTP_DPC_NIKON_BW_Setting_Type,                 /* 0xD146 */
 
3313
                 N_("BW Setting Type")},
 
3314
                {PTP_DPC_NIKON_Slot2SaveMode,                   /* 0xD148 */
 
3315
                 N_("Slot 2 Save Mode")},
 
3316
                {PTP_DPC_NIKON_RawBitMode,                      /* 0xD149 */
 
3317
                 N_("Raw Bit Mode")},
 
3318
                {PTP_DPC_NIKON_ISOAutoTime,                     /* 0xD14E */
 
3319
                 N_("ISO Auto Time")},
 
3320
                {PTP_DPC_NIKON_FlourescentType,                 /* 0xD14F */
 
3321
                 N_("Flourescent Type")},
 
3322
                {PTP_DPC_NIKON_TuneColourTemperature,           /* 0xD150 */
 
3323
                 N_("Tune Colour Temperature")},
 
3324
                {PTP_DPC_NIKON_TunePreset0,                     /* 0xD151 */
 
3325
                 N_("Tune Preset 0")},
 
3326
                {PTP_DPC_NIKON_TunePreset1,                     /* 0xD152 */
 
3327
                 N_("Tune Preset 1")},
 
3328
                {PTP_DPC_NIKON_TunePreset2,                     /* 0xD153 */
 
3329
                 N_("Tune Preset 2")},
 
3330
                {PTP_DPC_NIKON_TunePreset3,                     /* 0xD154 */
 
3331
                 N_("Tune Preset 3")},
 
3332
                {PTP_DPC_NIKON_TunePreset4,                     /* 0xD155 */
 
3333
                 N_("Tune Preset 4")},
3561
3334
                {PTP_DPC_NIKON_BeepOff,                         /* 0xD160 */
3562
3335
                 N_("AF Beep Mode")},
3563
3336
                {PTP_DPC_NIKON_AutofocusMode,                   /* 0xD161 */
3576
3349
                 N_("Flash Commander Mode")},
3577
3350
                {PTP_DPC_NIKON_FlashSign,                       /* 0xD169 */
3578
3351
                 N_("Flash Sign")},
 
3352
                {PTP_DPC_NIKON_ISOAuto,                         /* 0xD16A */
 
3353
                 N_("ISO Auto")},
3579
3354
                {PTP_DPC_NIKON_RemoteTimeout,                   /* 0xD16B */
3580
3355
                 N_("Remote Timeout")},
3581
3356
                {PTP_DPC_NIKON_GridDisplay,                     /* 0xD16C */
3584
3359
                 N_("Flash Mode Manual Power")},
3585
3360
                {PTP_DPC_NIKON_FlashModeCommanderPower,         /* 0xD16E */
3586
3361
                 N_("Flash Mode Commander Power")},
 
3362
                {PTP_DPC_NIKON_AutoFP,                          /* 0xD16F */
 
3363
                 N_("Auto FP")},
3587
3364
                {PTP_DPC_NIKON_CSMMenu,                         /* 0xD180 */
3588
3365
                 N_("CSM Menu")},
 
3366
                {PTP_DPC_NIKON_WarningDisplay,                  /* 0xD181 */
 
3367
                 N_("Warning Display")},
 
3368
                {PTP_DPC_NIKON_BatteryCellKind,                 /* 0xD182 */
 
3369
                 N_("Battery Cell Kind")},
 
3370
                {PTP_DPC_NIKON_ISOAutoHiLimit,                  /* 0xD183 */
 
3371
                 N_("ISO Auto High Limit")},
 
3372
                {PTP_DPC_NIKON_DynamicAFArea,                   /* 0xD184 */
 
3373
                 N_("Dynamic AF Area")},
 
3374
                {PTP_DPC_NIKON_ContinuousSpeedHigh,             /* 0xD186 */
 
3375
                 N_("Continuous Speed High")},
 
3376
                {PTP_DPC_NIKON_InfoDispSetting,                 /* 0xD187 */
 
3377
                 N_("Info Disp Setting")},
 
3378
                {PTP_DPC_NIKON_PreviewButton,                   /* 0xD189 */
 
3379
                 N_("Preview Button")},
 
3380
                {PTP_DPC_NIKON_PreviewButton2,                  /* 0xD18A */
 
3381
                 N_("Preview Button 2")},
 
3382
                {PTP_DPC_NIKON_AEAFLockButton2,                 /* 0xD18B */
 
3383
                 N_("AEAF Lock Button 2")},
 
3384
                {PTP_DPC_NIKON_IndicatorDisp,                   /* 0xD18D */
 
3385
                 N_("Indicator Display")},
 
3386
                {PTP_DPC_NIKON_CellKindPriority,                /* 0xD18E */
 
3387
                 N_("Cell Kind Priority")},
3589
3388
                {PTP_DPC_NIKON_BracketingFramesAndSteps,        /* 0xD190 */
3590
3389
                 N_("Bracketing Frames and Steps")},
3591
 
                {PTP_DPC_NIKON_LowLight,                        /* 0xD1B0 */
3592
 
                 N_("Low Light")},
 
3390
                {PTP_DPC_NIKON_LiveViewMode,                    /* 0xD1A0 */
 
3391
                 N_("Live View Mode")},
 
3392
                {PTP_DPC_NIKON_LiveViewDriveMode,               /* 0xD1A1 */
 
3393
                 N_("Live View Drive Mode")},
 
3394
                {PTP_DPC_NIKON_LiveViewStatus,                  /* 0xD1A2 */
 
3395
                 N_("Live View Status")},
 
3396
                {PTP_DPC_NIKON_LiveViewImageZoomRatio,          /* 0xD1A3 */
 
3397
                 N_("Live View Image Zoom Ratio")},
 
3398
                {PTP_DPC_NIKON_LiveViewProhibitCondition,       /* 0xD1A4 */
 
3399
                 N_("Live View Prohibit Condition")},
 
3400
                {PTP_DPC_NIKON_ExposureDisplayStatus,           /* 0xD1B0 */
 
3401
                 N_("Exposure Display Status")},
 
3402
                {PTP_DPC_NIKON_ExposureIndicateStatus,          /* 0xD1B1 */
 
3403
                 N_("Exposure Indicate Status")},
 
3404
                {PTP_DPC_NIKON_ExposureIndicateLightup,         /* 0xD1B2 */
 
3405
                 N_("Exposure Indicate Lightup")},
3593
3406
                {PTP_DPC_NIKON_FlashOpen,                       /* 0xD1C0 */
3594
3407
                 N_("Flash Open")},
3595
3408
                {PTP_DPC_NIKON_FlashCharged,                    /* 0xD1C1 */
3596
3409
                 N_("Flash Charged")},
 
3410
                {PTP_DPC_NIKON_FlashMRepeatValue,               /* 0xD1D0 */
 
3411
                 N_("Flash MRepeat Value")},
 
3412
                {PTP_DPC_NIKON_FlashMRepeatCount,               /* 0xD1D1 */
 
3413
                 N_("Flash MRepeat Count")},
 
3414
                {PTP_DPC_NIKON_FlashMRepeatInterval,            /* 0xD1D2 */
 
3415
                 N_("Flash MRepeat Interval")},
 
3416
                {PTP_DPC_NIKON_FlashCommandChannel,             /* 0xD1D3 */
 
3417
                 N_("Flash Command Channel")},
 
3418
                {PTP_DPC_NIKON_FlashCommandSelfMode,            /* 0xD1D4 */
 
3419
                 N_("Flash Command Self Mode")},
 
3420
                {PTP_DPC_NIKON_FlashCommandSelfCompensation,    /* 0xD1D5 */
 
3421
                 N_("Flash Command Self Compensation")},
 
3422
                {PTP_DPC_NIKON_FlashCommandSelfValue,           /* 0xD1D6 */
 
3423
                 N_("Flash Command Self Value")},
 
3424
                {PTP_DPC_NIKON_FlashCommandAMode,               /* 0xD1D7 */
 
3425
                 N_("Flash Command A Mode")},
 
3426
                {PTP_DPC_NIKON_FlashCommandACompensation,       /* 0xD1D8 */
 
3427
                 N_("Flash Command A Compensation")},
 
3428
                {PTP_DPC_NIKON_FlashCommandAValue,              /* 0xD1D9 */
 
3429
                 N_("Flash Command A Value")},
 
3430
                {PTP_DPC_NIKON_FlashCommandBMode,               /* 0xD1DA */
 
3431
                 N_("Flash Command B Mode")},
 
3432
                {PTP_DPC_NIKON_FlashCommandBCompensation,       /* 0xD1DB */
 
3433
                 N_("Flash Command B Compensation")},
 
3434
                {PTP_DPC_NIKON_FlashCommandBValue,              /* 0xD1DC */
 
3435
                 N_("Flash Command B Value")},
 
3436
                {PTP_DPC_NIKON_ActivePicCtrlItem,               /* 0xD200 */
 
3437
                 N_("Active Pic Ctrl Item")},
 
3438
                {PTP_DPC_NIKON_ChangePicCtrlItem,               /* 0xD201 */
 
3439
                 N_("Change Pic Ctrl Item")},
3597
3440
                {0,NULL}
3598
3441
        };
3599
3442
        struct {
3600
3443
                uint16_t dpc;
3601
3444
                const char *txt;
3602
3445
        } ptp_device_properties_MTP[] = {
3603
 
                {PTP_DPC_MTP_SecureTime,        N_("Secure Time")},
3604
 
                {PTP_DPC_MTP_DeviceCertificate, N_("Device Certificate")},
3605
 
                {PTP_DPC_MTP_SynchronizationPartner,
 
3446
                {PTP_DPC_MTP_SecureTime,        N_("Secure Time")},             /* D101 */
 
3447
                {PTP_DPC_MTP_DeviceCertificate, N_("Device Certificate")},      /* D102 */
 
3448
                {PTP_DPC_MTP_RevocationInfo,    N_("Revocation Info")},         /* D103 */
 
3449
                {PTP_DPC_MTP_SynchronizationPartner,                            /* D401 */
3606
3450
                 N_("Synchronization Partner")},
3607
 
                {PTP_DPC_MTP_DeviceFriendlyName,
 
3451
                {PTP_DPC_MTP_DeviceFriendlyName,                                /* D402 */
3608
3452
                 N_("Friendly Device Name")},
3609
 
                {PTP_DPC_MTP_VolumeLevel,       N_("Volume Level")},
3610
 
                {PTP_DPC_MTP_DeviceIcon,        N_("Device Icon")},
3611
 
                {PTP_DPC_MTP_PlaybackRate,      N_("Playback Rate")},
3612
 
                {PTP_DPC_MTP_PlaybackObject,    N_("Playback Object")},
3613
 
                {PTP_DPC_MTP_PlaybackContainerIndex,
 
3453
                {PTP_DPC_MTP_VolumeLevel,       N_("Volume Level")},            /* D403 */
 
3454
                {PTP_DPC_MTP_DeviceIcon,        N_("Device Icon")},             /* D405 */
 
3455
                {PTP_DPC_MTP_SessionInitiatorInfo,      N_("Session Initiator Info")},/* D406 */
 
3456
                {PTP_DPC_MTP_PerceivedDeviceType,       N_("Perceived Device Type")},/* D407 */
 
3457
                {PTP_DPC_MTP_PlaybackRate,      N_("Playback Rate")},           /* D410 */
 
3458
                {PTP_DPC_MTP_PlaybackObject,    N_("Playback Object")},         /* D411 */
 
3459
                {PTP_DPC_MTP_PlaybackContainerIndex,                            /* D412 */
3614
3460
                 N_("Playback Container Index")},
3615
 
                {PTP_DPC_MTP_PlaybackPosition,  N_("Playback Position")},
3616
 
                {PTP_DPC_MTP_RevocationInfo,    N_("Revocation Info")},
3617
 
                {PTP_DPC_MTP_PlaysForSureID,    N_("PlaysForSure ID")},
 
3461
                {PTP_DPC_MTP_PlaybackPosition,  N_("Playback Position")},       /* D413 */
 
3462
                {PTP_DPC_MTP_PlaysForSureID,    N_("PlaysForSure ID")},         /* D131 (?) */
3618
3463
                {0,NULL}
3619
3464
        };
3620
3465
 
3622
3467
                if (ptp_device_properties[i].dpc==dpc)
3623
3468
                        return (ptp_device_properties[i].txt);
3624
3469
 
3625
 
        if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_MICROSOFT)
 
3470
        if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_MICROSOFT
 
3471
            || params->deviceinfo.VendorExtensionID==PTP_VENDOR_MTP)
3626
3472
                for (i=0; ptp_device_properties_MTP[i].txt!=NULL; i++)
3627
3473
                        if (ptp_device_properties_MTP[i].dpc==dpc)
3628
3474
                                return (ptp_device_properties_MTP[i].txt);
3703
3549
                double bias;
3704
3550
                const char *format;
3705
3551
        } ptp_value_trans[] = {
3706
 
                {PTP_DPC_ExposureIndex, 0, 1.0, 0.0, "ISO %.0f"},
3707
 
                {PTP_DPC_BatteryLevel, 0, 1.0, 0.0, "%.0f%%"},
3708
 
                {PTP_DPC_FNumber, 0, 0.01, 0.0, "f/%.2g"},
3709
 
                {PTP_DPC_FocalLength, 0, 0.01, 0.0, "%.0f mm"},
3710
 
                {PTP_DPC_ExposureTime, 0, 0.00001, 0.0, "%.2g sec"},
3711
 
                {PTP_DPC_ExposureBiasCompensation, 0, 0.001, 0.0, N_("%.1f stops")},
 
3552
                {PTP_DPC_BatteryLevel, 0, 1.0, 0.0, "%.0f%%"},          /* 5001 */
 
3553
                {PTP_DPC_FNumber, 0, 0.01, 0.0, "f/%.2g"},              /* 5007 */
 
3554
                {PTP_DPC_FocalLength, 0, 0.01, 0.0, "%.0f mm"},         /* 5008 */
 
3555
                {PTP_DPC_FocusDistance, 0, 0.01, 0.0, "%.0f mm"},       /* 5009 */
 
3556
                {PTP_DPC_ExposureTime, 0, 0.00001, 0.0, "%.2g sec"},    /* 500D */
 
3557
                {PTP_DPC_ExposureIndex, 0, 1.0, 0.0, "ISO %.0f"},       /* 500F */
 
3558
                {PTP_DPC_ExposureBiasCompensation, 0, 0.001, 0.0, N_("%.1f stops")},/* 5010 */
 
3559
                {PTP_DPC_DigitalZoom, 0, 0.1, 0.0, "%.1f"},             /* 5016 */
3712
3560
 
3713
 
                {PTP_DPC_NIKON_LightMeter, PTP_VENDOR_NIKON, 0.08333, 0.0, N_("%.1f stops")},
3714
 
                {PTP_DPC_NIKON_FlashExposureCompensation, PTP_VENDOR_NIKON, 0.16666, 0.0, N_("%.1f stops")},
3715
 
                {PTP_DPC_NIKON_CenterWeightArea, PTP_VENDOR_NIKON, 2.0, 6.0, N_("%.0f mm")},
3716
 
                {PTP_DPC_NIKON_FocalLengthMin, PTP_VENDOR_NIKON, 0.01, 0.0, "%.0f mm"},
3717
 
                {PTP_DPC_NIKON_FocalLengthMax, PTP_VENDOR_NIKON, 0.01, 0.0, "%.0f mm"},
3718
 
                {PTP_DPC_NIKON_MaxApAtMinFocalLength, PTP_VENDOR_NIKON, 0.01, 0.0, "f/%.2g"},
3719
 
                {PTP_DPC_NIKON_MaxApAtMaxFocalLength, PTP_VENDOR_NIKON, 0.01, 0.0, "f/%.2g"},
3720
 
                {PTP_DPC_NIKON_ExternalFlashCompensation, PTP_VENDOR_NIKON, 1.0/6.0, 0.0,"%.0f"},
 
3561
                /* Nikon device properties */
 
3562
                {PTP_DPC_NIKON_LightMeter, PTP_VENDOR_NIKON, 0.08333, 0.0, N_("%.1f stops")},/* D10A */
 
3563
                {PTP_DPC_NIKON_FlashExposureCompensation, PTP_VENDOR_NIKON, 0.16666, 0.0, N_("%.1f stops")}, /* D126 */
 
3564
                {PTP_DPC_NIKON_CenterWeightArea, PTP_VENDOR_NIKON, 2.0, 6.0, N_("%.0f mm")},/* D059 */
 
3565
                {PTP_DPC_NIKON_FocalLengthMin, PTP_VENDOR_NIKON, 0.01, 0.0, "%.0f mm"}, /* D0E3 */
 
3566
                {PTP_DPC_NIKON_FocalLengthMax, PTP_VENDOR_NIKON, 0.01, 0.0, "%.0f mm"}, /* D0E4 */
 
3567
                {PTP_DPC_NIKON_MaxApAtMinFocalLength, PTP_VENDOR_NIKON, 0.01, 0.0, "f/%.2g"}, /* D0E5 */
 
3568
                {PTP_DPC_NIKON_MaxApAtMaxFocalLength, PTP_VENDOR_NIKON, 0.01, 0.0, "f/%.2g"}, /* D0E6 */
 
3569
                {PTP_DPC_NIKON_ExternalFlashCompensation, PTP_VENDOR_NIKON, 1.0/6.0, 0.0,"%.0f"}, /* D124 */
 
3570
                {PTP_DPC_NIKON_ExposureIndicateStatus, PTP_VENDOR_NIKON, 0.08333, 0.0, N_("%.1f stops")},/* D1B1 - FIXME: check if correct. */
3721
3571
                {0, 0, 0.0, 0.0, NULL}
3722
3572
        };
3723
3573
 
3727
3577
                int64_t key;
3728
3578
                char *value;
3729
3579
        } ptp_value_list[] = {
3730
 
                {PTP_DPC_CompressionSetting, 0, 0, N_("JPEG Basic")},
 
3580
                {PTP_DPC_CompressionSetting, 0, 0, N_("JPEG Basic")},   /* 5004 */
3731
3581
                {PTP_DPC_CompressionSetting, 0, 1, N_("JPEG Norm")},
3732
3582
                {PTP_DPC_CompressionSetting, 0, 2, N_("JPEG Fine")},
3733
3583
                {PTP_DPC_CompressionSetting, 0, 4, N_("RAW")},
3734
3584
                {PTP_DPC_CompressionSetting, 0, 5, N_("RAW + JPEG Basic")},
3735
3585
                {PTP_DPC_WhiteBalance, 0, 1, N_("Manual")},
3736
 
                {PTP_DPC_WhiteBalance, 0, 2, N_("Automatic")},
 
3586
                {PTP_DPC_WhiteBalance, 0, 2, N_("Automatic")},          /* 5005 */
3737
3587
                {PTP_DPC_WhiteBalance, 0, 3, N_("One-push Automatic")},
3738
3588
                {PTP_DPC_WhiteBalance, 0, 4, N_("Daylight")},
3739
3589
                {PTP_DPC_WhiteBalance, 0, 5, N_("Fluorescent")},
3743
3593
                {PTP_DPC_WhiteBalance, PTP_VENDOR_NIKON, 32785, N_("Shade")},
3744
3594
                {PTP_DPC_WhiteBalance, PTP_VENDOR_NIKON, 32786, N_("Color Temperature")},
3745
3595
                {PTP_DPC_WhiteBalance, PTP_VENDOR_NIKON, 32787, N_("Preset")},
3746
 
                {PTP_DPC_FlashMode, 0, 0, N_("Undefined")},
 
3596
                {PTP_DPC_FocusMode, 0, 1, N_("Manual Focus")},          /* 500A */
 
3597
                {PTP_DPC_FocusMode, 0, 2, N_("Automatic")},
 
3598
                {PTP_DPC_FocusMode, 0, 3, N_("Automatic Macro (close-up)")},
 
3599
                {PTP_DPC_FocusMode, PTP_VENDOR_NIKON, 32784, "AF-S"},
 
3600
                {PTP_DPC_FocusMode, PTP_VENDOR_NIKON, 32785, "AF-C"},
 
3601
                {PTP_DPC_FocusMode, PTP_VENDOR_NIKON, 32786, "AF-A"},
 
3602
                {PTP_DPC_ExposureMeteringMode, 0, 1, N_("Average")},    /* 500B */
 
3603
                {PTP_DPC_ExposureMeteringMode, 0, 2, N_("Center Weighted Average")},
 
3604
                {PTP_DPC_ExposureMeteringMode, 0, 3, N_("Multi-spot")},
 
3605
                {PTP_DPC_ExposureMeteringMode, 0, 4, N_("Center-spot")},
 
3606
                {PTP_DPC_FlashMode, 0, 0, N_("Undefined")},             /* 500C */
3747
3607
                {PTP_DPC_FlashMode, 0, 1, N_("Automatic flash")},
3748
3608
                {PTP_DPC_FlashMode, 0, 2, N_("Flash off")},
3749
3609
                {PTP_DPC_FlashMode, 0, 3, N_("Fill flash")},
3754
3614
                {PTP_DPC_FlashMode, PTP_VENDOR_NIKON, 32785, N_("Slow Sync")},
3755
3615
                {PTP_DPC_FlashMode, PTP_VENDOR_NIKON, 32786, N_("Rear Curtain Sync + Slow Sync")},
3756
3616
                {PTP_DPC_FlashMode, PTP_VENDOR_NIKON, 32787, N_("Red-eye Reduction + Slow Sync")},
3757
 
                {PTP_DPC_FocusMeteringMode, 0, 1, N_("Centre-spot")},
3758
 
                {PTP_DPC_FocusMeteringMode, 0, 2, N_("Multi-spot")},
3759
 
                {PTP_DPC_FocusMeteringMode, PTP_VENDOR_NIKON, 32784, N_("Single Area")},
3760
 
                {PTP_DPC_FocusMeteringMode, PTP_VENDOR_NIKON, 32785, N_("Closest Subject")},
3761
 
                {PTP_DPC_FocusMeteringMode, PTP_VENDOR_NIKON, 32786, N_("Group Dynamic")},
3762
 
                {PTP_DPC_FocusMode, 0, 1, N_("Manual Focus")},
3763
 
                {PTP_DPC_FocusMode, 0, 2, N_("Automatic")},
3764
 
                {PTP_DPC_FocusMode, 0, 3, N_("Automatic Macro (close-up)")},
3765
 
                {PTP_DPC_FocusMode, PTP_VENDOR_NIKON, 32784, "AF-S"},
3766
 
                {PTP_DPC_FocusMode, PTP_VENDOR_NIKON, 32785, "AF-C"},
3767
 
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_ISOAuto,PTP_VENDOR_NIKON),
3768
 
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_ExposureCompensation,PTP_VENDOR_NIKON),
3769
 
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_AELockMode,PTP_VENDOR_NIKON),
3770
 
                {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 0, N_("AE/AF Lock")},
3771
 
                {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 1, N_("AF Lock only")},
3772
 
                {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 2, N_("AE Lock only")},
3773
 
                {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 3, N_("AF Lock Hold")},
3774
 
                {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 4, N_("AF On")},
3775
 
                {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 5, N_("Flash Lock")},
3776
 
                {PTP_DPC_ExposureMeteringMode, 0, 1, N_("Average")},
3777
 
                {PTP_DPC_ExposureMeteringMode, 0, 2, N_("Center Weighted Average")},
3778
 
                {PTP_DPC_ExposureMeteringMode, 0, 3, N_("Multi-spot")},
3779
 
                {PTP_DPC_ExposureMeteringMode, 0, 4, N_("Center-spot")},
3780
 
                {PTP_DPC_ExposureProgramMode, 0, 1, "M"},
 
3617
                {PTP_DPC_ExposureProgramMode, 0, 1, "M"},               /* 500E */
3781
3618
                {PTP_DPC_ExposureProgramMode, 0, 3, "A"},
3782
3619
                {PTP_DPC_ExposureProgramMode, 0, 4, "S"},
3783
3620
                {PTP_DPC_ExposureProgramMode, 0, 2, "P"},
3788
3625
                {PTP_DPC_ExposureProgramMode, PTP_VENDOR_NIKON, 32788, N_("Sports")},
3789
3626
                {PTP_DPC_ExposureProgramMode, PTP_VENDOR_NIKON, 32790, N_("Night Landscape")},
3790
3627
                {PTP_DPC_ExposureProgramMode, PTP_VENDOR_NIKON, 32789, N_("Night Portrait")},
3791
 
                {PTP_DPC_StillCaptureMode, 0, 1, N_("Single Shot")},
 
3628
                {PTP_DPC_StillCaptureMode, 0, 1, N_("Single Shot")},    /* 5013 */
3792
3629
                {PTP_DPC_StillCaptureMode, 0, 2, N_("Power Wind")},
3793
3630
                {PTP_DPC_StillCaptureMode, 0, 3, N_("Timelapse")},
3794
3631
                {PTP_DPC_StillCaptureMode, PTP_VENDOR_NIKON, 32784, N_("Continuous Low Speed")},
3796
3633
                {PTP_DPC_StillCaptureMode, PTP_VENDOR_NIKON, 32787, N_("Remote")},
3797
3634
                {PTP_DPC_StillCaptureMode, PTP_VENDOR_NIKON, 32787, N_("Mirror Up")},
3798
3635
                {PTP_DPC_StillCaptureMode, PTP_VENDOR_NIKON, 32788, N_("Timer + Remote")},
3799
 
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_AFAssist,PTP_VENDOR_NIKON),
3800
 
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_ImageReview,PTP_VENDOR_NIKON),
3801
 
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_GridDisplay,PTP_VENDOR_NIKON),
3802
 
                {PTP_DPC_NIKON_AutofocusMode, PTP_VENDOR_NIKON, 0, N_("AF-S")},
3803
 
                {PTP_DPC_NIKON_AutofocusMode, PTP_VENDOR_NIKON, 1, N_("AF-C")},
3804
 
                {PTP_DPC_NIKON_AFAreaIllumination, PTP_VENDOR_NIKON, 0, N_("Auto")},
3805
 
                {PTP_DPC_NIKON_AFAreaIllumination, PTP_VENDOR_NIKON, 1, N_("Off")},
3806
 
                {PTP_DPC_NIKON_AFAreaIllumination, PTP_VENDOR_NIKON, 2, N_("On")},
3807
 
                {PTP_DPC_NIKON_ColorModel, PTP_VENDOR_NIKON, 0, "sRGB"},
3808
 
                {PTP_DPC_NIKON_ColorModel, PTP_VENDOR_NIKON, 1, "AdobeRGB"},
3809
 
                {PTP_DPC_NIKON_ColorModel, PTP_VENDOR_NIKON, 2, "sRGB"},
3810
 
                {PTP_DPC_NIKON_FlashMode, PTP_VENDOR_NIKON, 0, "iTTL"},
3811
 
                {PTP_DPC_NIKON_FlashMode, PTP_VENDOR_NIKON, 1, N_("Manual")},
3812
 
                {PTP_DPC_NIKON_FlashMode, PTP_VENDOR_NIKON, 2, N_("Commander")},
3813
 
                {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 0, N_("Full")},
3814
 
                {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 1, "1/2"},
3815
 
                {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 2, "1/4"},
3816
 
                {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 3, "1/8"},
3817
 
                {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 4, "1/16"},
3818
 
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_FlashSign,PTP_VENDOR_NIKON),
3819
 
                {PTP_DPC_NIKON_RemoteTimeout, PTP_VENDOR_NIKON, 0, N_("1 min")},
3820
 
                {PTP_DPC_NIKON_RemoteTimeout, PTP_VENDOR_NIKON, 1, N_("5 mins")},
3821
 
                {PTP_DPC_NIKON_RemoteTimeout, PTP_VENDOR_NIKON, 2, N_("10 mins")},
3822
 
                {PTP_DPC_NIKON_RemoteTimeout, PTP_VENDOR_NIKON, 3, N_("15 mins")},
3823
 
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FlashOpen,PTP_VENDOR_NIKON),
3824
 
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FlashCharged,PTP_VENDOR_NIKON),
3825
 
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_LongExposureNoiseReduction,PTP_VENDOR_NIKON),
3826
 
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_FileNumberSequence,PTP_VENDOR_NIKON),
3827
 
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_ReverseCommandDial,PTP_VENDOR_NIKON),
3828
 
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_NoCFCard,PTP_VENDOR_NIKON),
3829
 
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_ImageRotation,PTP_VENDOR_NIKON),
3830
 
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_Bracketing,PTP_VENDOR_NIKON),
3831
 
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_ImageCommentEnable,PTP_VENDOR_NIKON),
3832
 
                {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 0, N_("Centre")},
3833
 
                {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 1, N_("Top")},
3834
 
                {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 2, N_("Bottom")},
3835
 
                {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 3, N_("Left")},
3836
 
                {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 4, N_("Right")},
3837
 
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 0, N_("Normal")},
3838
 
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 1, N_("Vivid")},
3839
 
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 2, N_("Sharper")},
3840
 
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 3, N_("Softer")},
3841
 
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 4, N_("Direct Print")},
3842
 
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 5, N_("Portrait")},
3843
 
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 6, N_("Landscape")},
3844
 
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 7, N_("Custom")},
3845
 
 
3846
 
                {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 0, N_("Auto")},
 
3636
                {PTP_DPC_FocusMeteringMode, 0, 1, N_("Centre-spot")},   /* 501C */
 
3637
                {PTP_DPC_FocusMeteringMode, 0, 2, N_("Multi-spot")},
 
3638
                {PTP_DPC_FocusMeteringMode, PTP_VENDOR_NIKON, 32784, N_("Single Area")},
 
3639
                {PTP_DPC_FocusMeteringMode, PTP_VENDOR_NIKON, 32785, N_("Closest Subject")},
 
3640
                {PTP_DPC_FocusMeteringMode, PTP_VENDOR_NIKON, 32786, N_("Group Dynamic")},
 
3641
 
 
3642
 
 
3643
                /* Nikon specific device properties */
 
3644
                {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 0, N_("Auto")},       /* D02A */
3847
3645
                {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 1, N_("Normal")},
3848
3646
                {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 2, N_("Low")},
3849
3647
                {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 3, N_("Medium Low")},
3851
3649
                {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 5, N_("High")},
3852
3650
                {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 6, N_("None")},
3853
3651
 
3854
 
                {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 0, N_("Auto")},
 
3652
                {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 0, N_("Auto")},      /* D02B */
3855
3653
                {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 1, N_("Normal")},
3856
3654
                {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 2, N_("Low contrast")},
3857
3655
                {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 3, N_("Medium Low")},
3859
3657
                {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 5, N_("High control")},
3860
3658
                {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 6, N_("Custom")},
3861
3659
 
3862
 
                {PTP_DPC_NIKON_Saturation, PTP_VENDOR_NIKON, 0, N_("Normal")},
3863
 
                {PTP_DPC_NIKON_Saturation, PTP_VENDOR_NIKON, 1, N_("Moderate")},
3864
 
                {PTP_DPC_NIKON_Saturation, PTP_VENDOR_NIKON, 2, N_("Enhanced")},
3865
 
 
3866
 
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 0, N_("Unknown")},
3867
 
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 38, "Sigma 70-300mm 1:4-5.6 D APO Macro"},
3868
 
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 83, "AF Nikkor 80-200mm 1:2.8 D ED"},
3869
 
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 118, "AF Nikkor 50mm 1:1.8 D"},
3870
 
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 127, "AF-S Nikkor 18-70mm 1:3.5-4.5G ED DX"},
3871
 
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 139, "AF-S Nikkor 18-200mm 1:3.5-5.6 GED DX VR"},
3872
 
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 147, "AF-S Nikkor 24-70mm 1:2.8G ED DX"},
3873
 
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 154, "AF-S Nikkor 18-55mm 1:3.5-F5.6G DX VR"},
3874
 
 
3875
 
                {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 0, N_("10 seconds")},
3876
 
                {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 1, N_("20 seconds")},
3877
 
                {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 2, N_("1 minute")},
3878
 
                {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 3, N_("5 minutes")},
3879
 
                {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 4, N_("10 minutes")},
3880
 
                {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 5, N_("5 seconds")}, /* d80 observed */
3881
 
 
3882
 
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_LowLight,PTP_VENDOR_NIKON),
3883
 
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AFLockStatus,PTP_VENDOR_NIKON),
3884
 
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AELockStatus,PTP_VENDOR_NIKON),
3885
 
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FVLockStatus,PTP_VENDOR_NIKON),
3886
 
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ACPower,PTP_VENDOR_NIKON),
3887
 
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_CSMMenu,PTP_VENDOR_NIKON),
3888
 
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_BeepOff,PTP_VENDOR_NIKON),
3889
 
 
3890
 
                {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 0, "1/125"},
 
3660
                {PTP_DPC_NIKON_ColorModel, PTP_VENDOR_NIKON, 0, "sRGB"},                /* D02C */
 
3661
                {PTP_DPC_NIKON_ColorModel, PTP_VENDOR_NIKON, 1, "AdobeRGB"},
 
3662
                {PTP_DPC_NIKON_ColorModel, PTP_VENDOR_NIKON, 2, "sRGB"},
 
3663
 
 
3664
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_AutoDXCrop,PTP_VENDOR_NIKON),         /* D033 */
 
3665
 
 
3666
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_FocusAreaWrap,PTP_VENDOR_NIKON),      /* D04F */
 
3667
 
 
3668
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_EnableCopyright,PTP_VENDOR_NIKON),    /* D053 */
 
3669
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_ISOAuto,PTP_VENDOR_NIKON),            /* D054 */
 
3670
 
 
3671
                /* FIXME! this is not ISO Auto (which is a bool) Perhaps ISO Auto Time?*/
 
3672
                {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 0, "1/125"},                  /* D054 */
3891
3673
                {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 1, "1/60"},
3892
3674
                {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 2, "1/30"},
3893
3675
                {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 3, "1/15"},
3901
3683
                {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 11, "15"},
3902
3684
                {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 12, "30"},
3903
3685
 
3904
 
                {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 0, "0'"},
3905
 
                {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 1, "270'"},
3906
 
                {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 2, "90'"},
3907
 
                {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 3, "180'"},
3908
 
 
3909
 
                {PTP_DPC_NIKON_SelfTimer, PTP_VENDOR_NIKON, 0, N_("2 seconds")},
3910
 
                {PTP_DPC_NIKON_SelfTimer, PTP_VENDOR_NIKON, 1, N_("5 seconds")},
3911
 
                {PTP_DPC_NIKON_SelfTimer, PTP_VENDOR_NIKON, 2, N_("10 seconds")},
3912
 
                {PTP_DPC_NIKON_SelfTimer, PTP_VENDOR_NIKON, 3, N_("20 seconds")},
3913
 
 
3914
 
                {PTP_DPC_NIKON_MeterOff, PTP_VENDOR_NIKON, 0, N_("4 seconds")},
 
3686
                {PTP_DPC_NIKON_EVStep, PTP_VENDOR_NIKON, 0, "1/3"},                     /* D056 */
 
3687
                {PTP_DPC_NIKON_EVStep, PTP_VENDOR_NIKON, 1, "1/2"},
 
3688
 
 
3689
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_ExposureCompensation,PTP_VENDOR_NIKON),/*D058 */
 
3690
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_AELockMode,PTP_VENDOR_NIKON),         /* D05E */
 
3691
 
 
3692
                {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 0, N_("AE/AF Lock")},      /* D05F */
 
3693
                {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 1, N_("AF Lock only")},
 
3694
                {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 2, N_("AE Lock only")},
 
3695
                {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 3, N_("AF Lock Hold")},
 
3696
                {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 4, N_("AF On")},
 
3697
                {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 5, N_("Flash Lock")},
 
3698
 
 
3699
                {PTP_DPC_NIKON_MeterOff, PTP_VENDOR_NIKON, 0, N_("4 seconds")},         /* D062 */
3915
3700
                {PTP_DPC_NIKON_MeterOff, PTP_VENDOR_NIKON, 1, N_("6 seconds")},
3916
3701
                {PTP_DPC_NIKON_MeterOff, PTP_VENDOR_NIKON, 2, N_("8 seconds")},
3917
3702
                {PTP_DPC_NIKON_MeterOff, PTP_VENDOR_NIKON, 3, N_("16 seconds")},
3918
3703
                {PTP_DPC_NIKON_MeterOff, PTP_VENDOR_NIKON, 4, N_("30 minutes")},
3919
3704
                {PTP_DPC_NIKON_MeterOff, PTP_VENDOR_NIKON, 5, N_("30 seconds")},
3920
3705
 
3921
 
                {PTP_DPC_NIKON_BracketSet, PTP_VENDOR_NIKON, 0, N_("AE & Flash")},
 
3706
                {PTP_DPC_NIKON_SelfTimer, PTP_VENDOR_NIKON, 0, N_("2 seconds")},        /* D063 */
 
3707
                {PTP_DPC_NIKON_SelfTimer, PTP_VENDOR_NIKON, 1, N_("5 seconds")},
 
3708
                {PTP_DPC_NIKON_SelfTimer, PTP_VENDOR_NIKON, 2, N_("10 seconds")},
 
3709
                {PTP_DPC_NIKON_SelfTimer, PTP_VENDOR_NIKON, 3, N_("20 seconds")},
 
3710
 
 
3711
                {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 0, N_("10 seconds")},      /* D064 */
 
3712
                {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 1, N_("20 seconds")},
 
3713
                {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 2, N_("1 minute")},
 
3714
                {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 3, N_("5 minutes")},
 
3715
                {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 4, N_("10 minutes")},
 
3716
                {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 5, N_("5 seconds")}, /* d80 observed */
 
3717
 
 
3718
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_D3ExpDelayMode,PTP_VENDOR_NIKON),     /* D06A */
 
3719
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_LongExposureNoiseReduction,PTP_VENDOR_NIKON), /* D06B */
 
3720
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_FileNumberSequence,PTP_VENDOR_NIKON), /* D06C */
 
3721
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_D7Illumination,PTP_VENDOR_NIKON),     /* D06F */
 
3722
 
 
3723
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_SHSET_CH_GUID_DISP,PTP_VENDOR_NIKON), /* D071 */
 
3724
 
 
3725
                {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 0, "1/60s"},                /* D075 */
 
3726
                {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 1, "1/30s"},
 
3727
                {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 2, "1/15s"},
 
3728
                {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 3, "1/8s"},
 
3729
                {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 4, "1/4s"},
 
3730
                {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 5, "1/2s"},
 
3731
                {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 6, "1s"},
 
3732
                {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 7, "2s"},
 
3733
                {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 8, "4s"},
 
3734
                {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 9, "8s"},
 
3735
                {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 10, "15s"},
 
3736
                {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 11, "30s"},
 
3737
 
 
3738
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_E4ModelingFlash,PTP_VENDOR_NIKON),    /* D077 */
 
3739
 
 
3740
                {PTP_DPC_NIKON_BracketSet, PTP_VENDOR_NIKON, 0, N_("AE & Flash")},      /* D078 */
3922
3741
                {PTP_DPC_NIKON_BracketSet, PTP_VENDOR_NIKON, 1, N_("AE only")},
3923
3742
                {PTP_DPC_NIKON_BracketSet, PTP_VENDOR_NIKON, 2, N_("Flash only")},
3924
3743
                {PTP_DPC_NIKON_BracketSet, PTP_VENDOR_NIKON, 3, N_("WB bracketing")},
3925
3744
 
3926
 
                {PTP_DPC_NIKON_BracketOrder, PTP_VENDOR_NIKON, 0, N_("MTR > Under")},
 
3745
                {PTP_DPC_NIKON_BracketOrder, PTP_VENDOR_NIKON, 0, N_("MTR > Under")},   /* D07A */
3927
3746
                {PTP_DPC_NIKON_BracketOrder, PTP_VENDOR_NIKON, 1, N_("Under > MTR")},
3928
3747
 
3929
 
                {PTP_DPC_NIKON_FlashCommanderMode, PTP_VENDOR_NIKON, 0, N_("TTL")},
3930
 
                {PTP_DPC_NIKON_FlashCommanderMode, PTP_VENDOR_NIKON, 1, N_("Auto Aperture")},
3931
 
                {PTP_DPC_NIKON_FlashCommanderMode, PTP_VENDOR_NIKON, 2, N_("Full Manual")},
3932
 
 
3933
 
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 0, N_("Full")},
3934
 
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 1, "1/2"},
3935
 
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 2, "1/4"},
3936
 
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 3, "1/8"},
3937
 
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 4, "1/16"},
3938
 
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 5, "1/32"},
3939
 
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 6, "1/64"},
3940
 
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 7, "1/128"},
3941
 
 
3942
 
                {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 0,  "1/125"},
 
3748
                {PTP_DPC_NIKON_F1CenterButtonShootingMode, PTP_VENDOR_NIKON, 0, N_("Reset focus point to center")}, /* D080 */
 
3749
                {PTP_DPC_NIKON_F1CenterButtonShootingMode, PTP_VENDOR_NIKON, 1, N_("Highlight active focus point")},
 
3750
                {PTP_DPC_NIKON_F1CenterButtonShootingMode, PTP_VENDOR_NIKON, 2, N_("Unused")},
 
3751
 
 
3752
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_F3PhotoInfoPlayback,PTP_VENDOR_NIKON),/* D083 */
 
3753
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_F5CustomizeCommDials,PTP_VENDOR_NIKON),/* D085 */
 
3754
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_ReverseCommandDial,PTP_VENDOR_NIKON), /* D086 */
 
3755
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_F6ButtonsAndDials,PTP_VENDOR_NIKON), /* D089 */
 
3756
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_NoCFCard,PTP_VENDOR_NIKON),          /* D08A */
 
3757
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_AFAreaPoint,PTP_VENDOR_NIKON),       /* D08D */
 
3758
 
 
3759
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_ImageCommentEnable,PTP_VENDOR_NIKON), /* D091 */
 
3760
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_ImageRotation,PTP_VENDOR_NIKON),     /* D092 */
 
3761
 
 
3762
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_MovVoice,PTP_VENDOR_NIKON),           /* D0A1 */
 
3763
 
 
3764
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_Bracketing,PTP_VENDOR_NIKON),         /* D0C0 */
 
3765
 
 
3766
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 0, N_("Unknown")},             /* D0E0 */
 
3767
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 38, "Sigma 70-300mm 1:4-5.6 D APO Macro"},
 
3768
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 83, "AF Nikkor 80-200mm 1:2.8 D ED"},
 
3769
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 118, "AF Nikkor 50mm 1:1.8 D"},
 
3770
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 127, "AF-S Nikkor 18-70mm 1:3.5-4.5G ED DX"},
 
3771
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 139, "AF-S Nikkor 18-200mm 1:3.5-5.6 GED DX VR"},
 
3772
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 147, "AF-S Nikkor 24-70mm 1:2.8G ED DX"},
 
3773
                {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 154, "AF-S Nikkor 18-55mm 1:3.5-F5.6G DX VR"},
 
3774
                {PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 0, "Show ISO sensitivity"},/* 0xD0F0 */
 
3775
                {PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 1, "Show ISO/Easy ISO"},
 
3776
                {PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 2, "Show frame count"},
 
3777
 
 
3778
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ACPower,PTP_VENDOR_NIKON),              /* D101 */
 
3779
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AFLockStatus,PTP_VENDOR_NIKON),         /* D104 */
 
3780
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AELockStatus,PTP_VENDOR_NIKON),         /* D105 */
 
3781
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FVLockStatus,PTP_VENDOR_NIKON),         /* D106 */
 
3782
 
 
3783
                {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 0, N_("Centre")},       /* D108 */
 
3784
                {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 1, N_("Top")},
 
3785
                {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 2, N_("Bottom")},
 
3786
                {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 3, N_("Left")},
 
3787
                {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 4, N_("Right")},
 
3788
 
 
3789
                {PTP_DPC_NIKON_RecordingMedia, PTP_VENDOR_NIKON, 0, N_("Card")},        /* D10B */
 
3790
                {PTP_DPC_NIKON_RecordingMedia, PTP_VENDOR_NIKON, 1, N_("SDRam")},
 
3791
 
 
3792
                {PTP_DPC_NIKON_USBSpeed, PTP_VENDOR_NIKON, 0, N_("USB 1.1")},           /* D10C */
 
3793
                {PTP_DPC_NIKON_USBSpeed, PTP_VENDOR_NIKON, 1, N_("USB 2.0")},
 
3794
 
 
3795
                {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 0, "0'"},           /* D10E */
 
3796
                {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 1, "270'"},
 
3797
                {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 2, "90'"},
 
3798
                {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 3, "180'"},
 
3799
 
 
3800
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FNumberLock,PTP_VENDOR_NIKON),          /* D110 */
 
3801
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExposureApertureLock,PTP_VENDOR_NIKON), /* D111 */
 
3802
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_TVLockSetting,PTP_VENDOR_NIKON),        /* D112 */
 
3803
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AVLockSetting,PTP_VENDOR_NIKON),        /* D113 */
 
3804
 
 
3805
                {PTP_DPC_NIKON_IllumSetting,PTP_VENDOR_NIKON,0,N_("LCD Backlight")},    /* D114 */
 
3806
                {PTP_DPC_NIKON_IllumSetting,PTP_VENDOR_NIKON,1,N_("LCD Backlight and Info Display")},
 
3807
 
 
3808
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExternalFlashAttached,PTP_VENDOR_NIKON),/* D120 */
 
3809
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExternalFlashStatus,PTP_VENDOR_NIKON),  /* D121 */
 
3810
 
 
3811
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 0, N_("Normal")},       /* D140 */
 
3812
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 1, N_("Vivid")},
 
3813
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 2, N_("Sharper")},
 
3814
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 3, N_("Softer")},
 
3815
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 4, N_("Direct Print")},
 
3816
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 5, N_("Portrait")},
 
3817
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 6, N_("Landscape")},
 
3818
                {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 7, N_("Custom")},
 
3819
 
 
3820
                {PTP_DPC_NIKON_Saturation, PTP_VENDOR_NIKON, 0, N_("Normal")},          /* D142 */
 
3821
                {PTP_DPC_NIKON_Saturation, PTP_VENDOR_NIKON, 1, N_("Moderate")},
 
3822
                {PTP_DPC_NIKON_Saturation, PTP_VENDOR_NIKON, 2, N_("Enhanced")},
 
3823
 
 
3824
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_BeepOff,PTP_VENDOR_NIKON),           /* D160 */
 
3825
 
 
3826
                {PTP_DPC_NIKON_AutofocusMode, PTP_VENDOR_NIKON, 0, N_("AF-S")},         /* D161 */
 
3827
                {PTP_DPC_NIKON_AutofocusMode, PTP_VENDOR_NIKON, 1, N_("AF-C")},
 
3828
                {PTP_DPC_NIKON_AutofocusMode, PTP_VENDOR_NIKON, 2, N_("AF-A")},
 
3829
                {PTP_DPC_NIKON_AutofocusMode, PTP_VENDOR_NIKON, 3, N_("MF (fixed)")},
 
3830
                {PTP_DPC_NIKON_AutofocusMode, PTP_VENDOR_NIKON, 4, N_("MF (selection)")},
 
3831
 
 
3832
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_AFAssist,PTP_VENDOR_NIKON),          /* D163 */
 
3833
 
 
3834
                {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 0,  "1/125"},               /* D164 */
3943
3835
                {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 1,  "1/60"},
3944
3836
                {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 2,  "1/30"},
3945
3837
                {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 3,  "1/15"},
3953
3845
                {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 11, "15"},
3954
3846
                {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 12, "30"},
3955
3847
 
3956
 
                {PTP_DPC_NIKON_EVStep, PTP_VENDOR_NIKON, 0, "1/3"},
3957
 
                {PTP_DPC_NIKON_EVStep, PTP_VENDOR_NIKON, 1, "1/2"},
 
3848
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_ImageReview,PTP_VENDOR_NIKON),       /* D165 */
 
3849
 
 
3850
                {PTP_DPC_NIKON_AFAreaIllumination, PTP_VENDOR_NIKON, 0, N_("Auto")},    /* D166 */
 
3851
                {PTP_DPC_NIKON_AFAreaIllumination, PTP_VENDOR_NIKON, 1, N_("Off")},
 
3852
                {PTP_DPC_NIKON_AFAreaIllumination, PTP_VENDOR_NIKON, 2, N_("On")},
 
3853
 
 
3854
                {PTP_DPC_NIKON_FlashMode, PTP_VENDOR_NIKON, 0, "iTTL"},                 /* D167 */
 
3855
                {PTP_DPC_NIKON_FlashMode, PTP_VENDOR_NIKON, 1, N_("Manual")},
 
3856
                {PTP_DPC_NIKON_FlashMode, PTP_VENDOR_NIKON, 2, N_("Commander")},
 
3857
 
 
3858
                {PTP_DPC_NIKON_FlashCommanderMode, PTP_VENDOR_NIKON, 0, N_("TTL")},     /* D168 */
 
3859
                {PTP_DPC_NIKON_FlashCommanderMode, PTP_VENDOR_NIKON, 1, N_("Auto Aperture")},
 
3860
                {PTP_DPC_NIKON_FlashCommanderMode, PTP_VENDOR_NIKON, 2, N_("Full Manual")},
 
3861
 
 
3862
                PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_FlashSign,PTP_VENDOR_NIKON),         /* D169 */
 
3863
 
 
3864
                {PTP_DPC_NIKON_RemoteTimeout, PTP_VENDOR_NIKON, 0, N_("1 min")},        /* D16B */
 
3865
                {PTP_DPC_NIKON_RemoteTimeout, PTP_VENDOR_NIKON, 1, N_("5 mins")},
 
3866
                {PTP_DPC_NIKON_RemoteTimeout, PTP_VENDOR_NIKON, 2, N_("10 mins")},
 
3867
                {PTP_DPC_NIKON_RemoteTimeout, PTP_VENDOR_NIKON, 3, N_("15 mins")},
 
3868
 
 
3869
                PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_GridDisplay,PTP_VENDOR_NIKON),        /* D16C */
 
3870
 
 
3871
                {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 0, N_("Full")},  /* D16D */
 
3872
                {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 1, "1/2"},
 
3873
                {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 2, "1/4"},
 
3874
                {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 3, "1/8"},
 
3875
                {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 4, "1/16"},
 
3876
 
 
3877
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 0, N_("Full")},/* D16E */
 
3878
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 1, "1/2"},
 
3879
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 2, "1/4"},
 
3880
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 3, "1/8"},
 
3881
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 4, "1/16"},
 
3882
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 5, "1/32"},
 
3883
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 6, "1/64"},
 
3884
                {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 7, "1/128"},
 
3885
 
 
3886
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_CSMMenu,PTP_VENDOR_NIKON),              /* D180 */
 
3887
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_WarningDisplay,PTP_VENDOR_NIKON),       /* D181 */
 
3888
 
 
3889
                {PTP_DPC_NIKON_BatteryCellKind, PTP_VENDOR_NIKON, 0, "LR6 (AA alkaline)"},/* D182 */
 
3890
                {PTP_DPC_NIKON_BatteryCellKind, PTP_VENDOR_NIKON, 1, "HR6 (AA Ni-Mh)"},
 
3891
                {PTP_DPC_NIKON_BatteryCellKind, PTP_VENDOR_NIKON, 2, "FR6 (AA Lithium)"},
 
3892
                {PTP_DPC_NIKON_BatteryCellKind, PTP_VENDOR_NIKON, 3, "ZR6 (AA Ni-Mn)"},
 
3893
 
 
3894
                {PTP_DPC_NIKON_ISOAutoHiLimit, PTP_VENDOR_NIKON, 0, "400"},             /* D183 */
 
3895
                {PTP_DPC_NIKON_ISOAutoHiLimit, PTP_VENDOR_NIKON, 1, "800"},
 
3896
                {PTP_DPC_NIKON_ISOAutoHiLimit, PTP_VENDOR_NIKON, 2, "1600"},
 
3897
                {PTP_DPC_NIKON_ISOAutoHiLimit, PTP_VENDOR_NIKON, 3, "3200"},
 
3898
                {PTP_DPC_NIKON_ISOAutoHiLimit, PTP_VENDOR_NIKON, 4, "Hi 1"},
 
3899
 
 
3900
                {PTP_DPC_NIKON_InfoDispSetting, PTP_VENDOR_NIKON, 0, N_("Auto")},       /* 0xD187 */
 
3901
                {PTP_DPC_NIKON_InfoDispSetting, PTP_VENDOR_NIKON, 1, N_("Dark on light")},
 
3902
                {PTP_DPC_NIKON_InfoDispSetting, PTP_VENDOR_NIKON, 2, N_("Light on dark")},
 
3903
 
 
3904
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_IndicatorDisp,PTP_VENDOR_NIKON),        /* D18D */
 
3905
 
 
3906
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_LiveViewStatus,PTP_VENDOR_NIKON),       /* D1A2 */
 
3907
 
 
3908
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExposureDisplayStatus,PTP_VENDOR_NIKON),/* D1B0 */
 
3909
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_InfoDispErrStatus,PTP_VENDOR_NIKON),    /* D1B2 */
 
3910
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExposureIndicateLightup,PTP_VENDOR_NIKON),/* D1B3 */
 
3911
 
 
3912
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FlashOpen,PTP_VENDOR_NIKON),            /* D1C0 */
 
3913
                PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FlashCharged,PTP_VENDOR_NIKON),         /* D1C1 */
3958
3914
 
3959
3915
                /* Canon stuff */
3960
3916
                PTP_VENDOR_VAL_BOOL(PTP_DPC_CANON_AssistLight,PTP_VENDOR_CANON),
4189
4145
                        return snprintf(out, length, "%s", _(ptp_value_list[i].value));
4190
4146
                }
4191
4147
        }
4192
 
        if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_MICROSOFT) {
 
4148
        if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_MICROSOFT
 
4149
            || params->deviceinfo.VendorExtensionID==PTP_VENDOR_MTP) {
4193
4150
                switch (dpc) {
4194
4151
                case PTP_DPC_MTP_SynchronizationPartner:
4195
4152
                case PTP_DPC_MTP_DeviceFriendlyName:
4322
4279
        if (!(ofc & 0x8000)) {
4323
4280
                for (i=0;i<sizeof(ptp_ofc_trans)/sizeof(ptp_ofc_trans[0]);i++)
4324
4281
                        if (ofc == ptp_ofc_trans[i].ofc)
4325
 
                                return snprintf(txt, spaceleft,_(ptp_ofc_trans[i].format));
 
4282
                                return snprintf(txt, spaceleft, "%s", _(ptp_ofc_trans[i].format));
4326
4283
        } else {
4327
4284
                switch (params->deviceinfo.VendorExtensionID) {
4328
4285
                case PTP_VENDOR_EASTMAN_KODAK:
4342
4299
                        }
4343
4300
                        break;
4344
4301
                case PTP_VENDOR_MICROSOFT:
 
4302
                case PTP_VENDOR_MTP:              
4345
4303
                        for (i=0;i<sizeof(ptp_ofc_mtp_trans)/sizeof(ptp_ofc_mtp_trans[0]);i++)
4346
4304
                                if (ofc == ptp_ofc_mtp_trans[i].ofc)
4347
 
                                        return snprintf(txt, spaceleft,_(ptp_ofc_mtp_trans[i].format));
 
4305
                                        return snprintf(txt, spaceleft, "%s", _(ptp_ofc_mtp_trans[i].format));
4348
4306
                        break;
4349
4307
                default:break;
4350
4308
                }
4455
4413
        if (!(opcode & 0x8000)) {
4456
4414
                for (i=0;i<sizeof(ptp_opcode_trans)/sizeof(ptp_opcode_trans[0]);i++)
4457
4415
                        if (opcode == ptp_opcode_trans[i].opcode)
4458
 
                                return snprintf(txt, spaceleft,_(ptp_opcode_trans[i].name));
 
4416
                                return snprintf(txt, spaceleft, "%s", _(ptp_opcode_trans[i].name));
4459
4417
        } else {
4460
4418
                switch (params->deviceinfo.VendorExtensionID) {
4461
4419
                case PTP_VENDOR_MICROSOFT:
 
4420
                case PTP_VENDOR_MTP:
4462
4421
                        for (i=0;i<sizeof(ptp_opcode_mtp_trans)/sizeof(ptp_opcode_mtp_trans[0]);i++)
4463
4422
                                if (opcode == ptp_opcode_mtp_trans[i].opcode)
4464
 
                                        return snprintf(txt, spaceleft,_(ptp_opcode_mtp_trans[i].name));
 
4423
                                        return snprintf(txt, spaceleft, "%s", _(ptp_opcode_mtp_trans[i].name));
4465
4424
                        break;
4466
4425
                default:break;
4467
4426
                }
4649
4608
        int i;
4650
4609
        for (i=0;i<sizeof(ptp_opc_trans)/sizeof(ptp_opc_trans[0]);i++)
4651
4610
                if (propid == ptp_opc_trans[i].id)
4652
 
                        return snprintf(txt, spaceleft,ptp_opc_trans[i].name);
 
4611
                        return snprintf(txt, spaceleft, "%s", ptp_opc_trans[i].name);
4653
4612
        return snprintf (txt, spaceleft,"unknown(%04x)", propid);
4654
4613
}
4655
4614
 
4713
4672
MTPProperties *
4714
4673
ptp_find_object_prop_in_cache(PTPParams *params, uint32_t const handle, uint32_t const attribute_id)
4715
4674
{
4716
 
        int i;
4717
 
        MTPProperties *prop = params->props;
4718
 
        
4719
 
        if (!prop)
 
4675
        int     i;
 
4676
        MTPProperties   *prop;
 
4677
        PTPObject       *ob;
 
4678
        uint16_t        ret;
 
4679
 
 
4680
        ret = ptp_object_find (params, handle, &ob);
 
4681
        if (ret != PTP_RC_OK)
4720
4682
                return NULL;
4721
 
        
4722
 
        for (i=0;i<params->nrofprops;i++) {
4723
 
                if (handle == prop->ObjectHandle && attribute_id == prop->property)
 
4683
        prop = ob->mtpprops;
 
4684
        for (i=0;i<ob->nrofmtpprops;i++) {
 
4685
                if (attribute_id == prop->property)
4724
4686
                        return prop;
4725
 
                prop ++;
 
4687
                prop++;
4726
4688
        }
4727
4689
        return NULL;
4728
4690
}
4731
4693
ptp_remove_object_from_cache(PTPParams *params, uint32_t handle)
4732
4694
{
4733
4695
        int i;
 
4696
        PTPObject       *ob;
 
4697
        uint16_t        ret;
4734
4698
 
 
4699
        ret = ptp_object_find (params, handle, &ob);
 
4700
        if (ret != PTP_RC_OK)
 
4701
                return;
 
4702
        i = ob-params->objects;
4735
4703
        /* remove object from object info cache */
4736
 
        for (i = 0; i < params->handles.n; i++) {
4737
 
                if (params->handles.Handler[i] == handle) {
4738
 
                        ptp_free_objectinfo(&params->objectinfo[i]);
4739
 
 
4740
 
                        if (i < params->handles.n-1) {
4741
 
                                memmove(params->handles.Handler+i, params->handles.Handler+i+1,
4742
 
                                        (params->handles.n-i-1)*sizeof(uint32_t));
4743
 
                                memmove(params->objectinfo+i, params->objectinfo+i+1,
4744
 
                                        (params->handles.n-i-1)*sizeof(PTPObjectInfo));
4745
 
                        }
4746
 
                        params->handles.n--;
4747
 
                        /* We use less memory than before so this shouldn't fail */
4748
 
                        params->handles.Handler = realloc(params->handles.Handler, sizeof(uint32_t)*params->handles.n);
4749
 
                        params->objectinfo = realloc(params->objectinfo, sizeof(PTPObjectInfo)*params->handles.n);
 
4704
        ptp_free_object (ob);
 
4705
 
 
4706
        if (i < params->nrofobjects-1)
 
4707
                memmove (ob,ob+1,(params->nrofobjects-1-i)*sizeof(PTPObject));
 
4708
        params->nrofobjects--;
 
4709
        /* We use less memory than before so this shouldn't fail */
 
4710
        params->objects = realloc(params->objects, sizeof(PTPObject)*params->nrofobjects);
 
4711
}
 
4712
 
 
4713
static int _cmp_ob (const void *a, const void *b) {
 
4714
        PTPObject *oa = (PTPObject*)a;
 
4715
        PTPObject *ob = (PTPObject*)b;
 
4716
 
 
4717
        return oa->oid - ob->oid;
 
4718
}
 
4719
        
 
4720
void
 
4721
ptp_objects_sort (PTPParams *params) {
 
4722
        qsort (params->objects, params->nrofobjects, sizeof(PTPObject), _cmp_ob);
 
4723
}
 
4724
 
 
4725
/* Binary search in objects. Needs "objects" to be a sorted by objectid list!  */
 
4726
uint16_t
 
4727
ptp_object_find (PTPParams *params, uint32_t handle, PTPObject **retob) {
 
4728
        PTPObject       tmpob;
 
4729
 
 
4730
        tmpob.oid = handle;
 
4731
        *retob = bsearch (&tmpob, params->objects, params->nrofobjects, sizeof(tmpob), _cmp_ob);
 
4732
        if (!*retob)
 
4733
                return PTP_RC_GeneralError;
 
4734
        return PTP_RC_OK;
 
4735
}
 
4736
 
 
4737
/* Binary search in objects + insert of not found. Needs "objects" to be a sorted by objectid list!  */
 
4738
uint16_t
 
4739
ptp_object_find_or_insert (PTPParams *params, uint32_t handle, PTPObject **retob) {
 
4740
        int             begin, end, cursor;
 
4741
        int             insertat;
 
4742
        PTPObject       *newobs;
 
4743
 
 
4744
        if (!handle) return PTP_RC_GeneralError;
 
4745
        *retob = NULL;
 
4746
        if (!params->nrofobjects) {
 
4747
                params->objects = calloc(1,sizeof(PTPObject));
 
4748
                params->nrofobjects = 1;
 
4749
                params->objects[0].oid = handle;
 
4750
                *retob = &params->objects[0];
 
4751
                return PTP_RC_OK;
 
4752
        }
 
4753
        begin = 0;
 
4754
        end = params->nrofobjects-1;
 
4755
        /*ptp_debug (params, "searching %08x, total=%d", handle, params->nrofobjects);*/
 
4756
        while (1) {
 
4757
                cursor = (end-begin)/2+begin;
 
4758
                /*ptp_debug (params, "ob %d: %08x [%d-%d]", cursor, params->objects[cursor].oid, begin, end);*/
 
4759
                if (params->objects[cursor].oid == handle) {
 
4760
                        *retob = &params->objects[cursor];
 
4761
                        return PTP_RC_OK;
 
4762
                }
 
4763
                if (params->objects[cursor].oid < handle)
 
4764
                        begin = cursor;
 
4765
                else
 
4766
                        end = cursor;
 
4767
                if ((end - begin) <= 1)
4750
4768
                        break;
4751
 
                }
4752
 
        }
4753
 
        
4754
 
        /* delete cached object properties if metadata cache exists */
4755
 
        if (params->props != NULL) {
4756
 
                int nrofoldprops = 0;
4757
 
                int firstoldprop = 0;
 
4769
        }
 
4770
        if (params->objects[begin].oid == handle) {
 
4771
                *retob = &params->objects[begin];
 
4772
                return PTP_RC_OK;
 
4773
        }
 
4774
        if (params->objects[end].oid == handle) {
 
4775
                *retob = &params->objects[end];
 
4776
                return PTP_RC_OK;
 
4777
        }
 
4778
        if ((begin == 0) && (handle < params->objects[0].oid)) {
 
4779
                insertat=begin;
 
4780
        } else {
 
4781
                if ((end == params->nrofobjects-1) && (handle > params->objects[end].oid))
 
4782
                        insertat=end+1;
 
4783
                else
 
4784
                        insertat=begin+1;
 
4785
        }
 
4786
        /*ptp_debug (params, "inserting oid %x at [%x,%x], begin=%d, end=%d, insertat=%d\n", handle, params->objects[begin].oid, params->objects[end].oid, begin, end, insertat);*/
 
4787
        newobs = realloc (params->objects, sizeof(PTPObject)*(params->nrofobjects+1));
 
4788
        if (!newobs) return PTP_RC_GeneralError;
 
4789
        params->objects = newobs;
 
4790
        if (insertat<=params->nrofobjects)
 
4791
                memmove (&params->objects[insertat+1],&params->objects[insertat],(params->nrofobjects-insertat)*sizeof(PTPObject));
 
4792
        memset(&params->objects[insertat],0,sizeof(PTPObject));
 
4793
        params->objects[insertat].oid = handle;
 
4794
        *retob = &params->objects[insertat];
 
4795
        params->nrofobjects++;
 
4796
        return PTP_RC_OK;
 
4797
}
 
4798
 
 
4799
uint16_t
 
4800
ptp_object_want (PTPParams *params, uint32_t handle, int want, PTPObject **retob) {
 
4801
        uint16_t        ret;
 
4802
        PTPObject       *ob;
 
4803
        //Camera                *camera = ((PTPData *)params->data)->camera;
 
4804
 
 
4805
        *retob = NULL;
 
4806
        if (!handle) {
 
4807
                ptp_debug (params, "ptp_object_want: querying handle 0?\n");
 
4808
                return PTP_RC_GeneralError;
 
4809
        }
 
4810
        ret = ptp_object_find_or_insert (params, handle, &ob);
 
4811
        if (ret != PTP_RC_OK)
 
4812
                return PTP_RC_GeneralError;
 
4813
        *retob = ob;
 
4814
        /* Do we have all of it already? */
 
4815
        if ((ob->flags & want) == want)
 
4816
                return PTP_RC_OK;
 
4817
 
 
4818
#define X (PTPOBJECT_OBJECTINFO_LOADED|PTPOBJECT_STORAGEID_LOADED|PTPOBJECT_PARENTOBJECT_LOADED)
 
4819
        if ((want & X) && ((ob->flags & X) != X)) {
 
4820
                uint32_t        saveparent = 0;
4758
4821
                
4759
 
                for (i=0; i<params->nrofprops; i++) {
4760
 
                        MTPProperties *prop = &params->props[i];
4761
 
                        if (prop->ObjectHandle == handle)
4762
 
                                {
4763
 
                                        nrofoldprops++;
4764
 
                                        if (nrofoldprops == 1) {
4765
 
                                                firstoldprop = i;
4766
 
                                        }
4767
 
                                }
4768
 
                }
4769
 
                for (i=firstoldprop;i<(firstoldprop+nrofoldprops);i++) {
4770
 
                        ptp_destroy_object_prop(&params->props[i]);
4771
 
                }
4772
 
                memmove(&params->props[firstoldprop], 
4773
 
                        &params->props[firstoldprop+nrofoldprops], 
4774
 
                        (params->nrofprops-firstoldprop-nrofoldprops)*sizeof(MTPProperties));
4775
 
                /* We use less memory than before so this shouldn't fail */
4776
 
                params->props = realloc(params->props, 
4777
 
                                        (params->nrofprops - nrofoldprops)*sizeof(MTPProperties));
4778
 
                params->nrofprops -= nrofoldprops;
4779
 
        }
 
4822
                /* One EOS issue, where getobjecthandles(root) returns obs without root flag. */
 
4823
                if (ob->flags & PTPOBJECT_PARENTOBJECT_LOADED)
 
4824
                        saveparent = ob->oi.ParentObject;
 
4825
 
 
4826
                ret = ptp_getobjectinfo (params, handle, &ob->oi);
 
4827
                if (ret != PTP_RC_OK)
 
4828
                        return ret;
 
4829
                if (!ob->oi.Filename) ob->oi.Filename=strdup("<none>");
 
4830
                if (ob->flags & PTPOBJECT_PARENTOBJECT_LOADED)
 
4831
                        ob->oi.ParentObject = saveparent;
 
4832
 
 
4833
                /* Second EOS issue, 0x20000000 has 0x20000000 as parent */
 
4834
                if (ob->oi.ParentObject == handle)
 
4835
                        ob->oi.ParentObject = 0;
 
4836
                ob->flags |= X;
 
4837
 
 
4838
                /* EOS bug, DCIM links back to itself. */
 
4839
        }
 
4840
#undef X
 
4841
        if (    (want & PTPOBJECT_MTPPROPLIST_LOADED) &&
 
4842
                (!(ob->flags & PTPOBJECT_MTPPROPLIST_LOADED))
 
4843
        ) {
 
4844
                int             nrofprops = 0;
 
4845
                MTPProperties   *props = NULL;
 
4846
 
 
4847
                if (params->device_flags & DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST) {
 
4848
                        want &= ~PTPOBJECT_MTPPROPLIST_LOADED;
 
4849
                        goto fallback;
 
4850
                }
 
4851
                /* Microsoft/MTP has fast directory retrieval. */
 
4852
                if (!ptp_operation_issupported(params,PTP_OC_MTP_GetObjPropList)) {
 
4853
                        want &= ~PTPOBJECT_MTPPROPLIST_LOADED;
 
4854
                        goto fallback;
 
4855
                }
 
4856
 
 
4857
                ptp_debug (params, "ptp2/mtpfast: reading mtp proplist of %08x", handle);
 
4858
                ret = ptp_mtp_getobjectproplist (params, handle, &props, &nrofprops);
 
4859
                if (ret != PTP_RC_OK)
 
4860
                        goto fallback;
 
4861
                ob->mtpprops = props;
 
4862
                ob->nrofmtpprops = nrofprops;
 
4863
 
 
4864
#if 0
 
4865
                MTPProperties   *xpl;
 
4866
                int j;
 
4867
                PTPObjectInfo   oinfo;  
 
4868
 
 
4869
                memset (&oinfo,0,sizeof(oinfo));
 
4870
                /* hmm, not necessary ... only if we would use it */
 
4871
                for (j=0;j<nrofprops;j++) {
 
4872
                        xpl = &props[j];
 
4873
                        switch (xpl->property) {
 
4874
                        case PTP_OPC_ParentObject:
 
4875
                                if (xpl->datatype != PTP_DTC_UINT32) {
 
4876
                                        ptp_debug (params, "ptp2/mtpfast: parentobject has type 0x%x???", xpl->datatype);
 
4877
                                        break;
 
4878
                                }
 
4879
                                oinfo.ParentObject = xpl->propval.u32;
 
4880
                                ptp_debug (params, "ptp2/mtpfast: parent 0x%x", xpl->propval.u32);
 
4881
                                break;
 
4882
                        case PTP_OPC_ObjectFormat:
 
4883
                                if (xpl->datatype != PTP_DTC_UINT16) {
 
4884
                                        ptp_debug (params, "ptp2/mtpfast: objectformat has type 0x%x???", xpl->datatype);
 
4885
                                        break;
 
4886
                                }
 
4887
                                oinfo.ObjectFormat = xpl->propval.u16;
 
4888
                                ptp_debug (params, "ptp2/mtpfast: ofc 0x%x", xpl->propval.u16);
 
4889
                                break;
 
4890
                        case PTP_OPC_ObjectSize:
 
4891
                                switch (xpl->datatype) {
 
4892
                                case PTP_DTC_UINT32:
 
4893
                                        oinfo.ObjectCompressedSize = xpl->propval.u32;
 
4894
                                        break;
 
4895
                                case PTP_DTC_UINT64:
 
4896
                                        oinfo.ObjectCompressedSize = xpl->propval.u64;
 
4897
                                        break;
 
4898
                                default:
 
4899
                                        ptp_debug (params, "ptp2/mtpfast: objectsize has type 0x%x???", xpl->datatype);
 
4900
                                        break;
 
4901
                                }
 
4902
                                ptp_debug (params, "ptp2/mtpfast: objectsize %u", xpl->propval.u32);
 
4903
                                break;
 
4904
                        case PTP_OPC_StorageID:
 
4905
                                if (xpl->datatype != PTP_DTC_UINT32) {
 
4906
                                        ptp_debug (params, "ptp2/mtpfast: storageid has type 0x%x???", xpl->datatype);
 
4907
                                        break;
 
4908
                                }
 
4909
                                oinfo.StorageID = xpl->propval.u32;
 
4910
                                ptp_debug (params, "ptp2/mtpfast: storageid 0x%x", xpl->propval.u32);
 
4911
                                break;
 
4912
                        case PTP_OPC_ProtectionStatus:/*UINT16*/
 
4913
                                if (xpl->datatype != PTP_DTC_UINT16) {
 
4914
                                        ptp_debug (params, "ptp2/mtpfast: protectionstatus has type 0x%x???", xpl->datatype);
 
4915
                                        break;
 
4916
                                }
 
4917
                                oinfo.ProtectionStatus = xpl->propval.u16;
 
4918
                                ptp_debug (params, "ptp2/mtpfast: protection 0x%x", xpl->propval.u16);
 
4919
                                break;
 
4920
                        case PTP_OPC_ObjectFileName:
 
4921
                                if (xpl->datatype != PTP_DTC_STR) {
 
4922
                                        ptp_debug (params, "ptp2/mtpfast: filename has type 0x%x???", xpl->datatype);
 
4923
                                        break;
 
4924
                                }
 
4925
                                if (xpl->propval.str) {
 
4926
                                        ptp_debug (params, "ptp2/mtpfast: filename %s", xpl->propval.str);
 
4927
                                        oinfo.Filename = strdup(xpl->propval.str);
 
4928
                                } else {
 
4929
                                        oinfo.Filename = NULL;
 
4930
                                }
 
4931
                                break;
 
4932
                        case PTP_OPC_DateCreated:
 
4933
                                if (xpl->datatype != PTP_DTC_STR) {
 
4934
                                        ptp_debug (params, "ptp2/mtpfast: datecreated has type 0x%x???", xpl->datatype);
 
4935
                                        break;
 
4936
                                }
 
4937
                                ptp_debug (params, "ptp2/mtpfast: capturedate %s", xpl->propval.str);
 
4938
                                oinfo.CaptureDate = ptp_unpack_PTPTIME (xpl->propval.str);
 
4939
                                break;
 
4940
                        case PTP_OPC_DateModified:
 
4941
                                if (xpl->datatype != PTP_DTC_STR) {
 
4942
                                        ptp_debug (params, "ptp2/mtpfast: datemodified has type 0x%x???", xpl->datatype);
 
4943
                                        break;
 
4944
                                }
 
4945
                                ptp_debug (params, "ptp2/mtpfast: moddate %s", xpl->propval.str);
 
4946
                                oinfo.ModificationDate = ptp_unpack_PTPTIME (xpl->propval.str);
 
4947
                                break;
 
4948
                        default:
 
4949
                                if ((xpl->property & 0xfff0) == 0xdc00)
 
4950
                                        ptp_debug (params, "ptp2/mtpfast:case %x type %x unhandled", xpl->property, xpl->datatype);
 
4951
                                break;
 
4952
                        }
 
4953
                }
 
4954
                if (!oinfo.Filename)
 
4955
                        /* i have one such file on my Creative */
 
4956
                        oinfo.Filename = strdup("<null>");
 
4957
#endif
 
4958
                ob->flags |= PTPOBJECT_MTPPROPLIST_LOADED;
 
4959
fallback:       ;
 
4960
        }
 
4961
        if ((ob->flags & want) == want)
 
4962
                return PTP_RC_OK;
 
4963
        ptp_debug (params, "ptp_object_want: oid 0x%08x, want flags %x, have only %x?", handle, want, ob->flags);
 
4964
        return PTP_RC_GeneralError;
4780
4965
}
4781
4966
 
 
4967
 
4782
4968
uint16_t
4783
4969
ptp_add_object_to_cache(PTPParams *params, uint32_t handle)
4784
4970
{
4785
 
        uint32_t n;
4786
 
        uint32_t *xhandler;
4787
 
        PTPObjectInfo *xoi;
4788
 
        
4789
 
        /* We have a new handle */
4790
 
        params->handles.n++;
4791
 
        n = params->handles.n;
4792
 
        
4793
 
        /* Insert the new handle */
4794
 
        xhandler = (uint32_t*) realloc(params->handles.Handler,
4795
 
                                       sizeof(uint32_t)*n);
4796
 
        if (!xhandler) {
4797
 
                /* Well, out of memory is no I/O error really... */
4798
 
                return PTP_ERROR_IO;
4799
 
        }
4800
 
        params->handles.Handler = xhandler;
4801
 
        params->handles.Handler[n-1] = handle;
4802
 
        
4803
 
        /* Insert a new object info struct and populate it */
4804
 
        xoi = (PTPObjectInfo*)realloc(params->objectinfo,
4805
 
                                      sizeof(PTPObjectInfo)*n);
4806
 
        if (!xoi) {
4807
 
                /* Well, out of memory is no I/O error really... */
4808
 
                return PTP_ERROR_IO;
4809
 
        }
4810
 
        params->objectinfo = xoi;
4811
 
        memset(&params->objectinfo[n-1], 0, sizeof(PTPObjectInfo));
4812
 
        ptp_getobjectinfo(params, handle, &params->objectinfo[n-1]);
4813
 
 
4814
 
        /* Update proplist if we use cached props */
4815
 
        if (params->props != NULL) {
4816
 
                MTPProperties *props = NULL;
4817
 
                MTPProperties *xprops;
4818
 
                int no_new_props = 0;
4819
 
                uint16_t ret;
4820
 
                
4821
 
                ret = ptp_mtp_getobjectproplist(params, handle, &props, &no_new_props);
4822
 
                if (ret != PTP_RC_OK) {
4823
 
                        return ret;
4824
 
                }
4825
 
                xprops = realloc(params->props, (params->nrofprops+no_new_props)*sizeof(MTPProperties));
4826
 
                if (!xprops) {
4827
 
                        free(props);
4828
 
                        /* Well, out of memory is no I/O error really... */
4829
 
                        return PTP_ERROR_IO;
4830
 
                }
4831
 
                params->props = xprops;
4832
 
                memcpy(&params->props[params->nrofprops],&props[0],no_new_props*sizeof(MTPProperties));
4833
 
                /* do not free the sub strings, we copied them above! Only free the array. */
4834
 
                free(props);
4835
 
                params->nrofprops += no_new_props;
4836
 
        }
4837
 
        return PTP_RC_OK;
 
4971
        PTPObject *ob;
 
4972
        return ptp_object_want (params, handle, PTPOBJECT_OBJECTINFO_LOADED|PTPOBJECT_MTPPROPLIST_LOADED, &ob);
4838
4973
}