summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/ContextBase.cpp3
-rw-r--r--core/ContextBase.h3
-rw-r--r--core/LocAdapterBase.cpp22
-rw-r--r--core/LocAdapterBase.h6
-rw-r--r--core/LocApiBase.cpp29
-rw-r--r--core/LocApiBase.h18
6 files changed, 47 insertions, 34 deletions
diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp
index 7879015..dc47ffb 100644
--- a/core/ContextBase.cpp
+++ b/core/ContextBase.cpp
@@ -91,7 +91,8 @@ ContextBase::ContextBase(const MsgTask* msgTask,
const char* libName) :
mLBSProxy(getLBSProxy(libName)),
mMsgTask(msgTask),
- mLocApi(createLocApi(exMask))
+ mLocApi(createLocApi(exMask)),
+ mLocApiProxy(mLocApi->getLocApiProxy())
{
}
diff --git a/core/ContextBase.h b/core/ContextBase.h
index 93cb31f..b41dd78 100644
--- a/core/ContextBase.h
+++ b/core/ContextBase.h
@@ -46,7 +46,7 @@ protected:
const LBSProxyBase* mLBSProxy;
const MsgTask* mMsgTask;
LocApiBase* mLocApi;
-
+ LocApiProxyBase *mLocApiProxy;
public:
ContextBase(const MsgTask* msgTask,
LOC_API_ADAPTER_EVENT_MASK_T exMask,
@@ -55,6 +55,7 @@ public:
inline const MsgTask* getMsgTask() { return mMsgTask; }
inline LocApiBase* getLocApi() { return mLocApi; }
+ inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; }
inline bool hasAgpsExt() { return mLBSProxy->hasAgpsExt(); }
inline void requestUlp(LocAdapterBase* adapter,
unsigned long capabilities) {
diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp
index 48d179f..8bbe873 100644
--- a/core/LocAdapterBase.cpp
+++ b/core/LocAdapterBase.cpp
@@ -36,26 +36,6 @@
namespace loc_core {
-struct LocOpenMsg : public LocMsg {
- LocAdapterBase* mLocAdapter;
- LocApiBase* mLocApi;
- inline LocOpenMsg(LocAdapterBase* locAdapter,
- LocApiBase* locApi) :
- LocMsg(), mLocAdapter(locAdapter), mLocApi(locApi)
- {
- locallog();
- }
- inline virtual void proc() const {
- mLocApi->addAdapter(mLocAdapter);
- }
- inline void locallog() {
- LOC_LOGV("LocOpen");
- }
- inline virtual void log() {
- locallog();
- }
-};
-
// This is the top level class, so the constructor will
// always gets called. Here we prepare for the default.
// But if getLocApi(targetEnumType target) is overriden,
@@ -65,7 +45,7 @@ LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
mEvtMask(mask), mContext(context),
mLocApi(context->getLocApi()), mMsgTask(context->getMsgTask())
{
- sendMsg(new LocOpenMsg(this, mLocApi));
+ mLocApi->addAdapter(this);
}
void LocAdapterBase::
diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h
index f279f9f..be31de6 100644
--- a/core/LocAdapterBase.h
+++ b/core/LocAdapterBase.h
@@ -44,12 +44,10 @@ protected:
inline LocAdapterBase(const MsgTask* msgTask) :
mEvtMask(0), mContext(NULL), mLocApi(NULL), mMsgTask(msgTask) {}
-
+public:
+ inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
ContextBase* context);
- inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
-
-public:
inline LOC_API_ADAPTER_EVENT_MASK_T
checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const {
return mEvtMask & mask;
diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp
index 7a6456c..2978fb3 100644
--- a/core/LocApiBase.cpp
+++ b/core/LocApiBase.cpp
@@ -103,6 +103,27 @@ struct LocSsrMsg : public LocMsg {
}
};
+struct LocOpenMsg : public LocMsg {
+ LocApiBase* mLocApi;
+ LOC_API_ADAPTER_EVENT_MASK_T mMask;
+ inline LocOpenMsg(LocApiBase* locApi,
+ LOC_API_ADAPTER_EVENT_MASK_T mask) :
+ LocMsg(), mLocApi(locApi), mMask(mask)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mLocApi->open(mMask);
+ }
+ inline void locallog() {
+ LOC_LOGV("%s:%d]: LocOpen Mask: %x\n",
+ __func__, __LINE__, mMask);
+ }
+ inline virtual void log() {
+ locallog();
+ }
+};
+
LocApiBase::LocApiBase(const MsgTask* msgTask,
LOC_API_ADAPTER_EVENT_MASK_T excludedMask) :
mExcludedMask(excludedMask), mMsgTask(msgTask), mMask(0)
@@ -137,7 +158,8 @@ void LocApiBase::addAdapter(LocAdapterBase* adapter)
for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) {
if (mLocAdapters[i] == NULL) {
mLocAdapters[i] = adapter;
- open(mMask | (adapter->getEvtMask() & ~mExcludedMask));
+ mMsgTask->sendMsg(new LocOpenMsg(this,
+ (adapter->getEvtMask())));
break;
}
}
@@ -173,7 +195,7 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter)
close();
} else {
// else we need to remove the bit
- open(getEvtMask() & ~mExcludedMask);
+ mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask()));
}
}
}
@@ -298,7 +320,8 @@ void LocApiBase::requestNiNotify(GpsNiNotification &notify, const void* data)
void* LocApiBase :: getSibling()
DEFAULT_IMPL(NULL)
-void* LocApiBase :: getSibling2()
+
+LocApiProxyBase* LocApiBase :: getLocApiProxy()
DEFAULT_IMPL(NULL)
enum loc_api_adapter_err LocApiBase::
diff --git a/core/LocApiBase.h b/core/LocApiBase.h
index 4ddc57f..04afa53 100644
--- a/core/LocApiBase.h
+++ b/core/LocApiBase.h
@@ -34,6 +34,7 @@
#include <gps_extended.h>
#include <MsgTask.h>
#include <log_util.h>
+
namespace loc_core {
int hexcode(char *hexstring, int string_size,
@@ -51,14 +52,23 @@ int decodeAddress(char *addr_string, int string_size,
#define TO_1ST_HANDLING_ADAPTER(adapters, call) \
for (int i = 0; i <MAX_ADAPTERS && NULL != (adapters)[i] && !(call); i++);
-
class LocAdapterBase;
struct LocSsrMsg;
+struct LocOpenMsg;
+
+class LocApiProxyBase {
+public:
+ inline LocApiProxyBase() {}
+ inline virtual ~LocApiProxyBase() {}
+ inline virtual void* getSibling2() { return NULL; }
+};
class LocApiBase {
friend struct LocSsrMsg;
+ //LocOpenMsg calls open() which makes it necessary to declare
+ //it as a friend
+ friend struct LocOpenMsg;
friend class ContextBase;
- const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
const MsgTask* mMsgTask;
LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
@@ -68,13 +78,13 @@ protected:
open(LOC_API_ADAPTER_EVENT_MASK_T mask);
virtual enum loc_api_adapter_err
close();
-
LOC_API_ADAPTER_EVENT_MASK_T getEvtMask();
LOC_API_ADAPTER_EVENT_MASK_T mMask;
LocApiBase(const MsgTask* msgTask,
LOC_API_ADAPTER_EVENT_MASK_T excludedMask);
inline virtual ~LocApiBase() { close(); }
bool isInSession();
+ const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
public:
void addAdapter(LocAdapterBase* adapter);
@@ -111,7 +121,7 @@ public:
// RPC, QMI, etc. The default implementation is empty.
virtual void* getSibling();
- virtual void* getSibling2();
+ virtual LocApiProxyBase* getLocApiProxy();
virtual enum loc_api_adapter_err
startFix(const LocPosMode& posMode);
virtual enum loc_api_adapter_err