85
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 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 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cautils.h"
|
|
19 |
#include "caclientnotifiersession.h"
|
|
20 |
#include "caclientsubsession.h"
|
|
21 |
#include "cainnerentry.h"
|
|
22 |
#include "cainnerquery.h"
|
|
23 |
#include "caidsarray.h"
|
|
24 |
#include "caentriesarray.h"
|
|
25 |
#include "caclientnotifierproxy.h"
|
|
26 |
|
|
27 |
|
|
28 |
// ======== MEMBER FUNCTIONS ========
|
|
29 |
|
|
30 |
// -----------------------------------------------------------------------------
|
|
31 |
//
|
|
32 |
// -----------------------------------------------------------------------------
|
|
33 |
//
|
|
34 |
TUint32 RCaClientNotifierSession::HashFunc(const TKey& key)
|
|
35 |
{
|
|
36 |
return reinterpret_cast<TUint>(key.iFilterAddress) + key.iNotifierType;
|
|
37 |
}
|
|
38 |
|
|
39 |
// -----------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
// -----------------------------------------------------------------------------
|
|
42 |
//
|
|
43 |
TBool RCaClientNotifierSession::IdentityFunc(const TKey& key1,
|
|
44 |
const TKey& key2)
|
|
45 |
{
|
|
46 |
return key1.iFilterAddress == key2.iFilterAddress &&
|
|
47 |
key1.iNotifierType == key2.iNotifierType;
|
|
48 |
}
|
|
49 |
|
|
50 |
const THashFunction32<RCaClientNotifierSession::TKey>
|
|
51 |
RCaClientNotifierSession::iHashFunction(
|
|
52 |
RCaClientNotifierSession::HashFunc);
|
|
53 |
|
|
54 |
const TIdentityRelation<RCaClientNotifierSession::TKey>
|
|
55 |
RCaClientNotifierSession::iIdentityRelation(
|
|
56 |
RCaClientNotifierSession::IdentityFunc);
|
|
57 |
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
// RCaClientNotifierSession::RCaClientNotifierSession
|
|
60 |
// C++ default constructor can NOT contain any code, that
|
|
61 |
// might leave.
|
|
62 |
// -----------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
RCaClientNotifierSession::RCaClientNotifierSession() :
|
|
65 |
RSessionBase(), iSubsessions(iHashFunction, iIdentityRelation)
|
|
66 |
{
|
|
67 |
// No implementation required
|
|
68 |
}
|
|
69 |
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
// RCAClientSession::Connect
|
|
72 |
// Connect to Content publisher server session.
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
TInt RCaClientNotifierSession::Connect()
|
|
76 |
{
|
|
77 |
TInt error =
|
|
78 |
CreateSession(KCaSrvName, Version(), KDefaultMessageSlots);
|
|
79 |
if (error == KErrNone) {
|
|
80 |
ShareAuto();
|
|
81 |
}
|
|
82 |
return error;
|
|
83 |
}
|
|
84 |
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
//
|
|
88 |
// -----------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
void RCaClientNotifierSession::Close()
|
|
91 |
{
|
|
92 |
RHashMap<TKey, RCaClientSubSession*>::TIter iter(iSubsessions);
|
|
93 |
while(iter.NextValue()) {
|
|
94 |
(*iter.CurrentValue())->Close();
|
|
95 |
}
|
|
96 |
iSubsessions.Close();
|
|
97 |
RSessionBase::Close();
|
|
98 |
}
|
|
99 |
|
|
100 |
// -----------------------------------------------------------------------------
|
|
101 |
//
|
|
102 |
//
|
|
103 |
// -----------------------------------------------------------------------------
|
|
104 |
//
|
93
|
105 |
void RCaClientNotifierSession::ConnectAllL()
|
|
106 |
{
|
|
107 |
if( !CreateSession(KCaSrvName, Version(), KDefaultMessageSlots) )
|
|
108 |
{
|
|
109 |
RHashMap<TKey, RCaClientSubSession*>::TIter iter(iSubsessions);
|
|
110 |
while(iter.NextValue())
|
|
111 |
{
|
|
112 |
(*iter.CurrentValue())->CreateL();
|
|
113 |
}
|
|
114 |
}
|
|
115 |
}
|
|
116 |
|
|
117 |
// -----------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
//
|
|
120 |
// -----------------------------------------------------------------------------
|
|
121 |
//
|
85
|
122 |
TInt RCaClientNotifierSession::RegisterNotifier(
|
|
123 |
CCaInnerNotifierFilter* innerNotifierFilter,
|
|
124 |
const TAny* notifierFilter,
|
93
|
125 |
const IDataObserver* notifierProxy)
|
85
|
126 |
{
|
|
127 |
TRAPD(error, RegisterNotifierL(innerNotifierFilter,
|
|
128 |
notifierFilter,
|
|
129 |
notifierProxy));
|
|
130 |
return error;
|
|
131 |
}
|
|
132 |
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
//
|
|
135 |
//
|
|
136 |
// -----------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
void RCaClientNotifierSession::RegisterNotifierL(
|
|
139 |
CCaInnerNotifierFilter* innerNotifierFilter,
|
|
140 |
const TAny* notifierFilter,
|
93
|
141 |
const IDataObserver *notifierProxy)
|
85
|
142 |
{
|
|
143 |
RCaClientSubSession* subsession = new RCaClientSubSession(this,
|
|
144 |
notifierProxy, innerNotifierFilter);
|
|
145 |
CleanupClosePushL(*subsession);
|
|
146 |
subsession->CreateL();
|
|
147 |
TKey key(notifierFilter, innerNotifierFilter->GetNotifierType());
|
|
148 |
iSubsessions.InsertL(key, subsession);
|
|
149 |
CleanupStack::Pop(subsession);
|
|
150 |
}
|
|
151 |
|
|
152 |
// -----------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
//
|
|
155 |
// -----------------------------------------------------------------------------
|
|
156 |
//
|
|
157 |
void RCaClientNotifierSession::UnregisterNotifier(
|
|
158 |
const TAny* notifierFilter,
|
|
159 |
CCaInnerNotifierFilter::TNotifierType innerNotifierType)
|
|
160 |
{
|
|
161 |
TKey key(notifierFilter, innerNotifierType);
|
|
162 |
RCaClientSubSession** subsession = iSubsessions.Find(key);
|
|
163 |
if (subsession) {
|
|
164 |
(*subsession)->Close();
|
|
165 |
delete (*subsession);
|
|
166 |
iSubsessions.Remove(key);
|
|
167 |
}
|
|
168 |
}
|
|
169 |
|
|
170 |
// -----------------------------------------------------------------------------
|
|
171 |
//
|
|
172 |
//
|
|
173 |
// -----------------------------------------------------------------------------
|
|
174 |
//
|
|
175 |
TInt RCaClientNotifierSession::SubsessionsCount() const
|
|
176 |
{
|
|
177 |
return iSubsessions.Count();
|
|
178 |
}
|
|
179 |
|
|
180 |
// -----------------------------------------------------------------------------
|
|
181 |
//
|
|
182 |
//
|
|
183 |
// -----------------------------------------------------------------------------
|
|
184 |
//
|
|
185 |
TBool RCaClientNotifierSession::ContainsSubsession(
|
|
186 |
const TAny* notifierFilter,
|
|
187 |
CCaInnerNotifierFilter::TNotifierType innerNotifierType) const
|
|
188 |
{
|
|
189 |
TKey key(notifierFilter, innerNotifierType);
|
|
190 |
return iSubsessions.Find(key) != NULL;
|
|
191 |
}
|
|
192 |
|
|
193 |
// -----------------------------------------------------------------------------
|
|
194 |
// RCPServerClient::Version
|
|
195 |
// Version information.
|
|
196 |
// -----------------------------------------------------------------------------
|
|
197 |
//
|
|
198 |
TVersion RCaClientNotifierSession::Version() const
|
|
199 |
{
|
|
200 |
return (TVersion(KCaMajorVersion, KCaMinorVersion, KCaBuild));
|
|
201 |
}
|