|
1 /* |
|
2 * Copyright (c) 2005-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: Main plugin class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "musresourceproperties.h" |
|
20 #include "mussesseioninformationapi.h" |
|
21 #include "mussettingskeys.h" |
|
22 #include "mussessionproperties.h" |
|
23 #include "mussettings.inl" |
|
24 #include "musaoplugin.h" |
|
25 #include "mustsypropertymonitor.h" |
|
26 // Enable the below line if Kodiak Ptt has to be monitered |
|
27 // #include "muspttcallmonitor.h" |
|
28 #include "muspropertymonitor.h" |
|
29 #include "mustsypropertymonitor.h" |
|
30 #include "muslogger.h" |
|
31 |
|
32 #include <AlwaysOnlineManagerCommon.h> |
|
33 #include <AlwaysOnlineManagerClient.h> |
|
34 #include <mmtsy_names.h> |
|
35 #include <featmgr.h> |
|
36 |
|
37 using namespace NMusSessionInformationApi; |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // Symbian two-phase constructor. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CMusAoPlugin* CMusAoPlugin::NewL() |
|
44 { |
|
45 MUS_LOG( "mus: [MUSAO] -> CMusAoPlugin::NewL" ) |
|
46 CMusAoPlugin* self = new (ELeave) CMusAoPlugin(); |
|
47 CleanupStack::PushL( self ); |
|
48 self->ConstructL(); |
|
49 CleanupStack::Pop( self ); |
|
50 MUS_LOG( "mus: [MUSAO] <- CMusAoPlugin::NewL" ) |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // C++ constructor. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CMusAoPlugin::CMusAoPlugin() : |
|
59 CAlwaysOnlineEComInterface() |
|
60 { |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // Symbian second-phase constructor. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void CMusAoPlugin::ConstructL() |
|
68 { |
|
69 MUS_LOG( "mus: [MUSAO] -> CMusAoPlugin::ConstructL" ) |
|
70 FeatureManager::InitializeLibL(); |
|
71 TBool support = FeatureManager::FeatureSupported( KFeatureIdMultimediaSharing ); |
|
72 FeatureManager::UnInitializeLib(); |
|
73 if ( support ) |
|
74 { |
|
75 DefinePropertiesL(); |
|
76 User::LeaveIfError( iServer.Connect() ); |
|
77 User::LeaveIfError( iPhone.Open( iServer, KMmTsyPhoneName() ) ); |
|
78 iTsyPropertyMonitor = CMusTsyPropertyMonitor::NewL(iPhone); |
|
79 iPropertyMonitor = CMusPropertyMonitor::NewL(); |
|
80 // Enable the below line if Kodiak Ptt has to be monitered |
|
81 // iPttCallMonitor = CMusPttCallMonitor::NewL(*iLineMonitor); |
|
82 } |
|
83 MUS_LOG( "mus: [MUSAO] <- CMusAoPlugin::ConstructL" ) |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // C++ destructor. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CMusAoPlugin::~CMusAoPlugin() |
|
91 { |
|
92 MUS_LOG( "-> CMusAoPlugin::~CMusAoPlugin" ) |
|
93 // should never come here, because service should always be on |
|
94 delete iPropertyMonitor; |
|
95 delete iTsyPropertyMonitor; |
|
96 // Enable the below line if Kodiak Ptt has to be monitered |
|
97 // delete iPttCallMonitor; |
|
98 DeleteProperties(); |
|
99 iPhone.Close(); |
|
100 iServer.Close(); |
|
101 MUS_LOG( "<- CMusAoPlugin::~CMusAoPlugin" ) |
|
102 } |
|
103 |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CMusAoPlugin::DefineResourcePropertiesL() |
|
107 // Note : Ignore Define Errors . Because if define fails for sure Set |
|
108 // will fail too . But there are some cases in Define Error should |
|
109 // be ignored like KErrAlreadyExists , KErrPersmissionDenied.So It |
|
110 // could be better if we dont care Define Error but care about Set Err. |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 void CMusAoPlugin::DefinePropertiesL() |
|
114 { |
|
115 MUS_LOG( "mus: [MUSAO] -> CMusAoPlugin::DefineResourceProperties" ) |
|
116 // define resource properties |
|
117 // they need to be defined here to make them exist always |
|
118 // Read from cenrep key about the availability of camera and keypad |
|
119 // if the availability is dynamic then define a key else no. |
|
120 MusSettingsKeys::TAvailability camera = MusSettingsKeys::EAvailabilityStatic; |
|
121 MusSettingsKeys::TAvailability keypad = MusSettingsKeys::EAvailabilityStatic ; |
|
122 MultimediaSharingSettings::ResourceAvailability(camera,keypad); |
|
123 if( camera == MusSettingsKeys::EAvailabilityDynamic ) |
|
124 { |
|
125 DefinePropertyL(NMusResourceApi::KCameraAvailability, |
|
126 RProperty::EInt,( TInt ) NMusResourceApi::ENotAvailable); |
|
127 } |
|
128 if( keypad == MusSettingsKeys::EAvailabilityDynamic ) |
|
129 { |
|
130 DefinePropertyL(NMusResourceApi::KKeypadAvailability, |
|
131 RProperty::EInt,( TInt ) NMusResourceApi::ENotAvailable); |
|
132 } |
|
133 DefinePropertyL(NMusResourceApi::KCameraInformation, |
|
134 RProperty::EInt,( TInt ) NMusResourceApi::EUsePrimaryCamera); |
|
135 DefinePropertyL(NMusSessionInformationApi::KMusCallEvent, |
|
136 RProperty::EInt,( TInt ) NMusSessionInformationApi::ENoCall); |
|
137 DefinePropertyL(NMusSessionInformationApi::KMusCallCount,RProperty::EInt,0); |
|
138 _LIT(KEmptyTelNumber,""); |
|
139 DefinePropertyL(NMusSessionInformationApi::KMusTelNumber, |
|
140 RProperty::EText,KEmptyTelNumber); |
|
141 DefinePropertyL(NMusSessionInformationApi::KMUSForbidden, |
|
142 RProperty::EInt,( TInt ) NMusSessionInformationApi::EMUSAllowed); |
|
143 DefinePropertyL(NMusSessionInformationApi::KMusCallDirection, |
|
144 RProperty::EInt,( TInt ) NMusSessionInformationApi::ENoDirection); |
|
145 DefinePropertyL(NMusSessionInformationApi::KMUSPrivacy, |
|
146 RProperty::EInt,( TInt ) NMusSessionInformationApi::EPrivacyOff); |
|
147 DefinePropertyL(KMusClirSetting, |
|
148 RProperty::EInt,( TInt ) ESendOwnNumber); |
|
149 |
|
150 |
|
151 MUS_LOG( "mus: [MUSAO] <- CMusAoPlugin::DefineResourceProperties" ) |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CMusAoPlugin::DefineProperty() |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CMusAoPlugin::DefinePropertyL(TInt aKey,RProperty::TType aType,TInt aVal) |
|
159 { |
|
160 MUS_LOG( "mus: [MUSAO] -> CMusAoPlugin::DefinePropertyL( intValue )" ) |
|
161 |
|
162 TInt error = RProperty::Define( NMusResourceApi::KCategoryUid, |
|
163 aKey, |
|
164 aType ); |
|
165 MUS_LOG2( "mus: [MUSAO] Key=%d defining tried, return=%d", aKey, error ) |
|
166 |
|
167 if ( error == KErrNone ) |
|
168 { |
|
169 error = RProperty::Set( NMusResourceApi::KCategoryUid, aKey, aVal ); |
|
170 MUS_LOG2( "mus: [MUSAO] RProperty value %d set, return = %d", |
|
171 aVal, error ) |
|
172 User::LeaveIfError( error ); |
|
173 } |
|
174 else |
|
175 { |
|
176 MUS_LOG( "mus: [MUSAO] Defining failed, do not set value" ) |
|
177 } |
|
178 |
|
179 MUS_LOG( "mus: [MUSAO] <- CMusAoPlugin::DefinePropertyL( intValue )" ) |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CMusAoPlugin::DefineProperty() |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CMusAoPlugin::DefinePropertyL( TInt aKey, |
|
187 RProperty::TType aType, |
|
188 const TDesC& aVal ) |
|
189 { |
|
190 MUS_LOG( "mus: [MUSAO] -> CMusAoPlugin::DefinePropertyL( DesCValue )" ) |
|
191 |
|
192 TInt error = RProperty::Define( NMusResourceApi::KCategoryUid, |
|
193 aKey, |
|
194 aType ); |
|
195 MUS_LOG2( "mus: [MUSAO] Key=%d defining tried, return=%d", aKey, error ) |
|
196 |
|
197 if ( error == KErrNone ) |
|
198 { |
|
199 error = RProperty::Set( NMusResourceApi::KCategoryUid, aKey, aVal); |
|
200 MUS_LOG_TDESC( "mus: [MUSAO] Tried to set RProperty value: ", aVal ) |
|
201 MUS_LOG1("mus: [MUSAO] return value = %d",error ) |
|
202 User::LeaveIfError( error ); |
|
203 } |
|
204 else |
|
205 { |
|
206 MUS_LOG( "mus: [MUSAO] Defining failed, do not set value" ) |
|
207 } |
|
208 |
|
209 MUS_LOG( "mus: [MUSAO] <- CMusAoPlugin::DefinePropertyL( DesCValue )" ) |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CMusAoPlugin::DeleteResourceProperties() |
|
214 // Note : There is no need of caring the return value in deleting |
|
215 // This will be called when AO Plugin destroyed which is rare to happen |
|
216 // Any unwanted deletion of AO Plugin should leave some PS Keys open. |
|
217 // But this is OK if we ignore KErrAlreadyExists while defining next time. |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 void CMusAoPlugin::DeleteProperties() |
|
221 { |
|
222 MUS_LOG( "mus: [MUSAO] -> CMusAoPlugin::DeleteResourcePropertiesL" ) |
|
223 // Delete resource properties |
|
224 // they need to be defined here to make them exist always |
|
225 DeleteProperty(NMusResourceApi::KCameraAvailability); |
|
226 DeleteProperty(NMusResourceApi::KKeypadAvailability); |
|
227 DeleteProperty(NMusResourceApi::KCameraInformation); |
|
228 DeleteProperty(NMusSessionInformationApi::KMusCallEvent); |
|
229 DeleteProperty(NMusSessionInformationApi::KMusCallCount); |
|
230 DeleteProperty(NMusSessionInformationApi::KMusTelNumber); |
|
231 DeleteProperty(NMusSessionInformationApi::KMUSForbidden); |
|
232 DeleteProperty(NMusSessionInformationApi::KMusCallDirection); |
|
233 DeleteProperty(NMusSessionInformationApi::KMUSPrivacy); |
|
234 DeleteProperty(KMusClirSetting); |
|
235 MUS_LOG( "mus: [MUSAO] <- CMusAoPlugin::DeleteResourcePropertiesL" ) |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // CMusAoPlugin::DeleteProperty() |
|
240 // ----------------------------------------------------------------------------- |
|
241 // |
|
242 void CMusAoPlugin::DeleteProperty(TInt aKey) |
|
243 { |
|
244 TInt retVal = RProperty::Delete( NMusResourceApi::KCategoryUid,aKey); |
|
245 MUS_LOG2( "mus: [MUSAO] RProperty::Delete Type=%d return=%d",\ |
|
246 aKey, retVal ) |
|
247 } |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // CMusAoPlugin::HandleServerCommandL |
|
251 // CallBack from base class. |
|
252 // ----------------------------------------------------------------------------- |
|
253 // |
|
254 TAny* CMusAoPlugin::HandleServerCommandL( TInt /*aCommand*/, |
|
255 TDesC8* /*aParameters*/ ) |
|
256 { |
|
257 MUS_LOG( "mus: [MUSAO] -> CMusAoPlugin::HandleServerCommandL" ) |
|
258 MUS_LOG( "mus: [MUSAO] <- CMusAoPlugin::HandleServerCommandL: KErrNone" ) |
|
259 return &iError;; |
|
260 } |
|
261 |
|
262 |
|
263 // End of file |