Hello guys,
With the attached patch I added an option to obexftp that allows to set
Accept/Reject transfer timeout for obexftp. This is useful for bluetooth
applications where you want to send a file to multiple clients in very
little time (proximity marketing for example).
I created the patch against svn rev 225 from
http://dev.zuckschwerdt.org/svn/obexftp/
Any comments would be appreciated.
Thanks,
Manuel
Index: apps/obexftp.c
===================================================================
--- apps/obexftp.c (revisión: 225)
+++ apps/obexftp.c (copia de trabajo)
@@ -244,8 +244,10 @@
static int use_uuid_len = sizeof(UUID_FBS);
static int use_conn=1;
static int use_path=1;
+static int timeout = 20; /* the user has 20 seconds to accept/reject */
+
/* connect with given uuid. re-connect every time */
static int cli_connect_uuid(const char *uuid, int uuid_len)
{
@@ -269,6 +271,8 @@
if (!use_path) {
cli->quirks &= ~OBEXFTP_SPLIT_SETPATH;
}
+
+ cli->accept_timeout=timeout;
}
for (retry = 0; retry < 3; retry++) {
@@ -491,6 +495,7 @@
{"uuid", optional_argument, NULL, 'U'},
{"noconn", no_argument, NULL, 'H'},
{"nopath", no_argument, NULL, 'S'},
+ {"timeout", required_argument, NULL, 'T'},
{"list", optional_argument, NULL, 'l'},
{"chdir", required_argument, NULL, 'c'},
{"mkdir", required_argument, NULL, 'C'},
@@ -510,7 +515,7 @@
{0, 0, 0, 0}
};
- c = getopt_long (argc, argv,
"-ib::B:d:u::t:n:U::HSL::l::c:C:f:o:g:G:p:k:XYxm:VvhN:FP",
+ c = getopt_long (argc, argv,
"-ib::B:d:u::t:n:U::HST:L::l::c:C:f:o:g:G:p:k:XYxm:VvhN:FP",
long_options, &option_index);
if (c == -1)
break;
@@ -750,6 +755,13 @@
printf("ObexFTP %s\n", VERSION);
most_recent_cmd = 'h'; // not really
break;
+ case 'T':
+ timeout = atoi(optarg);
+ if (timeout < 0) {
+ fprintf(stderr, "timeout can't be less than 0\n");
+ exit(1);
+ }
+ break;
case 'h':
printf("ObexFTP %s\n", VERSION);
@@ -772,7 +784,9 @@
" -n, --network <host> connect to this
host\n\n"
" -U, --uuid use given uuid
(none, FBS, IRMC, S45, SHARP)\n"
" -H, --noconn suppress
connection ids (no conn header)\n"
- " -S, --nopath dont use setpaths
(use path as filename)\n\n"
+ " -S, --nopath dont use setpaths
(use path as filename)\n"
+ " -T, --timeout <seconds> amount of seconds
the user has to accept or reject \n"
+ " the transfer
before obexftp timeout\n\n"
" -c, --chdir <DIR> chdir\n"
" -C, --mkdir <DIR> mkdir and chdir\n"
" -l, --list [<FOLDER>] list
current/given folder\n"
Index: obexftp/client.c
===================================================================
--- obexftp/client.c (revisión: 225)
+++ obexftp/client.c (copia de trabajo)
@@ -422,7 +422,7 @@
/* cli->finished = FALSE; */
while(cli->finished == FALSE) {
- ret = OBEX_HandleInput(cli->obexhandle, 20);
+ ret = OBEX_HandleInput(cli->obexhandle, cli->accept_timeout);
DEBUG(3, "%s() OBEX_HandleInput = %d\n", __func__, ret);
if (ret <= 0) {
@@ -514,6 +514,9 @@
free(cli);
return NULL;
}
+
+ cli->accept_timeout = 20; /* 20 seconds for Accept/Reject timeout,
default value */
+
return cli;
}
Index: obexftp/client.h
===================================================================
--- obexftp/client.h (revisión: 225)
+++ obexftp/client.h (copia de trabajo)
@@ -106,6 +106,8 @@
cache_object_t *cache;
int cache_timeout;
int cache_maxsize;
+ /* useful for bluetooth */
+ int accept_timeout; /* accept reject timeout in seconds */
} obexftp_client_t;
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Openobex-users mailing list
Openobex-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/openobex-users