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

« back to all changes in this revision

Viewing changes to src/ptp-pack.c

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-05-25 08:22:17 UTC
  • mto: (0.2.1 upstream) (16.1.8 sid)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100525082217-3jpyw97sxwiewb6r
Tags: upstream-1.0.3
ImportĀ upstreamĀ versionĀ 1.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
376
376
        totallen += di->unk_len*sizeof(uint32_t)+4;
377
377
        return;
378
378
}
 
379
 
 
380
static inline void
 
381
ptp_free_EOS_DI (PTPCanonEOSDeviceInfo *di)
 
382
{
 
383
        free (di->EventsSupported);
 
384
        free (di->DevicePropertiesSupported);
 
385
        free (di->unk);
 
386
}
379
387
        
380
388
/* ObjectHandles array pack/unpack */
381
389
 
1348
1356
                                   i, propxtype, proptype, dpd->DataType, propxcnt);
1349
1357
                        dpd->FormFlag = PTP_DPFF_Enumeration;
1350
1358
                        dpd->FORM.Enum.NumberOfValues = propxcnt;
 
1359
                        if (dpd->FORM.Enum.SupportedValue) free (dpd->FORM.Enum.SupportedValue);
1351
1360
                        dpd->FORM.Enum.SupportedValue = malloc (sizeof (PTPPropertyValue)*propxcnt);
1352
1361
 
1353
1362
                        switch (proptype) {
1460
1469
                                /* set DataType */
1461
1470
                                switch (proptype) {
1462
1471
                                case PTP_DPC_CANON_EOS_CameraTime:
1463
 
                                case PTP_DPC_CANON_EOS_EVFOutputDevice:
1464
1472
                                case PTP_DPC_CANON_EOS_AvailableShots:
1465
1473
                                case PTP_DPC_CANON_EOS_CaptureDestination:
1466
1474
                                case PTP_DPC_CANON_EOS_WhiteBalanceXA:
1473
1481
                                case PTP_DPC_CANON_EOS_StroboFiring:
1474
1482
                                        dpd->DataType = PTP_DTC_UINT32;
1475
1483
                                        break;
 
1484
                                /* enumeration for AEM is never provided, but is available to set */
 
1485
                                case PTP_DPC_CANON_EOS_AutoExposureMode:
 
1486
                                        dpd->DataType = PTP_DTC_UINT16;
 
1487
                                        dpd->FormFlag = PTP_DPFF_Enumeration;
 
1488
                                        dpd->FORM.Enum.NumberOfValues = 0;
 
1489
                                        break;
1476
1490
                                case PTP_DPC_CANON_EOS_Aperture:
1477
1491
                                case PTP_DPC_CANON_EOS_ShutterSpeed:
1478
1492
                                case PTP_DPC_CANON_EOS_ISOSpeed:
1479
1493
                                case PTP_DPC_CANON_EOS_FocusMode:
1480
 
                                case PTP_DPC_CANON_EOS_AutoExposureMode:
1481
1494
                                case PTP_DPC_CANON_EOS_ColorSpace:
1482
1495
                                case PTP_DPC_CANON_EOS_BatteryPower:
1483
1496
                                case PTP_DPC_CANON_EOS_BatterySelect:
1486
1499
                                case PTP_DPC_CANON_EOS_AEB:
1487
1500
                                case PTP_DPC_CANON_EOS_BracketMode:
1488
1501
                                case PTP_DPC_CANON_EOS_QuickReviewTime:
 
1502
                                case PTP_DPC_CANON_EOS_EVFMode:
 
1503
                                case PTP_DPC_CANON_EOS_EVFOutputDevice:
1489
1504
                                        dpd->DataType = PTP_DTC_UINT16;
1490
1505
                                        break;
1491
1506
                                case PTP_DPC_CANON_EOS_PictureStyle:
1531
1546
                                        /* custom func entries look like this on the 400D: '5 0 0 0 ?' = 4 bytes size + 1 byte data */
1532
1547
                                        data += 4;
1533
1548
                                        break;
 
1549
                                /* ImageFormat special handling */
 
1550
                                case PTP_DPC_CANON_EOS_ImageFormat:
 
1551
                                case PTP_DPC_CANON_EOS_ImageFormatCF:
 
1552
                                case PTP_DPC_CANON_EOS_ImageFormatSD:
 
1553
                                case PTP_DPC_CANON_EOS_ImageFormatExtHD:
 
1554
                                        dpd->DataType = PTP_DTC_UINT16;
 
1555
                                        dpd->FactoryDefaultValue.u16    = ptp_unpack_EOS_ImageFormat( params, &data );
 
1556
                                        dpd->CurrentValue.u16           = dpd->FactoryDefaultValue.u16;
 
1557
                                        ptp_debug (params,"event %d: decoded imageformat, currentvalue of %x is %x", i, proptype, dpd->CurrentValue.u16);
 
1558
                                        break;
1534
1559
                                /* yet unknown 32bit props */
1535
1560
                                case PTP_DPC_CANON_EOS_ColorTemperature:
1536
1561
                                case PTP_DPC_CANON_EOS_WftStatus:
1538
1563
                                case PTP_DPC_CANON_EOS_CardExtension:
1539
1564
                                case PTP_DPC_CANON_EOS_TempStatus:
1540
1565
                                case PTP_DPC_CANON_EOS_PhotoStudioMode:
1541
 
                                case PTP_DPC_CANON_EOS_EVFMode:
1542
1566
                                case PTP_DPC_CANON_EOS_DepthOfFieldPreview:
1543
1567
                                case PTP_DPC_CANON_EOS_EVFSharpness:
1544
1568
                                case PTP_DPC_CANON_EOS_EVFWBMode:
1550
1574
                                case PTP_DPC_CANON_EOS_MovSize:
1551
1575
                                case PTP_DPC_CANON_EOS_DepthOfField:
1552
1576
                                case PTP_DPC_CANON_EOS_LvViewTypeSelect:
1553
 
                                case PTP_DPC_CANON_EOS_ImageFormat:
1554
 
                                case PTP_DPC_CANON_EOS_ImageFormatCF:
1555
 
                                case PTP_DPC_CANON_EOS_ImageFormatSD:
1556
 
                                case PTP_DPC_CANON_EOS_ImageFormatExtHD:
1557
1577
                                case PTP_DPC_CANON_EOS_CustomFuncEx:
1558
 
//                                      dpd->DataType = PTP_DTC_UINT32;
 
1578
                                        dpd->DataType = PTP_DTC_UINT32;
1559
1579
                                        ptp_debug (params, "event %d: Unknown EOS property %04x, datasize is %d, using uint32", i ,proptype, size-PTP_ece_Prop_Val_Data);
1560
1580
                                        if ((size-PTP_ece_Prop_Val_Data) % sizeof(uint32_t) != 0)
1561
1581
                                                ptp_debug (params, "event %d: Warning: datasize modulo sizeof(uint32) is not 0: ", i, (size-PTP_ece_Prop_Val_Data) % sizeof(uint32_t) );
1590
1610
                                        dpd->FactoryDefaultValue.str    = ptp_unpack_string(params, data, 0, &len);
1591
1611
                                        dpd->CurrentValue.str           = ptp_unpack_string(params, data, 0, &len);
1592
1612
#else
 
1613
                                        if (dpd->FactoryDefaultValue.str) free (dpd->FactoryDefaultValue.str);
1593
1614
                                        dpd->FactoryDefaultValue.str    = strdup( (char*)data );
 
1615
 
 
1616
                                        if (dpd->CurrentValue.str) free (dpd->CurrentValue.str);
1594
1617
                                        dpd->CurrentValue.str           = strdup( (char*)data );
1595
1618
#endif
1596
1619
                                        ptp_debug (params,"event %d: currentvalue of %x is %s", i, proptype, dpd->CurrentValue.str);
1601
1624
                                        break;
1602
1625
                                }
1603
1626
 
1604
 
                                /* ImageFormat special handling */
1605
 
                                switch (proptype) {
1606
 
                                case PTP_DPC_CANON_EOS_ImageFormat:
1607
 
                                case PTP_DPC_CANON_EOS_ImageFormatCF:
1608
 
                                case PTP_DPC_CANON_EOS_ImageFormatSD:
1609
 
                                case PTP_DPC_CANON_EOS_ImageFormatExtHD:
1610
 
                                        dpd->DataType = PTP_DTC_UINT16;
1611
 
                                        dpd->FactoryDefaultValue.u16    = ptp_unpack_EOS_ImageFormat( params, &data );
1612
 
                                        dpd->CurrentValue.u16           = dpd->FactoryDefaultValue.u16;
1613
 
                                        ptp_debug (params,"event %d: currentvalue of %x is %x", i, proptype, dpd->CurrentValue.u8);
1614
 
                                        break;
1615
 
                                }
1616
 
 
1617
1627
                                break;
1618
1628
                }
1619
1629
                case 0: /* end marker */
1661
1671
                if ((size == 8) && (type == 0))
1662
1672
                        break;
1663
1673
        }
1664
 
 
 
1674
        if (!entries) {
 
1675
                free (*ce);
 
1676
                *ce = NULL;
 
1677
        }
1665
1678
        return entries;
1666
1679
}
1667
1680
 
1685
1698
        *cnt = dtoh16a(&data[PTP_nikon_ec_Length]);
1686
1699
        if (*cnt > (len-PTP_nikon_ec_Code)/PTP_nikon_ec_Size) /* broken cnt? */
1687
1700
                return;
 
1701
        if (!*cnt)
 
1702
                return;
 
1703
 
1688
1704
        *ec = malloc(sizeof(PTPContainer)*(*cnt));
1689
1705
        
1690
1706
        for (i=0;i<*cnt;i++) {