| OLD | NEW |
| 1 /* ptp.c | 1 /* ptp.c |
| 2 * | 2 * |
| 3 * Copyright (C) 2001-2004 Mariusz Woloszyn <emsi@ipartners.pl> | 3 * Copyright (C) 2001-2004 Mariusz Woloszyn <emsi@ipartners.pl> |
| 4 * Copyright (C) 2003-2012 Marcus Meissner <marcus@jet.franken.de> | 4 * Copyright (C) 2003-2012 Marcus Meissner <marcus@jet.franken.de> |
| 5 * Copyright (C) 2006-2008 Linus Walleij <triad@df.lth.se> | 5 * Copyright (C) 2006-2008 Linus Walleij <triad@df.lth.se> |
| 6 * Copyright (C) 2007 Tero Saarni <tero.saarni@gmail.com> | 6 * Copyright (C) 2007 Tero Saarni <tero.saarni@gmail.com> |
| 7 * Copyright (C) 2009 Axel Waggershauser <awagger@web.de> | 7 * Copyright (C) 2009 Axel Waggershauser <awagger@web.de> |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Lesser General Public | 10 * modify it under the terms of the GNU Lesser General Public |
| 11 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
| 12 * version 2 of the License, or (at your option) any later version. | 12 * version 2 of the License, or (at your option) any later version. |
| 13 * | 13 * |
| 14 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 * Lesser General Public License for more details. | 17 * Lesser General Public License for more details. |
| 18 * | 18 * |
| 19 * You should have received a copy of the GNU Lesser General Public | 19 * You should have received a copy of the GNU Lesser General Public |
| 20 * License along with this library; if not, write to the | 20 * License along with this library; if not, write to the |
| 21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 * Boston, MA 02111-1307, USA. | 22 * Boston, MA 02110-1301 USA |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #define _BSD_SOURCE | 25 #define _DEFAULT_SOURCE |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "ptp.h" | 27 #include "ptp.h" |
| 28 | 28 |
| 29 #ifdef HAVE_LIBXML2 |
| 30 # include <libxml/parser.h> |
| 31 #endif |
| 32 |
| 29 #include <stdlib.h> | 33 #include <stdlib.h> |
| 30 #include <stdarg.h> | 34 #include <stdarg.h> |
| 31 #include <stdio.h> | 35 #include <stdio.h> |
| 32 #include <string.h> | 36 #include <string.h> |
| 33 #include <unistd.h> | 37 #ifdef HAVE_UNISTD_H |
| 38 # include <unistd.h> |
| 39 #endif |
| 34 | 40 |
| 35 #ifdef ENABLE_NLS | 41 #ifdef ENABLE_NLS |
| 36 # include <libintl.h> | 42 # include <libintl.h> |
| 37 # undef _ | 43 # undef _ |
| 38 # define _(String) dgettext (PACKAGE, String) | 44 # define _(String) dgettext (PACKAGE, String) |
| 39 # ifdef gettext_noop | 45 # ifdef gettext_noop |
| 40 # define N_(String) gettext_noop (String) | 46 # define N_(String) gettext_noop (String) |
| 41 # else | 47 # else |
| 42 # define N_(String) (String) | 48 # define N_(String) (String) |
| 43 # endif | 49 # endif |
| 44 #else | 50 #else |
| 45 # define textdomain(String) (String) | 51 # define textdomain(String) (String) |
| 46 # define gettext(String) (String) | 52 # define gettext(String) (String) |
| 47 # define dgettext(Domain,Message) (Message) | 53 # define dgettext(Domain,Message) (Message) |
| 48 # define dcgettext(Domain,Message,Type) (Message) | 54 # define dcgettext(Domain,Message,Type) (Message) |
| 49 # define bindtextdomain(Domain,Directory) (Domain) | 55 # define bindtextdomain(Domain,Directory) (Domain) |
| 50 # define _(String) (String) | 56 # define _(String) (String) |
| 51 # define N_(String) (String) | 57 # define N_(String) (String) |
| 52 #endif | 58 #endif |
| 53 | 59 |
| 54 #define CHECK_PTP_RC(result)» {uint16_t r=(result); if (r!=PTP_RC_OK) return r
;} | 60 #define CHECK_PTP_RC(RESULT) do { uint16_t r = (RESULT); if (r != PTP_RC_OK) ret
urn r; } while(0) |
| 55 | 61 |
| 56 #define PTP_CNT_INIT(cnt) {memset(&cnt,0,sizeof(cnt));} | 62 static inline void |
| 63 ptp_init_container(PTPContainer* ptp, uint16_t code, int n_param, ...) |
| 64 { |
| 65 » va_list»args; |
| 66 » int» i; |
| 67 |
| 68 » memset(ptp, 0, sizeof(*ptp)); |
| 69 » ptp->Code = code; |
| 70 » ptp->Nparam = n_param; |
| 71 |
| 72 » va_start(args, n_param); |
| 73 » for (i=0; i<n_param; ++i) |
| 74 » » (&ptp->Param1)[i] = va_arg(args, uint32_t); |
| 75 » va_end(args); |
| 76 } |
| 77 |
| 78 #define NARGS_SEQ(_1,_2,_3,_4,_5,_6,_7,_8,N,...) N |
| 79 #define NARGS(...) NARGS_SEQ(-1, ##__VA_ARGS__, 7, 6, 5, 4, 3, 2, 1, 0) |
| 80 |
| 81 #define PTP_CNT_INIT(PTP, CODE, ...) \ |
| 82 » ptp_init_container(&PTP, CODE, NARGS(__VA_ARGS__), ##__VA_ARGS__) |
| 57 | 83 |
| 58 static uint16_t ptp_exit_recv_memory_handler (PTPDataHandler*,unsigned char**,un
signed long*); | 84 static uint16_t ptp_exit_recv_memory_handler (PTPDataHandler*,unsigned char**,un
signed long*); |
| 59 static uint16_t ptp_init_recv_memory_handler(PTPDataHandler*); | 85 static uint16_t ptp_init_recv_memory_handler(PTPDataHandler*); |
| 60 static uint16_t ptp_init_send_memory_handler(PTPDataHandler*,unsigned char*,unsi
gned long len); | 86 static uint16_t ptp_init_send_memory_handler(PTPDataHandler*,unsigned char*,unsi
gned long len); |
| 61 static uint16_t ptp_exit_send_memory_handler (PTPDataHandler *handler); | 87 static uint16_t ptp_exit_send_memory_handler (PTPDataHandler *handler); |
| 62 | 88 |
| 63 void | 89 void |
| 64 ptp_debug (PTPParams *params, const char *format, ...) | 90 ptp_debug (PTPParams *params, const char *format, ...) |
| 65 { | 91 { |
| 66 va_list args; | 92 va_list args; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 93 } | 119 } |
| 94 va_end (args); | 120 va_end (args); |
| 95 } | 121 } |
| 96 | 122 |
| 97 /* Pack / unpack functions */ | 123 /* Pack / unpack functions */ |
| 98 | 124 |
| 99 #include "ptp-pack.c" | 125 #include "ptp-pack.c" |
| 100 | 126 |
| 101 /* major PTP functions */ | 127 /* major PTP functions */ |
| 102 | 128 |
| 103 /* Transaction data phase description */ | |
| 104 #define PTP_DP_NODATA 0x0000 /* no data phase */ | |
| 105 #define PTP_DP_SENDDATA 0x0001 /* sending data */ | |
| 106 #define PTP_DP_GETDATA 0x0002 /* receiving data */ | |
| 107 #define PTP_DP_DATA_MASK 0x00ff /* data phase mask */ | |
| 108 | |
| 109 /** | 129 /** |
| 110 * ptp_transaction: | 130 * ptp_transaction: |
| 111 * params: PTPParams* | 131 * params: PTPParams* |
| 112 * PTPContainer* ptp - general ptp container | 132 * PTPContainer* ptp - general ptp container |
| 113 * uint16_t flags - lower 8 bits - data phase description | 133 * uint16_t flags - lower 8 bits - data phase description |
| 114 * unsigned int sendlen - senddata phase data length | 134 * unsigned int sendlen - senddata phase data length |
| 115 * char** data - send or receive data buffer pointer | 135 * char** data - send or receive data buffer pointer |
| 116 * int* recvlen - receive data length | 136 * int* recvlen - receive data length |
| 117 * | 137 * |
| 118 * Performs PTP transaction. ptp is a PTPContainer with appropriate fields | 138 * Performs PTP transaction. ptp is a PTPContainer with appropriate fields |
| 119 * filled in (i.e. operation code and parameters). It's up to caller to do | 139 * filled in (i.e. operation code and parameters). It's up to caller to do |
| 120 * so. | 140 * so. |
| 121 * The flags decide thether the transaction has a data phase and what is its | 141 * The flags decide thether the transaction has a data phase and what is its |
| 122 * direction (send or receive). | 142 * direction (send or receive). |
| 123 * If transaction is sending data the sendlen should contain its length in | 143 * If transaction is sending data the sendlen should contain its length in |
| 124 * bytes, otherwise it's ignored. | 144 * bytes, otherwise it's ignored. |
| 125 * The data should contain an address of a pointer to data going to be sent | 145 * The data should contain an address of a pointer to data going to be sent |
| 126 * or is filled with such a pointer address if data are received depending | 146 * or is filled with such a pointer address if data are received depending |
| 127 * od dataphase direction (send or received) or is beeing ignored (no | 147 * od dataphase direction (send or received) or is beeing ignored (no |
| 128 * dataphase). | 148 * dataphase). |
| 129 * The memory for a pointer should be preserved by the caller, if data are | 149 * The memory for a pointer should be preserved by the caller, if data are |
| 130 * beeing retreived the appropriate amount of memory is beeing allocated | 150 * beeing retreived the appropriate amount of memory is beeing allocated |
| 131 * (the caller should handle that!). | 151 * (the caller should handle that!). |
| 132 * | 152 * |
| 133 * Return values: Some PTP_RC_* code. | 153 * Return values: Some PTP_RC_* code. |
| 134 * Upon success PTPContainer* ptp contains PTP Response Phase container with | 154 * Upon success PTPContainer* ptp contains PTP Response Phase container with |
| 135 * all fields filled in. | 155 * all fields filled in. |
| 136 **/ | 156 **/ |
| 137 static uint16_t | 157 uint16_t |
| 138 ptp_transaction_new (PTPParams* params, PTPContainer* ptp, | 158 ptp_transaction_new (PTPParams* params, PTPContainer* ptp, |
| 139 » » uint16_t flags, unsigned int sendlen, | 159 » » uint16_t flags, uint64_t sendlen, |
| 140 » » PTPDataHandler *handler | 160 » » PTPDataHandler *handler |
| 141 ) { | 161 ) { |
| 142 int tries; | 162 int tries; |
| 143 uint16_t cmd; | 163 uint16_t cmd; |
| 144 | 164 |
| 145 if ((params==NULL) || (ptp==NULL)) | 165 if ((params==NULL) || (ptp==NULL)) |
| 146 return PTP_ERROR_BADPARAM; | 166 return PTP_ERROR_BADPARAM; |
| 147 | 167 |
| 148 cmd = ptp->Code; | 168 cmd = ptp->Code; |
| 149 ptp->Transaction_ID=params->transaction_id++; | 169 ptp->Transaction_ID=params->transaction_id++; |
| 150 ptp->SessionID=params->session_id; | 170 ptp->SessionID=params->session_id; |
| 151 /* send request */ | 171 /* send request */ |
| 152 » CHECK_PTP_RC(params->sendreq_func (params, ptp)); | 172 » CHECK_PTP_RC(params->sendreq_func (params, ptp, flags)); |
| 153 /* is there a dataphase? */ | 173 /* is there a dataphase? */ |
| 154 switch (flags&PTP_DP_DATA_MASK) { | 174 switch (flags&PTP_DP_DATA_MASK) { |
| 155 case PTP_DP_SENDDATA: | 175 case PTP_DP_SENDDATA: |
| 156 { | 176 { |
| 157 » » » uint16_t ret; | 177 » » » uint16_t ret = params->senddata_func(params, ptp, sendle
n, handler); |
| 158 » » » ret = params->senddata_func(params, ptp, | 178 » » » if (ret == PTP_ERROR_CANCEL) |
| 159 » » » » » » sendlen, handler); | 179 » » » » CHECK_PTP_RC(params->cancelreq_func(params, para
ms->transaction_id-1)); |
| 160 » » » if (ret == PTP_ERROR_CANCEL) { | 180 » » » CHECK_PTP_RC(ret); |
| 161 » » » » ret = params->cancelreq_func(params, | |
| 162 » » » » » » » params->transaction
_id-1); | |
| 163 » » » » if (ret == PTP_RC_OK) | |
| 164 » » » » » ret = PTP_ERROR_CANCEL; | |
| 165 » » » } | |
| 166 » » » if (ret != PTP_RC_OK) | |
| 167 » » » » return ret; | |
| 168 } | 181 } |
| 169 break; | 182 break; |
| 170 case PTP_DP_GETDATA: | 183 case PTP_DP_GETDATA: |
| 171 { | 184 { |
| 172 » » » uint16_t ret; | 185 » » » uint16_t ret = params->getdata_func(params, ptp, handler
); |
| 173 » » » ret = params->getdata_func(params, ptp, handler); | 186 » » » if (ret == PTP_ERROR_CANCEL) |
| 174 » » » if (ret == PTP_ERROR_CANCEL) { | 187 » » » » CHECK_PTP_RC(params->cancelreq_func(params, para
ms->transaction_id-1)); |
| 175 » » » » ret = params->cancelreq_func(params, | 188 » » » CHECK_PTP_RC(ret); |
| 176 » » » » » » » params->transaction
_id-1); | |
| 177 » » » » if (ret == PTP_RC_OK) | |
| 178 » » » » » ret = PTP_ERROR_CANCEL; | |
| 179 » » » } | |
| 180 » » » if (ret != PTP_RC_OK) | |
| 181 » » » » return ret; | |
| 182 } | 189 } |
| 183 break; | 190 break; |
| 184 case PTP_DP_NODATA: | 191 case PTP_DP_NODATA: |
| 185 break; | 192 break; |
| 186 default: | 193 default: |
| 187 return PTP_ERROR_BADPARAM; | 194 return PTP_ERROR_BADPARAM; |
| 188 } | 195 } |
| 189 tries = 3; | 196 tries = 3; |
| 190 while (tries--) { | 197 while (tries--) { |
| 191 uint16_t ret; | 198 uint16_t ret; |
| 192 /* get response */ | 199 /* get response */ |
| 193 ret = params->getresp_func(params, ptp); | 200 ret = params->getresp_func(params, ptp); |
| 194 if (ret == PTP_ERROR_RESP_EXPECTED) { | 201 if (ret == PTP_ERROR_RESP_EXPECTED) { |
| 195 ptp_debug (params,"PTP: response expected but not got, r
etrying."); | 202 ptp_debug (params,"PTP: response expected but not got, r
etrying."); |
| 196 tries++; | 203 tries++; |
| 197 continue; | 204 continue; |
| 198 } | 205 } |
| 199 » » if (ret != PTP_RC_OK) | 206 » » CHECK_PTP_RC(ret); |
| 200 » » » return ret; | 207 |
| 201 » » | |
| 202 if (ptp->Transaction_ID < params->transaction_id-1) { | 208 if (ptp->Transaction_ID < params->transaction_id-1) { |
| 209 /* The Leica uses Transaction ID 0 on result from CloseS
ession. */ |
| 210 if (cmd == PTP_OC_CloseSession) |
| 211 break; |
| 203 tries++; | 212 tries++; |
| 204 ptp_debug (params, | 213 ptp_debug (params, |
| 205 "PTP: Sequence number mismatch %d vs expected %d
, suspecting old reply.", | 214 "PTP: Sequence number mismatch %d vs expected %d
, suspecting old reply.", |
| 206 ptp->Transaction_ID, params->transaction_id-1 | 215 ptp->Transaction_ID, params->transaction_id-1 |
| 207 ); | 216 ); |
| 208 continue; | 217 continue; |
| 209 } | 218 } |
| 210 if (ptp->Transaction_ID != params->transaction_id-1) { | 219 if (ptp->Transaction_ID != params->transaction_id-1) { |
| 211 /* try to clean up potential left overs from previous se
ssion */ | 220 /* try to clean up potential left overs from previous se
ssion */ |
| 212 if ((cmd == PTP_OC_OpenSession) && tries) | 221 if ((cmd == PTP_OC_OpenSession) && tries) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 239 if (priv->curoff + tocopy > priv->size) | 248 if (priv->curoff + tocopy > priv->size) |
| 240 tocopy = priv->size - priv->curoff; | 249 tocopy = priv->size - priv->curoff; |
| 241 memcpy (data, priv->data + priv->curoff, tocopy); | 250 memcpy (data, priv->data + priv->curoff, tocopy); |
| 242 priv->curoff += tocopy; | 251 priv->curoff += tocopy; |
| 243 *gotlen = tocopy; | 252 *gotlen = tocopy; |
| 244 return PTP_RC_OK; | 253 return PTP_RC_OK; |
| 245 } | 254 } |
| 246 | 255 |
| 247 static uint16_t | 256 static uint16_t |
| 248 memory_putfunc(PTPParams* params, void* private, | 257 memory_putfunc(PTPParams* params, void* private, |
| 249 » unsigned long sendlen, unsigned char *data, | 258 » unsigned long sendlen, unsigned char *data |
| 250 » unsigned long *putlen | |
| 251 ) { | 259 ) { |
| 252 PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)private; | 260 PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)private; |
| 253 | 261 |
| 254 if (priv->curoff + sendlen > priv->size) { | 262 if (priv->curoff + sendlen > priv->size) { |
| 255 priv->data = realloc (priv->data, priv->curoff+sendlen); | 263 priv->data = realloc (priv->data, priv->curoff+sendlen); |
| 256 if (!priv->data) | 264 if (!priv->data) |
| 257 return PTP_RC_GeneralError; | 265 return PTP_RC_GeneralError; |
| 258 priv->size = priv->curoff + sendlen; | 266 priv->size = priv->curoff + sendlen; |
| 259 } | 267 } |
| 260 memcpy (priv->data + priv->curoff, data, sendlen); | 268 memcpy (priv->data + priv->curoff, data, sendlen); |
| 261 priv->curoff += sendlen; | 269 priv->curoff += sendlen; |
| 262 *putlen = sendlen; | |
| 263 return PTP_RC_OK; | 270 return PTP_RC_OK; |
| 264 } | 271 } |
| 265 | 272 |
| 266 /* init private struct for receiving data. */ | 273 /* init private struct for receiving data. */ |
| 267 static uint16_t | 274 static uint16_t |
| 268 ptp_init_recv_memory_handler(PTPDataHandler *handler) { | 275 ptp_init_recv_memory_handler(PTPDataHandler *handler) |
| 276 { |
| 269 PTPMemHandlerPrivate* priv; | 277 PTPMemHandlerPrivate* priv; |
| 270 priv = malloc (sizeof(PTPMemHandlerPrivate)); | 278 priv = malloc (sizeof(PTPMemHandlerPrivate)); |
| 271 if (!priv) | 279 if (!priv) |
| 272 return PTP_RC_GeneralError; | 280 return PTP_RC_GeneralError; |
| 273 handler->priv = priv; | 281 handler->priv = priv; |
| 274 handler->getfunc = memory_getfunc; | 282 handler->getfunc = memory_getfunc; |
| 275 handler->putfunc = memory_putfunc; | 283 handler->putfunc = memory_putfunc; |
| 276 priv->data = NULL; | 284 priv->data = NULL; |
| 277 priv->size = 0; | 285 priv->size = 0; |
| 278 priv->curoff = 0; | 286 priv->curoff = 0; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 294 handler->getfunc = memory_getfunc; | 302 handler->getfunc = memory_getfunc; |
| 295 handler->putfunc = memory_putfunc; | 303 handler->putfunc = memory_putfunc; |
| 296 priv->data = data; | 304 priv->data = data; |
| 297 priv->size = len; | 305 priv->size = len; |
| 298 priv->curoff = 0; | 306 priv->curoff = 0; |
| 299 return PTP_RC_OK; | 307 return PTP_RC_OK; |
| 300 } | 308 } |
| 301 | 309 |
| 302 /* free private struct + data */ | 310 /* free private struct + data */ |
| 303 static uint16_t | 311 static uint16_t |
| 304 ptp_exit_send_memory_handler (PTPDataHandler *handler) { | 312 ptp_exit_send_memory_handler (PTPDataHandler *handler) |
| 313 { |
| 305 PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->priv; | 314 PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->priv; |
| 306 /* data is owned by caller */ | 315 /* data is owned by caller */ |
| 307 free (priv); | 316 free (priv); |
| 308 return PTP_RC_OK; | 317 return PTP_RC_OK; |
| 309 } | 318 } |
| 310 | 319 |
| 311 /* hand over our internal data to caller */ | 320 /* hand over our internal data to caller */ |
| 312 static uint16_t | 321 static uint16_t |
| 313 ptp_exit_recv_memory_handler (PTPDataHandler *handler, | 322 ptp_exit_recv_memory_handler (PTPDataHandler *handler, |
| 314 unsigned char **data, unsigned long *size | 323 unsigned char **data, unsigned long *size |
| (...skipping 21 matching lines...) Expand all Loading... |
| 336 got = read (priv->fd, data, wantlen); | 345 got = read (priv->fd, data, wantlen); |
| 337 if (got != -1) | 346 if (got != -1) |
| 338 *gotlen = got; | 347 *gotlen = got; |
| 339 else | 348 else |
| 340 return PTP_RC_GeneralError; | 349 return PTP_RC_GeneralError; |
| 341 return PTP_RC_OK; | 350 return PTP_RC_OK; |
| 342 } | 351 } |
| 343 | 352 |
| 344 static uint16_t | 353 static uint16_t |
| 345 fd_putfunc(PTPParams* params, void* private, | 354 fd_putfunc(PTPParams* params, void* private, |
| 346 » unsigned long sendlen, unsigned char *data, | 355 » unsigned long sendlen, unsigned char *data |
| 347 » unsigned long *putlen | |
| 348 ) { | 356 ) { |
| 349 » int» » written; | 357 » ssize_t»» written; |
| 350 PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)private; | 358 PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)private; |
| 351 | 359 |
| 352 written = write (priv->fd, data, sendlen); | 360 written = write (priv->fd, data, sendlen); |
| 353 » if (written != -1) | 361 » if (written != sendlen) |
| 354 » » *putlen = written; | 362 » » return PTP_ERROR_IO; |
| 355 » else | |
| 356 » » return PTP_RC_GeneralError; | |
| 357 return PTP_RC_OK; | 363 return PTP_RC_OK; |
| 358 } | 364 } |
| 359 | 365 |
| 360 static uint16_t | 366 static uint16_t |
| 361 ptp_init_fd_handler(PTPDataHandler *handler, int fd) { | 367 ptp_init_fd_handler(PTPDataHandler *handler, int fd) |
| 368 { |
| 362 PTPFDHandlerPrivate* priv; | 369 PTPFDHandlerPrivate* priv; |
| 363 priv = malloc (sizeof(PTPFDHandlerPrivate)); | 370 priv = malloc (sizeof(PTPFDHandlerPrivate)); |
| 364 if (!priv) | 371 if (!priv) |
| 365 return PTP_RC_GeneralError; | 372 return PTP_RC_GeneralError; |
| 366 handler->priv = priv; | 373 handler->priv = priv; |
| 367 handler->getfunc = fd_getfunc; | 374 handler->getfunc = fd_getfunc; |
| 368 handler->putfunc = fd_putfunc; | 375 handler->putfunc = fd_putfunc; |
| 369 priv->fd = fd; | 376 priv->fd = fd; |
| 370 return PTP_RC_OK; | 377 return PTP_RC_OK; |
| 371 } | 378 } |
| 372 | 379 |
| 373 static uint16_t | 380 static uint16_t |
| 374 ptp_exit_fd_handler (PTPDataHandler *handler) { | 381 ptp_exit_fd_handler (PTPDataHandler *handler) |
| 382 { |
| 375 PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)handler->priv; | 383 PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)handler->priv; |
| 376 free (priv); | 384 free (priv); |
| 377 return PTP_RC_OK; | 385 return PTP_RC_OK; |
| 378 } | 386 } |
| 379 | 387 |
| 380 /* Old style transaction, based on memory */ | 388 /* Old style transaction, based on memory */ |
| 381 static uint16_t | 389 /* A note on memory management: |
| 390 * If called with the flag PTP_DP_GETDATA, this function will internally |
| 391 * allocate memory as much as necessary. The caller has to free the memory |
| 392 * returned in *data. If the function returns an error, it will free any |
| 393 * memory it might have allocated. The recvlen may be NULL. After the |
| 394 * function returns, *data will be initialized (valid memory pointer or NULL), |
| 395 * i.e. it is not necessary to initialize *data or *recvlen beforehand. |
| 396 */ |
| 397 uint16_t |
| 382 ptp_transaction (PTPParams* params, PTPContainer* ptp, | 398 ptp_transaction (PTPParams* params, PTPContainer* ptp, |
| 383 » » uint16_t flags, unsigned int sendlen, | 399 » » uint16_t flags, uint64_t sendlen, |
| 384 unsigned char **data, unsigned int *recvlen | 400 unsigned char **data, unsigned int *recvlen |
| 385 ) { | 401 ) { |
| 386 PTPDataHandler handler; | 402 PTPDataHandler handler; |
| 387 uint16_t ret; | 403 uint16_t ret; |
| 388 | 404 |
| 389 switch (flags & PTP_DP_DATA_MASK) { | 405 switch (flags & PTP_DP_DATA_MASK) { |
| 390 case PTP_DP_SENDDATA: | 406 case PTP_DP_SENDDATA: |
| 391 » » ptp_init_send_memory_handler (&handler, *data, sendlen); | 407 » » if (!data) |
| 408 » » » return PTP_ERROR_BADPARAM; |
| 409 » » CHECK_PTP_RC(ptp_init_send_memory_handler (&handler, *data, send
len)); |
| 392 break; | 410 break; |
| 393 case PTP_DP_GETDATA: | 411 case PTP_DP_GETDATA: |
| 394 » » ptp_init_recv_memory_handler (&handler); | 412 » » if (!data) |
| 413 » » » return PTP_ERROR_BADPARAM; |
| 414 » » *data = NULL; |
| 415 » » if (recvlen) |
| 416 » » » *recvlen = 0; |
| 417 » » CHECK_PTP_RC(ptp_init_recv_memory_handler (&handler)); |
| 395 break; | 418 break; |
| 396 default:break; | 419 default:break; |
| 397 } | 420 } |
| 398 ret = ptp_transaction_new (params, ptp, flags, sendlen, &handler); | 421 ret = ptp_transaction_new (params, ptp, flags, sendlen, &handler); |
| 399 switch (flags & PTP_DP_DATA_MASK) { | 422 switch (flags & PTP_DP_DATA_MASK) { |
| 400 case PTP_DP_SENDDATA: | 423 case PTP_DP_SENDDATA: |
| 401 ptp_exit_send_memory_handler (&handler); | 424 ptp_exit_send_memory_handler (&handler); |
| 402 break; | 425 break; |
| 403 case PTP_DP_GETDATA: { | 426 case PTP_DP_GETDATA: { |
| 404 unsigned long len; | 427 unsigned long len; |
| 405 ptp_exit_recv_memory_handler (&handler, data, &len); | 428 ptp_exit_recv_memory_handler (&handler, data, &len); |
| 429 if (ret != PTP_RC_OK) { |
| 430 len = 0; |
| 431 free(*data); |
| 432 *data = NULL; |
| 433 } |
| 406 if (recvlen) | 434 if (recvlen) |
| 407 *recvlen = len; | 435 *recvlen = len; |
| 408 break; | 436 break; |
| 409 } | 437 } |
| 410 default:break; | 438 default:break; |
| 411 } | 439 } |
| 412 return ret; | 440 return ret; |
| 413 } | 441 } |
| 414 | 442 |
| 415 | 443 |
| 416 /** | 444 /** |
| 417 * PTP operation functions | 445 * PTP operation functions |
| 418 * | 446 * |
| 419 * all ptp_ functions should take integer parameters | 447 * all ptp_ functions should take integer parameters |
| 420 * in host byte order! | 448 * in host byte order! |
| 421 **/ | 449 **/ |
| 422 | 450 |
| 423 | 451 |
| 424 /** | 452 /** |
| 425 * ptp_getdeviceinfo: | 453 * ptp_getdeviceinfo: |
| 426 * params: PTPParams* | 454 * params: PTPParams* |
| 427 * | 455 * |
| 428 * Gets device info dataset and fills deviceinfo structure. | 456 * Gets device info dataset and fills deviceinfo structure. |
| 429 * | 457 * |
| 430 * Return values: Some PTP_RC_* code. | 458 * Return values: Some PTP_RC_* code. |
| 431 **/ | 459 **/ |
| 432 uint16_t | 460 uint16_t |
| 433 ptp_getdeviceinfo (PTPParams* params, PTPDeviceInfo* deviceinfo) | 461 ptp_getdeviceinfo (PTPParams* params, PTPDeviceInfo* deviceinfo) |
| 434 { | 462 { |
| 435 uint16_t ret; | |
| 436 unsigned long len; | |
| 437 PTPContainer ptp; | 463 PTPContainer ptp; |
| 438 » unsigned char*» di=NULL; | 464 » unsigned char» *data; |
| 439 » PTPDataHandler» handler; | 465 » unsigned int» size; |
| 440 | 466 |
| 441 » ptp_init_recv_memory_handler (&handler); | 467 » PTP_CNT_INIT(ptp, PTP_OC_GetDeviceInfo); |
| 442 » PTP_CNT_INIT(ptp); | 468 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 443 » ptp.Code=PTP_OC_GetDeviceInfo; | 469 » ptp_unpack_DI(params, data, deviceinfo, size); |
| 444 » ptp.Nparam=0; | 470 » free(data); |
| 445 » len=0; | 471 » return PTP_RC_OK; |
| 446 » ret=ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler); | |
| 447 » ptp_exit_recv_memory_handler (&handler, &di, &len); | |
| 448 » if (!di) ret = PTP_RC_GeneralError; | |
| 449 » if (ret == PTP_RC_OK) ptp_unpack_DI(params, di, deviceinfo, len); | |
| 450 » free(di); | |
| 451 » return ret; | |
| 452 } | 472 } |
| 453 | 473 |
| 454 uint16_t | 474 uint16_t |
| 455 ptp_canon_eos_getdeviceinfo (PTPParams* params, PTPCanonEOSDeviceInfo*di) | 475 ptp_canon_eos_getdeviceinfo (PTPParams* params, PTPCanonEOSDeviceInfo*di) |
| 456 { | 476 { |
| 477 PTPContainer ptp; |
| 478 unsigned char *data; |
| 479 unsigned int size; |
| 480 |
| 481 PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetDeviceInfoEx); |
| 482 CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 483 ptp_unpack_EOS_DI(params, data, di, size); |
| 484 free (data); |
| 485 return PTP_RC_OK; |
| 486 } |
| 487 |
| 488 #ifdef HAVE_LIBXML2 |
| 489 static int |
| 490 traverse_tree (PTPParams *params, int depth, xmlNodePtr node) |
| 491 { |
| 492 xmlNodePtr next; |
| 493 xmlChar *xchar; |
| 494 int n; |
| 495 char *xx; |
| 496 |
| 497 |
| 498 if (!node) return 0; |
| 499 xx = malloc (depth * 4 + 1); |
| 500 memset (xx, ' ', depth*4); |
| 501 xx[depth*4] = 0; |
| 502 |
| 503 n = xmlChildElementCount (node); |
| 504 |
| 505 next = node; |
| 506 do { |
| 507 fprintf(stderr,"%snode %s\n", xx,next->name); |
| 508 fprintf(stderr,"%selements %d\n", xx,n); |
| 509 xchar = xmlNodeGetContent (next); |
| 510 fprintf(stderr,"%scontent %s\n", xx,xchar); |
| 511 traverse_tree (params, depth+1,xmlFirstElementChild (next)); |
| 512 } while ((next = xmlNextElementSibling (next))); |
| 513 free (xx); |
| 514 return PTP_RC_OK; |
| 515 } |
| 516 |
| 517 static int |
| 518 parse_9301_cmd_tree (PTPParams *params, xmlNodePtr node, PTPDeviceInfo *di) |
| 519 { |
| 520 xmlNodePtr next; |
| 521 int cnt; |
| 522 |
| 523 cnt = 0; |
| 524 next = xmlFirstElementChild (node); |
| 525 while (next) { |
| 526 cnt++; |
| 527 next = xmlNextElementSibling (next); |
| 528 } |
| 529 di->OperationsSupported_len = cnt; |
| 530 di->OperationsSupported = malloc (cnt*sizeof(di->OperationsSupported[0])
); |
| 531 cnt = 0; |
| 532 next = xmlFirstElementChild (node); |
| 533 while (next) { |
| 534 unsigned int p; |
| 535 |
| 536 sscanf((char*)next->name, "c%04x", &p); |
| 537 ptp_debug( params, "cmd %s / 0x%04x", next->name, p); |
| 538 di->OperationsSupported[cnt++] = p; |
| 539 next = xmlNextElementSibling (next); |
| 540 } |
| 541 return PTP_RC_OK; |
| 542 } |
| 543 |
| 544 static int |
| 545 parse_9301_value (PTPParams *params, const char *str, uint16_t type, PTPProperty
Value *propval) |
| 546 { |
| 547 switch (type) { |
| 548 case 6: { /*UINT32*/ |
| 549 unsigned int x; |
| 550 if (!sscanf(str,"%08x", &x)) { |
| 551 ptp_debug( params, "could not parse uint32 %s", str); |
| 552 return PTP_RC_GeneralError; |
| 553 } |
| 554 ptp_debug( params, "\t%d", x); |
| 555 propval->u32 = x; |
| 556 break; |
| 557 } |
| 558 case 5: { /*INT32*/ |
| 559 int x; |
| 560 if (!sscanf(str,"%08x", &x)) { |
| 561 ptp_debug( params, "could not parse int32 %s", str); |
| 562 return PTP_RC_GeneralError; |
| 563 } |
| 564 ptp_debug( params, "\t%d", x); |
| 565 propval->i32 = x; |
| 566 break; |
| 567 } |
| 568 case 4: { /*UINT16*/ |
| 569 unsigned int x; |
| 570 if (!sscanf(str,"%04x", &x)) { |
| 571 ptp_debug( params, "could not parse uint16 %s", str); |
| 572 return PTP_RC_GeneralError; |
| 573 } |
| 574 ptp_debug( params, "\t%d", x); |
| 575 propval->u16 = x; |
| 576 break; |
| 577 } |
| 578 case 3: { /*INT16*/ |
| 579 int x; |
| 580 if (!sscanf(str,"%04x", &x)) { |
| 581 ptp_debug( params, "could not parse int16 %s", str); |
| 582 return PTP_RC_GeneralError; |
| 583 } |
| 584 ptp_debug( params, "\t%d", x); |
| 585 propval->i16 = x; |
| 586 break; |
| 587 } |
| 588 case 2: { /*UINT8*/ |
| 589 unsigned int x; |
| 590 if (!sscanf(str,"%02x", &x)) { |
| 591 ptp_debug( params, "could not parse uint8 %s", str); |
| 592 return PTP_RC_GeneralError; |
| 593 } |
| 594 ptp_debug( params, "\t%d", x); |
| 595 propval->u8 = x; |
| 596 break; |
| 597 } |
| 598 case 1: { /*INT8*/ |
| 599 int x; |
| 600 if (!sscanf(str,"%02x", &x)) { |
| 601 ptp_debug( params, "could not parse int8 %s", str); |
| 602 return PTP_RC_GeneralError; |
| 603 } |
| 604 ptp_debug( params, "\t%d", x); |
| 605 propval->i8 = x; |
| 606 break; |
| 607 } |
| 608 case 65535: { /* string */ |
| 609 int len; |
| 610 |
| 611 /* ascii ptp string, 1 byte length, little endian 16 bit chars *
/ |
| 612 if (sscanf(str,"%02x", &len)) { |
| 613 int i; |
| 614 char *xstr = malloc(len+1); |
| 615 for (i=0;i<len;i++) { |
| 616 int xc; |
| 617 if (sscanf(str+2+i*4,"%04x", &xc)) { |
| 618 int cx; |
| 619 |
| 620 cx = ((xc>>8) & 0xff) | ((xc & 0xff) <<
8); |
| 621 xstr[i] = cx; |
| 622 } |
| 623 xstr[len] = 0; |
| 624 } |
| 625 ptp_debug( params, "\t%s", xstr); |
| 626 propval->str = xstr; |
| 627 break; |
| 628 } |
| 629 ptp_debug( params, "string %s not parseable!", str); |
| 630 return PTP_RC_GeneralError; |
| 631 } |
| 632 case 7: /*INT64*/ |
| 633 case 8: /*UINT64*/ |
| 634 case 9: /*INT128*/ |
| 635 case 10: /*UINT128*/ |
| 636 default: |
| 637 ptp_debug( params, "unhandled data type %d!", type); |
| 638 return PTP_RC_GeneralError; |
| 639 } |
| 640 return PTP_RC_OK; |
| 641 } |
| 642 |
| 643 static int |
| 644 parse_9301_propdesc (PTPParams *params, xmlNodePtr next, PTPDevicePropDesc *dpd) |
| 645 { |
| 646 int type = -1; |
| 647 |
| 648 if (!next) |
| 649 return PTP_RC_GeneralError; |
| 650 |
| 651 ptp_debug (params, "parse_9301_propdesc"); |
| 652 dpd->FormFlag = PTP_DPFF_None; |
| 653 dpd->GetSet = PTP_DPGS_Get; |
| 654 do { |
| 655 if (!strcmp((char*)next->name,"type")) { /* propdesc.Data
Type */ |
| 656 if (!sscanf((char*)xmlNodeGetContent (next), "%04x", &ty
pe)) { |
| 657 ptp_debug( params, "\ttype %s not parseable?",xm
lNodeGetContent (next)); |
| 658 return 0; |
| 659 } |
| 660 ptp_debug( params, "type 0x%x", type); |
| 661 dpd->DataType = type; |
| 662 continue; |
| 663 } |
| 664 if (!strcmp((char*)next->name,"attribute")) { /* propdesc.GetS
et */ |
| 665 int attr; |
| 666 |
| 667 if (!sscanf((char*)xmlNodeGetContent (next), "%02x", &at
tr)) { |
| 668 ptp_debug( params, "\tattr %s not parseable",xml
NodeGetContent (next)); |
| 669 return 0; |
| 670 } |
| 671 ptp_debug( params, "attribute 0x%x", attr); |
| 672 dpd->GetSet = attr; |
| 673 continue; |
| 674 } |
| 675 if (!strcmp((char*)next->name,"default")) { /* propdesc.Fact
oryDefaultValue */ |
| 676 ptp_debug( params, "default value"); |
| 677 parse_9301_value (params, (char*)xmlNodeGetContent (next
), type, &dpd->FactoryDefaultValue); |
| 678 continue; |
| 679 } |
| 680 if (!strcmp((char*)next->name,"value")) { /* propdesc.Curr
entValue */ |
| 681 ptp_debug( params, "current value"); |
| 682 parse_9301_value (params, (char*)xmlNodeGetContent (next
), type, &dpd->CurrentValue); |
| 683 continue; |
| 684 } |
| 685 if (!strcmp((char*)next->name,"enum")) { /* propdesc.FORM
.Enum */ |
| 686 int n,i; |
| 687 char *s; |
| 688 |
| 689 ptp_debug( params, "enum"); |
| 690 dpd->FormFlag = PTP_DPFF_Enumeration; |
| 691 s = (char*)xmlNodeGetContent (next); |
| 692 n = 0; |
| 693 do { |
| 694 s = strchr(s,' '); |
| 695 if (s) s++; |
| 696 n++; |
| 697 } while (s); |
| 698 dpd->FORM.Enum.NumberOfValues = n; |
| 699 dpd->FORM.Enum.SupportedValue = malloc (n * sizeof(PTPPr
opertyValue)); |
| 700 s = (char*)xmlNodeGetContent (next); |
| 701 i = 0; |
| 702 do { |
| 703 parse_9301_value (params, s, type, &dpd->FORM.En
um.SupportedValue[i]); /* should turn ' ' into \0? */ |
| 704 i++; |
| 705 s = strchr(s,' '); |
| 706 if (s) s++; |
| 707 } while (s && (i<n)); |
| 708 continue; |
| 709 } |
| 710 if (!strcmp((char*)next->name,"range")) { /* propdesc.FORM
.Enum */ |
| 711 char *s = (char*)xmlNodeGetContent (next); |
| 712 dpd->FormFlag = PTP_DPFF_Range; |
| 713 ptp_debug( params, "range"); |
| 714 parse_9301_value (params, s, type, &dpd->FORM.Range.Mini
mumValue); /* should turn ' ' into \0? */ |
| 715 s = strchr(s,' '); |
| 716 if (!s) continue; |
| 717 s++; |
| 718 parse_9301_value (params, s, type, &dpd->FORM.Range.Maxi
mumValue); /* should turn ' ' into \0? */ |
| 719 s = strchr(s,' '); |
| 720 if (!s) continue; |
| 721 s++; |
| 722 parse_9301_value (params, s, type, &dpd->FORM.Range.Step
Size); /* should turn ' ' into \0? */ |
| 723 |
| 724 continue; |
| 725 } |
| 726 ptp_debug (params, "\tpropdescvar: %s", next->name); |
| 727 traverse_tree (params, 3, next); |
| 728 } while ((next = xmlNextElementSibling (next))); |
| 729 return PTP_RC_OK; |
| 730 } |
| 731 |
| 732 static int |
| 733 parse_9301_prop_tree (PTPParams *params, xmlNodePtr node, PTPDeviceInfo *di) |
| 734 { |
| 735 xmlNodePtr next; |
| 736 int cnt; |
| 737 unsigned int i; |
| 738 |
| 739 cnt = 0; |
| 740 next = xmlFirstElementChild (node); |
| 741 while (next) { |
| 742 cnt++; |
| 743 next = xmlNextElementSibling (next); |
| 744 } |
| 745 |
| 746 di->DevicePropertiesSupported_len = cnt; |
| 747 di->DevicePropertiesSupported = malloc (cnt*sizeof(di->DevicePropertiesS
upported[0])); |
| 748 cnt = 0; |
| 749 next = xmlFirstElementChild (node); |
| 750 while (next) { |
| 751 unsigned int p; |
| 752 PTPDevicePropDesc dpd; |
| 753 |
| 754 sscanf((char*)next->name, "p%04x", &p); |
| 755 ptp_debug( params, "prop %s / 0x%04x", next->name, p); |
| 756 parse_9301_propdesc (params, xmlFirstElementChild (next), &dpd); |
| 757 dpd.DevicePropertyCode = p; |
| 758 di->DevicePropertiesSupported[cnt++] = p; |
| 759 |
| 760 /* add to cache of device propdesc */ |
| 761 for (i=0;i<params->nrofdeviceproperties;i++) |
| 762 if (params->deviceproperties[i].desc.DevicePropertyCode
== p) |
| 763 break; |
| 764 if (i == params->nrofdeviceproperties) { |
| 765 params->deviceproperties = realloc(params->devicepropert
ies,(i+1)*sizeof(params->deviceproperties[0])); |
| 766 memset(¶ms->deviceproperties[i],0,sizeof(params->dev
iceproperties[0])); |
| 767 params->nrofdeviceproperties++; |
| 768 } else { |
| 769 ptp_free_devicepropdesc (¶ms->deviceproperties[i].de
sc); |
| 770 } |
| 771 /* FIXME: free old entry */ |
| 772 /* we are not using dpd, so copy it directly to the cache */ |
| 773 time( ¶ms->deviceproperties[i].timestamp); |
| 774 params->deviceproperties[i].desc = dpd; |
| 775 |
| 776 next = xmlNextElementSibling (next); |
| 777 } |
| 778 return PTP_RC_OK; |
| 779 } |
| 780 |
| 781 static int |
| 782 parse_9301_event_tree (PTPParams *params, xmlNodePtr node, PTPDeviceInfo *di) |
| 783 { |
| 784 xmlNodePtr next; |
| 785 int cnt; |
| 786 |
| 787 cnt = 0; |
| 788 next = xmlFirstElementChild (node); |
| 789 while (next) { |
| 790 cnt++; |
| 791 next = xmlNextElementSibling (next); |
| 792 } |
| 793 di->EventsSupported_len = cnt; |
| 794 di->EventsSupported = malloc (cnt*sizeof(di->EventsSupported[0])); |
| 795 cnt = 0; |
| 796 next = xmlFirstElementChild (node); |
| 797 while (next) { |
| 798 unsigned int p; |
| 799 |
| 800 sscanf((char*)next->name, "e%04x", &p); |
| 801 ptp_debug( params, "event %s / 0x%04x", next->name, p); |
| 802 di->EventsSupported[cnt++] = p; |
| 803 next = xmlNextElementSibling (next); |
| 804 } |
| 805 return PTP_RC_OK; |
| 806 } |
| 807 |
| 808 static int |
| 809 parse_9301_tree (PTPParams *params, xmlNodePtr node, PTPDeviceInfo *di) |
| 810 { |
| 811 xmlNodePtr next; |
| 812 |
| 813 next = xmlFirstElementChild (node); |
| 814 while (next) { |
| 815 if (!strcmp ((char*)next->name, "cmd")) { |
| 816 parse_9301_cmd_tree (params, next, di); |
| 817 next = xmlNextElementSibling (next); |
| 818 continue; |
| 819 } |
| 820 if (!strcmp ((char*)next->name, "prop")) { |
| 821 parse_9301_prop_tree (params, next, di); |
| 822 next = xmlNextElementSibling (next); |
| 823 continue; |
| 824 } |
| 825 if (!strcmp ((char*)next->name, "event")) { |
| 826 parse_9301_event_tree (params, next, di); |
| 827 next = xmlNextElementSibling (next); |
| 828 continue; |
| 829 } |
| 830 fprintf (stderr,"9301: unhandled type %s\n", next->name); |
| 831 next = xmlNextElementSibling (next); |
| 832 } |
| 833 /*traverse_tree (0, node);*/ |
| 834 return PTP_RC_OK; |
| 835 } |
| 836 |
| 837 static uint16_t |
| 838 ptp_olympus_parse_output_xml(PTPParams* params, char*data, int len, xmlNodePtr *
code) |
| 839 { |
| 840 xmlDocPtr docin; |
| 841 xmlNodePtr docroot, output, next; |
| 842 int result, xcode; |
| 843 |
| 844 *code = NULL; |
| 845 |
| 846 docin = xmlReadMemory ((char*)data, len, "http://gphoto.org/", "utf-8",
0); |
| 847 if (!docin) return PTP_RC_GeneralError; |
| 848 docroot = xmlDocGetRootElement (docin); |
| 849 if (!docroot) { |
| 850 xmlFreeDoc (docin); |
| 851 return PTP_RC_GeneralError; |
| 852 } |
| 853 |
| 854 if (strcmp((char*)docroot->name,"x3c")) { |
| 855 ptp_debug (params, "olympus: docroot is not x3c, but %s", docroo
t->name); |
| 856 xmlFreeDoc (docin); |
| 857 return PTP_RC_GeneralError; |
| 858 } |
| 859 if (xmlChildElementCount(docroot) != 1) { |
| 860 ptp_debug (params, "olympus: x3c: expected 1 child, got %ld", xm
lChildElementCount(docroot)); |
| 861 xmlFreeDoc (docin); |
| 862 return PTP_RC_GeneralError; |
| 863 } |
| 864 output = xmlFirstElementChild (docroot); |
| 865 if (strcmp((char*)output->name, "output") != 0) { |
| 866 ptp_debug (params, "olympus: x3c node: expected child 'output',
but got %s", (char*)output->name); |
| 867 xmlFreeDoc (docin); |
| 868 return PTP_RC_GeneralError; |
| 869 } |
| 870 next = xmlFirstElementChild (output); |
| 871 |
| 872 result = PTP_RC_GeneralError; |
| 873 |
| 874 while (next) { |
| 875 if (!strcmp((char*)next->name,"result")) { |
| 876 xmlChar *xchar; |
| 877 |
| 878 xchar = xmlNodeGetContent (next); |
| 879 if (!sscanf((char*)xchar,"%04x",&result)) |
| 880 ptp_debug (params, "failed scanning result from
%s", xchar); |
| 881 ptp_debug (params, "ptp result is 0x%04x", result); |
| 882 next = xmlNextElementSibling (next); |
| 883 continue; |
| 884 } |
| 885 if (sscanf((char*)next->name,"c%x", &xcode)) { |
| 886 ptp_debug (params, "ptp code node found %s", (char*)nex
t->name); |
| 887 *code = next; |
| 888 next = xmlNextElementSibling (next); |
| 889 continue; |
| 890 } |
| 891 ptp_debug (params, "unhandled node %s", (char*)next->name); |
| 892 next = xmlNextElementSibling (next); |
| 893 } |
| 894 |
| 895 if (result != PTP_RC_OK) { |
| 896 *code = NULL; |
| 897 xmlFreeDoc (docin); |
| 898 } |
| 899 return result; |
| 900 } |
| 901 #endif |
| 902 |
| 903 uint16_t |
| 904 ptp_olympus_getdeviceinfo (PTPParams* params, PTPDeviceInfo *di) |
| 905 { |
| 906 #ifdef HAVE_LIBXML2 |
| 907 PTPContainer ptp; |
| 457 uint16_t ret; | 908 uint16_t ret; |
| 909 unsigned char *data; |
| 910 unsigned int size; |
| 911 xmlNodePtr code; |
| 912 |
| 913 memset (di, 0, sizeof(PTPDeviceInfo)); |
| 914 |
| 915 PTP_CNT_INIT(ptp, PTP_OC_OLYMPUS_GetDeviceInfo); |
| 916 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size); |
| 917 /* TODO: check for error, only parse_output_xml if ret == PTP_RC_OK? |
| 918 * where is 'data' going to be deallocated? */ |
| 919 ret = ptp_olympus_parse_output_xml(params,(char*)data,size,&code); |
| 920 if (ret != PTP_RC_OK) |
| 921 return ret; |
| 922 |
| 923 ret = parse_9301_tree (params, code, di); |
| 924 |
| 925 xmlFreeDoc(code->doc); |
| 926 return ret; |
| 927 #else |
| 928 return PTP_RC_GeneralError; |
| 929 #endif |
| 930 } |
| 931 |
| 932 uint16_t |
| 933 ptp_olympus_opensession (PTPParams* params, unsigned char**data, unsigned int *l
en) |
| 934 { |
| 458 PTPContainer ptp; | 935 PTPContainer ptp; |
| 459 » PTPDataHandler» handler; | 936 |
| 460 » unsigned long» len; | 937 » PTP_CNT_INIT(ptp, PTP_OC_OLYMPUS_OpenSession); |
| 461 » unsigned char» *data; | 938 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, len); |
| 462 | 939 } |
| 463 » ptp_init_recv_memory_handler (&handler); | 940 |
| 464 » PTP_CNT_INIT(ptp); | 941 uint16_t |
| 465 » ptp.Code=PTP_OC_CANON_EOS_GetDeviceInfoEx; | 942 ptp_olympus_getcameraid (PTPParams* params, unsigned char**data, unsigned int *l
en) |
| 466 » ptp.Nparam=0; | 943 { |
| 467 » len=0; | 944 » PTPContainer» ptp; |
| 468 » data=NULL; | 945 |
| 469 » ret=ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler); | 946 » PTP_CNT_INIT(ptp, PTP_OC_OLYMPUS_GetCameraID); |
| 470 » ptp_exit_recv_memory_handler (&handler, &data, &len); | 947 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, len); |
| 471 » if (ret == PTP_RC_OK) ptp_unpack_EOS_DI(params, data, di, len); | |
| 472 » free (data); | |
| 473 » return ret; | |
| 474 } | 948 } |
| 475 | 949 |
| 476 /** | 950 /** |
| 477 * ptp_generic_no_data: | 951 * ptp_generic_no_data: |
| 478 * params: PTPParams* | 952 * params: PTPParams* |
| 479 * code PTP OP Code | 953 * code PTP OP Code |
| 480 * n_param count of parameters | 954 * n_param count of parameters |
| 481 * ... variable argument list ... | 955 * ... variable argument list ... |
| 482 * | 956 * |
| 483 * Emits a generic PTP command without any data transfer. | 957 * Emits a generic PTP command without any data transfer. |
| 484 * | 958 * |
| 485 * Return values: Some PTP_RC_* code. | 959 * Return values: Some PTP_RC_* code. |
| 486 **/ | 960 **/ |
| 487 uint16_t | 961 uint16_t |
| 488 ptp_generic_no_data (PTPParams* params, uint16_t code, unsigned int n_param, ...
) | 962 ptp_generic_no_data (PTPParams* params, uint16_t code, unsigned int n_param, ...
) |
| 489 { | 963 { |
| 490 » PTPContainer ptp; | 964 » PTPContainer» ptp; |
| 491 » va_list args; | 965 » va_list»» args; |
| 492 » int i; | 966 » unsigned int» i; |
| 493 | 967 |
| 494 if( n_param > 5 ) | 968 if( n_param > 5 ) |
| 495 » » return PTP_RC_InvalidParameter; | 969 » » return PTP_ERROR_BADPARAM; |
| 496 | 970 |
| 497 » PTP_CNT_INIT(ptp); | 971 » memset(&ptp, 0, sizeof(ptp)); |
| 498 ptp.Code=code; | 972 ptp.Code=code; |
| 499 ptp.Nparam=n_param; | 973 ptp.Nparam=n_param; |
| 500 | 974 |
| 501 va_start(args, n_param); | 975 va_start(args, n_param); |
| 502 for( i=0; i<n_param; ++i ) | 976 for( i=0; i<n_param; ++i ) |
| 503 (&ptp.Param1)[i] = va_arg(args, uint32_t); | 977 (&ptp.Param1)[i] = va_arg(args, uint32_t); |
| 504 va_end(args); | 978 va_end(args); |
| 505 | 979 |
| 506 return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL); | 980 return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL); |
| 507 } | 981 } |
| 508 | 982 |
| 509 /** | 983 /** |
| 510 * ptp_opensession: | 984 * ptp_opensession: |
| 511 * params: PTPParams* | 985 * params: PTPParams* |
| 512 * session - session number | 986 * session - session number |
| 513 * | 987 * |
| 514 * Establishes a new session. | 988 * Establishes a new session. |
| 515 * | 989 * |
| 516 * Return values: Some PTP_RC_* code. | 990 * Return values: Some PTP_RC_* code. |
| 517 **/ | 991 **/ |
| 518 uint16_t | 992 uint16_t |
| 519 ptp_opensession (PTPParams* params, uint32_t session) | 993 ptp_opensession (PTPParams* params, uint32_t session) |
| 520 { | 994 { |
| 521 » uint16_t ret; | 995 » PTPContainer» ptp; |
| 522 » PTPContainer ptp; | 996 » uint16_t» ret; |
| 523 | 997 |
| 524 ptp_debug(params,"PTP: Opening session"); | 998 ptp_debug(params,"PTP: Opening session"); |
| 525 | 999 |
| 526 /* SessonID field of the operation dataset should always | 1000 /* SessonID field of the operation dataset should always |
| 527 be set to 0 for OpenSession request! */ | 1001 be set to 0 for OpenSession request! */ |
| 528 params->session_id=0x00000000; | 1002 params->session_id=0x00000000; |
| 529 /* TransactionID should be set to 0 also! */ | 1003 /* TransactionID should be set to 0 also! */ |
| 530 params->transaction_id=0x0000000; | 1004 params->transaction_id=0x0000000; |
| 531 /* zero out response packet buffer */ | 1005 /* zero out response packet buffer */ |
| 532 params->response_packet = NULL; | 1006 params->response_packet = NULL; |
| 533 params->response_packet_size = 0; | 1007 params->response_packet_size = 0; |
| 534 /* no split headers */ | 1008 /* no split headers */ |
| 535 params->split_header_data = 0; | 1009 params->split_header_data = 0; |
| 536 | 1010 |
| 537 » PTP_CNT_INIT(ptp); | 1011 » PTP_CNT_INIT(ptp, PTP_OC_OpenSession, session); |
| 538 » ptp.Code=PTP_OC_OpenSession; | |
| 539 » ptp.Param1=session; | |
| 540 » ptp.Nparam=1; | |
| 541 ret=ptp_transaction_new(params, &ptp, PTP_DP_NODATA, 0, NULL); | 1012 ret=ptp_transaction_new(params, &ptp, PTP_DP_NODATA, 0, NULL); |
| 1013 /* TODO: check for error */ |
| 542 /* now set the global session id to current session number */ | 1014 /* now set the global session id to current session number */ |
| 543 params->session_id=session; | 1015 params->session_id=session; |
| 544 return ret; | 1016 return ret; |
| 545 } | 1017 } |
| 546 | 1018 |
| 1019 void |
| 1020 ptp_free_devicepropvalue(uint16_t dt, PTPPropertyValue* dpd) |
| 1021 { |
| 1022 switch (dt) { |
| 1023 case PTP_DTC_INT8: case PTP_DTC_UINT8: |
| 1024 case PTP_DTC_UINT16: case PTP_DTC_INT16: |
| 1025 case PTP_DTC_UINT32: case PTP_DTC_INT32: |
| 1026 case PTP_DTC_UINT64: case PTP_DTC_INT64: |
| 1027 case PTP_DTC_UINT128: case PTP_DTC_INT128: |
| 1028 /* Nothing to free */ |
| 1029 break; |
| 1030 case PTP_DTC_AINT8: case PTP_DTC_AUINT8: |
| 1031 case PTP_DTC_AUINT16: case PTP_DTC_AINT16: |
| 1032 case PTP_DTC_AUINT32: case PTP_DTC_AINT32: |
| 1033 case PTP_DTC_AUINT64: case PTP_DTC_AINT64: |
| 1034 case PTP_DTC_AUINT128: case PTP_DTC_AINT128: |
| 1035 free(dpd->a.v); |
| 1036 break; |
| 1037 case PTP_DTC_STR: |
| 1038 free(dpd->str); |
| 1039 break; |
| 1040 } |
| 1041 } |
| 1042 |
| 1043 void |
| 1044 ptp_free_devicepropdesc(PTPDevicePropDesc* dpd) |
| 1045 { |
| 1046 uint16_t i; |
| 1047 |
| 1048 ptp_free_devicepropvalue (dpd->DataType, &dpd->FactoryDefaultValue); |
| 1049 ptp_free_devicepropvalue (dpd->DataType, &dpd->CurrentValue); |
| 1050 switch (dpd->FormFlag) { |
| 1051 case PTP_DPFF_Range: |
| 1052 ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.Minimu
mValue); |
| 1053 ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.Maximu
mValue); |
| 1054 ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.StepSi
ze); |
| 1055 break; |
| 1056 case PTP_DPFF_Enumeration: |
| 1057 if (dpd->FORM.Enum.SupportedValue) { |
| 1058 for (i=0;i<dpd->FORM.Enum.NumberOfValues;i++) |
| 1059 ptp_free_devicepropvalue (dpd->DataType, dpd->FO
RM.Enum.SupportedValue+i); |
| 1060 free (dpd->FORM.Enum.SupportedValue); |
| 1061 } |
| 1062 } |
| 1063 dpd->DataType = PTP_DTC_UNDEF; |
| 1064 dpd->FormFlag = PTP_DPFF_None; |
| 1065 } |
| 1066 |
| 1067 |
| 1068 void |
| 1069 ptp_free_objectpropdesc(PTPObjectPropDesc* opd) |
| 1070 { |
| 1071 uint16_t i; |
| 1072 |
| 1073 ptp_free_devicepropvalue (opd->DataType, &opd->FactoryDefaultValue); |
| 1074 switch (opd->FormFlag) { |
| 1075 case PTP_OPFF_None: |
| 1076 break; |
| 1077 case PTP_OPFF_Range: |
| 1078 ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.Minimu
mValue); |
| 1079 ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.Maximu
mValue); |
| 1080 ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.StepSi
ze); |
| 1081 break; |
| 1082 case PTP_OPFF_Enumeration: |
| 1083 if (opd->FORM.Enum.SupportedValue) { |
| 1084 for (i=0;i<opd->FORM.Enum.NumberOfValues;i++) |
| 1085 ptp_free_devicepropvalue (opd->DataType, opd->FO
RM.Enum.SupportedValue+i); |
| 1086 free (opd->FORM.Enum.SupportedValue); |
| 1087 } |
| 1088 break; |
| 1089 case PTP_OPFF_DateTime: |
| 1090 case PTP_OPFF_FixedLengthArray: |
| 1091 case PTP_OPFF_RegularExpression: |
| 1092 case PTP_OPFF_ByteArray: |
| 1093 case PTP_OPFF_LongString: |
| 1094 /* Ignore these presently, we cannot unpack them, so there is no
thing to be freed. */ |
| 1095 break; |
| 1096 default: |
| 1097 fprintf (stderr, "Unknown OPFF type %d\n", opd->FormFlag); |
| 1098 break; |
| 1099 } |
| 1100 } |
| 1101 |
| 1102 |
| 547 /** | 1103 /** |
| 548 * ptp_free_params: | 1104 * ptp_free_params: |
| 549 * params: PTPParams* | 1105 * params: PTPParams* |
| 550 * | 1106 * |
| 551 * Frees all data within the PTPParams struct. | 1107 * Frees all data within the PTPParams struct. |
| 552 * | 1108 * |
| 553 * Return values: Some PTP_RC_* code. | 1109 * Return values: Some PTP_RC_* code. |
| 554 **/ | 1110 **/ |
| 555 void | 1111 void |
| 556 ptp_free_params (PTPParams *params) { | 1112 ptp_free_params (PTPParams *params) |
| 557 » int i; | 1113 { |
| 1114 » unsigned int i; |
| 558 | 1115 |
| 559 » if (params->cameraname) free (params->cameraname); | 1116 » free (params->cameraname); |
| 560 » if (params->wifi_profiles) free (params->wifi_profiles); | 1117 » free (params->wifi_profiles); |
| 561 for (i=0;i<params->nrofobjects;i++) | 1118 for (i=0;i<params->nrofobjects;i++) |
| 562 ptp_free_object (¶ms->objects[i]); | 1119 ptp_free_object (¶ms->objects[i]); |
| 563 free (params->objects); | 1120 free (params->objects); |
| 564 free (params->events); | 1121 free (params->events); |
| 565 for (i=0;i<params->nrofcanon_props;i++) { | 1122 for (i=0;i<params->nrofcanon_props;i++) { |
| 566 free (params->canon_props[i].data); | 1123 free (params->canon_props[i].data); |
| 567 ptp_free_devicepropdesc (¶ms->canon_props[i].dpd); | 1124 ptp_free_devicepropdesc (¶ms->canon_props[i].dpd); |
| 568 } | 1125 } |
| 569 free (params->canon_props); | 1126 free (params->canon_props); |
| 570 free (params->backlogentries); | 1127 free (params->backlogentries); |
| 1128 |
| 1129 for (i=0;i<params->nrofdeviceproperties;i++) |
| 1130 ptp_free_devicepropdesc (¶ms->deviceproperties[i].desc); |
| 1131 free (params->deviceproperties); |
| 1132 |
| 571 ptp_free_DI (¶ms->deviceinfo); | 1133 ptp_free_DI (¶ms->deviceinfo); |
| 572 } | 1134 } |
| 573 | 1135 |
| 574 /** | 1136 /** |
| 575 * ptp_getststorageids: | 1137 * ptp_getststorageids: |
| 576 * params: PTPParams* | 1138 * params: PTPParams* |
| 577 * | 1139 * |
| 578 * Gets array of StorageIDs and fills the storageids structure. | 1140 * Gets array of StorageIDs and fills the storageids structure. |
| 579 * | 1141 * |
| 580 * Return values: Some PTP_RC_* code. | 1142 * Return values: Some PTP_RC_* code. |
| 581 **/ | 1143 **/ |
| 582 uint16_t | 1144 uint16_t |
| 583 ptp_getstorageids (PTPParams* params, PTPStorageIDs* storageids) | 1145 ptp_getstorageids (PTPParams* params, PTPStorageIDs* storageids) |
| 584 { | 1146 { |
| 585 » uint16_t ret; | 1147 » PTPContainer» ptp; |
| 586 » PTPContainer ptp; | 1148 » unsigned char» *data; |
| 587 » unsigned int len; | 1149 » unsigned int» size; |
| 588 » unsigned char* sids=NULL; | |
| 589 | 1150 |
| 590 » PTP_CNT_INIT(ptp); | 1151 » PTP_CNT_INIT(ptp, PTP_OC_GetStorageIDs); |
| 591 » ptp.Code=PTP_OC_GetStorageIDs; | 1152 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 592 » ptp.Nparam=0; | 1153 » ptp_unpack_SIDs(params, data, storageids, size); |
| 593 » len=0; | 1154 » free(data); |
| 594 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &sids, &len); | 1155 » return PTP_RC_OK; |
| 595 » if (ret == PTP_RC_OK) ptp_unpack_SIDs(params, sids, storageids, len); | |
| 596 » free(sids); | |
| 597 » return ret; | |
| 598 } | 1156 } |
| 599 | 1157 |
| 600 /** | 1158 /** |
| 601 * ptp_getststorageinfo: | 1159 * ptp_getststorageinfo: |
| 602 * params: PTPParams* | 1160 * params: PTPParams* |
| 603 * storageid - StorageID | 1161 * storageid - StorageID |
| 604 * | 1162 * |
| 605 * Gets StorageInfo dataset of desired storage and fills storageinfo | 1163 * Gets StorageInfo dataset of desired storage and fills storageinfo |
| 606 * structure. | 1164 * structure. |
| 607 * | 1165 * |
| 608 * Return values: Some PTP_RC_* code. | 1166 * Return values: Some PTP_RC_* code. |
| 609 **/ | 1167 **/ |
| 610 uint16_t | 1168 uint16_t |
| 611 ptp_getstorageinfo (PTPParams* params, uint32_t storageid, | 1169 ptp_getstorageinfo (PTPParams* params, uint32_t storageid, |
| 612 PTPStorageInfo* storageinfo) | 1170 PTPStorageInfo* storageinfo) |
| 613 { | 1171 { |
| 614 » uint16_t ret; | 1172 » PTPContainer» ptp; |
| 615 » PTPContainer ptp; | 1173 » unsigned char» *data; |
| 616 » unsigned char* si=NULL; | 1174 » unsigned int» size; |
| 617 » unsigned int len; | |
| 618 | 1175 |
| 619 » PTP_CNT_INIT(ptp); | 1176 » PTP_CNT_INIT(ptp, PTP_OC_GetStorageInfo, storageid); |
| 620 » ptp.Code=PTP_OC_GetStorageInfo; | 1177 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 621 » ptp.Param1=storageid; | 1178 » ptp_unpack_SI(params, data, storageinfo, size); |
| 622 » ptp.Nparam=1; | 1179 » free(data); |
| 623 » len=0; | 1180 » return PTP_RC_OK; |
| 624 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &si, &len); | |
| 625 » if (ret == PTP_RC_OK) ptp_unpack_SI(params, si, storageinfo, len); | |
| 626 » free(si); | |
| 627 » return ret; | |
| 628 } | 1181 } |
| 629 | 1182 |
| 630 /** | 1183 /** |
| 631 * ptp_getobjecthandles: | 1184 * ptp_getobjecthandles: |
| 632 * params: PTPParams* | 1185 * params: PTPParams* |
| 633 * storage - StorageID | 1186 * storage - StorageID |
| 634 * objectformatcode - ObjectFormatCode (optional) | 1187 * objectformatcode - ObjectFormatCode (optional) |
| 635 * associationOH - ObjectHandle of Association for | 1188 * associationOH - ObjectHandle of Association for |
| 636 * wich a list of children is desired | 1189 * wich a list of children is desired |
| 637 * (optional) | 1190 * (optional) |
| 638 * objecthandles - pointer to structute | 1191 * objecthandles - pointer to structute |
| 639 * | 1192 * |
| 640 * Fills objecthandles with structure returned by device. | 1193 * Fills objecthandles with structure returned by device. |
| 641 * | 1194 * |
| 642 * Return values: Some PTP_RC_* code. | 1195 * Return values: Some PTP_RC_* code. |
| 643 **/ | 1196 **/ |
| 644 uint16_t | 1197 uint16_t |
| 645 ptp_getobjecthandles (PTPParams* params, uint32_t storage, | 1198 ptp_getobjecthandles (PTPParams* params, uint32_t storage, |
| 646 uint32_t objectformatcode, uint32_t associationOH, | 1199 uint32_t objectformatcode, uint32_t associationOH, |
| 647 PTPObjectHandles* objecthandles) | 1200 PTPObjectHandles* objecthandles) |
| 648 { | 1201 { |
| 649 » uint16_t ret; | 1202 » PTPContainer» ptp; |
| 650 » PTPContainer ptp; | 1203 » uint16_t» ret; |
| 651 » unsigned char* oh=NULL; | 1204 » unsigned char» *data; |
| 652 » unsigned int len; | 1205 » unsigned int» size; |
| 653 | 1206 |
| 654 » PTP_CNT_INIT(ptp); | 1207 » PTP_CNT_INIT(ptp, PTP_OC_GetObjectHandles, storage, objectformatcode, as
sociationOH); |
| 655 » ptp.Code=PTP_OC_GetObjectHandles; | 1208 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size); |
| 656 » ptp.Param1=storage; | |
| 657 » ptp.Param2=objectformatcode; | |
| 658 » ptp.Param3=associationOH; | |
| 659 » ptp.Nparam=3; | |
| 660 » len=0; | |
| 661 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &oh, &len); | |
| 662 if (ret == PTP_RC_OK) { | 1209 if (ret == PTP_RC_OK) { |
| 663 » » ptp_unpack_OH(params, oh, objecthandles, len); | 1210 » » ptp_unpack_OH(params, data, objecthandles, size); |
| 664 } else { | 1211 } else { |
| 665 if ( (storage == 0xffffffff) && | 1212 if ( (storage == 0xffffffff) && |
| 666 (objectformatcode == 0) && | 1213 (objectformatcode == 0) && |
| 667 (associationOH == 0) | 1214 (associationOH == 0) |
| 668 ) { | 1215 ) { |
| 669 /* When we query all object handles on all stores and | 1216 /* When we query all object handles on all stores and |
| 670 * get an error -> just handle it as "0 handles". | 1217 * get an error -> just handle it as "0 handles". |
| 671 */ | 1218 */ |
| 672 objecthandles->Handler = NULL; | 1219 objecthandles->Handler = NULL; |
| 673 objecthandles->n = 0; | 1220 objecthandles->n = 0; |
| 674 ret = PTP_RC_OK; | 1221 ret = PTP_RC_OK; |
| 675 } | 1222 } |
| 676 } | 1223 } |
| 677 » free(oh); | 1224 » free(data); |
| 678 return ret; | 1225 return ret; |
| 679 } | 1226 } |
| 680 | 1227 |
| 681 uint16_t | 1228 uint16_t |
| 682 ptp_getfilesystemmanifest (PTPParams* params, uint32_t storage, | 1229 ptp_getfilesystemmanifest (PTPParams* params, uint32_t storage, |
| 683 uint32_t objectformatcode, uint32_t associationOH, | 1230 uint32_t objectformatcode, uint32_t associationOH, |
| 684 unsigned char** data) | 1231 unsigned char** data) |
| 685 { | 1232 { |
| 686 uint16_t ret; | |
| 687 PTPContainer ptp; | 1233 PTPContainer ptp; |
| 688 unsigned int len; | |
| 689 | 1234 |
| 690 » PTP_CNT_INIT(ptp); | 1235 » PTP_CNT_INIT(ptp, PTP_OC_GetFilesystemManifest, storage, objectformatcod
e, associationOH); |
| 691 » ptp.Code=PTP_OC_GetFilesystemManifest; | 1236 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, NULL); |
| 692 » ptp.Param1=storage; | |
| 693 » ptp.Param2=objectformatcode; | |
| 694 » ptp.Param3=associationOH; | |
| 695 » ptp.Nparam=3; | |
| 696 » len=0; | |
| 697 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, &len); | |
| 698 » return ret; | |
| 699 } | 1237 } |
| 700 | 1238 |
| 701 /** | 1239 /** |
| 702 * ptp_getnumobjects: | 1240 * ptp_getnumobjects: |
| 703 * params: PTPParams* | 1241 * params: PTPParams* |
| 704 * storage - StorageID | 1242 * storage - StorageID |
| 705 * objectformatcode - ObjectFormatCode (optional) | 1243 * objectformatcode - ObjectFormatCode (optional) |
| 706 * associationOH - ObjectHandle of Association for | 1244 * associationOH - ObjectHandle of Association for |
| 707 * wich a list of children is desired | 1245 * wich a list of children is desired |
| 708 * (optional) | 1246 * (optional) |
| 709 * numobs - pointer to uint32_t that takes number
of objects | 1247 * numobs - pointer to uint32_t that takes number
of objects |
| 710 * | 1248 * |
| 711 * Fills numobs with number of objects on device. | 1249 * Fills numobs with number of objects on device. |
| 712 * | 1250 * |
| 713 * Return values: Some PTP_RC_* code. | 1251 * Return values: Some PTP_RC_* code. |
| 714 **/ | 1252 **/ |
| 715 uint16_t | 1253 uint16_t |
| 716 ptp_getnumobjects (PTPParams* params, uint32_t storage, | 1254 ptp_getnumobjects (PTPParams* params, uint32_t storage, |
| 717 uint32_t objectformatcode, uint32_t associationOH, | 1255 uint32_t objectformatcode, uint32_t associationOH, |
| 718 uint32_t* numobs) | 1256 uint32_t* numobs) |
| 719 { | 1257 { |
| 720 » uint16_t ret; | 1258 » PTPContainer» ptp; |
| 721 » PTPContainer ptp; | |
| 722 | 1259 |
| 723 » PTP_CNT_INIT(ptp); | 1260 » PTP_CNT_INIT(ptp, PTP_OC_GetNumObjects, storage, objectformatcode, assoc
iationOH); |
| 724 » ptp.Code=PTP_OC_GetNumObjects; | 1261 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL)
); |
| 725 » ptp.Param1=storage; | 1262 » if (ptp.Nparam >= 1) |
| 726 » ptp.Param2=objectformatcode; | 1263 » » *numobs = ptp.Param1; |
| 727 » ptp.Param3=associationOH; | 1264 » else |
| 728 » ptp.Nparam=3; | 1265 » » return PTP_RC_GeneralError; |
| 729 » ret=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL); | 1266 » return PTP_RC_OK; |
| 730 » if (ret == PTP_RC_OK) { | |
| 731 » » if (ptp.Nparam >= 1) | |
| 732 » » » *numobs = ptp.Param1; | |
| 733 » » else | |
| 734 » » » ret = PTP_RC_GeneralError; | |
| 735 » } | |
| 736 » return ret; | |
| 737 } | 1267 } |
| 738 | 1268 |
| 739 /** | 1269 /** |
| 740 * ptp_eos_bulbstart: | 1270 * ptp_eos_bulbstart: |
| 741 * params: PTPParams* | 1271 * params: PTPParams* |
| 742 * | 1272 * |
| 743 * Starts EOS Bulb capture. | 1273 * Starts EOS Bulb capture. |
| 744 * | 1274 * |
| 745 * Return values: Some PTP_RC_* code. | 1275 * Return values: Some PTP_RC_* code. |
| 746 **/ | 1276 **/ |
| 747 uint16_t | 1277 uint16_t |
| 748 ptp_canon_eos_bulbstart (PTPParams* params) | 1278 ptp_canon_eos_bulbstart (PTPParams* params) |
| 749 { | 1279 { |
| 750 » uint16_t ret; | 1280 » PTPContainer» ptp; |
| 751 » PTPContainer ptp; | |
| 752 | 1281 |
| 753 » PTP_CNT_INIT(ptp); | 1282 » PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_BulbStart); |
| 754 » ptp.Code = PTP_OC_CANON_EOS_BulbStart; | 1283 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL)
); |
| 755 » ptp.Nparam = 0; | 1284 » if ((ptp.Nparam >= 1) && ((ptp.Param1 & 0x7000) == 0x2000)) |
| 756 » ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL); | 1285 » » return ptp.Param1; |
| 757 » if ((ret == PTP_RC_OK) && (ptp.Nparam >= 1) && ((ptp.Param1 & 0x7000) ==
0x2000)) | 1286 » return PTP_RC_OK; |
| 758 » » ret = ptp.Param1; | |
| 759 » return ret; | |
| 760 } | 1287 } |
| 761 | 1288 |
| 762 /** | 1289 /** |
| 763 * ptp_eos_capture: | 1290 * ptp_eos_capture: |
| 764 * params: PTPParams* | 1291 * params: PTPParams* |
| 765 * uint32_t* result | 1292 * uint32_t* result |
| 766 * | 1293 * |
| 767 * This starts a EOS400D style capture. You have to use the | 1294 * This starts a EOS400D style capture. You have to use the |
| 768 * get_eos_events to find out what resulted. | 1295 * get_eos_events to find out what resulted. |
| 769 * The return value is "0" for all OK, and "1" for capture failed. (not fully co
nfirmed) | 1296 * The return value is "0" for all OK, and "1" for capture failed. (not fully co
nfirmed) |
| 770 * | 1297 * |
| 771 * Return values: Some PTP_RC_* code. | 1298 * Return values: Some PTP_RC_* code. |
| 772 **/ | 1299 **/ |
| 773 uint16_t | 1300 uint16_t |
| 774 ptp_canon_eos_capture (PTPParams* params, uint32_t *result) | 1301 ptp_canon_eos_capture (PTPParams* params, uint32_t *result) |
| 775 { | 1302 { |
| 776 » uint16_t ret; | 1303 » PTPContainer» ptp; |
| 777 » PTPContainer ptp; | |
| 778 | 1304 |
| 779 » PTP_CNT_INIT(ptp); | 1305 » PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_RemoteRelease); |
| 780 » ptp.Code = PTP_OC_CANON_EOS_RemoteRelease; | |
| 781 » ptp.Nparam = 0; | |
| 782 *result = 0; | 1306 *result = 0; |
| 783 » ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL); | 1307 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL)
); |
| 784 » if ((ret == PTP_RC_OK) && (ptp.Nparam >= 1)) | 1308 » if (ptp.Nparam >= 1) |
| 785 *result = ptp.Param1; | 1309 *result = ptp.Param1; |
| 786 » return ret; | 1310 » return PTP_RC_OK; |
| 787 } | 1311 } |
| 788 | 1312 |
| 789 /** | 1313 /** |
| 790 * ptp_canon_eos_bulbend: | 1314 * ptp_canon_eos_bulbend: |
| 791 * params: PTPParams* | 1315 * params: PTPParams* |
| 792 * | 1316 * |
| 793 * Starts EOS Bulb capture. | 1317 * Starts EOS Bulb capture. |
| 794 * | 1318 * |
| 795 * Return values: Some PTP_RC_* code. | 1319 * Return values: Some PTP_RC_* code. |
| 796 **/ | 1320 **/ |
| 797 uint16_t | 1321 uint16_t |
| 798 ptp_canon_eos_bulbend (PTPParams* params) | 1322 ptp_canon_eos_bulbend (PTPParams* params) |
| 799 { | 1323 { |
| 800 » uint16_t ret; | 1324 » PTPContainer» ptp; |
| 801 » PTPContainer ptp; | |
| 802 | 1325 |
| 803 » PTP_CNT_INIT(ptp); | 1326 » PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_BulbEnd); |
| 804 » ptp.Code = PTP_OC_CANON_EOS_BulbEnd; | 1327 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL)
); |
| 805 » ptp.Nparam = 0; | 1328 » if ((ptp.Nparam >= 1) && ((ptp.Param1 & 0x7000) == 0x2000)) |
| 806 » ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL); | 1329 » » return ptp.Param1; |
| 807 » if ((ret == PTP_RC_OK) && (ptp.Nparam >= 1) && ((ptp.Param1 & 0x7000) ==
0x2000)) | 1330 » return PTP_RC_OK; |
| 808 » » ret = ptp.Param1; | |
| 809 » return ret; | |
| 810 } | 1331 } |
| 811 | 1332 |
| 812 /** | 1333 /** |
| 813 * ptp_getobjectinfo: | 1334 * ptp_getobjectinfo: |
| 814 * params: PTPParams* | 1335 * params: PTPParams* |
| 815 * handle - Object handle | 1336 * handle - Object handle |
| 816 * objectinfo - pointer to objectinfo that is returned | 1337 * objectinfo - pointer to objectinfo that is returned |
| 817 * | 1338 * |
| 818 * Get objectinfo structure for handle from device. | 1339 * Get objectinfo structure for handle from device. |
| 819 * | 1340 * |
| 820 * Return values: Some PTP_RC_* code. | 1341 * Return values: Some PTP_RC_* code. |
| 821 **/ | 1342 **/ |
| 822 uint16_t | 1343 uint16_t |
| 823 ptp_getobjectinfo (PTPParams* params, uint32_t handle, | 1344 ptp_getobjectinfo (PTPParams* params, uint32_t handle, |
| 824 PTPObjectInfo* objectinfo) | 1345 PTPObjectInfo* objectinfo) |
| 825 { | 1346 { |
| 826 » uint16_t ret; | 1347 » PTPContainer» ptp; |
| 827 » PTPContainer ptp; | 1348 » unsigned char» *data; |
| 828 » unsigned char* oi=NULL; | 1349 » unsigned int» size; |
| 829 » unsigned int len; | |
| 830 | 1350 |
| 831 » PTP_CNT_INIT(ptp); | 1351 » PTP_CNT_INIT(ptp, PTP_OC_GetObjectInfo, handle); |
| 832 » ptp.Code=PTP_OC_GetObjectInfo; | 1352 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 833 » ptp.Param1=handle; | 1353 » ptp_unpack_OI(params, data, objectinfo, size); |
| 834 » ptp.Nparam=1; | 1354 » free(data); |
| 835 » len=0; | 1355 » return PTP_RC_OK; |
| 836 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &oi, &len); | |
| 837 » if (ret == PTP_RC_OK) ptp_unpack_OI(params, oi, objectinfo, len); | |
| 838 » free(oi); | |
| 839 » return ret; | |
| 840 } | 1356 } |
| 841 | 1357 |
| 842 /** | 1358 /** |
| 843 * ptp_getobject: | 1359 * ptp_getobject: |
| 844 * params: PTPParams* | 1360 * params: PTPParams* |
| 845 * handle - Object handle | 1361 * handle - Object handle |
| 846 * object - pointer to data area | 1362 * object - pointer to data area |
| 847 * | 1363 * |
| 848 * Get object 'handle' from device and store the data in newly | 1364 * Get object 'handle' from device and store the data in newly |
| 849 * allocated 'object'. | 1365 * allocated 'object'. |
| 850 * | 1366 * |
| 851 * Return values: Some PTP_RC_* code. | 1367 * Return values: Some PTP_RC_* code. |
| 852 **/ | 1368 **/ |
| 853 uint16_t | 1369 uint16_t |
| 854 ptp_getobject (PTPParams* params, uint32_t handle, unsigned char** object) | 1370 ptp_getobject (PTPParams* params, uint32_t handle, unsigned char** object) |
| 855 { | 1371 { |
| 856 PTPContainer ptp; | 1372 PTPContainer ptp; |
| 857 unsigned int len; | |
| 858 | 1373 |
| 859 » PTP_CNT_INIT(ptp); | 1374 » PTP_CNT_INIT(ptp, PTP_OC_GetObject, handle); |
| 860 » ptp.Code=PTP_OC_GetObject; | 1375 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, NULL); |
| 861 » ptp.Param1=handle; | |
| 862 » ptp.Nparam=1; | |
| 863 » len=0; | |
| 864 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, &len); | |
| 865 } | 1376 } |
| 866 | 1377 |
| 867 /** | 1378 /** |
| 868 * ptp_getobject_to_handler: | 1379 * ptp_getobject_to_handler: |
| 869 * params: PTPParams* | 1380 * params: PTPParams* |
| 870 * handle - Object handle | 1381 * handle - Object handle |
| 871 * PTPDataHandler* - pointer datahandler | 1382 * PTPDataHandler* - pointer datahandler |
| 872 * | 1383 * |
| 873 * Get object 'handle' from device and store the data in newly | 1384 * Get object 'handle' from device and store the data in newly |
| 874 * allocated 'object'. | 1385 * allocated 'object'. |
| 875 * | 1386 * |
| 876 * Return values: Some PTP_RC_* code. | 1387 * Return values: Some PTP_RC_* code. |
| 877 **/ | 1388 **/ |
| 878 uint16_t | 1389 uint16_t |
| 879 ptp_getobject_to_handler (PTPParams* params, uint32_t handle, PTPDataHandler *ha
ndler) | 1390 ptp_getobject_to_handler (PTPParams* params, uint32_t handle, PTPDataHandler *ha
ndler) |
| 880 { | 1391 { |
| 881 PTPContainer ptp; | 1392 PTPContainer ptp; |
| 882 | 1393 |
| 883 » PTP_CNT_INIT(ptp); | 1394 » PTP_CNT_INIT(ptp, PTP_OC_GetObject, handle); |
| 884 » ptp.Code=PTP_OC_GetObject; | |
| 885 » ptp.Param1=handle; | |
| 886 » ptp.Nparam=1; | |
| 887 return ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, handler); | 1395 return ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, handler); |
| 888 } | 1396 } |
| 889 | 1397 |
| 890 /** | 1398 /** |
| 891 * ptp_getobject_tofd: | 1399 * ptp_getobject_tofd: |
| 892 * params: PTPParams* | 1400 * params: PTPParams* |
| 893 * handle - Object handle | 1401 * handle - Object handle |
| 894 * fd - File descriptor to write() to | 1402 * fd - File descriptor to write() to |
| 895 * | 1403 * |
| 896 * Get object 'handle' from device and write the data to the | 1404 * Get object 'handle' from device and write the data to the |
| 897 * given file descriptor. | 1405 * given file descriptor. |
| 898 * | 1406 * |
| 899 * Return values: Some PTP_RC_* code. | 1407 * Return values: Some PTP_RC_* code. |
| 900 **/ | 1408 **/ |
| 901 uint16_t | 1409 uint16_t |
| 902 ptp_getobject_tofd (PTPParams* params, uint32_t handle, int fd) | 1410 ptp_getobject_tofd (PTPParams* params, uint32_t handle, int fd) |
| 903 { | 1411 { |
| 904 PTPContainer ptp; | 1412 PTPContainer ptp; |
| 905 PTPDataHandler handler; | 1413 PTPDataHandler handler; |
| 906 uint16_t ret; | 1414 uint16_t ret; |
| 907 | 1415 |
| 1416 PTP_CNT_INIT(ptp, PTP_OC_GetObject, handle); |
| 908 ptp_init_fd_handler (&handler, fd); | 1417 ptp_init_fd_handler (&handler, fd); |
| 909 PTP_CNT_INIT(ptp); | |
| 910 ptp.Code=PTP_OC_GetObject; | |
| 911 ptp.Param1=handle; | |
| 912 ptp.Nparam=1; | |
| 913 ret = ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler); | 1418 ret = ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler); |
| 914 ptp_exit_fd_handler (&handler); | 1419 ptp_exit_fd_handler (&handler); |
| 915 return ret; | 1420 return ret; |
| 916 } | 1421 } |
| 917 | 1422 |
| 918 /** | 1423 /** |
| 919 * ptp_getpartialobject: | 1424 * ptp_getpartialobject: |
| 920 * params: PTPParams* | 1425 * params: PTPParams* |
| 921 * handle - Object handle | 1426 * handle - Object handle |
| 922 * offset - Offset into object | 1427 * offset - Offset into object |
| 923 * maxbytes - Maximum of bytes to read | 1428 * maxbytes - Maximum of bytes to read |
| 924 * object - pointer to data area | 1429 * object - pointer to data area |
| 925 * len - pointer to returned length | 1430 * len - pointer to returned length |
| 926 * | 1431 * |
| 927 * Get object 'handle' from device and store the data in newly | 1432 * Get object 'handle' from device and store the data in newly |
| 928 * allocated 'object'. Start from offset and read at most maxbytes. | 1433 * allocated 'object'. Start from offset and read at most maxbytes. |
| 929 * | 1434 * |
| 930 * Return values: Some PTP_RC_* code. | 1435 * Return values: Some PTP_RC_* code. |
| 931 **/ | 1436 **/ |
| 932 uint16_t | 1437 uint16_t |
| 933 ptp_getpartialobject (PTPParams* params, uint32_t handle, uint32_t offset, | 1438 ptp_getpartialobject (PTPParams* params, uint32_t handle, uint32_t offset, |
| 934 uint32_t maxbytes, unsigned char** object, | 1439 uint32_t maxbytes, unsigned char** object, |
| 935 uint32_t *len) | 1440 uint32_t *len) |
| 936 { | 1441 { |
| 937 PTPContainer ptp; | 1442 PTPContainer ptp; |
| 938 | 1443 |
| 939 » PTP_CNT_INIT(ptp); | 1444 » PTP_CNT_INIT(ptp, PTP_OC_GetPartialObject, handle, offset, maxbytes); |
| 940 » ptp.Code=PTP_OC_GetPartialObject; | |
| 941 » ptp.Param1=handle; | |
| 942 » ptp.Param2=offset; | |
| 943 » ptp.Param3=maxbytes; | |
| 944 » ptp.Nparam=3; | |
| 945 » *len=0; | |
| 946 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, len); | 1445 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, len); |
| 947 } | 1446 } |
| 948 | 1447 |
| 949 /** | 1448 /** |
| 1449 * ptp_getpartialobject_to_handler: |
| 1450 * params: PTPParams* |
| 1451 * handle - Object handle |
| 1452 * offset - Offset into object |
| 1453 * maxbytes - Maximum of bytes to read |
| 1454 * handler - a ptp data handler |
| 1455 * |
| 1456 * Get object 'handle' from device and send the data to the |
| 1457 * data handler. Start from offset and read at most maxbytes. |
| 1458 * |
| 1459 * Return values: Some PTP_RC_* code. |
| 1460 **/ |
| 1461 uint16_t |
| 1462 ptp_getpartialobject_to_handler (PTPParams* params, uint32_t handle, uint32_t of
fset, |
| 1463 uint32_t maxbytes, PTPDataHandler *handler) |
| 1464 { |
| 1465 PTPContainer ptp; |
| 1466 |
| 1467 PTP_CNT_INIT(ptp, PTP_OC_GetPartialObject, handle, offset, maxbytes); |
| 1468 return ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, handler); |
| 1469 } |
| 1470 |
| 1471 /** |
| 950 * ptp_getthumb: | 1472 * ptp_getthumb: |
| 951 * params: PTPParams* | 1473 * params: PTPParams* |
| 952 * handle - Object handle | 1474 * handle - Object handle |
| 953 * object - pointer to data area | 1475 * object - pointer to data area |
| 954 * | 1476 * |
| 955 * Get thumb for object 'handle' from device and store the data in newly | 1477 * Get thumb for object 'handle' from device and store the data in newly |
| 956 * allocated 'object'. | 1478 * allocated 'object'. |
| 957 * | 1479 * |
| 958 * Return values: Some PTP_RC_* code. | 1480 * Return values: Some PTP_RC_* code. |
| 959 **/ | 1481 **/ |
| 960 uint16_t | 1482 uint16_t |
| 961 ptp_getthumb (PTPParams* params, uint32_t handle, unsigned char** object, unsign
ed int *len) | 1483 ptp_getthumb (PTPParams* params, uint32_t handle, unsigned char** object, unsign
ed int *len) |
| 962 { | 1484 { |
| 963 PTPContainer ptp; | 1485 PTPContainer ptp; |
| 964 | 1486 |
| 965 » PTP_CNT_INIT(ptp); | 1487 » PTP_CNT_INIT(ptp, PTP_OC_GetThumb, handle); |
| 966 » ptp.Code=PTP_OC_GetThumb; | |
| 967 » ptp.Param1=handle; | |
| 968 » ptp.Nparam=1; | |
| 969 » *len = 0; | |
| 970 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, len); | 1488 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, len); |
| 971 } | 1489 } |
| 972 | 1490 |
| 973 /** | 1491 /** |
| 974 * ptp_deleteobject: | 1492 * ptp_deleteobject: |
| 975 * params: PTPParams* | 1493 * params: PTPParams* |
| 976 * handle - object handle | 1494 * handle - object handle |
| 977 * ofc - object format code (optional) | 1495 * ofc - object format code (optional) |
| 978 * | 1496 * |
| 979 * Deletes desired objects. | 1497 * Deletes desired objects. |
| 980 * | 1498 * |
| 981 * Return values: Some PTP_RC_* code. | 1499 * Return values: Some PTP_RC_* code. |
| 982 **/ | 1500 **/ |
| 983 uint16_t | 1501 uint16_t |
| 984 ptp_deleteobject (PTPParams* params, uint32_t handle, uint32_t ofc) | 1502 ptp_deleteobject (PTPParams* params, uint32_t handle, uint32_t ofc) |
| 985 { | 1503 { |
| 986 PTPContainer ptp; | 1504 PTPContainer ptp; |
| 987 uint16_t ret; | |
| 988 | 1505 |
| 989 » PTP_CNT_INIT(ptp); | 1506 » PTP_CNT_INIT(ptp, PTP_OC_DeleteObject, handle, ofc); |
| 990 » ptp.Code=PTP_OC_DeleteObject; | 1507 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL)
); |
| 991 » ptp.Param1=handle; | |
| 992 » ptp.Param2=ofc; | |
| 993 » ptp.Nparam=2; | |
| 994 » ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL); | |
| 995 » if (ret != PTP_RC_OK) { | |
| 996 » » return ret; | |
| 997 » } | |
| 998 /* If the object is cached and could be removed, cleanse cache. */ | 1508 /* If the object is cached and could be removed, cleanse cache. */ |
| 999 ptp_remove_object_from_cache(params, handle); | 1509 ptp_remove_object_from_cache(params, handle); |
| 1000 return PTP_RC_OK; | 1510 return PTP_RC_OK; |
| 1001 } | 1511 } |
| 1002 | 1512 |
| 1003 /** | 1513 /** |
| 1004 * ptp_sendobjectinfo: | 1514 * ptp_sendobjectinfo: |
| 1005 * params: PTPParams* | 1515 * params: PTPParams* |
| 1006 * uint32_t* store - destination StorageID on Responder | 1516 * uint32_t* store - destination StorageID on Responder |
| 1007 * uint32_t* parenthandle - Parent ObjectHandle on responder | 1517 * uint32_t* parenthandle - Parent ObjectHandle on responder |
| 1008 * uint32_t* handle - see Return values | 1518 * uint32_t* handle - see Return values |
| 1009 * PTPObjectInfo* objectinfo- ObjectInfo that is to be sent | 1519 * PTPObjectInfo* objectinfo- ObjectInfo that is to be sent |
| 1010 * | 1520 * |
| 1011 * Sends ObjectInfo of file that is to be sent via SendFileObject. | 1521 * Sends ObjectInfo of file that is to be sent via SendFileObject. |
| 1012 * | 1522 * |
| 1013 * Return values: Some PTP_RC_* code. | 1523 * Return values: Some PTP_RC_* code. |
| 1014 * Upon success : uint32_t* store - Responder StorageID in which | 1524 * Upon success : uint32_t* store - Responder StorageID in which |
| 1015 * object will be stored | 1525 * object will be stored |
| 1016 * uint32_t* parenthandle- Responder Parent ObjectHandle | 1526 * uint32_t* parenthandle- Responder Parent ObjectHandle |
| 1017 * in which the object will be stored | 1527 * in which the object will be stored |
| 1018 * uint32_t* handle - Responder's reserved ObjectHandle | 1528 * uint32_t* handle - Responder's reserved ObjectHandle |
| 1019 * for the incoming object | 1529 * for the incoming object |
| 1020 **/ | 1530 **/ |
| 1021 uint16_t | 1531 uint16_t |
| 1022 ptp_sendobjectinfo (PTPParams* params, uint32_t* store, | 1532 ptp_sendobjectinfo (PTPParams* params, uint32_t* store, |
| 1023 uint32_t* parenthandle, uint32_t* handle, | 1533 uint32_t* parenthandle, uint32_t* handle, |
| 1024 PTPObjectInfo* objectinfo) | 1534 PTPObjectInfo* objectinfo) |
| 1025 { | 1535 { |
| 1026 » uint16_t ret; | 1536 » PTPContainer» ptp; |
| 1027 » PTPContainer ptp; | 1537 » uint16_t» ret; |
| 1028 » unsigned char* oidata=NULL; | 1538 » unsigned char» *data = NULL; |
| 1029 » uint32_t size; | 1539 » uint32_t» size; |
| 1030 | 1540 |
| 1031 » PTP_CNT_INIT(ptp); | 1541 » PTP_CNT_INIT(ptp, PTP_OC_SendObjectInfo, *store, *parenthandle); |
| 1032 » ptp.Code=PTP_OC_SendObjectInfo; | 1542 » size = ptp_pack_OI(params, objectinfo, &data); |
| 1033 » ptp.Param1=*store; | 1543 » ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL); |
| 1034 » ptp.Param2=*parenthandle; | 1544 » free(data); |
| 1035 » ptp.Nparam=2; | |
| 1036 » | |
| 1037 » size=ptp_pack_OI(params, objectinfo, &oidata); | |
| 1038 » ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &oidata, NULL
); | |
| 1039 » free(oidata); | |
| 1040 *store=ptp.Param1; | 1545 *store=ptp.Param1; |
| 1041 *parenthandle=ptp.Param2; | 1546 *parenthandle=ptp.Param2; |
| 1042 *handle=ptp.Param3; | 1547 *handle=ptp.Param3; |
| 1043 return ret; | 1548 return ret; |
| 1044 } | 1549 } |
| 1045 | 1550 |
| 1046 /** | 1551 /** |
| 1047 * ptp_sendobject: | 1552 * ptp_sendobject: |
| 1048 * params: PTPParams* | 1553 * params: PTPParams* |
| 1049 * char* object - contains the object that is to be sent | 1554 * char* object - contains the object that is to be sent |
| 1050 *» » uint32_t size» » - object size | 1555 *» » uint64_t size» » - object size |
| 1051 * | 1556 * |
| 1052 * Sends object to Responder. | 1557 * Sends object to Responder. |
| 1053 * | 1558 * |
| 1054 * Return values: Some PTP_RC_* code. | 1559 * Return values: Some PTP_RC_* code. |
| 1055 * | 1560 * |
| 1056 */ | 1561 */ |
| 1057 uint16_t | 1562 uint16_t |
| 1058 ptp_sendobject (PTPParams* params, unsigned char* object, uint32_t size) | 1563 ptp_sendobject (PTPParams* params, unsigned char* object, uint64_t size) |
| 1059 { | 1564 { |
| 1060 PTPContainer ptp; | 1565 PTPContainer ptp; |
| 1061 | 1566 |
| 1062 » PTP_CNT_INIT(ptp); | 1567 » PTP_CNT_INIT(ptp, PTP_OC_SendObject); |
| 1063 » ptp.Code=PTP_OC_SendObject; | |
| 1064 » ptp.Nparam=0; | |
| 1065 | |
| 1066 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &object, NUL
L); | 1568 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &object, NUL
L); |
| 1067 } | 1569 } |
| 1068 | 1570 |
| 1069 /** | 1571 /** |
| 1070 * ptp_sendobject_from_handler: | 1572 * ptp_sendobject_from_handler: |
| 1071 * params: PTPParams* | 1573 * params: PTPParams* |
| 1072 * PTPDataHandler* - File descriptor to read() object from | 1574 * PTPDataHandler* - File descriptor to read() object from |
| 1073 * uint32_t size - File/object size | 1575 * uint64_t size - File/object size |
| 1074 * | 1576 * |
| 1075 * Sends object from file descriptor by consecutive reads from this | 1577 * Sends object from file descriptor by consecutive reads from this |
| 1076 * descriptor. | 1578 * descriptor. |
| 1077 * | 1579 * |
| 1078 * Return values: Some PTP_RC_* code. | 1580 * Return values: Some PTP_RC_* code. |
| 1079 **/ | 1581 **/ |
| 1080 uint16_t | 1582 uint16_t |
| 1081 ptp_sendobject_from_handler (PTPParams* params, PTPDataHandler *handler, uint32_
t size) | 1583 ptp_sendobject_from_handler (PTPParams* params, PTPDataHandler *handler, uint64_
t size) |
| 1082 { | 1584 { |
| 1083 » PTPContainer» ptp; | 1585 » PTPContainer ptp; |
| 1084 | 1586 |
| 1085 » PTP_CNT_INIT(ptp); | 1587 » PTP_CNT_INIT(ptp, PTP_OC_SendObject); |
| 1086 » ptp.Code=PTP_OC_SendObject; | |
| 1087 » ptp.Nparam=0; | |
| 1088 return ptp_transaction_new(params, &ptp, PTP_DP_SENDDATA, size, handler)
; | 1588 return ptp_transaction_new(params, &ptp, PTP_DP_SENDDATA, size, handler)
; |
| 1089 } | 1589 } |
| 1090 | 1590 |
| 1091 | 1591 |
| 1092 /** | 1592 /** |
| 1093 * ptp_sendobject_fromfd: | 1593 * ptp_sendobject_fromfd: |
| 1094 * params: PTPParams* | 1594 * params: PTPParams* |
| 1095 * fd - File descriptor to read() object from | 1595 * fd - File descriptor to read() object from |
| 1096 * uint32_t size - File/object size | 1596 * uint64_t size - File/object size |
| 1097 * | 1597 * |
| 1098 * Sends object from file descriptor by consecutive reads from this | 1598 * Sends object from file descriptor by consecutive reads from this |
| 1099 * descriptor. | 1599 * descriptor. |
| 1100 * | 1600 * |
| 1101 * Return values: Some PTP_RC_* code. | 1601 * Return values: Some PTP_RC_* code. |
| 1102 **/ | 1602 **/ |
| 1103 uint16_t | 1603 uint16_t |
| 1104 ptp_sendobject_fromfd (PTPParams* params, int fd, uint32_t size) | 1604 ptp_sendobject_fromfd (PTPParams* params, int fd, uint64_t size) |
| 1105 { | 1605 { |
| 1106 PTPContainer ptp; | 1606 PTPContainer ptp; |
| 1107 PTPDataHandler handler; | 1607 PTPDataHandler handler; |
| 1108 uint16_t ret; | 1608 uint16_t ret; |
| 1109 | 1609 |
| 1610 PTP_CNT_INIT(ptp, PTP_OC_SendObject); |
| 1110 ptp_init_fd_handler (&handler, fd); | 1611 ptp_init_fd_handler (&handler, fd); |
| 1111 PTP_CNT_INIT(ptp); | |
| 1112 ptp.Code=PTP_OC_SendObject; | |
| 1113 ptp.Nparam=0; | |
| 1114 ret = ptp_transaction_new(params, &ptp, PTP_DP_SENDDATA, size, &handler)
; | 1612 ret = ptp_transaction_new(params, &ptp, PTP_DP_SENDDATA, size, &handler)
; |
| 1115 ptp_exit_fd_handler (&handler); | 1613 ptp_exit_fd_handler (&handler); |
| 1116 return ret; | 1614 return ret; |
| 1117 } | 1615 } |
| 1118 | 1616 |
| 1617 #define PROPCACHE_TIMEOUT 5 /* seconds */ |
| 1119 | 1618 |
| 1120 uint16_t | 1619 uint16_t |
| 1121 ptp_getdevicepropdesc (PTPParams* params, uint16_t propcode, | 1620 ptp_getdevicepropdesc (PTPParams* params, uint16_t propcode, |
| 1122 PTPDevicePropDesc* devicepropertydesc) | 1621 PTPDevicePropDesc* devicepropertydesc) |
| 1123 { | 1622 { |
| 1124 » PTPContainer ptp; | 1623 » PTPContainer» ptp; |
| 1125 » uint16_t ret; | 1624 » uint16_t» ret = PTP_RC_OK; |
| 1126 » unsigned int len; | 1625 » unsigned char» *data; |
| 1127 » unsigned char* dpd=NULL; | 1626 » unsigned int» size; |
| 1128 | 1627 |
| 1129 » PTP_CNT_INIT(ptp); | 1628 » PTP_CNT_INIT(ptp, PTP_OC_GetDevicePropDesc, propcode); |
| 1130 » ptp.Code=PTP_OC_GetDevicePropDesc; | 1629 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 1131 » ptp.Param1=propcode; | 1630 |
| 1132 » ptp.Nparam=1; | 1631 » if (params->device_flags & DEVICE_FLAG_OLYMPUS_XML_WRAPPED) { |
| 1133 » len=0; | 1632 #ifdef HAVE_LIBXML2 |
| 1134 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpd, &len); | 1633 » » xmlNodePtr» code; |
| 1135 » if (ret == PTP_RC_OK) ptp_unpack_DPD(params, dpd, devicepropertydesc, le
n); | 1634 |
| 1136 » free(dpd); | 1635 » » ret = ptp_olympus_parse_output_xml (params,(char*)data,size,&cod
e); |
| 1636 » » if (ret == PTP_RC_OK) { |
| 1637 » » » int x; |
| 1638 |
| 1639 » » » if (» (xmlChildElementCount(code) == 1) && |
| 1640 » » » » » (!strcmp((char*)code->name,"c1014")) |
| 1641 » » » » » ) { |
| 1642 » » » » code = xmlFirstElementChild (code); |
| 1643 |
| 1644 » » » » if (» (sscanf((char*)code->name,"p%x", &x)) && |
| 1645 » » » » » » (x == propcode) |
| 1646 » » » » » » ) { |
| 1647 » » » » » ret = parse_9301_propdesc (params, xmlFi
rstElementChild (code), devicepropertydesc); |
| 1648 » » » » » xmlFreeDoc(code->doc); |
| 1649 » » » » } |
| 1650 » » » } |
| 1651 » » } else { |
| 1652 » » » ptp_debug(params,"failed to parse output xml, ret %x?",
ret); |
| 1653 » » } |
| 1654 #endif |
| 1655 » } else { |
| 1656 » » ptp_unpack_DPD(params, data, devicepropertydesc, size); |
| 1657 » } |
| 1658 » free(data); |
| 1137 return ret; | 1659 return ret; |
| 1138 } | 1660 } |
| 1139 | 1661 |
| 1140 | 1662 |
| 1141 uint16_t | 1663 uint16_t |
| 1142 ptp_getdevicepropvalue (PTPParams* params, uint16_t propcode, | 1664 ptp_getdevicepropvalue (PTPParams* params, uint16_t propcode, |
| 1143 PTPPropertyValue* value, uint16_t datatype) | 1665 PTPPropertyValue* value, uint16_t datatype) |
| 1144 { | 1666 { |
| 1145 » PTPContainer ptp; | 1667 » PTPContainer» ptp; |
| 1146 » uint16_t ret; | 1668 » unsigned char» *data; |
| 1147 » unsigned int len; | 1669 » unsigned int» size, offset = 0; |
| 1148 » int offset; | 1670 » uint16_t» ret; |
| 1149 » unsigned char* dpv=NULL; | |
| 1150 | 1671 |
| 1151 | 1672 » PTP_CNT_INIT(ptp, PTP_OC_GetDevicePropValue, propcode); |
| 1152 » PTP_CNT_INIT(ptp); | 1673 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 1153 » ptp.Code=PTP_OC_GetDevicePropValue; | 1674 » ret = ptp_unpack_DPV(params, data, &offset, size, value, datatype) ? PTP
_RC_OK : PTP_RC_GeneralError; |
| 1154 » ptp.Param1=propcode; | 1675 » if (ret != PTP_RC_OK) |
| 1155 » ptp.Nparam=1; | 1676 » » ptp_debug (params, "ptp_getdevicepropvalue: unpacking DPV failed
"); |
| 1156 » len=offset=0; | 1677 » free(data); |
| 1157 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpv, &len); | |
| 1158 » if (ret == PTP_RC_OK) ptp_unpack_DPV(params, dpv, &offset, len, value, d
atatype); | |
| 1159 » free(dpv); | |
| 1160 return ret; | 1678 return ret; |
| 1161 } | 1679 } |
| 1162 | 1680 |
| 1163 uint16_t | 1681 uint16_t |
| 1164 ptp_setdevicepropvalue (PTPParams* params, uint16_t propcode, | 1682 ptp_setdevicepropvalue (PTPParams* params, uint16_t propcode, |
| 1165 PTPPropertyValue *value, uint16_t datatype) | 1683 PTPPropertyValue *value, uint16_t datatype) |
| 1166 { | 1684 { |
| 1167 » PTPContainer ptp; | 1685 » PTPContainer» ptp; |
| 1168 » uint16_t ret; | 1686 » uint16_t» ret; |
| 1169 » uint32_t size; | 1687 » unsigned char» *data = NULL; |
| 1170 » unsigned char* dpv=NULL; | 1688 » uint32_t» size; |
| 1171 | 1689 |
| 1172 » PTP_CNT_INIT(ptp); | 1690 » PTP_CNT_INIT(ptp, PTP_OC_SetDevicePropValue, propcode); |
| 1173 » ptp.Code=PTP_OC_SetDevicePropValue; | 1691 » size=ptp_pack_DPV(params, value, &data, datatype); |
| 1174 » ptp.Param1=propcode; | 1692 » ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL); |
| 1175 » ptp.Nparam=1; | 1693 » free(data); |
| 1176 » size=ptp_pack_DPV(params, value, &dpv, datatype); | |
| 1177 » ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &dpv, NULL); | |
| 1178 » free(dpv); | |
| 1179 return ret; | 1694 return ret; |
| 1180 } | 1695 } |
| 1181 | 1696 |
| 1182 /** | 1697 /** |
| 1183 * ptp_ek_sendfileobjectinfo: | 1698 * ptp_ek_sendfileobjectinfo: |
| 1184 * params: PTPParams* | 1699 * params: PTPParams* |
| 1185 * uint32_t* store - destination StorageID on Responder | 1700 * uint32_t* store - destination StorageID on Responder |
| 1186 * uint32_t* parenthandle - Parent ObjectHandle on responder | 1701 * uint32_t* parenthandle - Parent ObjectHandle on responder |
| 1187 * uint32_t* handle - see Return values | 1702 * uint32_t* handle - see Return values |
| 1188 * PTPObjectInfo* objectinfo- ObjectInfo that is to be sent | 1703 * PTPObjectInfo* objectinfo- ObjectInfo that is to be sent |
| 1189 * | 1704 * |
| 1190 * Sends ObjectInfo of file that is to be sent via SendFileObject. | 1705 * Sends ObjectInfo of file that is to be sent via SendFileObject. |
| 1191 * | 1706 * |
| 1192 * Return values: Some PTP_RC_* code. | 1707 * Return values: Some PTP_RC_* code. |
| 1193 * Upon success : uint32_t* store - Responder StorageID in which | 1708 * Upon success : uint32_t* store - Responder StorageID in which |
| 1194 * object will be stored | 1709 * object will be stored |
| 1195 * uint32_t* parenthandle- Responder Parent ObjectHandle | 1710 * uint32_t* parenthandle- Responder Parent ObjectHandle |
| 1196 * in which the object will be stored | 1711 * in which the object will be stored |
| 1197 * uint32_t* handle - Responder's reserved ObjectHandle | 1712 * uint32_t* handle - Responder's reserved ObjectHandle |
| 1198 * for the incoming object | 1713 * for the incoming object |
| 1199 **/ | 1714 **/ |
| 1200 uint16_t | 1715 uint16_t |
| 1201 ptp_ek_sendfileobjectinfo (PTPParams* params, uint32_t* store, | 1716 ptp_ek_sendfileobjectinfo (PTPParams* params, uint32_t* store, |
| 1202 uint32_t* parenthandle, uint32_t* handle, | 1717 uint32_t* parenthandle, uint32_t* handle, |
| 1203 PTPObjectInfo* objectinfo) | 1718 PTPObjectInfo* objectinfo) |
| 1204 { | 1719 { |
| 1205 » uint16_t ret; | 1720 » PTPContainer» ptp; |
| 1206 » PTPContainer ptp; | 1721 » uint16_t» ret; |
| 1207 » unsigned char* oidata=NULL; | 1722 » unsigned char» *data = NULL; |
| 1208 » uint32_t size; | 1723 » uint32_t» size; |
| 1209 | 1724 |
| 1210 » PTP_CNT_INIT(ptp); | 1725 » PTP_CNT_INIT(ptp, PTP_OC_EK_SendFileObjectInfo, *store, *parenthandle); |
| 1211 » ptp.Code=PTP_OC_EK_SendFileObjectInfo; | 1726 » size=ptp_pack_OI(params, objectinfo, &data); |
| 1212 » ptp.Param1=*store; | 1727 » ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL); |
| 1213 » ptp.Param2=*parenthandle; | 1728 » free(data); |
| 1214 » ptp.Nparam=2; | |
| 1215 » | |
| 1216 » size=ptp_pack_OI(params, objectinfo, &oidata); | |
| 1217 » ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &oidata, NULL);
| |
| 1218 » free(oidata); | |
| 1219 *store=ptp.Param1; | 1729 *store=ptp.Param1; |
| 1220 *parenthandle=ptp.Param2; | 1730 *parenthandle=ptp.Param2; |
| 1221 *handle=ptp.Param3; | 1731 *handle=ptp.Param3; |
| 1222 return ret; | 1732 return ret; |
| 1223 } | 1733 } |
| 1224 | 1734 |
| 1225 /** | 1735 /** |
| 1226 * ptp_ek_getserial: | 1736 * ptp_ek_getserial: |
| 1227 * params: PTPParams* | 1737 * params: PTPParams* |
| 1228 * char** serial - contains the serial number of the came
ra | 1738 * char** serial - contains the serial number of the came
ra |
| 1229 * uint32_t* size - contains the string length | 1739 * uint32_t* size - contains the string length |
| 1230 * | 1740 * |
| 1231 * Gets the serial number from the device. (ptp serial) | 1741 * Gets the serial number from the device. (ptp serial) |
| 1232 * | 1742 * |
| 1233 * Return values: Some PTP_RC_* code. | 1743 * Return values: Some PTP_RC_* code. |
| 1234 * | 1744 * |
| 1235 */ | 1745 */ |
| 1236 uint16_t | 1746 uint16_t |
| 1237 ptp_ek_getserial (PTPParams* params, unsigned char **data, unsigned int *size) | 1747 ptp_ek_getserial (PTPParams* params, unsigned char **data, unsigned int *size) |
| 1238 { | 1748 { |
| 1239 PTPContainer ptp; | 1749 PTPContainer ptp; |
| 1240 | 1750 |
| 1241 » PTP_CNT_INIT(ptp); | 1751 » PTP_CNT_INIT(ptp, PTP_OC_EK_GetSerial); |
| 1242 » ptp.Code = PTP_OC_EK_GetSerial; | |
| 1243 » ptp.Nparam = 0; | |
| 1244 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); | 1752 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); |
| 1245 } | 1753 } |
| 1246 | 1754 |
| 1247 /** | 1755 /** |
| 1248 * ptp_ek_setserial: | 1756 * ptp_ek_setserial: |
| 1249 * params: PTPParams* | 1757 * params: PTPParams* |
| 1250 * char* serial - contains the new serial number | 1758 * char* serial - contains the new serial number |
| 1251 * uint32_t size - string length | 1759 * uint32_t size - string length |
| 1252 * | 1760 * |
| 1253 * Sets the serial number of the device. (ptp serial) | 1761 * Sets the serial number of the device. (ptp serial) |
| 1254 * | 1762 * |
| 1255 * Return values: Some PTP_RC_* code. | 1763 * Return values: Some PTP_RC_* code. |
| 1256 * | 1764 * |
| 1257 */ | 1765 */ |
| 1258 uint16_t | 1766 uint16_t |
| 1259 ptp_ek_setserial (PTPParams* params, unsigned char *data, unsigned int size) | 1767 ptp_ek_setserial (PTPParams* params, unsigned char *data, unsigned int size) |
| 1260 { | 1768 { |
| 1261 PTPContainer ptp; | 1769 PTPContainer ptp; |
| 1262 | 1770 |
| 1263 » PTP_CNT_INIT(ptp); | 1771 » PTP_CNT_INIT(ptp, PTP_OC_EK_SetSerial); |
| 1264 » ptp.Code = PTP_OC_EK_SetSerial; | |
| 1265 » ptp.Nparam = 0; | |
| 1266 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL)
; | 1772 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL)
; |
| 1267 } | 1773 } |
| 1268 | 1774 |
| 1269 /* unclear what it does yet */ | 1775 /* unclear what it does yet */ |
| 1270 uint16_t | 1776 uint16_t |
| 1271 ptp_ek_9007 (PTPParams* params, unsigned char **data, unsigned int *size) | 1777 ptp_ek_9007 (PTPParams* params, unsigned char **data, unsigned int *size) |
| 1272 { | 1778 { |
| 1273 PTPContainer ptp; | 1779 PTPContainer ptp; |
| 1274 | 1780 |
| 1275 » PTP_CNT_INIT(ptp); | 1781 » PTP_CNT_INIT(ptp, 0x9007); |
| 1276 » ptp.Code = 0x9007; | |
| 1277 » ptp.Nparam = 0; | |
| 1278 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); | 1782 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); |
| 1279 } | 1783 } |
| 1280 | 1784 |
| 1281 /* unclear what it does yet */ | 1785 /* unclear what it does yet */ |
| 1282 uint16_t | 1786 uint16_t |
| 1283 ptp_ek_9009 (PTPParams* params, uint32_t *p1, uint32_t *p2) | 1787 ptp_ek_9009 (PTPParams* params, uint32_t *p1, uint32_t *p2) |
| 1284 { | 1788 { |
| 1285 PTPContainer ptp; | 1789 PTPContainer ptp; |
| 1286 uint16_t ret; | |
| 1287 | 1790 |
| 1288 » PTP_CNT_INIT(ptp); | 1791 » PTP_CNT_INIT(ptp, 0x9009); |
| 1289 » ptp.Code = 0x9009; | 1792 » *p1 = *p2 = 0; |
| 1290 » ptp.Nparam = 0; | 1793 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL)
); |
| 1291 » ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL); | |
| 1292 *p1 = ptp.Param1; | 1794 *p1 = ptp.Param1; |
| 1293 *p2 = ptp.Param2; | 1795 *p2 = ptp.Param2; |
| 1294 » return ret; | 1796 » return PTP_RC_OK; |
| 1295 } | 1797 } |
| 1296 | 1798 |
| 1297 /* unclear yet, but I guess it returns the info from 9008 */ | 1799 /* unclear yet, but I guess it returns the info from 9008 */ |
| 1298 uint16_t | 1800 uint16_t |
| 1299 ptp_ek_900c (PTPParams* params, unsigned char **data, unsigned int *size) | 1801 ptp_ek_900c (PTPParams* params, unsigned char **data, unsigned int *size) |
| 1300 { | 1802 { |
| 1301 PTPContainer ptp; | 1803 PTPContainer ptp; |
| 1302 | 1804 |
| 1303 » PTP_CNT_INIT(ptp); | 1805 » PTP_CNT_INIT(ptp, 0x900c); |
| 1304 » ptp.Code = 0x900c; | |
| 1305 » ptp.Nparam = 0; | |
| 1306 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); | 1806 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); |
| 1307 /* returned data is 16bit,16bit,32bit,32bit */ | 1807 /* returned data is 16bit,16bit,32bit,32bit */ |
| 1308 } | 1808 } |
| 1309 | 1809 |
| 1310 /** | 1810 /** |
| 1311 * ptp_ek_settext: | 1811 * ptp_ek_settext: |
| 1312 * params: PTPParams* | 1812 * params: PTPParams* |
| 1313 * PTPEKTextParams* - contains the texts to display. | 1813 * PTPEKTextParams* - contains the texts to display. |
| 1314 * | 1814 * |
| 1315 * Displays the specified texts on the TFT of the camera. | 1815 * Displays the specified texts on the TFT of the camera. |
| 1316 * | 1816 * |
| 1317 * Return values: Some PTP_RC_* code. | 1817 * Return values: Some PTP_RC_* code. |
| 1318 * | 1818 * |
| 1319 */ | 1819 */ |
| 1320 uint16_t | 1820 uint16_t |
| 1321 ptp_ek_settext (PTPParams* params, PTPEKTextParams *text) | 1821 ptp_ek_settext (PTPParams* params, PTPEKTextParams *text) |
| 1322 { | 1822 { |
| 1323 » PTPContainer ptp; | 1823 » PTPContainer» ptp; |
| 1324 » uint16_t ret; | 1824 » uint16_t» ret; |
| 1325 » unsigned int size; | 1825 » unsigned char» *data = 0; |
| 1326 » unsigned char *data; | 1826 » uint32_t» size; |
| 1327 | 1827 |
| 1328 » PTP_CNT_INIT(ptp); | 1828 » PTP_CNT_INIT(ptp, PTP_OC_EK_SetText); |
| 1329 » ptp.Code = PTP_OC_EK_SetText; | |
| 1330 » ptp.Nparam = 0; | |
| 1331 if (0 == (size = ptp_pack_EK_text(params, text, &data))) | 1829 if (0 == (size = ptp_pack_EK_text(params, text, &data))) |
| 1332 return PTP_ERROR_BADPARAM; | 1830 return PTP_ERROR_BADPARAM; |
| 1333 » ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
| 1831 » ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL); |
| 1334 free(data); | 1832 free(data); |
| 1335 return ret; | 1833 return ret; |
| 1336 } | 1834 } |
| 1337 | 1835 |
| 1338 /** | 1836 /** |
| 1339 * ptp_ek_sendfileobject: | 1837 * ptp_ek_sendfileobject: |
| 1340 * params: PTPParams* | 1838 * params: PTPParams* |
| 1341 * char* object - contains the object that is to be sent | 1839 * char* object - contains the object that is to be sent |
| 1342 * uint32_t size - object size | 1840 * uint32_t size - object size |
| 1343 * | 1841 * |
| 1344 * Sends object to Responder. | 1842 * Sends object to Responder. |
| 1345 * | 1843 * |
| 1346 * Return values: Some PTP_RC_* code. | 1844 * Return values: Some PTP_RC_* code. |
| 1347 * | 1845 * |
| 1348 */ | 1846 */ |
| 1349 uint16_t | 1847 uint16_t |
| 1350 ptp_ek_sendfileobject (PTPParams* params, unsigned char* object, uint32_t size) | 1848 ptp_ek_sendfileobject (PTPParams* params, unsigned char* object, uint32_t size) |
| 1351 { | 1849 { |
| 1352 PTPContainer ptp; | 1850 PTPContainer ptp; |
| 1353 | 1851 |
| 1354 » PTP_CNT_INIT(ptp); | 1852 » PTP_CNT_INIT(ptp, PTP_OC_EK_SendFileObject); |
| 1355 » ptp.Code=PTP_OC_EK_SendFileObject; | |
| 1356 » ptp.Nparam=0; | |
| 1357 | |
| 1358 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &object, NUL
L); | 1853 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &object, NUL
L); |
| 1359 } | 1854 } |
| 1360 | 1855 |
| 1361 /** | 1856 /** |
| 1362 * ptp_ek_sendfileobject_from_handler: | 1857 * ptp_ek_sendfileobject_from_handler: |
| 1363 * params: PTPParams* | 1858 * params: PTPParams* |
| 1364 * PTPDataHandler* handler - contains the handler of the object tha
t is to be sent | 1859 * PTPDataHandler* handler - contains the handler of the object tha
t is to be sent |
| 1365 * uint32_t size - object size | 1860 * uint32_t size - object size |
| 1366 * | 1861 * |
| 1367 * Sends object to Responder. | 1862 * Sends object to Responder. |
| 1368 * | 1863 * |
| 1369 * Return values: Some PTP_RC_* code. | 1864 * Return values: Some PTP_RC_* code. |
| 1370 * | 1865 * |
| 1371 */ | 1866 */ |
| 1372 uint16_t | 1867 uint16_t |
| 1373 ptp_ek_sendfileobject_from_handler (PTPParams* params, PTPDataHandler*handler, u
int32_t size) | 1868 ptp_ek_sendfileobject_from_handler (PTPParams* params, PTPDataHandler*handler, u
int32_t size) |
| 1374 { | 1869 { |
| 1375 PTPContainer ptp; | 1870 PTPContainer ptp; |
| 1376 | 1871 |
| 1377 » PTP_CNT_INIT(ptp); | 1872 » PTP_CNT_INIT(ptp, PTP_OC_EK_SendFileObject); |
| 1378 » ptp.Code=PTP_OC_EK_SendFileObject; | |
| 1379 » ptp.Nparam=0; | |
| 1380 return ptp_transaction_new(params, &ptp, PTP_DP_SENDDATA, size, handler)
; | 1873 return ptp_transaction_new(params, &ptp, PTP_DP_SENDDATA, size, handler)
; |
| 1381 } | 1874 } |
| 1382 | 1875 |
| 1383 /************************************************************************* | 1876 /************************************************************************* |
| 1384 * | 1877 * |
| 1385 * Canon PTP extensions support | 1878 * Canon PTP extensions support |
| 1386 * | 1879 * |
| 1387 * (C) Nikolai Kopanygin 2003 | 1880 * (C) Nikolai Kopanygin 2003 |
| 1388 * | 1881 * |
| 1389 *************************************************************************/ | 1882 *************************************************************************/ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1403 * Upon success : uint32_t* size - The object size | 1896 * Upon success : uint32_t* size - The object size |
| 1404 * uint32_t* rp2 - Still unknown return parameter | 1897 * uint32_t* rp2 - Still unknown return parameter |
| 1405 * (perhaps upper 32bit of size) | 1898 * (perhaps upper 32bit of size) |
| 1406 * | 1899 * |
| 1407 * | 1900 * |
| 1408 **/ | 1901 **/ |
| 1409 uint16_t | 1902 uint16_t |
| 1410 ptp_canon_getpartialobjectinfo (PTPParams* params, uint32_t handle, uint32_t p2,
| 1903 ptp_canon_getpartialobjectinfo (PTPParams* params, uint32_t handle, uint32_t p2,
|
| 1411 uint32_t* size, uint32_t* rp2) | 1904 uint32_t* size, uint32_t* rp2) |
| 1412 { | 1905 { |
| 1413 » uint16_t ret; | 1906 » PTPContainer» ptp; |
| 1414 » PTPContainer ptp; | |
| 1415 | 1907 |
| 1416 » PTP_CNT_INIT(ptp); | 1908 » PTP_CNT_INIT(ptp, PTP_OC_CANON_GetPartialObjectInfo, handle, p2); |
| 1417 » ptp.Code=PTP_OC_CANON_GetPartialObjectInfo; | 1909 » *size = *rp2 = 0; |
| 1418 » ptp.Param1=handle; | 1910 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL)
); |
| 1419 » ptp.Param2=p2; | |
| 1420 » ptp.Nparam=2; | |
| 1421 » ret=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL); | |
| 1422 *size=ptp.Param1; | 1911 *size=ptp.Param1; |
| 1423 *rp2=ptp.Param2; | 1912 *rp2=ptp.Param2; |
| 1424 » return ret; | 1913 » return PTP_RC_OK; |
| 1425 } | 1914 } |
| 1426 | 1915 |
| 1427 /** | 1916 /** |
| 1428 * ptp_canon_get_mac_address: | 1917 * ptp_canon_get_mac_address: |
| 1429 * params: PTPParams* | 1918 * params: PTPParams* |
| 1430 * value 0 works. | 1919 * value 0 works. |
| 1431 * Gets the MAC address of the wireless transmitter. | 1920 * Gets the MAC address of the wireless transmitter. |
| 1432 * | 1921 * |
| 1433 * Return values: Some PTP_RC_* code. | 1922 * Return values: Some PTP_RC_* code. |
| 1434 * Upon success : unsigned char* mac - The MAC address | 1923 * Upon success : unsigned char* mac - The MAC address |
| 1435 * | 1924 * |
| 1436 **/ | 1925 **/ |
| 1437 uint16_t | 1926 uint16_t |
| 1438 ptp_canon_get_mac_address (PTPParams* params, unsigned char **mac) | 1927 ptp_canon_get_mac_address (PTPParams* params, unsigned char **mac) |
| 1439 { | 1928 { |
| 1440 PTPContainer ptp; | 1929 PTPContainer ptp; |
| 1441 unsigned int size = 0; | |
| 1442 | 1930 |
| 1443 » PTP_CNT_INIT(ptp); | 1931 PTP_CNT_INIT(ptp, PTP_OC_CANON_GetMACAddress); |
| 1444 » ptp.Code=PTP_OC_CANON_GetMACAddress; | 1932 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, mac, NULL); |
| 1445 » ptp.Nparam=0; | |
| 1446 » *mac = NULL; | |
| 1447 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, mac, &size); | |
| 1448 } | 1933 } |
| 1449 | 1934 |
| 1450 /** | 1935 /** |
| 1451 * ptp_canon_get_directory: | 1936 * ptp_canon_get_directory: |
| 1452 * params: PTPParams* | 1937 * params: PTPParams* |
| 1453 | 1938 |
| 1454 * Gets the full directory of the camera. | 1939 * Gets the full directory of the camera. |
| 1455 * | 1940 * |
| 1456 * Return values: Some PTP_RC_* code. | 1941 * Return values: Some PTP_RC_* code. |
| 1457 * Upon success : PTPObjectHandles *handles - filled out with handle
s | 1942 * Upon success : PTPObjectHandles *handles - filled out with handle
s |
| 1458 * PTPObjectInfo **oinfos - allocated array of PTP
Object Infos | 1943 * PTPObjectInfo **oinfos - allocated array of PTP
Object Infos |
| 1459 * uint32_t **flags - allocated array of CAN
ON Flags | 1944 * uint32_t **flags - allocated array of CAN
ON Flags |
| 1460 * | 1945 * |
| 1461 **/ | 1946 **/ |
| 1462 uint16_t | 1947 uint16_t |
| 1463 ptp_canon_get_directory (PTPParams* params, | 1948 ptp_canon_get_directory (PTPParams* params, |
| 1464 PTPObjectHandles *handles, | 1949 PTPObjectHandles *handles, |
| 1465 PTPObjectInfo **oinfos, /* size(handles->n) */ | 1950 PTPObjectInfo **oinfos, /* size(handles->n) */ |
| 1466 uint32_t **flags /* size(handles->n) */ | 1951 uint32_t **flags /* size(handles->n) */ |
| 1467 ) { | 1952 ) { |
| 1468 PTPContainer ptp; | 1953 PTPContainer ptp; |
| 1469 » unsigned char» *dir = NULL; | 1954 » unsigned char» *data; |
| 1470 » unsigned int» size = 0; | |
| 1471 uint16_t ret; | 1955 uint16_t ret; |
| 1472 | 1956 |
| 1473 » PTP_CNT_INIT(ptp); | 1957 » PTP_CNT_INIT(ptp, PTP_OC_CANON_GetDirectory); |
| 1474 » ptp.Code=PTP_OC_CANON_GetDirectory; | 1958 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, NUL
L)); |
| 1475 » ptp.Nparam=0; | 1959 » ret = ptp_unpack_canon_directory(params, data, ptp.Param1, handles, oinf
os, flags); |
| 1476 » ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dir, &size); | 1960 » free (data); |
| 1477 » if (ret != PTP_RC_OK) | |
| 1478 » » return ret; | |
| 1479 » ret = ptp_unpack_canon_directory(params, dir, ptp.Param1, handles, oinfo
s, flags); | |
| 1480 » free (dir); | |
| 1481 return ret; | 1961 return ret; |
| 1482 } | 1962 } |
| 1483 | 1963 |
| 1484 /** | 1964 /** |
| 1485 * ptp_canon_gettreeinfo: | 1965 * ptp_canon_gettreeinfo: |
| 1486 * params: PTPParams* | 1966 * params: PTPParams* |
| 1487 * uint32_t *out | 1967 * uint32_t *out |
| 1488 * | 1968 * |
| 1489 * Switches the camera display to on and lets the user | 1969 * Switches the camera display to on and lets the user |
| 1490 * select what to transfer. Sends a 0xc011 event when started | 1970 * select what to transfer. Sends a 0xc011 event when started |
| 1491 * and 0xc013 if direct transfer aborted. | 1971 * and 0xc013 if direct transfer aborted. |
| 1492 * | 1972 * |
| 1493 * Return values: Some PTP_RC_* code. | 1973 * Return values: Some PTP_RC_* code. |
| 1494 * | 1974 * |
| 1495 **/ | 1975 **/ |
| 1496 uint16_t | 1976 uint16_t |
| 1497 ptp_canon_gettreeinfo (PTPParams* params, uint32_t *out) | 1977 ptp_canon_gettreeinfo (PTPParams* params, uint32_t *out) |
| 1498 { | 1978 { |
| 1499 » PTPContainer ptp; | 1979 » PTPContainer» ptp; |
| 1500 » uint16_t ret; | |
| 1501 | 1980 |
| 1502 » PTP_CNT_INIT(ptp); | 1981 » PTP_CNT_INIT(ptp, PTP_OC_CANON_GetTreeInfo, 0xf); |
| 1503 » ptp.Code = PTP_OC_CANON_GetTreeInfo; | 1982 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL)
); |
| 1504 » ptp.Nparam = 1; | 1983 » if (ptp.Nparam > 0) |
| 1505 » ptp.Param1 = 0xf; | |
| 1506 » ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL); | |
| 1507 » if ((ret == PTP_RC_OK) && (ptp.Nparam>0)) | |
| 1508 *out = ptp.Param1; | 1984 *out = ptp.Param1; |
| 1509 » return ret; | 1985 » return PTP_RC_OK; |
| 1510 } | 1986 } |
| 1511 | 1987 |
| 1512 /** | 1988 /** |
| 1513 * ptp_canon_getpairinginfo: | 1989 * ptp_canon_getpairinginfo: |
| 1514 * params: PTPParams* | 1990 * params: PTPParams* |
| 1515 * int nr | 1991 * int nr |
| 1516 * | 1992 * |
| 1517 * Get the pairing information. | 1993 * Get the pairing information. |
| 1518 * | 1994 * |
| 1519 * Return values: Some PTP_RC_* code. | 1995 * Return values: Some PTP_RC_* code. |
| 1520 * | 1996 * |
| 1521 **/ | 1997 **/ |
| 1522 uint16_t | 1998 uint16_t |
| 1523 ptp_canon_getpairinginfo (PTPParams* params, uint32_t nr, unsigned char **data,
unsigned int *size) | 1999 ptp_canon_getpairinginfo (PTPParams* params, uint32_t nr, unsigned char **data,
unsigned int *size) |
| 1524 { | 2000 { |
| 1525 PTPContainer ptp; | 2001 PTPContainer ptp; |
| 1526 uint16_t ret; | |
| 1527 | 2002 |
| 1528 » PTP_CNT_INIT(ptp); | 2003 » PTP_CNT_INIT(ptp, PTP_OC_CANON_GetPairingInfo, nr); |
| 1529 » ptp.Code = PTP_OC_CANON_GetPairingInfo; | 2004 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); |
| 1530 » ptp.Nparam = 1; | |
| 1531 » ptp.Param1 = nr; | |
| 1532 » *data = NULL; | |
| 1533 » *size = 0; | |
| 1534 » ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); | |
| 1535 » if (ret != PTP_RC_OK) | |
| 1536 » » return ret; | |
| 1537 » return PTP_RC_OK; | |
| 1538 } | 2005 } |
| 1539 | 2006 |
| 1540 /** | 2007 /** |
| 1541 * ptp_canon_get_target_handles: | 2008 * ptp_canon_get_target_handles: |
| 1542 * params: PTPParams* | 2009 * params: PTPParams* |
| 1543 * PTPCanon_directtransfer_entry **out | 2010 * PTPCanon_directtransfer_entry **out |
| 1544 * unsigned int *outsize | 2011 * unsigned int *outsize |
| 1545 * | 2012 * |
| 1546 * Retrieves direct transfer entries specifying the images to transfer | 2013 * Retrieves direct transfer entries specifying the images to transfer |
| 1547 * from the camera (to be retrieved after 0xc011 event). | 2014 * from the camera (to be retrieved after 0xc011 event). |
| 1548 * | 2015 * |
| 1549 * Return values: Some PTP_RC_* code. | 2016 * Return values: Some PTP_RC_* code. |
| 1550 * | 2017 * |
| 1551 **/ | 2018 **/ |
| 1552 uint16_t | 2019 uint16_t |
| 1553 ptp_canon_gettreesize (PTPParams* params, | 2020 ptp_canon_gettreesize (PTPParams* params, |
| 1554 PTPCanon_directtransfer_entry **entries, unsigned int *cnt) | 2021 PTPCanon_directtransfer_entry **entries, unsigned int *cnt) |
| 1555 { | 2022 { |
| 1556 » PTPContainer ptp; | 2023 » PTPContainer» ptp; |
| 1557 » uint16_t ret; | 2024 » uint16_t» ret = PTP_RC_OK; |
| 1558 » unsigned char *out = NULL, *cur; | 2025 » unsigned char» *data, *cur; |
| 1559 » int i; | 2026 » unsigned int» size, i; |
| 1560 » unsigned int size; | 2027 |
| 1561 » | 2028 » PTP_CNT_INIT(ptp, PTP_OC_CANON_GetTreeSize); |
| 1562 » PTP_CNT_INIT(ptp); | 2029 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 1563 » ptp.Code = PTP_OC_CANON_GetTreeSize; | 2030 » *cnt = dtoh32a(data); |
| 1564 » ptp.Nparam = 0; | |
| 1565 » ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &out, &size); | |
| 1566 » if (ret != PTP_RC_OK) | |
| 1567 » » return ret; | |
| 1568 » *cnt = dtoh32a(out); | |
| 1569 *entries = malloc(sizeof(PTPCanon_directtransfer_entry)*(*cnt)); | 2031 *entries = malloc(sizeof(PTPCanon_directtransfer_entry)*(*cnt)); |
| 1570 if (!*entries) { | 2032 if (!*entries) { |
| 1571 » » free (out); | 2033 » » ret = PTP_RC_GeneralError; |
| 1572 » » return PTP_RC_GeneralError; | 2034 » » goto exit; |
| 1573 } | 2035 } |
| 1574 » cur = out+4; | 2036 » cur = data+4; |
| 1575 for (i=0;i<*cnt;i++) { | 2037 for (i=0;i<*cnt;i++) { |
| 1576 unsigned char len; | 2038 unsigned char len; |
| 1577 (*entries)[i].oid = dtoh32a(cur); | 2039 (*entries)[i].oid = dtoh32a(cur); |
| 1578 (*entries)[i].str = ptp_unpack_string(params, cur, 4, &len); | 2040 (*entries)[i].str = ptp_unpack_string(params, cur, 4, &len); |
| 1579 cur += 4+(cur[4]*2+1); | 2041 cur += 4+(cur[4]*2+1); |
| 1580 } | 2042 } |
| 1581 » free (out); | 2043 exit: |
| 1582 » return PTP_RC_OK; | 2044 » free (data); |
| 2045 » return ret; |
| 1583 } | 2046 } |
| 1584 | 2047 |
| 1585 /** | 2048 /** |
| 1586 * ptp_canon_checkevent: | 2049 * ptp_canon_checkevent: |
| 1587 * params: PTPParams* | 2050 * params: PTPParams* |
| 1588 * | 2051 * |
| 1589 * The camera has a FIFO stack, in which it accumulates events. | 2052 * The camera has a FIFO stack, in which it accumulates events. |
| 1590 * Partially these events are communicated also via the USB interrupt pipe | 2053 * Partially these events are communicated also via the USB interrupt pipe |
| 1591 * according to the PTP USB specification, partially not. | 2054 * according to the PTP USB specification, partially not. |
| 1592 * This operation returns from the device a block of data, empty, | 2055 * This operation returns from the device a block of data, empty, |
| 1593 * if the event stack is empty, or filled with an event's data otherwise. | 2056 * if the event stack is empty, or filled with an event's data otherwise. |
| 1594 * The event is removed from the stack in the latter case. | 2057 * The event is removed from the stack in the latter case. |
| 1595 * The Remote Capture app sends this command to the camera all the time | 2058 * The Remote Capture app sends this command to the camera all the time |
| 1596 * of connection, filling with it the gaps between other operations. | 2059 * of connection, filling with it the gaps between other operations. |
| 1597 * | 2060 * |
| 1598 * Return values: Some PTP_RC_* code. | 2061 * Return values: Some PTP_RC_* code. |
| 1599 * Upon success : PTPUSBEventContainer* event - is filled with the event data | 2062 * Upon success : PTPUSBEventContainer* event - is filled with the event data |
| 1600 * if any | 2063 * if any |
| 1601 * int *isevent - returns 1 in case of event | 2064 * int *isevent - returns 1 in case of event |
| 1602 * or 0 otherwise | 2065 * or 0 otherwise |
| 1603 **/ | 2066 **/ |
| 1604 uint16_t | 2067 uint16_t |
| 1605 ptp_canon_checkevent (PTPParams* params, PTPContainer* event, int* isevent) | 2068 ptp_canon_checkevent (PTPParams* params, PTPContainer* event, int* isevent) |
| 1606 { | 2069 { |
| 1607 » uint16_t ret; | 2070 » PTPContainer» ptp; |
| 1608 » PTPContainer ptp; | 2071 » unsigned char» *data; |
| 1609 » unsigned char *evdata = NULL; | 2072 » unsigned int» size; |
| 1610 » unsigned int len; | |
| 1611 | 2073 |
| 2074 PTP_CNT_INIT(ptp, PTP_OC_CANON_CheckEvent); |
| 1612 *isevent=0; | 2075 *isevent=0; |
| 1613 » PTP_CNT_INIT(ptp); | 2076 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 1614 » ptp.Code=PTP_OC_CANON_CheckEvent; | 2077 » if (data && size) { /* check if we had a successfull call with data */ |
| 1615 » ptp.Nparam=0; | 2078 » » ptp_unpack_EC(params, data, event, size); |
| 1616 » len=0; | 2079 » » *isevent=1; |
| 1617 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &evdata, &len); | 2080 » » free(data); |
| 1618 » if (evdata!=NULL) { | |
| 1619 » » if (ret == PTP_RC_OK) { | |
| 1620 » » ptp_unpack_EC(params, evdata, event, len); | |
| 1621 » » » *isevent=1; | |
| 1622 » } | |
| 1623 » » free(evdata); | |
| 1624 } | 2081 } |
| 1625 » return ret; | 2082 » return PTP_RC_OK; |
| 1626 } | 2083 } |
| 1627 | 2084 |
| 1628 uint16_t | 2085 uint16_t |
| 1629 ptp_check_event (PTPParams *params) { | 2086 ptp_add_event (PTPParams *params, PTPContainer *evt) |
| 1630 » PTPContainer» » event; | 2087 { |
| 1631 » uint16_t» » ret; | 2088 » params->events = realloc(params->events, sizeof(PTPContainer)*(params->n
rofevents+1)); |
| 2089 » memcpy (¶ms->events[params->nrofevents],evt,1*sizeof(PTPContainer)); |
| 2090 » params->nrofevents += 1; |
| 2091 » return PTP_RC_OK; |
| 2092 } |
| 1632 | 2093 |
| 2094 uint16_t |
| 2095 ptp_check_event (PTPParams *params) |
| 2096 { |
| 2097 PTPContainer event; |
| 2098 uint16_t ret; |
| 2099 |
| 2100 /* Method offered by Nikon DSLR, Nikon 1, and some older Nikon Coolpix P
* |
| 2101 * The Nikon Coolpix P2 however does not return anything. So if we never
get |
| 2102 * events from here, use the ptp "interrupt" method */ |
| 1633 if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_NIKON) && | 2103 if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_NIKON) && |
| 1634 ptp_operation_issupported(params, PTP_OC_NIKON_CheckEvent) | 2104 ptp_operation_issupported(params, PTP_OC_NIKON_CheckEvent) |
| 1635 ) { | 2105 ) { |
| 1636 » » int evtcnt; | 2106 » » unsigned int evtcnt = 0; |
| 1637 » » PTPContainer» *xevent = NULL; | 2107 » » PTPContainer *xevent = NULL; |
| 1638 | 2108 |
| 1639 ret = ptp_nikon_check_event(params, &xevent, &evtcnt); | 2109 ret = ptp_nikon_check_event(params, &xevent, &evtcnt); |
| 1640 » » if (ret != PTP_RC_OK) | 2110 » » if (ret != PTP_RC_OperationNotSupported) |
| 1641 » » » return ret; | 2111 » » » CHECK_PTP_RC(ret); |
| 1642 | 2112 |
| 1643 if (evtcnt) { | 2113 if (evtcnt) { |
| 1644 » » » if (params->nrofevents) | 2114 » » » params->events = realloc(params->events, sizeof(PTPConta
iner)*(evtcnt+params->nrofevents)); |
| 1645 » » » » params->events = realloc(params->events, sizeof(
PTPContainer)*(evtcnt+params->nrofevents)); | |
| 1646 » » » else | |
| 1647 » » » » params->events = malloc(sizeof(PTPContainer)*evt
cnt); | |
| 1648 memcpy (¶ms->events[params->nrofevents],xevent,evtcn
t*sizeof(PTPContainer)); | 2115 memcpy (¶ms->events[params->nrofevents],xevent,evtcn
t*sizeof(PTPContainer)); |
| 1649 params->nrofevents += evtcnt; | 2116 params->nrofevents += evtcnt; |
| 1650 free (xevent); | 2117 free (xevent); |
| 2118 params->event90c7works = 1; |
| 1651 } | 2119 } |
| 1652 » » return PTP_RC_OK; | 2120 » » if (params->event90c7works) |
| 2121 » » » return PTP_RC_OK; |
| 2122 » » /* fall through to generic event handling */ |
| 1653 } | 2123 } |
| 1654 /* should not get here ... EOS has no normal PTP events and another queu
e handling. */ | 2124 /* should not get here ... EOS has no normal PTP events and another queu
e handling. */ |
| 1655 if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) && | 2125 if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) && |
| 1656 ptp_operation_issupported(params, PTP_OC_CANON_EOS_GetEvent) | 2126 ptp_operation_issupported(params, PTP_OC_CANON_EOS_GetEvent) |
| 1657 ) { | 2127 ) { |
| 1658 return PTP_RC_OK; | 2128 return PTP_RC_OK; |
| 1659 } | 2129 } |
| 1660 | 2130 |
| 1661 if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) && | 2131 if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) && |
| 1662 ptp_operation_issupported(params, PTP_OC_CANON_CheckEvent) | 2132 ptp_operation_issupported(params, PTP_OC_CANON_CheckEvent) |
| 1663 ) { | 2133 ) { |
| 1664 int isevent; | 2134 int isevent; |
| 1665 | 2135 |
| 1666 » » ret = ptp_canon_checkevent (params,&event,&isevent); | 2136 » » CHECK_PTP_RC(ptp_canon_checkevent (params,&event,&isevent)); |
| 1667 » » if (ret!=PTP_RC_OK) | 2137 |
| 1668 » » » return ret; | 2138 » » if (isevent) { |
| 1669 » » if (isevent) | 2139 » » » ret = PTP_RC_OK; |
| 1670 goto store_event; | 2140 goto store_event; |
| 2141 } |
| 1671 /* Event Emulate Mode 0 (unset) and 1-5 get interrupt events. 6-
7 does not. */ | 2142 /* Event Emulate Mode 0 (unset) and 1-5 get interrupt events. 6-
7 does not. */ |
| 1672 if (params->canon_event_mode > 5) | 2143 if (params->canon_event_mode > 5) |
| 1673 » » » return ret; | 2144 » » » return PTP_RC_OK; |
| 1674 | 2145 |
| 1675 /* FIXME: fallthrough or return? */ | 2146 /* FIXME: fallthrough or return? */ |
| 1676 #ifdef __APPLE__ | 2147 #ifdef __APPLE__ |
| 1677 /* the libusb 1 on darwin currently does not like polling | 2148 /* the libusb 1 on darwin currently does not like polling |
| 1678 * for interrupts, they have no timeout for it. 2010/08/23 | 2149 * for interrupts, they have no timeout for it. 2010/08/23 |
| 1679 * Check back in 2011 or so. -Marcus | 2150 * Check back in 2011 or so. -Marcus |
| 1680 */ | 2151 */ |
| 1681 » » return ret; | 2152 » » return PTP_RC_OK; |
| 1682 #endif | 2153 #endif |
| 1683 } | 2154 } |
| 1684 ret = params->event_check(params,&event); | 2155 ret = params->event_check(params,&event); |
| 1685 | 2156 |
| 1686 store_event: | 2157 store_event: |
| 1687 if (ret == PTP_RC_OK) { | 2158 if (ret == PTP_RC_OK) { |
| 1688 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, eve
nt.Param1, event.Param2, event.Param3); | 2159 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, eve
nt.Param1, event.Param2, event.Param3); |
| 1689 » » if (params->nrofevents) | 2160 » » ptp_add_event (params, &event); |
| 1690 » » » params->events = realloc(params->events, sizeof(PTPConta
iner)*(params->nrofevents+1)); | 2161 |
| 1691 » » else | 2162 » » /* handle some PTP stack internal events */ |
| 1692 » » » params->events = malloc(sizeof(PTPContainer)*1); | 2163 » » switch (event.Code) { |
| 1693 » » memcpy (¶ms->events[params->nrofevents],&event,1*sizeof(PTPC
ontainer)); | 2164 » » case PTP_EC_DevicePropChanged: { |
| 1694 » » params->nrofevents += 1; | 2165 » » » unsigned int i; |
| 2166 |
| 2167 » » » /* mark the property for a forced refresh on the next qu
ery */ |
| 2168 » » » for (i=0;i<params->nrofdeviceproperties;i++) |
| 2169 » » » » if (params->deviceproperties[i].desc.DevicePrope
rtyCode == event.Param1) { |
| 2170 » » » » » params->deviceproperties[i].timestamp =
0; |
| 2171 » » » » » break; |
| 2172 » » » » } |
| 2173 » » » break; |
| 2174 » » } |
| 2175 » » default: /* check if we should handle it internally too */ |
| 2176 » » » break; |
| 2177 » » } |
| 2178 » |
| 1695 } | 2179 } |
| 1696 if (ret == PTP_ERROR_TIMEOUT) /* ok, just new events */ | 2180 if (ret == PTP_ERROR_TIMEOUT) /* ok, just new events */ |
| 1697 ret = PTP_RC_OK; | 2181 ret = PTP_RC_OK; |
| 1698 return ret; | 2182 return ret; |
| 1699 } | 2183 } |
| 1700 | 2184 |
| 2185 uint16_t |
| 2186 ptp_wait_event (PTPParams *params) |
| 2187 { |
| 2188 PTPContainer event; |
| 2189 uint16_t ret; |
| 2190 |
| 2191 ret = params->event_wait(params,&event); |
| 2192 if (ret == PTP_RC_OK) { |
| 2193 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, eve
nt.Param1, event.Param2, event.Param3); |
| 2194 ptp_add_event (params, &event); |
| 2195 |
| 2196 /* handle some PTP stack internal events */ |
| 2197 switch (event.Code) { |
| 2198 case PTP_EC_DevicePropChanged: { |
| 2199 unsigned int i; |
| 2200 |
| 2201 /* mark the property for a forced refresh on the next qu
ery */ |
| 2202 for (i=0;i<params->nrofdeviceproperties;i++) |
| 2203 if (params->deviceproperties[i].desc.DevicePrope
rtyCode == event.Param1) { |
| 2204 params->deviceproperties[i].timestamp =
0; |
| 2205 break; |
| 2206 } |
| 2207 break; |
| 2208 } |
| 2209 default: /* check if we should handle it internally too */ |
| 2210 break; |
| 2211 } |
| 2212 } |
| 2213 if (ret == PTP_ERROR_TIMEOUT) /* ok, just new events */ |
| 2214 ret = PTP_RC_OK; |
| 2215 return ret; |
| 2216 } |
| 2217 |
| 2218 |
| 1701 int | 2219 int |
| 1702 ptp_get_one_event(PTPParams *params, PTPContainer *event) { | 2220 ptp_get_one_event(PTPParams *params, PTPContainer *event) |
| 2221 { |
| 1703 if (!params->nrofevents) | 2222 if (!params->nrofevents) |
| 1704 return 0; | 2223 return 0; |
| 1705 memcpy (event, params->events, sizeof(PTPContainer)); | 2224 memcpy (event, params->events, sizeof(PTPContainer)); |
| 1706 memmove (params->events, params->events+1, sizeof(PTPContainer)*(params-
>nrofevents-1)); | 2225 memmove (params->events, params->events+1, sizeof(PTPContainer)*(params-
>nrofevents-1)); |
| 1707 /* do not realloc on shrink. */ | 2226 /* do not realloc on shrink. */ |
| 1708 params->nrofevents--; | 2227 params->nrofevents--; |
| 1709 if (!params->nrofevents) { | 2228 if (!params->nrofevents) { |
| 1710 free (params->events); | 2229 free (params->events); |
| 1711 params->events = NULL; | 2230 params->events = NULL; |
| 1712 } | 2231 } |
| 1713 return 1; | 2232 return 1; |
| 1714 } | 2233 } |
| 1715 | 2234 |
| 1716 /** | 2235 /** |
| 1717 * ptp_canon_eos_getevent: | 2236 * ptp_canon_eos_getevent: |
| 1718 * | 2237 * |
| 1719 * This retrieves configuration status/updates/changes | 2238 * This retrieves configuration status/updates/changes |
| 1720 * on EOS cameras. It reads a datablock which has a list of variable | 2239 * on EOS cameras. It reads a datablock which has a list of variable |
| 1721 * sized structures. | 2240 * sized structures. |
| 1722 * | 2241 * |
| 1723 * params: PTPParams* | 2242 * params: PTPParams* |
| 1724 * | 2243 * |
| 1725 * Return values: Some PTP_RC_* code. | 2244 * Return values: Some PTP_RC_* code. |
| 1726 * | 2245 * |
| 1727 **/ | 2246 **/ |
| 1728 uint16_t | 2247 uint16_t |
| 1729 ptp_canon_eos_getevent (PTPParams* params, PTPCanon_changes_entry **entries, int
*nrofentries) | 2248 ptp_canon_eos_getevent (PTPParams* params, PTPCanon_changes_entry **entries, int
*nrofentries) |
| 1730 { | 2249 { |
| 1731 » PTPContainer ptp; | 2250 » PTPContainer» ptp; |
| 1732 » uint16_t» ret; | 2251 » unsigned char» *data; |
| 1733 » unsigned int » size = 0; | 2252 » unsigned int » size; |
| 1734 » unsigned char» *data = NULL; | |
| 1735 | 2253 |
| 2254 PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetEvent); |
| 1736 *nrofentries = 0; | 2255 *nrofentries = 0; |
| 1737 *entries = NULL; | 2256 *entries = NULL; |
| 1738 » PTP_CNT_INIT(ptp); | 2257 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 1739 » ptp.Code = PTP_OC_CANON_EOS_GetEvent; | 2258 » *nrofentries = ptp_unpack_CANON_changes(params,data,size,entries); |
| 1740 » ptp.Nparam = 0; | |
| 1741 » ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size); | |
| 1742 » if (ret != PTP_RC_OK) return ret; | |
| 1743 *nrofentries = ptp_unpack_CANON_changes(params,data,size,entries); | |
| 1744 free (data); | 2259 free (data); |
| 1745 return PTP_RC_OK; | 2260 return PTP_RC_OK; |
| 1746 } | 2261 } |
| 1747 | 2262 |
| 1748 uint16_t | 2263 uint16_t |
| 1749 ptp_check_eos_events (PTPParams *params) { | 2264 ptp_check_eos_events (PTPParams *params) |
| 1750 » uint16_t» » ret; | 2265 { |
| 1751 PTPCanon_changes_entry *entries = NULL, *nentries; | 2266 PTPCanon_changes_entry *entries = NULL, *nentries; |
| 1752 int nrofentries = 0; | 2267 int nrofentries = 0; |
| 1753 | 2268 |
| 1754 while (1) { /* call it repeatedly until the camera does not report any *
/ | 2269 while (1) { /* call it repeatedly until the camera does not report any *
/ |
| 1755 » » ret = ptp_canon_eos_getevent (params, &entries, &nrofentries); | 2270 » » CHECK_PTP_RC(ptp_canon_eos_getevent (params, &entries, &nrofentr
ies)); |
| 1756 » » if (ret != PTP_RC_OK) | |
| 1757 » » » return ret; | |
| 1758 if (!nrofentries) | 2271 if (!nrofentries) |
| 1759 return PTP_RC_OK; | 2272 return PTP_RC_OK; |
| 1760 | 2273 |
| 1761 if (params->nrofbacklogentries) { | 2274 if (params->nrofbacklogentries) { |
| 1762 nentries = realloc(params->backlogentries,sizeof(entries
[0])*(params->nrofbacklogentries+nrofentries)); | 2275 nentries = realloc(params->backlogentries,sizeof(entries
[0])*(params->nrofbacklogentries+nrofentries)); |
| 1763 if (!nentries) | 2276 if (!nentries) |
| 1764 return PTP_RC_GeneralError; | 2277 return PTP_RC_GeneralError; |
| 1765 params->backlogentries = nentries; | 2278 params->backlogentries = nentries; |
| 1766 memcpy (nentries+params->nrofbacklogentries, entries, nr
ofentries*sizeof(entries[0])); | 2279 memcpy (nentries+params->nrofbacklogentries, entries, nr
ofentries*sizeof(entries[0])); |
| 1767 params->nrofbacklogentries += nrofentries; | 2280 params->nrofbacklogentries += nrofentries; |
| 1768 free (entries); | 2281 free (entries); |
| 1769 } else { | 2282 } else { |
| 1770 params->backlogentries = entries; | 2283 params->backlogentries = entries; |
| 1771 params->nrofbacklogentries = nrofentries; | 2284 params->nrofbacklogentries = nrofentries; |
| 1772 } | 2285 } |
| 1773 } | 2286 } |
| 1774 return PTP_RC_OK; | 2287 return PTP_RC_OK; |
| 1775 } | 2288 } |
| 1776 | 2289 |
| 1777 int | 2290 int |
| 1778 ptp_get_one_eos_event (PTPParams *params, PTPCanon_changes_entry *entry) { | 2291 ptp_get_one_eos_event (PTPParams *params, PTPCanon_changes_entry *entry) |
| 2292 { |
| 1779 if (!params->nrofbacklogentries) | 2293 if (!params->nrofbacklogentries) |
| 1780 return 0; | 2294 return 0; |
| 1781 memcpy (entry, params->backlogentries, sizeof(*entry)); | 2295 memcpy (entry, params->backlogentries, sizeof(*entry)); |
| 1782 if (params->nrofbacklogentries > 1) { | 2296 if (params->nrofbacklogentries > 1) { |
| 1783 memmove (params->backlogentries,params->backlogentries+1,sizeof(
*entry)*(params->nrofbacklogentries-1)); | 2297 memmove (params->backlogentries,params->backlogentries+1,sizeof(
*entry)*(params->nrofbacklogentries-1)); |
| 1784 params->nrofbacklogentries--; | 2298 params->nrofbacklogentries--; |
| 1785 } else { | 2299 } else { |
| 1786 free (params->backlogentries); | 2300 free (params->backlogentries); |
| 1787 params->backlogentries = NULL; | 2301 params->backlogentries = NULL; |
| 1788 params->nrofbacklogentries = 0; | 2302 params->nrofbacklogentries = 0; |
| 1789 } | 2303 } |
| 1790 return 1; | 2304 return 1; |
| 1791 } | 2305 } |
| 1792 | 2306 |
| 1793 | 2307 |
| 1794 uint16_t | 2308 uint16_t |
| 1795 ptp_canon_eos_getdevicepropdesc (PTPParams* params, uint16_t propcode, | 2309 ptp_canon_eos_getdevicepropdesc (PTPParams* params, uint16_t propcode, |
| 1796 PTPDevicePropDesc *dpd) | 2310 PTPDevicePropDesc *dpd) |
| 1797 { | 2311 { |
| 1798 » int i; | 2312 » unsigned int i; |
| 1799 | 2313 |
| 1800 for (i=0;i<params->nrofcanon_props;i++) | 2314 for (i=0;i<params->nrofcanon_props;i++) |
| 1801 if (params->canon_props[i].proptype == propcode) | 2315 if (params->canon_props[i].proptype == propcode) |
| 1802 break; | 2316 break; |
| 1803 if (params->nrofcanon_props == i) | 2317 if (params->nrofcanon_props == i) |
| 1804 return PTP_RC_Undefined; | 2318 return PTP_RC_Undefined; |
| 1805 memcpy (dpd, ¶ms->canon_props[i].dpd, sizeof (*dpd)); | 2319 memcpy (dpd, ¶ms->canon_props[i].dpd, sizeof (*dpd)); |
| 1806 if (dpd->FormFlag == PTP_DPFF_Enumeration) { | 2320 if (dpd->FormFlag == PTP_DPFF_Enumeration) { |
| 1807 /* need to duplicate the Enumeration alloc */ | 2321 /* need to duplicate the Enumeration alloc */ |
| 1808 dpd->FORM.Enum.SupportedValue = malloc (sizeof (PTPPropertyValue
)*dpd->FORM.Enum.NumberOfValues); | 2322 dpd->FORM.Enum.SupportedValue = malloc (sizeof (PTPPropertyValue
)*dpd->FORM.Enum.NumberOfValues); |
| 1809 memcpy (dpd->FORM.Enum.SupportedValue, | 2323 memcpy (dpd->FORM.Enum.SupportedValue, |
| 1810 params->canon_props[i].dpd.FORM.Enum.SupportedValue, | 2324 params->canon_props[i].dpd.FORM.Enum.SupportedValue, |
| 1811 sizeof (PTPPropertyValue)*dpd->FORM.Enum.NumberOfValues | 2325 sizeof (PTPPropertyValue)*dpd->FORM.Enum.NumberOfValues |
| 1812 ); | 2326 ); |
| 1813 } | 2327 } |
| 1814 if (dpd->DataType == PTP_DTC_STR) { | 2328 if (dpd->DataType == PTP_DTC_STR) { |
| 1815 dpd->FactoryDefaultValue.str = strdup( params->canon_props[i].dp
d.FactoryDefaultValue.str ); | 2329 dpd->FactoryDefaultValue.str = strdup( params->canon_props[i].dp
d.FactoryDefaultValue.str ); |
| 1816 dpd->CurrentValue.str = strdup( params->canon_props[i].dpd.Curre
ntValue.str ); | 2330 dpd->CurrentValue.str = strdup( params->canon_props[i].dpd.Curre
ntValue.str ); |
| 1817 } | 2331 } |
| 1818 | 2332 |
| 1819 return PTP_RC_OK; | 2333 return PTP_RC_OK; |
| 1820 } | 2334 } |
| 1821 | 2335 |
| 1822 | 2336 |
| 1823 uint16_t | 2337 uint16_t |
| 1824 ptp_canon_eos_getstorageids (PTPParams* params, PTPStorageIDs* storageids) | 2338 ptp_canon_eos_getstorageids (PTPParams* params, PTPStorageIDs* storageids) |
| 1825 { | 2339 { |
| 1826 PTPContainer ptp; | 2340 PTPContainer ptp; |
| 1827 » unsigned int» len = 0; | 2341 » unsigned char» *data; |
| 1828 » uint16_t» ret; | 2342 » unsigned int» size; |
| 1829 » unsigned char*» sids=NULL; | 2343 |
| 1830 » | 2344 » PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetStorageIDs); |
| 1831 » PTP_CNT_INIT(ptp); | 2345 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 1832 » ptp.Code » = PTP_OC_CANON_EOS_GetStorageIDs; | 2346 » ptp_unpack_SIDs(params, data, storageids, size); |
| 1833 » ptp.Nparam» = 0; | 2347 » free(data); |
| 1834 » ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &sids, &len); | 2348 » return PTP_RC_OK; |
| 1835 » if (ret == PTP_RC_OK) ptp_unpack_SIDs(params, sids, storageids, len); | |
| 1836 » free(sids); | |
| 1837 » return ret; | |
| 1838 } | 2349 } |
| 1839 | 2350 |
| 1840 uint16_t | 2351 uint16_t |
| 1841 ptp_canon_eos_getstorageinfo (PTPParams* params, uint32_t p1, unsigned char **da
ta, unsigned int *size) | 2352 ptp_canon_eos_getstorageinfo (PTPParams* params, uint32_t p1, unsigned char **da
ta, unsigned int *size) |
| 1842 { | 2353 { |
| 1843 » PTPContainer ptp; | 2354 » PTPContainer» ptp; |
| 1844 » uint16_t» ret; | |
| 1845 | 2355 |
| 1846 » *size = 0; | 2356 » PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetStorageInfo, p1); |
| 1847 » *data = NULL; | 2357 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); |
| 1848 » PTP_CNT_INIT(ptp); | |
| 1849 » ptp.Code » = PTP_OC_CANON_EOS_GetStorageInfo; | |
| 1850 » ptp.Nparam» = 1; | |
| 1851 » ptp.Param1» = p1; | |
| 1852 » ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); | |
| 1853 /* FIXME: do stuff with data */ | 2358 /* FIXME: do stuff with data */ |
| 1854 return ret; | |
| 1855 } | 2359 } |
| 1856 | 2360 |
| 1857 uint16_t | 2361 uint16_t |
| 1858 ptp_canon_eos_getobjectinfoex ( | 2362 ptp_canon_eos_getobjectinfoex ( |
| 1859 PTPParams* params, uint32_t storageid, uint32_t oid, uint32_t unk, | 2363 PTPParams* params, uint32_t storageid, uint32_t oid, uint32_t unk, |
| 1860 PTPCANONFolderEntry **entries, unsigned int *nrofentries | 2364 PTPCANONFolderEntry **entries, unsigned int *nrofentries |
| 1861 ) { | 2365 ) { |
| 1862 PTPContainer ptp; | 2366 PTPContainer ptp; |
| 1863 » unsigned int» i, size = 0; | 2367 » uint16_t» ret = PTP_RC_OK; |
| 1864 unsigned char *data, *xdata; | 2368 unsigned char *data, *xdata; |
| 1865 » uint16_t» ret; | 2369 » unsigned int» size, i; |
| 1866 | 2370 |
| 1867 » data = NULL; | 2371 » PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetObjectInfoEx, storageid, oid, unk)
; |
| 1868 » PTP_CNT_INIT(ptp); | 2372 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 1869 » ptp.Code » = PTP_OC_CANON_EOS_GetObjectInfoEx; | 2373 » if (!data) { |
| 1870 » ptp.Nparam» = 3; | 2374 » » *nrofentries = 0; |
| 1871 » ptp.Param1» = storageid; | 2375 » » return PTP_RC_OK; |
| 1872 » ptp.Param2» = oid; | 2376 » } |
| 1873 » ptp.Param3» = unk; | |
| 1874 » ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size); | |
| 1875 » if (ret != PTP_RC_OK) | |
| 1876 » » return ret; | |
| 1877 | 2377 |
| 1878 *nrofentries = dtoh32a(data); | 2378 *nrofentries = dtoh32a(data); |
| 1879 *entries = malloc(*nrofentries * sizeof(PTPCANONFolderEntry)); | 2379 *entries = malloc(*nrofentries * sizeof(PTPCANONFolderEntry)); |
| 1880 » if (!*entries) | 2380 » if (!*entries) { |
| 1881 » » return PTP_RC_GeneralError; | 2381 » » ret = PTP_RC_GeneralError; |
| 2382 » » goto exit; |
| 2383 » } |
| 1882 | 2384 |
| 1883 xdata = data+sizeof(uint32_t); | 2385 xdata = data+sizeof(uint32_t); |
| 1884 for (i=0;i<*nrofentries;i++) { | 2386 for (i=0;i<*nrofentries;i++) { |
| 1885 ptp_unpack_Canon_EOS_FE (params, &xdata[4], &((*entries)[i])); | 2387 ptp_unpack_Canon_EOS_FE (params, &xdata[4], &((*entries)[i])); |
| 1886 xdata += dtoh32a(xdata); | 2388 xdata += dtoh32a(xdata); |
| 1887 } | 2389 } |
| 1888 » return PTP_RC_OK; | 2390 exit: |
| 2391 » free (data); |
| 2392 » return ret; |
| 1889 } | 2393 } |
| 1890 | 2394 |
| 1891 /** | 2395 /** |
| 1892 * ptp_canon_eos_getpartialobject: | 2396 * ptp_canon_eos_getpartialobject: |
| 1893 * | 2397 * |
| 1894 * This retrieves a part of an PTP object which you specify as object id. | 2398 * This retrieves a part of an PTP object which you specify as object id. |
| 1895 * The id originates from 0x9116 call. | 2399 * The id originates from 0x9116 call. |
| 1896 * After finishing it, we seem to need to call ptp_canon_eos_enddirecttransfer. | 2400 * After finishing it, we seem to need to call ptp_canon_eos_enddirecttransfer. |
| 1897 * | 2401 * |
| 1898 * params: PTPParams* | 2402 * params: PTPParams* |
| 1899 * oid Object ID | 2403 * oid Object ID |
| 1900 * offset The offset where to start the data transfer | 2404 * offset The offset where to start the data transfer |
| 1901 * xsize Size in bytes of the transfer to do | 2405 * xsize Size in bytes of the transfer to do |
| 1902 * data Pointer that receives the malloc()ed memory of t
he transfer. | 2406 * data Pointer that receives the malloc()ed memory of t
he transfer. |
| 1903 * | 2407 * |
| 1904 * Return values: Some PTP_RC_* code. | 2408 * Return values: Some PTP_RC_* code. |
| 1905 * | 2409 * |
| 1906 */ | 2410 */ |
| 1907 uint16_t | 2411 uint16_t |
| 1908 ptp_canon_eos_getpartialobject (PTPParams* params, uint32_t oid, uint32_t offset
, uint32_t xsize, unsigned char**data) | 2412 ptp_canon_eos_getpartialobject (PTPParams* params, uint32_t oid, uint32_t offset
, uint32_t xsize, unsigned char**data) |
| 1909 { | 2413 { |
| 1910 PTPContainer ptp; | 2414 PTPContainer ptp; |
| 1911 unsigned int size = 0; | |
| 1912 | 2415 |
| 1913 » *data = NULL; | 2416 » PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetPartialObject, oid, offset, xsize)
; |
| 1914 » PTP_CNT_INIT(ptp); | 2417 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, NULL); |
| 1915 » ptp.Code » = PTP_OC_CANON_EOS_GetPartialObject; | |
| 1916 » ptp.Nparam» = 3; | |
| 1917 » ptp.Param1» = oid; | |
| 1918 » ptp.Param2» = offset; | |
| 1919 » ptp.Param3» = xsize; | |
| 1920 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, &size); | |
| 1921 } | 2418 } |
| 1922 | 2419 |
| 1923 uint16_t | 2420 uint16_t |
| 1924 ptp_canon_eos_setdevicepropvalueex (PTPParams* params, unsigned char* data, unsi
gned int size) | 2421 ptp_canon_eos_setdevicepropvalueex (PTPParams* params, unsigned char* data, unsi
gned int size) |
| 1925 { | 2422 { |
| 1926 PTPContainer ptp; | 2423 PTPContainer ptp; |
| 1927 | 2424 |
| 1928 » PTP_CNT_INIT(ptp); | 2425 » PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_SetDevicePropValueEx); |
| 1929 » ptp.Code » = PTP_OC_CANON_EOS_SetDevicePropValueEx; | |
| 1930 » ptp.Nparam» = 0; | |
| 1931 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL)
; | 2426 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL)
; |
| 1932 } | 2427 } |
| 1933 | 2428 |
| 1934 #if 0 | 2429 #if 0 |
| 1935 uint16_t | 2430 uint16_t |
| 1936 ptp_canon_eos_setdevicepropvalue (PTPParams* params, | 2431 ptp_canon_eos_setdevicepropvalue (PTPParams* params, |
| 1937 uint16_t propcode, PTPPropertyValue *value, uint16_t datatype | 2432 uint16_t propcode, PTPPropertyValue *value, uint16_t datatype |
| 1938 ) { | 2433 ) { |
| 1939 PTPContainer ptp; | 2434 PTPContainer ptp; |
| 1940 uint16_t ret; | 2435 uint16_t ret; |
| 1941 » int » » i; | 2436 » unsigned char» *data = NULL; |
| 1942 » unsigned char» *data; | 2437 » unsigned int» i, size; |
| 1943 » unsigned int» size; | |
| 1944 | 2438 |
| 1945 » PTP_CNT_INIT(ptp); | 2439 » PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_SetDevicePropValueEx); |
| 1946 » ptp.Code » = PTP_OC_CANON_EOS_SetDevicePropValueEx; | 2440 |
| 1947 » ptp.Nparam» = 0; | |
| 1948 for (i=0;i<params->nrofcanon_props;i++) | 2441 for (i=0;i<params->nrofcanon_props;i++) |
| 1949 if (params->canon_props[i].proptype == propcode) | 2442 if (params->canon_props[i].proptype == propcode) |
| 1950 break; | 2443 break; |
| 1951 if (params->nrofcanon_props == i) | 2444 if (params->nrofcanon_props == i) |
| 1952 return PTP_RC_Undefined; | 2445 return PTP_RC_Undefined; |
| 1953 | 2446 |
| 1954 switch (propcode) { | 2447 switch (propcode) { |
| 1955 case PTP_DPC_CANON_EOS_ImageFormat: | 2448 case PTP_DPC_CANON_EOS_ImageFormat: |
| 1956 case PTP_DPC_CANON_EOS_ImageFormatCF: | 2449 case PTP_DPC_CANON_EOS_ImageFormatCF: |
| 1957 case PTP_DPC_CANON_EOS_ImageFormatSD: | 2450 case PTP_DPC_CANON_EOS_ImageFormatSD: |
| 1958 case PTP_DPC_CANON_EOS_ImageFormatExtHD: | 2451 case PTP_DPC_CANON_EOS_ImageFormatExtHD: |
| 1959 /* special handling of ImageFormat properties */ | 2452 /* special handling of ImageFormat properties */ |
| 1960 size = 8 + ptp_pack_EOS_ImageFormat( params, NULL, value->u16 ); | 2453 size = 8 + ptp_pack_EOS_ImageFormat( params, NULL, value->u16 ); |
| 1961 data = malloc( size ); | 2454 data = malloc( size ); |
| 1962 if (!data) return PTP_RC_GeneralError; | 2455 if (!data) return PTP_RC_GeneralError; |
| 1963 params->canon_props[i].dpd.CurrentValue.u16 = value->u16; | 2456 params->canon_props[i].dpd.CurrentValue.u16 = value->u16; |
| 1964 ptp_pack_EOS_ImageFormat( params, data + 8, value->u16 ); | 2457 ptp_pack_EOS_ImageFormat( params, data + 8, value->u16 ); |
| 1965 break; | 2458 break; |
| 1966 case PTP_DPC_CANON_EOS_CustomFuncEx: | 2459 case PTP_DPC_CANON_EOS_CustomFuncEx: |
| 1967 /* special handling of CustomFuncEx properties */ | 2460 /* special handling of CustomFuncEx properties */ |
| 1968 ptp_debug (params, "ptp2/ptp_canon_eos_setdevicepropvalue: setti
ng EOS prop %x to %s",propcode,value->str); | 2461 ptp_debug (params, "ptp2/ptp_canon_eos_setdevicepropvalue: setti
ng EOS prop %x to %s",propcode,value->str); |
| 1969 size = 8 + ptp_pack_EOS_CustomFuncEx( params, NULL, value->str )
; | 2462 size = 8 + ptp_pack_EOS_CustomFuncEx( params, NULL, value->str )
; |
| 1970 data = malloc( size ); | 2463 data = malloc( size ); |
| 1971 if (!data) return PTP_RC_GeneralError; | 2464 if (!data) return PTP_RC_GeneralError; |
| 1972 params->canon_props[i].dpd.CurrentValue.str = strdup( value->str
); | 2465 params->canon_props[i].dpd.CurrentValue.str = strdup( value->str
); |
| 1973 ptp_pack_EOS_CustomFuncEx( params, data + 8, value->str ); | 2466 ptp_pack_EOS_CustomFuncEx( params, data + 8, value->str ); |
| 1974 break; | 2467 break; |
| 1975 default: | 2468 default: |
| 1976 if (datatype != PTP_DTC_STR) { | 2469 if (datatype != PTP_DTC_STR) { |
| 1977 » » » data = calloc(sizeof(uint32_t),3); | 2470 » » » data = calloc(3,sizeof(uint32_t)); |
| 1978 if (!data) return PTP_RC_GeneralError; | 2471 if (!data) return PTP_RC_GeneralError; |
| 1979 size = sizeof(uint32_t)*3; | 2472 size = sizeof(uint32_t)*3; |
| 1980 } else { | 2473 } else { |
| 1981 size = strlen(value->str) + 1 + 8; | 2474 size = strlen(value->str) + 1 + 8; |
| 1982 » » » data = calloc(sizeof(char),size); | 2475 » » » data = calloc(size,sizeof(char)); |
| 1983 if (!data) return PTP_RC_GeneralError; | 2476 if (!data) return PTP_RC_GeneralError; |
| 1984 } | 2477 } |
| 1985 switch (datatype) { | 2478 switch (datatype) { |
| 1986 case PTP_DTC_INT8: | 2479 case PTP_DTC_INT8: |
| 1987 case PTP_DTC_UINT8: | 2480 case PTP_DTC_UINT8: |
| 1988 /*fprintf (stderr, "%x -> %d\n", propcode, value->u8);*/ | 2481 /*fprintf (stderr, "%x -> %d\n", propcode, value->u8);*/ |
| 1989 htod8a(&data[8], value->u8); | 2482 htod8a(&data[8], value->u8); |
| 1990 params->canon_props[i].dpd.CurrentValue.u8 = value->u8; | 2483 params->canon_props[i].dpd.CurrentValue.u8 = value->u8; |
| 1991 break; | 2484 break; |
| 1992 case PTP_DTC_UINT16: | 2485 case PTP_DTC_UINT16: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 * char **block - the pointer to the block of data read | 2528 * char **block - the pointer to the block of data read |
| 2036 * uint32_t* readnum - the number of bytes read | 2529 * uint32_t* readnum - the number of bytes read |
| 2037 * | 2530 * |
| 2038 **/ | 2531 **/ |
| 2039 uint16_t | 2532 uint16_t |
| 2040 ptp_canon_getpartialobject (PTPParams* params, uint32_t handle, | 2533 ptp_canon_getpartialobject (PTPParams* params, uint32_t handle, |
| 2041 uint32_t offset, uint32_t size, | 2534 uint32_t offset, uint32_t size, |
| 2042 uint32_t pos, unsigned char** block, | 2535 uint32_t pos, unsigned char** block, |
| 2043 uint32_t* readnum) | 2536 uint32_t* readnum) |
| 2044 { | 2537 { |
| 2045 » uint16_t ret; | 2538 » PTPContainer» ptp; |
| 2046 » PTPContainer ptp; | 2539 » uint16_t» ret; |
| 2047 » unsigned char *data=NULL; | 2540 » unsigned char» *data; |
| 2048 » unsigned int len; | |
| 2049 | 2541 |
| 2050 » PTP_CNT_INIT(ptp); | 2542 » PTP_CNT_INIT(ptp, PTP_OC_CANON_GetPartialObjectEx, handle, offset, size,
pos); |
| 2051 » ptp.Code=PTP_OC_CANON_GetPartialObjectEx; | 2543 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, NULL); |
| 2052 » ptp.Param1=handle; | |
| 2053 » ptp.Param2=offset; | |
| 2054 » ptp.Param3=size; | |
| 2055 » ptp.Param4=pos; | |
| 2056 » ptp.Nparam=4; | |
| 2057 » len=0; | |
| 2058 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &len); | |
| 2059 if (ret==PTP_RC_OK) { | 2544 if (ret==PTP_RC_OK) { |
| 2060 *block=data; | 2545 *block=data; |
| 2061 *readnum=ptp.Param1; | 2546 *readnum=ptp.Param1; |
| 2062 } | 2547 } |
| 2548 free (data); |
| 2063 return ret; | 2549 return ret; |
| 2064 } | 2550 } |
| 2065 | 2551 |
| 2066 /** | 2552 /** |
| 2067 * ptp_canon_getviewfinderimage: | 2553 * ptp_canon_getviewfinderimage: |
| 2068 * | 2554 * |
| 2069 * This operation can be used to read the image which is currently | 2555 * This operation can be used to read the image which is currently |
| 2070 * in the camera's viewfinder. The image size is 320x240, format is JPEG. | 2556 * in the camera's viewfinder. The image size is 320x240, format is JPEG. |
| 2071 * Of course, prior to calling this operation, one must turn the viewfinder | 2557 * Of course, prior to calling this operation, one must turn the viewfinder |
| 2072 * on with the CANON_ViewfinderOn command. | 2558 * on with the CANON_ViewfinderOn command. |
| 2073 * Invoking this operation many times, one can get live video from the camera! | 2559 * Invoking this operation many times, one can get live video from the camera! |
| 2074 * | 2560 * |
| 2075 * params: PTPParams* | 2561 * params: PTPParams* |
| 2076 * | 2562 * |
| 2077 * Return values: Some PTP_RC_* code. | 2563 * Return values: Some PTP_RC_* code. |
| 2078 * char **image - the pointer to the read image | 2564 * char **image - the pointer to the read image |
| 2079 * unit32_t *size - the size of the image in bytes | 2565 * unit32_t *size - the size of the image in bytes |
| 2080 * | 2566 * |
| 2081 **/ | 2567 **/ |
| 2082 uint16_t | 2568 uint16_t |
| 2083 ptp_canon_getviewfinderimage (PTPParams* params, unsigned char** image, uint32_t
* size) | 2569 ptp_canon_getviewfinderimage (PTPParams* params, unsigned char** image, uint32_t
* size) |
| 2084 { | 2570 { |
| 2085 » uint16_t ret; | 2571 » PTPContainer» ptp; |
| 2086 » PTPContainer ptp; | 2572 » uint16_t» ret; |
| 2087 » unsigned int len; | |
| 2088 | 2573 |
| 2089 » PTP_CNT_INIT(ptp); | 2574 » PTP_CNT_INIT(ptp, PTP_OC_CANON_GetViewfinderImage); |
| 2090 » ptp.Code=PTP_OC_CANON_GetViewfinderImage; | 2575 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, image, NULL); |
| 2091 » ptp.Nparam=0; | 2576 » if (ret==PTP_RC_OK) |
| 2092 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, image, &len); | 2577 » » *size=ptp.Param1; |
| 2093 » if (ret==PTP_RC_OK) *size=ptp.Param1; | |
| 2094 return ret; | 2578 return ret; |
| 2095 } | 2579 } |
| 2096 | 2580 |
| 2097 /** | 2581 /** |
| 2098 * ptp_canon_getchanges: | 2582 * ptp_canon_getchanges: |
| 2099 * | 2583 * |
| 2100 * This is an interesting operation, about the effect of which I am not sure. | 2584 * This is an interesting operation, about the effect of which I am not sure. |
| 2101 * This command is called every time when a device property has been changed | 2585 * This command is called every time when a device property has been changed |
| 2102 * with the SetDevicePropValue operation, and after some other operations. | 2586 * with the SetDevicePropValue operation, and after some other operations. |
| 2103 * This operation reads the array of Device Properties which have been changed | 2587 * This operation reads the array of Device Properties which have been changed |
| 2104 * by the previous operation. | 2588 * by the previous operation. |
| 2105 * Probably, this operation is even required to make those changes work. | 2589 * Probably, this operation is even required to make those changes work. |
| 2106 * | 2590 * |
| 2107 * params: PTPParams* | 2591 * params: PTPParams* |
| 2108 * | 2592 * |
| 2109 * Return values: Some PTP_RC_* code. | 2593 * Return values: Some PTP_RC_* code. |
| 2110 * uint16_t** props - the pointer to the array of changed properties | 2594 * uint16_t** props - the pointer to the array of changed properties |
| 2111 * uint32_t* propnum - the number of elements in the *props array | 2595 * uint32_t* propnum - the number of elements in the *props array |
| 2112 * | 2596 * |
| 2113 **/ | 2597 **/ |
| 2114 uint16_t | 2598 uint16_t |
| 2115 ptp_canon_getchanges (PTPParams* params, uint16_t** props, uint32_t* propnum) | 2599 ptp_canon_getchanges (PTPParams* params, uint16_t** props, uint32_t* propnum) |
| 2116 { | 2600 { |
| 2117 » uint16_t ret; | 2601 » PTPContainer» ptp; |
| 2118 » PTPContainer ptp; | 2602 » unsigned char» *data; |
| 2119 » unsigned char* data=NULL; | 2603 » unsigned int» size; |
| 2120 » unsigned int len; | |
| 2121 | 2604 |
| 2122 » PTP_CNT_INIT(ptp); | 2605 » PTP_CNT_INIT(ptp, PTP_OC_CANON_GetChanges); |
| 2123 » ptp.Code=PTP_OC_CANON_GetChanges; | 2606 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 2124 » ptp.Nparam=0; | 2607 » *propnum=ptp_unpack_uint16_t_array(params,data,0,size,props); |
| 2125 » len=0; | |
| 2126 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &len); | |
| 2127 » if (ret == PTP_RC_OK) | |
| 2128 » *propnum=ptp_unpack_uint16_t_array(params,data,0,props); | |
| 2129 free(data); | 2608 free(data); |
| 2130 » return ret; | 2609 » return PTP_RC_OK; |
| 2131 } | 2610 } |
| 2132 | 2611 |
| 2133 /** | 2612 /** |
| 2134 * ptp_canon_getobjectinfo: | 2613 * ptp_canon_getobjectinfo: |
| 2135 * | 2614 * |
| 2136 * This command reads a specified object's record in a device's filesystem, | 2615 * This command reads a specified object's record in a device's filesystem, |
| 2137 * or the records of all objects belonging to a specified folder (association). | 2616 * or the records of all objects belonging to a specified folder (association). |
| 2138 * | 2617 * |
| 2139 * params: PTPParams* | 2618 * params: PTPParams* |
| 2140 * uint32_t store - StorageID, | 2619 * uint32_t store - StorageID, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2151 * Return values: Some PTP_RC_* code. | 2630 * Return values: Some PTP_RC_* code. |
| 2152 * PTPCANONFolderEntry** entries - the pointer to the folder entry array | 2631 * PTPCANONFolderEntry** entries - the pointer to the folder entry array |
| 2153 * uint32_t* entnum - the number of elements of the array | 2632 * uint32_t* entnum - the number of elements of the array |
| 2154 * | 2633 * |
| 2155 **/ | 2634 **/ |
| 2156 uint16_t | 2635 uint16_t |
| 2157 ptp_canon_getobjectinfo (PTPParams* params, uint32_t store, uint32_t p2, | 2636 ptp_canon_getobjectinfo (PTPParams* params, uint32_t store, uint32_t p2, |
| 2158 uint32_t parent, uint32_t handle, | 2637 uint32_t parent, uint32_t handle, |
| 2159 PTPCANONFolderEntry** entries, uint32_t* entnum) | 2638 PTPCANONFolderEntry** entries, uint32_t* entnum) |
| 2160 { | 2639 { |
| 2161 » uint16_t ret; | 2640 » PTPContainer» ptp; |
| 2162 » PTPContainer ptp; | 2641 » uint16_t» ret; |
| 2163 » unsigned char *data = NULL; | 2642 » unsigned char» *data; |
| 2164 » unsigned int len; | 2643 » unsigned int» i; |
| 2165 | 2644 |
| 2166 » PTP_CNT_INIT(ptp); | 2645 » PTP_CNT_INIT(ptp, PTP_OC_CANON_GetObjectInfoEx, store, p2, parent, handl
e); |
| 2167 » ptp.Code=PTP_OC_CANON_GetObjectInfoEx; | 2646 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, NULL); |
| 2168 » ptp.Param1=store; | 2647 » if (ret != PTP_RC_OK) |
| 2169 » ptp.Param2=p2; | 2648 » » goto exit; |
| 2170 » ptp.Param3=parent; | 2649 |
| 2171 » ptp.Param4=handle; | 2650 » *entnum=ptp.Param1; |
| 2172 » ptp.Nparam=4; | 2651 » *entries=calloc(*entnum, sizeof(PTPCANONFolderEntry)); |
| 2173 » len=0; | 2652 » if (*entries==NULL) { |
| 2174 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &len); | 2653 » » ret=PTP_RC_GeneralError; |
| 2175 » if (ret == PTP_RC_OK) { | 2654 » » goto exit; |
| 2176 » » int i; | 2655 » } |
| 2177 » » *entnum=ptp.Param1; | 2656 » for(i=0; i<(*entnum); i++) |
| 2178 » » *entries=calloc(*entnum, sizeof(PTPCANONFolderEntry)); | 2657 » » ptp_unpack_Canon_FE(params, |
| 2179 » » if (*entries!=NULL) { | 2658 » » » » data+i*PTP_CANON_FolderEntryLen, |
| 2180 » » » for(i=0; i<(*entnum); i++) | 2659 » » » » &((*entries)[i]) ); |
| 2181 » » » » ptp_unpack_Canon_FE(params, | 2660 |
| 2182 » » » » » data+i*PTP_CANON_FolderEntryLen, | 2661 exit: |
| 2183 » » » » » &((*entries)[i]) ); | 2662 » free (data); |
| 2184 » » } else { | |
| 2185 » » » ret=PTP_ERROR_IO; /* Cannot allocate memory */ | |
| 2186 » » } | |
| 2187 » } | |
| 2188 » free(data); | |
| 2189 return ret; | 2663 return ret; |
| 2190 } | 2664 } |
| 2191 | 2665 |
| 2192 /** | 2666 /** |
| 2193 * ptp_canon_get_objecthandle_by_name: | 2667 * ptp_canon_get_objecthandle_by_name: |
| 2194 * | 2668 * |
| 2195 * This command looks up the specified object on the camera. | 2669 * This command looks up the specified object on the camera. |
| 2196 * | 2670 * |
| 2197 * Format is "A:\\PATH". | 2671 * Format is "A:\\PATH". |
| 2198 * | 2672 * |
| 2199 * The 'A' is the VolumeLabel from GetStorageInfo, | 2673 * The 'A' is the VolumeLabel from GetStorageInfo, |
| 2200 * my IXUS has "A" for the card and "V" for internal memory. | 2674 * my IXUS has "A" for the card and "V" for internal memory. |
| 2201 * | 2675 * |
| 2202 * params: PTPParams* | 2676 * params: PTPParams* |
| 2203 * char* name - path name | 2677 * char* name - path name |
| 2204 * | 2678 * |
| 2205 * Return values: Some PTP_RC_* code. | 2679 * Return values: Some PTP_RC_* code. |
| 2206 * uint32_t *oid - PTP object id. | 2680 * uint32_t *oid - PTP object id. |
| 2207 * | 2681 * |
| 2208 **/ | 2682 **/ |
| 2209 uint16_t | 2683 uint16_t |
| 2210 ptp_canon_get_objecthandle_by_name (PTPParams* params, char* name, uint32_t* obj
ectid) | 2684 ptp_canon_get_objecthandle_by_name (PTPParams* params, char* name, uint32_t* obj
ectid) |
| 2211 { | 2685 { |
| 2212 » uint16_t ret; | 2686 » PTPContainer» ptp; |
| 2213 » PTPContainer ptp; | 2687 » uint16_t» ret; |
| 2214 » unsigned char *data = NULL; | 2688 » unsigned char» *data; |
| 2215 » uint8_t len; | 2689 » uint8_t»» len = 0; |
| 2216 | 2690 |
| 2217 » PTP_CNT_INIT (ptp); | 2691 » PTP_CNT_INIT(ptp, PTP_OC_CANON_GetObjectHandleByName); |
| 2218 » ptp.Code=PTP_OC_CANON_GetObjectHandleByName; | |
| 2219 » ptp.Nparam=0; | |
| 2220 » len=0; | |
| 2221 data = malloc (2*(strlen(name)+1)+2); | 2692 data = malloc (2*(strlen(name)+1)+2); |
| 2693 if (!data) return PTP_RC_GeneralError; |
| 2222 memset (data, 0, 2*(strlen(name)+1)+2); | 2694 memset (data, 0, 2*(strlen(name)+1)+2); |
| 2223 ptp_pack_string (params, name, data, 0, &len); | 2695 ptp_pack_string (params, name, data, 0, &len); |
| 2224 ret=ptp_transaction (params, &ptp, PTP_DP_SENDDATA, (len+1)*2+1, &data,
NULL); | 2696 ret=ptp_transaction (params, &ptp, PTP_DP_SENDDATA, (len+1)*2+1, &data,
NULL); |
| 2225 free (data); | 2697 free (data); |
| 2226 *objectid = ptp.Param1; | 2698 *objectid = ptp.Param1; |
| 2227 return ret; | 2699 return ret; |
| 2228 } | 2700 } |
| 2229 | 2701 |
| 2230 /** | 2702 /** |
| 2231 * ptp_canon_get_customize_data: | 2703 * ptp_canon_get_customize_data: |
| 2232 * | 2704 * |
| 2233 * This command downloads the specified theme slot, including jpegs | 2705 * This command downloads the specified theme slot, including jpegs |
| 2234 * and wav files. | 2706 * and wav files. |
| 2235 * | 2707 * |
| 2236 * params: PTPParams* | 2708 * params: PTPParams* |
| 2237 * uint32_t themenr - nr of theme | 2709 * uint32_t themenr - nr of theme |
| 2238 * | 2710 * |
| 2239 * Return values: Some PTP_RC_* code. | 2711 * Return values: Some PTP_RC_* code. |
| 2240 * unsigned char **data - pointer to data pointer | 2712 * unsigned char **data - pointer to data pointer |
| 2241 * unsigned int *size - size of data returned | 2713 * unsigned int *size - size of data returned |
| 2242 * | 2714 * |
| 2243 **/ | 2715 **/ |
| 2244 uint16_t | 2716 uint16_t |
| 2245 ptp_canon_get_customize_data (PTPParams* params, uint32_t themenr, | 2717 ptp_canon_get_customize_data (PTPParams* params, uint32_t themenr, |
| 2246 unsigned char **data, unsigned int *size) | 2718 unsigned char **data, unsigned int *size) |
| 2247 { | 2719 { |
| 2248 PTPContainer ptp; | 2720 PTPContainer ptp; |
| 2249 | 2721 |
| 2250 » *data = NULL; | 2722 » PTP_CNT_INIT(ptp, PTP_OC_CANON_GetCustomizeData, themenr); |
| 2723 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); |
| 2724 } |
| 2725 |
| 2726 |
| 2727 uint16_t |
| 2728 ptp_nikon_curve_download (PTPParams* params, unsigned char **data, unsigned int
*size) |
| 2729 { |
| 2730 » PTPContainer ptp; |
| 2731 |
| 2732 » PTP_CNT_INIT(ptp, PTP_OC_NIKON_CurveDownload); |
| 2733 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); |
| 2734 } |
| 2735 |
| 2736 /** |
| 2737 * ptp_sony_sdioconnect: |
| 2738 * |
| 2739 * This changes modes of the camera |
| 2740 * |
| 2741 * params:» PTPParams* |
| 2742 * |
| 2743 * Return values: Some PTP_RC_* code. |
| 2744 * |
| 2745 **/ |
| 2746 uint16_t |
| 2747 ptp_sony_sdioconnect (PTPParams* params, uint32_t p1, uint32_t p2, uint32_t p3) |
| 2748 { |
| 2749 » PTPContainer» ptp; |
| 2750 » unsigned char» *data; |
| 2751 |
| 2752 » PTP_CNT_INIT(ptp, PTP_OC_SONY_SDIOConnect, p1, p2, p3); |
| 2753 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, NUL
L)); |
| 2754 » free (data); |
| 2755 » return PTP_RC_OK; |
| 2756 } |
| 2757 /** |
| 2758 * ptp_sony_get_vendorpropcodes: |
| 2759 * |
| 2760 * This command downloads the vendor specific property codes. |
| 2761 * |
| 2762 * params:» PTPParams* |
| 2763 * |
| 2764 * Return values: Some PTP_RC_* code. |
| 2765 * unsigned char **data - pointer to data pointer |
| 2766 * unsigned int *size - size of data returned |
| 2767 * |
| 2768 **/ |
| 2769 uint16_t |
| 2770 ptp_sony_get_vendorpropcodes (PTPParams* params, uint16_t **props, unsigned int
*size) |
| 2771 { |
| 2772 » PTPContainer» ptp; |
| 2773 » unsigned char» *xdata; |
| 2774 » unsigned int » xsize, psize1 = 0, psize2 = 0; |
| 2775 » uint16_t» *props1 = NULL,*props2 = NULL; |
| 2776 |
| 2777 » *props = NULL; |
| 2251 *size = 0; | 2778 *size = 0; |
| 2252 » PTP_CNT_INIT(ptp); | 2779 » PTP_CNT_INIT(ptp, PTP_OC_SONY_GetSDIOGetExtDeviceInfo, 0xc8 /* unclear *
/); |
| 2253 » ptp.Code» = PTP_OC_CANON_GetCustomizeData; | 2780 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &xdata, &x
size)); |
| 2254 » ptp.Param1» = themenr; | 2781 » if (xsize == 0) { |
| 2255 » ptp.Nparam» = 1; | 2782 » » ptp_debug (params, "No special operations sent?"); |
| 2256 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); | 2783 » » return PTP_RC_OK; |
| 2257 } | 2784 » } |
| 2258 | 2785 |
| 2259 | 2786 » psize1 = ptp_unpack_uint16_t_array (params, xdata+2, 0, xsize, &props1); |
| 2260 uint16_t | 2787 » ptp_debug (params, "xsize %d, got size %d\n", xsize, psize1*2 + 2 + 4); |
| 2261 ptp_nikon_curve_download (PTPParams* params, unsigned char **data, unsigned int
*size) { | 2788 » if (psize1*2 + 2 + 4 < xsize) { |
| 2262 » PTPContainer ptp; | 2789 » » psize2 = ptp_unpack_uint16_t_array(params,xdata+2+psize1*2+4, 0,
xsize, &props2); |
| 2263 » *data = NULL; | 2790 » } |
| 2264 » *size = 0; | 2791 » *size = psize1+psize2; |
| 2265 » PTP_CNT_INIT(ptp); | 2792 » *props = malloc((psize1+psize2)*sizeof(uint16_t)); |
| 2266 » ptp.Code» = PTP_OC_NIKON_CurveDownload; | 2793 » memcpy (*props, props1, psize1*sizeof(uint16_t)); |
| 2267 » ptp.Nparam» = 0; | 2794 » memcpy ((*props)+psize1, props2, psize2*sizeof(uint16_t)); |
| 2268 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); | 2795 » free (props1); |
| 2269 } | 2796 » free (props2); |
| 2270 | 2797 » free (xdata); |
| 2271 /** | 2798 » return PTP_RC_OK; |
| 2272 * ptp_canon_get_vendorpropcodes: | 2799 } |
| 2800 |
| 2801 uint16_t |
| 2802 ptp_sony_getdevicepropdesc (PTPParams* params, uint16_t propcode, PTPDevicePropD
esc *dpd) |
| 2803 { |
| 2804 » PTPContainer» ptp; |
| 2805 » unsigned char» *data; |
| 2806 » unsigned int » size, len = 0; |
| 2807 » uint16_t» ret; |
| 2808 |
| 2809 » PTP_CNT_INIT(ptp, PTP_OC_SONY_GetDevicePropdesc, propcode); |
| 2810 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 2811 » /* first 16 bit is 0xc8 0x00, then an array of 16 bit PTP ids */ |
| 2812 » ret = ptp_unpack_Sony_DPD(params,data,dpd,size,&len) ? PTP_RC_OK : PTP_R
C_GeneralError; |
| 2813 » free (data); |
| 2814 » return ret; |
| 2815 } |
| 2816 |
| 2817 uint16_t |
| 2818 ptp_sony_getalldevicepropdesc (PTPParams* params) |
| 2819 { |
| 2820 » PTPContainer» » ptp; |
| 2821 » unsigned char» » *data, *dpddata; |
| 2822 » unsigned int» » size, readlen; |
| 2823 » PTPDevicePropDesc» dpd; |
| 2824 |
| 2825 » PTP_CNT_INIT(ptp, PTP_OC_SONY_GetAllDevicePropData); |
| 2826 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 2827 » dpddata = data+8; /* nr of entries 32bit, 0 32bit */ |
| 2828 » size -= 8; |
| 2829 » while (size>0) { |
| 2830 » » unsigned int» i; |
| 2831 » » uint16_t» propcode; |
| 2832 |
| 2833 » » if (!ptp_unpack_Sony_DPD (params, dpddata, &dpd, size, &readlen)
) |
| 2834 » » » break; |
| 2835 |
| 2836 » » propcode = dpd.DevicePropertyCode; |
| 2837 |
| 2838 » » for (i=0;i<params->nrofdeviceproperties;i++) |
| 2839 » » » if (params->deviceproperties[i].desc.DevicePropertyCode
== propcode) |
| 2840 » » » » break; |
| 2841 |
| 2842 » » if (i == params->nrofdeviceproperties) { |
| 2843 » » » params->deviceproperties = realloc(params->devicepropert
ies,(i+1)*sizeof(params->deviceproperties[0])); |
| 2844 » » » memset(¶ms->deviceproperties[i],0,sizeof(params->dev
iceproperties[0])); |
| 2845 » » » params->nrofdeviceproperties++; |
| 2846 » » } else { |
| 2847 » » » ptp_free_devicepropdesc (¶ms->deviceproperties[i].de
sc); |
| 2848 » » } |
| 2849 » » params->deviceproperties[i].desc = dpd; |
| 2850 #if 0 |
| 2851 » » ptp_debug (params, "dpd.DevicePropertyCode %04x, readlen %d, get
set %d", dpd.DevicePropertyCode, readlen, dpd.GetSet); |
| 2852 » » switch (dpd.DataType) { |
| 2853 » » case PTP_DTC_INT8: |
| 2854 » » » ptp_debug (params, "value %d/%x", dpd.CurrentValue.i8, d
pd.CurrentValue.i8); |
| 2855 » » » break; |
| 2856 » » case PTP_DTC_UINT8: |
| 2857 » » » ptp_debug (params, "value %d/%x", dpd.CurrentValue.u8, d
pd.CurrentValue.u8); |
| 2858 » » » break; |
| 2859 » » case PTP_DTC_UINT16: |
| 2860 » » » ptp_debug (params, "value %d/%x", dpd.CurrentValue.u16,
dpd.CurrentValue.u16); |
| 2861 » » » break; |
| 2862 » » case PTP_DTC_INT16: |
| 2863 » » » ptp_debug (params, "value %d/%x", dpd.CurrentValue.i16,
dpd.CurrentValue.i16); |
| 2864 » » » break; |
| 2865 » » case PTP_DTC_INT32: |
| 2866 » » » ptp_debug (params, "value %d/%x", dpd.CurrentValue.i32,
dpd.CurrentValue.i32); |
| 2867 » » » break; |
| 2868 » » case PTP_DTC_UINT32: |
| 2869 » » » ptp_debug (params, "value %d/%x", dpd.CurrentValue.u32,
dpd.CurrentValue.u32); |
| 2870 » » » break; |
| 2871 » » default: |
| 2872 » » » ptp_debug (params, "unknown type %x", dpd.DataType); |
| 2873 » » » break; |
| 2874 » » } |
| 2875 #endif |
| 2876 » » dpddata += readlen; |
| 2877 » » size -= readlen; |
| 2878 » } |
| 2879 » free(data); |
| 2880 » return PTP_RC_OK; |
| 2881 } |
| 2882 |
| 2883 uint16_t |
| 2884 ptp_sony_setdevicecontrolvaluea (PTPParams* params, uint16_t propcode, |
| 2885 » » » PTPPropertyValue *value, uint16_t datatype) |
| 2886 { |
| 2887 » PTPContainer» ptp; |
| 2888 » uint16_t» ret; |
| 2889 » unsigned char» *data; |
| 2890 » uint32_t» size; |
| 2891 |
| 2892 » PTP_CNT_INIT(ptp, PTP_OC_SONY_SetControlDeviceA, propcode); |
| 2893 » size = ptp_pack_DPV(params, value, &data, datatype); |
| 2894 » ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL); |
| 2895 » free(data); |
| 2896 » return ret; |
| 2897 } |
| 2898 |
| 2899 uint16_t |
| 2900 ptp_sony_setdevicecontrolvalueb (PTPParams* params, uint16_t propcode, |
| 2901 » » » PTPPropertyValue *value, uint16_t datatype) |
| 2902 { |
| 2903 » PTPContainer» ptp; |
| 2904 » uint16_t» ret; |
| 2905 » unsigned char» *data; |
| 2906 » uint32_t» size; |
| 2907 |
| 2908 » PTP_CNT_INIT(ptp, PTP_OC_SONY_SetControlDeviceB, propcode); |
| 2909 » size = ptp_pack_DPV(params, value, &data , datatype); |
| 2910 » ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL); |
| 2911 » free(data); |
| 2912 » return ret; |
| 2913 } |
| 2914 |
| 2915 uint16_t |
| 2916 ptp_sony_9280 (PTPParams* params, uint32_t param1, |
| 2917 » uint32_t additional, uint32_t data2, uint32_t data3, uint32_t data4, uin
t8_t x, uint8_t y) |
| 2918 { |
| 2919 » PTPContainer» ptp; |
| 2920 » unsigned char » buf[18]; |
| 2921 » unsigned char» *buffer; |
| 2922 |
| 2923 » PTP_CNT_INIT(ptp, 0x9280, param1); |
| 2924 |
| 2925 » if ((additional != 0) && (additional != 2)) |
| 2926 » » return PTP_RC_GeneralError; |
| 2927 |
| 2928 » htod32a(&buf[0], additional); |
| 2929 » htod32a(&buf[4], data2); |
| 2930 » htod32a(&buf[8], data3); |
| 2931 » htod32a(&buf[12], data4); |
| 2932 |
| 2933 » /* only sent in the case where additional is 2 */ |
| 2934 » buf[16]= x; buf[17]= y; |
| 2935 |
| 2936 » buffer=buf; |
| 2937 » return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, 16+additional, &bu
ffer, NULL); |
| 2938 } |
| 2939 |
| 2940 uint16_t |
| 2941 ptp_sony_9281 (PTPParams* params, uint32_t param1) { |
| 2942 » PTPContainer» ptp; |
| 2943 » unsigned int» size = 0; |
| 2944 » unsigned char» *buffer = NULL; |
| 2945 » uint16_t» ret; |
| 2946 |
| 2947 » PTP_CNT_INIT(ptp, 0x9281, param1); |
| 2948 » ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &buffer, &size); |
| 2949 » free (buffer); |
| 2950 » return ret; |
| 2951 } |
| 2952 |
| 2953 /** |
| 2954 * ptp_generic_getdevicepropdesc: |
| 2955 * |
| 2956 * This command gets a propertydesc. |
| 2957 * If a vendor specific property desc query is available, it uses that. |
| 2958 * If not, it falls back to the generic PTP getdevicepropdesc. |
| 2959 * |
| 2960 * params:» PTPParams* |
| 2961 * uint16_t propcode |
| 2962 * PTPDevicePropDesc *dpd |
| 2963 * |
| 2964 * Return values: Some PTP_RC_* code. |
| 2965 * |
| 2966 **/ |
| 2967 /* Cache time in seconds. Should perhaps be more granular... */ |
| 2968 #define CACHETIME 2 |
| 2969 |
| 2970 uint16_t |
| 2971 ptp_generic_getdevicepropdesc (PTPParams *params, uint16_t propcode, PTPDevicePr
opDesc *dpd) |
| 2972 { |
| 2973 » unsigned int» i; |
| 2974 » time_t» » now; |
| 2975 |
| 2976 » for (i=0;i<params->nrofdeviceproperties;i++) |
| 2977 » » if (params->deviceproperties[i].desc.DevicePropertyCode == propc
ode) |
| 2978 » » » break; |
| 2979 » if (i == params->nrofdeviceproperties) { |
| 2980 » » params->deviceproperties = realloc(params->deviceproperties,(i+1
)*sizeof(params->deviceproperties[0])); |
| 2981 » » memset(¶ms->deviceproperties[i],0,sizeof(params->deviceprope
rties[0])); |
| 2982 » » params->nrofdeviceproperties++; |
| 2983 » } |
| 2984 |
| 2985 » if (params->deviceproperties[i].desc.DataType != PTP_DTC_UNDEF) { |
| 2986 » » time(&now); |
| 2987 » » if ((now - params->deviceproperties[i].timestamp) <= CACHETIME)
{ |
| 2988 » » » duplicate_DevicePropDesc(¶ms->deviceproperties[i].de
sc, dpd); |
| 2989 » » » return PTP_RC_OK; |
| 2990 » » } |
| 2991 » » /* free cached entry as we will refetch it. */ |
| 2992 » » ptp_free_devicepropdesc (¶ms->deviceproperties[i].desc); |
| 2993 » } |
| 2994 |
| 2995 » if (» (params->deviceinfo.VendorExtensionID == PTP_VENDOR_SONY) && |
| 2996 » » ptp_operation_issupported(params, PTP_OC_SONY_GetAllDevicePropDa
ta) |
| 2997 » ) { |
| 2998 » » CHECK_PTP_RC(ptp_sony_getalldevicepropdesc (params)); |
| 2999 |
| 3000 » » for (i=0;i<params->nrofdeviceproperties;i++) |
| 3001 » » » if (params->deviceproperties[i].desc.DevicePropertyCode
== propcode) |
| 3002 » » » » break; |
| 3003 » » if (i == params->nrofdeviceproperties) { |
| 3004 » » » ptp_debug (params, "property 0x%04x not found?\n", propc
ode); |
| 3005 » » » return PTP_RC_GeneralError; |
| 3006 » » } |
| 3007 » » time(&now); |
| 3008 » » params->deviceproperties[i].timestamp = now; |
| 3009 » » duplicate_DevicePropDesc(¶ms->deviceproperties[i].desc, dpd)
; |
| 3010 » » return PTP_RC_OK; |
| 3011 » } |
| 3012 » if (» (params->deviceinfo.VendorExtensionID == PTP_VENDOR_SONY) && |
| 3013 » » ptp_operation_issupported(params, PTP_OC_SONY_GetDevicePropdesc) |
| 3014 » ) { |
| 3015 » » CHECK_PTP_RC(ptp_sony_getdevicepropdesc (params, propcode, ¶
ms->deviceproperties[i].desc)); |
| 3016 |
| 3017 » » time(&now); |
| 3018 » » params->deviceproperties[i].timestamp = now; |
| 3019 » » duplicate_DevicePropDesc(¶ms->deviceproperties[i].desc, dpd)
; |
| 3020 » » return PTP_RC_OK; |
| 3021 » } |
| 3022 |
| 3023 |
| 3024 » if (ptp_operation_issupported(params, PTP_OC_GetDevicePropDesc)) { |
| 3025 » » CHECK_PTP_RC(ptp_getdevicepropdesc (params, propcode, ¶ms->d
eviceproperties[i].desc)); |
| 3026 |
| 3027 » » time(&now); |
| 3028 » » params->deviceproperties[i].timestamp = now; |
| 3029 » » duplicate_DevicePropDesc(¶ms->deviceproperties[i].desc, dpd)
; |
| 3030 » » return PTP_RC_OK; |
| 3031 » } |
| 3032 |
| 3033 » return PTP_RC_OK; |
| 3034 } |
| 3035 |
| 3036 /** |
| 3037 * ptp_generic_setdevicepropvalue: |
| 3038 * |
| 3039 * This command sets a property value, device specific. |
| 3040 * |
| 3041 * params:» PTPParams* |
| 3042 * uint16_t propcode |
| 3043 * PTPDevicePropertyValue *value |
| 3044 * uint16_t datatype |
| 3045 * |
| 3046 * Return values: Some PTP_RC_* code. |
| 3047 * |
| 3048 **/ |
| 3049 uint16_t |
| 3050 ptp_generic_setdevicepropvalue (PTPParams* params, uint16_t propcode, |
| 3051 » PTPPropertyValue *value, uint16_t datatype) |
| 3052 { |
| 3053 » unsigned int i; |
| 3054 |
| 3055 » /* reset the cache entry */ |
| 3056 » for (i=0;i<params->nrofdeviceproperties;i++) |
| 3057 » » if (params->deviceproperties[i].desc.DevicePropertyCode == propc
ode) |
| 3058 » » » break; |
| 3059 » if (i != params->nrofdeviceproperties) |
| 3060 » » params->deviceproperties[i].timestamp = 0; |
| 3061 |
| 3062 » /* FIXME: change the cache? hmm */ |
| 3063 » /* this works for some methods, but not for all */ |
| 3064 » if (» (params->deviceinfo.VendorExtensionID == PTP_VENDOR_SONY) && |
| 3065 » » ptp_operation_issupported(params, PTP_OC_SONY_SetControlDeviceA) |
| 3066 » ) |
| 3067 » » return ptp_sony_setdevicecontrolvaluea (params, propcode, value,
datatype); |
| 3068 » return ptp_setdevicepropvalue (params, propcode, value, datatype); |
| 3069 } |
| 3070 |
| 3071 /** |
| 3072 * ptp_nikon_get_vendorpropcodes: |
| 2273 * | 3073 * |
| 2274 * This command downloads the vendor specific property codes. | 3074 * This command downloads the vendor specific property codes. |
| 2275 * | 3075 * |
| 2276 * params: PTPParams* | 3076 * params: PTPParams* |
| 2277 * | 3077 * |
| 2278 * Return values: Some PTP_RC_* code. | 3078 * Return values: Some PTP_RC_* code. |
| 2279 * unsigned char **data - pointer to data pointer | 3079 * unsigned char **data - pointer to data pointer |
| 2280 * unsigned int *size - size of data returned | 3080 * unsigned int *size - size of data returned |
| 2281 * | 3081 * |
| 2282 **/ | 3082 **/ |
| 2283 uint16_t | 3083 uint16_t |
| 2284 ptp_nikon_get_vendorpropcodes (PTPParams* params, uint16_t **props, unsigned int
*size) { | 3084 ptp_nikon_get_vendorpropcodes (PTPParams* params, uint16_t **props, unsigned int
*size) |
| 3085 { |
| 2285 PTPContainer ptp; | 3086 PTPContainer ptp; |
| 2286 » uint16_t» ret; | 3087 » unsigned char» *data = NULL; |
| 2287 » unsigned char» *xdata = NULL; | 3088 » unsigned int» xsize = 0; |
| 2288 » unsigned int » xsize; | |
| 2289 | 3089 |
| 2290 *props = NULL; | 3090 *props = NULL; |
| 2291 *size = 0; | 3091 *size = 0; |
| 2292 » PTP_CNT_INIT(ptp); | 3092 » PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetVendorPropCodes); |
| 2293 » ptp.Code» = PTP_OC_NIKON_GetVendorPropCodes; | 3093 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &xs
ize)); |
| 2294 » ptp.Nparam» = 0; | 3094 » *size = ptp_unpack_uint16_t_array(params,data,0,xsize,props); |
| 2295 » ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &xdata, &xsize); | 3095 » free (data); |
| 2296 » if (ret == PTP_RC_OK) | 3096 » return PTP_RC_OK; |
| 2297 » *size = ptp_unpack_uint16_t_array(params,xdata,0,props); | |
| 2298 » free (xdata); | |
| 2299 » return ret; | |
| 2300 } | 3097 } |
| 2301 | 3098 |
| 2302 uint16_t | 3099 uint16_t |
| 2303 ptp_nikon_getfileinfoinblock ( PTPParams* params, | 3100 ptp_nikon_getfileinfoinblock ( PTPParams* params, |
| 2304 uint32_t p1, uint32_t p2, uint32_t p3, | 3101 uint32_t p1, uint32_t p2, uint32_t p3, |
| 2305 unsigned char **data, unsigned int *size | 3102 unsigned char **data, unsigned int *size |
| 2306 ) { | 3103 ) { |
| 2307 PTPContainer ptp; | 3104 PTPContainer ptp; |
| 2308 » *data = NULL; | 3105 |
| 2309 » *size = 0; | 3106 » PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetFileInfoInBlock, p1, p2, p3); |
| 2310 » PTP_CNT_INIT(ptp); | |
| 2311 » ptp.Code» = PTP_OC_NIKON_GetFileInfoInBlock; | |
| 2312 » ptp.Nparam» = 3; | |
| 2313 » ptp.Param1» = p1; | |
| 2314 » ptp.Param2» = p2; | |
| 2315 » ptp.Param3» = p3; | |
| 2316 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); | 3107 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); |
| 2317 } | 3108 } |
| 2318 | 3109 |
| 2319 /** | 3110 /** |
| 2320 * ptp_nikon_get_liveview_image: | 3111 * ptp_nikon_get_liveview_image: |
| 2321 * | 3112 * |
| 2322 * This command gets a LiveView image from newer Nikons DSLRs. | 3113 * This command gets a LiveView image from newer Nikons DSLRs. |
| 2323 * | 3114 * |
| 2324 * params: PTPParams* | 3115 * params: PTPParams* |
| 2325 * | 3116 * |
| 2326 * Return values: Some PTP_RC_* code. | 3117 * Return values: Some PTP_RC_* code. |
| 2327 * | 3118 * |
| 2328 **/ | 3119 **/ |
| 2329 uint16_t | 3120 uint16_t |
| 2330 ptp_nikon_get_liveview_image (PTPParams* params, unsigned char **data, unsigned
int *size) | 3121 ptp_nikon_get_liveview_image (PTPParams* params, unsigned char **data, unsigned
int *size) |
| 2331 { | 3122 { |
| 2332 PTPContainer ptp; | 3123 PTPContainer ptp; |
| 2333 | 3124 |
| 2334 PTP_CNT_INIT(ptp); | 3125 PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetLiveViewImg); |
| 2335 ptp.Code=PTP_OC_NIKON_GetLiveViewImg; | |
| 2336 ptp.Nparam=0; | |
| 2337 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); | 3126 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); |
| 2338 } | 3127 } |
| 2339 | 3128 |
| 2340 /** | 3129 /** |
| 2341 * ptp_nikon_get_preview_image: | 3130 * ptp_nikon_get_preview_image: |
| 2342 * | 3131 * |
| 2343 * This command gets a Preview image from newer Nikons DSLRs. | 3132 * This command gets a Preview image from newer Nikons DSLRs. |
| 2344 * | 3133 * |
| 2345 * params: PTPParams* | 3134 * params: PTPParams* |
| 2346 * | 3135 * |
| 2347 * Return values: Some PTP_RC_* code. | 3136 * Return values: Some PTP_RC_* code. |
| 2348 * | 3137 * |
| 2349 **/ | 3138 **/ |
| 2350 uint16_t | 3139 uint16_t |
| 2351 ptp_nikon_get_preview_image (PTPParams* params, unsigned char **xdata, unsigned
int *xsize, | 3140 ptp_nikon_get_preview_image (PTPParams* params, unsigned char **xdata, unsigned
int *xsize, |
| 2352 uint32_t *handle) | 3141 uint32_t *handle) |
| 2353 { | 3142 { |
| 2354 PTPContainer» ptp; | 3143 » PTPContainer» ptp; |
| 2355 » uint16_t» ret; | 3144 |
| 2356 | 3145 PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetPreviewImg); |
| 2357 PTP_CNT_INIT(ptp); | 3146 |
| 2358 ptp.Code=PTP_OC_NIKON_GetPreviewImg; | 3147 » /* FIXME: |
| 2359 ptp.Nparam=0; | 3148 » * pdslrdashboard passes 3 parameters: |
| 2360 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, xdata, xsize); | 3149 » * objectid, minimum size, maximum size |
| 2361 » if (ret == PTP_RC_OK) { | 3150 » */ |
| 2362 » » if (ptp.Nparam > 0) | 3151 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, xdata, xsi
ze)); |
| 2363 » » » *handle = ptp.Param1; | 3152 » if (ptp.Nparam > 0) |
| 2364 » } | 3153 » » *handle = ptp.Param1; |
| 2365 » return ret; | 3154 » return PTP_RC_OK; |
| 2366 } | 3155 } |
| 2367 | 3156 |
| 2368 /** | 3157 /** |
| 2369 * ptp_canon_eos_get_viewfinder_image: | 3158 * ptp_canon_eos_get_viewfinder_image: |
| 2370 * | 3159 * |
| 2371 * This command gets a Viewfinder image from newer Nikons DSLRs. | 3160 * This command gets a Viewfinder image from newer Nikons DSLRs. |
| 2372 * | 3161 * |
| 2373 * params: PTPParams* | 3162 * params: PTPParams* |
| 2374 * | 3163 * |
| 2375 * Return values: Some PTP_RC_* code. | 3164 * Return values: Some PTP_RC_* code. |
| 2376 * | 3165 * |
| 2377 **/ | 3166 **/ |
| 2378 uint16_t | 3167 uint16_t |
| 2379 ptp_canon_eos_get_viewfinder_image (PTPParams* params, unsigned char **data, uns
igned int *size) | 3168 ptp_canon_eos_get_viewfinder_image (PTPParams* params, unsigned char **data, uns
igned int *size) |
| 2380 { | 3169 { |
| 2381 PTPContainer ptp; | 3170 PTPContainer ptp; |
| 2382 | 3171 |
| 2383 PTP_CNT_INIT(ptp); | 3172 PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetViewFinderData, 0x00100000 /* from
trace */); |
| 2384 ptp.Code=PTP_OC_CANON_EOS_GetViewFinderData; | |
| 2385 ptp.Nparam=1; | |
| 2386 ptp.Param1=0x00100000; /* from trace */ | |
| 2387 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); | 3173 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); |
| 2388 } | 3174 } |
| 2389 | 3175 |
| 2390 uint16_t | 3176 uint16_t |
| 2391 ptp_canon_eos_get_viewfinder_image_handler (PTPParams* params, PTPDataHandler*ha
ndler) | 3177 ptp_canon_eos_get_viewfinder_image_handler (PTPParams* params, PTPDataHandler*ha
ndler) |
| 2392 { | 3178 { |
| 2393 PTPContainer ptp; | 3179 PTPContainer ptp; |
| 2394 | 3180 |
| 2395 PTP_CNT_INIT(ptp); | 3181 PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetViewFinderData, 0x00100000 /* from
trace */); |
| 2396 ptp.Code=PTP_OC_CANON_EOS_GetViewFinderData; | |
| 2397 ptp.Nparam=1; | |
| 2398 ptp.Param1=0x00100000; /* from trace */ | |
| 2399 return ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, handler); | 3182 return ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, handler); |
| 2400 } | 3183 } |
| 2401 | 3184 |
| 2402 /** | 3185 /** |
| 2403 * ptp_nikon_check_event: | 3186 * ptp_nikon_check_event: |
| 2404 * | 3187 * |
| 2405 * This command checks the event queue on the Nikon. | 3188 * This command checks the event queue on the Nikon. |
| 2406 * | 3189 * |
| 2407 * params: PTPParams* | 3190 * params: PTPParams* |
| 2408 * PTPUSBEventContainer **event - list of usb events. | 3191 * PTPUSBEventContainer **event - list of usb events. |
| 2409 * int *evtcnt - number of usb events in event structure. | 3192 * int *evtcnt - number of usb events in event structure. |
| 2410 * | 3193 * |
| 2411 * Return values: Some PTP_RC_* code. | 3194 * Return values: Some PTP_RC_* code. |
| 2412 * | 3195 * |
| 2413 **/ | 3196 **/ |
| 2414 uint16_t | 3197 uint16_t |
| 2415 ptp_nikon_check_event (PTPParams* params, PTPContainer** event, int* evtcnt) | 3198 ptp_nikon_check_event (PTPParams* params, PTPContainer** event, unsigned int* ev
tcnt) |
| 2416 { | 3199 { |
| 2417 PTPContainer ptp; | 3200 » PTPContainer» ptp; |
| 2418 » uint16_t ret; | 3201 » unsigned char» *data; |
| 2419 » unsigned char *data = NULL; | 3202 » unsigned int» size; |
| 2420 » unsigned int size = 0; | |
| 2421 | 3203 |
| 2422 » PTP_CNT_INIT(ptp); | 3204 » PTP_CNT_INIT(ptp, PTP_OC_NIKON_CheckEvent); |
| 2423 » ptp.Code=PTP_OC_NIKON_CheckEvent; | |
| 2424 » ptp.Nparam=0; | |
| 2425 *evtcnt = 0; | 3205 *evtcnt = 0; |
| 2426 » ret = ptp_transaction (params, &ptp, PTP_DP_GETDATA, 0, &data, &size); | 3206 » CHECK_PTP_RC(ptp_transaction (params, &ptp, PTP_DP_GETDATA, 0, &data, &s
ize)); |
| 2427 » if (ret == PTP_RC_OK) { | 3207 » ptp_unpack_Nikon_EC (params, data, size, event, evtcnt); |
| 2428 » » ptp_unpack_Nikon_EC (params, data, size, event, evtcnt); | 3208 » free (data); |
| 2429 » » free (data); | 3209 » return PTP_RC_OK; |
| 2430 » } | |
| 2431 » return ret; | |
| 2432 } | 3210 } |
| 2433 | 3211 |
| 2434 /** | 3212 /** |
| 2435 * ptp_nikon_getptpipinfo: | 3213 * ptp_nikon_getptpipinfo: |
| 2436 * | 3214 * |
| 2437 * This command gets the ptpip info data. | 3215 * This command gets the ptpip info data. |
| 2438 * | 3216 * |
| 2439 * params: PTPParams* | 3217 * params: PTPParams* |
| 2440 * unsigned char *data - data | 3218 * unsigned char *data - data |
| 2441 * unsigned int size - size of returned data | 3219 * unsigned int size - size of returned data |
| 2442 * | 3220 * |
| 2443 * Return values: Some PTP_RC_* code. | 3221 * Return values: Some PTP_RC_* code. |
| 2444 * | 3222 * |
| 2445 **/ | 3223 **/ |
| 2446 uint16_t | 3224 uint16_t |
| 2447 ptp_nikon_getptpipinfo (PTPParams* params, unsigned char **data, unsigned int *s
ize) | 3225 ptp_nikon_getptpipinfo (PTPParams* params, unsigned char **data, unsigned int *s
ize) |
| 2448 { | 3226 { |
| 2449 PTPContainer ptp; | 3227 PTPContainer ptp; |
| 2450 | 3228 |
| 2451 PTP_CNT_INIT(ptp); | 3229 PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetDevicePTPIPInfo); |
| 2452 ptp.Code=PTP_OC_NIKON_GetDevicePTPIPInfo; | |
| 2453 ptp.Nparam=0; | |
| 2454 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); | 3230 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); |
| 2455 } | 3231 } |
| 2456 | 3232 |
| 2457 /** | 3233 /** |
| 2458 * ptp_nikon_getwifiprofilelist: | 3234 * ptp_nikon_getwifiprofilelist: |
| 2459 * | 3235 * |
| 2460 * This command gets the wifi profile list. | 3236 * This command gets the wifi profile list. |
| 2461 * | 3237 * |
| 2462 * params: PTPParams* | 3238 * params: PTPParams* |
| 2463 * | 3239 * |
| 2464 * Return values: Some PTP_RC_* code. | 3240 * Return values: Some PTP_RC_* code. |
| 2465 * | 3241 * |
| 2466 **/ | 3242 **/ |
| 2467 uint16_t | 3243 uint16_t |
| 2468 ptp_nikon_getwifiprofilelist (PTPParams* params) | 3244 ptp_nikon_getwifiprofilelist (PTPParams* params) |
| 2469 { | 3245 { |
| 2470 PTPContainer ptp; | 3246 » PTPContainer» ptp; |
| 2471 » unsigned char* data; | 3247 » uint16_t» ret; |
| 2472 » unsigned int size; | 3248 » unsigned char» *data; |
| 2473 » unsigned int pos; | 3249 » unsigned int» size, pos, profn, n; |
| 2474 » unsigned int profn; | 3250 » char» » *buffer; |
| 2475 » unsigned int n; | 3251 » uint8_t»» len; |
| 2476 » char* buffer; | 3252 |
| 2477 » uint8_t len; | 3253 PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetProfileAllData); |
| 2478 » | |
| 2479 PTP_CNT_INIT(ptp); | |
| 2480 ptp.Code=PTP_OC_NIKON_GetProfileAllData; | |
| 2481 ptp.Nparam=0; | |
| 2482 » size = 0; | |
| 2483 » data = NULL; | |
| 2484 CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); | 3254 CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 2485 | 3255 |
| 2486 » if (size < 2) return PTP_RC_Undefined; /* FIXME: Add more precise error
code */ | 3256 » ret = PTP_RC_Undefined; /* FIXME: Add more precise error code */ |
| 3257 |
| 3258 » if (size < 2) |
| 3259 » » goto exit; |
| 2487 | 3260 |
| 2488 params->wifi_profiles_version = data[0]; | 3261 params->wifi_profiles_version = data[0]; |
| 2489 params->wifi_profiles_number = data[1]; | 3262 params->wifi_profiles_number = data[1]; |
| 2490 » if (params->wifi_profiles) | 3263 » free(params->wifi_profiles); |
| 2491 » » free(params->wifi_profiles); | |
| 2492 | 3264 |
| 2493 params->wifi_profiles = malloc(params->wifi_profiles_number*sizeof(PTPNI
KONWifiProfile)); | 3265 params->wifi_profiles = malloc(params->wifi_profiles_number*sizeof(PTPNI
KONWifiProfile)); |
| 2494 memset(params->wifi_profiles, 0, params->wifi_profiles_number*sizeof(PTP
NIKONWifiProfile)); | 3266 memset(params->wifi_profiles, 0, params->wifi_profiles_number*sizeof(PTP
NIKONWifiProfile)); |
| 2495 | 3267 |
| 2496 pos = 2; | 3268 pos = 2; |
| 2497 profn = 0; | 3269 profn = 0; |
| 2498 while (profn < params->wifi_profiles_number && pos < size) { | 3270 while (profn < params->wifi_profiles_number && pos < size) { |
| 2499 » » if (pos+6 >= size) return PTP_RC_Undefined; | 3271 » » if (pos+6 >= size) |
| 3272 » » » goto exit; |
| 2500 params->wifi_profiles[profn].id = data[pos++]; | 3273 params->wifi_profiles[profn].id = data[pos++]; |
| 2501 params->wifi_profiles[profn].valid = data[pos++]; | 3274 params->wifi_profiles[profn].valid = data[pos++]; |
| 2502 | 3275 |
| 2503 n = dtoh32a(&data[pos]); | 3276 n = dtoh32a(&data[pos]); |
| 2504 pos += 4; | 3277 pos += 4; |
| 2505 » » if (pos+n+4 >= size) return PTP_RC_Undefined; | 3278 » » if (pos+n+4 >= size) |
| 3279 » » » goto exit; |
| 2506 strncpy(params->wifi_profiles[profn].profile_name, (char*)&data[
pos], n); | 3280 strncpy(params->wifi_profiles[profn].profile_name, (char*)&data[
pos], n); |
| 2507 params->wifi_profiles[profn].profile_name[16] = '\0'; | 3281 params->wifi_profiles[profn].profile_name[16] = '\0'; |
| 2508 pos += n; | 3282 pos += n; |
| 2509 | 3283 |
| 2510 params->wifi_profiles[profn].display_order = data[pos++]; | 3284 params->wifi_profiles[profn].display_order = data[pos++]; |
| 2511 params->wifi_profiles[profn].device_type = data[pos++]; | 3285 params->wifi_profiles[profn].device_type = data[pos++]; |
| 2512 params->wifi_profiles[profn].icon_type = data[pos++]; | 3286 params->wifi_profiles[profn].icon_type = data[pos++]; |
| 2513 | 3287 |
| 2514 buffer = ptp_unpack_string(params, data, pos, &len); | 3288 buffer = ptp_unpack_string(params, data, pos, &len); |
| 2515 strncpy(params->wifi_profiles[profn].creation_date, buffer, size
of(params->wifi_profiles[profn].creation_date)); | 3289 strncpy(params->wifi_profiles[profn].creation_date, buffer, size
of(params->wifi_profiles[profn].creation_date)); |
| 2516 free (buffer); | 3290 free (buffer); |
| 2517 pos += (len*2+1); | 3291 pos += (len*2+1); |
| 2518 » » if (pos+1 >= size) return PTP_RC_Undefined; | 3292 » » if (pos+1 >= size) |
| 3293 » » » goto exit; |
| 2519 /* FIXME: check if it is really last usage date */ | 3294 /* FIXME: check if it is really last usage date */ |
| 2520 buffer = ptp_unpack_string(params, data, pos, &len); | 3295 buffer = ptp_unpack_string(params, data, pos, &len); |
| 2521 strncpy(params->wifi_profiles[profn].lastusage_date, buffer, siz
eof(params->wifi_profiles[profn].lastusage_date)); | 3296 strncpy(params->wifi_profiles[profn].lastusage_date, buffer, siz
eof(params->wifi_profiles[profn].lastusage_date)); |
| 2522 free (buffer); | 3297 free (buffer); |
| 2523 pos += (len*2+1); | 3298 pos += (len*2+1); |
| 2524 » » if (pos+5 >= size) return PTP_RC_Undefined; | 3299 » » if (pos+5 >= size) |
| 3300 » » » goto exit; |
| 2525 | 3301 |
| 2526 n = dtoh32a(&data[pos]); | 3302 n = dtoh32a(&data[pos]); |
| 2527 pos += 4; | 3303 pos += 4; |
| 2528 » » if (pos+n >= size) return PTP_RC_Undefined; | 3304 » » if (pos+n >= size) |
| 3305 » » » goto exit; |
| 2529 strncpy(params->wifi_profiles[profn].essid, (char*)&data[pos], n
); | 3306 strncpy(params->wifi_profiles[profn].essid, (char*)&data[pos], n
); |
| 2530 params->wifi_profiles[profn].essid[32] = '\0'; | 3307 params->wifi_profiles[profn].essid[32] = '\0'; |
| 2531 pos += n; | 3308 pos += n; |
| 2532 pos += 1; | 3309 pos += 1; |
| 2533 profn++; | 3310 profn++; |
| 2534 } | 3311 } |
| 2535 | 3312 |
| 2536 #if 0 | 3313 #if 0 |
| 2537 PTPNIKONWifiProfile test; | 3314 PTPNIKONWifiProfile test; |
| 2538 memset(&test, 0, sizeof(PTPNIKONWifiProfile)); | 3315 memset(&test, 0, sizeof(PTPNIKONWifiProfile)); |
| 2539 strcpy(test.profile_name, "MyTest"); | 3316 strcpy(test.profile_name, "MyTest"); |
| 2540 test.icon_type = 1; | 3317 test.icon_type = 1; |
| 2541 strcpy(test.essid, "nikon"); | 3318 strcpy(test.essid, "nikon"); |
| 2542 test.ip_address = 10 + 11 << 16 + 11 << 24; | 3319 test.ip_address = 10 + 11 << 16 + 11 << 24; |
| 2543 test.subnet_mask = 24; | 3320 test.subnet_mask = 24; |
| 2544 test.access_mode = 1; | 3321 test.access_mode = 1; |
| 2545 test.wifi_channel = 1; | 3322 test.wifi_channel = 1; |
| 2546 test.key_nr = 1; | 3323 test.key_nr = 1; |
| 2547 | 3324 |
| 2548 ptp_nikon_writewifiprofile(params, &test); | 3325 ptp_nikon_writewifiprofile(params, &test); |
| 2549 #endif | 3326 #endif |
| 2550 | 3327 » /* everything went Ok */ |
| 2551 » return PTP_RC_OK; | 3328 » ret = PTP_RC_OK; |
| 3329 exit: |
| 3330 » free (data); |
| 3331 » return ret; |
| 2552 } | 3332 } |
| 2553 | 3333 |
| 2554 /** | 3334 /** |
| 2555 * ptp_nikon_writewifiprofile: | 3335 * ptp_nikon_writewifiprofile: |
| 2556 * | 3336 * |
| 2557 * This command gets the ptpip info data. | 3337 * This command gets the ptpip info data. |
| 2558 * | 3338 * |
| 2559 * params: PTPParams* | 3339 * params: PTPParams* |
| 2560 * unsigned int profilenr - profile number | 3340 * unsigned int profilenr - profile number |
| 2561 * unsigned char *data - data | 3341 * unsigned char *data - data |
| 2562 * unsigned int size - size of returned data | 3342 * unsigned int size - size of returned data |
| 2563 * | 3343 * |
| 2564 * Return values: Some PTP_RC_* code. | 3344 * Return values: Some PTP_RC_* code. |
| 2565 * | 3345 * |
| 2566 **/ | 3346 **/ |
| 2567 uint16_t | 3347 uint16_t |
| 2568 ptp_nikon_writewifiprofile (PTPParams* params, PTPNIKONWifiProfile* profile) | 3348 ptp_nikon_writewifiprofile (PTPParams* params, PTPNIKONWifiProfile* profile) |
| 2569 { | 3349 { |
| 2570 unsigned char guid[16]; | |
| 2571 | |
| 2572 PTPContainer ptp; | 3350 PTPContainer ptp; |
| 2573 unsigned char buffer[1024]; | 3351 unsigned char buffer[1024]; |
| 2574 unsigned char* data = buffer; | 3352 unsigned char* data = buffer; |
| 2575 int size = 0; | 3353 int size = 0; |
| 2576 int i; | 3354 int i; |
| 2577 uint8_t len; | 3355 uint8_t len; |
| 2578 int profilenr = -1; | 3356 int profilenr = -1; |
| 2579 » | 3357 » unsigned char guid[16]; |
| 3358 |
| 2580 ptp_nikon_getptpipguid(guid); | 3359 ptp_nikon_getptpipguid(guid); |
| 2581 | 3360 |
| 2582 if (!params->wifi_profiles) | 3361 if (!params->wifi_profiles) |
| 2583 CHECK_PTP_RC(ptp_nikon_getwifiprofilelist(params)); | 3362 CHECK_PTP_RC(ptp_nikon_getwifiprofilelist(params)); |
| 2584 | 3363 |
| 2585 for (i = 0; i < params->wifi_profiles_number; i++) { | 3364 for (i = 0; i < params->wifi_profiles_number; i++) { |
| 2586 if (!params->wifi_profiles[i].valid) { | 3365 if (!params->wifi_profiles[i].valid) { |
| 2587 profilenr = params->wifi_profiles[i].id; | 3366 profilenr = params->wifi_profiles[i].id; |
| 2588 break; | 3367 break; |
| 2589 } | 3368 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2604 strncpy((char*)&buffer[0x05], profile->profile_name, 16); | 3383 strncpy((char*)&buffer[0x05], profile->profile_name, 16); |
| 2605 | 3384 |
| 2606 buffer[0x16] = 0x00; /* Display order */ | 3385 buffer[0x16] = 0x00; /* Display order */ |
| 2607 buffer[0x17] = profile->device_type; | 3386 buffer[0x17] = profile->device_type; |
| 2608 buffer[0x18] = profile->icon_type; | 3387 buffer[0x18] = profile->icon_type; |
| 2609 | 3388 |
| 2610 /* FIXME: Creation date: put a real date here */ | 3389 /* FIXME: Creation date: put a real date here */ |
| 2611 ptp_pack_string(params, "19990909T090909", data, 0x19, &len); | 3390 ptp_pack_string(params, "19990909T090909", data, 0x19, &len); |
| 2612 | 3391 |
| 2613 /* IP parameters */ | 3392 /* IP parameters */ |
| 2614 » *((unsigned int*)&buffer[0x3A]) = profile->ip_address; /* Do not reverse
bytes */ | 3393 » memcpy(&buffer[0x3A],&profile->ip_address,sizeof(profile->ip_address)); |
| 3394 » /**((unsigned int*)&buffer[0x3A]) = profile->ip_address; *//* Do not rev
erse bytes */ |
| 2615 buffer[0x3E] = profile->subnet_mask; | 3395 buffer[0x3E] = profile->subnet_mask; |
| 2616 » *((unsigned int*)&buffer[0x3F]) = profile->gateway_address; /* Do not re
verse bytes */ | 3396 » memcpy(&buffer[0x3F],&profile->gateway_address,sizeof(profile->gateway_a
ddress)); |
| 3397 » /**((unsigned int*)&buffer[0x3F]) = profile->gateway_address; */ /* Do n
ot reverse bytes */ |
| 2617 buffer[0x43] = profile->address_mode; | 3398 buffer[0x43] = profile->address_mode; |
| 2618 | 3399 |
| 2619 /* Wifi parameters */ | 3400 /* Wifi parameters */ |
| 2620 buffer[0x44] = profile->access_mode; | 3401 buffer[0x44] = profile->access_mode; |
| 2621 buffer[0x45] = profile->wifi_channel; | 3402 buffer[0x45] = profile->wifi_channel; |
| 2622 | 3403 |
| 2623 htod32a(&buffer[0x46], 33); /* essid */ | 3404 htod32a(&buffer[0x46], 33); /* essid */ |
| 2624 /* 32 as third parameter, so there will always be a null-byte in the en
d */ | 3405 /* 32 as third parameter, so there will always be a null-byte in the en
d */ |
| 2625 strncpy((char*)&buffer[0x4A], profile->essid, 32); | 3406 strncpy((char*)&buffer[0x4A], profile->essid, 32); |
| 2626 | 3407 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2638 htod16a(&buffer[0xC2], 5); /* (64-24)/8 = 5 */ | 3419 htod16a(&buffer[0xC2], 5); /* (64-24)/8 = 5 */ |
| 2639 break; | 3420 break; |
| 2640 case 2: /* WEP 128bit */ | 3421 case 2: /* WEP 128bit */ |
| 2641 htod16a(&buffer[0xC2], 13); /* (128-24)/8 = 13 */ | 3422 htod16a(&buffer[0xC2], 13); /* (128-24)/8 = 13 */ |
| 2642 break; | 3423 break; |
| 2643 default: | 3424 default: |
| 2644 htod16a(&buffer[0xC2], 0); | 3425 htod16a(&buffer[0xC2], 0); |
| 2645 } | 3426 } |
| 2646 size = 0xC4; | 3427 size = 0xC4; |
| 2647 | 3428 |
| 2648 » PTP_CNT_INIT(ptp); | 3429 » PTP_CNT_INIT(ptp, PTP_OC_NIKON_SendProfileData, profilenr); |
| 2649 » ptp.Code=PTP_OC_NIKON_SendProfileData; | |
| 2650 » ptp.Nparam=1; | |
| 2651 » ptp.Param1=profilenr; | |
| 2652 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL)
; | 3430 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL)
; |
| 2653 } | 3431 } |
| 2654 | 3432 |
| 2655 /** | 3433 /** |
| 2656 * ptp_mtp_getobjectpropssupported: | 3434 * ptp_mtp_getobjectpropssupported: |
| 2657 * | 3435 * |
| 2658 * This command gets the object properties possible from the device. | 3436 * This command gets the object properties possible from the device. |
| 2659 * | 3437 * |
| 2660 * params: PTPParams* | 3438 * params: PTPParams* |
| 2661 * uint ofc - object format code | 3439 * uint ofc - object format code |
| 2662 * unsigned int *propnum - number of elements in returned array | 3440 * unsigned int *propnum - number of elements in returned array |
| 2663 * uint16_t *props - array of supported properties | 3441 * uint16_t *props - array of supported properties |
| 2664 * | 3442 * |
| 2665 * Return values: Some PTP_RC_* code. | 3443 * Return values: Some PTP_RC_* code. |
| 2666 * | 3444 * |
| 2667 **/ | 3445 **/ |
| 2668 uint16_t | 3446 uint16_t |
| 2669 ptp_mtp_getobjectpropssupported (PTPParams* params, uint16_t ofc, | 3447 ptp_mtp_getobjectpropssupported (PTPParams* params, uint16_t ofc, |
| 2670 uint32_t *propnum, uint16_t **props | 3448 uint32_t *propnum, uint16_t **props |
| 2671 ) { | 3449 ) { |
| 2672 PTPContainer ptp; | 3450 » PTPContainer» ptp; |
| 2673 » uint16_t ret; | 3451 » unsigned char» *data = NULL; |
| 2674 » unsigned char *data = NULL; | 3452 » unsigned int» xsize = 0; |
| 2675 » unsigned int size = 0; | 3453 |
| 2676 | 3454 PTP_CNT_INIT(ptp, PTP_OC_MTP_GetObjectPropsSupported, ofc); |
| 2677 PTP_CNT_INIT(ptp); | 3455 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &xs
ize)); |
| 2678 ptp.Code=PTP_OC_MTP_GetObjectPropsSupported; | 3456 » *propnum=ptp_unpack_uint16_t_array (params, data, 0, xsize, props); |
| 2679 ptp.Nparam = 1; | |
| 2680 ptp.Param1 = ofc; | |
| 2681 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size); | |
| 2682 » if (ret == PTP_RC_OK) | |
| 2683 » *propnum=ptp_unpack_uint16_t_array(params,data,0,props); | |
| 2684 free(data); | 3457 free(data); |
| 2685 » return ret; | 3458 » return PTP_RC_OK; |
| 2686 } | 3459 } |
| 2687 | 3460 |
| 2688 /** | 3461 /** |
| 2689 * ptp_mtp_getobjectpropdesc: | 3462 * ptp_mtp_getobjectpropdesc: |
| 2690 * | 3463 * |
| 2691 * This command gets the object property description. | 3464 * This command gets the object property description. |
| 2692 * | 3465 * |
| 2693 * params: PTPParams* | 3466 * params: PTPParams* |
| 2694 * uint16_t opc - object property code | 3467 * uint16_t opc - object property code |
| 2695 * uint16_t ofc - object format code | 3468 * uint16_t ofc - object format code |
| 2696 * | 3469 * |
| 2697 * Return values: Some PTP_RC_* code. | 3470 * Return values: Some PTP_RC_* code. |
| 2698 * | 3471 * |
| 2699 **/ | 3472 **/ |
| 2700 uint16_t | 3473 uint16_t |
| 2701 ptp_mtp_getobjectpropdesc ( | 3474 ptp_mtp_getobjectpropdesc ( |
| 2702 PTPParams* params, uint16_t opc, uint16_t ofc, PTPObjectPropDesc *opd | 3475 PTPParams* params, uint16_t opc, uint16_t ofc, PTPObjectPropDesc *opd |
| 2703 ) { | 3476 ) { |
| 2704 PTPContainer ptp; | 3477 » PTPContainer» ptp; |
| 2705 » uint16_t ret; | 3478 » unsigned char» *data; |
| 2706 » unsigned char *data = NULL; | 3479 » unsigned int» size; |
| 2707 » unsigned int size = 0; | 3480 |
| 2708 | 3481 PTP_CNT_INIT(ptp, PTP_OC_MTP_GetObjectPropDesc, opc, ofc); |
| 2709 PTP_CNT_INIT(ptp); | 3482 CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 2710 ptp.Code=PTP_OC_MTP_GetObjectPropDesc; | 3483 » ptp_unpack_OPD (params, data, opd, size); |
| 2711 ptp.Nparam = 2; | |
| 2712 ptp.Param1 = opc; | |
| 2713 ptp.Param2 = ofc; | |
| 2714 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size); | |
| 2715 » if (ret == PTP_RC_OK) | |
| 2716 » » ptp_unpack_OPD (params, data, opd, size); | |
| 2717 free(data); | 3484 free(data); |
| 2718 » return ret; | 3485 » return PTP_RC_OK; |
| 2719 } | 3486 } |
| 2720 | 3487 |
| 2721 /** | 3488 /** |
| 2722 * ptp_mtp_getobjectpropvalue: | 3489 * ptp_mtp_getobjectpropvalue: |
| 2723 * | 3490 * |
| 2724 * This command gets the object properties of an object handle. | 3491 * This command gets the object properties of an object handle. |
| 2725 * | 3492 * |
| 2726 * params: PTPParams* | 3493 * params: PTPParams* |
| 2727 * uint32_t objectid - object format code | 3494 * uint32_t objectid - object format code |
| 2728 * uint16_t opc - object prop code | 3495 * uint16_t opc - object prop code |
| 2729 * | 3496 * |
| 2730 * Return values: Some PTP_RC_* code. | 3497 * Return values: Some PTP_RC_* code. |
| 2731 * | 3498 * |
| 2732 **/ | 3499 **/ |
| 2733 uint16_t | 3500 uint16_t |
| 2734 ptp_mtp_getobjectpropvalue ( | 3501 ptp_mtp_getobjectpropvalue ( |
| 2735 PTPParams* params, uint32_t oid, uint16_t opc, | 3502 PTPParams* params, uint32_t oid, uint16_t opc, |
| 2736 PTPPropertyValue *value, uint16_t datatype | 3503 PTPPropertyValue *value, uint16_t datatype |
| 2737 ) { | 3504 ) { |
| 2738 PTPContainer ptp; | 3505 » PTPContainer» ptp; |
| 2739 » uint16_t ret; | 3506 » uint16_t» ret = PTP_RC_OK; |
| 2740 » unsigned char *data = NULL; | 3507 » unsigned char» *data; |
| 2741 » unsigned int size = 0; | 3508 » unsigned int» size, offset = 0; |
| 2742 » int offset = 0; | |
| 2743 | 3509 |
| 2744 PTP_CNT_INIT(ptp); | 3510 PTP_CNT_INIT(ptp, PTP_OC_MTP_GetObjectPropValue, oid, opc); |
| 2745 ptp.Code=PTP_OC_MTP_GetObjectPropValue; | 3511 CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 2746 ptp.Nparam = 2; | 3512 if (!ptp_unpack_DPV(params, data, &offset, size, value, datatype)) { |
| 2747 ptp.Param1 = oid; | 3513 ptp_debug (params, "ptp_mtp_getobjectpropvalue: unpacking DPV fa
iled"); |
| 2748 ptp.Param2 = opc; | 3514 ret = PTP_RC_GeneralError; |
| 2749 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size); | 3515 } |
| 2750 » if (ret == PTP_RC_OK) | |
| 2751 » » ptp_unpack_DPV(params, data, &offset, size, value, datatype); | |
| 2752 free(data); | 3516 free(data); |
| 2753 return ret; | 3517 return ret; |
| 2754 } | 3518 } |
| 2755 | 3519 |
| 2756 /** | 3520 /** |
| 2757 * ptp_mtp_setobjectpropvalue: | 3521 * ptp_mtp_setobjectpropvalue: |
| 2758 * | 3522 * |
| 2759 * This command gets the object properties of an object handle. | 3523 * This command gets the object properties of an object handle. |
| 2760 * | 3524 * |
| 2761 * params: PTPParams* | 3525 * params: PTPParams* |
| 2762 * uint32_t objectid - object format code | 3526 * uint32_t objectid - object format code |
| 2763 * uint16_t opc - object prop code | 3527 * uint16_t opc - object prop code |
| 2764 * | 3528 * |
| 2765 * Return values: Some PTP_RC_* code. | 3529 * Return values: Some PTP_RC_* code. |
| 2766 * | 3530 * |
| 2767 **/ | 3531 **/ |
| 2768 uint16_t | 3532 uint16_t |
| 2769 ptp_mtp_setobjectpropvalue ( | 3533 ptp_mtp_setobjectpropvalue ( |
| 2770 PTPParams* params, uint32_t oid, uint16_t opc, | 3534 PTPParams* params, uint32_t oid, uint16_t opc, |
| 2771 PTPPropertyValue *value, uint16_t datatype | 3535 PTPPropertyValue *value, uint16_t datatype |
| 2772 ) { | 3536 ) { |
| 2773 PTPContainer ptp; | 3537 » PTPContainer» ptp; |
| 2774 » uint16_t ret; | 3538 » uint16_t» ret; |
| 2775 » unsigned char *data = NULL; | 3539 » unsigned char» *data = NULL; |
| 2776 » unsigned int size ; | 3540 » uint32_t» size; |
| 2777 | 3541 |
| 2778 PTP_CNT_INIT(ptp); | 3542 PTP_CNT_INIT(ptp, PTP_OC_MTP_SetObjectPropValue, oid, opc); |
| 2779 ptp.Code=PTP_OC_MTP_SetObjectPropValue; | |
| 2780 ptp.Nparam = 2; | |
| 2781 ptp.Param1 = oid; | |
| 2782 ptp.Param2 = opc; | |
| 2783 size = ptp_pack_DPV(params, value, &data, datatype); | 3543 size = ptp_pack_DPV(params, value, &data, datatype); |
| 2784 ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL); | 3544 ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL); |
| 2785 free(data); | 3545 free(data); |
| 2786 return ret; | 3546 return ret; |
| 2787 } | 3547 } |
| 2788 | 3548 |
| 2789 uint16_t | 3549 uint16_t |
| 2790 ptp_mtp_getobjectreferences (PTPParams* params, uint32_t handle, uint32_t** ohAr
ray, uint32_t* arraylen) | 3550 ptp_mtp_getobjectreferences (PTPParams* params, uint32_t handle, uint32_t** ohAr
ray, uint32_t* arraylen) |
| 2791 { | 3551 { |
| 2792 » PTPContainer ptp; | 3552 » PTPContainer» ptp; |
| 2793 » uint16_t ret; | 3553 » unsigned char» *data; |
| 2794 » unsigned char* dpv=NULL; | 3554 » unsigned int» size; |
| 2795 » unsigned int dpvlen = 0; | |
| 2796 | 3555 |
| 2797 » PTP_CNT_INIT(ptp); | 3556 » PTP_CNT_INIT(ptp, PTP_OC_MTP_GetObjectReferences, handle); |
| 2798 » ptp.Code=PTP_OC_MTP_GetObjectReferences; | 3557 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data , &s
ize)); |
| 2799 » ptp.Param1=handle; | 3558 » /* Sandisk Sansa skips the DATA phase, but returns OK as response. |
| 2800 » ptp.Nparam=1; | |
| 2801 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpv, &dpvlen); | |
| 2802 » if (ret == PTP_RC_OK) { | |
| 2803 » » /* Sandisk Sansa skips the DATA phase, but returns OK as respons
e. | |
| 2804 * this will gives us a NULL here. Handle it. -Marcus */ | 3559 * this will gives us a NULL here. Handle it. -Marcus */ |
| 2805 » » if ((dpv == NULL) || (dpvlen == 0)) { | 3560 » if ((data == NULL) || (size == 0)) { |
| 2806 » » » *arraylen = 0; | 3561 » » *arraylen = 0; |
| 2807 » » » *ohArray = NULL; | 3562 » » *ohArray = NULL; |
| 2808 » » } else { | 3563 » } else { |
| 2809 » » » *arraylen = ptp_unpack_uint32_t_array(params, dpv, 0, oh
Array); | 3564 » » *arraylen = ptp_unpack_uint32_t_array(params, data , 0, size, oh
Array); |
| 2810 » » } | |
| 2811 } | 3565 } |
| 2812 » free(dpv); | 3566 » free(data); |
| 2813 » return ret; | 3567 » return PTP_RC_OK; |
| 2814 } | 3568 } |
| 2815 | 3569 |
| 2816 uint16_t | 3570 uint16_t |
| 2817 ptp_mtp_setobjectreferences (PTPParams* params, uint32_t handle, uint32_t* ohArr
ay, uint32_t arraylen) | 3571 ptp_mtp_setobjectreferences (PTPParams* params, uint32_t handle, uint32_t* ohArr
ay, uint32_t arraylen) |
| 2818 { | 3572 { |
| 2819 » PTPContainer ptp; | 3573 » PTPContainer» ptp; |
| 2820 » uint16_t ret; | 3574 » uint16_t» ret; |
| 2821 » uint32_t size; | 3575 » unsigned char» *data = NULL; |
| 2822 » unsigned char* dpv=NULL; | 3576 » uint32_t» size; |
| 2823 | 3577 |
| 2824 » PTP_CNT_INIT(ptp); | 3578 » PTP_CNT_INIT(ptp, PTP_OC_MTP_SetObjectReferences, handle); |
| 2825 » ptp.Code = PTP_OC_MTP_SetObjectReferences; | 3579 » size = ptp_pack_uint32_t_array(params, ohArray, arraylen, &data); |
| 2826 » ptp.Param1 = handle; | 3580 » ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL); |
| 2827 » ptp.Nparam = 1; | 3581 » free(data); |
| 2828 » size = ptp_pack_uint32_t_array(params, ohArray, arraylen, &dpv); | |
| 2829 » ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, (unsigned cha
r **)&dpv, NULL); | |
| 2830 » free(dpv); | |
| 2831 return ret; | 3582 return ret; |
| 2832 } | 3583 } |
| 2833 | 3584 |
| 2834 uint16_t | 3585 uint16_t |
| 2835 ptp_mtp_getobjectproplist (PTPParams* params, uint32_t handle, MTPProperties **p
rops, int *nrofprops) | 3586 ptp_mtp_getobjectproplist (PTPParams* params, uint32_t handle, MTPProperties **p
rops, int *nrofprops) |
| 2836 { | 3587 { |
| 2837 » uint16_t ret; | 3588 » PTPContainer» ptp; |
| 2838 » PTPContainer ptp; | 3589 » unsigned char» *data; |
| 2839 » unsigned char* opldata = NULL; | 3590 » unsigned int» size; |
| 2840 » unsigned int oplsize; | |
| 2841 | 3591 |
| 2842 » PTP_CNT_INIT(ptp); | 3592 » PTP_CNT_INIT(ptp, PTP_OC_MTP_GetObjPropList, handle, |
| 2843 » ptp.Code = PTP_OC_MTP_GetObjPropList; | 3593 » » 0x00000000U, /* 0x00000000U should be "all formats" */ |
| 2844 » ptp.Param1 = handle; | 3594 » » 0xFFFFFFFFU, /* 0xFFFFFFFFU should be "all properties" */ |
| 2845 » ptp.Param2 = 0x00000000U; /* 0x00000000U should be "all formats" */ | 3595 » » 0x00000000U, |
| 2846 » ptp.Param3 = 0xFFFFFFFFU; /* 0xFFFFFFFFU should be "all properties" */ | 3596 » » 0xFFFFFFFFU /* means - return full tree below the Param1 h
andle */ |
| 2847 » ptp.Param4 = 0x00000000U; | 3597 » ); |
| 2848 » ptp.Param5 = 0xFFFFFFFFU; /* means - return full tree below the Param1
handle */ | 3598 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 2849 » ptp.Nparam = 5; | 3599 » *nrofprops = ptp_unpack_OPL(params, data, props, size); |
| 2850 » ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &opldata, &oplsiz
e); | 3600 » free(data); |
| 2851 » if (ret == PTP_RC_OK) *nrofprops = ptp_unpack_OPL(params, opldata, props
, oplsize); | 3601 » return PTP_RC_OK; |
| 2852 » if (opldata != NULL) | |
| 2853 » » free(opldata); | |
| 2854 » return ret; | |
| 2855 } | 3602 } |
| 2856 | 3603 |
| 2857 uint16_t | 3604 uint16_t |
| 2858 ptp_mtp_getobjectproplist_single (PTPParams* params, uint32_t handle, MTPPropert
ies **props, int *nrofprops) | 3605 ptp_mtp_getobjectproplist_single (PTPParams* params, uint32_t handle, MTPPropert
ies **props, int *nrofprops) |
| 2859 { | 3606 { |
| 2860 » uint16_t ret; | 3607 » PTPContainer» ptp; |
| 2861 » PTPContainer ptp; | 3608 » unsigned char» *data; |
| 2862 » unsigned char* opldata = NULL; | 3609 » unsigned int» size; |
| 2863 » unsigned int oplsize; | |
| 2864 | 3610 |
| 2865 » PTP_CNT_INIT(ptp); | 3611 » PTP_CNT_INIT(ptp, PTP_OC_MTP_GetObjPropList, handle, |
| 2866 » ptp.Code = PTP_OC_MTP_GetObjPropList; | 3612 » » 0x00000000U, /* 0x00000000U should be "all formats" */ |
| 2867 » ptp.Param1 = handle; | 3613 » » 0xFFFFFFFFU, /* 0xFFFFFFFFU should be "all properties" */ |
| 2868 » ptp.Param2 = 0x00000000U; /* 0x00000000U should be "all formats" */ | 3614 » » 0x00000000U, |
| 2869 » ptp.Param3 = 0xFFFFFFFFU; /* 0xFFFFFFFFU should be "all properties" */ | 3615 » » 0x00000000U /* means - return single tree below the Param1
handle */ |
| 2870 » ptp.Param4 = 0x00000000U; | 3616 » ); |
| 2871 » ptp.Param5 = 0x00000000U; /* means - return single tree below the Param
1 handle */ | 3617 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &si
ze)); |
| 2872 » ptp.Nparam = 5; | 3618 » *nrofprops = ptp_unpack_OPL(params, data, props, size); |
| 2873 » ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &opldata, &oplsiz
e); | 3619 » free(data); |
| 2874 » if (ret == PTP_RC_OK) *nrofprops = ptp_unpack_OPL(params, opldata, props
, oplsize); | 3620 » return PTP_RC_OK; |
| 2875 » if (opldata != NULL) | |
| 2876 » » free(opldata); | |
| 2877 » return ret; | |
| 2878 } | 3621 } |
| 2879 | 3622 |
| 2880 uint16_t | 3623 uint16_t |
| 2881 ptp_mtp_sendobjectproplist (PTPParams* params, uint32_t* store, uint32_t* parent
handle, uint32_t* handle, | 3624 ptp_mtp_sendobjectproplist (PTPParams* params, uint32_t* store, uint32_t* parent
handle, uint32_t* handle, |
| 2882 uint16_t objecttype, uint64_t objectsize, MTPPropert
ies *props, int nrofprops) | 3625 uint16_t objecttype, uint64_t objectsize, MTPPropert
ies *props, int nrofprops) |
| 2883 { | 3626 { |
| 2884 » uint16_t ret; | 3627 » PTPContainer» ptp; |
| 2885 » PTPContainer ptp; | 3628 » uint16_t» ret; |
| 2886 » unsigned char* opldata=NULL; | 3629 » unsigned char» *data = NULL; |
| 2887 » uint32_t oplsize; | 3630 » uint32_t» size; |
| 2888 | 3631 |
| 2889 » PTP_CNT_INIT(ptp); | 3632 » PTP_CNT_INIT(ptp, PTP_OC_MTP_SendObjectPropList, *store, *parenthandle,
(uint32_t) objecttype, |
| 2890 » ptp.Code = PTP_OC_MTP_SendObjectPropList; | 3633 » » (uint32_t) (objectsize >> 32), (uint32_t) (objectsize & 0xf
fffffffU) |
| 2891 » ptp.Param1 = *store; | 3634 » ); |
| 2892 » ptp.Param2 = *parenthandle; | |
| 2893 » ptp.Param3 = (uint32_t) objecttype; | |
| 2894 » ptp.Param4 = (uint32_t) (objectsize >> 32); | |
| 2895 » ptp.Param5 = (uint32_t) (objectsize & 0xffffffffU); | |
| 2896 » ptp.Nparam = 5; | |
| 2897 | 3635 |
| 2898 /* Set object handle to 0 for a new object */ | 3636 /* Set object handle to 0 for a new object */ |
| 2899 » oplsize = ptp_pack_OPL(params,props,nrofprops,&opldata); | 3637 » size = ptp_pack_OPL(params,props,nrofprops,&data); |
| 2900 » ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, oplsize, &opldata,
NULL); | 3638 » ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL); |
| 2901 » free(opldata); | 3639 » free(data); |
| 2902 *store = ptp.Param1; | 3640 *store = ptp.Param1; |
| 2903 *parenthandle = ptp.Param2; | 3641 *parenthandle = ptp.Param2; |
| 2904 *handle = ptp.Param3; | 3642 *handle = ptp.Param3; |
| 2905 | 3643 |
| 2906 return ret; | 3644 return ret; |
| 2907 } | 3645 } |
| 2908 | 3646 |
| 2909 uint16_t | 3647 uint16_t |
| 2910 ptp_mtp_setobjectproplist (PTPParams* params, MTPProperties *props, int nrofprop
s) | 3648 ptp_mtp_setobjectproplist (PTPParams* params, MTPProperties *props, int nrofprop
s) |
| 2911 { | 3649 { |
| 2912 » uint16_t ret; | 3650 » PTPContainer» ptp; |
| 2913 » PTPContainer ptp; | 3651 » unsigned char» *data = NULL; |
| 2914 » unsigned char* opldata=NULL; | 3652 » uint32_t» size; |
| 2915 » uint32_t oplsize; | |
| 2916 | |
| 2917 » PTP_CNT_INIT(ptp); | |
| 2918 » ptp.Code = PTP_OC_MTP_SetObjPropList; | |
| 2919 » ptp.Nparam = 0; | |
| 2920 | |
| 2921 » oplsize = ptp_pack_OPL(params,props,nrofprops,&opldata); | |
| 2922 » ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, oplsize, &opldata,
NULL); | |
| 2923 » free(opldata); | |
| 2924 | 3653 |
| 2925 » return ret; | 3654 » PTP_CNT_INIT(ptp, PTP_OC_MTP_SetObjPropList); |
| 3655 » size = ptp_pack_OPL(params,props,nrofprops,&data); |
| 3656 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data,
NULL)); |
| 3657 » free(data); |
| 3658 » return PTP_RC_OK; |
| 2926 } | 3659 } |
| 2927 | 3660 |
| 2928 uint16_t | 3661 uint16_t |
| 2929 ptp_mtpz_sendwmdrmpdapprequest (PTPParams* params, unsigned char *appcertmsg, ui
nt32_t size) | 3662 ptp_mtpz_sendwmdrmpdapprequest (PTPParams* params, unsigned char *appcertmsg, ui
nt32_t size) |
| 2930 { | 3663 { |
| 2931 PTPContainer ptp; | 3664 PTPContainer ptp; |
| 2932 | 3665 |
| 2933 » PTP_CNT_INIT(ptp); | 3666 » PTP_CNT_INIT(ptp, PTP_OC_MTP_WMDRMPD_SendWMDRMPDAppRequest); |
| 2934 » ptp.Code=PTP_OC_MTP_WMDRMPD_SendWMDRMPDAppRequest; | |
| 2935 return ptp_transaction (params, &ptp, PTP_DP_SENDDATA, size, &appcertmsg
, NULL); | 3667 return ptp_transaction (params, &ptp, PTP_DP_SENDDATA, size, &appcertmsg
, NULL); |
| 2936 } | 3668 } |
| 2937 | 3669 |
| 2938 uint16_t | 3670 uint16_t |
| 2939 ptp_mtpz_getwmdrmpdappresponse (PTPParams* params, unsigned char **response, uin
t32_t *size) | 3671 ptp_mtpz_getwmdrmpdappresponse (PTPParams* params, unsigned char **response, uin
t32_t *size) |
| 2940 { | 3672 { |
| 2941 PTPContainer ptp; | 3673 PTPContainer ptp; |
| 2942 | 3674 |
| 2943 » PTP_CNT_INIT(ptp); | 3675 » PTP_CNT_INIT(ptp, PTP_OC_MTP_WMDRMPD_GetWMDRMPDAppResponse); |
| 2944 » ptp.Code = PTP_OC_MTP_WMDRMPD_GetWMDRMPDAppResponse; | |
| 2945 *size = 0; | 3676 *size = 0; |
| 2946 *response = NULL; | 3677 *response = NULL; |
| 2947 return ptp_transaction (params, &ptp, PTP_DP_GETDATA, 0, response, size)
; | 3678 return ptp_transaction (params, &ptp, PTP_DP_GETDATA, 0, response, size)
; |
| 2948 } | 3679 } |
| 2949 | 3680 |
| 2950 /****** CHDK interface ******/ | 3681 /****** CHDK interface ******/ |
| 2951 | 3682 |
| 2952 uint16_t | 3683 uint16_t |
| 2953 ptp_chdk_get_memory(PTPParams* params, int start, int num, unsigned char **buf ) | 3684 ptp_chdk_get_memory(PTPParams* params, int start, int num, unsigned char **buf) |
| 2954 { | 3685 { |
| 2955 PTPContainer ptp; | 3686 PTPContainer ptp; |
| 2956 | 3687 |
| 2957 » PTP_CNT_INIT(ptp); | 3688 » PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_GetMemory, start, num); |
| 2958 » ptp.Code=PTP_OC_CHDK; | |
| 2959 » ptp.Nparam=3; | |
| 2960 » ptp.Param1=PTP_CHDK_GetMemory; | |
| 2961 » ptp.Param2=start; | |
| 2962 » ptp.Param3=num; | |
| 2963 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, buf, NULL); | 3689 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, buf, NULL); |
| 2964 } | 3690 } |
| 2965 | 3691 |
| 3692 uint16_t |
| 3693 ptp_chdk_set_memory_long(PTPParams* params, int addr, int val) |
| 3694 { |
| 3695 PTPContainer ptp; |
| 3696 unsigned char *buf = (unsigned char *) &val; /* FIXME ... endianness? */ |
| 2966 | 3697 |
| 2967 uint16_t | 3698 » PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_SetMemory, addr, 4); |
| 2968 ptp_chdk_call(PTPParams* params, int *args, int size, int *ret) | 3699 » return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, 4, &buf, NULL); |
| 2969 { | |
| 2970 » uint16_t r; | |
| 2971 » PTPContainer ptp; | |
| 2972 | |
| 2973 » PTP_CNT_INIT(ptp); | |
| 2974 » ptp.Code=PTP_OC_CHDK; | |
| 2975 » ptp.Nparam=1; | |
| 2976 » ptp.Param1=PTP_CHDK_CallFunction; | |
| 2977 | |
| 2978 » /* FIXME: check int packing */ | |
| 2979 » r=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size*sizeof(int), (unsi
gned char **) &args, NULL); | |
| 2980 » if ( r == PTP_RC_OK ) | |
| 2981 » » return r; | |
| 2982 » if ( ret ) | |
| 2983 » » *ret = ptp.Param1; | |
| 2984 » return r; | |
| 2985 } | 3700 } |
| 2986 | 3701 |
| 2987 uint16_t | 3702 uint16_t |
| 2988 ptp_chdk_get_propcase(PTPParams* params, int start, int num, int* ints) | 3703 ptp_chdk_download(PTPParams* params, char *remote_fn, PTPDataHandler *handler) |
| 2989 { | 3704 { |
| 2990 PTPContainer ptp; | 3705 PTPContainer ptp; |
| 2991 | 3706 |
| 2992 » PTP_CNT_INIT(ptp); | 3707 » PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_TempData, 0); |
| 2993 » ptp.Code=PTP_OC_CHDK; | 3708 » CHECK_PTP_RC (ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(remo
te_fn), (unsigned char**)&remote_fn, NULL)); |
| 2994 » ptp.Nparam=3; | |
| 2995 » ptp.Param1=PTP_CHDK_GetPropCase; | |
| 2996 » ptp.Param2=start; | |
| 2997 » ptp.Param3=num; | |
| 2998 » /* FIXME: unpack ints correctly */ | |
| 2999 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, (unsigned char**
)ints, NULL); | |
| 3000 } | |
| 3001 | 3709 |
| 3002 uint16_t | 3710 » PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_DownloadFile); |
| 3003 ptp_chdk_get_paramdata(PTPParams* params, int start, int num, unsigned char **bu
f) | 3711 » return ptp_transaction_new (params, &ptp, PTP_DP_GETDATA, 0, handler); |
| 3004 { | |
| 3005 » PTPContainer ptp; | |
| 3006 | |
| 3007 » PTP_CNT_INIT(ptp); | |
| 3008 » ptp.Code=PTP_OC_CHDK; | |
| 3009 » ptp.Nparam=3; | |
| 3010 » ptp.Param1=PTP_CHDK_GetParamData; | |
| 3011 » ptp.Param2=start; | |
| 3012 » ptp.Param3=num; | |
| 3013 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, buf, NULL); | |
| 3014 } | 3712 } |
| 3015 | 3713 |
| 3016 #if 0 | 3714 #if 0 |
| 3017 int ptp_chdk_upload(char *local_fn, char *remote_fn, PTPParams* params, PTPDevic
eInfo* deviceinfo) | 3715 int ptp_chdk_upload(PTPParams* params, char *local_fn, char *remote_fn) |
| 3018 { | 3716 { |
| 3019 uint16_t ret; | 3717 uint16_t ret; |
| 3020 PTPContainer ptp; | 3718 PTPContainer ptp; |
| 3021 char *buf = NULL; | 3719 char *buf = NULL; |
| 3022 FILE *f; | 3720 FILE *f; |
| 3023 int s,l; | 3721 unsigned file_len,data_len,file_name_len; |
| 3024 struct stat st_buf; | |
| 3025 | 3722 |
| 3026 PTP_CNT_INIT(ptp); | 3723 PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_UploadFile); |
| 3027 ptp.Code=PTP_OC_CHDK; | |
| 3028 ptp.Nparam=2; | |
| 3029 ptp.Param1=PTP_CHDK_UploadFile; | |
| 3030 | |
| 3031 if (stat(local_fn, &st_buf)==0) ptp.Param2=st_buf.st_mtime-_timezone-_daylight
; else ptp.Param2=0; | |
| 3032 | 3724 |
| 3033 f = fopen(local_fn,"rb"); | 3725 f = fopen(local_fn,"rb"); |
| 3034 if ( f == NULL ) | 3726 if ( f == NULL ) |
| 3035 { | 3727 { |
| 3036 ptp_error(params,"could not open file \'%s\'",local_fn); | 3728 ptp_error(params,"could not open file \'%s\'",local_fn); |
| 3037 return 0; | 3729 return 0; |
| 3038 } | 3730 } |
| 3039 | 3731 |
| 3040 | |
| 3041 fseek(f,0,SEEK_END); | 3732 fseek(f,0,SEEK_END); |
| 3042 s = ftell(f); | 3733 file_len = ftell(f); |
| 3043 fseek(f,0,SEEK_SET); | 3734 fseek(f,0,SEEK_SET); |
| 3044 | 3735 |
| 3045 l = strlen(remote_fn); | 3736 file_name_len = strlen(remote_fn); |
| 3046 buf = malloc(4+l+s); | 3737 data_len = 4 + file_name_len + file_len; |
| 3047 memcpy(buf,&l,4); | 3738 buf = malloc(data_len); |
| 3048 memcpy(buf+4,remote_fn,l); | 3739 memcpy(buf,&file_name_len,4); |
| 3049 fread(buf+4+l,1,s,f); | 3740 memcpy(buf+4,remote_fn,file_name_len); |
| 3741 fread(buf+4+file_name_len,1,file_len,f); |
| 3050 | 3742 |
| 3051 fclose(f); | 3743 fclose(f); |
| 3052 | 3744 |
| 3053 ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, 4+l+s, &buf); | 3745 ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, data_len, &buf, NULL); |
| 3054 | 3746 |
| 3055 free(buf); | 3747 free(buf); |
| 3056 | 3748 |
| 3057 if ( ret != 0x2001 ) | 3749 if ( ret != PTP_RC_OK ) |
| 3058 { | 3750 { |
| 3059 ptp_error(params,"unexpected return code 0x%x",ret); | 3751 ptp_error(params,"unexpected return code 0x%x",ret); |
| 3060 return 0; | 3752 return 0; |
| 3061 } | 3753 } |
| 3062 return 1; | 3754 return 1; |
| 3063 } | 3755 } |
| 3064 | 3756 |
| 3065 int ptp_chdk_download(char *remote_fn, char *local_fn, PTPParams* params, PTPDev
iceInfo* deviceinfo) | |
| 3066 { | |
| 3067 uint16_t ret; | |
| 3068 PTPContainer ptp; | |
| 3069 char *buf = NULL; | |
| 3070 FILE *f; | |
| 3071 | |
| 3072 PTP_CNT_INIT(ptp); | |
| 3073 ptp.Code=PTP_OC_CHDK; | |
| 3074 ptp.Nparam=1; | |
| 3075 ptp.Param1=PTP_CHDK_TempData; | |
| 3076 ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(remote_fn), &remote_
fn); | |
| 3077 if ( ret != 0x2001 ) | |
| 3078 { | |
| 3079 ptp_error(params,"unexpected return code 0x%x",ret); | |
| 3080 return 0; | |
| 3081 } | |
| 3082 | |
| 3083 PTP_CNT_INIT(ptp); | |
| 3084 ptp.Code=PTP_OC_CHDK; | |
| 3085 ptp.Nparam=1; | |
| 3086 ptp.Param1=PTP_CHDK_DownloadFile; | |
| 3087 | |
| 3088 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &buf); | |
| 3089 if ( ret != 0x2001 ) | |
| 3090 { | |
| 3091 ptp_error(params,"unexpected return code 0x%x",ret); | |
| 3092 return 0; | |
| 3093 } | |
| 3094 | |
| 3095 f = fopen(local_fn,"wb"); | |
| 3096 if ( f == NULL ) | |
| 3097 { | |
| 3098 ptp_error(params,"could not open file \'%s\'",local_fn); | |
| 3099 free(buf); | |
| 3100 return 0; | |
| 3101 } | |
| 3102 | |
| 3103 fwrite(buf,1,ptp.Param1,f); | |
| 3104 fclose(f); | |
| 3105 | |
| 3106 free(buf); | |
| 3107 | |
| 3108 return 1; | |
| 3109 } | |
| 3110 #endif | 3757 #endif |
| 3111 | 3758 |
| 3112 uint16_t | 3759 /* |
| 3113 ptp_chdk_exec_lua(PTPParams* params, char *script, uint32_t *ret) | 3760 * Preliminary remote capture over USB code. Corresponding CHDK code is in the p
tp-remote-capture-test |
| 3114 { | 3761 * This is under development and should not be included in builds for general di
stribution |
| 3115 » uint16_t r; | 3762 */ |
| 3116 » PTPContainer ptp; | 3763 /* |
| 3117 | 3764 * isready: 0: not ready, lowest 2 bits: available image formats, 0x10000000: er
ror |
| 3118 » PTP_CNT_INIT(ptp); | 3765 */ |
| 3119 » ptp.Code=PTP_OC_CHDK; | 3766 uint16_t |
| 3120 » ptp.Nparam=1; | 3767 ptp_chdk_rcisready(PTPParams* params, int *isready, int *imgnum) |
| 3121 » ptp.Param1=PTP_CHDK_ExecuteLUA; | 3768 { |
| 3122 » r=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(script)+1, (unsi
gned char**)&script, NULL); | 3769 » PTPContainer ptp; |
| 3123 » if ( r != PTP_RC_OK ) | 3770 |
| 3124 » » return r; | 3771 » PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_RemoteCaptureIsReady); |
| 3125 » *ret = ptp.Param1; | 3772 » *isready = *imgnum = 0; |
| 3126 » return r; | 3773 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL)
); |
| 3127 } | 3774 » *isready=ptp.Param1; |
| 3128 | 3775 » *imgnum=ptp.Param2; |
| 3129 uint16_t | 3776 » return PTP_RC_OK; |
| 3130 ptp_chdk_get_script_output(PTPParams* params, char** scriptoutput) { | 3777 } |
| 3131 » PTPContainer ptp; | 3778 |
| 3132 | 3779 uint16_t |
| 3133 » PTP_CNT_INIT(ptp); | 3780 ptp_chdk_rcgetchunk(PTPParams* params, int fmt, ptp_chdk_rc_chunk *chunk) |
| 3134 » ptp.Code=PTP_OC_CHDK; | 3781 { |
| 3135 » ptp.Nparam=1; | 3782 » PTPContainer ptp; |
| 3136 » ptp.Param1=PTP_CHDK_GetScriptOutput; | 3783 |
| 3137 » return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, (unsigned char *
*)scriptoutput, NULL); | 3784 » PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_RemoteCaptureGetData, fmt); //ge
t chunk |
| 3138 } | 3785 |
| 3139 | 3786 » chunk->data = NULL; |
| 3140 #if 0 | 3787 » chunk->size = 0; |
| 3141 void ptp_chdk_opendir(char *dir, PTPParams* params, PTPDeviceInfo* deviceinfo){ | 3788 » chunk->offset = 0; |
| 3142 uint16_t ret; | 3789 » chunk->last = 0; |
| 3143 PTPContainer ptp; | 3790 » // TODO should allow ptp_getdata_transaction to send chunks directly to
file, or to mem |
| 3144 | 3791 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &chunk->da
ta, NULL)); |
| 3145 PTP_CNT_INIT(ptp); | 3792 » chunk->size = ptp.Param1; |
| 3146 ptp.Code=PTP_OC_CHDK; | 3793 » chunk->last = (ptp.Param2 == 0); |
| 3147 ptp.Nparam=1; | 3794 » chunk->offset = ptp.Param3; //-1 for none |
| 3148 ptp.Param1=PTP_CHDK_OpenDir; | 3795 » return PTP_RC_OK; |
| 3149 ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(dir)+1, (char*)&dir)
; | 3796 } |
| 3150 if ( ret != 0x2001 ) | 3797 |
| 3151 { | 3798 uint16_t |
| 3152 ptp_error(params,"unexpected return code 0x%x",ret); | 3799 ptp_chdk_exec_lua(PTPParams* params, char *script, int flags, int *script_id, in
t *status) |
| 3153 return; | 3800 { |
| 3154 } | 3801 » PTPContainer ptp; |
| 3155 } | 3802 |
| 3156 | 3803 » PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_ExecuteScript, PTP_CHDK_SL_LUA |
flags); |
| 3157 void ptp_chdk_closedir(PTPParams* params, PTPDeviceInfo* deviceinfo){ | 3804 » *script_id = 0; |
| 3158 uint16_t ret; | 3805 » *status = 0; |
| 3159 PTPContainer ptp; | 3806 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(scrip
t)+1, (unsigned char**)&script, NULL)); |
| 3160 | 3807 » *script_id = ptp.Param1; |
| 3161 PTP_CNT_INIT(ptp); | 3808 » *status = ptp.Param2; |
| 3162 ptp.Code=PTP_OC_CHDK; | 3809 » return PTP_RC_OK; |
| 3163 ptp.Nparam=1; | 3810 } |
| 3164 ptp.Param1=PTP_CHDK_CloseDir; | 3811 |
| 3165 ret=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL); | 3812 uint16_t |
| 3166 if ( ret != 0x2001 ) | 3813 ptp_chdk_get_version(PTPParams* params, int *major, int *minor) |
| 3167 { | 3814 { |
| 3168 ptp_error(params,"unexpected return code 0x%x",ret); | 3815 » PTPContainer ptp; |
| 3169 return; | 3816 |
| 3170 } | 3817 » PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_Version); |
| 3171 } | 3818 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL)
); |
| 3172 | 3819 » *major = ptp.Param1; |
| 3173 struct fileinfo* ptp_chdk_readdir(PTPParams* params, PTPDeviceInfo* deviceinfo){ | 3820 » *minor = ptp.Param2; |
| 3174 uint16_t ret; | 3821 » return PTP_RC_OK; |
| 3175 PTPContainer ptp; | 3822 } |
| 3176 char* buf=NULL; | 3823 |
| 3177 static struct fileinfo fi; | 3824 uint16_t |
| 3178 | 3825 ptp_chdk_get_script_status(PTPParams* params, unsigned *status) |
| 3179 PTP_CNT_INIT(ptp); | 3826 { |
| 3180 ptp.Code=PTP_OC_CHDK; | 3827 » PTPContainer ptp; |
| 3181 ptp.Nparam=1; | 3828 |
| 3182 ptp.Param1=PTP_CHDK_ReadDir; | 3829 » PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_ScriptStatus); |
| 3183 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &buf); | 3830 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL)
); |
| 3184 if ( ret != 0x2001 ) | 3831 » *status = ptp.Param1; |
| 3185 { | 3832 » return PTP_RC_OK; |
| 3186 ptp_error(params,"unexpected return code 0x%x",ret); | 3833 } |
| 3187 return NULL; | 3834 uint16_t |
| 3188 } | 3835 ptp_chdk_get_script_support(PTPParams* params, unsigned *status) |
| 3189 if (buf){ | 3836 { |
| 3190 memcpy(&fi, buf, sizeof(fi)); | 3837 » PTPContainer ptp; |
| 3191 free(buf); | 3838 |
| 3192 } | 3839 » PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_ScriptSupport); |
| 3193 | 3840 » CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL)
); |
| 3194 return &fi; | 3841 » *status = ptp.Param1; |
| 3195 | 3842 » return PTP_RC_OK; |
| 3196 } | 3843 } |
| 3197 | 3844 |
| 3198 void ptp_chdk_download_alt_end(PTPParams* params, PTPDeviceInfo* deviceinfo){ //
internal use | 3845 uint16_t |
| 3199 uint16_t ret; | 3846 ptp_chdk_write_script_msg(PTPParams* params, char *data, unsigned size, int targ
et_script_id, int *status) |
| 3200 PTPContainer ptp; | 3847 { |
| 3201 PTP_CNT_INIT(ptp); | 3848 » PTPContainer ptp; |
| 3202 ptp.Code=PTP_OC_CHDK; | 3849 |
| 3203 ptp.Nparam=1; | 3850 » // a zero length data phase appears to do bad things, camera stops respo
nding to PTP |
| 3204 ptp.Param1=PTP_CHDK_EndDownloadFile; | 3851 » if(!size) { |
| 3205 ret=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL); | 3852 » » ptp_error(params,"zero length message not allowed"); |
| 3206 if ( ret != 0x2001 ) ptp_error(params,"unexpected return code 0x%x",ret); | 3853 » » *status = 0; |
| 3207 } | 3854 » » return PTP_ERROR_BADPARAM; |
| 3208 | |
| 3209 int ptp_chdk_download_alt(char *remote_fn, char *local_fn, PTPParams* params, PT
PDeviceInfo* deviceinfo) | |
| 3210 { | |
| 3211 uint16_t ret; | |
| 3212 PTPContainer ptp; | |
| 3213 char *buf = NULL; | |
| 3214 FILE *f; | |
| 3215 | |
| 3216 PTP_CNT_INIT(ptp); | |
| 3217 ptp.Code=PTP_OC_CHDK; | |
| 3218 ptp.Nparam=1; | |
| 3219 ptp.Param1=PTP_CHDK_StartDownloadFile; | |
| 3220 ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(remote_fn)+1, &remot
e_fn); | |
| 3221 if ( ret != 0x2001 ) | |
| 3222 { | |
| 3223 ptp_error(params,"unexpected return code 0x%x",ret); | |
| 3224 return 0; | |
| 3225 } | |
| 3226 f = fopen(local_fn,"wb"); | |
| 3227 if ( f == NULL ) | |
| 3228 { | |
| 3229 ptp_error(params,"could not open file \'%s\'",local_fn); | |
| 3230 return 0; | |
| 3231 } | |
| 3232 | |
| 3233 while(1) { | |
| 3234 PTP_CNT_INIT(ptp); | |
| 3235 ptp.Code=PTP_OC_CHDK; | |
| 3236 ptp.Nparam=1; | |
| 3237 ptp.Param1=PTP_CHDK_ResumeDownloadFile; | |
| 3238 buf=NULL; | |
| 3239 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &buf); | |
| 3240 if ( ret != 0x2001 ) | |
| 3241 { | |
| 3242 ptp_error(params,"unexpected return code 0x%x",ret); | |
| 3243 ptp_chdk_download_alt_end(params, deviceinfo); | |
| 3244 fclose(f); | |
| 3245 return 0; | |
| 3246 } | |
| 3247 | |
| 3248 if (ptp.Param1<=0){free(buf); break;} | |
| 3249 fwrite(buf, 1, ptp.Param1, f); | |
| 3250 free(buf); | |
| 3251 } | |
| 3252 fclose(f); | |
| 3253 ptp_chdk_download_alt_end(params, deviceinfo); | |
| 3254 return 1; | |
| 3255 } | |
| 3256 #endif | |
| 3257 | |
| 3258 uint16_t | |
| 3259 ptp_chdk_get_video_settings(PTPParams* params, ptp_chdk_videosettings* vsettings
) | |
| 3260 { | |
| 3261 » uint16_t ret; | |
| 3262 » PTPContainer ptp; | |
| 3263 » unsigned char* buf=NULL; | |
| 3264 | |
| 3265 » PTP_CNT_INIT(ptp); | |
| 3266 » ptp.Code=PTP_OC_CHDK; | |
| 3267 » ptp.Nparam=1; | |
| 3268 » ptp.Param1=PTP_CHDK_GetVideoSettings; | |
| 3269 » ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &buf, NULL); | |
| 3270 » if ( ret != PTP_RC_OK ) | |
| 3271 » » return ret; | |
| 3272 » if (buf) { | |
| 3273 » » /* FIXME: endian convert */ | |
| 3274 » » memcpy(vsettings, buf, sizeof(ptp_chdk_videosettings)); | |
| 3275 » » free(buf); | |
| 3276 } | 3855 } |
| 3856 PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_WriteScriptMsg, target_script_id
); |
| 3857 *status = 0; |
| 3858 CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, (unsig
ned char**)&data, NULL)); |
| 3859 *status = ptp.Param1; |
| 3860 return PTP_RC_OK; |
| 3861 } |
| 3862 uint16_t |
| 3863 ptp_chdk_read_script_msg(PTPParams* params, ptp_chdk_script_msg **msg) |
| 3864 { |
| 3865 PTPContainer ptp; |
| 3866 unsigned char *data; |
| 3867 |
| 3868 PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_ReadScriptMsg); |
| 3869 |
| 3870 *msg = NULL; |
| 3871 |
| 3872 /* camera will always send data, otherwise getdata will cause problems *
/ |
| 3873 CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, NUL
L)); |
| 3874 |
| 3875 /* for convenience, always allocate an extra byte and null it*/ |
| 3876 *msg = malloc(sizeof(ptp_chdk_script_msg) + ptp.Param4 + 1); |
| 3877 (*msg)->type = ptp.Param1; |
| 3878 (*msg)->subtype = ptp.Param2; |
| 3879 (*msg)->script_id = ptp.Param3; |
| 3880 (*msg)->size = ptp.Param4; |
| 3881 memcpy((*msg)->data,data,(*msg)->size); |
| 3882 (*msg)->data[(*msg)->size] = 0; |
| 3883 free(data); |
| 3884 return PTP_RC_OK; |
| 3885 } |
| 3886 |
| 3887 uint16_t |
| 3888 ptp_chdk_get_live_data(PTPParams* params, unsigned flags, unsigned char **data,
unsigned int *data_size) |
| 3889 { |
| 3890 PTPContainer ptp; |
| 3891 |
| 3892 PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_GetDisplayData, flags); |
| 3893 *data_size = 0; |
| 3894 CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, NULL
)); |
| 3895 *data_size = ptp.Param1; |
| 3896 return PTP_RC_OK; |
| 3897 } |
| 3898 |
| 3899 uint16_t |
| 3900 ptp_chdk_call_function(PTPParams* params, int *args, int size, int *ret) |
| 3901 { |
| 3902 PTPContainer ptp; |
| 3903 |
| 3904 PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_CallFunction); |
| 3905 CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size*sizeof(
int), (unsigned char **) &args, NULL)); |
| 3906 if (ret) |
| 3907 *ret = ptp.Param1; |
| 3908 return PTP_RC_OK; |
| 3909 } |
| 3910 |
| 3911 |
| 3912 |
| 3913 |
| 3914 /** |
| 3915 * Android MTP Extensions |
| 3916 */ |
| 3917 |
| 3918 /** |
| 3919 * ptp_android_getpartialobject64: |
| 3920 * params: PTPParams* |
| 3921 * handle - Object handle |
| 3922 * offset - Offset into object |
| 3923 * maxbytes - Maximum of bytes to read |
| 3924 * object - pointer to data area |
| 3925 * len - pointer to returned length |
| 3926 * |
| 3927 * Get object 'handle' from device and store the data in newly |
| 3928 * allocated 'object'. Start from offset and read at most maxbytes. |
| 3929 * |
| 3930 * This is a 64bit offset version of the standard GetPartialObject. |
| 3931 * |
| 3932 * Return values: Some PTP_RC_* code. |
| 3933 **/ |
| 3934 uint16_t |
| 3935 ptp_android_getpartialobject64 (PTPParams* params, uint32_t handle, uint64_t off
set, |
| 3936 uint32_t maxbytes, unsigned char** object, |
| 3937 uint32_t *len) |
| 3938 { |
| 3939 PTPContainer ptp; |
| 3940 |
| 3941 PTP_CNT_INIT(ptp, PTP_OC_ANDROID_GetPartialObject64, handle, offset & 0x
FFFFFFFF, offset >> 32, maxbytes); |
| 3942 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, len); |
| 3943 } |
| 3944 |
| 3945 uint16_t |
| 3946 ptp_android_sendpartialobject (PTPParams* params, uint32_t handle, uint64_t offs
et, |
| 3947 unsigned char* object, uint32_t len) |
| 3948 { |
| 3949 PTPContainer ptp; |
| 3950 uint16_t ret; |
| 3951 |
| 3952 PTP_CNT_INIT(ptp, PTP_OC_ANDROID_SendPartialObject, handle, offset & 0xF
FFFFFFF, offset >> 32, len); |
| 3953 |
| 3954 /* |
| 3955 * MtpServer.cpp is buggy: it uses write() without offset |
| 3956 * rather than pwrite to send the data for data coming with |
| 3957 * the header packet |
| 3958 */ |
| 3959 params->split_header_data = 1; |
| 3960 ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, len, &object, NULL); |
| 3961 params->split_header_data = 0; |
| 3962 |
| 3277 return ret; | 3963 return ret; |
| 3278 } | 3964 } |
| 3279 | 3965 |
| 3280 | 3966 |
| 3281 | |
| 3282 /* Non PTP protocol functions */ | 3967 /* Non PTP protocol functions */ |
| 3283 /* devinfo testing functions */ | 3968 /* devinfo testing functions */ |
| 3284 | 3969 |
| 3285 int | 3970 int |
| 3286 ptp_event_issupported(PTPParams* params, uint16_t event) | 3971 ptp_event_issupported(PTPParams* params, uint16_t event) |
| 3287 { | 3972 { |
| 3288 » int i=0; | 3973 » unsigned int i=0; |
| 3289 | 3974 |
| 3290 for (;i<params->deviceinfo.EventsSupported_len;i++) { | 3975 for (;i<params->deviceinfo.EventsSupported_len;i++) { |
| 3291 if (params->deviceinfo.EventsSupported[i]==event) | 3976 if (params->deviceinfo.EventsSupported[i]==event) |
| 3292 return 1; | 3977 return 1; |
| 3293 } | 3978 } |
| 3294 return 0; | 3979 return 0; |
| 3295 } | 3980 } |
| 3296 | 3981 |
| 3297 | 3982 |
| 3298 int | 3983 int |
| 3299 ptp_property_issupported(PTPParams* params, uint16_t property) | 3984 ptp_property_issupported(PTPParams* params, uint16_t property) |
| 3300 { | 3985 { |
| 3301 » int i; | 3986 » unsigned int i; |
| 3302 | 3987 |
| 3303 for (i=0;i<params->deviceinfo.DevicePropertiesSupported_len;i++) | 3988 for (i=0;i<params->deviceinfo.DevicePropertiesSupported_len;i++) |
| 3304 if (params->deviceinfo.DevicePropertiesSupported[i]==property) | 3989 if (params->deviceinfo.DevicePropertiesSupported[i]==property) |
| 3305 return 1; | 3990 return 1; |
| 3306 return 0; | 3991 return 0; |
| 3307 } | 3992 } |
| 3308 | 3993 |
| 3309 /* ptp structures freeing functions */ | |
| 3310 void | |
| 3311 ptp_free_devicepropvalue(uint16_t dt, PTPPropertyValue* dpd) { | |
| 3312 switch (dt) { | |
| 3313 case PTP_DTC_INT8: case PTP_DTC_UINT8: | |
| 3314 case PTP_DTC_UINT16: case PTP_DTC_INT16: | |
| 3315 case PTP_DTC_UINT32: case PTP_DTC_INT32: | |
| 3316 case PTP_DTC_UINT64: case PTP_DTC_INT64: | |
| 3317 case PTP_DTC_UINT128: case PTP_DTC_INT128: | |
| 3318 /* Nothing to free */ | |
| 3319 break; | |
| 3320 case PTP_DTC_AINT8: case PTP_DTC_AUINT8: | |
| 3321 case PTP_DTC_AUINT16: case PTP_DTC_AINT16: | |
| 3322 case PTP_DTC_AUINT32: case PTP_DTC_AINT32: | |
| 3323 case PTP_DTC_AUINT64: case PTP_DTC_AINT64: | |
| 3324 case PTP_DTC_AUINT128: case PTP_DTC_AINT128: | |
| 3325 if (dpd->a.v) | |
| 3326 free(dpd->a.v); | |
| 3327 break; | |
| 3328 case PTP_DTC_STR: | |
| 3329 if (dpd->str) | |
| 3330 free(dpd->str); | |
| 3331 break; | |
| 3332 } | |
| 3333 } | |
| 3334 | |
| 3335 void | |
| 3336 ptp_free_devicepropdesc(PTPDevicePropDesc* dpd) | |
| 3337 { | |
| 3338 uint16_t i; | |
| 3339 | |
| 3340 ptp_free_devicepropvalue (dpd->DataType, &dpd->FactoryDefaultValue); | |
| 3341 ptp_free_devicepropvalue (dpd->DataType, &dpd->CurrentValue); | |
| 3342 switch (dpd->FormFlag) { | |
| 3343 case PTP_DPFF_Range: | |
| 3344 ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.Minimu
mValue); | |
| 3345 ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.Maximu
mValue); | |
| 3346 ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.StepSi
ze); | |
| 3347 break; | |
| 3348 case PTP_DPFF_Enumeration: | |
| 3349 if (dpd->FORM.Enum.SupportedValue) { | |
| 3350 for (i=0;i<dpd->FORM.Enum.NumberOfValues;i++) | |
| 3351 ptp_free_devicepropvalue (dpd->DataType, dpd->FO
RM.Enum.SupportedValue+i); | |
| 3352 free (dpd->FORM.Enum.SupportedValue); | |
| 3353 } | |
| 3354 } | |
| 3355 } | |
| 3356 | |
| 3357 void | |
| 3358 ptp_free_objectpropdesc(PTPObjectPropDesc* opd) | |
| 3359 { | |
| 3360 uint16_t i; | |
| 3361 | |
| 3362 ptp_free_devicepropvalue (opd->DataType, &opd->FactoryDefaultValue); | |
| 3363 switch (opd->FormFlag) { | |
| 3364 case PTP_OPFF_None: | |
| 3365 break; | |
| 3366 case PTP_OPFF_Range: | |
| 3367 ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.Minimu
mValue); | |
| 3368 ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.Maximu
mValue); | |
| 3369 ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.StepSi
ze); | |
| 3370 break; | |
| 3371 case PTP_OPFF_Enumeration: | |
| 3372 if (opd->FORM.Enum.SupportedValue) { | |
| 3373 for (i=0;i<opd->FORM.Enum.NumberOfValues;i++) | |
| 3374 ptp_free_devicepropvalue (opd->DataType, opd->FO
RM.Enum.SupportedValue+i); | |
| 3375 free (opd->FORM.Enum.SupportedValue); | |
| 3376 } | |
| 3377 break; | |
| 3378 case PTP_OPFF_DateTime: | |
| 3379 case PTP_OPFF_FixedLengthArray: | |
| 3380 case PTP_OPFF_RegularExpression: | |
| 3381 case PTP_OPFF_ByteArray: | |
| 3382 case PTP_OPFF_LongString: | |
| 3383 /* Ignore these presently, we cannot unpack them, so there is no
thing to be freed. */ | |
| 3384 break; | |
| 3385 default: | |
| 3386 fprintf (stderr, "Unknown OPFF type %d\n", opd->FormFlag); | |
| 3387 break; | |
| 3388 } | |
| 3389 } | |
| 3390 | |
| 3391 void | 3994 void |
| 3392 ptp_free_objectinfo (PTPObjectInfo *oi) | 3995 ptp_free_objectinfo (PTPObjectInfo *oi) |
| 3393 { | 3996 { |
| 3394 if (!oi) return; | 3997 if (!oi) return; |
| 3395 free (oi->Filename); oi->Filename = NULL; | 3998 free (oi->Filename); oi->Filename = NULL; |
| 3396 free (oi->Keywords); oi->Keywords = NULL; | 3999 free (oi->Keywords); oi->Keywords = NULL; |
| 3397 } | 4000 } |
| 3398 | 4001 |
| 3399 void | 4002 void |
| 3400 ptp_free_object (PTPObject *ob) | 4003 ptp_free_object (PTPObject *ob) |
| 3401 { | 4004 { |
| 3402 » int i; | 4005 » unsigned int i; |
| 3403 if (!ob) return; | 4006 if (!ob) return; |
| 3404 | 4007 |
| 3405 ptp_free_objectinfo (&ob->oi); | 4008 ptp_free_objectinfo (&ob->oi); |
| 3406 for (i=0;i<ob->nrofmtpprops;i++) | 4009 for (i=0;i<ob->nrofmtpprops;i++) |
| 3407 ptp_destroy_object_prop(&ob->mtpprops[i]); | 4010 ptp_destroy_object_prop(&ob->mtpprops[i]); |
| 3408 ob->flags = 0; | 4011 ob->flags = 0; |
| 3409 } | 4012 } |
| 3410 | 4013 |
| 3411 const char * | 4014 /* PTP error descriptions */ |
| 3412 ptp_strerror(uint16_t error) { | 4015 static struct { |
| 4016 » uint16_t rc; |
| 4017 » uint16_t vendor; |
| 4018 » const char *txt; |
| 4019 } ptp_errors[] = { |
| 4020 » {PTP_RC_Undefined,» » 0, N_("PTP Undefined Error")}, |
| 4021 » {PTP_RC_OK,» » » 0, N_("PTP OK!")}, |
| 4022 » {PTP_RC_GeneralError,» » 0, N_("PTP General Error")}, |
| 4023 » {PTP_RC_SessionNotOpen,»» 0, N_("PTP Session Not Open")}, |
| 4024 » {PTP_RC_InvalidTransactionID,» 0, N_("PTP Invalid Transaction ID")}, |
| 4025 » {PTP_RC_OperationNotSupported,» 0, N_("PTP Operation Not Supported")}, |
| 4026 » {PTP_RC_ParameterNotSupported,» 0, N_("PTP Parameter Not Supported")}, |
| 4027 » {PTP_RC_IncompleteTransfer,» 0, N_("PTP Incomplete Transfer")}, |
| 4028 » {PTP_RC_InvalidStorageId,» 0, N_("PTP Invalid Storage ID")}, |
| 4029 » {PTP_RC_InvalidObjectHandle,» 0, N_("PTP Invalid Object Handle")}, |
| 4030 » {PTP_RC_DevicePropNotSupported,»0, N_("PTP Device Prop Not Supported")}, |
| 4031 » {PTP_RC_InvalidObjectFormatCode,0, N_("PTP Invalid Object Format Code")}
, |
| 4032 » {PTP_RC_StoreFull,» » 0, N_("PTP Store Full")}, |
| 4033 » {PTP_RC_ObjectWriteProtected,» 0, N_("PTP Object Write Protected")}, |
| 4034 » {PTP_RC_StoreReadOnly,» » 0, N_("PTP Store Read Only")}, |
| 4035 » {PTP_RC_AccessDenied,» » 0, N_("PTP Access Denied")}, |
| 4036 » {PTP_RC_NoThumbnailPresent,» 0, N_("PTP No Thumbnail Present")}, |
| 4037 » {PTP_RC_SelfTestFailed,»» 0, N_("PTP Self Test Failed")}, |
| 4038 » {PTP_RC_PartialDeletion,» 0, N_("PTP Partial Deletion")}, |
| 4039 » {PTP_RC_StoreNotAvailable,» 0, N_("PTP Store Not Available")}, |
| 4040 » {PTP_RC_SpecificationByFormatUnsupported, 0, N_("PTP Specification By Fo
rmat Unsupported")}, |
| 4041 » {PTP_RC_NoValidObjectInfo,» 0, N_("PTP No Valid Object Info")}, |
| 4042 » {PTP_RC_InvalidCodeFormat,» 0, N_("PTP Invalid Code Format")}, |
| 4043 » {PTP_RC_UnknownVendorCode,» 0, N_("PTP Unknown Vendor Code")}, |
| 4044 » {PTP_RC_CaptureAlreadyTerminated, 0, N_("PTP Capture Already Terminated"
)}, |
| 4045 » {PTP_RC_DeviceBusy,» » 0, N_("PTP Device Busy")}, |
| 4046 » {PTP_RC_InvalidParentObject,» 0, N_("PTP Invalid Parent Object")}, |
| 4047 » {PTP_RC_InvalidDevicePropFormat,0, N_("PTP Invalid Device Prop Format")}
, |
| 4048 » {PTP_RC_InvalidDevicePropValue,»0, N_("PTP Invalid Device Prop Value")}, |
| 4049 » {PTP_RC_InvalidParameter,» 0, N_("PTP Invalid Parameter")}, |
| 4050 » {PTP_RC_SessionAlreadyOpened,» 0, N_("PTP Session Already Opened")}, |
| 4051 » {PTP_RC_TransactionCanceled,» 0, N_("PTP Transaction Canceled")}, |
| 4052 » {PTP_RC_SpecificationOfDestinationUnsupported, 0, N_("PTP Specification
Of Destination Unsupported")}, |
| 3413 | 4053 |
| 3414 » int i; | 4054 » {PTP_RC_EK_FilenameRequired,» PTP_VENDOR_EASTMAN_KODAK, N_("Filename R
equired")}, |
| 3415 » /* PTP error descriptions */ | 4055 » {PTP_RC_EK_FilenameConflicts,» PTP_VENDOR_EASTMAN_KODAK, N_("Filename C
onflicts")}, |
| 3416 » static struct { | 4056 » {PTP_RC_EK_FilenameInvalid,» PTP_VENDOR_EASTMAN_KODAK, N_("Filename I
nvalid")}, |
| 3417 » » short n; | |
| 3418 » » const char *txt; | |
| 3419 » } ptp_errors[] = { | |
| 3420 » {PTP_RC_Undefined, » » N_("PTP: Undefined Error")}, | |
| 3421 » {PTP_RC_OK, » » » N_("PTP: OK!")}, | |
| 3422 » {PTP_RC_GeneralError, » » N_("PTP: General Error")}, | |
| 3423 » {PTP_RC_SessionNotOpen, » N_("PTP: Session Not Open")}, | |
| 3424 » {PTP_RC_InvalidTransactionID, » N_("PTP: Invalid Transaction ID")}, | |
| 3425 » {PTP_RC_OperationNotSupported, »N_("PTP: Operation Not Supported")}, | |
| 3426 » {PTP_RC_ParameterNotSupported, »N_("PTP: Parameter Not Supported")}, | |
| 3427 » {PTP_RC_IncompleteTransfer, » N_("PTP: Incomplete Transfer")}, | |
| 3428 » {PTP_RC_InvalidStorageId, » N_("PTP: Invalid Storage ID")}, | |
| 3429 » {PTP_RC_InvalidObjectHandle, » N_("PTP: Invalid Object Handle")}, | |
| 3430 » {PTP_RC_DevicePropNotSupported, N_("PTP: Device Prop Not Supported")}, | |
| 3431 » {PTP_RC_InvalidObjectFormatCode, N_("PTP: Invalid Object Format Code")}, | |
| 3432 » {PTP_RC_StoreFull, » » N_("PTP: Store Full")}, | |
| 3433 » {PTP_RC_ObjectWriteProtected, » N_("PTP: Object Write Protected")}, | |
| 3434 » {PTP_RC_StoreReadOnly, »» N_("PTP: Store Read Only")}, | |
| 3435 » {PTP_RC_AccessDenied,» » N_("PTP: Access Denied")}, | |
| 3436 » {PTP_RC_NoThumbnailPresent, » N_("PTP: No Thumbnail Present")}, | |
| 3437 » {PTP_RC_SelfTestFailed, » N_("PTP: Self Test Failed")}, | |
| 3438 » {PTP_RC_PartialDeletion, » N_("PTP: Partial Deletion")}, | |
| 3439 » {PTP_RC_StoreNotAvailable, » N_("PTP: Store Not Available")}, | |
| 3440 » {PTP_RC_SpecificationByFormatUnsupported, | |
| 3441 » » » » N_("PTP: Specification By Format Unsupported")}, | |
| 3442 » {PTP_RC_NoValidObjectInfo, » N_("PTP: No Valid Object Info")}, | |
| 3443 » {PTP_RC_InvalidCodeFormat, » N_("PTP: Invalid Code Format")}, | |
| 3444 » {PTP_RC_UnknownVendorCode, » N_("PTP: Unknown Vendor Code")}, | |
| 3445 » {PTP_RC_CaptureAlreadyTerminated, | |
| 3446 » » » » » N_("PTP: Capture Already Terminated")}, | |
| 3447 » {PTP_RC_DeviceBusy, » » N_("PTP: Device Busy")}, | |
| 3448 » {PTP_RC_InvalidParentObject, » N_("PTP: Invalid Parent Object")}, | |
| 3449 » {PTP_RC_InvalidDevicePropFormat, N_("PTP: Invalid Device Prop Format")}, | |
| 3450 » {PTP_RC_InvalidDevicePropValue, N_("PTP: Invalid Device Prop Value")}, | |
| 3451 » {PTP_RC_InvalidParameter, » N_("PTP: Invalid Parameter")}, | |
| 3452 » {PTP_RC_SessionAlreadyOpened, » N_("PTP: Session Already Opened")}, | |
| 3453 » {PTP_RC_TransactionCanceled, » N_("PTP: Transaction Canceled")}, | |
| 3454 » {PTP_RC_SpecificationOfDestinationUnsupported, | |
| 3455 » » » N_("PTP: Specification Of Destination Unsupported")}, | |
| 3456 » {PTP_RC_EK_FilenameRequired,» N_("PTP: EK Filename Required")}, | |
| 3457 » {PTP_RC_EK_FilenameConflicts,» N_("PTP: EK Filename Conflicts")}, | |
| 3458 » {PTP_RC_EK_FilenameInvalid,» N_("PTP: EK Filename Invalid")}, | |
| 3459 | 4057 |
| 3460 » {PTP_ERROR_IO,» » N_("PTP: I/O error")}, | 4058 » {PTP_RC_NIKON_HardwareError,» » PTP_VENDOR_NIKON, N_("Hardware E
rror")}, |
| 3461 » {PTP_ERROR_BADPARAM,» N_("PTP: Error: bad parameter")}, | 4059 » {PTP_RC_NIKON_OutOfFocus,» » PTP_VENDOR_NIKON, N_("Out of Foc
us")}, |
| 3462 » {PTP_ERROR_DATA_EXPECTED, N_("PTP: Protocol error, data expected")}, | 4060 » {PTP_RC_NIKON_ChangeCameraModeFailed,» PTP_VENDOR_NIKON, N_("Change Cam
era Mode Failed")}, |
| 3463 » {PTP_ERROR_RESP_EXPECTED, N_("PTP: Protocol error, response expected")}, | 4061 » {PTP_RC_NIKON_InvalidStatus,» » PTP_VENDOR_NIKON, N_("Invalid St
atus")}, |
| 3464 » {0, NULL} | 4062 » {PTP_RC_NIKON_SetPropertyNotSupported,» PTP_VENDOR_NIKON, N_("Set Proper
ty Not Supported")}, |
| 4063 » {PTP_RC_NIKON_WbResetError,» » PTP_VENDOR_NIKON, N_("Whitebalan
ce Reset Error")}, |
| 4064 » {PTP_RC_NIKON_DustReferenceError,» PTP_VENDOR_NIKON, N_("Dust Refer
ence Error")}, |
| 4065 » {PTP_RC_NIKON_ShutterSpeedBulb,»» PTP_VENDOR_NIKON, N_("Shutter Sp
eed Bulb")}, |
| 4066 » {PTP_RC_NIKON_MirrorUpSequence,»» PTP_VENDOR_NIKON, N_("Mirror Up
Sequence")}, |
| 4067 » {PTP_RC_NIKON_CameraModeNotAdjustFNumber, PTP_VENDOR_NIKON, N_("Camera M
ode Not Adjust FNumber")}, |
| 4068 » {PTP_RC_NIKON_NotLiveView,» » PTP_VENDOR_NIKON, N_("Not in Liv
eview")}, |
| 4069 » {PTP_RC_NIKON_MfDriveStepEnd,» » PTP_VENDOR_NIKON, N_("Mf Drive S
tep End")}, |
| 4070 » {PTP_RC_NIKON_MfDriveStepInsufficiency,»PTP_VENDOR_NIKON, N_("Mf Drive S
tep Insufficiency")}, |
| 4071 » {PTP_RC_NIKON_AdvancedTransferCancel,» PTP_VENDOR_NIKON, N_("Advanced T
ransfer Cancel")}, |
| 4072 |
| 4073 » {PTP_RC_CANON_UNKNOWN_COMMAND,» PTP_VENDOR_CANON, N_("Unknown Command")}
, |
| 4074 » {PTP_RC_CANON_OPERATION_REFUSED,PTP_VENDOR_CANON, N_("Operation Refused"
)}, |
| 4075 » {PTP_RC_CANON_LENS_COVER,» PTP_VENDOR_CANON, N_("Lens Cover Present
")}, |
| 4076 » {PTP_RC_CANON_BATTERY_LOW,» PTP_VENDOR_CANON, N_("Battery Low")}, |
| 4077 » {PTP_RC_CANON_NOT_READY,» PTP_VENDOR_CANON, N_("Camera Not Ready")
}, |
| 4078 |
| 4079 » {PTP_ERROR_TIMEOUT,» » 0, N_("PTP Timeout")}, |
| 4080 » {PTP_ERROR_CANCEL,» » 0, N_("PTP Cancel Request")}, |
| 4081 » {PTP_ERROR_BADPARAM,» » 0, N_("PTP Invalid Parameter")}, |
| 4082 » {PTP_ERROR_RESP_EXPECTED,» 0, N_("PTP Response Expected")}, |
| 4083 » {PTP_ERROR_DATA_EXPECTED,» 0, N_("PTP Data Expected")}, |
| 4084 » {PTP_ERROR_IO,» » » 0, N_("PTP I/O Error")}, |
| 4085 » {0, 0, NULL} |
| 3465 }; | 4086 }; |
| 3466 | 4087 |
| 3467 » for (i=0; ptp_errors[i].txt!=NULL; i++) | 4088 const char * |
| 3468 » » if (ptp_errors[i].n == error) | 4089 ptp_strerror(uint16_t ret, uint16_t vendor) |
| 4090 { |
| 4091 » int i; |
| 4092 |
| 4093 » for (i=0; ptp_errors[i].txt != NULL; i++) |
| 4094 » » if ((ptp_errors[i].rc == ret) && ((ptp_errors[i].vendor == 0) ||
(ptp_errors[i].vendor == vendor))) |
| 3469 return ptp_errors[i].txt; | 4095 return ptp_errors[i].txt; |
| 3470 return NULL; | 4096 return NULL; |
| 3471 } | 4097 } |
| 3472 | 4098 |
| 3473 void | |
| 3474 ptp_perror(PTPParams* params, uint16_t error) { | |
| 3475 const char *txt = ptp_strerror(error); | |
| 3476 if (txt != NULL) | |
| 3477 ptp_error(params, txt); | |
| 3478 } | |
| 3479 | |
| 3480 const char* | 4099 const char* |
| 3481 ptp_get_property_description(PTPParams* params, uint16_t dpc) | 4100 ptp_get_property_description(PTPParams* params, uint16_t dpc) |
| 3482 { | 4101 { |
| 3483 int i; | 4102 int i; |
| 3484 /* Device Property descriptions */ | 4103 /* Device Property descriptions */ |
| 3485 struct { | 4104 struct { |
| 3486 uint16_t dpc; | 4105 uint16_t dpc; |
| 3487 const char *txt; | 4106 const char *txt; |
| 3488 } ptp_device_properties[] = { | 4107 } ptp_device_properties[] = { |
| 3489 {PTP_DPC_Undefined, N_("Undefined PTP Property")}, | 4108 {PTP_DPC_Undefined, N_("Undefined PTP Property")}, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3513 {PTP_DPC_DigitalZoom, N_("Digital Zoom")}, | 4132 {PTP_DPC_DigitalZoom, N_("Digital Zoom")}, |
| 3514 {PTP_DPC_EffectMode, N_("Effect Mode")}, | 4133 {PTP_DPC_EffectMode, N_("Effect Mode")}, |
| 3515 {PTP_DPC_BurstNumber, N_("Burst Number")}, | 4134 {PTP_DPC_BurstNumber, N_("Burst Number")}, |
| 3516 {PTP_DPC_BurstInterval, N_("Burst Interval")}, | 4135 {PTP_DPC_BurstInterval, N_("Burst Interval")}, |
| 3517 {PTP_DPC_TimelapseNumber, N_("Timelapse Number")}, | 4136 {PTP_DPC_TimelapseNumber, N_("Timelapse Number")}, |
| 3518 {PTP_DPC_TimelapseInterval, N_("Timelapse Interval")}, | 4137 {PTP_DPC_TimelapseInterval, N_("Timelapse Interval")}, |
| 3519 {PTP_DPC_FocusMeteringMode, N_("Focus Metering Mode")}, | 4138 {PTP_DPC_FocusMeteringMode, N_("Focus Metering Mode")}, |
| 3520 {PTP_DPC_UploadURL, N_("Upload URL")}, | 4139 {PTP_DPC_UploadURL, N_("Upload URL")}, |
| 3521 {PTP_DPC_Artist, N_("Artist")}, | 4140 {PTP_DPC_Artist, N_("Artist")}, |
| 3522 {PTP_DPC_CopyrightInfo, N_("Copyright Info")}, | 4141 {PTP_DPC_CopyrightInfo, N_("Copyright Info")}, |
| 4142 {PTP_DPC_SupportedStreams, N_("Supported Streams")}, |
| 4143 {PTP_DPC_EnabledStreams, N_("Enabled Streams")}, |
| 4144 {PTP_DPC_VideoFormat, N_("Video Format")}, |
| 4145 {PTP_DPC_VideoResolution, N_("Video Resolution")}, |
| 4146 {PTP_DPC_VideoQuality, N_("Video Quality")}, |
| 4147 {PTP_DPC_VideoFrameRate, N_("Video Framerate")}, |
| 4148 {PTP_DPC_VideoContrast, N_("Video Contrast")}, |
| 4149 {PTP_DPC_VideoBrightness, N_("Video Brightness")}, |
| 4150 {PTP_DPC_AudioFormat, N_("Audio Format")}, |
| 4151 {PTP_DPC_AudioBitrate, N_("Audio Bitrate")}, |
| 4152 {PTP_DPC_AudioSamplingRate, N_("Audio Samplingrate")}, |
| 4153 {PTP_DPC_AudioBitPerSample, N_("Audio Bits per sample")}, |
| 4154 {PTP_DPC_AudioVolume, N_("Audio Volume")}, |
| 3523 {0,NULL} | 4155 {0,NULL} |
| 3524 }; | 4156 }; |
| 3525 struct { | 4157 struct { |
| 3526 uint16_t dpc; | 4158 uint16_t dpc; |
| 3527 const char *txt; | 4159 const char *txt; |
| 3528 } ptp_device_properties_EK[] = { | 4160 } ptp_device_properties_EK[] = { |
| 3529 {PTP_DPC_EK_ColorTemperature, N_("Color Temperature")}, | 4161 {PTP_DPC_EK_ColorTemperature, N_("Color Temperature")}, |
| 3530 {PTP_DPC_EK_DateTimeStampFormat, | 4162 {PTP_DPC_EK_DateTimeStampFormat, |
| 3531 N_("Date Time Stamp Format")}, | 4163 N_("Date Time Stamp Format")}, |
| 3532 {PTP_DPC_EK_BeepMode, N_("Beep Mode")}, | 4164 {PTP_DPC_EK_BeepMode, N_("Beep Mode")}, |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3684 {PTP_DPC_NIKON_NonCPULensDataMaximumAperture, /* 0xD02f */ | 4316 {PTP_DPC_NIKON_NonCPULensDataMaximumAperture, /* 0xD02f */ |
| 3685 N_("Lens Maximum Aperture (Non CPU)")}, | 4317 N_("Lens Maximum Aperture (Non CPU)")}, |
| 3686 {PTP_DPC_NIKON_ShootingMode, /* 0xD030 */ | 4318 {PTP_DPC_NIKON_ShootingMode, /* 0xD030 */ |
| 3687 N_("Shooting Mode")}, | 4319 N_("Shooting Mode")}, |
| 3688 {PTP_DPC_NIKON_JPEG_Compression_Policy, /* 0xD031 */ | 4320 {PTP_DPC_NIKON_JPEG_Compression_Policy, /* 0xD031 */ |
| 3689 N_("JPEG Compression Policy")}, | 4321 N_("JPEG Compression Policy")}, |
| 3690 {PTP_DPC_NIKON_ColorSpace, /* 0xD032 */ | 4322 {PTP_DPC_NIKON_ColorSpace, /* 0xD032 */ |
| 3691 N_("Color Space")}, | 4323 N_("Color Space")}, |
| 3692 {PTP_DPC_NIKON_AutoDXCrop, /* 0xD033 */ | 4324 {PTP_DPC_NIKON_AutoDXCrop, /* 0xD033 */ |
| 3693 N_("Auto DX Crop")}, | 4325 N_("Auto DX Crop")}, |
| 4326 {PTP_DPC_NIKON_FlickerReduction, /* 0xD034 */ |
| 4327 N_("Flicker Reduction")}, |
| 4328 {PTP_DPC_NIKON_RemoteMode, /* 0xD035 */ |
| 4329 N_("Remote Mode")}, |
| 4330 {PTP_DPC_NIKON_VideoMode, /* 0xD036 */ |
| 4331 N_("Video Mode")}, |
| 4332 {PTP_DPC_NIKON_EffectMode, /* 0xD037 */ |
| 4333 N_("Effect Mode")}, |
| 3694 {PTP_DPC_NIKON_CSMMenuBankSelect, /* 0xD040 */ | 4334 {PTP_DPC_NIKON_CSMMenuBankSelect, /* 0xD040 */ |
| 3695 "PTP_DPC_NIKON_CSMMenuBankSelect"}, | 4335 "PTP_DPC_NIKON_CSMMenuBankSelect"}, |
| 3696 {PTP_DPC_NIKON_MenuBankNameA, /* 0xD041 */ | 4336 {PTP_DPC_NIKON_MenuBankNameA, /* 0xD041 */ |
| 3697 N_("Menu Bank Name A")}, | 4337 N_("Menu Bank Name A")}, |
| 3698 {PTP_DPC_NIKON_MenuBankNameB, /* 0xD042 */ | 4338 {PTP_DPC_NIKON_MenuBankNameB, /* 0xD042 */ |
| 3699 N_("Menu Bank Name B")}, | 4339 N_("Menu Bank Name B")}, |
| 3700 {PTP_DPC_NIKON_MenuBankNameC, /* 0xD043 */ | 4340 {PTP_DPC_NIKON_MenuBankNameC, /* 0xD043 */ |
| 3701 N_("Menu Bank Name C")}, | 4341 N_("Menu Bank Name C")}, |
| 3702 {PTP_DPC_NIKON_MenuBankNameD, /* 0xD044 */ | 4342 {PTP_DPC_NIKON_MenuBankNameD, /* 0xD044 */ |
| 3703 N_("Menu Bank Name D")}, | 4343 N_("Menu Bank Name D")}, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3829 {PTP_DPC_NIKON_NoCFCard, /* 0xD08A */ | 4469 {PTP_DPC_NIKON_NoCFCard, /* 0xD08A */ |
| 3830 N_("No CF Card Release")}, | 4470 N_("No CF Card Release")}, |
| 3831 {PTP_DPC_NIKON_CenterButtonZoomRatio, /* 0xD08B */ | 4471 {PTP_DPC_NIKON_CenterButtonZoomRatio, /* 0xD08B */ |
| 3832 N_("Center Button Zoom Ratio")}, | 4472 N_("Center Button Zoom Ratio")}, |
| 3833 {PTP_DPC_NIKON_FunctionButton2, /* 0xD08C */ | 4473 {PTP_DPC_NIKON_FunctionButton2, /* 0xD08C */ |
| 3834 N_("Function Button 2")}, | 4474 N_("Function Button 2")}, |
| 3835 {PTP_DPC_NIKON_AFAreaPoint, /* 0xD08D */ | 4475 {PTP_DPC_NIKON_AFAreaPoint, /* 0xD08D */ |
| 3836 N_("AF Area Point")}, | 4476 N_("AF Area Point")}, |
| 3837 {PTP_DPC_NIKON_NormalAFOn, /* 0xD08E */ | 4477 {PTP_DPC_NIKON_NormalAFOn, /* 0xD08E */ |
| 3838 N_("Normal AF On")}, | 4478 N_("Normal AF On")}, |
| 4479 {PTP_DPC_NIKON_CleanImageSensor, /* 0xD08F */ |
| 4480 N_("Clean Image Sensor")}, |
| 3839 {PTP_DPC_NIKON_ImageCommentString, /* 0xD090 */ | 4481 {PTP_DPC_NIKON_ImageCommentString, /* 0xD090 */ |
| 3840 N_("Image Comment String")}, | 4482 N_("Image Comment String")}, |
| 3841 {PTP_DPC_NIKON_ImageCommentEnable, /* 0xD091 */ | 4483 {PTP_DPC_NIKON_ImageCommentEnable, /* 0xD091 */ |
| 3842 N_("Image Comment Enable")}, | 4484 N_("Image Comment Enable")}, |
| 3843 {PTP_DPC_NIKON_ImageRotation, /* 0xD092 */ | 4485 {PTP_DPC_NIKON_ImageRotation, /* 0xD092 */ |
| 3844 N_("Image Rotation")}, | 4486 N_("Image Rotation")}, |
| 3845 {PTP_DPC_NIKON_ManualSetLensNo, /* 0xD093 */ | 4487 {PTP_DPC_NIKON_ManualSetLensNo, /* 0xD093 */ |
| 3846 N_("Manual Set Lens Number")}, | 4488 N_("Manual Set Lens Number")}, |
| 3847 {PTP_DPC_NIKON_MovScreenSize, /* 0xD0A0 */ | 4489 {PTP_DPC_NIKON_MovScreenSize, /* 0xD0A0 */ |
| 3848 N_("Movie Screen Size")}, | 4490 N_("Movie Screen Size")}, |
| 3849 {PTP_DPC_NIKON_MovVoice, /* 0xD0A1 */ | 4491 {PTP_DPC_NIKON_MovVoice, /* 0xD0A1 */ |
| 3850 N_("Movie Voice")}, | 4492 N_("Movie Voice")}, |
| 4493 {PTP_DPC_NIKON_MovMicrophone, /* 0xD0A2 */ |
| 4494 N_("Movie Microphone")}, |
| 4495 {PTP_DPC_NIKON_MovFileSlot, /* 0xD0A3 */ |
| 4496 N_("Movie Card Slot")}, |
| 4497 {PTP_DPC_NIKON_ManualMovieSetting, /* 0xD0A6 */ |
| 4498 N_("Manual Movie Setting")}, |
| 4499 {PTP_DPC_NIKON_MovQuality, /* 0xD0A7 */ |
| 4500 N_("Movie Quality")}, |
| 4501 {PTP_DPC_NIKON_MonitorOffDelay, /* 0xD0B3 */ |
| 4502 N_("Monitor Off Delay")}, |
| 3851 {PTP_DPC_NIKON_Bracketing, /* 0xD0C0 */ | 4503 {PTP_DPC_NIKON_Bracketing, /* 0xD0C0 */ |
| 3852 N_("Bracketing Enable")}, | 4504 N_("Bracketing Enable")}, |
| 3853 {PTP_DPC_NIKON_AutoExposureBracketStep, /* 0xD0C1 */ | 4505 {PTP_DPC_NIKON_AutoExposureBracketStep, /* 0xD0C1 */ |
| 3854 N_("Exposure Bracketing Step")}, | 4506 N_("Exposure Bracketing Step")}, |
| 3855 {PTP_DPC_NIKON_AutoExposureBracketProgram, /* 0xD0C2 */ | 4507 {PTP_DPC_NIKON_AutoExposureBracketProgram, /* 0xD0C2 */ |
| 3856 N_("Exposure Bracketing Program")}, | 4508 N_("Exposure Bracketing Program")}, |
| 3857 {PTP_DPC_NIKON_AutoExposureBracketCount, /* 0xD0C3 */ | 4509 {PTP_DPC_NIKON_AutoExposureBracketCount, /* 0xD0C3 */ |
| 3858 N_("Auto Exposure Bracket Count")}, | 4510 N_("Auto Exposure Bracket Count")}, |
| 3859 {PTP_DPC_NIKON_WhiteBalanceBracketStep, N_("White Balance Bracke
t Step")}, /* 0xD0C4 */ | 4511 {PTP_DPC_NIKON_WhiteBalanceBracketStep, N_("White Balance Bracke
t Step")}, /* 0xD0C4 */ |
| 3860 {PTP_DPC_NIKON_WhiteBalanceBracketProgram, N_("White Balance Bra
cket Program")}, /* 0xD0C5 */ | 4512 {PTP_DPC_NIKON_WhiteBalanceBracketProgram, N_("White Balance Bra
cket Program")}, /* 0xD0C5 */ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3879 {PTP_DPC_NIKON_AutoOffMenu, /* 0xD0F3 */ | 4531 {PTP_DPC_NIKON_AutoOffMenu, /* 0xD0F3 */ |
| 3880 N_("Auto Off Menu")}, | 4532 N_("Auto Off Menu")}, |
| 3881 {PTP_DPC_NIKON_AutoOffInfo, /* 0xD0F4 */ | 4533 {PTP_DPC_NIKON_AutoOffInfo, /* 0xD0F4 */ |
| 3882 N_("Auto Off Info")}, | 4534 N_("Auto Off Info")}, |
| 3883 {PTP_DPC_NIKON_SelfTimerShootNum, /* 0xD0F5 */ | 4535 {PTP_DPC_NIKON_SelfTimerShootNum, /* 0xD0F5 */ |
| 3884 N_("Self Timer Shot Number")}, | 4536 N_("Self Timer Shot Number")}, |
| 3885 {PTP_DPC_NIKON_VignetteCtrl, /* 0xD0F7 */ | 4537 {PTP_DPC_NIKON_VignetteCtrl, /* 0xD0F7 */ |
| 3886 N_("Vignette Control")}, | 4538 N_("Vignette Control")}, |
| 3887 {PTP_DPC_NIKON_AutoDistortionControl, /* 0xD0F8 */ | 4539 {PTP_DPC_NIKON_AutoDistortionControl, /* 0xD0F8 */ |
| 3888 N_("Auto Distortion Control")}, | 4540 N_("Auto Distortion Control")}, |
| 4541 {PTP_DPC_NIKON_SceneMode, /* 0xD0F9 */ |
| 4542 N_("Scene Mode")}, |
| 3889 {PTP_DPC_NIKON_ExposureTime, /* 0xD100 */ | 4543 {PTP_DPC_NIKON_ExposureTime, /* 0xD100 */ |
| 3890 N_("Nikon Exposure Time")}, | 4544 N_("Nikon Exposure Time")}, |
| 3891 {PTP_DPC_NIKON_ACPower, N_("AC Power")}, /* 0xD101 */ | 4545 {PTP_DPC_NIKON_ACPower, N_("AC Power")}, /* 0xD101 */ |
| 3892 {PTP_DPC_NIKON_WarningStatus, N_("Warning Status")},/* 0xD102 */ | 4546 {PTP_DPC_NIKON_WarningStatus, N_("Warning Status")},/* 0xD102 */ |
| 3893 {PTP_DPC_NIKON_MaximumShots, /* 0xD103 */ | 4547 {PTP_DPC_NIKON_MaximumShots, /* 0xD103 */ |
| 3894 N_("Maximum Shots")}, | 4548 N_("Maximum Shots")}, |
| 3895 {PTP_DPC_NIKON_AFLockStatus, N_("AF Locked")},/* 0xD104 */ | 4549 {PTP_DPC_NIKON_AFLockStatus, N_("AF Locked")},/* 0xD104 */ |
| 3896 {PTP_DPC_NIKON_AELockStatus, N_("AE Locked")},/* 0xD105 */ | 4550 {PTP_DPC_NIKON_AELockStatus, N_("AE Locked")},/* 0xD105 */ |
| 3897 {PTP_DPC_NIKON_FVLockStatus, N_("FV Locked")},/* 0xD106 */ | 4551 {PTP_DPC_NIKON_FVLockStatus, N_("FV Locked")},/* 0xD106 */ |
| 3898 {PTP_DPC_NIKON_AutofocusLCDTopMode2, /* 0xD107 */ | 4552 {PTP_DPC_NIKON_AutofocusLCDTopMode2, /* 0xD107 */ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3954 {PTP_DPC_NIKON_BW_Sharpness, /* 0xD144 */ | 4608 {PTP_DPC_NIKON_BW_Sharpness, /* 0xD144 */ |
| 3955 N_("BW Sharpness")}, | 4609 N_("BW Sharpness")}, |
| 3956 {PTP_DPC_NIKON_BW_Contrast, /* 0xD145 */ | 4610 {PTP_DPC_NIKON_BW_Contrast, /* 0xD145 */ |
| 3957 N_("BW Contrast")}, | 4611 N_("BW Contrast")}, |
| 3958 {PTP_DPC_NIKON_BW_Setting_Type, /* 0xD146 */ | 4612 {PTP_DPC_NIKON_BW_Setting_Type, /* 0xD146 */ |
| 3959 N_("BW Setting Type")}, | 4613 N_("BW Setting Type")}, |
| 3960 {PTP_DPC_NIKON_Slot2SaveMode, /* 0xD148 */ | 4614 {PTP_DPC_NIKON_Slot2SaveMode, /* 0xD148 */ |
| 3961 N_("Slot 2 Save Mode")}, | 4615 N_("Slot 2 Save Mode")}, |
| 3962 {PTP_DPC_NIKON_RawBitMode, /* 0xD149 */ | 4616 {PTP_DPC_NIKON_RawBitMode, /* 0xD149 */ |
| 3963 N_("Raw Bit Mode")}, | 4617 N_("Raw Bit Mode")}, |
| 3964 » » {PTP_DPC_NIKON_ISOAutoTime,» » » /* 0xD14E */ | 4618 » » {PTP_DPC_NIKON_ActiveDLighting,»» » /* 0xD14E */ |
| 3965 » » N_("ISO Auto Time")}, | 4619 » » N_("Active D-Lighting")}, |
| 3966 {PTP_DPC_NIKON_FlourescentType, /* 0xD14F */ | 4620 {PTP_DPC_NIKON_FlourescentType, /* 0xD14F */ |
| 3967 N_("Flourescent Type")}, | 4621 N_("Flourescent Type")}, |
| 3968 {PTP_DPC_NIKON_TuneColourTemperature, /* 0xD150 */ | 4622 {PTP_DPC_NIKON_TuneColourTemperature, /* 0xD150 */ |
| 3969 N_("Tune Colour Temperature")}, | 4623 N_("Tune Colour Temperature")}, |
| 3970 {PTP_DPC_NIKON_TunePreset0, /* 0xD151 */ | 4624 {PTP_DPC_NIKON_TunePreset0, /* 0xD151 */ |
| 3971 N_("Tune Preset 0")}, | 4625 N_("Tune Preset 0")}, |
| 3972 {PTP_DPC_NIKON_TunePreset1, /* 0xD152 */ | 4626 {PTP_DPC_NIKON_TunePreset1, /* 0xD152 */ |
| 3973 N_("Tune Preset 1")}, | 4627 N_("Tune Preset 1")}, |
| 3974 {PTP_DPC_NIKON_TunePreset2, /* 0xD153 */ | 4628 {PTP_DPC_NIKON_TunePreset2, /* 0xD153 */ |
| 3975 N_("Tune Preset 2")}, | 4629 N_("Tune Preset 2")}, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3988 {PTP_DPC_NIKON_ImageReview, /* 0xD165 */ | 4642 {PTP_DPC_NIKON_ImageReview, /* 0xD165 */ |
| 3989 N_("Image Review")}, | 4643 N_("Image Review")}, |
| 3990 {PTP_DPC_NIKON_AFAreaIllumination, /* 0xD166 */ | 4644 {PTP_DPC_NIKON_AFAreaIllumination, /* 0xD166 */ |
| 3991 N_("AF Area Illumination")}, | 4645 N_("AF Area Illumination")}, |
| 3992 {PTP_DPC_NIKON_FlashMode, /* 0xD167 */ | 4646 {PTP_DPC_NIKON_FlashMode, /* 0xD167 */ |
| 3993 N_("Flash Mode")}, | 4647 N_("Flash Mode")}, |
| 3994 {PTP_DPC_NIKON_FlashCommanderMode, /* 0xD168 */ | 4648 {PTP_DPC_NIKON_FlashCommanderMode, /* 0xD168 */ |
| 3995 N_("Flash Commander Mode")}, | 4649 N_("Flash Commander Mode")}, |
| 3996 {PTP_DPC_NIKON_FlashSign, /* 0xD169 */ | 4650 {PTP_DPC_NIKON_FlashSign, /* 0xD169 */ |
| 3997 N_("Flash Sign")}, | 4651 N_("Flash Sign")}, |
| 3998 » » {PTP_DPC_NIKON_ISOAuto,»» » » /* 0xD16A */ | 4652 » » {PTP_DPC_NIKON_ISO_Auto,» » » /* 0xD16A */ |
| 3999 N_("ISO Auto")}, | 4653 N_("ISO Auto")}, |
| 4000 {PTP_DPC_NIKON_RemoteTimeout, /* 0xD16B */ | 4654 {PTP_DPC_NIKON_RemoteTimeout, /* 0xD16B */ |
| 4001 N_("Remote Timeout")}, | 4655 N_("Remote Timeout")}, |
| 4002 {PTP_DPC_NIKON_GridDisplay, /* 0xD16C */ | 4656 {PTP_DPC_NIKON_GridDisplay, /* 0xD16C */ |
| 4003 N_("Viewfinder Grid Display")}, | 4657 N_("Viewfinder Grid Display")}, |
| 4004 {PTP_DPC_NIKON_FlashModeManualPower, /* 0xD16D */ | 4658 {PTP_DPC_NIKON_FlashModeManualPower, /* 0xD16D */ |
| 4005 N_("Flash Mode Manual Power")}, | 4659 N_("Flash Mode Manual Power")}, |
| 4006 {PTP_DPC_NIKON_FlashModeCommanderPower, /* 0xD16E */ | 4660 {PTP_DPC_NIKON_FlashModeCommanderPower, /* 0xD16E */ |
| 4007 N_("Flash Mode Commander Power")}, | 4661 N_("Flash Mode Commander Power")}, |
| 4008 {PTP_DPC_NIKON_AutoFP, /* 0xD16F */ | 4662 {PTP_DPC_NIKON_AutoFP, /* 0xD16F */ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4040 {PTP_DPC_NIKON_LiveViewStatus, /* 0xD1A2 */ | 4694 {PTP_DPC_NIKON_LiveViewStatus, /* 0xD1A2 */ |
| 4041 N_("Live View Status")}, | 4695 N_("Live View Status")}, |
| 4042 {PTP_DPC_NIKON_LiveViewImageZoomRatio, /* 0xD1A3 */ | 4696 {PTP_DPC_NIKON_LiveViewImageZoomRatio, /* 0xD1A3 */ |
| 4043 N_("Live View Image Zoom Ratio")}, | 4697 N_("Live View Image Zoom Ratio")}, |
| 4044 {PTP_DPC_NIKON_LiveViewProhibitCondition, /* 0xD1A4 */ | 4698 {PTP_DPC_NIKON_LiveViewProhibitCondition, /* 0xD1A4 */ |
| 4045 N_("Live View Prohibit Condition")}, | 4699 N_("Live View Prohibit Condition")}, |
| 4046 {PTP_DPC_NIKON_ExposureDisplayStatus, /* 0xD1B0 */ | 4700 {PTP_DPC_NIKON_ExposureDisplayStatus, /* 0xD1B0 */ |
| 4047 N_("Exposure Display Status")}, | 4701 N_("Exposure Display Status")}, |
| 4048 {PTP_DPC_NIKON_ExposureIndicateStatus, /* 0xD1B1 */ | 4702 {PTP_DPC_NIKON_ExposureIndicateStatus, /* 0xD1B1 */ |
| 4049 N_("Exposure Indicate Status")}, | 4703 N_("Exposure Indicate Status")}, |
| 4050 » » {PTP_DPC_NIKON_ExposureIndicateLightup,»» /* 0xD1B2 */ | 4704 » » {PTP_DPC_NIKON_InfoDispErrStatus,» » /* 0xD1B2 */ |
| 4705 » » N_("Info Display Error Status")}, |
| 4706 » » {PTP_DPC_NIKON_ExposureIndicateLightup,»» /* 0xD1B3 */ |
| 4051 N_("Exposure Indicate Lightup")}, | 4707 N_("Exposure Indicate Lightup")}, |
| 4052 {PTP_DPC_NIKON_FlashOpen, /* 0xD1C0 */ | 4708 {PTP_DPC_NIKON_FlashOpen, /* 0xD1C0 */ |
| 4053 N_("Flash Open")}, | 4709 N_("Flash Open")}, |
| 4054 {PTP_DPC_NIKON_FlashCharged, /* 0xD1C1 */ | 4710 {PTP_DPC_NIKON_FlashCharged, /* 0xD1C1 */ |
| 4055 N_("Flash Charged")}, | 4711 N_("Flash Charged")}, |
| 4056 {PTP_DPC_NIKON_FlashMRepeatValue, /* 0xD1D0 */ | 4712 {PTP_DPC_NIKON_FlashMRepeatValue, /* 0xD1D0 */ |
| 4057 N_("Flash MRepeat Value")}, | 4713 N_("Flash MRepeat Value")}, |
| 4058 {PTP_DPC_NIKON_FlashMRepeatCount, /* 0xD1D1 */ | 4714 {PTP_DPC_NIKON_FlashMRepeatCount, /* 0xD1D1 */ |
| 4059 N_("Flash MRepeat Count")}, | 4715 N_("Flash MRepeat Count")}, |
| 4060 {PTP_DPC_NIKON_FlashMRepeatInterval, /* 0xD1D2 */ | 4716 {PTP_DPC_NIKON_FlashMRepeatInterval, /* 0xD1D2 */ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4076 {PTP_DPC_NIKON_FlashCommandBMode, /* 0xD1DA */ | 4732 {PTP_DPC_NIKON_FlashCommandBMode, /* 0xD1DA */ |
| 4077 N_("Flash Command B Mode")}, | 4733 N_("Flash Command B Mode")}, |
| 4078 {PTP_DPC_NIKON_FlashCommandBCompensation, /* 0xD1DB */ | 4734 {PTP_DPC_NIKON_FlashCommandBCompensation, /* 0xD1DB */ |
| 4079 N_("Flash Command B Compensation")}, | 4735 N_("Flash Command B Compensation")}, |
| 4080 {PTP_DPC_NIKON_FlashCommandBValue, /* 0xD1DC */ | 4736 {PTP_DPC_NIKON_FlashCommandBValue, /* 0xD1DC */ |
| 4081 N_("Flash Command B Value")}, | 4737 N_("Flash Command B Value")}, |
| 4082 {PTP_DPC_NIKON_ActivePicCtrlItem, /* 0xD200 */ | 4738 {PTP_DPC_NIKON_ActivePicCtrlItem, /* 0xD200 */ |
| 4083 N_("Active Pic Ctrl Item")}, | 4739 N_("Active Pic Ctrl Item")}, |
| 4084 {PTP_DPC_NIKON_ChangePicCtrlItem, /* 0xD201 */ | 4740 {PTP_DPC_NIKON_ChangePicCtrlItem, /* 0xD201 */ |
| 4085 N_("Change Pic Ctrl Item")}, | 4741 N_("Change Pic Ctrl Item")}, |
| 4742 /* nikon 1 stuff */ |
| 4743 {PTP_DPC_NIKON_1_ISO, /* 0xf002 */ |
| 4744 N_("ISO")}, |
| 4745 {PTP_DPC_NIKON_1_ImageSize, /* 0xf00a */ |
| 4746 N_("Image Size")}, |
| 4747 {PTP_DPC_NIKON_1_LongExposureNoiseReduction, /* 0xF00D */ |
| 4748 N_("Long Exposure Noise Reduction")}, |
| 4749 {PTP_DPC_NIKON_1_MovQuality, /* 0xF01C */ |
| 4750 N_("Movie Quality")}, |
| 4751 {PTP_DPC_NIKON_1_HiISONoiseReduction, /* 0xF00E */ |
| 4752 N_("High ISO Noise Reduction")}, |
| 4753 {PTP_DPC_NIKON_1_WhiteBalance, /* 0xF00C */ |
| 4754 N_("White Balance")}, |
| 4755 {PTP_DPC_NIKON_1_ImageCompression, /* 0xF009 */ |
| 4756 N_("Image Compression")}, |
| 4757 {PTP_DPC_NIKON_1_ActiveDLighting, /* 0xF00F */ |
| 4758 N_("Active D-Lighting")}, |
| 4086 {0,NULL} | 4759 {0,NULL} |
| 4087 }; | 4760 }; |
| 4088 struct { | 4761 struct { |
| 4089 uint16_t dpc; | 4762 uint16_t dpc; |
| 4090 const char *txt; | 4763 const char *txt; |
| 4091 } ptp_device_properties_MTP[] = { | 4764 } ptp_device_properties_MTP[] = { |
| 4092 {PTP_DPC_MTP_SecureTime, N_("Secure Time")},
/* D101 */ | 4765 {PTP_DPC_MTP_SecureTime, N_("Secure Time")},
/* D101 */ |
| 4093 {PTP_DPC_MTP_DeviceCertificate, N_("Device Certificate")},
/* D102 */ | 4766 {PTP_DPC_MTP_DeviceCertificate, N_("Device Certificate")},
/* D102 */ |
| 4094 {PTP_DPC_MTP_RevocationInfo, N_("Revocation Info")},
/* D103 */ | 4767 {PTP_DPC_MTP_RevocationInfo, N_("Revocation Info")},
/* D103 */ |
| 4095 {PTP_DPC_MTP_SynchronizationPartner,
/* D401 */ | 4768 {PTP_DPC_MTP_SynchronizationPartner,
/* D401 */ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4115 {PTP_DPC_FUJI_ColorTemperature, N_("Color Temperature")},
/* 0xD017 */ | 4788 {PTP_DPC_FUJI_ColorTemperature, N_("Color Temperature")},
/* 0xD017 */ |
| 4116 {PTP_DPC_FUJI_Quality, N_("Quality")},
/* 0xD018 */ | 4789 {PTP_DPC_FUJI_Quality, N_("Quality")},
/* 0xD018 */ |
| 4117 {PTP_DPC_FUJI_Quality, N_("Release Mode")},
/* 0xD201 */ | 4790 {PTP_DPC_FUJI_Quality, N_("Release Mode")},
/* 0xD201 */ |
| 4118 {PTP_DPC_FUJI_Quality, N_("Focus Areas")},
/* 0xD206 */ | 4791 {PTP_DPC_FUJI_Quality, N_("Focus Areas")},
/* 0xD206 */ |
| 4119 {PTP_DPC_FUJI_Quality, N_("AE Lock")},
/* 0xD213 */ | 4792 {PTP_DPC_FUJI_Quality, N_("AE Lock")},
/* 0xD213 */ |
| 4120 {PTP_DPC_FUJI_Quality, N_("Aperture")},
/* 0xD218 */ | 4793 {PTP_DPC_FUJI_Quality, N_("Aperture")},
/* 0xD218 */ |
| 4121 {PTP_DPC_FUJI_Quality, N_("Shutter Speed")},
/* 0xD219 */ | 4794 {PTP_DPC_FUJI_Quality, N_("Shutter Speed")},
/* 0xD219 */ |
| 4122 {0,NULL} | 4795 {0,NULL} |
| 4123 }; | 4796 }; |
| 4124 | 4797 |
| 4798 struct { |
| 4799 uint16_t dpc; |
| 4800 const char *txt; |
| 4801 } ptp_device_properties_SONY[] = { |
| 4802 {PTP_DPC_SONY_DPCCompensation, ("DOC Compensation")}, /* 0xD20
0 */ |
| 4803 {PTP_DPC_SONY_DRangeOptimize, ("DRangeOptimize")}, /* 0xD20
1 */ |
| 4804 {PTP_DPC_SONY_ImageSize, N_("Image size")}, /* 0xD20
3 */ |
| 4805 {PTP_DPC_SONY_ShutterSpeed, N_("Shutter speed")}, /* 0xD20
D */ |
| 4806 {PTP_DPC_SONY_ColorTemp, N_("Color temperature")}, /* 0xD20
F */ |
| 4807 {PTP_DPC_SONY_CCFilter, ("CC Filter")}, /* 0xD21
0 */ |
| 4808 {PTP_DPC_SONY_AspectRatio, N_("Aspect Ratio")}, /* 0xD21
1 */ |
| 4809 {PTP_DPC_SONY_ExposeIndex, N_("Expose Index")}, /* 0xD21
6 */ |
| 4810 {PTP_DPC_SONY_PictureEffect, N_("Picture Effect")}, /* 0xD21
B */ |
| 4811 {PTP_DPC_SONY_ABFilter, N_("AB Filter")}, /* 0xD21
C */ |
| 4812 {PTP_DPC_SONY_ISO, N_("ISO")}, /* 0xD21
E */ |
| 4813 {PTP_DPC_SONY_Movie, N_("Movie")}, /* 0xD2C
8 */ |
| 4814 {PTP_DPC_SONY_StillImage, N_("Still Image")}, /* 0xD2C
7 */ |
| 4815 {0,NULL} |
| 4816 }; |
| 4817 |
| 4818 |
| 4125 for (i=0; ptp_device_properties[i].txt!=NULL; i++) | 4819 for (i=0; ptp_device_properties[i].txt!=NULL; i++) |
| 4126 if (ptp_device_properties[i].dpc==dpc) | 4820 if (ptp_device_properties[i].dpc==dpc) |
| 4127 return (ptp_device_properties[i].txt); | 4821 return (ptp_device_properties[i].txt); |
| 4128 | 4822 |
| 4129 if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_MICROSOFT | 4823 if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_MICROSOFT |
| 4130 || params->deviceinfo.VendorExtensionID==PTP_VENDOR_MTP) | 4824 || params->deviceinfo.VendorExtensionID==PTP_VENDOR_MTP) |
| 4131 for (i=0; ptp_device_properties_MTP[i].txt!=NULL; i++) | 4825 for (i=0; ptp_device_properties_MTP[i].txt!=NULL; i++) |
| 4132 if (ptp_device_properties_MTP[i].dpc==dpc) | 4826 if (ptp_device_properties_MTP[i].dpc==dpc) |
| 4133 return (ptp_device_properties_MTP[i].txt); | 4827 return (ptp_device_properties_MTP[i].txt); |
| 4134 | 4828 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4145 if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_NIKON) | 4839 if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_NIKON) |
| 4146 for (i=0; ptp_device_properties_Nikon[i].txt!=NULL; i++) | 4840 for (i=0; ptp_device_properties_Nikon[i].txt!=NULL; i++) |
| 4147 if (ptp_device_properties_Nikon[i].dpc==dpc) | 4841 if (ptp_device_properties_Nikon[i].dpc==dpc) |
| 4148 return (ptp_device_properties_Nikon[i].txt); | 4842 return (ptp_device_properties_Nikon[i].txt); |
| 4149 | 4843 |
| 4150 if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_FUJI) | 4844 if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_FUJI) |
| 4151 for (i=0; ptp_device_properties_FUJI[i].txt!=NULL; i++) | 4845 for (i=0; ptp_device_properties_FUJI[i].txt!=NULL; i++) |
| 4152 if (ptp_device_properties_FUJI[i].dpc==dpc) | 4846 if (ptp_device_properties_FUJI[i].dpc==dpc) |
| 4153 return (ptp_device_properties_FUJI[i].txt); | 4847 return (ptp_device_properties_FUJI[i].txt); |
| 4154 | 4848 |
| 4849 if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_SONY) |
| 4850 for (i=0; ptp_device_properties_SONY[i].txt!=NULL; i++) |
| 4851 if (ptp_device_properties_SONY[i].dpc==dpc) |
| 4852 return (ptp_device_properties_SONY[i].txt); |
| 4853 |
| 4155 return NULL; | 4854 return NULL; |
| 4156 } | 4855 } |
| 4157 | 4856 |
| 4158 static int64_t | 4857 static int64_t |
| 4159 _value_to_num(PTPPropertyValue *data, uint16_t dt) { | 4858 _value_to_num(PTPPropertyValue *data, uint16_t dt) { |
| 4160 if (dt == PTP_DTC_STR) { | 4859 if (dt == PTP_DTC_STR) { |
| 4161 if (!data->str) | 4860 if (!data->str) |
| 4162 return 0; | 4861 return 0; |
| 4163 return atol(data->str); | 4862 return atol(data->str); |
| 4164 } | 4863 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 4194 return 0; | 4893 return 0; |
| 4195 } | 4894 } |
| 4196 | 4895 |
| 4197 #define PTP_VAL_BOOL(dpc) {dpc, 0, N_("Off")}, {dpc, 1, N_("On")} | 4896 #define PTP_VAL_BOOL(dpc) {dpc, 0, N_("Off")}, {dpc, 1, N_("On")} |
| 4198 #define PTP_VENDOR_VAL_BOOL(dpc,vendor) {dpc, vendor, 0, N_("Off")}, {dpc, vendo
r, 1, N_("On")} | 4897 #define PTP_VENDOR_VAL_BOOL(dpc,vendor) {dpc, vendor, 0, N_("Off")}, {dpc, vendo
r, 1, N_("On")} |
| 4199 #define PTP_VENDOR_VAL_RBOOL(dpc,vendor) {dpc, vendor, 0, N_("On")}, {dpc, vendo
r, 1, N_("Off")} | 4898 #define PTP_VENDOR_VAL_RBOOL(dpc,vendor) {dpc, vendor, 0, N_("On")}, {dpc, vendo
r, 1, N_("Off")} |
| 4200 #define PTP_VENDOR_VAL_YN(dpc,vendor) {dpc, vendor, 0, N_("No")}, {dpc, vendor,
1, N_("Yes")} | 4899 #define PTP_VENDOR_VAL_YN(dpc,vendor) {dpc, vendor, 0, N_("No")}, {dpc, vendor,
1, N_("Yes")} |
| 4201 | 4900 |
| 4202 int | 4901 int |
| 4203 ptp_render_property_value(PTPParams* params, uint16_t dpc, | 4902 ptp_render_property_value(PTPParams* params, uint16_t dpc, |
| 4204 » » » PTPDevicePropDesc *dpd, int length, char *out) | 4903 » » » PTPDevicePropDesc *dpd, unsigned int length, char *out
) |
| 4205 { | 4904 { |
| 4206 » int i; | 4905 » unsigned int i; |
| 4207 int64_t kval; | 4906 int64_t kval; |
| 4208 | 4907 |
| 4209 struct { | 4908 struct { |
| 4210 uint16_t dpc; | 4909 uint16_t dpc; |
| 4211 uint16_t vendor; | 4910 uint16_t vendor; |
| 4212 double coef; | 4911 double coef; |
| 4213 double bias; | 4912 double bias; |
| 4214 const char *format; | 4913 const char *format; |
| 4215 } ptp_value_trans[] = { | 4914 } ptp_value_trans[] = { |
| 4216 {PTP_DPC_BatteryLevel, 0, 1.0, 0.0, "%.0f%%"}, /* 5001
*/ | 4915 {PTP_DPC_BatteryLevel, 0, 1.0, 0.0, "%.0f%%"}, /* 5001
*/ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4227 /* Nikon device properties */ | 4926 /* Nikon device properties */ |
| 4228 {PTP_DPC_NIKON_LightMeter, PTP_VENDOR_NIKON, 0.08333, 0.0, N_("%
.1f stops")},/* D10A */ | 4927 {PTP_DPC_NIKON_LightMeter, PTP_VENDOR_NIKON, 0.08333, 0.0, N_("%
.1f stops")},/* D10A */ |
| 4229 {PTP_DPC_NIKON_FlashExposureCompensation, PTP_VENDOR_NIKON, 0.16
666, 0.0, N_("%.1f stops")}, /* D126 */ | 4928 {PTP_DPC_NIKON_FlashExposureCompensation, PTP_VENDOR_NIKON, 0.16
666, 0.0, N_("%.1f stops")}, /* D126 */ |
| 4230 {PTP_DPC_NIKON_CenterWeightArea, PTP_VENDOR_NIKON, 2.0, 6.0, N_(
"%.0f mm")},/* D059 */ | 4929 {PTP_DPC_NIKON_CenterWeightArea, PTP_VENDOR_NIKON, 2.0, 6.0, N_(
"%.0f mm")},/* D059 */ |
| 4231 {PTP_DPC_NIKON_FocalLengthMin, PTP_VENDOR_NIKON, 0.01, 0.0, "%.0
f mm"}, /* D0E3 */ | 4930 {PTP_DPC_NIKON_FocalLengthMin, PTP_VENDOR_NIKON, 0.01, 0.0, "%.0
f mm"}, /* D0E3 */ |
| 4232 {PTP_DPC_NIKON_FocalLengthMax, PTP_VENDOR_NIKON, 0.01, 0.0, "%.0
f mm"}, /* D0E4 */ | 4931 {PTP_DPC_NIKON_FocalLengthMax, PTP_VENDOR_NIKON, 0.01, 0.0, "%.0
f mm"}, /* D0E4 */ |
| 4233 {PTP_DPC_NIKON_MaxApAtMinFocalLength, PTP_VENDOR_NIKON, 0.01, 0.
0, "f/%.2g"}, /* D0E5 */ | 4932 {PTP_DPC_NIKON_MaxApAtMinFocalLength, PTP_VENDOR_NIKON, 0.01, 0.
0, "f/%.2g"}, /* D0E5 */ |
| 4234 {PTP_DPC_NIKON_MaxApAtMaxFocalLength, PTP_VENDOR_NIKON, 0.01, 0.
0, "f/%.2g"}, /* D0E6 */ | 4933 {PTP_DPC_NIKON_MaxApAtMaxFocalLength, PTP_VENDOR_NIKON, 0.01, 0.
0, "f/%.2g"}, /* D0E6 */ |
| 4235 {PTP_DPC_NIKON_ExternalFlashCompensation, PTP_VENDOR_NIKON, 1.0/
6.0, 0.0,"%.0f"}, /* D124 */ | 4934 {PTP_DPC_NIKON_ExternalFlashCompensation, PTP_VENDOR_NIKON, 1.0/
6.0, 0.0,"%.0f"}, /* D124 */ |
| 4236 {PTP_DPC_NIKON_ExposureIndicateStatus, PTP_VENDOR_NIKON, 0.08333
, 0.0, N_("%.1f stops")},/* D1B1 - FIXME: check if correct. */ | 4935 {PTP_DPC_NIKON_ExposureIndicateStatus, PTP_VENDOR_NIKON, 0.08333
, 0.0, N_("%.1f stops")},/* D1B1 - FIXME: check if correct. */ |
| 4936 {PTP_DPC_NIKON_AngleLevel, PTP_VENDOR_NIKON, 1.0/65536, 0.0, "%.
1f'"},/* 0xD067 */ |
| 4237 {0, 0, 0.0, 0.0, NULL} | 4937 {0, 0, 0.0, 0.0, NULL} |
| 4238 }; | 4938 }; |
| 4239 | 4939 |
| 4240 struct { | 4940 struct { |
| 4241 uint16_t dpc; | 4941 uint16_t dpc; |
| 4242 uint16_t vendor; | 4942 uint16_t vendor; |
| 4243 int64_t key; | 4943 int64_t key; |
| 4244 char *value; | 4944 char *value; |
| 4245 } ptp_value_list[] = { | 4945 } ptp_value_list[] = { |
| 4246 {PTP_DPC_CompressionSetting, 0, 0, N_("JPEG Basic")}, /* 5004
*/ | 4946 {PTP_DPC_CompressionSetting, 0, 0, N_("JPEG Basic")}, /* 5004
*/ |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4436 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 118, "AF Nikkor 50mm 1:
1.8 D"}, | 5136 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 118, "AF Nikkor 50mm 1:
1.8 D"}, |
| 4437 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 127, "AF-S Nikkor 18-70
mm 1:3.5-4.5G ED DX"}, | 5137 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 127, "AF-S Nikkor 18-70
mm 1:3.5-4.5G ED DX"}, |
| 4438 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 139, "AF-S Nikkor 18-20
0mm 1:3.5-5.6 GED DX VR"}, | 5138 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 139, "AF-S Nikkor 18-20
0mm 1:3.5-5.6 GED DX VR"}, |
| 4439 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 147, "AF-S Nikkor 24-70
mm 1:2.8G ED DX"}, | 5139 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 147, "AF-S Nikkor 24-70
mm 1:2.8G ED DX"}, |
| 4440 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 154, "AF-S Nikkor 18-55
mm 1:3.5-F5.6G DX VR"}, | 5140 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 154, "AF-S Nikkor 18-55
mm 1:3.5-F5.6G DX VR"}, |
| 4441 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 159, "AF-S Nikkor 35mm
1:1.8G DX"}, | 5141 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 159, "AF-S Nikkor 35mm
1:1.8G DX"}, |
| 4442 {PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 0, "Show ISO sen
sitivity"},/* 0xD0F0 */ | 5142 {PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 0, "Show ISO sen
sitivity"},/* 0xD0F0 */ |
| 4443 {PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 1, "Show ISO/Eas
y ISO"}, | 5143 {PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 1, "Show ISO/Eas
y ISO"}, |
| 4444 {PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 2, "Show frame c
ount"}, | 5144 {PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 2, "Show frame c
ount"}, |
| 4445 | 5145 |
| 5146 {PTP_DPC_NIKON_RawCompression, PTP_VENDOR_NIKON, 0, N_("Lossless
")}, /* D016 */ |
| 5147 {PTP_DPC_NIKON_RawCompression, PTP_VENDOR_NIKON, 1, N_("Lossy")}
, |
| 5148 |
| 4446 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ACPower,PTP_VENDOR_NIKON),
/* D101 */ | 5149 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ACPower,PTP_VENDOR_NIKON),
/* D101 */ |
| 4447 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AFLockStatus,PTP_VENDOR_NIKON),
/* D104 */ | 5150 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AFLockStatus,PTP_VENDOR_NIKON),
/* D104 */ |
| 4448 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AELockStatus,PTP_VENDOR_NIKON),
/* D105 */ | 5151 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AELockStatus,PTP_VENDOR_NIKON),
/* D105 */ |
| 4449 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FVLockStatus,PTP_VENDOR_NIKON),
/* D106 */ | 5152 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FVLockStatus,PTP_VENDOR_NIKON),
/* D106 */ |
| 4450 | 5153 |
| 4451 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 0, N_("Centre")}
, /* D108 */ | 5154 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 0, N_("Centre")}
, /* D108 */ |
| 4452 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 1, N_("Top")}, | 5155 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 1, N_("Top")}, |
| 4453 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 2, N_("Bottom")}
, | 5156 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 2, N_("Bottom")}
, |
| 4454 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 3, N_("Left")}, | 5157 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 3, N_("Left")}, |
| 4455 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 4, N_("Right")}, | 5158 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 4, N_("Right")}, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4574 | 5277 |
| 4575 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_LiveViewStatus,PTP_VENDOR_NIKON)
, /* D1A2 */ | 5278 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_LiveViewStatus,PTP_VENDOR_NIKON)
, /* D1A2 */ |
| 4576 | 5279 |
| 4577 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExposureDisplayStatus,PTP_VENDOR
_NIKON),/* D1B0 */ | 5280 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExposureDisplayStatus,PTP_VENDOR
_NIKON),/* D1B0 */ |
| 4578 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_InfoDispErrStatus,PTP_VENDOR_NIK
ON), /* D1B2 */ | 5281 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_InfoDispErrStatus,PTP_VENDOR_NIK
ON), /* D1B2 */ |
| 4579 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExposureIndicateLightup,PTP_VEND
OR_NIKON),/* D1B3 */ | 5282 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExposureIndicateLightup,PTP_VEND
OR_NIKON),/* D1B3 */ |
| 4580 | 5283 |
| 4581 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FlashOpen,PTP_VENDOR_NIKON),
/* D1C0 */ | 5284 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FlashOpen,PTP_VENDOR_NIKON),
/* D1C0 */ |
| 4582 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FlashCharged,PTP_VENDOR_NIKON),
/* D1C1 */ | 5285 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FlashCharged,PTP_VENDOR_NIKON),
/* D1C1 */ |
| 4583 | 5286 |
| 5287 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ManualMovieSetting,PTP_VENDOR_NI
KON), /* 0xD0A6 */ |
| 5288 |
| 5289 {PTP_DPC_NIKON_FlickerReduction, PTP_VENDOR_NIKON, 0, "50Hz"},
/* 0xD034 */ |
| 5290 {PTP_DPC_NIKON_FlickerReduction, PTP_VENDOR_NIKON, 1, "60Hz"}, |
| 5291 |
| 5292 {PTP_DPC_NIKON_RemoteMode, PTP_VENDOR_NIKON, 0, N_("Delayed Remo
te")}, /* 0xD035 */ |
| 5293 {PTP_DPC_NIKON_RemoteMode, PTP_VENDOR_NIKON, 1, N_("Quick Respon
se")}, /* 0xD035 */ |
| 5294 {PTP_DPC_NIKON_RemoteMode, PTP_VENDOR_NIKON, 2, N_("Remote Mirro
r Up")},/* 0xD035 */ |
| 5295 |
| 5296 {PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 0, "5min"},
/* 0xD0b3 */ |
| 5297 {PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 1, "10min"},
/* 0xD0b3 */ |
| 5298 {PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 2, "15min"},
/* 0xD0b3 */ |
| 5299 {PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 3, "20min"},
/* 0xD0b3 */ |
| 5300 {PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 4, "30min"},
/* 0xD0b3 */ |
| 5301 |
| 5302 |
| 4584 /* Canon stuff */ | 5303 /* Canon stuff */ |
| 4585 PTP_VENDOR_VAL_BOOL(PTP_DPC_CANON_AssistLight,PTP_VENDOR_CANON), | 5304 PTP_VENDOR_VAL_BOOL(PTP_DPC_CANON_AssistLight,PTP_VENDOR_CANON), |
| 4586 PTP_VENDOR_VAL_RBOOL(PTP_DPC_CANON_RotationScene,PTP_VENDOR_CANO
N), | 5305 PTP_VENDOR_VAL_RBOOL(PTP_DPC_CANON_RotationScene,PTP_VENDOR_CANO
N), |
| 4587 PTP_VENDOR_VAL_RBOOL(PTP_DPC_CANON_BeepMode,PTP_VENDOR_CANON), | 5306 PTP_VENDOR_VAL_RBOOL(PTP_DPC_CANON_BeepMode,PTP_VENDOR_CANON), |
| 4588 PTP_VENDOR_VAL_BOOL(PTP_DPC_CANON_Beep,PTP_VENDOR_CANON), | 5307 PTP_VENDOR_VAL_BOOL(PTP_DPC_CANON_Beep,PTP_VENDOR_CANON), |
| 4589 | 5308 |
| 4590 {PTP_DPC_CANON_RotationAngle, PTP_VENDOR_CANON, 0, "0'"}, | 5309 {PTP_DPC_CANON_RotationAngle, PTP_VENDOR_CANON, 0, "0'"}, |
| 4591 {PTP_DPC_CANON_RotationAngle, PTP_VENDOR_CANON, 3, "270'"}, | 5310 {PTP_DPC_CANON_RotationAngle, PTP_VENDOR_CANON, 3, "270'"}, |
| 4592 {PTP_DPC_CANON_RotationAngle, PTP_VENDOR_CANON, 1, "90'"}, | 5311 {PTP_DPC_CANON_RotationAngle, PTP_VENDOR_CANON, 1, "90'"}, |
| 4593 | 5312 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4937 {PTP_OFC_MTP_vCalendar1,N_("vCalendar1")}, | 5656 {PTP_OFC_MTP_vCalendar1,N_("vCalendar1")}, |
| 4938 {PTP_OFC_MTP_vCalendar2,N_("vCalendar2")}, | 5657 {PTP_OFC_MTP_vCalendar2,N_("vCalendar2")}, |
| 4939 {PTP_OFC_MTP_UndefinedWindowsExecutable,N_("Undefined Windows Executable
")}, | 5658 {PTP_OFC_MTP_UndefinedWindowsExecutable,N_("Undefined Windows Executable
")}, |
| 4940 {PTP_OFC_MTP_MediaCast,N_("Media Cast")}, | 5659 {PTP_OFC_MTP_MediaCast,N_("Media Cast")}, |
| 4941 {PTP_OFC_MTP_Section,N_("Section")}, | 5660 {PTP_OFC_MTP_Section,N_("Section")}, |
| 4942 }; | 5661 }; |
| 4943 | 5662 |
| 4944 int | 5663 int |
| 4945 ptp_render_ofc(PTPParams* params, uint16_t ofc, int spaceleft, char *txt) | 5664 ptp_render_ofc(PTPParams* params, uint16_t ofc, int spaceleft, char *txt) |
| 4946 { | 5665 { |
| 4947 » int i; | 5666 » unsigned int i; |
| 4948 » | 5667 |
| 4949 if (!(ofc & 0x8000)) { | 5668 if (!(ofc & 0x8000)) { |
| 4950 for (i=0;i<sizeof(ptp_ofc_trans)/sizeof(ptp_ofc_trans[0]);i++) | 5669 for (i=0;i<sizeof(ptp_ofc_trans)/sizeof(ptp_ofc_trans[0]);i++) |
| 4951 if (ofc == ptp_ofc_trans[i].ofc) | 5670 if (ofc == ptp_ofc_trans[i].ofc) |
| 4952 return snprintf(txt, spaceleft, "%s", _(ptp_ofc_
trans[i].format)); | 5671 return snprintf(txt, spaceleft, "%s", _(ptp_ofc_
trans[i].format)); |
| 4953 } else { | 5672 } else { |
| 4954 switch (params->deviceinfo.VendorExtensionID) { | 5673 switch (params->deviceinfo.VendorExtensionID) { |
| 4955 case PTP_VENDOR_EASTMAN_KODAK: | 5674 case PTP_VENDOR_EASTMAN_KODAK: |
| 4956 switch (ofc) { | 5675 switch (ofc) { |
| 4957 case PTP_OFC_EK_M3U: | 5676 case PTP_OFC_EK_M3U: |
| 4958 return snprintf (txt, spaceleft,"M3U"); | 5677 return snprintf (txt, spaceleft,"M3U"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4973 for (i=0;i<sizeof(ptp_ofc_mtp_trans)/sizeof(ptp_ofc_mtp_
trans[0]);i++) | 5692 for (i=0;i<sizeof(ptp_ofc_mtp_trans)/sizeof(ptp_ofc_mtp_
trans[0]);i++) |
| 4974 if (ofc == ptp_ofc_mtp_trans[i].ofc) | 5693 if (ofc == ptp_ofc_mtp_trans[i].ofc) |
| 4975 return snprintf(txt, spaceleft, "%s", _(
ptp_ofc_mtp_trans[i].format)); | 5694 return snprintf(txt, spaceleft, "%s", _(
ptp_ofc_mtp_trans[i].format)); |
| 4976 break; | 5695 break; |
| 4977 default:break; | 5696 default:break; |
| 4978 } | 5697 } |
| 4979 } | 5698 } |
| 4980 return snprintf (txt, spaceleft,_("Unknown(%04x)"), ofc); | 5699 return snprintf (txt, spaceleft,_("Unknown(%04x)"), ofc); |
| 4981 } | 5700 } |
| 4982 | 5701 |
| 4983 struct { | 5702 typedef struct { |
| 4984 uint16_t opcode; | 5703 uint16_t opcode; |
| 4985 const char *name; | 5704 const char *name; |
| 4986 } ptp_opcode_trans[] = { | 5705 } ptp_opcode_trans_t; |
| 5706 |
| 5707 ptp_opcode_trans_t ptp_opcode_trans[] = { |
| 4987 {PTP_OC_Undefined,N_("Undefined")}, | 5708 {PTP_OC_Undefined,N_("Undefined")}, |
| 4988 » {PTP_OC_GetDeviceInfo,N_("get device info")}, | 5709 » {PTP_OC_GetDeviceInfo,N_("Get device info")}, |
| 4989 {PTP_OC_OpenSession,N_("Open session")}, | 5710 {PTP_OC_OpenSession,N_("Open session")}, |
| 4990 {PTP_OC_CloseSession,N_("Close session")}, | 5711 {PTP_OC_CloseSession,N_("Close session")}, |
| 4991 {PTP_OC_GetStorageIDs,N_("Get storage IDs")}, | 5712 {PTP_OC_GetStorageIDs,N_("Get storage IDs")}, |
| 4992 {PTP_OC_GetStorageInfo,N_("Get storage info")}, | 5713 {PTP_OC_GetStorageInfo,N_("Get storage info")}, |
| 4993 {PTP_OC_GetNumObjects,N_("Get number of objects")}, | 5714 {PTP_OC_GetNumObjects,N_("Get number of objects")}, |
| 4994 {PTP_OC_GetObjectHandles,N_("Get object handles")}, | 5715 {PTP_OC_GetObjectHandles,N_("Get object handles")}, |
| 4995 {PTP_OC_GetObjectInfo,N_("Get object info")}, | 5716 {PTP_OC_GetObjectInfo,N_("Get object info")}, |
| 4996 {PTP_OC_GetObject,N_("Get object")}, | 5717 {PTP_OC_GetObject,N_("Get object")}, |
| 4997 {PTP_OC_GetThumb,N_("Get thumbnail")}, | 5718 {PTP_OC_GetThumb,N_("Get thumbnail")}, |
| 4998 {PTP_OC_DeleteObject,N_("Delete object")}, | 5719 {PTP_OC_DeleteObject,N_("Delete object")}, |
| 4999 {PTP_OC_SendObjectInfo,N_("Send object info")}, | 5720 {PTP_OC_SendObjectInfo,N_("Send object info")}, |
| 5000 {PTP_OC_SendObject,N_("Send object")}, | 5721 {PTP_OC_SendObject,N_("Send object")}, |
| 5001 {PTP_OC_InitiateCapture,N_("Initiate capture")}, | 5722 {PTP_OC_InitiateCapture,N_("Initiate capture")}, |
| 5002 {PTP_OC_FormatStore,N_("Format storage")}, | 5723 {PTP_OC_FormatStore,N_("Format storage")}, |
| 5003 {PTP_OC_ResetDevice,N_("Reset device")}, | 5724 {PTP_OC_ResetDevice,N_("Reset device")}, |
| 5004 {PTP_OC_SelfTest,N_("Self test device")}, | 5725 {PTP_OC_SelfTest,N_("Self test device")}, |
| 5005 {PTP_OC_SetObjectProtection,N_("Set object protection")}, | 5726 {PTP_OC_SetObjectProtection,N_("Set object protection")}, |
| 5006 {PTP_OC_PowerDown,N_("Power down device")}, | 5727 {PTP_OC_PowerDown,N_("Power down device")}, |
| 5007 {PTP_OC_GetDevicePropDesc,N_("Get device property description")}, | 5728 {PTP_OC_GetDevicePropDesc,N_("Get device property description")}, |
| 5008 {PTP_OC_GetDevicePropValue,N_("Get device property value")}, | 5729 {PTP_OC_GetDevicePropValue,N_("Get device property value")}, |
| 5009 {PTP_OC_SetDevicePropValue,N_("Set device property value")}, | 5730 {PTP_OC_SetDevicePropValue,N_("Set device property value")}, |
| 5010 {PTP_OC_ResetDevicePropValue,N_("Reset device property value")}, | 5731 {PTP_OC_ResetDevicePropValue,N_("Reset device property value")}, |
| 5011 {PTP_OC_TerminateOpenCapture,N_("Terminate open capture")}, | 5732 {PTP_OC_TerminateOpenCapture,N_("Terminate open capture")}, |
| 5012 {PTP_OC_MoveObject,N_("Move object")}, | 5733 {PTP_OC_MoveObject,N_("Move object")}, |
| 5013 {PTP_OC_CopyObject,N_("Copy object")}, | 5734 {PTP_OC_CopyObject,N_("Copy object")}, |
| 5014 {PTP_OC_GetPartialObject,N_("Get partial object")}, | 5735 {PTP_OC_GetPartialObject,N_("Get partial object")}, |
| 5015 » {PTP_OC_InitiateOpenCapture,N_("Initiate open capture")} | 5736 » {PTP_OC_InitiateOpenCapture,N_("Initiate open capture")}, |
| 5737 » /* PTP v1.1 operation codes */ |
| 5738 » {PTP_OC_StartEnumHandles,N_("Start Enumerate Handles")}, |
| 5739 » {PTP_OC_EnumHandles,N_("Enumerate Handles")}, |
| 5740 » {PTP_OC_StopEnumHandles,N_("Stop Enumerate Handles")}, |
| 5741 » {PTP_OC_GetVendorExtensionMaps,N_("Get Vendor Extension Maps")}, |
| 5742 » {PTP_OC_GetVendorDeviceInfo,N_("Get Vendor Device Info")}, |
| 5743 » {PTP_OC_GetResizedImageObject,N_("Get Resized Image Object")}, |
| 5744 » {PTP_OC_GetFilesystemManifest,N_("Get Filesystem Manifest")}, |
| 5745 » {PTP_OC_GetStreamInfo,N_("Get Stream Info")}, |
| 5746 » {PTP_OC_GetStream,N_("Get Stream")}, |
| 5016 }; | 5747 }; |
| 5017 | 5748 |
| 5018 struct { | 5749 ptp_opcode_trans_t ptp_opcode_mtp_trans[] = { |
| 5019 » uint16_t opcode; | |
| 5020 » const char *name; | |
| 5021 } ptp_opcode_mtp_trans[] = { | |
| 5022 {PTP_OC_MTP_GetObjectPropsSupported,N_("Get object properties supported"
)}, | 5750 {PTP_OC_MTP_GetObjectPropsSupported,N_("Get object properties supported"
)}, |
| 5023 {PTP_OC_MTP_GetObjectPropDesc,N_("Get object property description")}, | 5751 {PTP_OC_MTP_GetObjectPropDesc,N_("Get object property description")}, |
| 5024 {PTP_OC_MTP_GetObjectPropValue,N_("Get object property value")}, | 5752 {PTP_OC_MTP_GetObjectPropValue,N_("Get object property value")}, |
| 5025 {PTP_OC_MTP_SetObjectPropValue,N_("Set object property value")}, | 5753 {PTP_OC_MTP_SetObjectPropValue,N_("Set object property value")}, |
| 5026 {PTP_OC_MTP_GetObjPropList,N_("Get object property list")}, | 5754 {PTP_OC_MTP_GetObjPropList,N_("Get object property list")}, |
| 5027 {PTP_OC_MTP_SetObjPropList,N_("Set object property list")}, | 5755 {PTP_OC_MTP_SetObjPropList,N_("Set object property list")}, |
| 5028 {PTP_OC_MTP_GetInterdependendPropdesc,N_("Get interdependent property de
scription")}, | 5756 {PTP_OC_MTP_GetInterdependendPropdesc,N_("Get interdependent property de
scription")}, |
| 5029 {PTP_OC_MTP_SendObjectPropList,N_("Send object property list")}, | 5757 {PTP_OC_MTP_SendObjectPropList,N_("Send object property list")}, |
| 5030 {PTP_OC_MTP_GetObjectReferences,N_("Get object references")}, | 5758 {PTP_OC_MTP_GetObjectReferences,N_("Get object references")}, |
| 5031 {PTP_OC_MTP_SetObjectReferences,N_("Set object references")}, | 5759 {PTP_OC_MTP_SetObjectReferences,N_("Set object references")}, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5065 | 5793 |
| 5066 /* WMDRMND Extensions */ | 5794 /* WMDRMND Extensions */ |
| 5067 {PTP_OC_MTP_WMDRMND_SendRegistrationRequest,N_("Send Registration Reques
t")}, | 5795 {PTP_OC_MTP_WMDRMND_SendRegistrationRequest,N_("Send Registration Reques
t")}, |
| 5068 {PTP_OC_MTP_WMDRMND_GetRegistrationResponse,N_("Get Registration Respons
e")}, | 5796 {PTP_OC_MTP_WMDRMND_GetRegistrationResponse,N_("Get Registration Respons
e")}, |
| 5069 {PTP_OC_MTP_WMDRMND_GetProximityChallenge,N_("Get Proximity Challenge")}
, | 5797 {PTP_OC_MTP_WMDRMND_GetProximityChallenge,N_("Get Proximity Challenge")}
, |
| 5070 {PTP_OC_MTP_WMDRMND_SendProximityResponse,N_("Send Proximity Response")}
, | 5798 {PTP_OC_MTP_WMDRMND_SendProximityResponse,N_("Send Proximity Response")}
, |
| 5071 {PTP_OC_MTP_WMDRMND_SendWMDRMNDLicenseRequest,N_("Send WMDRM-ND License
Request")}, | 5799 {PTP_OC_MTP_WMDRMND_SendWMDRMNDLicenseRequest,N_("Send WMDRM-ND License
Request")}, |
| 5072 {PTP_OC_MTP_WMDRMND_GetWMDRMNDLicenseResponse,N_("Get WMDRM-ND License R
esponse")}, | 5800 {PTP_OC_MTP_WMDRMND_GetWMDRMNDLicenseResponse,N_("Get WMDRM-ND License R
esponse")}, |
| 5073 | 5801 |
| 5074 /* WiFi Provisioning MTP Extension Codes (microsoft.com/WPDWCN: 1.0) */ | 5802 /* WiFi Provisioning MTP Extension Codes (microsoft.com/WPDWCN: 1.0) */ |
| 5075 {PTP_OC_MTP_WPDWCN_ProcessWFCObject,N_("Process WFC Object")} | 5803 {PTP_OC_MTP_WPDWCN_ProcessWFCObject,N_("Process WFC Object")}, |
| 5076 }; | 5804 |
| 5077 | 5805 /* Android Direct I/O Extensions */ |
| 5078 int | 5806 {PTP_OC_ANDROID_GetPartialObject64,N_("Get Partial Object (64bit Offset)
")}, |
| 5079 ptp_render_opcode(PTPParams* params, uint16_t opcode, int spaceleft, char *txt) | 5807 {PTP_OC_ANDROID_SendPartialObject,N_("Send Partial Object")}, |
| 5808 {PTP_OC_ANDROID_TruncateObject,N_("Truncate Object")}, |
| 5809 {PTP_OC_ANDROID_BeginEditObject,N_("Begin Edit Object")}, |
| 5810 {PTP_OC_ANDROID_EndEditObject,N_("End Edit Object")}, |
| 5811 }; |
| 5812 |
| 5813 ptp_opcode_trans_t ptp_opcode_nikon_trans[] = { |
| 5814 {PTP_OC_NIKON_GetProfileAllData,"PTP_OC_NIKON_GetProfileAllData"}, |
| 5815 {PTP_OC_NIKON_SendProfileData,"PTP_OC_NIKON_SendProfileData"}, |
| 5816 {PTP_OC_NIKON_DeleteProfile,"PTP_OC_NIKON_DeleteProfile"}, |
| 5817 {PTP_OC_NIKON_SetProfileData,"PTP_OC_NIKON_SetProfileData"}, |
| 5818 {PTP_OC_NIKON_AdvancedTransfer,"PTP_OC_NIKON_AdvancedTransfer"}, |
| 5819 {PTP_OC_NIKON_GetFileInfoInBlock,"PTP_OC_NIKON_GetFileInfoInBlock"}, |
| 5820 {PTP_OC_NIKON_Capture,"PTP_OC_NIKON_Capture"}, |
| 5821 {PTP_OC_NIKON_AfDrive,"PTP_OC_NIKON_AfDrive"}, |
| 5822 {PTP_OC_NIKON_SetControlMode,"PTP_OC_NIKON_SetControlMode"}, |
| 5823 {PTP_OC_NIKON_DelImageSDRAM,"PTP_OC_NIKON_DelImageSDRAM"}, |
| 5824 {PTP_OC_NIKON_GetLargeThumb,"PTP_OC_NIKON_GetLargeThumb"}, |
| 5825 {PTP_OC_NIKON_CurveDownload,"PTP_OC_NIKON_CurveDownload"}, |
| 5826 {PTP_OC_NIKON_CurveUpload,"PTP_OC_NIKON_CurveUpload"}, |
| 5827 {PTP_OC_NIKON_CheckEvent,"PTP_OC_NIKON_CheckEvent"}, |
| 5828 {PTP_OC_NIKON_DeviceReady,"PTP_OC_NIKON_DeviceReady"}, |
| 5829 {PTP_OC_NIKON_SetPreWBData,"PTP_OC_NIKON_SetPreWBData"}, |
| 5830 {PTP_OC_NIKON_GetVendorPropCodes,"PTP_OC_NIKON_GetVendorPropCodes"}, |
| 5831 {PTP_OC_NIKON_AfCaptureSDRAM,"PTP_OC_NIKON_AfCaptureSDRAM"}, |
| 5832 {PTP_OC_NIKON_GetPictCtrlData,"PTP_OC_NIKON_GetPictCtrlData"}, |
| 5833 {PTP_OC_NIKON_SetPictCtrlData,"PTP_OC_NIKON_SetPictCtrlData"}, |
| 5834 {PTP_OC_NIKON_DelCstPicCtrl,"PTP_OC_NIKON_DelCstPicCtrl"}, |
| 5835 {PTP_OC_NIKON_GetPicCtrlCapability,"PTP_OC_NIKON_GetPicCtrlCapability"}, |
| 5836 {PTP_OC_NIKON_GetPreviewImg,"PTP_OC_NIKON_GetPreviewImg"}, |
| 5837 {PTP_OC_NIKON_StartLiveView,"PTP_OC_NIKON_StartLiveView"}, |
| 5838 {PTP_OC_NIKON_EndLiveView,"PTP_OC_NIKON_EndLiveView"}, |
| 5839 {PTP_OC_NIKON_GetLiveViewImg,"PTP_OC_NIKON_GetLiveViewImg"}, |
| 5840 {PTP_OC_NIKON_MfDrive,"PTP_OC_NIKON_MfDrive"}, |
| 5841 {PTP_OC_NIKON_ChangeAfArea,"PTP_OC_NIKON_ChangeAfArea"}, |
| 5842 {PTP_OC_NIKON_AfDriveCancel,"PTP_OC_NIKON_AfDriveCancel"}, |
| 5843 {PTP_OC_NIKON_InitiateCaptureRecInMedia,"PTP_OC_NIKON_InitiateCaptureRec
InMedia"}, |
| 5844 {PTP_OC_NIKON_GetVendorStorageIDs,"PTP_OC_NIKON_GetVendorStorageIDs"}, |
| 5845 {PTP_OC_NIKON_StartMovieRecInCard,"PTP_OC_NIKON_StartMovieRecInCard"}, |
| 5846 {PTP_OC_NIKON_EndMovieRec,"PTP_OC_NIKON_EndMovieRec"}, |
| 5847 {PTP_OC_NIKON_TerminateCapture,"PTP_OC_NIKON_TerminateCapture"}, |
| 5848 {PTP_OC_NIKON_GetDevicePTPIPInfo,"PTP_OC_NIKON_GetDevicePTPIPInfo"}, |
| 5849 {PTP_OC_NIKON_GetPartialObjectHiSpeed,"PTP_OC_NIKON_GetPartialObjectHiSp
eed"}, |
| 5850 {PTP_OC_NIKON_GetDevicePropEx,"PTP_OC_NIKON_GetDevicePropEx"}, |
| 5851 }; |
| 5852 |
| 5853 ptp_opcode_trans_t ptp_opcode_canon_trans[] = { |
| 5854 {PTP_OC_CANON_GetPartialObjectInfo,"PTP_OC_CANON_GetPartialObjectInfo"}, |
| 5855 {PTP_OC_CANON_SetObjectArchive,"PTP_OC_CANON_SetObjectArchive"}, |
| 5856 {PTP_OC_CANON_KeepDeviceOn,"PTP_OC_CANON_KeepDeviceOn"}, |
| 5857 {PTP_OC_CANON_LockDeviceUI,"PTP_OC_CANON_LockDeviceUI"}, |
| 5858 {PTP_OC_CANON_UnlockDeviceUI,"PTP_OC_CANON_UnlockDeviceUI"}, |
| 5859 {PTP_OC_CANON_GetObjectHandleByName,"PTP_OC_CANON_GetObjectHandleByName"
}, |
| 5860 {PTP_OC_CANON_InitiateReleaseControl,"PTP_OC_CANON_InitiateReleaseContro
l"}, |
| 5861 {PTP_OC_CANON_TerminateReleaseControl,"PTP_OC_CANON_TerminateReleaseCont
rol"}, |
| 5862 {PTP_OC_CANON_TerminatePlaybackMode,"PTP_OC_CANON_TerminatePlaybackMode"
}, |
| 5863 {PTP_OC_CANON_ViewfinderOn,"PTP_OC_CANON_ViewfinderOn"}, |
| 5864 {PTP_OC_CANON_ViewfinderOff,"PTP_OC_CANON_ViewfinderOff"}, |
| 5865 {PTP_OC_CANON_DoAeAfAwb,"PTP_OC_CANON_DoAeAfAwb"}, |
| 5866 {PTP_OC_CANON_GetCustomizeSpec,"PTP_OC_CANON_GetCustomizeSpec"}, |
| 5867 {PTP_OC_CANON_GetCustomizeItemInfo,"PTP_OC_CANON_GetCustomizeItemInfo"}, |
| 5868 {PTP_OC_CANON_GetCustomizeData,"PTP_OC_CANON_GetCustomizeData"}, |
| 5869 {PTP_OC_CANON_SetCustomizeData,"PTP_OC_CANON_SetCustomizeData"}, |
| 5870 {PTP_OC_CANON_GetCaptureStatus,"PTP_OC_CANON_GetCaptureStatus"}, |
| 5871 {PTP_OC_CANON_CheckEvent,"PTP_OC_CANON_CheckEvent"}, |
| 5872 {PTP_OC_CANON_FocusLock,"PTP_OC_CANON_FocusLock"}, |
| 5873 {PTP_OC_CANON_FocusUnlock,"PTP_OC_CANON_FocusUnlock"}, |
| 5874 {PTP_OC_CANON_GetLocalReleaseParam,"PTP_OC_CANON_GetLocalReleaseParam"}, |
| 5875 {PTP_OC_CANON_SetLocalReleaseParam,"PTP_OC_CANON_SetLocalReleaseParam"}, |
| 5876 {PTP_OC_CANON_AskAboutPcEvf,"PTP_OC_CANON_AskAboutPcEvf"}, |
| 5877 {PTP_OC_CANON_SendPartialObject,"PTP_OC_CANON_SendPartialObject"}, |
| 5878 {PTP_OC_CANON_InitiateCaptureInMemory,"PTP_OC_CANON_InitiateCaptureInMem
ory"}, |
| 5879 {PTP_OC_CANON_GetPartialObjectEx,"PTP_OC_CANON_GetPartialObjectEx"}, |
| 5880 {PTP_OC_CANON_SetObjectTime,"PTP_OC_CANON_SetObjectTime"}, |
| 5881 {PTP_OC_CANON_GetViewfinderImage,"PTP_OC_CANON_GetViewfinderImage"}, |
| 5882 {PTP_OC_CANON_GetObjectAttributes,"PTP_OC_CANON_GetObjectAttributes"}, |
| 5883 {PTP_OC_CANON_ChangeUSBProtocol,"PTP_OC_CANON_ChangeUSBProtocol"}, |
| 5884 {PTP_OC_CANON_GetChanges,"PTP_OC_CANON_GetChanges"}, |
| 5885 {PTP_OC_CANON_GetObjectInfoEx,"PTP_OC_CANON_GetObjectInfoEx"}, |
| 5886 {PTP_OC_CANON_InitiateDirectTransfer,"PTP_OC_CANON_InitiateDirectTransfe
r"}, |
| 5887 {PTP_OC_CANON_TerminateDirectTransfer ,"PTP_OC_CANON_TerminateDirectTran
sfer "}, |
| 5888 {PTP_OC_CANON_SendObjectInfoByPath ,"PTP_OC_CANON_SendObjectInfoByPath "
}, |
| 5889 {PTP_OC_CANON_SendObjectByPath ,"PTP_OC_CANON_SendObjectByPath "}, |
| 5890 {PTP_OC_CANON_InitiateDirectTansferEx,"PTP_OC_CANON_InitiateDirectTansfe
rEx"}, |
| 5891 {PTP_OC_CANON_GetAncillaryObjectHandles,"PTP_OC_CANON_GetAncillaryObject
Handles"}, |
| 5892 {PTP_OC_CANON_GetTreeInfo ,"PTP_OC_CANON_GetTreeInfo "}, |
| 5893 {PTP_OC_CANON_GetTreeSize ,"PTP_OC_CANON_GetTreeSize "}, |
| 5894 {PTP_OC_CANON_NotifyProgress ,"PTP_OC_CANON_NotifyProgress "}, |
| 5895 {PTP_OC_CANON_NotifyCancelAccepted,"PTP_OC_CANON_NotifyCancelAccepted"}, |
| 5896 {PTP_OC_CANON_902C,"PTP_OC_CANON_902C"}, |
| 5897 {PTP_OC_CANON_GetDirectory,"PTP_OC_CANON_GetDirectory"}, |
| 5898 {PTP_OC_CANON_SetPairingInfo,"PTP_OC_CANON_SetPairingInfo"}, |
| 5899 {PTP_OC_CANON_GetPairingInfo,"PTP_OC_CANON_GetPairingInfo"}, |
| 5900 {PTP_OC_CANON_DeletePairingInfo,"PTP_OC_CANON_DeletePairingInfo"}, |
| 5901 {PTP_OC_CANON_GetMACAddress,"PTP_OC_CANON_GetMACAddress"}, |
| 5902 {PTP_OC_CANON_SetDisplayMonitor,"PTP_OC_CANON_SetDisplayMonitor"}, |
| 5903 {PTP_OC_CANON_PairingComplete,"PTP_OC_CANON_PairingComplete"}, |
| 5904 {PTP_OC_CANON_GetWirelessMAXChannel,"PTP_OC_CANON_GetWirelessMAXChannel"
}, |
| 5905 {PTP_OC_CANON_GetWebServiceSpec,"PTP_OC_CANON_GetWebServiceSpec"}, |
| 5906 {PTP_OC_CANON_GetWebServiceData,"PTP_OC_CANON_GetWebServiceData"}, |
| 5907 {PTP_OC_CANON_SetWebServiceData,"PTP_OC_CANON_SetWebServiceData"}, |
| 5908 {PTP_OC_CANON_GetRootCertificateSpec,"PTP_OC_CANON_GetRootCertificateSpe
c"}, |
| 5909 {PTP_OC_CANON_GetRootCertificateData,"PTP_OC_CANON_GetRootCertificateDat
a"}, |
| 5910 {PTP_OC_CANON_SetRootCertificateData,"PTP_OC_CANON_SetRootCertificateDat
a"}, |
| 5911 {PTP_OC_CANON_EOS_GetStorageIDs,"PTP_OC_CANON_EOS_GetStorageIDs"}, |
| 5912 {PTP_OC_CANON_EOS_GetStorageInfo,"PTP_OC_CANON_EOS_GetStorageInfo"}, |
| 5913 {PTP_OC_CANON_EOS_GetObjectInfo,"PTP_OC_CANON_EOS_GetObjectInfo"}, |
| 5914 {PTP_OC_CANON_EOS_GetObject,"PTP_OC_CANON_EOS_GetObject"}, |
| 5915 {PTP_OC_CANON_EOS_DeleteObject,"PTP_OC_CANON_EOS_DeleteObject"}, |
| 5916 {PTP_OC_CANON_EOS_FormatStore,"PTP_OC_CANON_EOS_FormatStore"}, |
| 5917 {PTP_OC_CANON_EOS_GetPartialObject,"PTP_OC_CANON_EOS_GetPartialObject"}, |
| 5918 {PTP_OC_CANON_EOS_GetDeviceInfoEx,"PTP_OC_CANON_EOS_GetDeviceInfoEx"}, |
| 5919 {PTP_OC_CANON_EOS_GetObjectInfoEx,"PTP_OC_CANON_EOS_GetObjectInfoEx"}, |
| 5920 {PTP_OC_CANON_EOS_GetThumbEx,"PTP_OC_CANON_EOS_GetThumbEx"}, |
| 5921 {PTP_OC_CANON_EOS_SendPartialObject,"PTP_OC_CANON_EOS_SendPartialObject"
}, |
| 5922 {PTP_OC_CANON_EOS_SetObjectAttributes,"PTP_OC_CANON_EOS_SetObjectAttribu
tes"}, |
| 5923 {PTP_OC_CANON_EOS_GetObjectTime,"PTP_OC_CANON_EOS_GetObjectTime"}, |
| 5924 {PTP_OC_CANON_EOS_SetObjectTime,"PTP_OC_CANON_EOS_SetObjectTime"}, |
| 5925 {PTP_OC_CANON_EOS_RemoteRelease,"PTP_OC_CANON_EOS_RemoteRelease"}, |
| 5926 {PTP_OC_CANON_EOS_SetDevicePropValueEx,"PTP_OC_CANON_EOS_SetDevicePropVa
lueEx"}, |
| 5927 {PTP_OC_CANON_EOS_GetRemoteMode,"PTP_OC_CANON_EOS_GetRemoteMode"}, |
| 5928 {PTP_OC_CANON_EOS_SetRemoteMode,"PTP_OC_CANON_EOS_SetRemoteMode"}, |
| 5929 {PTP_OC_CANON_EOS_SetEventMode,"PTP_OC_CANON_EOS_SetEventMode"}, |
| 5930 {PTP_OC_CANON_EOS_GetEvent,"PTP_OC_CANON_EOS_GetEvent"}, |
| 5931 {PTP_OC_CANON_EOS_TransferComplete,"PTP_OC_CANON_EOS_TransferComplete"}, |
| 5932 {PTP_OC_CANON_EOS_CancelTransfer,"PTP_OC_CANON_EOS_CancelTransfer"}, |
| 5933 {PTP_OC_CANON_EOS_ResetTransfer,"PTP_OC_CANON_EOS_ResetTransfer"}, |
| 5934 {PTP_OC_CANON_EOS_PCHDDCapacity,"PTP_OC_CANON_EOS_PCHDDCapacity"}, |
| 5935 {PTP_OC_CANON_EOS_SetUILock,"PTP_OC_CANON_EOS_SetUILock"}, |
| 5936 {PTP_OC_CANON_EOS_ResetUILock,"PTP_OC_CANON_EOS_ResetUILock"}, |
| 5937 {PTP_OC_CANON_EOS_KeepDeviceOn,"PTP_OC_CANON_EOS_KeepDeviceOn"}, |
| 5938 {PTP_OC_CANON_EOS_SetNullPacketMode,"PTP_OC_CANON_EOS_SetNullPacketMode"
}, |
| 5939 {PTP_OC_CANON_EOS_UpdateFirmware,"PTP_OC_CANON_EOS_UpdateFirmware"}, |
| 5940 {PTP_OC_CANON_EOS_TransferCompleteDT,"PTP_OC_CANON_EOS_TransferCompleteD
T"}, |
| 5941 {PTP_OC_CANON_EOS_CancelTransferDT,"PTP_OC_CANON_EOS_CancelTransferDT"}, |
| 5942 {PTP_OC_CANON_EOS_SetWftProfile,"PTP_OC_CANON_EOS_SetWftProfile"}, |
| 5943 {PTP_OC_CANON_EOS_GetWftProfile,"PTP_OC_CANON_EOS_GetWftProfile"}, |
| 5944 {PTP_OC_CANON_EOS_SetProfileToWft,"PTP_OC_CANON_EOS_SetProfileToWft"}, |
| 5945 {PTP_OC_CANON_EOS_BulbStart,"PTP_OC_CANON_EOS_BulbStart"}, |
| 5946 {PTP_OC_CANON_EOS_BulbEnd,"PTP_OC_CANON_EOS_BulbEnd"}, |
| 5947 {PTP_OC_CANON_EOS_RequestDevicePropValue,"PTP_OC_CANON_EOS_RequestDevice
PropValue"}, |
| 5948 {PTP_OC_CANON_EOS_RemoteReleaseOn,"PTP_OC_CANON_EOS_RemoteReleaseOn"}, |
| 5949 {PTP_OC_CANON_EOS_RemoteReleaseOff,"PTP_OC_CANON_EOS_RemoteReleaseOff"}, |
| 5950 {PTP_OC_CANON_EOS_RegistBackgroundImage,"PTP_OC_CANON_EOS_RegistBackgrou
ndImage"}, |
| 5951 {PTP_OC_CANON_EOS_ChangePhotoStudioMode,"PTP_OC_CANON_EOS_ChangePhotoStu
dioMode"}, |
| 5952 {PTP_OC_CANON_EOS_GetPartialObjectEx,"PTP_OC_CANON_EOS_GetPartialObjectE
x"}, |
| 5953 {PTP_OC_CANON_EOS_ResetMirrorLockupState,"PTP_OC_CANON_EOS_ResetMirrorLo
ckupState"}, |
| 5954 {PTP_OC_CANON_EOS_PopupBuiltinFlash,"PTP_OC_CANON_EOS_PopupBuiltinFlash"
}, |
| 5955 {PTP_OC_CANON_EOS_EndGetPartialObjectEx,"PTP_OC_CANON_EOS_EndGetPartialO
bjectEx"}, |
| 5956 {PTP_OC_CANON_EOS_MovieSelectSWOn,"PTP_OC_CANON_EOS_MovieSelectSWOn"}, |
| 5957 {PTP_OC_CANON_EOS_MovieSelectSWOff,"PTP_OC_CANON_EOS_MovieSelectSWOff"}, |
| 5958 {PTP_OC_CANON_EOS_GetCTGInfo,"PTP_OC_CANON_EOS_GetCTGInfo"}, |
| 5959 {PTP_OC_CANON_EOS_GetLensAdjust,"PTP_OC_CANON_EOS_GetLensAdjust"}, |
| 5960 {PTP_OC_CANON_EOS_SetLensAdjust,"PTP_OC_CANON_EOS_SetLensAdjust"}, |
| 5961 {PTP_OC_CANON_EOS_GetMusicInfo,"PTP_OC_CANON_EOS_GetMusicInfo"}, |
| 5962 {PTP_OC_CANON_EOS_CreateHandle,"PTP_OC_CANON_EOS_CreateHandle"}, |
| 5963 {PTP_OC_CANON_EOS_SendPartialObjectEx,"PTP_OC_CANON_EOS_SendPartialObjec
tEx"}, |
| 5964 {PTP_OC_CANON_EOS_EndSendPartialObjectEx,"PTP_OC_CANON_EOS_EndSendPartia
lObjectEx"}, |
| 5965 {PTP_OC_CANON_EOS_SetCTGInfo,"PTP_OC_CANON_EOS_SetCTGInfo"}, |
| 5966 {PTP_OC_CANON_EOS_SetRequestOLCInfoGroup,"PTP_OC_CANON_EOS_SetRequestOLC
InfoGroup"}, |
| 5967 {PTP_OC_CANON_EOS_SetRequestRollingPitchingLevel,"PTP_OC_CANON_EOS_SetRe
questRollingPitchingLevel"}, |
| 5968 {PTP_OC_CANON_EOS_GetCameraSupport,"PTP_OC_CANON_EOS_GetCameraSupport"}, |
| 5969 {PTP_OC_CANON_EOS_SetRating,"PTP_OC_CANON_EOS_SetRating"}, |
| 5970 {PTP_OC_CANON_EOS_RequestInnerDevelopStart,"PTP_OC_CANON_EOS_RequestInne
rDevelopStart"}, |
| 5971 {PTP_OC_CANON_EOS_RequestInnerDevelopParamChange,"PTP_OC_CANON_EOS_Reque
stInnerDevelopParamChange"}, |
| 5972 {PTP_OC_CANON_EOS_RequestInnerDevelopEnd,"PTP_OC_CANON_EOS_RequestInnerD
evelopEnd"}, |
| 5973 {PTP_OC_CANON_EOS_GpsLoggingDataMode,"PTP_OC_CANON_EOS_GpsLoggingDataMod
e"}, |
| 5974 {PTP_OC_CANON_EOS_GetGpsLogCurrentHandle,"PTP_OC_CANON_EOS_GetGpsLogCurr
entHandle"}, |
| 5975 {PTP_OC_CANON_EOS_InitiateViewfinder,"PTP_OC_CANON_EOS_InitiateViewfinde
r"}, |
| 5976 {PTP_OC_CANON_EOS_TerminateViewfinder,"PTP_OC_CANON_EOS_TerminateViewfin
der"}, |
| 5977 {PTP_OC_CANON_EOS_GetViewFinderData,"PTP_OC_CANON_EOS_GetViewFinderData"
}, |
| 5978 {PTP_OC_CANON_EOS_DoAf,"PTP_OC_CANON_EOS_DoAf"}, |
| 5979 {PTP_OC_CANON_EOS_DriveLens,"PTP_OC_CANON_EOS_DriveLens"}, |
| 5980 {PTP_OC_CANON_EOS_DepthOfFieldPreview,"PTP_OC_CANON_EOS_DepthOfFieldPrev
iew"}, |
| 5981 {PTP_OC_CANON_EOS_ClickWB,"PTP_OC_CANON_EOS_ClickWB"}, |
| 5982 {PTP_OC_CANON_EOS_Zoom,"PTP_OC_CANON_EOS_Zoom"}, |
| 5983 {PTP_OC_CANON_EOS_ZoomPosition,"PTP_OC_CANON_EOS_ZoomPosition"}, |
| 5984 {PTP_OC_CANON_EOS_SetLiveAfFrame,"PTP_OC_CANON_EOS_SetLiveAfFrame"}, |
| 5985 {PTP_OC_CANON_EOS_TouchAfPosition,"PTP_OC_CANON_EOS_TouchAfPosition"}, |
| 5986 {PTP_OC_CANON_EOS_SetLvPcFlavoreditMode,"PTP_OC_CANON_EOS_SetLvPcFlavore
ditMode"}, |
| 5987 {PTP_OC_CANON_EOS_SetLvPcFlavoreditParam,"PTP_OC_CANON_EOS_SetLvPcFlavor
editParam"}, |
| 5988 {PTP_OC_CANON_EOS_AfCancel,"PTP_OC_CANON_EOS_AfCancel"}, |
| 5989 {PTP_OC_CANON_EOS_SetDefaultCameraSetting,"PTP_OC_CANON_EOS_SetDefaultCa
meraSetting"}, |
| 5990 {PTP_OC_CANON_EOS_GetAEData,"PTP_OC_CANON_EOS_GetAEData"}, |
| 5991 {PTP_OC_CANON_EOS_NotifyNetworkError,"PTP_OC_CANON_EOS_NotifyNetworkErro
r"}, |
| 5992 {PTP_OC_CANON_EOS_AdapterTransferProgress,"PTP_OC_CANON_EOS_AdapterTrans
ferProgress"}, |
| 5993 {PTP_OC_CANON_EOS_TransferComplete2,"PTP_OC_CANON_EOS_TransferComplete2"
}, |
| 5994 {PTP_OC_CANON_EOS_CancelTransfer2,"PTP_OC_CANON_EOS_CancelTransfer2"}, |
| 5995 {PTP_OC_CANON_EOS_FAPIMessageTX,"PTP_OC_CANON_EOS_FAPIMessageTX"}, |
| 5996 {PTP_OC_CANON_EOS_FAPIMessageRX,"PTP_OC_CANON_EOS_FAPIMessageRX"}, |
| 5997 }; |
| 5998 |
| 5999 ptp_opcode_trans_t ptp_opcode_sony_trans[] = { |
| 6000 {PTP_OC_SONY_SDIOConnect,"PTP_OC_SONY_SDIOConnect"}, |
| 6001 {PTP_OC_SONY_GetSDIOGetExtDeviceInfo,"PTP_OC_SONY_GetSDIOGetExtDeviceInf
o"}, |
| 6002 {PTP_OC_SONY_GetDevicePropdesc,"PTP_OC_SONY_GetDevicePropdesc"}, |
| 6003 {PTP_OC_SONY_GetDevicePropertyValue,"PTP_OC_SONY_GetDevicePropertyValue"
}, |
| 6004 {PTP_OC_SONY_SetControlDeviceA,"PTP_OC_SONY_SetControlDeviceA"}, |
| 6005 {PTP_OC_SONY_GetControlDeviceDesc,"PTP_OC_SONY_GetControlDeviceDesc"}, |
| 6006 {PTP_OC_SONY_SetControlDeviceB,"PTP_OC_SONY_SetControlDeviceB"}, |
| 6007 {PTP_OC_SONY_GetAllDevicePropData,"PTP_OC_SONY_GetAllDevicePropData"}, |
| 6008 }; |
| 6009 |
| 6010 const char* |
| 6011 ptp_get_opcode_name(PTPParams* params, uint16_t opcode) |
| 5080 { | 6012 { |
| 5081 » int i; | 6013 #define RETURN_NAME_FROM_TABLE(TABLE, OPCODE) \ |
| 5082 | 6014 { \ |
| 5083 » if (!(opcode & 0x8000)) { | 6015 » unsigned int i; \ |
| 5084 » » for (i=0;i<sizeof(ptp_opcode_trans)/sizeof(ptp_opcode_trans[0]);
i++) | 6016 » for (i=0; i<sizeof(TABLE)/sizeof(TABLE[0]); i++) \ |
| 5085 » » » if (opcode == ptp_opcode_trans[i].opcode) | 6017 » » if (OPCODE == TABLE[i].opcode) \ |
| 5086 » » » » return snprintf(txt, spaceleft, "%s", _(ptp_opco
de_trans[i].name)); | 6018 » » » return _(TABLE[i].name); \ |
| 5087 » } else { | 6019 » return _("Unknown PTP_OC"); \ |
| 5088 » » switch (params->deviceinfo.VendorExtensionID) { | 6020 } |
| 5089 » » case PTP_VENDOR_MICROSOFT: | 6021 |
| 5090 » » case PTP_VENDOR_MTP: | 6022 » if (!(opcode & 0x8000)) |
| 5091 » » » for (i=0;i<sizeof(ptp_opcode_mtp_trans)/sizeof(ptp_opcod
e_mtp_trans[0]);i++) | 6023 » » RETURN_NAME_FROM_TABLE(ptp_opcode_trans, opcode); |
| 5092 » » » » if (opcode == ptp_opcode_mtp_trans[i].opcode) | 6024 |
| 5093 » » » » » return snprintf(txt, spaceleft, "%s", _(
ptp_opcode_mtp_trans[i].name)); | 6025 » switch (params->deviceinfo.VendorExtensionID) { |
| 5094 » » » break; | 6026 » case PTP_VENDOR_MICROSOFT: |
| 5095 » » default:break; | 6027 » case PTP_VENDOR_MTP:» RETURN_NAME_FROM_TABLE(ptp_opcode_mtp_trans, opc
ode); |
| 5096 » » } | 6028 » case PTP_VENDOR_NIKON:» RETURN_NAME_FROM_TABLE(ptp_opcode_nikon_trans, o
pcode); |
| 6029 » case PTP_VENDOR_CANON:» RETURN_NAME_FROM_TABLE(ptp_opcode_canon_trans, o
pcode); |
| 6030 » case PTP_VENDOR_SONY:» RETURN_NAME_FROM_TABLE(ptp_opcode_sony_trans, op
code); |
| 6031 » default: |
| 6032 » » break; |
| 5097 } | 6033 } |
| 5098 » return snprintf (txt, spaceleft,_("Unknown (%04x)"), opcode); | 6034 #undef RETURN_NAME_FROM_TABLE |
| 6035 |
| 6036 » return _("Unknown VendorExtensionID"); |
| 5099 } | 6037 } |
| 5100 | 6038 |
| 5101 | 6039 |
| 5102 struct { | 6040 struct { |
| 5103 uint16_t id; | 6041 uint16_t id; |
| 5104 const char *name; | 6042 const char *name; |
| 5105 } ptp_opc_trans[] = { | 6043 } ptp_opc_trans[] = { |
| 5106 {PTP_OPC_StorageID,"StorageID"}, | 6044 {PTP_OPC_StorageID,"StorageID"}, |
| 5107 {PTP_OPC_ObjectFormat,"ObjectFormat"}, | 6045 {PTP_OPC_ObjectFormat,"ObjectFormat"}, |
| 5108 {PTP_OPC_ProtectionStatus,"ProtectionStatus"}, | 6046 {PTP_OPC_ProtectionStatus,"ProtectionStatus"}, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5267 {PTP_OPC_VideoBitRate,"VideoBitRate"}, | 6205 {PTP_OPC_VideoBitRate,"VideoBitRate"}, |
| 5268 {PTP_OPC_FramesPerThousandSeconds,"FramesPerThousandSeconds"}, | 6206 {PTP_OPC_FramesPerThousandSeconds,"FramesPerThousandSeconds"}, |
| 5269 {PTP_OPC_KeyFrameDistance,"KeyFrameDistance"}, | 6207 {PTP_OPC_KeyFrameDistance,"KeyFrameDistance"}, |
| 5270 {PTP_OPC_BufferSize,"BufferSize"}, | 6208 {PTP_OPC_BufferSize,"BufferSize"}, |
| 5271 {PTP_OPC_EncodingQuality,"EncodingQuality"}, | 6209 {PTP_OPC_EncodingQuality,"EncodingQuality"}, |
| 5272 {PTP_OPC_EncodingProfile,"EncodingProfile"}, | 6210 {PTP_OPC_EncodingProfile,"EncodingProfile"}, |
| 5273 {PTP_OPC_BuyFlag,"BuyFlag"}, | 6211 {PTP_OPC_BuyFlag,"BuyFlag"}, |
| 5274 }; | 6212 }; |
| 5275 | 6213 |
| 5276 int | 6214 int |
| 5277 ptp_render_mtp_propname(uint16_t propid, int spaceleft, char *txt) { | 6215 ptp_render_mtp_propname(uint16_t propid, int spaceleft, char *txt) |
| 5278 » int i; | 6216 { |
| 6217 » unsigned int i; |
| 5279 for (i=0;i<sizeof(ptp_opc_trans)/sizeof(ptp_opc_trans[0]);i++) | 6218 for (i=0;i<sizeof(ptp_opc_trans)/sizeof(ptp_opc_trans[0]);i++) |
| 5280 if (propid == ptp_opc_trans[i].id) | 6219 if (propid == ptp_opc_trans[i].id) |
| 5281 return snprintf(txt, spaceleft, "%s", ptp_opc_trans[i].n
ame); | 6220 return snprintf(txt, spaceleft, "%s", ptp_opc_trans[i].n
ame); |
| 5282 return snprintf (txt, spaceleft,"unknown(%04x)", propid); | 6221 return snprintf (txt, spaceleft,"unknown(%04x)", propid); |
| 5283 } | 6222 } |
| 5284 | 6223 |
| 5285 /* | 6224 /* |
| 5286 * Allocate and default-initialize a few object properties. | 6225 * Allocate and default-initialize a few object properties. |
| 5287 */ | 6226 */ |
| 5288 MTPProperties * | 6227 MTPProperties * |
| 5289 ptp_get_new_object_prop_entry(MTPProperties **props, int *nrofprops) { | 6228 ptp_get_new_object_prop_entry(MTPProperties **props, int *nrofprops) |
| 6229 { |
| 5290 MTPProperties *newprops; | 6230 MTPProperties *newprops; |
| 5291 MTPProperties *prop; | 6231 MTPProperties *prop; |
| 5292 | 6232 |
| 5293 » if (*props == NULL) { | 6233 » newprops = realloc(*props,sizeof(MTPProperties)*(*nrofprops+1)); |
| 5294 » » newprops = malloc(sizeof(MTPProperties)*(*nrofprops+1)); | |
| 5295 » } else { | |
| 5296 » » newprops = realloc(*props,sizeof(MTPProperties)*(*nrofprops+1)); | |
| 5297 » } | |
| 5298 if (newprops == NULL) | 6234 if (newprops == NULL) |
| 5299 return NULL; | 6235 return NULL; |
| 5300 prop = &newprops[*nrofprops]; | 6236 prop = &newprops[*nrofprops]; |
| 5301 prop->property = PTP_OPC_StorageID; /* Should be "unknown" */ | 6237 prop->property = PTP_OPC_StorageID; /* Should be "unknown" */ |
| 5302 prop->datatype = PTP_DTC_UNDEF; | 6238 prop->datatype = PTP_DTC_UNDEF; |
| 5303 prop->ObjectHandle = 0x00000000U; | 6239 prop->ObjectHandle = 0x00000000U; |
| 5304 prop->propval.str = NULL; | 6240 prop->propval.str = NULL; |
| 5305 | 6241 |
| 5306 (*props) = newprops; | 6242 (*props) = newprops; |
| 5307 (*nrofprops)++; | 6243 (*nrofprops)++; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 5335 free(props); | 6271 free(props); |
| 5336 } | 6272 } |
| 5337 | 6273 |
| 5338 /* | 6274 /* |
| 5339 * Find a certain object property in the cache, i.e. a certain metadata | 6275 * Find a certain object property in the cache, i.e. a certain metadata |
| 5340 * item for a certain object handle. | 6276 * item for a certain object handle. |
| 5341 */ | 6277 */ |
| 5342 MTPProperties * | 6278 MTPProperties * |
| 5343 ptp_find_object_prop_in_cache(PTPParams *params, uint32_t const handle, uint32_t
const attribute_id) | 6279 ptp_find_object_prop_in_cache(PTPParams *params, uint32_t const handle, uint32_t
const attribute_id) |
| 5344 { | 6280 { |
| 5345 » int» i; | 6281 » unsigned int» i; |
| 5346 MTPProperties *prop; | 6282 MTPProperties *prop; |
| 5347 PTPObject *ob; | 6283 PTPObject *ob; |
| 5348 uint16_t ret; | 6284 uint16_t ret; |
| 5349 | 6285 |
| 5350 ret = ptp_object_find (params, handle, &ob); | 6286 ret = ptp_object_find (params, handle, &ob); |
| 5351 if (ret != PTP_RC_OK) | 6287 if (ret != PTP_RC_OK) |
| 5352 return NULL; | 6288 return NULL; |
| 5353 prop = ob->mtpprops; | 6289 prop = ob->mtpprops; |
| 5354 for (i=0;i<ob->nrofmtpprops;i++) { | 6290 for (i=0;i<ob->nrofmtpprops;i++) { |
| 5355 if (attribute_id == prop->property) | 6291 if (attribute_id == prop->property) |
| 5356 return prop; | 6292 return prop; |
| 5357 prop++; | 6293 prop++; |
| 5358 } | 6294 } |
| 5359 return NULL; | 6295 return NULL; |
| 5360 } | 6296 } |
| 5361 | 6297 |
| 5362 void | 6298 uint16_t |
| 5363 ptp_remove_object_from_cache(PTPParams *params, uint32_t handle) | 6299 ptp_remove_object_from_cache(PTPParams *params, uint32_t handle) |
| 5364 { | 6300 { |
| 5365 » int i; | 6301 » unsigned int i; |
| 5366 PTPObject *ob; | 6302 PTPObject *ob; |
| 5367 uint16_t ret; | |
| 5368 | 6303 |
| 5369 » ret = ptp_object_find (params, handle, &ob); | 6304 » CHECK_PTP_RC(ptp_object_find (params, handle, &ob)); |
| 5370 » if (ret != PTP_RC_OK) | |
| 5371 » » return; | |
| 5372 i = ob-params->objects; | 6305 i = ob-params->objects; |
| 5373 /* remove object from object info cache */ | 6306 /* remove object from object info cache */ |
| 5374 ptp_free_object (ob); | 6307 ptp_free_object (ob); |
| 5375 | 6308 |
| 5376 if (i < params->nrofobjects-1) | 6309 if (i < params->nrofobjects-1) |
| 5377 memmove (ob,ob+1,(params->nrofobjects-1-i)*sizeof(PTPObject)); | 6310 memmove (ob,ob+1,(params->nrofobjects-1-i)*sizeof(PTPObject)); |
| 5378 params->nrofobjects--; | 6311 params->nrofobjects--; |
| 5379 /* We use less memory than before so this shouldn't fail */ | 6312 /* We use less memory than before so this shouldn't fail */ |
| 5380 params->objects = realloc(params->objects, sizeof(PTPObject)*params->nro
fobjects); | 6313 params->objects = realloc(params->objects, sizeof(PTPObject)*params->nro
fobjects); |
| 6314 return PTP_RC_OK; |
| 5381 } | 6315 } |
| 5382 | 6316 |
| 5383 static int _cmp_ob (const void *a, const void *b) { | 6317 static int _cmp_ob (const void *a, const void *b) |
| 6318 { |
| 5384 PTPObject *oa = (PTPObject*)a; | 6319 PTPObject *oa = (PTPObject*)a; |
| 5385 PTPObject *ob = (PTPObject*)b; | 6320 PTPObject *ob = (PTPObject*)b; |
| 5386 | 6321 |
| 5387 return oa->oid - ob->oid; | 6322 return oa->oid - ob->oid; |
| 5388 } | 6323 } |
| 5389 | 6324 |
| 5390 void | 6325 void |
| 5391 ptp_objects_sort (PTPParams *params) { | 6326 ptp_objects_sort (PTPParams *params) |
| 6327 { |
| 5392 qsort (params->objects, params->nrofobjects, sizeof(PTPObject), _cmp_ob)
; | 6328 qsort (params->objects, params->nrofobjects, sizeof(PTPObject), _cmp_ob)
; |
| 5393 } | 6329 } |
| 5394 | 6330 |
| 5395 /* Binary search in objects. Needs "objects" to be a sorted by objectid list! *
/ | 6331 /* Binary search in objects. Needs "objects" to be a sorted by objectid list! *
/ |
| 5396 uint16_t | 6332 uint16_t |
| 5397 ptp_object_find (PTPParams *params, uint32_t handle, PTPObject **retob) { | 6333 ptp_object_find (PTPParams *params, uint32_t handle, PTPObject **retob) |
| 6334 { |
| 5398 PTPObject tmpob; | 6335 PTPObject tmpob; |
| 5399 | 6336 |
| 5400 tmpob.oid = handle; | 6337 tmpob.oid = handle; |
| 5401 *retob = bsearch (&tmpob, params->objects, params->nrofobjects, sizeof(t
mpob), _cmp_ob); | 6338 *retob = bsearch (&tmpob, params->objects, params->nrofobjects, sizeof(t
mpob), _cmp_ob); |
| 5402 if (!*retob) | 6339 if (!*retob) |
| 5403 return PTP_RC_GeneralError; | 6340 return PTP_RC_GeneralError; |
| 5404 return PTP_RC_OK; | 6341 return PTP_RC_OK; |
| 5405 } | 6342 } |
| 5406 | 6343 |
| 5407 /* Binary search in objects + insert of not found. Needs "objects" to be a sorte
d by objectid list! */ | 6344 /* Binary search in objects + insert of not found. Needs "objects" to be a sorte
d by objectid list! */ |
| 5408 uint16_t | 6345 uint16_t |
| 5409 ptp_object_find_or_insert (PTPParams *params, uint32_t handle, PTPObject **retob
) { | 6346 ptp_object_find_or_insert (PTPParams *params, uint32_t handle, PTPObject **retob
) |
| 5410 » int » » begin, end, cursor; | 6347 { |
| 5411 » int» » insertat; | 6348 » unsigned int » begin, end, cursor; |
| 6349 » unsigned int» insertat; |
| 5412 PTPObject *newobs; | 6350 PTPObject *newobs; |
| 5413 | 6351 |
| 5414 if (!handle) return PTP_RC_GeneralError; | 6352 if (!handle) return PTP_RC_GeneralError; |
| 5415 *retob = NULL; | 6353 *retob = NULL; |
| 5416 if (!params->nrofobjects) { | 6354 if (!params->nrofobjects) { |
| 5417 params->objects = calloc(1,sizeof(PTPObject)); | 6355 params->objects = calloc(1,sizeof(PTPObject)); |
| 5418 params->nrofobjects = 1; | 6356 params->nrofobjects = 1; |
| 5419 params->objects[0].oid = handle; | 6357 params->objects[0].oid = handle; |
| 5420 *retob = ¶ms->objects[0]; | 6358 *retob = ¶ms->objects[0]; |
| 5421 return PTP_RC_OK; | 6359 return PTP_RC_OK; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 5450 } else { | 6388 } else { |
| 5451 if ((end == params->nrofobjects-1) && (handle > params->objects[
end].oid)) | 6389 if ((end == params->nrofobjects-1) && (handle > params->objects[
end].oid)) |
| 5452 insertat=end+1; | 6390 insertat=end+1; |
| 5453 else | 6391 else |
| 5454 insertat=begin+1; | 6392 insertat=begin+1; |
| 5455 } | 6393 } |
| 5456 /*ptp_debug (params, "inserting oid %x at [%x,%x], begin=%d, end=%d, ins
ertat=%d\n", handle, params->objects[begin].oid, params->objects[end].oid, begin
, end, insertat);*/ | 6394 /*ptp_debug (params, "inserting oid %x at [%x,%x], begin=%d, end=%d, ins
ertat=%d\n", handle, params->objects[begin].oid, params->objects[end].oid, begin
, end, insertat);*/ |
| 5457 newobs = realloc (params->objects, sizeof(PTPObject)*(params->nrofobject
s+1)); | 6395 newobs = realloc (params->objects, sizeof(PTPObject)*(params->nrofobject
s+1)); |
| 5458 if (!newobs) return PTP_RC_GeneralError; | 6396 if (!newobs) return PTP_RC_GeneralError; |
| 5459 params->objects = newobs; | 6397 params->objects = newobs; |
| 5460 » if (insertat<=params->nrofobjects) | 6398 » if (insertat<params->nrofobjects) |
| 5461 memmove (¶ms->objects[insertat+1],¶ms->objects[insertat]
,(params->nrofobjects-insertat)*sizeof(PTPObject)); | 6399 memmove (¶ms->objects[insertat+1],¶ms->objects[insertat]
,(params->nrofobjects-insertat)*sizeof(PTPObject)); |
| 5462 memset(¶ms->objects[insertat],0,sizeof(PTPObject)); | 6400 memset(¶ms->objects[insertat],0,sizeof(PTPObject)); |
| 5463 params->objects[insertat].oid = handle; | 6401 params->objects[insertat].oid = handle; |
| 5464 *retob = ¶ms->objects[insertat]; | 6402 *retob = ¶ms->objects[insertat]; |
| 5465 params->nrofobjects++; | 6403 params->nrofobjects++; |
| 5466 return PTP_RC_OK; | 6404 return PTP_RC_OK; |
| 5467 } | 6405 } |
| 5468 | 6406 |
| 5469 uint16_t | 6407 uint16_t |
| 5470 ptp_object_want (PTPParams *params, uint32_t handle, int want, PTPObject **retob
) { | 6408 ptp_object_want (PTPParams *params, uint32_t handle, unsigned int want, PTPObjec
t **retob) |
| 6409 { |
| 5471 uint16_t ret; | 6410 uint16_t ret; |
| 5472 PTPObject *ob; | 6411 PTPObject *ob; |
| 5473 /*Camera *camera = ((PTPData *)params->data)->camera;*/ | 6412 /*Camera *camera = ((PTPData *)params->data)->camera;*/ |
| 5474 | 6413 |
| 5475 /* If GetObjectInfo is broken, force GetPropList */ | 6414 /* If GetObjectInfo is broken, force GetPropList */ |
| 5476 if (params->device_flags & DEVICE_FLAG_PROPLIST_OVERRIDES_OI) | 6415 if (params->device_flags & DEVICE_FLAG_PROPLIST_OVERRIDES_OI) |
| 5477 want |= PTPOBJECT_MTPPROPLIST_LOADED; | 6416 want |= PTPOBJECT_MTPPROPLIST_LOADED; |
| 5478 | 6417 |
| 5479 *retob = NULL; | 6418 *retob = NULL; |
| 5480 if (!handle) { | 6419 if (!handle) { |
| 5481 ptp_debug (params, "ptp_object_want: querying handle 0?\n"); | 6420 ptp_debug (params, "ptp_object_want: querying handle 0?\n"); |
| 5482 return PTP_RC_GeneralError; | 6421 return PTP_RC_GeneralError; |
| 5483 } | 6422 } |
| 5484 » ret = ptp_object_find_or_insert (params, handle, &ob); | 6423 » CHECK_PTP_RC(ptp_object_find_or_insert (params, handle, &ob)); |
| 5485 » if (ret != PTP_RC_OK) | |
| 5486 » » return PTP_RC_GeneralError; | |
| 5487 *retob = ob; | 6424 *retob = ob; |
| 5488 /* Do we have all of it already? */ | 6425 /* Do we have all of it already? */ |
| 5489 if ((ob->flags & want) == want) | 6426 if ((ob->flags & want) == want) |
| 5490 return PTP_RC_OK; | 6427 return PTP_RC_OK; |
| 5491 | 6428 |
| 5492 #define X (PTPOBJECT_OBJECTINFO_LOADED|PTPOBJECT_STORAGEID_LOADED|PTPOBJECT_PARE
NTOBJECT_LOADED) | 6429 #define X (PTPOBJECT_OBJECTINFO_LOADED|PTPOBJECT_STORAGEID_LOADED|PTPOBJECT_PARE
NTOBJECT_LOADED) |
| 5493 if ((want & X) && ((ob->flags & X) != X)) { | 6430 if ((want & X) && ((ob->flags & X) != X)) { |
| 5494 uint32_t saveparent = 0; | 6431 uint32_t saveparent = 0; |
| 5495 | 6432 |
| 5496 /* One EOS issue, where getobjecthandles(root) returns obs witho
ut root flag. */ | 6433 /* One EOS issue, where getobjecthandles(root) returns obs witho
ut root flag. */ |
| 5497 if (ob->flags & PTPOBJECT_PARENTOBJECT_LOADED) | 6434 if (ob->flags & PTPOBJECT_PARENTOBJECT_LOADED) |
| 5498 saveparent = ob->oi.ParentObject; | 6435 saveparent = ob->oi.ParentObject; |
| 5499 | 6436 |
| 5500 ret = ptp_getobjectinfo (params, handle, &ob->oi); | 6437 ret = ptp_getobjectinfo (params, handle, &ob->oi); |
| 5501 if (ret != PTP_RC_OK) { | 6438 if (ret != PTP_RC_OK) { |
| 5502 /* kill it from the internal list ... */ | 6439 /* kill it from the internal list ... */ |
| 5503 ptp_remove_object_from_cache(params, handle); | 6440 ptp_remove_object_from_cache(params, handle); |
| 5504 return ret; | 6441 return ret; |
| 5505 } | 6442 } |
| 5506 if (!ob->oi.Filename) ob->oi.Filename=strdup("<none>"); | 6443 if (!ob->oi.Filename) ob->oi.Filename=strdup("<none>"); |
| 5507 if (ob->flags & PTPOBJECT_PARENTOBJECT_LOADED) | 6444 if (ob->flags & PTPOBJECT_PARENTOBJECT_LOADED) |
| 5508 ob->oi.ParentObject = saveparent; | 6445 ob->oi.ParentObject = saveparent; |
| 5509 | 6446 |
| 5510 /* Second EOS issue, 0x20000000 has 0x20000000 as parent */ | 6447 /* Second EOS issue, 0x20000000 has 0x20000000 as parent */ |
| 5511 if (ob->oi.ParentObject == handle) | 6448 if (ob->oi.ParentObject == handle) |
| 5512 ob->oi.ParentObject = 0; | 6449 ob->oi.ParentObject = 0; |
| 6450 |
| 6451 /* Read out the canon special flags */ |
| 6452 if ((params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) &
& |
| 6453 ptp_operation_issupported(params,PTP_OC_CANON_GetObjectInfoE
x)) { |
| 6454 PTPCANONFolderEntry *ents = NULL; |
| 6455 uint32_t numents = 0; |
| 6456 |
| 6457 ret = ptp_canon_getobjectinfo(params, |
| 6458 ob->oi.StorageID,0, |
| 6459 ob->oi.ParentObject,handle, |
| 6460 &ents,&numents |
| 6461 ); |
| 6462 if ((ret == PTP_RC_OK) && (numents >= 1)) |
| 6463 ob->canon_flags = ents[0].Flags; |
| 6464 free (ents); |
| 6465 } |
| 6466 |
| 5513 ob->flags |= X; | 6467 ob->flags |= X; |
| 5514 | |
| 5515 /* EOS bug, DCIM links back to itself. */ | |
| 5516 } | 6468 } |
| 5517 #undef X | 6469 #undef X |
| 5518 if ( (want & PTPOBJECT_MTPPROPLIST_LOADED) && | 6470 if ( (want & PTPOBJECT_MTPPROPLIST_LOADED) && |
| 5519 (!(ob->flags & PTPOBJECT_MTPPROPLIST_LOADED)) | 6471 (!(ob->flags & PTPOBJECT_MTPPROPLIST_LOADED)) |
| 5520 ) { | 6472 ) { |
| 5521 int nrofprops = 0; | 6473 int nrofprops = 0; |
| 5522 MTPProperties *props = NULL; | 6474 MTPProperties *props = NULL; |
| 5523 | 6475 |
| 5524 if (params->device_flags & DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST)
{ | 6476 if (params->device_flags & DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST)
{ |
| 5525 want &= ~PTPOBJECT_MTPPROPLIST_LOADED; | 6477 want &= ~PTPOBJECT_MTPPROPLIST_LOADED; |
| 5526 goto fallback; | 6478 goto fallback; |
| 5527 } | 6479 } |
| 5528 /* Microsoft/MTP has fast directory retrieval. */ | 6480 /* Microsoft/MTP has fast directory retrieval. */ |
| 5529 if (!ptp_operation_issupported(params,PTP_OC_MTP_GetObjPropList)
) { | 6481 if (!ptp_operation_issupported(params,PTP_OC_MTP_GetObjPropList)
) { |
| 5530 want &= ~PTPOBJECT_MTPPROPLIST_LOADED; | 6482 want &= ~PTPOBJECT_MTPPROPLIST_LOADED; |
| 5531 goto fallback; | 6483 goto fallback; |
| 5532 } | 6484 } |
| 5533 | 6485 |
| 5534 ptp_debug (params, "ptp2/mtpfast: reading mtp proplist of %08x",
handle); | 6486 ptp_debug (params, "ptp2/mtpfast: reading mtp proplist of %08x",
handle); |
| 5535 /* We just want this one object, not all at once. */ | 6487 /* We just want this one object, not all at once. */ |
| 5536 ret = ptp_mtp_getobjectproplist_single (params, handle, &props,
&nrofprops); | 6488 ret = ptp_mtp_getobjectproplist_single (params, handle, &props,
&nrofprops); |
| 5537 if (ret != PTP_RC_OK) | 6489 if (ret != PTP_RC_OK) |
| 5538 goto fallback; | 6490 goto fallback; |
| 5539 ob->mtpprops = props; | 6491 ob->mtpprops = props; |
| 5540 ob->nrofmtpprops = nrofprops; | 6492 ob->nrofmtpprops = nrofprops; |
| 5541 | 6493 |
| 5542 /* Override the ObjectInfo data with data from properties */ | 6494 /* Override the ObjectInfo data with data from properties */ |
| 5543 if (params->device_flags & DEVICE_FLAG_PROPLIST_OVERRIDES_OI) { | 6495 if (params->device_flags & DEVICE_FLAG_PROPLIST_OVERRIDES_OI) { |
| 5544 » » » int i; | 6496 » » » unsigned int i; |
| 5545 MTPProperties *prop = ob->mtpprops; | 6497 MTPProperties *prop = ob->mtpprops; |
| 5546 | 6498 |
| 5547 for (i=0;i<ob->nrofmtpprops;i++,prop++) { | 6499 for (i=0;i<ob->nrofmtpprops;i++,prop++) { |
| 5548 /* in case we got all subtree objects */ | 6500 /* in case we got all subtree objects */ |
| 5549 if (prop->ObjectHandle != handle) continue; | 6501 if (prop->ObjectHandle != handle) continue; |
| 5550 | 6502 |
| 5551 switch (prop->property) { | 6503 switch (prop->property) { |
| 5552 case PTP_OPC_StorageID: | 6504 case PTP_OPC_StorageID: |
| 5553 ob->oi.StorageID = prop->propval.u32; | 6505 ob->oi.StorageID = prop->propval.u32; |
| 5554 break; | 6506 break; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5702 return PTP_RC_GeneralError; | 6654 return PTP_RC_GeneralError; |
| 5703 } | 6655 } |
| 5704 | 6656 |
| 5705 | 6657 |
| 5706 uint16_t | 6658 uint16_t |
| 5707 ptp_add_object_to_cache(PTPParams *params, uint32_t handle) | 6659 ptp_add_object_to_cache(PTPParams *params, uint32_t handle) |
| 5708 { | 6660 { |
| 5709 PTPObject *ob; | 6661 PTPObject *ob; |
| 5710 return ptp_object_want (params, handle, PTPOBJECT_OBJECTINFO_LOADED|PTPO
BJECT_MTPPROPLIST_LOADED, &ob); | 6662 return ptp_object_want (params, handle, PTPOBJECT_OBJECTINFO_LOADED|PTPO
BJECT_MTPPROPLIST_LOADED, &ob); |
| 5711 } | 6663 } |
| OLD | NEW |