📄 properties.c
字号:
/* properties.c * * Copyright (C) 2005 Mariusz Woloszyn <emsi@ipartners.pl> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include <config.h>#include "ptp.h"#include <string.h>#include <stdio.h>#include <stdlib.h>#ifdef ENABLE_NLS# include <libintl.h># undef _# define _(String) dgettext (PACKAGE, String)# ifdef gettext_noop# define N_(String) gettext_noop (String)# else# define N_(String) (String)# endif#else# define textdomain(String) (String)# define gettext(String) (String)# define dgettext(Domain,Message) (Message)# define dcgettext(Domain,Message,Type) (Message)# define bindtextdomain(Domain,Directory) (Domain)# define _(String) (String)# define N_(String) (String)#endif#define SVALLEN 256#define SVALRET(s) { \ if (n>=SVALLEN) s[SVALLEN]='\0'; \ return s;\}intptp_property_issupported(PTPParams* params, uint16_t property){ int i=0; for (;i<params->deviceinfo.DevicePropertiesSupported_len;i++) { if (params->deviceinfo.DevicePropertiesSupported[i]==property) return 1; } return 0;}static struct { uint16_t dpc; const char *txt;} ptp_device_properties[] = { {PTP_DPC_Undefined, N_("PTP Undefined Property")}, {PTP_DPC_BatteryLevel, N_("Battery Level")}, {PTP_DPC_FunctionalMode, N_("Functional Mode")}, {PTP_DPC_ImageSize, N_("Image Size")}, {PTP_DPC_CompressionSetting, N_("Compression Setting")}, {PTP_DPC_WhiteBalance, N_("White Balance")}, {PTP_DPC_RGBGain, N_("RGB Gain")}, {PTP_DPC_FNumber, N_("F-Number")}, {PTP_DPC_FocalLength, N_("Focal Length")}, {PTP_DPC_FocusDistance, N_("Focus Distance")}, {PTP_DPC_FocusMode, N_("Focus Mode")}, {PTP_DPC_ExposureMeteringMode, N_("Exposure Metering Mode")}, {PTP_DPC_FlashMode, N_("Flash Mode")}, {PTP_DPC_ExposureTime, N_("Exposure Time")}, {PTP_DPC_ExposureProgramMode, N_("Exposure Program Mode")}, {PTP_DPC_ExposureIndex, N_("Exposure Index (film speed ISO)")}, {PTP_DPC_ExposureBiasCompensation, N_("Exposure Bias Compensation")}, {PTP_DPC_DateTime, N_("Date Time")}, {PTP_DPC_CaptureDelay, N_("Pre-Capture Delay")}, {PTP_DPC_StillCaptureMode, N_("Still Capture Mode")}, {PTP_DPC_Contrast, N_("Contrast")}, {PTP_DPC_Sharpness, N_("Sharpness")}, {PTP_DPC_DigitalZoom, N_("Digital Zoom")}, {PTP_DPC_EffectMode, N_("Effect Mode")}, {PTP_DPC_BurstNumber, N_("Burst Number")}, {PTP_DPC_BurstInterval, N_("Burst Interval")}, {PTP_DPC_TimelapseNumber, N_("Timelapse Number")}, {PTP_DPC_TimelapseInterval, N_("Timelapse Interval")}, {PTP_DPC_FocusMeteringMode, N_("Focus Metering Mode")}, {PTP_DPC_UploadURL, N_("Upload URL")}, {PTP_DPC_Artist, N_("Artist")}, {PTP_DPC_CopyrightInfo, N_("Copyright Info")}, {0,NULL}};static struct { uint16_t dpc; const char *txt;} ptp_device_properties_EK[] = { {PTP_DPC_EK_ColorTemperature, N_("EK Color Temperature")}, {PTP_DPC_EK_DateTimeStampFormat,N_("EK Date Time Stamp Format")}, {PTP_DPC_EK_BeepMode, N_("EK Beep Mode")}, {PTP_DPC_EK_VideoOut, N_("EK Video Out")}, {PTP_DPC_EK_PowerSaving, N_("EK Power Saving")}, {PTP_DPC_EK_UI_Language, N_("EK UI Language")}, {0,NULL}};static struct { uint16_t dpc; const char *txt;} ptp_device_properties_CANON[] = { {PTP_DPC_CANON_BeepMode, N_("CANON Beep Mode")}, {PTP_DPC_CANON_UnixTime, N_("CANON Time measured in" " secondssince 01-01-1970")}, {PTP_DPC_CANON_FlashMemory, N_("CANON Flash Card Capacity")}, {PTP_DPC_CANON_CameraModel, N_("CANON Camera Model")}, {0,NULL}};/** * Properties reported by Corey Manders and Mehreen Chaudary, revised for * D70 by Mariusz Woloszyn **/static struct { uint16_t dpc; const char *txt;} ptp_device_properties_NIKON[] = { {PTP_DPC_NIKON_ShootingBank, N_("NIKON Shooting Bank")}, {PTP_DPC_NIKON_ShootingBankNameA, N_("NIKON Shooting Bank Name A")}, {PTP_DPC_NIKON_ShootingBankNameB, N_("NIKON Shooting Bank Name B")}, {PTP_DPC_NIKON_ShootingBankNameC, N_("NIKON Shooting Bank Name C")}, {PTP_DPC_NIKON_ShootingBankNameD, N_("NIKON Shooting Bank Name D")}, {PTP_DPC_NIKON_RawCompression, N_("NIKON Raw Compression")}, {PTP_DPC_NIKON_WhiteBalanceAutoBias, N_("NIKON White Balance Auto Bias")}, {PTP_DPC_NIKON_WhiteBalanceTungstenBias, N_("NIKON White Balance Tungsten Bias")}, {PTP_DPC_NIKON_WhiteBalanceFlourescentBias, N_("NIKON White Balance Flourescent Bias")}, {PTP_DPC_NIKON_WhiteBalanceDaylightBias, N_("NIKON White Balance Daylight Bias")}, {PTP_DPC_NIKON_WhiteBalanceFlashBias, N_("NIKON White Balance Flash Bias")}, {PTP_DPC_NIKON_WhiteBalanceCloudyBias, N_("NIKON White Balance Cloudy Bias")}, {PTP_DPC_NIKON_WhiteBalanceShadeBias, N_("NIKON White Balance Shade Bias")}, {PTP_DPC_NIKON_WhiteBalanceColorTemperature, N_("NIKON White Balance Color Temperature")}, {PTP_DPC_NIKON_ImageSharpening, N_("NIKON Image Sharpening")}, {PTP_DPC_NIKON_ToneCompensation, N_("NIKON Tone Compensation")}, {PTP_DPC_NIKON_ColorMode, N_("NIKON Color Mode")}, {PTP_DPC_NIKON_HueAdjustment, N_("NIKON Hue Adjustment")}, {PTP_DPC_NIKON_NonCPULensDataFocalLength, N_("NIKON Non CPU Lens Data Focal Length")}, {PTP_DPC_NIKON_NonCPULensDataMaximumAperture, N_("NIKON Non CPU Lens Data Maximum Aperture")}, {PTP_DPC_NIKON_CSMMenuBankSelect, N_("NIKON CSM Menu Bank Select")}, {PTP_DPC_NIKON_MenuBankNameA, N_("NIKON Menu Bank Name A")}, {PTP_DPC_NIKON_MenuBankNameB, N_("NIKON Menu Bank Name B")}, {PTP_DPC_NIKON_MenuBankNameC, N_("NIKON Menu Bank Name C")}, {PTP_DPC_NIKON_MenuBankNameD, N_("NIKON Menu Bank Name D")}, {PTP_DPC_NIKON_A1AFCModePriority, N_("NIKON (A1) AFC Mode Priority")}, {PTP_DPC_NIKON_A2AFSModePriority, N_("NIKON (A2) AFS Mode Priority")}, {PTP_DPC_NIKON_A3GroupDynamicAF, N_("NIKON (A3) Group Dynamic AF")}, {PTP_DPC_NIKON_A4AFActivation, N_("NIKON (A4) AF Activation")}, {PTP_DPC_NIKON_A5FocusAreaIllumManualFocus, N_("NIKON (A5) Focus Area Illum Manual Focus")}, {PTP_DPC_NIKON_FocusAreaIllumContinuous, N_("NIKON Focus Area Illum Continuous")}, {PTP_DPC_NIKON_FocusAreaIllumWhenSelected, N_("NIKON Focus Area Illum When Selected")}, {PTP_DPC_NIKON_FocusAreaWrap, N_("NIKON Focus Area Wrap")}, {PTP_DPC_NIKON_A7VerticalAFON, N_("NIKON (A7) Vertical AF ON")}, {PTP_DPC_NIKON_ISOAuto, N_("NIKON ISO Auto")}, {PTP_DPC_NIKON_B2ISOStep, N_("NIKON (B2) ISO Step")}, {PTP_DPC_NIKON_EVStep, N_("NIKON EV Step")}, {PTP_DPC_NIKON_B4ExposureCompEv, N_("NIKON (B4) Exposure Comp Ev")}, {PTP_DPC_NIKON_ExposureCompensation, N_("NIKON Exposure Compensation by Command Dial only")}, {PTP_DPC_NIKON_CenterWeightArea, N_("NIKON Center Weighted Area")}, {PTP_DPC_NIKON_AELockMode, N_("NIKON AE Lock Mode")}, {PTP_DPC_NIKON_AELAFLMode, N_("NIKON AE-L/AF-L Mode")}, {PTP_DPC_NIKON_MeterOff, N_("NIKON Meter-Off")}, {PTP_DPC_NIKON_SelfTimer, N_("NIKON Self Timer")}, {PTP_DPC_NIKON_MonitorOff, N_("NIKON Monitor Off")}, {PTP_DPC_NIKON_D1ShootingSpeed, N_("NIKON (D1) Shooting Speed")}, {PTP_DPC_NIKON_ExposureTime, N_("NIKON Exposure Time")}, {PTP_DPC_NIKON_ACPower, N_("NIKON AC Power")}, {PTP_DPC_NIKON_D2MaximumShots, N_("NIKON (D2) Maximum Shots")}, {PTP_DPC_NIKON_D3ExpDelayMode, N_("NIKON (D3) ExpDelayMode")}, {PTP_DPC_NIKON_LongExposureNoiseReduction, N_("NIKON Long Exposure Noise Reduction")}, {PTP_DPC_NIKON_FileNumberSequence, N_("NIKON File Number Sequence")}, {PTP_DPC_NIKON_D6ControlPanelFinderRearControl, N_("NIKON (D6) Control Panel Finder Rear Control")}, {PTP_DPC_NIKON_ControlPanelFinderViewfinder, N_("NIKON Control Panel Finder Viewfinder")}, {PTP_DPC_NIKON_D7Illumination, N_("NIKON (D7) Illumination")}, {PTP_DPC_NIKON_E1FlashSyncSpeed, N_("NIKON (E1) Flash Sync Speed")}, {PTP_DPC_NIKON_FlashShutterSpeed, N_("NIKON Slowest Flash Shutter Speed")}, {PTP_DPC_NIKON_E3AAFlashMode, N_("NIKON (E3) AA Flash Mode")}, {PTP_DPC_NIKON_E4ModelingFlash, N_("NIKON (E4) Modeling Flash")}, {PTP_DPC_NIKON_BracketSet, N_("NIKON Bracket Set")}, {PTP_DPC_NIKON_E6ManualModeBracketing, N_("NIKON (E6) Manual Mode Bracketing")}, {PTP_DPC_NIKON_BracketOrder, N_("NIKON Bracket Order")}, {PTP_DPC_NIKON_E8AutoBracketSelection, N_("NIKON (E8) Auto Bracket Selection")}, {PTP_DPC_NIKON_BracketingSet, N_("NIKON Auto Bracketing Set")}, {PTP_DPC_NIKON_F1CenterButtonShootingMode, N_("NIKON (F1) Center Button Shooting Mode")}, {PTP_DPC_NIKON_CenterButtonPlaybackMode, N_("NIKON Center Button Playback Mode")}, {PTP_DPC_NIKON_F2Multiselector, N_("NIKON (F2) Multiselector")}, {PTP_DPC_NIKON_F3PhotoInfoPlayback, N_("NIKON (F3) PhotoInfoPlayback")}, {PTP_DPC_NIKON_F4AssignFuncButton, N_("NIKON (F4) Assign Function Button")}, {PTP_DPC_NIKON_F5CustomizeCommDials, N_("NIKON (F5) Customize Comm Dials")}, {PTP_DPC_NIKON_ReverseCommandDial, N_("NIKON Reverse Command Dials")}, {PTP_DPC_NIKON_ApertureSetting, N_("NIKON Aperture Setting")}, {PTP_DPC_NIKON_MenusAndPlayback, N_("NIKON Menus and Playback")}, {PTP_DPC_NIKON_F6ButtonsAndDials, N_("NIKON (F6) Buttons and Dials")}, {PTP_DPC_NIKON_NoCFCard, N_("NIKON No CF Card")}, {PTP_DPC_NIKON_ImageRotation, N_("NIKON Image Rotation")}, {PTP_DPC_NIKON_Bracketing, N_("NIKON Bracketing")}, {PTP_DPC_NIKON_ExposureBracketingIntervalDist, N_("NIKON Exposure Bracketing Interval Distance")}, {PTP_DPC_NIKON_BracketingProgram, N_("NIKON Bracketing Program")}, {PTP_DPC_NIKON_WhiteBalanceBracketStep, N_("NIKON White Balance Bracket Step")}, {PTP_DPC_NIKON_AutofocusLCDTopMode2, N_("NIKON Autofocus LCD Top Mode 2")}, {PTP_DPC_NIKON_AutofocusArea, N_("NIKON Autofocus Area selector")}, {PTP_DPC_NIKON_LightMeter, N_("NIKON Light Meter")}, {PTP_DPC_NIKON_ExposureApertureLock, N_("NIKON Exposure Aperture Lock")}, {PTP_DPC_NIKON_MaximumShots, N_("NIKON Maximum Shots")}, {PTP_DPC_NIKON_AFLLock, N_("NIKON AF-L Locked")}, {PTP_DPC_NIKON_BeepOff, N_("NIKON Beep")}, {PTP_DPC_NIKON_AutofocusMode, N_("NIKON Autofocus Mode")}, {PTP_DPC_NIKON_AFAssist, N_("NIKON AF Assist Lamp")}, {PTP_DPC_NIKON_PADVPMode, N_("NIKON Auto ISO shutter limit for P A and DVP Mode")}, {PTP_DPC_NIKON_ImageReview, N_("NIKON Image Review")}, {PTP_DPC_NIKON_GridDisplay, N_("NIKON Viewfinder Grid Display")}, {PTP_DPC_NIKON_AFAreaIllumination, N_("NIKON AF Area Illumination")}, {PTP_DPC_NIKON_FlashMode, N_("NIKON Flash Mode")}, {PTP_DPC_NIKON_FlashCommanderMode, N_("NIKON Flash Commander Mode")}, {PTP_DPC_NIKON_FlashSign, N_("NIKON Flash Signal Indicator")}, {PTP_DPC_NIKON_GridDisplay, N_("NIKON Grid Display")}, {PTP_DPC_NIKON_FlashModeManualPower, N_("NIKON Flash Manual Mode Power")}, {PTP_DPC_NIKON_FlashModeCommanderPower, N_("NIKON Flash Commander Mode Power")}, {PTP_DPC_NIKON_FlashExposureCompensation, N_("NIKON Flash Exposure Compensation")}, {PTP_DPC_NIKON_RemoteTimeout, N_("NIKON Remote Timeout")}, {PTP_DPC_NIKON_ImageCommentString, N_("NIKON Image Comment String")}, {PTP_DPC_NIKON_ImageCommentAttach, N_("NIKON Image Comment Attach")}, {PTP_DPC_NIKON_FlashOpen, N_("NIKON Flash Open")}, {PTP_DPC_NIKON_FlashCharged, N_("NIKON Flash Charged")}, {PTP_DPC_NIKON_LensID, N_("NIKON Lens ID")}, {PTP_DPC_NIKON_FocalLengthMin, N_("NIKON Min. Focal Length")}, {PTP_DPC_NIKON_FocalLengthMax, N_("NIKON Max. Focal Length")}, {PTP_DPC_NIKON_MaxApAtMinFocalLength, N_("NIKON Max. Aperture at Min. Focal Length")}, {PTP_DPC_NIKON_MaxApAtMaxFocalLength, N_("NIKON Max. Aperture at Max. Focal Length")}, {PTP_DPC_NIKON_LowLight, N_("NIKON Low Light Indicator")}, {PTP_DPC_NIKON_CSMMenu, N_("NIKON CSM Menu")}, {PTP_DPC_NIKON_OptimizeImage, N_("NIKON Optimize Image")}, {PTP_DPC_NIKON_AutoExposureLock, N_("NIKON AE Lock")}, {PTP_DPC_NIKON_AutoFocusLock, N_("NIKON AF Lock")}, {PTP_DPC_NIKON_CameraOrientation, N_("NIKON Camera orientation")}, {PTP_DPC_NIKON_BracketingIncrement, N_("NIKON Bracketing Increment")}, {PTP_DPC_NIKON_Saturation, N_("NIKON Saturation")}, {0,NULL}};/* return ptp property name */const char*ptp_prop_getname(PTPParams* params, uint16_t dpc){ int i; /* Device Property descriptions */ for (i=0; ptp_device_properties[i].txt!=NULL; i++) if (ptp_device_properties[i].dpc==dpc) return (ptp_device_properties[i].txt); /*if (dpc|PTP_DPC_EXTENSION_MASK==PTP_DPC_EXTENSION)*/ switch (params->deviceinfo.VendorExtensionID) { case PTP_VENDOR_EASTMAN_KODAK: for (i=0; ptp_device_properties_EK[i].txt!=NULL; i++) if (ptp_device_properties_EK[i].dpc==dpc) return (ptp_device_properties_EK[i].txt); break; case PTP_VENDOR_CANON: for (i=0; ptp_device_properties_CANON[i].txt!=NULL; i++) if (ptp_device_properties_CANON[i].dpc==dpc) return (ptp_device_properties_CANON[i].txt); break; case PTP_VENDOR_NIKON: for (i=0; ptp_device_properties_NIKON[i].txt!=NULL; i++) if (ptp_device_properties_NIKON[i].dpc==dpc) return (ptp_device_properties_NIKON[i].txt); break; } return NULL;}uint16_tptp_prop_getcodebyname(PTPParams* params, char* name){ int i; for (i=0; ptp_device_properties[i].txt!=NULL; i++) if (!strncasecmp(ptp_device_properties[i].txt,name, strlen(name)))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -