More interface
diff --git a/ChangeLog b/ChangeLog
index eee83a7..c9c1662 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-08-19 Linus Walleij <triad@df.lth.se>
+
+ * src/libmtp.h.in: add function to get syncronization
+ partner for the device.
+ * src/libmtp.c: dito.
+ * examples/detect.c: use that function.
+ * src/Makefile.am: backward-compatible interface bump.
+
2006-08-17 Linus Walleij <triad@df.lth.se>
* configure.ac: bump to 0.0.12 and require iconv.h.
diff --git a/examples/detect.c b/examples/detect.c
index 9b6787c..40fa68a 100644
--- a/examples/detect.c
+++ b/examples/detect.c
@@ -42,7 +42,8 @@
uint64_t freebytes;
char *storage_description;
char *volume_label;
- char *owner;
+ char *friendlyname;
+ char *syncpartner;
char *sectime;
char *devcert;
uint16_t *filetypes;
@@ -80,13 +81,20 @@
LIBMTP_Dump_Device_Info(device);
printf("MTP-specific device properties:\n");
- // The owner name
- owner = LIBMTP_Get_Ownername(device);
- if (owner == NULL) {
- printf(" Owner name: (NULL)\n");
+ // The friendly name
+ friendlyname = LIBMTP_Get_Ownername(device);
+ if (friendlyname == NULL) {
+ printf(" Friendly name: (NULL)\n");
} else {
- printf(" Owner name: %s\n", owner);
- free(owner);
+ printf(" Friendly name: %s\n", friendlyname);
+ free(friendlyname);
+ }
+ syncpartner = LIBMTP_Get_Syncpartner(device);
+ if (syncpartner == NULL) {
+ printf(" Synchronization partner: (NULL)\n");
+ } else {
+ printf(" Synchronization partner: %s\n", syncpartner);
+ free(syncpartner);
}
// Some storage info
diff --git a/src/Makefile.am b/src/Makefile.am
index dfdfb88..679955d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,9 +29,9 @@
# increment AGE, Otherwise AGE is reset to 0. If CURRENT has changed,
# REVISION is set to 0, otherwise REVISION is incremented.
# ---------------------------------------------------------------------------
-CURRENT=2
-REVISION=1
-AGE=1
+CURRENT=3
+REVISION=2
+AGE=0
SOVERSION=$(CURRENT):$(REVISION):$(AGE)
libmtp_la_LDFLAGS=@LDFLAGS@ -version-info $(SOVERSION)
diff --git a/src/libmtp.c b/src/libmtp.c
index ecc07e1..f425668 100644
--- a/src/libmtp.c
+++ b/src/libmtp.c
@@ -1058,9 +1058,13 @@
/**
- * This retrieves the owners name of an MTP device.
- * @param device a pointer to the device to get the owner for.
- * @return a newly allocated UTF-8 string representing the owner.
+ * This retrieves the "friendly name" of an MTP device. Usually
+ * this is simply the name of the owner or something like
+ * "John Doe's Digital Audio Player" so the function is named
+ * Ownername for this reason. This property should be supported
+ * by all MTP devices.
+ * @param device a pointer to the device to get the friendly name for.
+ * @return a newly allocated UTF-8 string representing the friendly name.
* The string must be freed by the caller after use.
*/
char *LIBMTP_Get_Ownername(LIBMTP_mtpdevice_t *device)
@@ -1079,7 +1083,36 @@
PTP_DTC_UNISTR) != PTP_RC_OK) {
return NULL;
}
- // Convert from UTF-16 to UTF-8
+ // Convert from UCS-2 to UTF-8
+ retstring = ucs2le_to_utf8((uint16_t *) propval.unistr);
+ free(propval.unistr);
+ return retstring;
+}
+
+/**
+ * This retrieves the syncronization partner of an MTP device. This
+ * property should be supported by all MTP devices.
+ * @param device a pointer to the device to get the sync partner for.
+ * @return a newly allocated UTF-8 string representing the synchronization
+ * partner. The string must be freed by the caller after use.
+ */
+char *LIBMTP_Get_Syncpartner(LIBMTP_mtpdevice_t *device)
+{
+ PTPPropertyValue propval;
+ char *retstring = NULL;
+ PTPParams *params = (PTPParams *) device->params;
+
+ if (!ptp_property_issupported(params, PTP_DPC_MTP_SynchronizationPartner)) {
+ return NULL;
+ }
+
+ if (ptp_getdevicepropvalue(params,
+ PTP_DPC_MTP_SynchronizationPartner,
+ &propval,
+ PTP_DTC_UNISTR) != PTP_RC_OK) {
+ return NULL;
+ }
+ // Convert from UCS-2 to UTF-8
retstring = ucs2le_to_utf8((uint16_t *) propval.unistr);
free(propval.unistr);
return retstring;
diff --git a/src/libmtp.h.in b/src/libmtp.h.in
index 6156fdb..3d2742f 100644
--- a/src/libmtp.h.in
+++ b/src/libmtp.h.in
@@ -245,6 +245,7 @@
char *LIBMTP_Get_Serialnumber(LIBMTP_mtpdevice_t*);
char *LIBMTP_Get_Deviceversion(LIBMTP_mtpdevice_t*);
char *LIBMTP_Get_Ownername(LIBMTP_mtpdevice_t*);
+char *LIBMTP_Get_Syncpartner(LIBMTP_mtpdevice_t*);
int LIBMTP_Get_Storageinfo(LIBMTP_mtpdevice_t *, uint64_t * const,
uint64_t * const, char ** const storage_description,
char ** const volume_label);