File obex-data-server-transferstarted.patch of Package obex-data-server

--- obex-data-server/trunk/src/ods-server-session.c	2008/11/14 12:58:25	2132
+++ obex-data-server/trunk/src/ods-server-session.c	2008/11/14 19:39:52	2138
@@ -252,12 +252,13 @@
 		/* Reset state */
 		server_session->priv->state = ODS_SERVER_SESSION_STATE_OPEN;
 	} else if (ret == 0 && !obex_context->transfer_started_signal_emitted &&
-				obex_context->report_progress && obex_context->remote) {
+				obex_context->report_progress && obex_context->local) {
 		g_signal_emit (server_session, signals [TRANSFER_STARTED], 0,
 						obex_context->remote,
 						obex_context->local,
 						obex_context->target_size);
 		obex_context->transfer_started_signal_emitted = TRUE;
+		g_message ("TransferStarted emitted at obex_transfer_data_exchange_done");
 	}
 }
 
@@ -345,12 +346,14 @@
 	if (ret == 0)
 		remote_display_action (server_session, action);
 	/* also emit TransferStarted signal */
-	if (ret == 0 && obex_context->report_progress) {
+	if (ret == 0 && !obex_context->transfer_started_signal_emitted &&
+			obex_context->report_progress && obex_context->local) {
 		g_signal_emit (server_session, signals [TRANSFER_STARTED],
 						0, obex_context->remote,
 						obex_context->local,
 						obex_context->target_size);
 		obex_context->transfer_started_signal_emitted = TRUE;
+		g_message ("TransferStarted emitted at obex_request_put");
 	}
 	/* In a rare situation when received file is smaller than MTU,
 	 * this function is called after all data is already received.
@@ -511,6 +514,7 @@
 										obex_context->local,
 										obex_context->target_size);
 						obex_context->transfer_started_signal_emitted = TRUE;
+						g_message ("TransferStarted emitted at obex_event at OBEX_EV_REQ");
 					}
 					break;
 				case OBEX_CMD_PUT:
@@ -545,7 +549,7 @@
 				goto readstream_done;
 			}
 			/* This PUT request is definitely not a delete request. Let's
-			 * open a file for writing. */
+			 * open a file for writing in case this wasn't done yet */
 			if (obex_context->remote && !obex_context->local) {
 				if (!ods_obex_srv_new_file (obex_context, server_session->priv->path)) {
 					OBEX_ObjectSetRsp (object, OBEX_RSP_UNAUTHORIZED, 
--- obex-data-server/trunk/src/ods-obex.c	2008/10/31 21:35:22	2088
+++ obex-data-server/trunk/src/ods-obex.c	2008/11/14 19:39:52	2138
@@ -1286,14 +1286,14 @@
 	}
 	
 	g_message ("path: %s", path);
-	/* Open file for writing only if some data was received already */
-	if (obex_context->buf_size > 0) {
+	/* Open file for writing only if this is not a delete request */
+	if (!is_delete) {
 		if (!ods_obex_srv_new_file (obex_context, path)) {
 			ret = -1;
 			OBEX_ObjectSetRsp (object, OBEX_RSP_UNAUTHORIZED, OBEX_RSP_UNAUTHORIZED);
 			goto out;
 		}
-	} else if (is_delete) {
+	} else {
 		/* this is a delete request */
 		obex_context->report_progress = FALSE;
 		obex_context->local = g_build_filename (path, obex_context->remote, NULL);
openSUSE Build Service is sponsored by