From: <dg...@su...> - 2009-01-20 10:18:07
|
Author: bellmich Date: Tue Jan 20 11:16:53 2009 New Revision: 896 URL: http://libsyncml.opensync.org/changeset/896 Log: ticket #212 added IRDA support to OBEX client The patch was developed by Peter Collingbourne <pe...@pc...>. Modified: trunk/libsyncml/transports/obex_client.c trunk/libsyncml/transports/obex_client_internals.h trunk/tools/syncml-ds-tool.c Modified: trunk/libsyncml/transports/obex_client.c ============================================================================== --- trunk/libsyncml/transports/obex_client.c Mon Jan 19 11:47:43 2009 (r895) +++ trunk/libsyncml/transports/obex_client.c Tue Jan 20 11:16:53 2009 (r896) @@ -621,6 +621,11 @@ env->path = g_strdup(value); smlTrace(TRACE_INTERNAL, "%s: URL or Bluetooth MAC %s detected", __func__, VA_STRING(env->path)); + } else if (!strcmp(name, SML_TRANSPORT_CONFIG_IRDA_SERVICE)) { + if (env->irda_service) + smlSafeCFree(&(env->irda_service)); + env->irda_service = g_strdup(value); + smlTrace(TRACE_INTERNAL, "%s: IrDA service %s detected", __func__, VA_STRING(env->irda_service)); } else if (!strcmp(name, SML_TRANSPORT_CONFIG_AT_COMMAND)) { if (env->at_command) smlSafeCFree(&(env->at_command)); @@ -790,6 +795,8 @@ OBEX_Cleanup(env->obexhandle); + if (env->irda_service) + smlSafeCFree(&(env->irda_service)); if (env->at_command) smlSafeCFree(&(env->at_command)); if (env->manufacturer) @@ -892,6 +899,17 @@ smlErrorSet(&error, SML_ERROR_GENERIC, "Bluetooth not enabled"); goto error; #endif + } else if (env->type == SML_TRANSPORT_CONNECTION_TYPE_IRDA) { + smlTrace(TRACE_INTERNAL, "%s: connecting to IrDA service %s", __func__, env->irda_service ? env->irda_service : "OBEX"); + + if (GET_OBEX_RESULT(IrOBEX_TransportConnect(env->obexhandle, env->irda_service)) < 0) { + smlErrorSet(&error, SML_ERROR_GENERIC, + "The IrDA connect failed. %s (%i).", + strerror(errno), errno); + goto error; + } + + smlTrace(TRACE_INTERNAL, "%s: IrDA connect done", __func__); } else { struct termios tio; memset(&tio, 0, sizeof(tio)); @@ -937,7 +955,9 @@ tcflush(fd, TCIFLUSH); } - if (env->type != SML_TRANSPORT_CONNECTION_TYPE_USB && env->type != SML_TRANSPORT_CONNECTION_TYPE_BLUETOOTH) { + if (env->type != SML_TRANSPORT_CONNECTION_TYPE_USB + && env->type != SML_TRANSPORT_CONNECTION_TYPE_BLUETOOTH + && env->type != SML_TRANSPORT_CONNECTION_TYPE_IRDA) { /* Start the obex transport */ if (GET_OBEX_RESULT(FdOBEX_TransportSetup(env->obexhandle, fd, fd, 4096)) < 0) { smlErrorSet(&error, SML_ERROR_GENERIC, Modified: trunk/libsyncml/transports/obex_client_internals.h ============================================================================== --- trunk/libsyncml/transports/obex_client_internals.h Mon Jan 19 11:47:43 2009 (r895) +++ trunk/libsyncml/transports/obex_client_internals.h Tue Jan 20 11:16:53 2009 (r896) @@ -50,6 +50,7 @@ uint32_t connection_id; char *path; unsigned int port; + char *irda_service; char *at_command; char *manufacturer; char *model; Modified: trunk/tools/syncml-ds-tool.c ============================================================================== --- trunk/tools/syncml-ds-tool.c Mon Jan 19 11:47:43 2009 (r895) +++ trunk/tools/syncml-ds-tool.c Tue Jan 20 11:16:53 2009 (r896) @@ -83,6 +83,12 @@ * @param --ip "<addr>" "<port>" * Connect to this TCP/IP address. * + * @param --irda + * Connect using IrDA. + * + * @param --irda-service "<service>" + * Use the given IrDA service (default: OBEX). + * * @subsection OPTION_OBEX_SERVER_CONFIG OBEX server configuration * * @param --port "<port>" @@ -776,7 +782,9 @@ fprintf(stderr, "\t-u\t\tList all available USB interfaces.\n"); fprintf(stderr, "\t-u <id>\t\tConnect to the given usb interface number.\n"); fprintf(stderr, "\t-b <addr> <channel>\tConnect to the given bluetooth device.\n"); - fprintf(stderr, "\t--ip <addr> <port>\tConnect to this TCP/IP address.\n\n"); + fprintf(stderr, "\t--ip <addr> <port>\tConnect to this TCP/IP address.\n"); + fprintf(stderr, "\t--irda\t\tConnect using IrDA.\n"); + fprintf(stderr, "\t--irda-service <service>\tUse the given IrDA service (default: OBEX).\n\n"); fprintf(stderr, "\tOBEX server configuration:\n"); fprintf(stderr, "\t==========================\n\n"); @@ -987,6 +995,28 @@ printf("Bluetooth is not available in this build\n"); return 1; #endif + } else if (!strcmp (arg, "--irda")) { + if (!smlDataSyncSetOption( + dsObject, + SML_DATA_SYNC_CONFIG_CONNECTION_TYPE, + SML_DATA_SYNC_CONFIG_CONNECTION_IRDA, + error)) + goto error; + } else if (!strcmp (arg, "--irda-service")) { + if (!smlDataSyncSetOption( + dsObject, + SML_DATA_SYNC_CONFIG_CONNECTION_TYPE, + SML_DATA_SYNC_CONFIG_CONNECTION_IRDA, + error)) + goto error; + i++; + if (!argv[i]) + usage (argv[0]); + if (!smlDataSyncSetOption( + dsObject, + SML_TRANSPORT_CONFIG_IRDA_SERVICE, + argv[i], error)) + goto error; } else if (!strcmp (arg, "-s")) { if (!smlDataSyncSetOption( dsObject, |