85
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
87
|
14 |
* Description:
|
85
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef CACLIENTNOTIFIERPROXY_H
|
|
19 |
#define CACLIENTNOTIFIERPROXY_H
|
|
20 |
|
|
21 |
#include <QObject>
|
|
22 |
#include <QMutex>
|
|
23 |
#include "cadef.h"
|
|
24 |
|
|
25 |
#include "caclient_global.h"
|
|
26 |
#include "cadefs.h"
|
|
27 |
#include "canotifier_p.h"
|
|
28 |
#include "caclientnotifiersession.h"
|
|
29 |
|
|
30 |
class CaEntry;
|
|
31 |
class CaNotifierFilter;
|
|
32 |
|
|
33 |
/**
|
|
34 |
* IDataObserver
|
|
35 |
*
|
|
36 |
*/
|
|
37 |
class IDataObserver
|
|
38 |
{
|
|
39 |
public:
|
|
40 |
/**
|
|
41 |
* Method invoked when entry is changed.
|
|
42 |
* @param entryId entry id.
|
|
43 |
* @param changeType change type.
|
|
44 |
*/
|
|
45 |
virtual void entryChanged(TInt entryId,
|
87
|
46 |
TChangeType changeType) const = 0;
|
85
|
47 |
|
|
48 |
/**
|
|
49 |
* Method invoked when entry is changed.
|
|
50 |
* @param entry entry.
|
|
51 |
* @param changeType change type.
|
|
52 |
*/
|
|
53 |
virtual void entryChanged(const CCaInnerEntry &entry,
|
87
|
54 |
TChangeType changeType) const = 0;
|
85
|
55 |
|
|
56 |
/**
|
|
57 |
* Method invoked when entry was changed.
|
|
58 |
* @param entryId entry id.
|
|
59 |
*/
|
|
60 |
virtual void entryTouched(TInt id) const = 0;
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Method invoked when entry was changed.
|
|
64 |
* @param groupId group id.
|
|
65 |
*/
|
|
66 |
virtual void groupContentChanged(TInt groupId) const = 0;
|
|
67 |
};
|
|
68 |
|
|
69 |
class CACLIENT_EXPORT CaClientNotifierProxy: public QObject,
|
|
70 |
public IDataObserver
|
|
71 |
{
|
87
|
72 |
Q_OBJECT
|
85
|
73 |
|
|
74 |
public:
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Constructor.
|
|
78 |
* @param parent pointer to parent. Defaults to NULL.
|
|
79 |
*/
|
|
80 |
explicit CaClientNotifierProxy(QObject *parent = 0);
|
|
81 |
|
|
82 |
/**
|
|
83 |
* Destructor.
|
|
84 |
*/
|
|
85 |
~CaClientNotifierProxy();
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Method invoked when entry is changed.
|
|
89 |
* @param entryId entry id.
|
|
90 |
* @param changeType change type.
|
|
91 |
*/
|
|
92 |
virtual void entryChanged(TInt entryId, TChangeType changeType) const;
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Method invoked when entry is changed.
|
|
96 |
* @param entry entry.
|
|
97 |
* @param changeType change type.
|
|
98 |
*/
|
|
99 |
virtual void entryChanged(const CCaInnerEntry &entry,
|
87
|
100 |
TChangeType changeType) const;
|
85
|
101 |
|
|
102 |
/**
|
|
103 |
* Method invoked when entry was changed.
|
|
104 |
* @param entryId entry id.
|
|
105 |
*/
|
|
106 |
virtual void entryTouched(TInt entryId) const;
|
|
107 |
|
|
108 |
/**
|
|
109 |
* Method invoked when entry was changed.
|
|
110 |
* @param groupId group id.
|
|
111 |
*/
|
|
112 |
virtual void groupContentChanged(TInt groupId) const;
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Method for registering notifier
|
|
116 |
*
|
|
117 |
* @param notifierFilter notifierFilter used to register notifier.
|
|
118 |
* @param notifierType type of notifier
|
|
119 |
* @return error code
|
|
120 |
*/
|
|
121 |
int registerNotifier(
|
|
122 |
const CaNotifierFilter *notifierFilter,
|
|
123 |
CaNotifierPrivate::NotifierType notifierType,
|
|
124 |
const CaClientNotifierProxy *notifierProxy);
|
|
125 |
|
|
126 |
/**
|
|
127 |
* Method for unregistering notifier.
|
|
128 |
*
|
|
129 |
* @param notifierFilter notifierFilter used to unregister notifier.
|
|
130 |
* @param notifierType type of notifier
|
|
131 |
*/
|
|
132 |
void unregisterNotifier(
|
|
133 |
const CaNotifierFilter ¬ifierFilter,
|
|
134 |
CaNotifierPrivate::NotifierType notifierType);
|
|
135 |
|
|
136 |
signals:
|
|
137 |
|
|
138 |
void signalEntryChanged(int entryId, ChangeType changeType) const;
|
|
139 |
void signalEntryChanged(const CaEntry &entry,
|
87
|
140 |
ChangeType changeType) const;
|
85
|
141 |
void signalEntryTouched(int id) const;
|
|
142 |
void signalGroupContentChanged(int groupId) const;
|
|
143 |
|
|
144 |
private:
|
|
145 |
/**
|
|
146 |
* Method for finding a session with free slots.
|
|
147 |
*
|
|
148 |
* @return a pointer to a session.
|
|
149 |
*/
|
|
150 |
RCaClientNotifierSession *findSession();
|
|
151 |
|
|
152 |
/**
|
|
153 |
* Method for finding a position of a session with a subsession
|
|
154 |
* associated with given parameters.
|
|
155 |
*
|
|
156 |
* @param notifierFilter notifierFilter used to unregister notifier.
|
|
157 |
* @param innerNotifierType inner type of notifier
|
|
158 |
* @return a position of a pointer to a session,
|
|
159 |
* KErrNotFound when not found.
|
|
160 |
*/
|
|
161 |
TInt findSession(
|
|
162 |
const CaNotifierFilter ¬ifierFilter,
|
|
163 |
CCaInnerNotifierFilter::TNotifierType innerNotifierType) const;
|
|
164 |
|
|
165 |
/**
|
|
166 |
* Method for creating a new session.
|
|
167 |
*
|
|
168 |
* @param[out] error error code.
|
|
169 |
* @return a pointer to a newly created session, NULL in case of error.
|
|
170 |
*/
|
|
171 |
RCaClientNotifierSession *newSession(TInt &error);
|
|
172 |
|
|
173 |
private:
|
|
174 |
|
|
175 |
// Sessions to server.
|
|
176 |
RArray<RCaClientNotifierSession> mSessions;
|
|
177 |
|
|
178 |
// Mutex to serialize access to mSessions.
|
|
179 |
QMutex mMutex;
|
|
180 |
|
|
181 |
Q_DISABLE_COPY(CaClientNotifierProxy)
|
|
182 |
|
|
183 |
friend class CaClientProxy;
|
|
184 |
friend class CaClientObserver;
|
|
185 |
|
|
186 |
};
|
|
187 |
|
|
188 |
#endif //_CACLIENTNOTIFIERPROXY_H
|