|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
16 #include <tzuserdefineddata.h> |
|
17 #endif |
|
18 #include "timezoneserver.h" |
|
19 #include "timezonesession.h" |
|
20 |
|
21 // Set server priority |
|
22 const TInt KServerPriority = 0; // EStandard Priority |
|
23 |
|
24 // indexes into TPolicyElement::KPolicyElements |
|
25 #define KPolicyElementWriteDeviceData 0 |
|
26 #define KPolicyElementReadUserData 1 |
|
27 #define KPolicyElementWriteUserData 2 |
|
28 |
|
29 // opcodes ranges with different security policies |
|
30 const TUint KRangeCount = 5; |
|
31 |
|
32 const TInt KOpCodeRanges[KRangeCount] = |
|
33 { |
|
34 KCapabilityNone, |
|
35 KCapabilityWriteDeviceData, |
|
36 KCapabilityReadUserData, |
|
37 KCapabilityWriteUserData, |
|
38 CTzServer::ENotSupported |
|
39 }; |
|
40 |
|
41 const TUint8 KElementsIndex[KRangeCount] = |
|
42 { |
|
43 CPolicyServer::EAlwaysPass, |
|
44 KPolicyElementWriteDeviceData, |
|
45 KPolicyElementReadUserData, |
|
46 KPolicyElementWriteUserData, |
|
47 CPolicyServer::ENotSupported |
|
48 }; |
|
49 |
|
50 const CPolicyServer::TPolicyElement KPolicyElements[] = |
|
51 { |
|
52 {_INIT_SECURITY_POLICY_C1(ECapabilityWriteDeviceData), CPolicyServer::EFailClient}, // KPolicyElementWriteDeviceData |
|
53 {_INIT_SECURITY_POLICY_C1(ECapabilityReadUserData), CPolicyServer::EFailClient}, // KPolicyElementReadUserData |
|
54 {_INIT_SECURITY_POLICY_C1(ECapabilityWriteUserData), CPolicyServer::EFailClient}, // KPolicyElementWriteUserData |
|
55 }; |
|
56 |
|
57 const CPolicyServer::TPolicy KTzSrvrPolicy = |
|
58 { |
|
59 CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass |
|
60 KRangeCount, |
|
61 KOpCodeRanges, |
|
62 KElementsIndex, // what each range is compared to |
|
63 KPolicyElements // what policies range is compared to |
|
64 }; |
|
65 |
|
66 // Create Tz Server |
|
67 CTzServer* CTzServer::NewL() |
|
68 { |
|
69 CTzServer* self = new (ELeave) CTzServer(KServerPriority); |
|
70 CleanupStack::PushL(self); |
|
71 |
|
72 self->ConstructL(); |
|
73 |
|
74 CleanupStack::Pop(self); |
|
75 return self; |
|
76 } |
|
77 |
|
78 CTzServer::~CTzServer() |
|
79 { |
|
80 delete iTzLocalizationDb; |
|
81 delete iTimeZoneMgr; |
|
82 delete iTzUserDataDb; |
|
83 delete iTzSwiObserver; |
|
84 } |
|
85 |
|
86 CTzServer::CTzServer(TInt aPriority) |
|
87 :CPolicyServer(aPriority, KTzSrvrPolicy, ESharableSessions) |
|
88 { |
|
89 } |
|
90 |
|
91 // Create and connect to the file server |
|
92 // Rename the server process to "TZServer" |
|
93 // Start the server |
|
94 // |
|
95 void CTzServer::ConstructL() |
|
96 { |
|
97 iTzUserDataDb = CTzUserDataDb::NewL(); |
|
98 iTzSwiObserver = CTzSwiObserver::NewL(); |
|
99 iTimeZoneMgr = CTzConfigAgent::NewL(*this, *iTzUserDataDb, *iTzSwiObserver); |
|
100 iTzLocalizationDb = CTzLocalizationDb::NewL(*this); |
|
101 iTimeZoneMgr->SetLocalizationDb(iTzLocalizationDb); |
|
102 iTzUserDataDb->AddObserverL(iTimeZoneMgr); |
|
103 iTimeZoneMgr->AddObserverL(iTzLocalizationDb); |
|
104 StartL(KTimeZoneServerName); |
|
105 } |
|
106 |
|
107 // Create a new server session |
|
108 CSession2* CTzServer::NewSessionL(const TVersion& aVersion,const RMessage2& /*aMessage*/) const |
|
109 { |
|
110 TVersion ver(KTimeZoneServerMajorVersion, KTimeZoneServerMinorVersion, KTimeZoneServerBuildVersion); |
|
111 if (!User::QueryVersionSupported(ver,aVersion)) |
|
112 { |
|
113 User::Leave(KErrNotSupported); |
|
114 } |
|
115 |
|
116 CTzServerSession* session = CTzServerSession::NewL(); |
|
117 |
|
118 SessionAdded(); |
|
119 return session; |
|
120 } |
|
121 |
|
122 void CTzServer::SessionClosed() const |
|
123 { |
|
124 // Called when a session exits |
|
125 // If this is the last session for the server, then stop the scheduler so server can be destroyed |
|
126 // outside the context of this call |
|
127 --iSessionCount; |
|
128 if (iSessionCount == 0) |
|
129 { |
|
130 CActiveScheduler::Stop(); |
|
131 } |
|
132 } |
|
133 |
|
134 void CTzServer::SessionAdded() const |
|
135 { |
|
136 iSessionCount++; |
|
137 } |
|
138 |
|
139 // Notifies Change to all client sessions |
|
140 // each client is responsible for rejecting the call |
|
141 // if there is no pending request |
|
142 void CTzServer::NotifyTZStatusChange(RTz::TTzChanges aChange, const TAny* aRequester) |
|
143 { |
|
144 iSessionIter.SetToFirst(); |
|
145 CSession2* pS; |
|
146 while ((pS = iSessionIter++)!=NULL) |
|
147 { |
|
148 (static_cast<CTzServerSession*>(pS))->NotifyTZStatusChange(aChange, aRequester); |
|
149 } |
|
150 } |
|
151 |
|
152 // |
|
153 // Message servicing failed. Complete message with error code and restart |
|
154 // |
|
155 void CTzServer::Error(TInt aError) |
|
156 { |
|
157 Message().Complete(aError); |
|
158 ReStart(); |
|
159 } |