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