Index: obexftp-errcode/apps/obexftp.c
===================================================================
--- obexftp-errcode/apps/obexftp.c	(revision 202)
+++ obexftp-errcode/apps/obexftp.c	(working copy)
@@ -70,6 +70,7 @@
 		break;
 
 	case OBEXFTP_EV_ERR:
+		// OBEX_EV_REQDONE: obex_rsp=43  (SE user reject)
 		fprintf(stderr, "failed: %s\n", msg);
 		break;
 	case OBEXFTP_EV_OK:
@@ -253,7 +254,7 @@
 		if(cli == NULL) {
 			fprintf(stderr, "Error opening obexftp-client\n");
 			exit(1);
-			//return FALSE;
+			//return -1;
 		}
 		if (!use_conn) {
 			cli->quirks &= ~OBEXFTP_CONN_HEADER;
@@ -267,7 +268,7 @@
 		/* Connect */
 		ret = obexftp_connect_src(cli, src_dev, device, channel, uuid, uuid_len);
 		if (ret >= 0)
-       			return TRUE;
+       			return ret;
 		switch (errno) {
 		
 		case ETIMEDOUT:
@@ -276,7 +277,7 @@
 
 		case ECONNREFUSED:
 			perror("The user may have rejected the transfer");
-			return FALSE;
+			return -errno;
 
 		case EHOSTDOWN:
 			perror("The device may be out of range or turned off");
@@ -296,14 +297,14 @@
 
 	obexftp_close(cli);
 	cli = NULL;
-	return FALSE;
+	return ret;
 }
 
 /* connect, possibly without fbs uuid. won't re-connect */
 static int cli_connect()
 {
 	if (cli != NULL) {
-		return TRUE;
+		return 0;
 	}
 
 	/* complete bt address if necessary */
@@ -311,10 +312,10 @@
 		find_bt(device, &device, &channel);
 		// we should free() the find_bt result at some point
 	}
-	if (!cli_connect_uuid(use_uuid, use_uuid_len))
+	if (cli_connect_uuid(use_uuid, use_uuid_len) < 0)
 		exit(1);
 
-	return TRUE;
+	return 0;
 }
 
 static void cli_disconnect()
@@ -332,7 +333,7 @@
 {
 	int rsp[10];
 	
-	if (!cli_connect_uuid(uuid, uuid_len)) {
+	if (cli_connect_uuid(uuid, uuid_len) < 0) {
 		printf("couldn't connect.\n");
 		return;
 	}
@@ -422,10 +423,11 @@
 
 int main(int argc, char *argv[])
 {
-	int verbose=0;
+	int verbose = 0;
 	int most_recent_cmd = 0;
 	char *output_file = NULL;
 	char *move_src = NULL;
+	int ret = 0;
 
 	/* preset mode of operation depending on our name */
 	if (strstr(argv[0], "ls") != NULL)	most_recent_cmd = 'l';
@@ -599,7 +601,7 @@
 				optarg = argv[optind];
 				optind++;
 			}
-			if(cli_connect ()) {
+			if (cli_connect() >= 0) {
 				/* List folder */
 				stat_entry_t *ent;
 				void *dir = obexftp_opendir(cli, optarg);
@@ -621,25 +623,25 @@
 				optarg = argv[optind];
 				optind++;
 			}
-			if(cli_connect ()) {
+			if (cli_connect() >= 0) {
 				/* List folder */
-				(void) obexftp_list(cli, NULL, optarg);
+				ret = obexftp_list(cli, NULL, optarg);
 			}
 			most_recent_cmd = c;
 			break;
 
 		case 'c':
-			if(cli_connect ()) {
+			if (cli_connect() >= 0) {
 				/* Change dir */
-				(void) obexftp_setpath(cli, optarg, 0);
+				ret = obexftp_setpath(cli, optarg, 0);
 			}
 			most_recent_cmd = c;
 			break;
 
 		case 'C':
-			if(cli_connect ()) {
+			if (cli_connect() >= 0) {
 				/* Change or Make dir */
-				(void) obexftp_setpath(cli, optarg, 1);
+				ret = obexftp_setpath(cli, optarg, 1);
 			}
 			most_recent_cmd = c;
 			break;
@@ -650,44 +652,44 @@
 
 		case 'g':
 		case 'G':
-			if(cli_connect ()) {
+			if (cli_connect() >= 0) {
 				char *p; /* basename or output_file */
 				if ((p = strrchr(optarg, '/')) != NULL) p++;
 				else p = optarg;
 				if (output_file) p = output_file;
 				/* Get file */
 				if (obexftp_get(cli, p, optarg) && c == 'G')
-					(void) obexftp_del(cli, optarg);
+					ret = obexftp_del(cli, optarg);
 				output_file = NULL;
 			}
 			most_recent_cmd = c;
 			break;
 
 		case 'p':
-			if(cli_connect ()) {
+			if (cli_connect() >= 0) {
 				char *p; /* basename or output_file */
 				if ((p = strrchr(optarg, '/')) != NULL) p++;
 				else p = optarg;
 				if (output_file) p = output_file;
 				/* Send file */
-				(void) obexftp_put_file(cli, optarg, p);
+				ret = obexftp_put_file(cli, optarg, p);
 				output_file = NULL;
 			}
 			most_recent_cmd = c;
 			break;
 
 		case 'k':
-			if(cli_connect ()) {
+			if (cli_connect() >= 0) {
 				/* Delete file */
-				(void) obexftp_del(cli, optarg);
+				ret = obexftp_del(cli, optarg);
 			}
 			most_recent_cmd = c;
 			break;
 
 		case 'X':
-			if(cli_connect ()) {
+			if (cli_connect() >= 0) {
 				/* Get capabilities */
-				(void) obexftp_get_capability(cli, optarg, 0);
+				ret = obexftp_get_capability(cli, optarg, 0);
 			}
 			most_recent_cmd = 'h'; // not really
 			break;
@@ -701,7 +703,7 @@
 			break;
 
 		case 'x':
-			if(cli_connect ()) {
+			if (cli_connect() >= 0) {
 				/* for S65 */
 				(void) obexftp_disconnect (cli);
 				(void) obexftp_connect_uuid (cli, device, channel, UUID_S45, sizeof(UUID_S45));
@@ -719,9 +721,9 @@
 				move_src = optarg;
 				break;
 			}
-			if(cli_connect ()) {
+			if (cli_connect() >= 0) {
 				/* Rename a file */
-				(void) obexftp_rename(cli, move_src, optarg);
+				ret = obexftp_rename(cli, move_src, optarg);
 			}
 			move_src = NULL;
 			break;
@@ -782,6 +784,8 @@
 			printf("Try `%s --help' for more information.\n",
 				 argv[0]);
 		}
+		if (ret < 0)
+			printf("The operation failed with return code %d\n", -ret);
 	}
 
 	if (most_recent_cmd == 0)
@@ -796,6 +800,6 @@
 
 	cli_disconnect ();
 
-	exit (0);
+	exit (-ret);
 
 }
Index: obexftp-errcode/obexftp/client.c
===================================================================
--- obexftp-errcode/obexftp/client.c	(revision 202)
+++ obexftp-errcode/obexftp/client.c	(working copy)
@@ -392,6 +392,7 @@
 	case OBEX_EV_LINKERR:
 		cli->finished = TRUE;
 		cli->success = FALSE;
+		DEBUG(2, "%s() OBEX_EV_LINKERR\n", __func__);
 		break;
 	
 	case OBEX_EV_STREAMEMPTY:
@@ -431,7 +432,7 @@
 	if(cli->success)
 		return 1;
 	else
-		return -1;
+		return - cli->obex_rsp;
 }
 
 
Index: obexftp-errcode/obexftp/obexftp.h
===================================================================
--- obexftp-errcode/obexftp/obexftp.h	(revision 202)
+++ obexftp-errcode/obexftp/obexftp.h	(working copy)
@@ -32,7 +32,7 @@
 
 /** ObexFTP message callback events */
 enum {
-	OBEXFTP_EV_ERRMSG,
+	OBEXFTP_EV_ERRMSG, /* not used */
 
 	OBEXFTP_EV_OK,
 	OBEXFTP_EV_ERR,
