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