a958c0e
--- /dev/null	2007-02-06 15:45:45.046837255 +0100
0eb59d3
+++ openobex-1.3/src/obex_push.1	2007-02-07 09:21:04.000000000 +0100
a958c0e
@@ -0,0 +1,39 @@
a958c0e
+.TH OBEX_PUSH 1 "04 June 2003" "1.0.0"  "openobex-apps"
a958c0e
+.SH NAME
a958c0e
+obex_push \- Push and Receive Files over the Bluetooth OBEX Push Channel
a958c0e
+.SH SYNOPSIS
a958c0e
+obex_push \fI[\fR\fB<channel>\fR\fI]  \fI[\fR\fB<bdaddr> <filename>\fR\fI] 
a958c0e
+.SH DESCRIPTION
a958c0e
+obex_push can send and receive files over the Bluetooth OBEX Push Channel.
a958c0e
+.PP
a958c0e
+To configure your bluetooth device, you should do the following:
a958c0e
+.PP
a958c0e
+Add modules into /etc/modules.conf: 
a958c0e
+.PP
a958c0e
+.RS
a958c0e
+.nf
a958c0e
+alias net-pf-31 bluez
a958c0e
+alias bt-proto-0 l2cap
a958c0e
+alias bt-proto-2 sco
a958c0e
+alias bt-proto-3 rfcomm
a958c0e
+.fi
a958c0e
+.RE
a958c0e
+.PP
a958c0e
+Link your bluetooth device with your computer.
a958c0e
+.PP
a958c0e
+You can see the SDP services with:
a958c0e
+.PP
a958c0e
+$ sdptool browse <bdaddr>
a958c0e
+.PP
a958c0e
+.SH OPTIONS
a958c0e
+If no options are given, any files sent over bluetooth will be received over channel 10 and stored in /tmp.
a958c0e
+.PP 
a958c0e
+If \fI<bdaddr>\fR and \fI<filename>\fR are given, the file will be send to the device specified with \fI<bdaddr>\fR.
a958c0e
+.TP
a958c0e
+\fI<channel>\fR - The bluetooth channel to use. Lookup the OBEX Push channel with sdptool browse <bdaddr>.
a958c0e
+.TP
a958c0e
+\fI<bdaddr>\fR - The bluetooth address <bdaddr> of the device to send to.
a958c0e
+.TP
a958c0e
+\fI<filename>\fR - The file to send.
a958c0e
+.SH AUTHOR
a958c0e
+Harald Hoyer \fI<harald@redhat.com>\fR
a958c0e
--- /dev/null	2007-02-06 15:45:45.046837255 +0100
0eb59d3
+++ openobex-1.3/apps/obex_push.c	2007-02-07 09:36:56.000000000 +0100
a958c0e
@@ -0,0 +1,177 @@
a958c0e
+/*********************************************************************
a958c0e
+ *                
a958c0e
+ * Filename:      obex_push.c
a958c0e
+ * Version:       0.1
a958c0e
+ * Description:   Demonstrates use of PUSH command
a958c0e
+ * Status:        Experimental.
a958c0e
+ * Author:        Harald Hoyer 
a958c0e
+ *
a958c0e
+ *     modified irobex_palm3.c
a958c0e
+ * 
0eb59d3
+ *     Copyright (C) 2003-2007 Harald Hoyer, All Rights Reserved.
0eb59d3
+ *     Copyright (C) 2003-2007 Red Hat, Inc.
a958c0e
+ *     
a958c0e
+ *     This program is free software; you can redistribute it and/or 
a958c0e
+ *     modify it under the terms of the GNU General Public License as 
a958c0e
+ *     published by the Free Software Foundation; either version 2 of 
a958c0e
+ *     the License, or (at your option) any later version.
a958c0e
+ * 
a958c0e
+ *     This program is distributed in the hope that it will be useful,
a958c0e
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
a958c0e
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a958c0e
+ *     GNU General Public License for more details.
a958c0e
+ * 
a958c0e
+ *     You should have received a copy of the GNU General Public License 
a958c0e
+ *     along with this program; if not, write to the Free Software 
a958c0e
+ *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
a958c0e
+ *     MA 02111-1307 USA
a958c0e
+ *
a958c0e
+ *
a958c0e
+ *     Start without arguments to receive a file.
a958c0e
+ *     Start with address and filename as argument to send a file. 
a958c0e
+ *     
a958c0e
+ ********************************************************************/
a958c0e
+
a958c0e
+#include <stdio.h>
a958c0e
+#include <stdlib.h>
a958c0e
+
a958c0e
+#ifndef _WIN32
a958c0e
+#include <unistd.h>
a958c0e
+#endif
a958c0e
+
a958c0e
+#ifdef HAVE_CONFIG_H
a958c0e
+#include <config.h>
a958c0e
+#endif
a958c0e
+
a958c0e
+#if _WIN32
a958c0e
+#include <winsock.h>
a958c0e
+#else
a958c0e
+#include <sys/socket.h>
a958c0e
+#include <arpa/inet.h>
a958c0e
+#include <netdb.h>
a958c0e
+#include <netinet/in.h>
a958c0e
+#endif /* _WIN32 */
a958c0e
+
a958c0e
+#include <libgen.h>
a958c0e
+
a958c0e
+#include <bluetooth/bluetooth.h>
a958c0e
+#include <bluetooth/rfcomm.h>
a958c0e
+
a958c0e
+
a958c0e
+#include <openobex/obex.h>
a958c0e
+#include "obex_put_common.h"
a958c0e
+#include "obex_io.h"
a958c0e
+
a958c0e
+#define OBEX_PUSH_HANDLE	10
a958c0e
+
a958c0e
+#define TRUE  1
a958c0e
+#define FALSE 0
a958c0e
+
a958c0e
+obex_t *handle = NULL;
a958c0e
+volatile int finished = FALSE;
a958c0e
+extern int last_rsp;
a958c0e
+
a958c0e
+/*
a958c0e
+ * Function main (argc, )
a958c0e
+ *
a958c0e
+ *    Starts all the fun!
a958c0e
+ *
a958c0e
+ */
a958c0e
+int main(int argc, char *argv[])
a958c0e
+{
a958c0e
+	obex_object_t *object;
a958c0e
+	int ret, exitval = EXIT_SUCCESS;
a958c0e
+	bdaddr_t bdaddr;
a958c0e
+	uint8_t channel;
a958c0e
+	char *filename;
a958c0e
+	if ((argc < 1) || (argc > 4))	{
a958c0e
+		printf ("Usage: %s [<channel>] [<bdaddr> <filename>]\n", argv[0]); 
a958c0e
+		return -1;
a958c0e
+	}
a958c0e
+	handle = OBEX_Init(OBEX_TRANS_BLUETOOTH, obex_event, 0);
a958c0e
+
a958c0e
+	switch (argc) {
a958c0e
+#ifdef HAVE_BLUETOOTH
a958c0e
+	case 4:
a958c0e
+		channel = atoi(argv[1]);
a958c0e
+		str2ba(argv[2], &bdaddr);
a958c0e
+		filename = argv[3];
a958c0e
+		break;
a958c0e
+	case 3:
a958c0e
+		str2ba(argv[1], &bdaddr);
a958c0e
+		filename = argv[2];
a958c0e
+		channel = OBEX_PUSH_HANDLE;
a958c0e
+		break;
a958c0e
+	case 2:
a958c0e
+		channel = atoi(argv[1]);
a958c0e
+		break;
a958c0e
+	case 1:
a958c0e
+		channel = OBEX_PUSH_HANDLE;
a958c0e
+		break;
a958c0e
+#endif
a958c0e
+	default:
a958c0e
+		printf("Wrong number of arguments\n");
a958c0e
+		exit(0);
a958c0e
+	}
a958c0e
+
a958c0e
+	printf("Send and receive files through bluetooth OBEX PUSH channel %d\n", channel);
a958c0e
+	if (argc <= 2)	{
a958c0e
+		char cmd[1024];
a958c0e
+		int ret;
a958c0e
+		/* We are server*/
a958c0e
+		snprintf(cmd, sizeof(cmd), "sdptool add --channel=%d OPUSH", channel);
a958c0e
+		ret = system(cmd);
a958c0e
+		if (ret != 0) {
a958c0e
+			fprintf(stderr, "Command failed: %s\n", cmd);
a958c0e
+		}
a958c0e
+		
a958c0e
+		printf("Waiting for files\n");
a958c0e
+		BtOBEX_ServerRegister(handle, NULL, channel);
a958c0e
+		
a958c0e
+		while (!finished)
a958c0e
+			OBEX_HandleInput(handle, 1);
a958c0e
+	}
a958c0e
+	else {
a958c0e
+		char *basefilename = basename(strdup(filename));
a958c0e
+		/* We are a client */
a958c0e
+		if (bacmp(&bdaddr, BDADDR_ANY) == 0) {
a958c0e
+			printf("Device address error! (Bluetooth)\n");
a958c0e
+			return -1;
a958c0e
+		}
a958c0e
+
a958c0e
+		/* Try to connect to peer */
a958c0e
+		ret = BtOBEX_TransportConnect(handle, BDADDR_ANY, &bdaddr,
a958c0e
+					      channel);
a958c0e
+		if (ret < 0) {
a958c0e
+			printf("Sorry, unable to connect!\n");
a958c0e
+			return EXIT_FAILURE;
a958c0e
+		}
a958c0e
+
a958c0e
+		object = OBEX_ObjectNew(handle, OBEX_CMD_CONNECT);
a958c0e
+		ret = do_sync_request(handle, object, FALSE);
a958c0e
+		if ((last_rsp != OBEX_RSP_SUCCESS) || (ret < 0)) {
a958c0e
+			printf("Sorry, unable to connect!\n");
a958c0e
+			return EXIT_FAILURE;
a958c0e
+		}
a958c0e
+		if ((object = build_object_from_file(handle, filename,
a958c0e
+					basefilename)))
a958c0e
+		{
a958c0e
+			ret = do_sync_request(handle, object, FALSE);
a958c0e
+			if ((last_rsp != OBEX_RSP_SUCCESS) || (ret < 0))
a958c0e
+				exitval = EXIT_FAILURE;
a958c0e
+		} else
a958c0e
+			exitval = EXIT_FAILURE;
a958c0e
+
a958c0e
+		object = OBEX_ObjectNew(handle, OBEX_CMD_DISCONNECT);
a958c0e
+		ret = do_sync_request(handle, object, FALSE);
a958c0e
+		if ((last_rsp != OBEX_RSP_SUCCESS) || (ret < 0))
a958c0e
+			exitval = EXIT_FAILURE;
a958c0e
+
a958c0e
+		if (exitval == EXIT_SUCCESS)
a958c0e
+			printf("PUT successful\n");
a958c0e
+		else
a958c0e
+			printf("PUT failed\n");
a958c0e
+	}
a958c0e
+//	sleep(1);
a958c0e
+	return exitval;
a958c0e
+}
0eb59d3
--- /dev/null	2007-02-06 15:45:45.046837255 +0100
0eb59d3
+++ openobex-1.3/apps/obex_push.1	2007-02-07 09:21:04.000000000 +0100
a958c0e
@@ -0,0 +1,26 @@
a958c0e
+.TH OBEX_PUSH 1 "07 Feb 2007" "1.0.0"  "openobex-apps"
a958c0e
+.SH NAME
a958c0e
+obex_push \- Push and Receive Files over the Bluetooth OBEX Push Channel
a958c0e
+.SH SYNOPSIS
a958c0e
+obex_push \fI[\fR\fB<channel>\fR\fI]  \fI[\fR\fB<bdaddr> <filename>\fR\fI] 
a958c0e
+.SH DESCRIPTION
a958c0e
+obex_push can send and receive files over the Bluetooth OBEX Push Channel.
a958c0e
+.PP
a958c0e
+Link your bluetooth device with your computer.
a958c0e
+.PP
a958c0e
+You can see the SDP services with:
a958c0e
+.PP
a958c0e
+$ sdptool browse <bdaddr>
a958c0e
+.PP
a958c0e
+.SH OPTIONS
a958c0e
+If no options are given, any files sent over bluetooth will be received over channel 10 and stored in /tmp.
a958c0e
+.PP 
a958c0e
+If \fI<bdaddr>\fR and \fI<filename>\fR are given, the file will be send to the device specified with \fI<bdaddr>\fR.
a958c0e
+.TP
a958c0e
+\fI<channel>\fR - The bluetooth channel to use. Lookup the OBEX Push channel with sdptool browse <bdaddr>.
a958c0e
+.TP
a958c0e
+\fI<bdaddr>\fR - The bluetooth address <bdaddr> of the device to send to.
a958c0e
+.TP
a958c0e
+\fI<filename>\fR - The file to send.
a958c0e
+.SH AUTHOR
a958c0e
+Harald Hoyer \fI<harald@redhat.com>\fR
a958c0e
--- openobex-1.3/apps/Makefile.am.push	2006-01-03 19:36:15.000000000 +0100
0eb59d3
+++ openobex-1.3/apps/Makefile.am	2007-02-07 09:21:04.000000000 +0100
a958c0e
@@ -6,7 +6,7 @@
a958c0e
 	obex_io.c obex_io.h \
a958c0e
 	obex_put_common.c obex_put_common.h
a958c0e
 
a958c0e
-bin_PROGRAMS = irxfer obex_tcp irobex_palm3 obex_test
a958c0e
+bin_PROGRAMS = irxfer obex_tcp irobex_palm3 obex_test obex_push
a958c0e
 
a958c0e
 obex_test_SOURCES = \
a958c0e
 	obex_test.c obex_test.h \
7f0aeff
@@ -16,6 +16,11 @@
a958c0e
 
7f0aeff
 obex_test_LDADD = libmisc.a $(top_builddir)/lib/libopenobex.la @BLUETOOTH_LIBS@
a958c0e
 
a958c0e
+obex_push_SOURCES = obex_push.c
7f0aeff
+obex_push_LDADD = $(top_builddir)/lib/libopenobex.la @BLUETOOTH_LIBS@ @USB_LIBS@ libmisc.a
a958c0e
+
a958c0e
+man_MANS = obex_push.1
a958c0e
+
7f0aeff
 AM_CFLAGS = @OPENOBEX_CFLAGS@
7f0aeff
 
7f0aeff
 LDADD = libmisc.a $(top_builddir)/lib/libopenobex.la
a958c0e