Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(669)

Unified Diff: src/libmtp.c

Issue 11358153: Update libmtp from pre 1.1.4 git to 1.1.5 release. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libmtp/
Patch Set: disable mptz Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« config.h ('K') | « src/libmtp.h ('k') | src/libmtp.sym » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/libmtp.c
===================================================================
--- src/libmtp.c (revision 166547)
+++ src/libmtp.c (working copy)
@@ -45,6 +45,8 @@
#endif
#include "util.h"
+#include "mtpz.h"
+
#include <stdlib.h>
#include <limits.h>
#include <unistd.h>
@@ -72,14 +74,17 @@
* The value "-1" enables all debug flags.
*
* Some of the utilities in examples/ also take a command-line flag "-d" that
- * enables all debug flags, as if you had set LIBMTP_DEBUG=-1.
+ * enables LIBMTP_DEBUG_PTP and LIBMTP_DEBUG_DATA (same as setting
+ * LIBMTP_DEBUG=9).
*
* Flags (combine by adding the hex values):
- * 0x00 [0000 0000] : no debug (default)
- * 0x01 [0000 0001] : PTP debug
- * 0x02 [0000 0010] : Playlist debug
- * 0x04 [0000 0100] : USB debug
- * 0x08 [0000 1000] : USB data debug
+ * 0x00 [0000 0000] : LIBMTP_DEBUG_NONE : no debug (default)
+ * 0x01 [0000 0001] : LIBMTP_DEBUG_PTP : PTP debug
+ * 0x02 [0000 0010] : LIBMTP_DEBUG_PLST : Playlist debug
+ * 0x04 [0000 0100] : LIBMTP_DEBUG_USB : USB debug
+ * 0x08 [0000 1000] : LIBMTP_DEBUG_DATA : USB data debug
+ *
+ * (Please keep this list in sync with libmtp.h.)
*/
int LIBMTP_debug = LIBMTP_DEBUG_NONE;
@@ -752,7 +757,7 @@
* Never re-initialize libmtp!
*
* The only thing this does at the moment is to initialise the
- * filetype mapping table.
+ * filetype mapping table, as well as load MTPZ data if necessary.
*/
void LIBMTP_Init(void)
{
@@ -770,6 +775,12 @@
init_filemap();
init_propertymap();
+
+ if (mtpz_loaddata() == -1)
+ use_mtpz = 0;
+ else
+ use_mtpz = 1;
+
return;
}
@@ -2087,6 +2098,24 @@
if (mtp_device == NULL)
return NULL;
+ /* Check for MTPZ devices. */
+ if (use_mtpz) {
+ LIBMTP_device_extension_t *tmpext = mtp_device->extensions;
+
+ while (tmpext != NULL) {
+ if (!strcmp(tmpext->name, "microsoft.com/MTPZ")) {
+ LIBMTP_INFO("MTPZ device detected. Authenticating...\n");
+ if (PTP_RC_OK == ptp_mtpz_handshake(mtp_device->params)) {
+ LIBMTP_INFO ("(MTPZ) Successfully authenticated with device.\n");
+ } else {
+ LIBMTP_INFO ("(MTPZ) Failure - could not authenticate with device.\n");
+ }
+ break;
+ }
+ tmpext = tmpext->next;
+ }
+ }
+
// Set up this device as cached
mtp_device->cached = 1;
/*
@@ -2105,10 +2134,11 @@
* @param device a pointer to the MTP device to poll for events.
* @param event contains a pointer to be filled in with the event retrieved if the call
* is successful.
+ * @param out1 contains the param1 value from the raw event.
* @return 0 on success, any other value means the polling loop shall be
* terminated immediately for this session.
*/
-int LIBMTP_Read_Event(LIBMTP_mtpdevice_t *device, LIBMTP_event_t *event)
+int LIBMTP_Read_Event(LIBMTP_mtpdevice_t *device, LIBMTP_event_t *event, uint32_t *out1)
{
/*
* FIXME: Potential race-condition here, if client deallocs device
@@ -2159,6 +2189,8 @@
case PTP_EC_StoreAdded:
LIBMTP_INFO("Received event PTP_EC_StoreAdded in session %u\n", session_id);
/* TODO: rescan storages */
+ *event = LIBMTP_EVENT_STORE_ADDED;
+ *out1 = param1;
break;
case PTP_EC_StoreRemoved:
LIBMTP_INFO("Received event PTP_EC_StoreRemoved in session %u\n", session_id);
@@ -8787,6 +8819,24 @@
}
/**
+ * Retrieve the thumbnail for a file.
+ * @param device a pointer to the device to get the thumbnail from.
+ * @param id the object ID of the file to retrieve the thumbnail for.
+ * @return 0 on success, any other value means failure.
+ */
+int LIBMTP_Get_Thumbnail(LIBMTP_mtpdevice_t *device, uint32_t const id,
+ unsigned char **data, unsigned int *size)
+{
+ PTPParams *params = (PTPParams *) device->params;
+ uint16_t ret;
+
+ ret = ptp_getthumb(params, id, data, size);
+ if (ret == PTP_RC_OK)
+ return 0;
+ return -1;
+}
+
+/**
* This routine updates an album based on the metadata
* supplied. If the <code>tracks</code> field of the metadata
* contains a track listing, these tracks will be added to the
« config.h ('K') | « src/libmtp.h ('k') | src/libmtp.sym » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698