Here's the supplementary patch for openobex-apps.

-- 
Alexander

Homepage: http://www.sensi.org/~ak/

diff -uNr -x INSTALL -x Makefile -x Makefile.in -x aclocal.m4 -x autom4te.cache 
-x config.cache -x config.h -x 'config.h*' -x config.log -x config.status -x 
configure -x depcomp -x install-sh -x missing -x mkinstalldirs -x '*.Po' 
openobex-apps-1.0.0/ChangeLog openobex-apps-1.0.0-usb/ChangeLog
--- openobex-apps-1.0.0/ChangeLog       2002-12-01 19:34:41.000000000 +0200
+++ openobex-apps-1.0.0-usb/ChangeLog   2005-02-10 22:02:37.869328597 +0200
@@ -1,3 +1,7 @@
+2005-07-02  Alex Kanavin  <[EMAIL PROTECTED]>
+
+       * Add client-side USB support and interface discovery
+
 2002-11-15  Marcel Holtmann  <[EMAIL PROTECTED]>
 
        * Add Bluetooth server support
diff -uNr -x INSTALL -x Makefile -x Makefile.in -x aclocal.m4 -x autom4te.cache 
-x config.cache -x config.h -x 'config.h*' -x config.log -x config.status -x 
configure -x depcomp -x install-sh -x missing -x mkinstalldirs -x '*.Po' 
openobex-apps-1.0.0/acinclude.m4 openobex-apps-1.0.0-usb/acinclude.m4
--- openobex-apps-1.0.0/acinclude.m4    2002-12-01 19:34:41.000000000 +0200
+++ openobex-apps-1.0.0-usb/acinclude.m4        2005-01-25 01:34:27.000000000 
+0200
@@ -27,3 +27,30 @@
        AC_SUBST(BLUETOOTH_LIBS)
        AC_MSG_RESULT($am_cv_bluetooth_found)
 ])
+
+dnl
+dnl Check for USB library
+dnl
+
+AC_DEFUN([USB_CHECK],[
+       AC_MSG_CHECKING(for USB support)
+
+       AC_TRY_COMPILE( [       #include <usb.h>
+                       ],[
+                               struct usb_dev_handle *dev;
+                       ],
+                               am_cv_usb_found=yes,
+                               am_cv_usb_found=no
+                       )
+
+       if test $am_cv_usb_found = yes; then
+               AC_DEFINE(HAVE_USB,1,[Define if system supports USB])
+
+               USB_CFLAGS=""
+               USB_LIBS="-lusb"
+       fi
+
+       AC_SUBST(USB_CFLAGS)
+       AC_SUBST(USB_LIBS)
+       AC_MSG_RESULT($am_cv_usb_found)
+])
diff -uNr -x INSTALL -x Makefile -x Makefile.in -x aclocal.m4 -x autom4te.cache 
-x config.cache -x config.h -x 'config.h*' -x config.log -x config.status -x 
configure -x depcomp -x install-sh -x missing -x mkinstalldirs -x '*.Po' 
openobex-apps-1.0.0/configure.in openobex-apps-1.0.0-usb/configure.in
--- openobex-apps-1.0.0/configure.in    2002-12-01 19:34:41.000000000 +0200
+++ openobex-apps-1.0.0-usb/configure.in        2005-01-25 01:35:58.000000000 
+0200
@@ -18,5 +18,6 @@
 AM_PATH_OPENOBEX(1.0.0)
 
 BLUETOOTH_CHECK
+USB_CHECK
 
 AC_OUTPUT([Makefile src/Makefile])
diff -uNr -x INSTALL -x Makefile -x Makefile.in -x aclocal.m4 -x autom4te.cache 
-x config.cache -x config.h -x 'config.h*' -x config.log -x config.status -x 
configure -x depcomp -x install-sh -x missing -x mkinstalldirs -x '*.Po' 
openobex-apps-1.0.0/src/Makefile.am openobex-apps-1.0.0-usb/src/Makefile.am
--- openobex-apps-1.0.0/src/Makefile.am 2002-12-01 19:34:41.000000000 +0200
+++ openobex-apps-1.0.0-usb/src/Makefile.am     2005-01-25 01:35:35.000000000 
+0200
@@ -17,7 +17,7 @@
        obex_test_server.c obex_test_server.h \
        obex_test_cable.c obex_test_cable.h
 
-obex_test_LDADD = @OPENOBEX_LIBS@ @BLUETOOTH_LIBS@ libmisc.a
+obex_test_LDADD = @OPENOBEX_LIBS@ @BLUETOOTH_LIBS@ @USB_LIBS@ libmisc.a
 
 obex_tcp_SOURCES = obex_tcp.c
 
@@ -28,6 +28,6 @@
 
 LDADD = @OPENOBEX_LIBS@ libmisc.a
 
-INCLUDES = @OPENOBEX_CFLAGS@ @BLUETOOTH_CFLAGS@
+INCLUDES = @OPENOBEX_CFLAGS@ @BLUETOOTH_CFLAGS@ @USB_CFLAGS@
 
 EXTRA_DIST = makefile.msc
Binary files openobex-apps-1.0.0/src/irobex_palm3 and 
openobex-apps-1.0.0-usb/src/irobex_palm3 differ
Binary files openobex-apps-1.0.0/src/irobex_palm3.o and 
openobex-apps-1.0.0-usb/src/irobex_palm3.o differ
Binary files openobex-apps-1.0.0/src/irxfer and 
openobex-apps-1.0.0-usb/src/irxfer differ
Binary files openobex-apps-1.0.0/src/irxfer.o and 
openobex-apps-1.0.0-usb/src/irxfer.o differ
Binary files openobex-apps-1.0.0/src/libmisc.a and 
openobex-apps-1.0.0-usb/src/libmisc.a differ
Binary files openobex-apps-1.0.0/src/obex_io.o and 
openobex-apps-1.0.0-usb/src/obex_io.o differ
Binary files openobex-apps-1.0.0/src/obex_put_common.o and 
openobex-apps-1.0.0-usb/src/obex_put_common.o differ
Binary files openobex-apps-1.0.0/src/obex_tcp and 
openobex-apps-1.0.0-usb/src/obex_tcp differ
Binary files openobex-apps-1.0.0/src/obex_tcp.o and 
openobex-apps-1.0.0-usb/src/obex_tcp.o differ
Binary files openobex-apps-1.0.0/src/obex_test and 
openobex-apps-1.0.0-usb/src/obex_test differ
diff -uNr -x INSTALL -x Makefile -x Makefile.in -x aclocal.m4 -x autom4te.cache 
-x config.cache -x config.h -x 'config.h*' -x config.log -x config.status -x 
configure -x depcomp -x install-sh -x missing -x mkinstalldirs -x '*.Po' 
openobex-apps-1.0.0/src/obex_test.c openobex-apps-1.0.0-usb/src/obex_test.c
--- openobex-apps-1.0.0/src/obex_test.c 2002-12-01 19:34:41.000000000 +0200
+++ openobex-apps-1.0.0-usb/src/obex_test.c     2005-02-07 00:40:07.000000000 
+0200
@@ -47,6 +47,10 @@
 #include <bluetooth/rfcomm.h>
 #endif
 
+#ifdef HAVE_USB
+#include <usb.h>
+#endif
+
 #include <openobex/obex.h>
 
 #include "obex_test.h"
@@ -155,13 +159,18 @@
 {
        char cmd[10];
        int end = 0;
-       int cobex = FALSE, tcpobex = FALSE, btobex = FALSE, r320 = FALSE;
+       int cobex = FALSE, tcpobex = FALSE, btobex = FALSE, r320 = FALSE, 
usbobex = FALSE;
        obex_t *handle;
 #ifdef HAVE_BLUETOOTH
        bdaddr_t bdaddr;
        uint8_t channel;
 #endif
 
+#ifdef HAVE_USB
+       struct usb_obex_intf* usb_intf;
+       struct usb_obex_intf* interfaces;
+#endif
+
        struct context global_context = {0,};
 
 #ifndef _WIN32
@@ -181,7 +190,8 @@
                tcpobex = TRUE;
        if( (argc >= 2) && (strcmp(argv[1], "-b") == 0 ) )
                btobex = TRUE;
-
+       if( (argc >= 2) && (strcmp(argv[1], "-u") == 0 ) )
+               usbobex = TRUE;
 
        if(cobex)       {
 #ifndef _WIN32
@@ -262,6 +272,60 @@
                printf("Not implemented in Win32 yet.\n");
 #endif // _WIN32
        }
+       else if(usbobex) {
+           switch (argc) {
+#ifdef HAVE_USB
+           case 2:
+                printf("Using USB transport, querying available interfaces\n");
+                if(! (handle = OBEX_Init(OBEX_TRANS_USB, obex_event, 0)))      
{
+                        perror( "OBEX_Init failed");
+                        exit(0);
+               }
+               struct usb_dev_handle* usb_handle;
+               char manufacturer[256] = "\0";
+               char product[256] = "\0";
+               char interface_desc[256] = "\0";
+               int i = 0; int len;
+               
+               interfaces = UsbOBEX_GetInterfaces(handle);
+               while (interfaces != NULL) {
+                       usb_handle = usb_open(interfaces->device);
+                       len = usb_get_string_simple(usb_handle, 
interfaces->device->descriptor.iManufacturer, manufacturer, 256);
+                       len = usb_get_string_simple(usb_handle, 
interfaces->device->descriptor.iProduct, product ,256);
+                       len = usb_get_string_simple(usb_handle, 
interfaces->control_interface_description, interface_desc, 256);
+                       usb_close(usb_handle);
+                       printf("Interface %d: %s %s %s\n", i, manufacturer, 
product, interface_desc);
+                       interfaces = interfaces->next; i++;
+               }
+               printf("Use '%s -u interface_number' to run interactive OBEX 
test client\n", argv[0]);
+               OBEX_Cleanup(handle);
+               exit(0);
+               break;
+           case 3:
+                printf("Using USB transport \n");
+               int interface = atoi(argv[2]);
+                if(! (handle = OBEX_Init(OBEX_TRANS_USB, obex_event, 0)))      
{
+                        perror( "OBEX_Init failed");
+                        exit(0);
+                }
+
+                interfaces = UsbOBEX_GetInterfaces(handle);
+                while (interfaces != NULL && interface > 0) {
+                        interfaces = interfaces->next; interface--;
+                }
+               if (interfaces == NULL) {
+                       printf( "Invalid interface number\n");
+                       exit(0);
+               }
+               usb_intf = interfaces;
+                       
+               break;
+#endif
+           default:
+               printf("Wrong number of arguments\n");
+                        exit(0);
+           }
+       }
        else    {
                printf("Using IrDA transport\n");
                if(! (handle = OBEX_Init(OBEX_TRANS_IRDA, obex_event, 0)))      
{
@@ -321,6 +385,16 @@
                                        printf("Transport not found! 
(Bluetooth)\n");
 #endif
                                }
+                               if (usbobex) {
+#ifdef HAVE_USB
+                                       if (UsbOBEX_TransportConnect(handle, 
usb_intf) < 0) {
+                                               printf("Transport connect 
error! (USB)\n");
+                                               break;
+                                       }
+#else
+                                       printf("Transport not found! (USB)\n");
+#endif         
+                               }       
                                else {
                                        if(IrOBEX_TransportConnect(handle, 
IR_SERVICE) < 0) {
                                                printf("Transport connect 
error! (IrDA)\n");
Binary files openobex-apps-1.0.0/src/obex_test.o and 
openobex-apps-1.0.0-usb/src/obex_test.o differ
Binary files openobex-apps-1.0.0/src/obex_test_cable.o and 
openobex-apps-1.0.0-usb/src/obex_test_cable.o differ
diff -uNr -x INSTALL -x Makefile -x Makefile.in -x aclocal.m4 -x autom4te.cache 
-x config.cache -x config.h -x 'config.h*' -x config.log -x config.status -x 
configure -x depcomp -x install-sh -x missing -x mkinstalldirs -x '*.Po' 
openobex-apps-1.0.0/src/obex_test_client.c 
openobex-apps-1.0.0-usb/src/obex_test_client.c
--- openobex-apps-1.0.0/src/obex_test_client.c  2002-12-01 19:34:41.000000000 
+0200
+++ openobex-apps-1.0.0-usb/src/obex_test_client.c      2005-02-02 
00:40:48.000000000 +0200
@@ -256,7 +256,7 @@
 
        free(buf);
        free(uname);
-       free(bfname);
+//     free(bfname);
 
        OBEX_Request(handle, object);
        syncwait(handle);




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to