Some fixed from Marcus.
diff --git a/ChangeLog b/ChangeLog
index 43df50c..e2b7288 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-11-25 Marcus Meissner <marcus@jet.franken.de>
+
+ * examples/hotplug.c: adding HAL style XML output for
+ the devices.
+ * examples/Makefile.am: fixing a bug in the automake
+ file (pathutils.h missing!)
+ * Makefile.am: fix the problem with re-making sources
+ (you had to run ./autogen.sh before!)
+
2006-11-23 Linus Walleij <triad@df.lth.se>
* src/libusb-glue.h: add a new bug flag for devices that
diff --git a/Makefile.am b/Makefile.am
index 8bf4429..ad86eb7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,5 @@
SUBDIRS=src examples doc
+ACLOCAL_AMFLAGS=-I m4
pkgconfigdir=$(libdir)/pkgconfig
pkgconfig_DATA=libmtp.pc
diff --git a/examples/Makefile.am b/examples/Makefile.am
index cab4c02..18086ae 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -2,7 +2,8 @@
folders trexist playlists getplaylist \
format albumart albums newplaylist emptyfolders
-connect_SOURCES=connect.c delfile.c getfile.c newfolder.c sendfile.c sendtr.c pathutils.c common.h
+connect_SOURCES=connect.c delfile.c getfile.c newfolder.c \
+ sendfile.c sendtr.c pathutils.c pathutils.h common.h
detect_SOURCES=detect.c common.h
tracks_SOURCES=tracks.c common.h
files_SOURCES=files.c common.h
@@ -27,4 +28,3 @@
ln -f -s $(DESTDIR)$(bindir)/mtp-connect $(DESTDIR)$(bindir)/mtp-newfolder
ln -f -s $(DESTDIR)$(bindir)/mtp-connect $(DESTDIR)$(bindir)/mtp-sendfile
ln -f -s $(DESTDIR)$(bindir)/mtp-connect $(DESTDIR)$(bindir)/mtp-sendtr
-
diff --git a/examples/hotplug.c b/examples/hotplug.c
index 2a132c6..d58f318 100644
--- a/examples/hotplug.c
+++ b/examples/hotplug.c
@@ -8,29 +8,39 @@
{
fprintf(stderr, "usage: hotplug [-h -u -a\"ACTION\"]\n");
fprintf(stderr, " -u: use udev syntax\n");
+ fprintf(stderr, " -H: use hal syntax\n");
fprintf(stderr, " -a\"ACTION\": perform udev action ACTION on attachment\n");
exit(1);
}
+enum style {
+ style_usbmap,
+ style_udev,
+ style_hal
+};
+
int main (int argc, char **argv)
{
LIBMTP_device_entry_t *entries;
int numentries;
int i;
int ret;
- int udev_style = 0;
+ enum style style = style_usbmap;
int opt;
extern int optind;
extern char *optarg;
char *udev_action = NULL;
char default_udev_action[] = "SYMLINK+=\"libmtp-%k\", MODE=\"666\"";
- while ( (opt = getopt(argc, argv, "ua:")) != -1 ) {
+ while ( (opt = getopt(argc, argv, "uHa:")) != -1 ) {
switch (opt) {
case 'a':
udev_action = strdup(optarg);
case 'u':
- udev_style = 1;
+ style = style_udev;
+ break;
+ case 'H':
+ style = style_hal;
break;
default:
usage();
@@ -40,29 +50,57 @@
LIBMTP_Init();
ret = LIBMTP_Get_Supported_Devices_List(&entries, &numentries);
if (ret == 0) {
- if (udev_style) {
+ switch (style) {
+ case style_udev:
printf("# UDEV-style hotplug map for libmtp\n");
printf("# Put this file in /etc/udev/rules.d\n\n");
printf("SUBSYSTEM!=\"usb_device\", ACTION!=\"add\", GOTO=\"libmtp_rules_end\"\n\n");
- } else {
+ break;
+ case style_usbmap:
printf("# This usermap will call the script \"libmtp.sh\" whenever a known MTP device is attached.\n\n");
+ break;
+ case style_hal:
+ printf("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> <!-- -*- SGML -*- -->\n");
+ printf("<!-- This file was generated by %s - - fdi -->\n", argv[0]);
+ printf("<deviceinfo version=\"0.2\">\n");
+ printf(" <device>\n");
+ printf(" <match key=\"info.bus\" string=\"usb\">\n");
+ break;
}
for (i = 0; i < numentries; i++) {
LIBMTP_device_entry_t * entry = &entries[i];
- printf("# %s\n", entry->name);
- if (udev_style) {
+ switch (style) {
+ case style_udev: {
char *action;
+ printf("# %s\n", entry->name);
if (udev_action != NULL) {
action = udev_action;
} else {
action = default_udev_action;
}
printf("SYSFS{idVendor}==\"%04x\", SYSFS{idProduct}==\"%04x\", %s\n", entry->vendor_id, entry->product_id, action);
- } else {
+ break;
+ }
+ case style_usbmap:
+ printf("# %s\n", entry->name);
printf("libmtp.sh 0x0003 0x%04x 0x%04x 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000\n", entry->vendor_id, entry->product_id);
+ break;
+ case style_hal:
+ printf(" <match key=\"usb.vendor_id\" int=\"%d\">\n", entry->vendor_id);
+ printf(" <match key=\"usb.product_id\" int=\"%d\">\n", entry->product_id);
+ printf(" <merge key=\"info.category\" type=\"string\">portable_audio_player</merge>\n");
+ printf(" <append key=\"info.capabilities\" type=\"strlist\">portable_audio_player</append>\n");
+ printf(" <merge key=\"portable_audio_player.access_method\" type=\"string\">user</merge>\n");
+ printf(" <merge key=\"portable_audio_player.type\" type=\"string\">mtp</merge>\n");
+
+ /* FIXME: needs true list of formats ... But all of them can do MP3 */
+ printf(" <append key=\"portable_audio_player.output_formats\" type=\"strlist\">audio/mpeg</append>\n");
+ printf(" </match>\n");
+ printf(" </match>\n");
+ break;
}
}
} else {
@@ -70,8 +108,17 @@
exit(1);
}
- if (udev_style) {
+ switch (style) {
+ case style_usbmap:
+ break;
+ case style_udev:
printf("\nLABEL=\"libmtp_rules_end\"\n");
+ break;
+ case style_hal:
+ printf(" </match>\n");
+ printf(" </device>\n");
+ printf("</deviceinfo>\n");
+ break;
}
exit (0);