Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[PATCH] USB support to obexfs

2006-03-07
2013-05-01
  • Hello, I notice that there is still no USB support in the obexfs package, so I thought it would be good if I implement the supposedly easy patch. So here is my attemt, pleasee use it if you like it :)

    P.S. As not to open a new thread, I want to share a issue I have with my Nokia 6630 and obexfs. When connected, the root directory contains E: and E: drives (i.e. same names). One cannot access the built-in memory because of that. I played a bit with the source and could get it to display and browse C: and E: correctly, but with a dirty hack. I wonder if that is an issue only on my system (obexftp displays names fine).

    So, here is the USB patch:

    --- obexfs.c.orig       2006-01-18 03:08:51.000000000 +0200
    +++ obexfs.c.new        2006-03-07 23:20:39.000000000 +0200
    @@ -499,6 +499,7 @@
                    int c;
                    static struct option long_options[] = {
                            {"irda",        no_argument, NULL, 'i'},
    +                       {"usb", required_argument, NULL, 'u'},
                            {"bluetooth",   required_argument, NULL, 'b'},
                            {"channel",     required_argument, NULL, 'B'},
                            {"tty",         required_argument, NULL, 't'},
    @@ -508,7 +509,7 @@
                            {0, 0, 0, 0}
                    };

    -               c = getopt_long (argc, argv, "+ib:B:t:Nh",
    +               c = getopt_long (argc, argv, "+iu:b:B:t:Nh",
                                     long_options, &option_index);
                    if (c == -1)
                            break;
    @@ -529,6 +530,11 @@
                    case 'B':
                            btchannel = atoi(optarg);
                            break;
    +
    +               case 'u':
    +                       transport = OBEX_TRANS_USB;
    +      btchannel = atoi(optarg);
    +                       break;

                    case 't':
                            transport = OBEX_TRANS_CUSTOM;
    @@ -554,6 +560,7 @@
                                    " -b, --bluetooth <device>    connect to this bluetooth device\n"
                                    " -B, --channel <number>      use this bluetooth channel when connecting\n"
                                    " -t, --tty <device>          connect to this tty using a custom transport\n\n"
    +                               " -u, --usb <device>          connect using USB transport\n"
                                    " -N, --nonblock              nonblocking mode\n\n"
                                    " -h, --help, --usage         this help text\n\n"
                                    "Options to fusermount need to be preceeded by two dashes (--).\n"

     
    • Thank you for the small patch.

      The issues you experience with your 6630 are most likely related to the pseudo xml parser.
      Please post a sample xml listing of the mobiles root folder (using obexftp).

       
    • Hello,

      yes, just before I read your reply, I checked just that, the behaviour of the parser. When I use the Bulgarian language of the phone, the listing is as follows:
         <folder name="C:" user-perm="RW" mem-type="DEV" label="Памет на телефона"/>
         <folder name="E:" user-perm="RW" mem-type="MMC" label="Smith"/>
      I tried switching the language to English and it started behaving correctly. Nasty bug :/ Perhaps I will take a look at the parser (I have it open before me), but I'm not sure I'll be able to correct it by myself. Anyway, thanks for your reply and your appreciation of my patch :)

      P.S. I wonder where the CVS for obefs lives :)
      P.P.S. I've got a couple of other bugs I experience, but perhaps they should go in another thread.

       
      • Found the bug. There is no way to convert the string to latin1 so iconv bailed out eating half of the xml listing. This will be fixed in obexftp-0.20.

         
        • Alex Kanavin
          Alex Kanavin
          2006-03-08

          By the way, instead of converting to latin1 always:
          utf8 = iconv_open ("LATIN1", "UTF-8");

          you should convert to the system locale encoding:

          utf8 = iconv_open (nl_langinfo(CODESET), "UTF-8");

          That way, non-latin folder names (Cyrillic, Greek, Chinese, whatever) will be properly handled.

           
          • Exactly what I was looking for. Does this create additional dependancies? (with langinfo.h).
            Are any ifdefs or ac macros needed for this?

             
            • Alex Kanavin
              Alex Kanavin
              2006-03-08

              CODESET symbol is not defined on all Unices, but I guess the following should be enough:

              dnl Check for nl_langinfo and CODESET
              AC_MSG_CHECKING([for nl_langinfo (CODESET)])
              AC_TRY_LINK([#include <langinfo.h>],
                          [char *codeset = nl_langinfo (CODESET);],
                          [AC_MSG_RESULT(yes)],
                          [AC_MSG_RESULT(no)
                          AC_DEFINE(CODESET, 0, [Define to 0 if you don't have CODESET.])
                          ])