From e9b45ff67d32fdc27950a51135b6dabada8334e7 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Sun, 24 Jul 2011 17:57:24 +0100 Subject: initial commit of meta-opie Populate the repository with files from OpenEmbedded at revision 45edf621296daf150c72b876d720861235e5762e - no changes, only rearranged the directory structure to match the new oe-core style and added COPYING.MIT and README. Signed-off-by: Paul Eggleton --- recipes-support/obexpush/files/add-obextool.patch | 461 ++++++++++++++++++++++ recipes-support/obexpush/files/init | 44 +++ recipes-support/obexpush/files/opd_args | 1 + recipes-support/obexpush/obexpush_1.0.0.bb | 53 +++ 4 files changed, 559 insertions(+) create mode 100644 recipes-support/obexpush/files/add-obextool.patch create mode 100644 recipes-support/obexpush/files/init create mode 100644 recipes-support/obexpush/files/opd_args create mode 100644 recipes-support/obexpush/obexpush_1.0.0.bb (limited to 'recipes-support/obexpush') diff --git a/recipes-support/obexpush/files/add-obextool.patch b/recipes-support/obexpush/files/add-obextool.patch new file mode 100644 index 0000000..34a7625 --- /dev/null +++ b/recipes-support/obexpush/files/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 ++ * ++ * ++ * 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 ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++ ++ ++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, " [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] \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/recipes-support/obexpush/files/init b/recipes-support/obexpush/files/init new file mode 100644 index 0000000..a9891ef --- /dev/null +++ b/recipes-support/obexpush/files/init @@ -0,0 +1,44 @@ +#!/bin/sh +# +# Start or stop the OBEX Push daemon. +# +# Written by Michael Haynie +# +# 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/recipes-support/obexpush/files/opd_args b/recipes-support/obexpush/files/opd_args new file mode 100644 index 0000000..26afc0e --- /dev/null +++ b/recipes-support/obexpush/files/opd_args @@ -0,0 +1 @@ +OPD_ARGS="--mode OBEX --path /var/obexpush --channel 10 --sdp --metadata" diff --git a/recipes-support/obexpush/obexpush_1.0.0.bb b/recipes-support/obexpush/obexpush_1.0.0.bb new file mode 100644 index 0000000..5701c28 --- /dev/null +++ b/recipes-support/obexpush/obexpush_1.0.0.bb @@ -0,0 +1,53 @@ +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 = "r7" + +SRC_URI = "http://www.caside.lancs.ac.uk/bt/obexpush.tar.gz \ + file://add-obextool.patch \ + file://init \ + file://opd_args" +S = "${WORKDIR}/obexpush" + +inherit update-rc.d + +INITSCRIPT_NAME = "opd" +INITSCRIPT_PARAMS = "defaults 33 9" + +export GLIBINC = "-I${STAGING_INCDIR}/glib-2.0 -I${STAGING_LIBDIR}/glib-2.0/include" +export GLIBLIB = "-I${STAGING_LIBDIR} -lglib-2.0" +export OBEXINC = "-I${STAGING_INCDIR}" +export OBEXLIB = "${LDFLAGS} -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 -d ${D}${sysconfdir}/default + install -d ${D}/var/obexpush + install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/opd + install -m 0755 ${WORKDIR}/opd_args ${D}${sysconfdir}/default/opd_args +} + + +SRC_URI[md5sum] = "edb66ba97fe6c84b6160c670c4bcdea8" +SRC_URI[sha256sum] = "341c6865aa392b6cf056e1bd9cda53d2f31a942460087ad22d6f6dc91bb0bd0e" -- cgit 1.2.3-korg