summaryrefslogtreecommitdiffstats
path: root/plugins/landmarks/symbian_landmarks/inc/qlandmarkdbeventhandler.h
blob: 721ebf0483ed7b45c96200105a6a3b6bd4a4bb9f (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/****************************************************************************
 **
 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: http://www.qt-project.org/legal
 **
 ** This file is part of the Qt Mobility Components.
 **
 ** $QT_BEGIN_LICENSE:LGPL$
 ** GNU Lesser General Public License Usage
 ** This file may be used under the terms of the GNU Lesser General Public
 ** License version 2.1 as published by the Free Software Foundation and
 ** appearing in the file LICENSE.LGPL included in the packaging of this
 ** file. Please review the following information to ensure the GNU Lesser
 ** General Public License version 2.1 requirements will be met:
 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 **
 ** In addition, as a special exception, Nokia gives you certain additional
 ** rights. These rights are described in the Nokia Qt LGPL Exception
 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 **
 ** GNU General Public License Usage
 ** Alternatively, this file may be used under the terms of the GNU General
 ** Public License version 3.0 as published by the Free Software Foundation
 ** and appearing in the file LICENSE.GPL included in the packaging of this
 ** file. Please review the following information to ensure the GNU General
 ** Public License version 3.0 requirements will be met:
 ** http://www.gnu.org/copyleft/gpl.html.
 **
 ** Other Usage
 ** Alternatively, this file may be used in accordance with the terms and
 ** conditions contained in a signed written agreement between you and Nokia.
 **
 **
 **
 **
 **
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/

#ifndef QLANDMARK_DB_EVENT_HANDLER_H
#define QLANDMARK_DB_EVENT_HANDLER_H

// System Includes
#include <EPos_CPosLandmarkDatabase.h>
#include <e32base.h>

/*
 * Observers that require notification of database events should derive from MLandmarkDbEventObserver
 * and register with the Event Handler using CLandmarkDbEventHandler::AddObserver
 */
class MLandmarkDbEventObserver
{
public:
    virtual void handleDatabaseEvent(const TPosLmEvent& aEvent) = 0;
};

/**
 * CLandmarkDbEventHandler class is used to observer the landmark database
 * events. It is a self running active object
 * The initialization happens only once ensuring there is only one object of CLandmarkDbEventHandler
 * There 
 */
NONSHARABLE_CLASS( CLandmarkDbEventHandler ): public CActive
{
public:

    /*
     * Default Ctor
     */
    CLandmarkDbEventHandler();

    /*
     * Default dtor
     */
    ~CLandmarkDbEventHandler();

    /*
     * AddObserver is used to add an observer, the observer will be notified upon
     * database event completion
     * The observer derives from MLandmarkDbEventObserver class
     * The observer object destruction is to be done by the caller of AddObserver
     */
    TInt AddObsever(MLandmarkDbEventObserver* aObserverHandle);

    /*
     * RemoveObsever is used to remove an observer, the observer will be notified upon
     * database event completion
     * The observer derives from MLandmarkDbEventObserver class
     * The observer object destruction is to be done by the caller of AddObserver
     */
    TInt RemoveObsever(MLandmarkDbEventObserver* aObserverHandle);

private:

    /*
     * Called by ActiveScheduler when an event occurs on this active object,
     * i.e., when a landmark database event occurs
     */
    void RunL();

    /*
     * Used to cancel the notification request
     */
    void DoCancel();

    /*
     * This should be called before any use, it initializes all the required objects
     */
    void InitializeL();

    /*
     * StartListening() is called to start listening to the database event
     * It has to be protected by the iObserverLock. It is not taken inside this function
     * for performance reasons.
     */
    void StartListening();

private:
    /*
     * This is a handle to the database, it is used for Notification request
     */
    CPosLandmarkDatabase* iDatabase;

    /*
     * Holds the event that occurred in the landmark database
     */
    TPosLmEvent iEvent;

    /*
     * Holds the observers, the destruction of the observer is not done by this array
     * It is the responsibility of the caller of AddObserver
     */
    RPointerArray<MLandmarkDbEventObserver> iObserverList;

    /*
     * To synchronize the access to the observer list
     */
    RFastLock iObserverLock;

    /*
     * ETrue if Initialize is done
     */
    TBool iIsInitialized;

};

#endif // QLANDMARK_DB_EVENT_HANDLER_H