blob: 5ba6cc76d315cfd2bc1870e26954faf60e73770b [file] [log] [blame]
Linus Walleijeb8c6fe2006-02-03 09:46:22 +00001/**
2 * \file libmtp.h
Linus Walleijeb8c6fe2006-02-03 09:46:22 +00003 * Interface to the Media Transfer Protocol library.
4 *
Linus Walleija3895612013-04-29 21:56:38 +02005 * Copyright (C) 2005-2013 Linus Walleij <triad@df.lth.se>
Richard Low36e447c2008-01-20 15:24:55 +00006 * Copyright (C) 2005-2008 Richard A. Low <richard@wentnet.com>
Linus Walleijde8193f2008-01-27 14:55:31 +00007 * Copyright (C) 2007 Ted Bullock <tbullock@canada.com>
8 * Copyright (C) 2008 Florent Mertens <flomertens@gmail.com>
Linus Walleij7b7a0e22007-02-05 18:22:27 +00009 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 02111-1307, USA.
24 *
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000025 * <code>
26 * #include <libmtp.h>
27 * </code>
28 */
29#ifndef LIBMTP_H_INCLUSION_GUARD
30#define LIBMTP_H_INCLUSION_GUARD
31
32#define LIBMTP_VERSION @VERSION@
tedbullockcd9f4992007-03-29 06:00:40 +000033#define LIBMTP_VERSION_STRING "@VERSION@"
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000034
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000035/* This handles MSVC pecularities */
36#ifdef _MSC_VER
37#include <windows.h>
38#define __WIN32__
39#define snprintf _snprintf
40#define ssize_t SSIZE_T
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000041/*
Linus Walleij5b4a4d22009-01-10 12:18:14 +000042 * Types that do not exist in Windows
43 * sys/types.h, but they exist in mingw32
44 * sys/types.h.
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000045 */
46typedef char int8_t;
47typedef unsigned char uint8_t;
48typedef __int16 int16_t;
49typedef unsigned __int16 uint16_t;
50typedef __int32 int32_t;
51typedef unsigned __int32 uint32_t;
52typedef unsigned __int64 uint64_t;
Philip Langdale0a576512016-04-09 14:22:25 -070053#else
54#include <sys/time.h>
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000055#endif
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000056
Linus Walleij5b4a4d22009-01-10 12:18:14 +000057#include <stdio.h>
Linus Walleij5b4a4d22009-01-10 12:18:14 +000058#include <stdint.h>
Linus Walleijcbc5e812010-01-02 00:25:58 +000059/* We use time_t */
60#include <time.h>
Jerry Zhang60d02262017-06-08 18:19:59 -070061#include <utime.h>
Linus Walleij5b4a4d22009-01-10 12:18:14 +000062
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000063/**
Linus Walleij438bd7f2006-06-08 11:35:44 +000064 * @defgroup types libmtp global type definitions
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000065 * @{
nicklas7903584082009-09-28 18:20:16 +000066 */
67
68/**
69 * The debug flags defined here are the external flags used
70 * by the libmtp library interface.
Catalin Patulea406d5f92012-07-20 19:00:24 -040071 *
72 * Please keep this list in sync with libmtp.c.
nicklas7903584082009-09-28 18:20:16 +000073 */
74#define LIBMTP_DEBUG_NONE 0x00
75#define LIBMTP_DEBUG_PTP 0x01
76#define LIBMTP_DEBUG_PLST 0x02
77#define LIBMTP_DEBUG_USB 0x04
78#define LIBMTP_DEBUG_DATA 0x08
79#define LIBMTP_DEBUG_ALL 0xFF
80
81
82/**
Linus Walleij83f57eb2006-05-31 19:57:56 +000083 * The filetypes defined here are the external types used
84 * by the libmtp library interface. The types used internally
85 * as PTP-defined enumerator types is something different.
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000086 */
Linus Walleijb9256fd2006-02-15 09:40:43 +000087typedef enum {
Linus Walleija8b88892011-03-03 19:58:26 +010088 LIBMTP_FILETYPE_FOLDER,
Linus Walleijf6bc1782006-03-24 15:12:47 +000089 LIBMTP_FILETYPE_WAV,
90 LIBMTP_FILETYPE_MP3,
91 LIBMTP_FILETYPE_WMA,
Linus Walleij9c6ca022006-04-21 10:24:15 +000092 LIBMTP_FILETYPE_OGG,
Linus Walleije46f12e2006-06-22 17:53:25 +000093 LIBMTP_FILETYPE_AUDIBLE,
Linus Walleij9c6ca022006-04-21 10:24:15 +000094 LIBMTP_FILETYPE_MP4,
95 LIBMTP_FILETYPE_UNDEF_AUDIO,
Linus Walleijf6bc1782006-03-24 15:12:47 +000096 LIBMTP_FILETYPE_WMV,
97 LIBMTP_FILETYPE_AVI,
98 LIBMTP_FILETYPE_MPEG,
99 LIBMTP_FILETYPE_ASF,
100 LIBMTP_FILETYPE_QT,
Linus Walleij9c6ca022006-04-21 10:24:15 +0000101 LIBMTP_FILETYPE_UNDEF_VIDEO,
Linus Walleij83f57eb2006-05-31 19:57:56 +0000102 LIBMTP_FILETYPE_JPEG,
Linus Walleijf6bc1782006-03-24 15:12:47 +0000103 LIBMTP_FILETYPE_JFIF,
104 LIBMTP_FILETYPE_TIFF,
105 LIBMTP_FILETYPE_BMP,
106 LIBMTP_FILETYPE_GIF,
107 LIBMTP_FILETYPE_PICT,
108 LIBMTP_FILETYPE_PNG,
Linus Walleij16c51f02006-05-04 13:20:22 +0000109 LIBMTP_FILETYPE_VCALENDAR1,
110 LIBMTP_FILETYPE_VCALENDAR2,
111 LIBMTP_FILETYPE_VCARD2,
112 LIBMTP_FILETYPE_VCARD3,
113 LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT,
114 LIBMTP_FILETYPE_WINEXEC,
115 LIBMTP_FILETYPE_TEXT,
116 LIBMTP_FILETYPE_HTML,
Linus Walleija05b9802006-12-08 08:50:30 +0000117 LIBMTP_FILETYPE_FIRMWARE,
Linus Walleij5fb47132006-12-30 15:35:48 +0000118 LIBMTP_FILETYPE_AAC,
119 LIBMTP_FILETYPE_MEDIACARD,
120 LIBMTP_FILETYPE_FLAC,
121 LIBMTP_FILETYPE_MP2,
122 LIBMTP_FILETYPE_M4A,
123 LIBMTP_FILETYPE_DOC,
124 LIBMTP_FILETYPE_XML,
125 LIBMTP_FILETYPE_XLS,
126 LIBMTP_FILETYPE_PPT,
127 LIBMTP_FILETYPE_MHT,
128 LIBMTP_FILETYPE_JP2,
129 LIBMTP_FILETYPE_JPX,
Richard Lowd3b17022009-04-11 12:37:39 +0000130 LIBMTP_FILETYPE_ALBUM,
131 LIBMTP_FILETYPE_PLAYLIST,
Linus Walleijf6bc1782006-03-24 15:12:47 +0000132 LIBMTP_FILETYPE_UNKNOWN
133} LIBMTP_filetype_t;
Linus Walleij10e0ce72008-05-04 19:20:33 +0000134
135/**
Linus Walleij2832a202008-09-17 18:58:20 +0000136 * \def LIBMTP_FILETYPE_IS_AUDIO
137 * Audio filetype test.
138 *
139 * For filetypes that can be either audio
140 * or video, use LIBMTP_FILETYPE_IS_AUDIOVIDEO
Linus Walleij10e0ce72008-05-04 19:20:33 +0000141 */
142#define LIBMTP_FILETYPE_IS_AUDIO(a)\
143(a == LIBMTP_FILETYPE_WAV ||\
144 a == LIBMTP_FILETYPE_MP3 ||\
145 a == LIBMTP_FILETYPE_MP2 ||\
146 a == LIBMTP_FILETYPE_WMA ||\
147 a == LIBMTP_FILETYPE_OGG ||\
148 a == LIBMTP_FILETYPE_FLAC ||\
149 a == LIBMTP_FILETYPE_AAC ||\
150 a == LIBMTP_FILETYPE_M4A ||\
Richard Low6f070842009-05-03 10:26:16 +0000151 a == LIBMTP_FILETYPE_AUDIBLE ||\
Linus Walleij10e0ce72008-05-04 19:20:33 +0000152 a == LIBMTP_FILETYPE_UNDEF_AUDIO)
Linus Walleij2832a202008-09-17 18:58:20 +0000153
154/**
155 * \def LIBMTP_FILETYPE_IS_VIDEO
156 * Video filetype test.
157 *
158 * For filetypes that can be either audio
159 * or video, use LIBMTP_FILETYPE_IS_AUDIOVIDEO
160 */
Linus Walleij10e0ce72008-05-04 19:20:33 +0000161#define LIBMTP_FILETYPE_IS_VIDEO(a)\
162(a == LIBMTP_FILETYPE_WMV ||\
163 a == LIBMTP_FILETYPE_AVI ||\
164 a == LIBMTP_FILETYPE_MPEG ||\
165 a == LIBMTP_FILETYPE_UNDEF_VIDEO)
Linus Walleij2832a202008-09-17 18:58:20 +0000166
167/**
168 * \def LIBMTP_FILETYPE_IS_AUDIOVIDEO
169 * Audio and&slash;or video filetype test.
170 */
Linus Walleij10e0ce72008-05-04 19:20:33 +0000171#define LIBMTP_FILETYPE_IS_AUDIOVIDEO(a)\
172(a == LIBMTP_FILETYPE_MP4 ||\
173 a == LIBMTP_FILETYPE_ASF ||\
174 a == LIBMTP_FILETYPE_QT)
Linus Walleij2832a202008-09-17 18:58:20 +0000175
176/**
177 * \def LIBMTP_FILETYPE_IS_TRACK
178 * Test if filetype is a track.
179 * Use this to determine if the File API or Track API
180 * should be used to upload or download an object.
181 */
Linus Walleij10e0ce72008-05-04 19:20:33 +0000182#define LIBMTP_FILETYPE_IS_TRACK(a)\
183(LIBMTP_FILETYPE_IS_AUDIO(a) ||\
184 LIBMTP_FILETYPE_IS_VIDEO(a) ||\
185 LIBMTP_FILETYPE_IS_AUDIOVIDEO(a))
186
Linus Walleij2715c442007-01-20 22:35:29 +0000187/**
Linus Walleij2832a202008-09-17 18:58:20 +0000188 * \def LIBMTP_FILETYPE_IS_IMAGE
189 * Image filetype test
190 */
191#define LIBMTP_FILETYPE_IS_IMAGE(a)\
192(a == LIBMTP_FILETYPE_JPEG ||\
193a == LIBMTP_FILETYPE_JFIF ||\
194a == LIBMTP_FILETYPE_TIFF ||\
195a == LIBMTP_FILETYPE_BMP ||\
196a == LIBMTP_FILETYPE_GIF ||\
197a == LIBMTP_FILETYPE_PICT ||\
198a == LIBMTP_FILETYPE_PNG ||\
199a == LIBMTP_FILETYPE_JP2 ||\
200a == LIBMTP_FILETYPE_JPX ||\
201a == LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT)
202
203/**
204 * \def LIBMTP_FILETYPE_IS_ADDRESSBOOK
205 * Addressbook and Business card filetype test
206 */
207#define LIBMTP_FILETYPE_IS_ADDRESSBOOK(a)\
208(a == LIBMTP_FILETYPE_VCARD2 ||\
Linus Walleijf9424812012-06-27 22:16:57 +0200209a == LIBMTP_FILETYPE_VCARD3)
Linus Walleij2832a202008-09-17 18:58:20 +0000210
211/**
212 * \def LIBMTP_FILETYPE_IS_CALENDAR
213 * Calendar and Appointment filetype test
214 */
215#define LIBMTP_FILETYPE_IS_CALENDAR(a)\
216(a == LIBMTP_FILETYPE_VCALENDAR1 ||\
217a == LIBMTP_FILETYPE_VCALENDAR2)
218
219/**
Richard Low6f070842009-05-03 10:26:16 +0000220 * The properties defined here are the external types used
221 * by the libmtp library interface.
222 */
223typedef enum {
224 LIBMTP_PROPERTY_StorageID,
225 LIBMTP_PROPERTY_ObjectFormat,
226 LIBMTP_PROPERTY_ProtectionStatus,
227 LIBMTP_PROPERTY_ObjectSize,
228 LIBMTP_PROPERTY_AssociationType,
229 LIBMTP_PROPERTY_AssociationDesc,
230 LIBMTP_PROPERTY_ObjectFileName,
231 LIBMTP_PROPERTY_DateCreated,
232 LIBMTP_PROPERTY_DateModified,
233 LIBMTP_PROPERTY_Keywords,
234 LIBMTP_PROPERTY_ParentObject,
235 LIBMTP_PROPERTY_AllowedFolderContents,
236 LIBMTP_PROPERTY_Hidden,
237 LIBMTP_PROPERTY_SystemObject,
238 LIBMTP_PROPERTY_PersistantUniqueObjectIdentifier,
239 LIBMTP_PROPERTY_SyncID,
240 LIBMTP_PROPERTY_PropertyBag,
241 LIBMTP_PROPERTY_Name,
242 LIBMTP_PROPERTY_CreatedBy,
243 LIBMTP_PROPERTY_Artist,
244 LIBMTP_PROPERTY_DateAuthored,
245 LIBMTP_PROPERTY_Description,
246 LIBMTP_PROPERTY_URLReference,
247 LIBMTP_PROPERTY_LanguageLocale,
248 LIBMTP_PROPERTY_CopyrightInformation,
249 LIBMTP_PROPERTY_Source,
250 LIBMTP_PROPERTY_OriginLocation,
251 LIBMTP_PROPERTY_DateAdded,
252 LIBMTP_PROPERTY_NonConsumable,
253 LIBMTP_PROPERTY_CorruptOrUnplayable,
254 LIBMTP_PROPERTY_ProducerSerialNumber,
255 LIBMTP_PROPERTY_RepresentativeSampleFormat,
256 LIBMTP_PROPERTY_RepresentativeSampleSize,
257 LIBMTP_PROPERTY_RepresentativeSampleHeight,
258 LIBMTP_PROPERTY_RepresentativeSampleWidth,
259 LIBMTP_PROPERTY_RepresentativeSampleDuration,
260 LIBMTP_PROPERTY_RepresentativeSampleData,
261 LIBMTP_PROPERTY_Width,
262 LIBMTP_PROPERTY_Height,
263 LIBMTP_PROPERTY_Duration,
264 LIBMTP_PROPERTY_Rating,
265 LIBMTP_PROPERTY_Track,
266 LIBMTP_PROPERTY_Genre,
267 LIBMTP_PROPERTY_Credits,
268 LIBMTP_PROPERTY_Lyrics,
269 LIBMTP_PROPERTY_SubscriptionContentID,
270 LIBMTP_PROPERTY_ProducedBy,
271 LIBMTP_PROPERTY_UseCount,
272 LIBMTP_PROPERTY_SkipCount,
273 LIBMTP_PROPERTY_LastAccessed,
274 LIBMTP_PROPERTY_ParentalRating,
275 LIBMTP_PROPERTY_MetaGenre,
276 LIBMTP_PROPERTY_Composer,
277 LIBMTP_PROPERTY_EffectiveRating,
278 LIBMTP_PROPERTY_Subtitle,
279 LIBMTP_PROPERTY_OriginalReleaseDate,
280 LIBMTP_PROPERTY_AlbumName,
281 LIBMTP_PROPERTY_AlbumArtist,
282 LIBMTP_PROPERTY_Mood,
283 LIBMTP_PROPERTY_DRMStatus,
284 LIBMTP_PROPERTY_SubDescription,
285 LIBMTP_PROPERTY_IsCropped,
286 LIBMTP_PROPERTY_IsColorCorrected,
287 LIBMTP_PROPERTY_ImageBitDepth,
288 LIBMTP_PROPERTY_Fnumber,
289 LIBMTP_PROPERTY_ExposureTime,
290 LIBMTP_PROPERTY_ExposureIndex,
291 LIBMTP_PROPERTY_DisplayName,
292 LIBMTP_PROPERTY_BodyText,
293 LIBMTP_PROPERTY_Subject,
294 LIBMTP_PROPERTY_Priority,
295 LIBMTP_PROPERTY_GivenName,
296 LIBMTP_PROPERTY_MiddleNames,
297 LIBMTP_PROPERTY_FamilyName,
298 LIBMTP_PROPERTY_Prefix,
299 LIBMTP_PROPERTY_Suffix,
300 LIBMTP_PROPERTY_PhoneticGivenName,
301 LIBMTP_PROPERTY_PhoneticFamilyName,
302 LIBMTP_PROPERTY_EmailPrimary,
303 LIBMTP_PROPERTY_EmailPersonal1,
304 LIBMTP_PROPERTY_EmailPersonal2,
305 LIBMTP_PROPERTY_EmailBusiness1,
306 LIBMTP_PROPERTY_EmailBusiness2,
307 LIBMTP_PROPERTY_EmailOthers,
308 LIBMTP_PROPERTY_PhoneNumberPrimary,
309 LIBMTP_PROPERTY_PhoneNumberPersonal,
310 LIBMTP_PROPERTY_PhoneNumberPersonal2,
311 LIBMTP_PROPERTY_PhoneNumberBusiness,
312 LIBMTP_PROPERTY_PhoneNumberBusiness2,
313 LIBMTP_PROPERTY_PhoneNumberMobile,
314 LIBMTP_PROPERTY_PhoneNumberMobile2,
315 LIBMTP_PROPERTY_FaxNumberPrimary,
316 LIBMTP_PROPERTY_FaxNumberPersonal,
317 LIBMTP_PROPERTY_FaxNumberBusiness,
318 LIBMTP_PROPERTY_PagerNumber,
319 LIBMTP_PROPERTY_PhoneNumberOthers,
320 LIBMTP_PROPERTY_PrimaryWebAddress,
321 LIBMTP_PROPERTY_PersonalWebAddress,
322 LIBMTP_PROPERTY_BusinessWebAddress,
323 LIBMTP_PROPERTY_InstantMessengerAddress,
324 LIBMTP_PROPERTY_InstantMessengerAddress2,
325 LIBMTP_PROPERTY_InstantMessengerAddress3,
326 LIBMTP_PROPERTY_PostalAddressPersonalFull,
327 LIBMTP_PROPERTY_PostalAddressPersonalFullLine1,
328 LIBMTP_PROPERTY_PostalAddressPersonalFullLine2,
329 LIBMTP_PROPERTY_PostalAddressPersonalFullCity,
330 LIBMTP_PROPERTY_PostalAddressPersonalFullRegion,
331 LIBMTP_PROPERTY_PostalAddressPersonalFullPostalCode,
332 LIBMTP_PROPERTY_PostalAddressPersonalFullCountry,
333 LIBMTP_PROPERTY_PostalAddressBusinessFull,
334 LIBMTP_PROPERTY_PostalAddressBusinessLine1,
335 LIBMTP_PROPERTY_PostalAddressBusinessLine2,
336 LIBMTP_PROPERTY_PostalAddressBusinessCity,
337 LIBMTP_PROPERTY_PostalAddressBusinessRegion,
338 LIBMTP_PROPERTY_PostalAddressBusinessPostalCode,
339 LIBMTP_PROPERTY_PostalAddressBusinessCountry,
340 LIBMTP_PROPERTY_PostalAddressOtherFull,
341 LIBMTP_PROPERTY_PostalAddressOtherLine1,
342 LIBMTP_PROPERTY_PostalAddressOtherLine2,
343 LIBMTP_PROPERTY_PostalAddressOtherCity,
344 LIBMTP_PROPERTY_PostalAddressOtherRegion,
345 LIBMTP_PROPERTY_PostalAddressOtherPostalCode,
346 LIBMTP_PROPERTY_PostalAddressOtherCountry,
347 LIBMTP_PROPERTY_OrganizationName,
348 LIBMTP_PROPERTY_PhoneticOrganizationName,
349 LIBMTP_PROPERTY_Role,
350 LIBMTP_PROPERTY_Birthdate,
351 LIBMTP_PROPERTY_MessageTo,
352 LIBMTP_PROPERTY_MessageCC,
353 LIBMTP_PROPERTY_MessageBCC,
354 LIBMTP_PROPERTY_MessageRead,
355 LIBMTP_PROPERTY_MessageReceivedTime,
356 LIBMTP_PROPERTY_MessageSender,
357 LIBMTP_PROPERTY_ActivityBeginTime,
358 LIBMTP_PROPERTY_ActivityEndTime,
359 LIBMTP_PROPERTY_ActivityLocation,
360 LIBMTP_PROPERTY_ActivityRequiredAttendees,
361 LIBMTP_PROPERTY_ActivityOptionalAttendees,
362 LIBMTP_PROPERTY_ActivityResources,
363 LIBMTP_PROPERTY_ActivityAccepted,
364 LIBMTP_PROPERTY_Owner,
365 LIBMTP_PROPERTY_Editor,
366 LIBMTP_PROPERTY_Webmaster,
367 LIBMTP_PROPERTY_URLSource,
368 LIBMTP_PROPERTY_URLDestination,
369 LIBMTP_PROPERTY_TimeBookmark,
370 LIBMTP_PROPERTY_ObjectBookmark,
371 LIBMTP_PROPERTY_ByteBookmark,
372 LIBMTP_PROPERTY_LastBuildDate,
373 LIBMTP_PROPERTY_TimetoLive,
374 LIBMTP_PROPERTY_MediaGUID,
375 LIBMTP_PROPERTY_TotalBitRate,
376 LIBMTP_PROPERTY_BitRateType,
377 LIBMTP_PROPERTY_SampleRate,
378 LIBMTP_PROPERTY_NumberOfChannels,
379 LIBMTP_PROPERTY_AudioBitDepth,
380 LIBMTP_PROPERTY_ScanDepth,
381 LIBMTP_PROPERTY_AudioWAVECodec,
382 LIBMTP_PROPERTY_AudioBitRate,
383 LIBMTP_PROPERTY_VideoFourCCCodec,
384 LIBMTP_PROPERTY_VideoBitRate,
385 LIBMTP_PROPERTY_FramesPerThousandSeconds,
386 LIBMTP_PROPERTY_KeyFrameDistance,
387 LIBMTP_PROPERTY_BufferSize,
388 LIBMTP_PROPERTY_EncodingQuality,
389 LIBMTP_PROPERTY_EncodingProfile,
390 LIBMTP_PROPERTY_BuyFlag,
391 LIBMTP_PROPERTY_UNKNOWN
392} LIBMTP_property_t;
393
394/**
395 * These are the data types
396 */
397typedef enum {
398 LIBMTP_DATATYPE_INT8,
399 LIBMTP_DATATYPE_UINT8,
400 LIBMTP_DATATYPE_INT16,
401 LIBMTP_DATATYPE_UINT16,
402 LIBMTP_DATATYPE_INT32,
403 LIBMTP_DATATYPE_UINT32,
404 LIBMTP_DATATYPE_INT64,
405 LIBMTP_DATATYPE_UINT64,
406} LIBMTP_datatype_t;
407
408/**
Linus Walleija3895612013-04-29 21:56:38 +0200409 * These are device capabilities
410 */
411typedef enum {
412 /**
413 * This capability tells whether you can call the funcion getting
414 * partial objects, @see LIBMTP_GetPartialObject()
415 */
416 LIBMTP_DEVICECAP_GetPartialObject,
417 /**
418 * This capability tells whether you can call the function sending
419 * partial objects. @see LIBMTP_SendPartialObject()
420 */
421 LIBMTP_DEVICECAP_SendPartialObject,
422 /**
423 * This capability tells whether you can call the functions editing
424 * objects in-place on a device.
425 * @see LIBMTP_BeginEditObject()
426 * @see LIBMTP_EndEditObject()
427 * @see LIBMTP_TruncateObject()
428 */
429 LIBMTP_DEVICECAP_EditObjects,
430} LIBMTP_devicecap_t;
431
432/**
Linus Walleij2715c442007-01-20 22:35:29 +0000433 * These are the numbered error codes. You can also
434 * get string representations for errors.
435 */
436typedef enum {
437 LIBMTP_ERROR_NONE,
Linus Walleij2e1c8a32007-01-22 06:46:08 +0000438 LIBMTP_ERROR_GENERAL,
Linus Walleij070e9b42007-01-22 08:49:28 +0000439 LIBMTP_ERROR_PTP_LAYER,
440 LIBMTP_ERROR_USB_LAYER,
441 LIBMTP_ERROR_MEMORY_ALLOCATION,
tedbullock433d2172007-02-23 22:39:12 +0000442 LIBMTP_ERROR_NO_DEVICE_ATTACHED,
Linus Walleij550d6d52007-01-24 14:32:51 +0000443 LIBMTP_ERROR_STORAGE_FULL,
Linus Walleij25d33b52007-09-16 21:36:19 +0000444 LIBMTP_ERROR_CONNECTING,
445 LIBMTP_ERROR_CANCELLED
Linus Walleij2715c442007-01-20 22:35:29 +0000446} LIBMTP_error_number_t;
Linus Walleij38d7ee82010-07-24 22:17:21 +0000447
Linus Walleij6fd2f082006-03-28 07:19:22 +0000448typedef struct LIBMTP_device_entry_struct LIBMTP_device_entry_t; /**< @see LIBMTP_device_entry_struct */
Linus Walleij63fd1e62008-04-23 23:49:43 +0000449typedef struct LIBMTP_raw_device_struct LIBMTP_raw_device_t; /**< @see LIBMTP_raw_device_struct */
Linus Walleij2715c442007-01-20 22:35:29 +0000450typedef struct LIBMTP_error_struct LIBMTP_error_t; /**< @see LIBMTP_error_struct */
Richard Low6f070842009-05-03 10:26:16 +0000451typedef struct LIBMTP_allowed_values_struct LIBMTP_allowed_values_t; /**< @see LIBMTP_allowed_values_struct */
Linus Walleij38d7ee82010-07-24 22:17:21 +0000452typedef struct LIBMTP_device_extension_struct LIBMTP_device_extension_t; /** < @see LIBMTP_device_extension_struct */
Linus Walleijb9256fd2006-02-15 09:40:43 +0000453typedef struct LIBMTP_mtpdevice_struct LIBMTP_mtpdevice_t; /**< @see LIBMTP_mtpdevice_struct */
Linus Walleijf6bc1782006-03-24 15:12:47 +0000454typedef struct LIBMTP_file_struct LIBMTP_file_t; /**< @see LIBMTP_file_struct */
455typedef struct LIBMTP_track_struct LIBMTP_track_t; /**< @see LIBMTP_track_struct */
Linus Walleij438bd7f2006-06-08 11:35:44 +0000456typedef struct LIBMTP_playlist_struct LIBMTP_playlist_t; /**< @see LIBMTP_playlist_struct */
Linus Walleij0c33ec02006-10-27 10:15:40 +0000457typedef struct LIBMTP_album_struct LIBMTP_album_t; /**< @see LIBMTP_album_struct */
raveloxd9a28642006-05-26 23:42:22 +0000458typedef struct LIBMTP_folder_struct LIBMTP_folder_t; /**< @see LIBMTP_folder_t */
459typedef struct LIBMTP_object_struct LIBMTP_object_t; /**< @see LIBMTP_object_t */
rreardon5332f9c2006-12-05 10:18:23 +0000460typedef struct LIBMTP_filesampledata_struct LIBMTP_filesampledata_t; /**< @see LIBMTP_filesample_t */
Linus Walleij9e1b0812006-12-12 19:22:02 +0000461typedef struct LIBMTP_devicestorage_struct LIBMTP_devicestorage_t; /**< @see LIBMTP_devicestorage_t */
Linus Walleij438bd7f2006-06-08 11:35:44 +0000462
mopoke31364442006-11-20 04:53:04 +0000463/**
Linus Walleij438bd7f2006-06-08 11:35:44 +0000464 * The callback type definition. Notice that a progress percentage ratio
mopoke31364442006-11-20 04:53:04 +0000465 * is easy to calculate by dividing <code>sent</code> by
Linus Walleij438bd7f2006-06-08 11:35:44 +0000466 * <code>total</code>.
467 * @param sent the number of bytes sent so far
468 * @param total the total number of bytes to send
469 * @param data a user-defined dereferencable pointer
470 * @return if anything else than 0 is returned, the current transfer will be
471 * interrupted / cancelled.
472 */
Linus Walleijd214b9b2006-08-26 22:08:37 +0000473typedef int (* LIBMTP_progressfunc_t) (uint64_t const sent, uint64_t const total,
Linus Walleij438bd7f2006-06-08 11:35:44 +0000474 void const * const data);
475
Richard Low6f070842009-05-03 10:26:16 +0000476/**
477 * Callback function for get by handler function
478 * @param params the device parameters
479 * @param priv a user-defined dereferencable pointer
480 * @param wantlen the number of bytes wanted
481 * @param data a buffer to write the data to
482 * @param gotlen pointer to the number of bytes actually written
483 * to data
484 * @return LIBMTP_HANDLER_RETURN_OK if successful,
485 * LIBMTP_HANDLER_RETURN_ERROR on error or
486 * LIBMTP_HANDLER_RETURN_CANCEL to cancel the transfer
487 */
488typedef uint16_t (* MTPDataGetFunc) (void* params, void* priv,
Richard Low5b4023c2009-04-16 19:14:38 +0000489 uint32_t wantlen, unsigned char *data, uint32_t *gotlen);
Richard Lowd3b17022009-04-11 12:37:39 +0000490
Richard Low6f070842009-05-03 10:26:16 +0000491/**
492 * Callback function for put by handler function
493 * @param params the device parameters
494 * @param priv a user-defined dereferencable pointer
495 * @param sendlen the number of bytes available
496 * @param data a buffer to read the data from
497 * @param putlen pointer to the number of bytes actually read
498 * from data
499 * @return LIBMTP_HANDLER_RETURN_OK if successful,
500 * LIBMTP_HANDLER_RETURN_ERROR on error or
501 * LIBMTP_HANDLER_RETURN_CANCEL to cancel the transfer
502 */
503typedef uint16_t (* MTPDataPutFunc) (void* params, void* priv,
Richard Low5b4023c2009-04-16 19:14:38 +0000504 uint32_t sendlen, unsigned char *data, uint32_t *putlen);
Richard Lowd3b17022009-04-11 12:37:39 +0000505
mopoke31364442006-11-20 04:53:04 +0000506/**
Richard Low6f070842009-05-03 10:26:16 +0000507 * The return codes for the get/put functions
508 */
509#define LIBMTP_HANDLER_RETURN_OK 0
510#define LIBMTP_HANDLER_RETURN_ERROR 1
511#define LIBMTP_HANDLER_RETURN_CANCEL 2
512
513/**
mopoke31364442006-11-20 04:53:04 +0000514 * @}
Linus Walleij438bd7f2006-06-08 11:35:44 +0000515 * @defgroup structar libmtp data structures
516 * @{
517 */
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000518
519/**
Linus Walleij2715c442007-01-20 22:35:29 +0000520 * A data structure to hold MTP device entries.
Linus Walleij6fd2f082006-03-28 07:19:22 +0000521 */
522struct LIBMTP_device_entry_struct {
jefferaida9687e2007-10-16 16:44:15 +0000523 char *vendor; /**< The vendor of this device */
Linus Walleij6fd2f082006-03-28 07:19:22 +0000524 uint16_t vendor_id; /**< Vendor ID for this device */
jefferaida9687e2007-10-16 16:44:15 +0000525 char *product; /**< The product name of this device */
Linus Walleij6fd2f082006-03-28 07:19:22 +0000526 uint16_t product_id; /**< Product ID for this device */
Linus Walleij0558ac52006-09-07 06:55:03 +0000527 uint32_t device_flags; /**< Bugs, device specifics etc */
Linus Walleij6fd2f082006-03-28 07:19:22 +0000528};
529
530/**
Linus Walleij63fd1e62008-04-23 23:49:43 +0000531 * A data structure to hold a raw MTP device connected
532 * to the bus.
533 */
534struct LIBMTP_raw_device_struct {
535 LIBMTP_device_entry_t device_entry; /**< The device entry for this raw device */
536 uint32_t bus_location; /**< Location of the bus, if device available */
537 uint8_t devnum; /**< Device number on the bus, if device available */
538};
539
540/**
Linus Walleij2715c442007-01-20 22:35:29 +0000541 * A data structure to hold errors from the library.
542 */
543struct LIBMTP_error_struct {
544 LIBMTP_error_number_t errornumber;
545 char *error_text;
546 LIBMTP_error_t *next;
547};
548
549/**
Richard Low6f070842009-05-03 10:26:16 +0000550 * A data structure to hold allowed ranges of values
551 */
552struct LIBMTP_allowed_values_struct {
553 uint8_t u8max;
554 uint8_t u8min;
555 uint8_t u8step;
556 uint8_t* u8vals;
557 int8_t i8max;
558 int8_t i8min;
559 int8_t i8step;
560 int8_t* i8vals;
561 uint16_t u16max;
562 uint16_t u16min;
563 uint16_t u16step;
564 uint16_t* u16vals;
565 int16_t i16max;
566 int16_t i16min;
567 int16_t i16step;
568 int16_t* i16vals;
569 uint32_t u32max;
570 uint32_t u32min;
571 uint32_t u32step;
572 uint32_t* u32vals;
573 int32_t i32max;
574 int32_t i32min;
575 int32_t i32step;
576 int32_t* i32vals;
577 uint64_t u64max;
578 uint64_t u64min;
579 uint64_t u64step;
580 uint64_t* u64vals;
581 int64_t i64max;
582 int64_t i64min;
583 int64_t i64step;
584 int64_t* i64vals;
585 /**
586 * Number of entries in the vals array
587 */
588 uint16_t num_entries;
589 /**
590 * The datatype specifying which of the above is used
591 */
592 LIBMTP_datatype_t datatype;
593 /**
594 * Non zero for range, 0 for enum
595 */
596 int is_range;
597};
598
599/**
Linus Walleij38d7ee82010-07-24 22:17:21 +0000600 * MTP device extension holder struct
601 */
602struct LIBMTP_device_extension_struct {
603 /**
604 * Name of extension e.g. "foo.com"
605 */
606 char *name;
607 /**
608 * Major revision of extension
609 */
610 int major;
611 /**
612 * Minor revision of extension
613 */
614 int minor;
615 /**
616 * Pointer to the next extension or NULL if this is the
617 * last extension.
618 */
619 LIBMTP_device_extension_t *next;
620};
621
622/**
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000623 * Main MTP device object struct
624 */
Linus Walleijb9256fd2006-02-15 09:40:43 +0000625struct LIBMTP_mtpdevice_struct {
Linus Walleijddaba2f2007-10-02 21:20:30 +0000626 /**
627 * Object bitsize, typically 32 or 64.
Linus Walleijb0ab5482007-08-29 21:08:54 +0000628 */
Linus Walleijddaba2f2007-10-02 21:20:30 +0000629 uint8_t object_bitsize;
mopoke31364442006-11-20 04:53:04 +0000630 /**
631 * Parameters for this device, must be cast into
Linus Walleij9b28da32006-03-16 13:47:58 +0000632 * \c (PTPParams*) before internal use.
633 */
634 void *params;
mopoke31364442006-11-20 04:53:04 +0000635 /**
Linus Walleij2d411db2006-03-22 12:13:09 +0000636 * USB device for this device, must be cast into
637 * \c (PTP_USB*) before internal use.
638 */
639 void *usbinfo;
Linus Walleija8b88892011-03-03 19:58:26 +0100640 /**
641 * The storage for this device, do not use strings in here without
Linus Walleijf8491912006-12-15 10:23:30 +0000642 * copying them first, and beware that this list may be rebuilt at
643 * any time.
Linus Walleij6a821042008-05-23 21:30:15 +0000644 * @see LIBMTP_Get_Storage()
Linus Walleijf8491912006-12-15 10:23:30 +0000645 */
Linus Walleij9e1b0812006-12-12 19:22:02 +0000646 LIBMTP_devicestorage_t *storage;
Linus Walleij2715c442007-01-20 22:35:29 +0000647 /**
648 * The error stack. This shall be handled using the error getting
649 * and clearing functions, not by dereferencing this list.
650 */
651 LIBMTP_error_t *errorstack;
Linus Walleij9b28da32006-03-16 13:47:58 +0000652 /** The maximum battery level for this device */
653 uint8_t maximum_battery_level;
Linus Walleij05ccbe72006-06-13 07:46:58 +0000654 /** Default music folder */
655 uint32_t default_music_folder;
656 /** Default playlist folder */
657 uint32_t default_playlist_folder;
658 /** Default picture folder */
659 uint32_t default_picture_folder;
660 /** Default video folder */
661 uint32_t default_video_folder;
662 /** Default organizer folder */
663 uint32_t default_organizer_folder;
664 /** Default ZENcast folder (only Creative devices...) */
665 uint32_t default_zencast_folder;
Linus Walleijccf28ce2006-11-16 16:06:38 +0000666 /** Default Album folder */
667 uint32_t default_album_folder;
Linus Walleij9316e652006-12-07 09:55:21 +0000668 /** Default Text folder */
669 uint32_t default_text_folder;
Linus Walleij3ec86312006-08-21 13:25:24 +0000670 /** Per device iconv() converters, only used internally */
671 void *cd;
Linus Walleij38d7ee82010-07-24 22:17:21 +0000672 /** Extension list */
673 LIBMTP_device_extension_t *extensions;
Linus Walleija8b88892011-03-03 19:58:26 +0100674 /** Whether the device uses caching, only used internally */
675 int cached;
676
Linus Walleij2d3f7b82007-02-14 09:24:20 +0000677 /** Pointer to next device in linked list; NULL if this is the last device */
678 LIBMTP_mtpdevice_t *next;
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000679};
680
Linus Walleijb9256fd2006-02-15 09:40:43 +0000681/**
Linus Walleijf6bc1782006-03-24 15:12:47 +0000682 * MTP file struct
683 */
684struct LIBMTP_file_struct {
685 uint32_t item_id; /**< Unique item ID */
Linus Walleijd208f9c2006-04-27 14:16:06 +0000686 uint32_t parent_id; /**< ID of parent folder */
Linus Walleijea68f1f2008-06-22 21:54:44 +0000687 uint32_t storage_id; /**< ID of storage holding this file */
Linus Walleijf6bc1782006-03-24 15:12:47 +0000688 char *filename; /**< Filename of this file */
689 uint64_t filesize; /**< Size of file in bytes */
Richard Lowd3b17022009-04-11 12:37:39 +0000690 time_t modificationdate; /**< Date of last alteration of the file */
Linus Walleijf6bc1782006-03-24 15:12:47 +0000691 LIBMTP_filetype_t filetype; /**< Filetype used for the current file */
692 LIBMTP_file_t *next; /**< Next file in list or NULL if last file */
693};
694
695/**
Linus Walleijb9256fd2006-02-15 09:40:43 +0000696 * MTP track struct
697 */
698struct LIBMTP_track_struct {
699 uint32_t item_id; /**< Unique item ID */
mopoke31364442006-11-20 04:53:04 +0000700 uint32_t parent_id; /**< ID of parent folder */
Linus Walleijea68f1f2008-06-22 21:54:44 +0000701 uint32_t storage_id; /**< ID of storage holding this track */
Linus Walleijb9256fd2006-02-15 09:40:43 +0000702 char *title; /**< Track title */
703 char *artist; /**< Name of recording artist */
Linus Walleij31b74292008-05-02 23:29:06 +0000704 char *composer; /**< Name of recording composer */
Linus Walleijb9256fd2006-02-15 09:40:43 +0000705 char *genre; /**< Genre name for track */
706 char *album; /**< Album name for track */
707 char *date; /**< Date of original recording as a string */
708 char *filename; /**< Original filename of this track */
709 uint16_t tracknumber; /**< Track number (in sequence on recording) */
710 uint32_t duration; /**< Duration in milliseconds */
mopoke31364442006-11-20 04:53:04 +0000711 uint32_t samplerate; /**< Sample rate of original file, min 0x1f80 max 0xbb80 */
Linus Walleijcf223e62006-06-19 09:31:53 +0000712 uint16_t nochannels; /**< Number of channels in this recording 0 = unknown, 1 or 2 */
713 uint32_t wavecodec; /**< FourCC wave codec name */
714 uint32_t bitrate; /**< (Average) bitrate for this file min=1 max=0x16e360 */
715 uint16_t bitratetype; /**< 0 = unused, 1 = constant, 2 = VBR, 3 = free */
716 uint16_t rating; /**< User rating 0-100 (0x00-0x64) */
717 uint32_t usecount; /**< Number of times used/played */
Linus Walleijb9256fd2006-02-15 09:40:43 +0000718 uint64_t filesize; /**< Size of track file in bytes */
Richard Lowd3b17022009-04-11 12:37:39 +0000719 time_t modificationdate; /**< Date of last alteration of the track */
Linus Walleijf6bc1782006-03-24 15:12:47 +0000720 LIBMTP_filetype_t filetype; /**< Filetype used for the current track */
Linus Walleijb9256fd2006-02-15 09:40:43 +0000721 LIBMTP_track_t *next; /**< Next track in list or NULL if last track */
722};
723
Linus Walleij9c6ca022006-04-21 10:24:15 +0000724/**
Linus Walleij438bd7f2006-06-08 11:35:44 +0000725 * MTP Playlist structure
726 */
727struct LIBMTP_playlist_struct {
728 uint32_t playlist_id; /**< Unique playlist ID */
Linus Walleij5ce59db2008-03-12 21:22:58 +0000729 uint32_t parent_id; /**< ID of parent folder */
Linus Walleijea68f1f2008-06-22 21:54:44 +0000730 uint32_t storage_id; /**< ID of storage holding this playlist */
Linus Walleij438bd7f2006-06-08 11:35:44 +0000731 char *name; /**< Name of playlist */
732 uint32_t *tracks; /**< The tracks in this playlist */
733 uint32_t no_tracks; /**< The number of tracks in this playlist */
734 LIBMTP_playlist_t *next; /**< Next playlist or NULL if last playlist */
735};
736
737/**
Linus Walleij0c33ec02006-10-27 10:15:40 +0000738 * MTP Album structure
739 */
740struct LIBMTP_album_struct {
741 uint32_t album_id; /**< Unique playlist ID */
Linus Walleij5ce59db2008-03-12 21:22:58 +0000742 uint32_t parent_id; /**< ID of parent folder */
Linus Walleijea68f1f2008-06-22 21:54:44 +0000743 uint32_t storage_id; /**< ID of storage holding this album */
Linus Walleij0c33ec02006-10-27 10:15:40 +0000744 char *name; /**< Name of album */
Linus Walleijadce4a52007-04-23 07:28:11 +0000745 char *artist; /**< Name of album artist */
Linus Walleij31b74292008-05-02 23:29:06 +0000746 char *composer; /**< Name of recording composer */
Linus Walleijadce4a52007-04-23 07:28:11 +0000747 char *genre; /**< Genre of album */
Linus Walleij0c33ec02006-10-27 10:15:40 +0000748 uint32_t *tracks; /**< The tracks in this album */
749 uint32_t no_tracks; /**< The number of tracks in this album */
750 LIBMTP_album_t *next; /**< Next album or NULL if last album */
751};
752
753/**
Linus Walleij9c6ca022006-04-21 10:24:15 +0000754 * MTP Folder structure
755 */
756struct LIBMTP_folder_struct {
757 uint32_t folder_id; /**< Unique folder ID */
758 uint32_t parent_id; /**< ID of parent folder */
Linus Walleijea68f1f2008-06-22 21:54:44 +0000759 uint32_t storage_id; /**< ID of storage holding this folder */
Linus Walleij9c6ca022006-04-21 10:24:15 +0000760 char *name; /**< Name of folder */
761 LIBMTP_folder_t *sibling; /**< Next folder at same level or NULL if no more */
762 LIBMTP_folder_t *child; /**< Child folder or NULL if no children */
763};
764
rreardon5332f9c2006-12-05 10:18:23 +0000765/**
766 * LIBMTP Object RepresentativeSampleData Structure
767 */
768struct LIBMTP_filesampledata_struct {
769 uint32_t width; /**< Width of sample if it is an image */
770 uint32_t height; /**< Height of sample if it is an image */
771 uint32_t duration; /**< Duration in milliseconds if it is audio */
772 LIBMTP_filetype_t filetype; /**< Filetype used for the sample */
773 uint64_t size; /**< Size of sample data in bytes */
774 char *data; /**< Sample data */
775};
776
Linus Walleij9e1b0812006-12-12 19:22:02 +0000777/**
778 * LIBMTP Device Storage structure
779 */
780struct LIBMTP_devicestorage_struct {
Linus Walleijf8491912006-12-15 10:23:30 +0000781 uint32_t id; /**< Unique ID for this storage */
782 uint16_t StorageType; /**< Storage type */
783 uint16_t FilesystemType; /**< Filesystem type */
784 uint16_t AccessCapability; /**< Access capability */
785 uint64_t MaxCapacity; /**< Maximum capability */
786 uint64_t FreeSpaceInBytes; /**< Free space in bytes */
787 uint64_t FreeSpaceInObjects; /**< Free space in objects */
788 char *StorageDescription; /**< A brief description of this storage */
789 char *VolumeIdentifier; /**< A volume identifier */
790 LIBMTP_devicestorage_t *next; /**< Next storage, follow this link until NULL */
791 LIBMTP_devicestorage_t *prev; /**< Previous storage */
Linus Walleij9e1b0812006-12-12 19:22:02 +0000792};
Linus Walleija8b88892011-03-03 19:58:26 +0100793
Linus Walleij335b6fb2011-03-22 23:43:32 +0100794/**
795 * LIBMTP Event structure
796 * TODO: add all externally visible events here
797 */
798enum LIBMTP_event_enum {
799 LIBMTP_EVENT_NONE,
Philip Langdaleda268792012-09-02 14:48:25 -0700800 LIBMTP_EVENT_STORE_ADDED,
Philip Langdale50dd3472013-03-10 12:22:51 -0700801 LIBMTP_EVENT_STORE_REMOVED,
802 LIBMTP_EVENT_OBJECT_ADDED,
803 LIBMTP_EVENT_OBJECT_REMOVED,
Linus Walleij335b6fb2011-03-22 23:43:32 +0100804};
805typedef enum LIBMTP_event_enum LIBMTP_event_t;
Linus Walleij9e1b0812006-12-12 19:22:02 +0000806
Linus Walleij438bd7f2006-06-08 11:35:44 +0000807/** @} */
808
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000809/* Make functions available for C++ */
810#ifdef __cplusplus
811extern "C" {
812#endif
813
nicklas79daadbf22009-09-28 18:19:34 +0000814extern int LIBMTP_debug;
815
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000816/**
Linus Walleij6fd2f082006-03-28 07:19:22 +0000817 * @defgroup internals The libmtp internals API.
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000818 * @{
819 */
nicklas79daadbf22009-09-28 18:19:34 +0000820void LIBMTP_Set_Debug(int);
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000821void LIBMTP_Init(void);
Linus Walleij6fd2f082006-03-28 07:19:22 +0000822int LIBMTP_Get_Supported_Devices_List(LIBMTP_device_entry_t ** const, int * const);
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000823/**
824 * @}
825 * @defgroup basic The basic device management API.
826 * @{
827 */
Linus Walleija700d222008-05-28 23:06:14 +0000828LIBMTP_error_number_t LIBMTP_Detect_Raw_Devices(LIBMTP_raw_device_t **, int *);
Linus Walleij549f49a2010-12-05 14:00:34 +0000829int LIBMTP_Check_Specific_Device(int busno, int devno);
Linus Walleijbdb89bd2008-05-28 23:32:35 +0000830LIBMTP_mtpdevice_t *LIBMTP_Open_Raw_Device(LIBMTP_raw_device_t *);
Linus Walleija8b88892011-03-03 19:58:26 +0100831LIBMTP_mtpdevice_t *LIBMTP_Open_Raw_Device_Uncached(LIBMTP_raw_device_t *);
Linus Walleijbdb89bd2008-05-28 23:32:35 +0000832/* Begin old, legacy interface */
Linus Walleijb9256fd2006-02-15 09:40:43 +0000833LIBMTP_mtpdevice_t *LIBMTP_Get_First_Device(void);
Linus Walleij2d3f7b82007-02-14 09:24:20 +0000834LIBMTP_error_number_t LIBMTP_Get_Connected_Devices(LIBMTP_mtpdevice_t **);
tedbullock848009b2007-03-03 23:20:12 +0000835uint32_t LIBMTP_Number_Devices_In_List(LIBMTP_mtpdevice_t *);
tedbullock0f033cb2007-02-14 20:56:54 +0000836void LIBMTP_Release_Device_List(LIBMTP_mtpdevice_t*);
Linus Walleijbdb89bd2008-05-28 23:32:35 +0000837/* End old, legacy interface */
Linus Walleijb9256fd2006-02-15 09:40:43 +0000838void LIBMTP_Release_Device(LIBMTP_mtpdevice_t*);
Linus Walleij8c45b292006-04-26 14:12:44 +0000839void LIBMTP_Dump_Device_Info(LIBMTP_mtpdevice_t*);
Linus Walleij5d533bb2007-07-17 21:48:57 +0000840int LIBMTP_Reset_Device(LIBMTP_mtpdevice_t*);
Linus Walleij2350b712008-01-14 22:54:37 +0000841char *LIBMTP_Get_Manufacturername(LIBMTP_mtpdevice_t*);
Linus Walleij80124062006-03-15 10:26:09 +0000842char *LIBMTP_Get_Modelname(LIBMTP_mtpdevice_t*);
843char *LIBMTP_Get_Serialnumber(LIBMTP_mtpdevice_t*);
844char *LIBMTP_Get_Deviceversion(LIBMTP_mtpdevice_t*);
Linus Walleij30658792006-08-19 22:18:55 +0000845char *LIBMTP_Get_Friendlyname(LIBMTP_mtpdevice_t*);
846int LIBMTP_Set_Friendlyname(LIBMTP_mtpdevice_t*, char const * const);
Linus Walleijfae27482006-08-19 20:13:25 +0000847char *LIBMTP_Get_Syncpartner(LIBMTP_mtpdevice_t*);
Linus Walleij30658792006-08-19 22:18:55 +0000848int LIBMTP_Set_Syncpartner(LIBMTP_mtpdevice_t*, char const * const);
mopoke31364442006-11-20 04:53:04 +0000849int LIBMTP_Get_Batterylevel(LIBMTP_mtpdevice_t *,
850 uint8_t * const,
Linus Walleijfa1374c2006-02-27 07:41:46 +0000851 uint8_t * const);
Linus Walleij8ab54262006-06-21 07:12:28 +0000852int LIBMTP_Get_Secure_Time(LIBMTP_mtpdevice_t *, char ** const);
853int LIBMTP_Get_Device_Certificate(LIBMTP_mtpdevice_t *, char ** const);
854int LIBMTP_Get_Supported_Filetypes(LIBMTP_mtpdevice_t *, uint16_t ** const, uint16_t * const);
Linus Walleija3895612013-04-29 21:56:38 +0200855int LIBMTP_Check_Capability(LIBMTP_mtpdevice_t *, LIBMTP_devicecap_t);
Linus Walleij2715c442007-01-20 22:35:29 +0000856LIBMTP_error_t *LIBMTP_Get_Errorstack(LIBMTP_mtpdevice_t*);
857void LIBMTP_Clear_Errorstack(LIBMTP_mtpdevice_t*);
858void LIBMTP_Dump_Errorstack(LIBMTP_mtpdevice_t*);
Linus Walleijf6bc1782006-03-24 15:12:47 +0000859
Jerry Zhang60d02262017-06-08 18:19:59 -0700860void LIBMTP_Set_Device_Timeout(LIBMTP_mtpdevice_t *device, int milliseconds);
861void LIBMTP_Get_Device_Timeout(LIBMTP_mtpdevice_t *device, int *milliseconds);
862
Linus Walleij9e1b0812006-12-12 19:22:02 +0000863#define LIBMTP_STORAGE_SORTBY_NOTSORTED 0
864#define LIBMTP_STORAGE_SORTBY_FREESPACE 1
865#define LIBMTP_STORAGE_SORTBY_MAXSPACE 2
866
867int LIBMTP_Get_Storage(LIBMTP_mtpdevice_t *, int const);
Linus Walleijf8491912006-12-15 10:23:30 +0000868int LIBMTP_Format_Storage(LIBMTP_mtpdevice_t *, LIBMTP_devicestorage_t *);
869
Richard Low6f070842009-05-03 10:26:16 +0000870/**
871 * Get/set arbitrary properties. These do not update the cache; should only be used on
872 * properties not stored in structs
873 */
874char *LIBMTP_Get_String_From_Object(LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const);
875uint64_t LIBMTP_Get_u64_From_Object(LIBMTP_mtpdevice_t *, uint32_t const,
876 LIBMTP_property_t const, uint64_t const);
877uint32_t LIBMTP_Get_u32_From_Object(LIBMTP_mtpdevice_t *, uint32_t const,
878 LIBMTP_property_t const, uint32_t const);
879uint16_t LIBMTP_Get_u16_From_Object(LIBMTP_mtpdevice_t *, uint32_t const,
880 LIBMTP_property_t const, uint16_t const);
881uint8_t LIBMTP_Get_u8_From_Object(LIBMTP_mtpdevice_t *, uint32_t const,
882 LIBMTP_property_t const, uint8_t const);
883int LIBMTP_Set_Object_String(LIBMTP_mtpdevice_t *, uint32_t const,
884 LIBMTP_property_t const, char const * const);
885int LIBMTP_Set_Object_u32(LIBMTP_mtpdevice_t *, uint32_t const,
886 LIBMTP_property_t const, uint32_t const);
887int LIBMTP_Set_Object_u16(LIBMTP_mtpdevice_t *, uint32_t const,
888 LIBMTP_property_t const, uint16_t const);
889int LIBMTP_Set_Object_u8(LIBMTP_mtpdevice_t *, uint32_t const,
890 LIBMTP_property_t const, uint8_t const);
891char const * LIBMTP_Get_Property_Description(LIBMTP_property_t inproperty);
892int LIBMTP_Is_Property_Supported(LIBMTP_mtpdevice_t*, LIBMTP_property_t const,
893 LIBMTP_filetype_t const);
894int LIBMTP_Get_Allowed_Property_Values(LIBMTP_mtpdevice_t*, LIBMTP_property_t const,
895 LIBMTP_filetype_t const, LIBMTP_allowed_values_t*);
896void LIBMTP_destroy_allowed_values_t(LIBMTP_allowed_values_t*);
Linus Walleij9e1b0812006-12-12 19:22:02 +0000897
Linus Walleijf6bc1782006-03-24 15:12:47 +0000898/**
899 * @}
900 * @defgroup files The file management API.
901 * @{
902 */
903LIBMTP_file_t *LIBMTP_new_file_t(void);
904void LIBMTP_destroy_file_t(LIBMTP_file_t*);
Linus Walleij16c51f02006-05-04 13:20:22 +0000905char const * LIBMTP_Get_Filetype_Description(LIBMTP_filetype_t);
Linus Walleij2e4b5f92006-06-16 14:00:49 +0000906LIBMTP_file_t *LIBMTP_Get_Filelisting(LIBMTP_mtpdevice_t *);
Richard Lowdc0b6c72006-11-13 09:22:23 +0000907LIBMTP_file_t *LIBMTP_Get_Filelisting_With_Callback(LIBMTP_mtpdevice_t *,
908 LIBMTP_progressfunc_t const, void const * const);
Stanisław Pitucha4c162fa2017-02-04 09:35:54 +1100909
910#define LIBMTP_FILES_AND_FOLDERS_ROOT 0xffffffff
911
Linus Walleija8b88892011-03-03 19:58:26 +0100912LIBMTP_file_t * LIBMTP_Get_Files_And_Folders(LIBMTP_mtpdevice_t *,
Linus Walleij8a199282011-03-05 22:28:41 +0100913 uint32_t const,
Linus Walleij71c79292011-03-05 22:08:07 +0100914 uint32_t const);
Linus Walleij2e4b5f92006-06-16 14:00:49 +0000915LIBMTP_file_t *LIBMTP_Get_Filemetadata(LIBMTP_mtpdevice_t *, uint32_t const);
mopoke31364442006-11-20 04:53:04 +0000916int LIBMTP_Get_File_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
Linus Walleijee73ef22006-08-27 19:56:00 +0000917 LIBMTP_progressfunc_t const, void const * const);
Linus Walleij71c79292011-03-05 22:08:07 +0100918int LIBMTP_Get_File_To_File_Descriptor(LIBMTP_mtpdevice_t*,
919 uint32_t const,
920 int const,
921 LIBMTP_progressfunc_t const,
922 void const * const);
923int LIBMTP_Get_File_To_Handler(LIBMTP_mtpdevice_t *,
924 uint32_t const,
925 MTPDataPutFunc,
926 void *,
927 LIBMTP_progressfunc_t const,
928 void const * const);
929int LIBMTP_Send_File_From_File(LIBMTP_mtpdevice_t *,
930 char const * const,
931 LIBMTP_file_t * const,
932 LIBMTP_progressfunc_t const,
933 void const * const);
934int LIBMTP_Send_File_From_File_Descriptor(LIBMTP_mtpdevice_t *,
935 int const,
936 LIBMTP_file_t * const,
937 LIBMTP_progressfunc_t const,
938 void const * const);
939int LIBMTP_Send_File_From_Handler(LIBMTP_mtpdevice_t *,
940 MTPDataGetFunc, void *,
941 LIBMTP_file_t * const,
942 LIBMTP_progressfunc_t const,
943 void const * const);
944int LIBMTP_Set_File_Name(LIBMTP_mtpdevice_t *,
945 LIBMTP_file_t *,
946 const char *);
rreardon5332f9c2006-12-05 10:18:23 +0000947LIBMTP_filesampledata_t *LIBMTP_new_filesampledata_t(void);
Linus Walleijf1b02f22006-12-06 09:03:23 +0000948void LIBMTP_destroy_filesampledata_t(LIBMTP_filesampledata_t *);
949int LIBMTP_Get_Representative_Sample_Format(LIBMTP_mtpdevice_t *,
950 LIBMTP_filetype_t const,
951 LIBMTP_filesampledata_t **);
rreardon5332f9c2006-12-05 10:18:23 +0000952int LIBMTP_Send_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
953 LIBMTP_filesampledata_t *);
Richard Low36e447c2008-01-20 15:24:55 +0000954int LIBMTP_Get_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
955 LIBMTP_filesampledata_t *);
Philip Langdale99351a42012-08-18 15:32:12 -0700956int LIBMTP_Get_Thumbnail(LIBMTP_mtpdevice_t *, uint32_t const,
957 unsigned char **data, unsigned int *size);
rreardon5332f9c2006-12-05 10:18:23 +0000958
Jerry Zhang60d02262017-06-08 18:19:59 -0700959void LIBMTP_Set_Load_Cache_On_Demand(int flag);
960
Linus Walleijdcde6082006-02-17 16:16:34 +0000961/**
962 * @}
963 * @defgroup tracks The track management API.
964 * @{
965 */
Linus Walleij95698cd2006-02-24 10:40:40 +0000966LIBMTP_track_t *LIBMTP_new_track_t(void);
967void LIBMTP_destroy_track_t(LIBMTP_track_t*);
968LIBMTP_track_t *LIBMTP_Get_Tracklisting(LIBMTP_mtpdevice_t*);
Richard Lowdc0b6c72006-11-13 09:22:23 +0000969LIBMTP_track_t *LIBMTP_Get_Tracklisting_With_Callback(LIBMTP_mtpdevice_t*,
970 LIBMTP_progressfunc_t const, void const * const);
nicklas7918b54d72009-11-07 19:54:07 +0000971LIBMTP_track_t *LIBMTP_Get_Tracklisting_With_Callback_For_Storage(LIBMTP_mtpdevice_t*, uint32_t const,
972 LIBMTP_progressfunc_t const, void const * const);
Linus Walleij2e4b5f92006-06-16 14:00:49 +0000973LIBMTP_track_t *LIBMTP_Get_Trackmetadata(LIBMTP_mtpdevice_t*, uint32_t const);
mopoke31364442006-11-20 04:53:04 +0000974int LIBMTP_Get_Track_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
Linus Walleijee73ef22006-08-27 19:56:00 +0000975 LIBMTP_progressfunc_t const, void const * const);
mopoke31364442006-11-20 04:53:04 +0000976int LIBMTP_Get_Track_To_File_Descriptor(LIBMTP_mtpdevice_t*, uint32_t const, int const,
Linus Walleijee73ef22006-08-27 19:56:00 +0000977 LIBMTP_progressfunc_t const, void const * const);
Richard Lowd3b17022009-04-11 12:37:39 +0000978int LIBMTP_Get_Track_To_Handler(LIBMTP_mtpdevice_t *, uint32_t const, MTPDataPutFunc,
979 void *, LIBMTP_progressfunc_t const, void const * const);
mopoke31364442006-11-20 04:53:04 +0000980int LIBMTP_Send_Track_From_File(LIBMTP_mtpdevice_t *,
Linus Walleij394bbbe2006-02-22 16:10:53 +0000981 char const * const, LIBMTP_track_t * const,
Linus Walleijee73ef22006-08-27 19:56:00 +0000982 LIBMTP_progressfunc_t const,
Linus Walleijea68f1f2008-06-22 21:54:44 +0000983 void const * const);
mopoke31364442006-11-20 04:53:04 +0000984int LIBMTP_Send_Track_From_File_Descriptor(LIBMTP_mtpdevice_t *,
Linus Walleij394bbbe2006-02-22 16:10:53 +0000985 int const, LIBMTP_track_t * const,
Linus Walleijee73ef22006-08-27 19:56:00 +0000986 LIBMTP_progressfunc_t const,
Linus Walleijea68f1f2008-06-22 21:54:44 +0000987 void const * const);
Richard Lowd3b17022009-04-11 12:37:39 +0000988int LIBMTP_Send_Track_From_Handler(LIBMTP_mtpdevice_t *,
989 MTPDataGetFunc, void *, LIBMTP_track_t * const,
990 LIBMTP_progressfunc_t const,
991 void const * const);
mopoke31364442006-11-20 04:53:04 +0000992int LIBMTP_Update_Track_Metadata(LIBMTP_mtpdevice_t *,
Linus Walleij95698cd2006-02-24 10:40:40 +0000993 LIBMTP_track_t const * const);
Linus Walleij4841ffc2011-03-05 22:54:22 +0100994int LIBMTP_Track_Exists(LIBMTP_mtpdevice_t *, uint32_t const);
Linus Walleij8d8c4352008-09-23 23:04:16 +0000995int LIBMTP_Set_Track_Name(LIBMTP_mtpdevice_t *, LIBMTP_track_t *, const char *);
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000996/** @} */
Linus Walleij9c6ca022006-04-21 10:24:15 +0000997
998/**
999 * @}
1000 * @defgroup folders The folder management API.
1001 * @{
1002 */
1003LIBMTP_folder_t *LIBMTP_new_folder_t(void);
1004void LIBMTP_destroy_folder_t(LIBMTP_folder_t*);
1005LIBMTP_folder_t *LIBMTP_Get_Folder_List(LIBMTP_mtpdevice_t*);
Linus Walleij1e4dfea2011-03-05 22:50:39 +01001006LIBMTP_folder_t *LIBMTP_Get_Folder_List_For_Storage(LIBMTP_mtpdevice_t*,
1007 uint32_t const);
Linus Walleij9c6ca022006-04-21 10:24:15 +00001008LIBMTP_folder_t *LIBMTP_Find_Folder(LIBMTP_folder_t*, uint32_t const);
Richard Lowf8cd3d72009-05-04 16:38:33 +00001009uint32_t LIBMTP_Create_Folder(LIBMTP_mtpdevice_t*, char *, uint32_t, uint32_t);
Linus Walleij8d8c4352008-09-23 23:04:16 +00001010int LIBMTP_Set_Folder_Name(LIBMTP_mtpdevice_t *, LIBMTP_folder_t *, const char *);
Linus Walleij9c6ca022006-04-21 10:24:15 +00001011/** @} */
1012
Linus Walleij438bd7f2006-06-08 11:35:44 +00001013
1014/**
1015 * @}
1016 * @defgroup playlists The audio/video playlist management API.
1017 * @{
1018 */
1019LIBMTP_playlist_t *LIBMTP_new_playlist_t(void);
1020void LIBMTP_destroy_playlist_t(LIBMTP_playlist_t *);
1021LIBMTP_playlist_t *LIBMTP_Get_Playlist_List(LIBMTP_mtpdevice_t *);
Linus Walleij2e4b5f92006-06-16 14:00:49 +00001022LIBMTP_playlist_t *LIBMTP_Get_Playlist(LIBMTP_mtpdevice_t *, uint32_t const);
Linus Walleijea68f1f2008-06-22 21:54:44 +00001023int LIBMTP_Create_New_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const);
alistair_boyle5e5fcb72008-11-17 14:38:19 +00001024int LIBMTP_Update_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const);
Linus Walleij8d8c4352008-09-23 23:04:16 +00001025int LIBMTP_Set_Playlist_Name(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *, const char *);
Linus Walleij438bd7f2006-06-08 11:35:44 +00001026
Linus Walleij0c33ec02006-10-27 10:15:40 +00001027/**
1028 * @}
1029 * @defgroup albums The audio/video album management API.
1030 * @{
1031 */
1032LIBMTP_album_t *LIBMTP_new_album_t(void);
1033void LIBMTP_destroy_album_t(LIBMTP_album_t *);
1034LIBMTP_album_t *LIBMTP_Get_Album_List(LIBMTP_mtpdevice_t *);
nicklas795e0100b2009-11-07 19:53:46 +00001035LIBMTP_album_t *LIBMTP_Get_Album_List_For_Storage(LIBMTP_mtpdevice_t *, uint32_t const);
Linus Walleij0c33ec02006-10-27 10:15:40 +00001036LIBMTP_album_t *LIBMTP_Get_Album(LIBMTP_mtpdevice_t *, uint32_t const);
Linus Walleijea68f1f2008-06-22 21:54:44 +00001037int LIBMTP_Create_New_Album(LIBMTP_mtpdevice_t *, LIBMTP_album_t * const);
Linus Walleij0c33ec02006-10-27 10:15:40 +00001038int LIBMTP_Update_Album(LIBMTP_mtpdevice_t *, LIBMTP_album_t const * const);
Linus Walleij8d8c4352008-09-23 23:04:16 +00001039int LIBMTP_Set_Album_Name(LIBMTP_mtpdevice_t *, LIBMTP_album_t *, const char *);
Linus Walleij438bd7f2006-06-08 11:35:44 +00001040
raveloxd9a28642006-05-26 23:42:22 +00001041/**
1042 * @}
1043 * @defgroup objects The object management API.
1044 * @{
1045 */
Linus Walleij438bd7f2006-06-08 11:35:44 +00001046int LIBMTP_Delete_Object(LIBMTP_mtpdevice_t *, uint32_t);
Linus Walleijde8193f2008-01-27 14:55:31 +00001047int LIBMTP_Set_Object_Filename(LIBMTP_mtpdevice_t *, uint32_t , char *);
Philip Langdale31e831c2013-03-04 20:58:19 -08001048int LIBMTP_GetPartialObject(LIBMTP_mtpdevice_t *, uint32_t const,
1049 uint64_t, uint32_t,
1050 unsigned char **, unsigned int *);
1051int LIBMTP_SendPartialObject(LIBMTP_mtpdevice_t *, uint32_t const,
1052 uint64_t, unsigned char *, unsigned int);
1053int LIBMTP_BeginEditObject(LIBMTP_mtpdevice_t *, uint32_t const);
1054int LIBMTP_EndEditObject(LIBMTP_mtpdevice_t *, uint32_t const);
1055int LIBMTP_TruncateObject(LIBMTP_mtpdevice_t *, uint32_t const, uint64_t);
Linus Walleij335b6fb2011-03-22 23:43:32 +01001056
Linus Walleijcb2794e2013-03-06 04:48:24 +01001057/**
1058 * @}
1059 * @defgroup files The events API.
1060 * @{
1061 */
Philip Langdale0a576512016-04-09 14:22:25 -07001062typedef void(* LIBMTP_event_cb_fn) (int, LIBMTP_event_t, uint32_t, void *);
Linus Walleijcb2794e2013-03-06 04:48:24 +01001063int LIBMTP_Read_Event(LIBMTP_mtpdevice_t *, LIBMTP_event_t *, uint32_t *);
Philip Langdale0a576512016-04-09 14:22:25 -07001064int LIBMTP_Read_Event_Async(LIBMTP_mtpdevice_t *, LIBMTP_event_cb_fn, void *);
1065int LIBMTP_Handle_Events_Timeout_Completed(struct timeval *, int *);
Linus Walleijcb2794e2013-03-06 04:48:24 +01001066
Marcin Niestroj718b2902017-06-10 16:36:18 +02001067/**
1068 * @}
1069 * @defgroup custom Custom operations API.
1070 * @{
1071 */
1072int LIBMTP_Custom_Operation(LIBMTP_mtpdevice_t *, uint16_t, int, ...);
1073
raveloxd9a28642006-05-26 23:42:22 +00001074/** @} */
1075
Linus Walleijeb8c6fe2006-02-03 09:46:22 +00001076/* End of C++ exports */
1077#ifdef __cplusplus
1078}
1079#endif
1080
1081#endif /* LIBMTP_H_INCLUSION_GUARD */
1082