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 | 43 ++++++-------------------------------------
lib/obex_object.h | 2 +-
3 files changed, 8 insertions(+), 39 deletions(-)
diff --git a/lib/obex.c b/lib/obex.c
index 991f06f..277dbf2 100644
--- a/lib/obex.c
+++ b/lib/obex.c
@@ -574,7 +574,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..f0b4b7f 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 -1;
+
object->suspend = 1;
return 0;
}
-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)
- 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);
+ if (object->suspend == 0)
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;
+ object->suspend = 0;
return 0;
}
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
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Openobex-users mailing list
[email protected]
http://lists.sourceforge.net/lists/listinfo/openobex-users