This also makes the public type an enum (like it was for the internal type) but
the names for the values stay the same.
---
include/openobex/obex_const.h | 7 +++++--
lib/defines.h | 5 -----
lib/obex.c | 6 +++---
lib/obex_client.c | 12 ++++++------
lib/obex_main.c | 9 +++------
lib/obex_object.c | 2 +-
6 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/include/openobex/obex_const.h b/include/openobex/obex_const.h
index 8276aae..ff147df 100644
--- a/include/openobex/obex_const.h
+++ b/include/openobex/obex_const.h
@@ -145,8 +145,11 @@ typedef union {
//obex_bluetooth_intf_t bt; // to be added
} obex_interface_t;
-#define OBEX_MODE_CLIENT 0
-#define OBEX_MODE_SERVER 1
+/** Possible modes */
+enum obex_mode {
+ OBEX_MODE_CLIENT = 0, /**< client mode */
+ OBEX_MODE_SERVER = 1, /**< server mode */
+};
/* Possible events */
#define OBEX_EV_PROGRESS 0 /* Progress has been made */
diff --git a/lib/defines.h b/lib/defines.h
index 5935930..051509a 100644
--- a/lib/defines.h
+++ b/lib/defines.h
@@ -18,11 +18,6 @@
#define OBEX_VERSION 0x10 /* OBEX Protocol Version 1.1 */
-enum obex_mode {
- MODE_SRV,
- MODE_CLI,
-};
-
enum obex_state {
STATE_IDLE,
STATE_SEND,
diff --git a/lib/obex.c b/lib/obex.c
index eaa50b0..7bb5bfb 100644
--- a/lib/obex.c
+++ b/lib/obex.c
@@ -118,7 +118,7 @@ obex_t * CALLAPI OBEX_Init(int transport, obex_event_t
eventcb,
self->eventcb = eventcb;
self->init_flags = flags;
- self->mode = MODE_SRV;
+ self->mode = OBEX_MODE_SERVER;
self->state = STATE_IDLE;
self->rsp_mode = OBEX_RSP_MODE_NORMAL;
@@ -383,7 +383,7 @@ obex_t *CALLAPI OBEX_ServerAccept(obex_t *server,
obex_event_t eventcb,
goto out_err;
obex_transport_split(self, server);
- self->mode = MODE_SRV;
+ self->mode = OBEX_MODE_SERVER;
self->state = STATE_IDLE;
self->rsp_mode = server->rsp_mode;
@@ -532,7 +532,7 @@ int CALLAPI OBEX_Request(obex_t *self, obex_object_t
*object)
object->rsp_mode = self->rsp_mode;
self->object = object;
- self->mode = MODE_CLI;
+ self->mode = OBEX_MODE_CLIENT;
self->state = STATE_SEND;
self->substate = SUBSTATE_PREPARE_TX;
diff --git a/lib/obex_client.c b/lib/obex_client.c
index efaf9f3..0282886 100644
--- a/lib/obex_client.c
+++ b/lib/obex_client.c
@@ -99,7 +99,7 @@ static int obex_client_abort(obex_t *self)
if (event == OBEX_EV_LINKERR)
ret = -1;
- self->mode = MODE_SRV;
+ self->mode = OBEX_MODE_SERVER;
self->state = STATE_IDLE;
return ret;
}
@@ -176,7 +176,7 @@ static int obex_client_recv(obex_t *self)
if (obex_parse_connect_header(self, msg) < 0) {
obex_deliver_event(self, OBEX_EV_PARSEERR,
self->object->opcode, 0, TRUE);
- self->mode = MODE_SRV;
+ self->mode = OBEX_MODE_SERVER;
self->state = STATE_IDLE;
return -1;
}
@@ -198,7 +198,7 @@ static int obex_client_recv(obex_t *self)
if (ret < 0) {
obex_deliver_event(self, OBEX_EV_PARSEERR,
self->object->opcode, 0, TRUE);
- self->mode = MODE_SRV;
+ self->mode = OBEX_MODE_SERVER;
self->state = STATE_IDLE;
return -1;
}
@@ -216,7 +216,7 @@ static int obex_client_recv(obex_t *self)
DEBUG(3, "Done! Rsp=%02x!\n", rsp);
obex_deliver_event(self, OBEX_EV_REQDONE, self->object->opcode,
rsp, TRUE);
- self->mode = MODE_SRV;
+ self->mode = OBEX_MODE_SERVER;
self->state = STATE_IDLE;
return 0;
}
@@ -234,7 +234,7 @@ static int obex_client_send_transmit_tx(obex_t *self)
/* Error while sending */
obex_deliver_event(self, OBEX_EV_LINKERR,
self->object->opcode, 0, TRUE);
- self->mode = MODE_SRV;
+ self->mode = OBEX_MODE_SERVER;
self->state = STATE_IDLE;
} else if (ret == 1) {
@@ -344,7 +344,7 @@ static int obex_client_send(obex_t *self)
if (ret < 0) {
obex_deliver_event(self, OBEX_EV_PARSEERR,
self->object->opcode, 0, TRUE);
- self->mode = MODE_SRV;
+ self->mode = OBEX_MODE_SERVER;
self->state = STATE_IDLE;
return -1;
}
diff --git a/lib/obex_main.c b/lib/obex_main.c
index 03819a2..690dd97 100644
--- a/lib/obex_main.c
+++ b/lib/obex_main.c
@@ -192,10 +192,7 @@ void obex_deliver_event(obex_t *self, int event, int cmd,
int rsp, int del)
if (del == TRUE)
self->object = NULL;
- if (self->mode == MODE_SRV)
- self->eventcb(self, object, OBEX_MODE_SERVER, event, cmd, rsp);
- else
- self->eventcb(self, object, OBEX_MODE_CLIENT, event, cmd, rsp);
+ self->eventcb(self, object, self->mode, event, cmd, rsp);
if (del == TRUE)
obex_object_delete(object);
@@ -267,10 +264,10 @@ int obex_data_request(obex_t *self, buf_t *msg)
static int obex_mode(obex_t *self)
{
switch (self->mode) {
- case MODE_SRV:
+ case OBEX_MODE_SERVER:
return obex_server(self);
- case MODE_CLI:
+ case OBEX_MODE_CLIENT:
return obex_client(self);
default:
diff --git a/lib/obex_object.c b/lib/obex_object.c
index f0b4b7f..9f84862 100644
--- a/lib/obex_object.c
+++ b/lib/obex_object.c
@@ -278,7 +278,7 @@ int obex_object_addheader(obex_t *self, obex_object_t
*object, uint8_t hi,
static uint8_t obex_object_getcmd(const obex_t *self,
const obex_object_t *object)
{
- if (self->mode == MODE_SRV)
+ if (self->mode == OBEX_MODE_SERVER)
return object->cmd;
else
return (object->opcode & ~OBEX_FINAL);
--
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