Diff between d3558f1c0b9099d32db30c8ba2ea642991c7512e and fd54935c61aad1994bf4a9500528db3654728a1b

Changed Files

File Additions Deletions Status
gobex/gobex.c +17 -16 modified

Full Patch

diff --git a/gobex/gobex.c b/gobex/gobex.c
index e778cdb..046cca5 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -836,39 +836,40 @@ void g_obex_set_request_function(GObex *obex, GObexRequestFunc func,
 	obex->req_func_data = user_data;
 }
 
-static void handle_response(GObex *obex, GObexPacket *rsp)
-{
-	struct pending_req *req = obex->pending_req;
-
-	if (req->rsp_func)
-		req->rsp_func(obex, NULL, rsp, req->rsp_data);
-
-	pending_req_free(req);
-	obex->pending_req = NULL;
-}
-
-static gboolean handle_connect_req(GObex *obex, GObexPacket *req)
+static void parse_connect_data(GObex *obex, GObexPacket *pkt)
 {
 	const struct connect_data *data;
 	guint16 u16;
 	size_t data_len;
 
-	data = g_obex_packet_get_data(req, &data_len);
+	data = g_obex_packet_get_data(pkt, &data_len);
 	if (data == NULL || data_len != sizeof(*data))
-		return FALSE;
+		return;
 
 	memcpy(&u16, &data->mtu, sizeof(u16));
 
 	obex->tx_mtu = g_ntohs(u16);
 	obex->tx_buf = g_realloc(obex->tx_buf, obex->tx_mtu);
+}
 
-	return TRUE;
+static void handle_response(GObex *obex, GObexPacket *rsp)
+{
+	struct pending_req *req = obex->pending_req;
+
+	if (req->opcode == G_OBEX_OP_CONNECT)
+		parse_connect_data(obex, rsp);
+
+	if (req->rsp_func)
+		req->rsp_func(obex, NULL, rsp, req->rsp_data);
+
+	pending_req_free(req);
+	obex->pending_req = NULL;
 }
 
 static void handle_request(GObex *obex, GObexPacket *req)
 {
 	if (g_obex_packet_get_operation(req, NULL) == G_OBEX_OP_CONNECT)
-		handle_connect_req(obex, req);
+		parse_connect_data(obex, req);
 
 	if (obex->req_func)
 		obex->req_func(obex, req, obex->req_func_data);