summaryrefslogtreecommitdiff
path: root/enhanced-position-service/src/serverimpl.h
blob: 5c446ef67c1f6a2660ca43a4eb60cc6e3d41e202 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**************************************************************************
* @licence app begin@
*
* SPDX-License-Identifier: MPL-2.0
*
* \ingroup EnhancedPositionService
*
* \copyright Copyright (C) BMW Car IT GmbH 2011, 2012
* 
* \license
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
* this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* @licence end@
**************************************************************************/

#ifndef SERVERIMPL_H
#define SERVERIMPL_H

#include <QtCore>
#include <QtDBus>

#include "genivi-dbus-types.h"
#include "ConfigurationImpl.h"

#include "gnss-simple.h"
#include "PositionFilter.h"

// FIXME: decide, if still needed.
enum _EnhancedPositionStatus {
    ENH_STATUS_INVALID = 0,
    ENH_STATUS_UNKNOWN = 1,
    ENH_STATUS_DISCONNECTED = 2,
    ENH_STATUS_STARTUP = 3,
    ENH_STATUS_READY = 4,
    ENH_STATUS_CONNECTED = 5
};

/*
 * Signatures needs to match demoifadaptor.h
 */
class ServerImpl : public QObject, public QDBusContext
{
Q_OBJECT
public:
    explicit ServerImpl(QObject *parent = 0);
    ~ServerImpl();
    void setConnection(QDBusConnection& conn);

    QDBusConnection* getConnection();


public: // PROPERTIES
public Q_SLOTS: // METHODS
    MapUShortVariant GetAccuracy();
    MapUShortVariant GetData(const QList<ushort> &valuesToReturn);
    MapUShortVariant GetPosition();
    MapUShortVariant GetRotationRate();
    MapUShortVariant GetSatelliteInfo();
    MapUShortVariant GetStatus();
    MapUShortVariant GetTime();
    GeniviVersion GetVersion();

Q_SIGNALS: // SIGNALS
    void AccuracyUpdate(const QList<ushort> &changedValues);
    void PositionUpdate(const QList<ushort> &changedValues);
    void RotationRateUpdate(const QList<ushort> &changedValues);
    void SatelliteInfoUpdate(const QList<ushort> &changedValues);
    void StatusUpdate(const QList<ushort> &changedValues);

private Q_SLOTS:
    void changeStatus();
    void sendUpdate();
    void onAgentUnregistered(const QString &serviceName);

private:
    bool checkAndPrintDBusContext();
    bool activateWatcherFor(const QString& uniqueId);

    QDBusConnection* m_pConnection;
    QDBusServiceWatcher m_watcher;

    _EnhancedPositionStatus m_status;

    PositionFilter& m_posFilter;
};

#endif