1bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
2bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo *
3bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * Redistribution and use in source and binary forms, with or without
4bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * modification, are permitted provided that the following conditions are
5bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * met:
6bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo *     * Redistributions of source code must retain the above copyright
7bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo *       notice, this list of conditions and the following disclaimer.
8bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo *     * Redistributions in binary form must reproduce the above
9bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo *       copyright notice, this list of conditions and the following
10bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo *       disclaimer in the documentation and/or other materials provided
11bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo *       with the distribution.
12bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo *     * Neither the name of The Linux Foundation, nor the names of its
13bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo *       contributors may be used to endorse or promote products derived
14bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo *       from this software without specific prior written permission.
15bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo *
16bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo *
28bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo */
29bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#ifndef LOC_API_ADAPTER_BASE_H
30bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#define LOC_API_ADAPTER_BASE_H
31bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
32bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#include <gps_extended.h>
33bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#include <UlpProxyBase.h>
34bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#include <ContextBase.h>
35bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
36bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russonamespace loc_core {
37bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
38bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russoclass LocAdapterProxyBase;
39bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
40bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russoclass LocAdapterBase {
41bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russoprotected:
42bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    const LOC_API_ADAPTER_EVENT_MASK_T mEvtMask;
43bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    ContextBase* mContext;
44bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    LocApiBase* mLocApi;
45bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    LocAdapterProxyBase* mLocAdapterProxyBase;
46bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    const MsgTask* mMsgTask;
47bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
48bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    inline LocAdapterBase(const MsgTask* msgTask) :
49bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo        mEvtMask(0), mContext(NULL), mLocApi(NULL), mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {}
50bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russopublic:
51bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
52bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
53bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo                   ContextBase* context, LocAdapterProxyBase *adapterProxyBase = NULL);
54bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    inline LOC_API_ADAPTER_EVENT_MASK_T
55bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo        checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const {
56bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo        return mEvtMask & mask;
57bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    }
58bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
59bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    inline LOC_API_ADAPTER_EVENT_MASK_T getEvtMask() const {
60bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo        return mEvtMask;
61bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    }
62bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
63bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    inline void sendMsg(const LocMsg* msg) const {
64bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo        mMsgTask->sendMsg(msg);
65bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    }
66bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
67bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    inline void sendMsg(const LocMsg* msg) {
68bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo        mMsgTask->sendMsg(msg);
69bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    }
70bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
71bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    // This will be overridden by the individual adapters
72bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    // if necessary.
73bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    inline virtual void setUlpProxy(UlpProxyBase* ulp) {}
74bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual void handleEngineUpEvent();
75bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual void handleEngineDownEvent();
76bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    inline virtual void setPositionModeInt(LocPosMode& posMode) {}
77bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual void startFixInt() {}
78bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual void stopFixInt() {}
79bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual void getZppInt() {}
80bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual void reportPosition(UlpLocation &location,
81bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo                                GpsLocationExtended &locationExtended,
82bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo                                void* locationExt,
83bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo                                enum loc_sess_status status,
84bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo                                LocPosTechMask loc_technology_mask);
85bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual void reportSv(GpsSvStatus &svStatus,
86bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo                          GpsLocationExtended &locationExtended,
87bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo                          void* svExt);
88bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual void reportStatus(GpsStatusValue status);
89bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual void reportNmea(const char* nmea, int length);
90bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual bool reportXtraServer(const char* url1, const char* url2,
91bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo                                  const char* url3, const int maxlength);
92bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual bool requestXtraData();
93bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual bool requestTime();
94bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual bool requestLocation();
95bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual bool requestATL(int connHandle, AGpsType agps_type);
96bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual bool releaseATL(int connHandle);
97bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual bool requestSuplES(int connHandle);
98bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual bool reportDataCallOpened();
99bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual bool reportDataCallClosed();
100bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual bool requestNiNotify(GpsNiNotification &notify,
101bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo                                 const void* data);
102bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    inline virtual bool isInSession() { return false; }
103bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual void shutdown();
104bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    ContextBase* getContext() const { return mContext; }
105bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData);
106bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo};
107bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
108bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo} // namespace loc_core
109bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
110bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#endif //LOC_API_ADAPTER_BASE_H
111