Now that the multi-level state machine is used, the resume function can be
simplified a lot. To actually continue now, you have to call the
OBEX_HandleInput() function.
---
 lib/obex.c        |    2 +-
 lib/obex_object.c |   45 +++++++--------------------------------------
 lib/obex_object.h |    2 +-
 3 files changed, 9 insertions(+), 40 deletions(-)

diff --git a/lib/obex.c b/lib/obex.c
index 5e16fc4..3aa6bac 100644
--- a/lib/obex.c
+++ b/lib/obex.c
@@ -575,7 +575,7 @@ LIB_SYMBOL
 int CALLAPI OBEX_ResumeRequest(obex_t *self)
 {
        obex_return_val_if_fail(self->object != NULL, -1);
-       return obex_object_resume(self, self->object);
+       return obex_object_resume(self->object);
 }
 
 /**
diff --git a/lib/obex_object.c b/lib/obex_object.c
index f888a2d..a7d5cb3 100644
--- a/lib/obex_object.c
+++ b/lib/obex_object.c
@@ -1146,49 +1146,18 @@ int obex_object_readstream(obex_t *self, obex_object_t 
*object,
 
 int obex_object_suspend(obex_object_t *object)
 {
+       if (object->suspend == 1)
+               return 0;
+
        object->suspend = 1;
-       return 0;
+       return 1;
 }
 
-int obex_object_resume(obex_t *self, obex_object_t *object)
+int obex_object_resume(obex_object_t *object)
 {
-       int ret;
-       uint8_t cmd = obex_object_getcmd(self, object);
-       int allowfinalcmd = TRUE, forcefinalbit = FALSE;
-
-       if (!object->suspend)
+       if (object->suspend == 0)
                return 0;
 
        object->suspend = 0;
-
-       if (object->first_packet_sent && !object->continue_received)
-               return 0;
-
-       if (self->mode == MODE_SRV) {
-               forcefinalbit = TRUE;
-               if (self->state == STATE_REC)
-                       allowfinalcmd = FALSE;
-       }
-
-       ret = obex_object_send(self, object, allowfinalcmd, forcefinalbit);
-
-       if (ret < 0) {
-               obex_deliver_event(self, OBEX_EV_LINKERR, cmd, 0, TRUE);
-               return -1;
-       } else if (ret == 0) {
-               obex_deliver_event(self, OBEX_EV_PROGRESS, cmd, 0, FALSE);
-               object->first_packet_sent = 1;
-               object->continue_received = 0;
-       } else {
-               if (self->mode == MODE_SRV) {
-                       obex_deliver_event(self, OBEX_EV_REQDONE,
-                                                       cmd, 0, TRUE);
-                       self->state = STATE_IDLE;
-                       return 0;
-               }
-       }
-
-       self->state = STATE_REC;
-
-       return 0;
+       return 1;
 }
diff --git a/lib/obex_object.h b/lib/obex_object.h
index 5bcbe0b..31a7d80 100644
--- a/lib/obex_object.h
+++ b/lib/obex_object.h
@@ -109,6 +109,6 @@ int obex_object_receive(struct obex *self, struct 
databuffer *msg);
 
 int obex_object_readstream(struct obex *self, struct obex_object *object, 
const uint8_t **buf);
 int obex_object_suspend(struct obex_object *object);
-int obex_object_resume(struct obex *self, struct obex_object *object);
+int obex_object_resume(struct obex_object *object);
 
 #endif
-- 
1.7.5.4


------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
Openobex-users mailing list
Openobex-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/openobex-users

Reply via email to