diff options
author | Rene Wagner <rw@handhelds.org> | 2005-08-24 16:27:50 +0000 |
---|---|---|
committer | OpenEmbedded Project <openembedded-devel@lists.openembedded.org> | 2005-08-24 16:27:50 +0000 |
commit | 9ab834cb933cbe887ecc45a05086aeac9bcae5af (patch) | |
tree | 8dc51bf63102b2c25b2db367863bdf51adae976f /packages/obexpush | |
parent | 7106374e696b7d9f7e03702950352b5191ffa556 (diff) | |
parent | 09fc038cf066498585825d2706dec7accdc20edb (diff) |
merge of 67c06308e7dc7f4e91adc69fedea16ec131bb45e
and ab3bfea881e8e12863a1707268606b7f864d1dc6
Diffstat (limited to 'packages/obexpush')
-rw-r--r-- | packages/obexpush/.mtn2git_empty | 0 | ||||
-rw-r--r-- | packages/obexpush/files/.mtn2git_empty | 0 | ||||
-rw-r--r-- | packages/obexpush/files/init | 44 | ||||
-rw-r--r-- | packages/obexpush/obexpush-native_1.0.0.bb | 9 | ||||
-rw-r--r-- | packages/obexpush/obexpush/.mtn2git_empty | 0 | ||||
-rw-r--r-- | packages/obexpush/obexpush/add-obextool.patch | 461 | ||||
-rw-r--r-- | packages/obexpush/obexpush_1.0.0.bb | 46 |
7 files changed, 560 insertions, 0 deletions
diff --git a/packages/obexpush/.mtn2git_empty b/packages/obexpush/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/obexpush/.mtn2git_empty diff --git a/packages/obexpush/files/.mtn2git_empty b/packages/obexpush/files/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/obexpush/files/.mtn2git_empty diff --git a/packages/obexpush/files/init b/packages/obexpush/files/init new file mode 100644 index 0000000000..a9891ef8ad --- /dev/null +++ b/packages/obexpush/files/init @@ -0,0 +1,44 @@ +#!/bin/sh +# +# Start or stop the OBEX Push daemon. +# +# Written by Michael Haynie <mbhaynie@zoominternet.net> +# +# It might be better to just edit the bluetooth script, +# since opd depends heavily on it. +# + +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +[ -f /etc/default/rcS ] && . /etc/default/rcS +[ -f /etc/default/opd_args ] && . /etc/default/opd_args + +case "$1" in + start) + echo -n "Starting the OBEX Push daemon: " + start-stop-daemon -S -x /usr/sbin/opd -- --daemonize $OPD_ARGS + if [ $? = 0 ]; then + echo "opd." + else + echo "(failed.)" + fi + ;; + stop) + echo -n "Stopping the OBEX Push daemon: " + start-stop-daemon -K \ + -x /usr/sbin/opd + echo "opd." + ;; + restart|force-reload) + $0 stop + $0 start + exit + ;; + *) + echo "Usage: " $0 " {start|stop|restart|force-reload}" + exit 1 + ;; +esac + +exit 0 + diff --git a/packages/obexpush/obexpush-native_1.0.0.bb b/packages/obexpush/obexpush-native_1.0.0.bb new file mode 100644 index 0000000000..6e63de5c98 --- /dev/null +++ b/packages/obexpush/obexpush-native_1.0.0.bb @@ -0,0 +1,9 @@ +include obexpush_${PV}.bb +inherit native + +FILESPATH = "${FILE_DIRNAME}/obexpush-${PV}:${FILE_DIRNAME}/obexpush:${FILE_DIRNAME}/files:${FILE_DIRNAME}" + +do_install() { + : +} + diff --git a/packages/obexpush/obexpush/.mtn2git_empty b/packages/obexpush/obexpush/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/obexpush/obexpush/.mtn2git_empty diff --git a/packages/obexpush/obexpush/add-obextool.patch b/packages/obexpush/obexpush/add-obextool.patch new file mode 100644 index 0000000000..34a7625818 --- /dev/null +++ b/packages/obexpush/obexpush/add-obextool.patch @@ -0,0 +1,461 @@ + +# +# Patch managed by http://www.holgerschurig.de/patcher.html +# + +--- obexpush/client/obex_main.c~add-obextool.patch ++++ obexpush/client/obex_main.c +@@ -221,12 +221,7 @@ + return NULL; + } + +- +- #ifdef OLDLIBOBEX +- custfunc.userdata = gt->userdata; +- #else //OLDLIBOBEX + custfunc.customdata = gt->userdata; +- #endif //OLDLIBOBEX + custfunc.connect = cobex_connect; + custfunc.disconnect = cobex_disconnect; + custfunc.write = cobex_write; +--- /dev/null ++++ obexpush/client/obextool.c +@@ -0,0 +1,411 @@ ++/* ++ * ++ * Bluetooth OBEX tool ++ * ++ * Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org> ++ * ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ */ ++ ++#include <stdio.h> ++#include <errno.h> ++#include <fcntl.h> ++#include <getopt.h> ++#include <string.h> ++#include <libgen.h> ++#include <stdlib.h> ++#include <unistd.h> ++#include <sys/stat.h> ++#include <sys/time.h> ++#include <sys/param.h> ++#include <sys/socket.h> ++ ++#include <bluetooth/bluetooth.h> ++#include <bluetooth/hci.h> ++#include <bluetooth/hci_lib.h> ++#include <bluetooth/rfcomm.h> ++ ++#include <glib.h> ++#include <openobex/obex.h> ++ ++ ++ ++volatile int finished = 0; ++ ++struct btobex_context_t { ++ int fd; ++ bdaddr_t bdaddr; ++ uint8_t channel; ++} btobex_context; ++ ++ ++gint btobex_connect(obex_t *handle, gpointer userdata) ++{ ++ struct btobex_context_t *context = userdata; ++ struct sockaddr_rc laddr, raddr; ++ int s; ++ ++ if ((s = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0) { ++ printf("Can't create socket. %s (%d)\n", strerror(errno), errno); ++ return -1; ++ } ++ ++ laddr.rc_family = AF_BLUETOOTH; ++ bacpy(&laddr.rc_bdaddr, BDADDR_ANY); ++ laddr.rc_channel = 0; ++ if (bind(s, (struct sockaddr *)&laddr, sizeof(laddr)) < 0) { ++ printf("Can't bind socket. %s (%d)\n", strerror(errno), errno); ++ close(s); ++ return -1; ++ } ++ ++ raddr.rc_family = AF_BLUETOOTH; ++ bacpy(&raddr.rc_bdaddr, &context->bdaddr); ++ raddr.rc_channel = context->channel; ++ if (connect(s, (struct sockaddr *)&raddr, sizeof(raddr)) < 0) { ++ printf("Can't connect. %s (%d)\n", strerror(errno), errno); ++ close(s); ++ return -1; ++ } ++ ++ context->fd = s; ++ ++ return 1; ++} ++ ++ ++gint btobex_disconnect(obex_t *handle, gpointer userdata) ++{ ++ struct btobex_context_t *context = userdata; ++ ++ close(context->fd); ++ ++ return 1; ++} ++ ++ ++gint btobex_listen(obex_t *handle, gpointer userdata) ++{ ++ printf("The listen command is not implemented\n"); ++ ++ return -1; ++} ++ ++ ++gint btobex_write(obex_t *handle, gpointer userdata, guint8 *buffer, gint length) ++{ ++ struct btobex_context_t *context = userdata; ++ ++ return (write(context->fd, buffer, length)); ++} ++ ++ ++gint btobex_handleinput(obex_t *handle, gpointer userdata, gint timeout) ++{ ++ struct btobex_context_t *context = userdata; ++ struct timeval to; ++ fd_set fdset; ++ unsigned char buf[1024]; ++ int sel, len; ++ ++ to.tv_sec = timeout; ++ to.tv_usec = 0; ++ ++ FD_ZERO(&fdset); ++ FD_SET(context->fd, &fdset); ++ ++ len = 0; ++ ++ if ((sel = select(context->fd + 1, &fdset, NULL, NULL, &to)) > 0) { ++ if ((len = read(context->fd, buf, sizeof(buf))) > 0) ++ OBEX_CustomDataFeed(handle, buf, len); ++ } ++ ++ return len; ++} ++ ++ ++obex_ctrans_t btobex_ctrans = { ++ customdata: &btobex_context, ++ connect: btobex_connect, ++ disconnect: btobex_disconnect, ++ listen: btobex_listen, ++ write: btobex_write, ++ handleinput: btobex_handleinput, ++}; ++ ++ ++void btobex_event(obex_t *handle, obex_object_t *object, gint mode, gint event, gint obex_cmd, gint obex_rsp) ++{ ++ switch (event) { ++ case OBEX_EV_PROGRESS: ++ break; ++ case OBEX_EV_ABORT: ++ printf("Request aborted\n"); ++ finished = 1; ++ break; ++ case OBEX_EV_REQDONE: ++ finished = 1; ++ break; ++ case OBEX_EV_REQHINT: ++ printf("Request hint\n"); ++ break; ++ case OBEX_EV_REQ: ++ printf("Server request\n"); ++ break; ++ case OBEX_EV_LINKERR: ++ OBEX_TransportDisconnect(handle); ++ printf("Link broken\n"); ++ break; ++ case OBEX_EV_PARSEERR: ++ printf("Parse error\n"); ++ break; ++ default: ++ printf("Unknown event 0x%02x\n", event); ++ break; ++ } ++} ++ ++ ++ ++guint8 *btobex_readfile(const char *filename, int *filesize) ++{ ++ guint8 *buf; ++ struct stat stats; ++ int fd, fs; ++ ++ stat(filename, &stats); ++ fs = stats.st_size; ++ ++ if ((fd = open(filename, O_RDONLY, 0)) < 0) ++ return NULL; ++ ++ if (!(buf = g_malloc(fs))) { ++ close(fd); ++ return NULL; ++ } ++ ++ *filesize = read(fd, buf, fs); ++ ++ close(fd); ++ ++ return buf; ++} ++ ++ ++int btobex_push(bdaddr_t *bdaddr, uint8_t channel, char *filename, char *alias) ++{ ++ obex_t *handle; ++ obex_object_t *object; ++ obex_headerdata_t hd; ++ ++ guint8 namebuf[MAXPATHLEN + 1]; ++ int namelen; ++ guint8 *databuf; ++ int datalen; ++ ++ int err; ++ ++ if (!(handle = OBEX_Init(OBEX_TRANS_CUST, btobex_event, 0))) { ++ printf("Init of OBEX failed. %s (%d)", strerror(errno), errno); ++ return -1; ++ } ++ ++ bacpy(&btobex_context.bdaddr, bdaddr); ++ btobex_context.channel = channel; ++ ++ OBEX_SetUserData(handle, &btobex_context); ++ ++ if (OBEX_RegisterCTransport(handle, &btobex_ctrans) < 0) { ++ printf("Custom transport callback registration failed."); ++ return -1; ++ } ++ ++ if (OBEX_TransportConnect(handle, (void *)1, 0) != 1) ++ return -1; ++ ++ ++ object = OBEX_ObjectNew(handle, OBEX_CMD_CONNECT); ++ err = OBEX_Request(handle, object); ++ ++ finished = 0; ++ while (!finished) { ++ if ((err = OBEX_HandleInput(handle, 1)) < 0) { ++ printf("Error while handling input.\n"); ++ break; ++ } ++ } ++ ++ ++ object = OBEX_ObjectNew(handle, OBEX_CMD_PUT); ++ ++ namelen = OBEX_CharToUnicode(namebuf, alias, MAXPATHLEN); ++ hd.bs = namebuf; ++ OBEX_ObjectAddHeader(handle, object, OBEX_HDR_NAME, hd, namelen, 0); ++ ++ if (!(databuf = btobex_readfile(filename, &datalen))) { ++ OBEX_TransportDisconnect(handle); ++ return -1; ++ } ++ ++ hd.bq4 = datalen; ++ OBEX_ObjectAddHeader(handle, object, OBEX_HDR_LENGTH, hd, sizeof(guint32), 0); ++ ++ hd.bs = databuf; ++ OBEX_ObjectAddHeader(handle, object, OBEX_HDR_BODY, hd, datalen, 0); ++ ++ printf("Sending object ...\n"); ++ ++ err = OBEX_Request(handle, object); ++ ++ finished = 0; ++ while (!finished) { ++ if ((err = OBEX_HandleInput(handle, 1)) < 0) { ++ printf("Error while handling input.\n"); ++ break; ++ } ++ } ++ ++ ++ object = OBEX_ObjectNew(handle, OBEX_CMD_DISCONNECT); ++ err = OBEX_Request(handle, object); ++ ++ finished = 0; ++ while (!finished) { ++ if ((err = OBEX_HandleInput(handle, 1)) < 0) { ++ printf("Error while handling input.\n"); ++ break; ++ } ++ } ++ ++ ++ OBEX_TransportDisconnect(handle); ++ ++ return 0; ++} ++ ++ ++ ++static void usage(void); ++ ++ ++void cmd_push(bdaddr_t *local, int argc, char **argv) ++{ ++ char *filename; ++ char *alias; ++ bdaddr_t bdaddr; ++ uint8_t channel; ++ ++ if (argc < 3) { ++ usage(); ++ return; ++ } ++ ++ filename = argv[1]; ++ alias = basename(filename); ++ str2ba(argv[2], &bdaddr); ++ channel = (argc > 3) ? atoi(argv[3]) : 10; ++ ++ btobex_push(&bdaddr, channel, filename, alias); ++} ++ ++ ++struct { ++ char *cmd; ++ void (*func)(bdaddr_t *bdaddr, int argc, char **argv); ++ char *opt; ++ char *doc; ++} command[] = { ++ { "push", cmd_push, "<file> <bdaddr> [channel]", "Push a file" }, ++ { NULL, NULL, 0, 0 } ++}; ++ ++ ++static void usage(void) ++{ ++ int i; ++ ++ printf("Bluetooth OBEX tool\n\n"); ++ ++ printf("Usage:\n" ++ "\tobextool [options] <command>\n" ++ "\n"); ++ ++ printf("Options:\n" ++ "\t-i [hciX|bdaddr] Local HCI device or BD Address\n" ++ "\t-h, --help Display help\n" ++ "\n"); ++ ++ printf("Commands:\n"); ++ for (i = 0; command[i].cmd; i++) ++ printf("\t%-6s %-18s\t%s\n", command[i].cmd, ++ command[i].opt ? command[i].opt : " ", ++ command[i].doc); ++ printf("\n"); ++} ++ ++ ++static struct option main_options[] = { ++ { "help", 0, 0, 'h' }, ++ { "device", 1, 0, 'i' }, ++ { 0, 0, 0, 0 } ++}; ++ ++ ++int main(int argc, char *argv[]) ++{ ++ bdaddr_t bdaddr; ++ int i, opt; ++ ++ bacpy(&bdaddr, BDADDR_ANY); ++ ++ while ((opt = getopt_long(argc, argv, "+i:h", main_options, NULL)) != -1) { ++ switch(opt) { ++ case 'i': ++ if (strncmp(optarg, "hci", 3) == 0) ++ hci_devba(atoi(optarg + 3), &bdaddr); ++ else ++ str2ba(optarg, &bdaddr); ++ break; ++ case 'h': ++ usage(); ++ exit(0); ++ default: ++ exit(0); ++ } ++ } ++ ++ argc -= optind; ++ argv += optind; ++ optind = 0; ++ ++ if (argc < 1) { ++ usage(); ++ exit(0); ++ } ++ ++ for (i = 0; command[i].cmd; i++) { ++ if (strncmp(command[i].cmd, argv[0], 3)) ++ continue; ++ command[i].func(&bdaddr, argc, argv); ++ exit(0); ++ } ++ ++ usage(); ++ ++ return 0; ++} +--- obexpush/client/Makefile~add-obextool.patch ++++ obexpush/client/Makefile +@@ -35,11 +35,21 @@ + # + + ussp-push: obex_main.o obex_socket.o +- gcc obex_main.o obex_socket.o ${GLIBLIB} ${OBEXLIB} -o ussp-push ++ $(CC) obex_main.o obex_socket.o ${GLIBLIB} ${OBEXLIB} -o ussp-push + + obex_main.o: obex_main.c obex_socket.h +- gcc ${OBEXINC} ${GLIBINC} -c obex_main.c -o obex_main.o ++ $(CC) ${OBEXINC} ${GLIBINC} -c obex_main.c -o obex_main.o + + obex_socket.o: obex_socket.c obex_socket.h +- gcc ${OBEXINC} ${GLIBINC} -c obex_socket.c -o obex_socket.o ++ $(CC) ${OBEXINC} ${GLIBINC} -c obex_socket.c -o obex_socket.o ++ ++ ++ ++obextool: obextool.o ++ $(CC) obextool.o ${GLIBLIB} ${OBEXLIB} -lbluetooth -o obextool ++ ++obextool.o: obextool.c ++ $(CC) ${OBEXINC} ${GLIBINC} -c obextool.c -o obextool.o ++ ++all: ussp-push obextool + diff --git a/packages/obexpush/obexpush_1.0.0.bb b/packages/obexpush/obexpush_1.0.0.bb new file mode 100644 index 0000000000..b441e7c3a6 --- /dev/null +++ b/packages/obexpush/obexpush_1.0.0.bb @@ -0,0 +1,46 @@ +DESCRIPTION = "Obex Push Utilities" +HOMEPAGE = "http://www.caside.lancs.ac.uk/java_bt.php" +SECTION = "console/network" +LICENSE = "GPL" +DEPENDS = "glib-2.0 openobex bluez-libs" +PR = "r1" + +SRC_URI = "http://www.caside.lancs.ac.uk/bt/obexpush.tar.gz \ + file://add-obextool.patch;patch=1 \ + file://init" +S = "${WORKDIR}/obexpush" + +inherit update-rc.d + +INITSCRIPT_NAME = "opd" +INITSCRIPT_PARAMS = "defaults 33 09" + +export GLIBINC=-I${STAGING_INCDIR}/glib-2.0 +export GLIBLIB=-I${STAGING_LIBDIR} -lglib-2.0 +export OBEXINC=-I${STAGING_INCDIR} +export OBEXLIB=-L${STAGING_LIBDIR} -lopenobex + +do_configure() { + rm -f client/*.o client/ussp-push + rm -f opd/*.o opd/opd + sed -i 's:gcc:${CC}:' */Makefile + sed -i 's:__FUNCTION__::' opd/*.c +} + +do_compile() { + oe_runmake -C client ussp-push + oe_runmake -C client obextool + oe_runmake -C opd +} + +do_install() { + install -d ${D}${bindir} + install -d ${D}${sbindir} + install -m 0755 client/ussp-push ${D}${bindir} + install -m 0755 client/obextool ${D}${bindir} + install -m 0755 opd/opd ${D}${sbindir} + + install -d ${D}${sysconfdir}/init.d + install -m 0644 ${WORKDIR}/init ${D}${sysconfdir}/init.d/opd +} + |