|
1 /* |
|
2 * Copyright (c) 2006 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: See class description. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <bautils.h> |
|
21 #include <data_caging_path_literals.hrh> |
|
22 #include <pslninternalcrkeys.h> |
|
23 |
|
24 #include "phoneconstants.h" |
|
25 #include "cphonecallthememonitor.h" |
|
26 #include "phonelogger.h" |
|
27 #include "cphonecenrepproxy.h" |
|
28 #include "mphonecenrepobserver.h" |
|
29 #include "phoneui.pan" |
|
30 |
|
31 // Values for KThemesCallImageSettings CR key |
|
32 const TInt KPslnCRUserDefinedCallImage = 1; |
|
33 |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CPhoneCallThemeMonitor::CPhoneCallThemeMonitor |
|
39 // C++ default constructor can NOT contain any code, that |
|
40 // might leave. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CPhoneCallThemeMonitor::CPhoneCallThemeMonitor() |
|
44 { |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CPhoneCallThemeMonitor::ConstructL |
|
49 // Symbian 2nd phase constructor can leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CPhoneCallThemeMonitor::ConstructL() |
|
53 { |
|
54 __LOGMETHODSTARTEND( EPhoneUIUtils, "CPhoneCallThemeMonitor::ConstructL ()" ); |
|
55 |
|
56 // Get all current values |
|
57 TRAP_IGNORE( ReadAllL() ); |
|
58 |
|
59 // Start listen changes in setting and image path |
|
60 CPhoneCenRepProxy::Instance()->NotifyChangeL( |
|
61 KCRUidThemes, |
|
62 KThemesCallImagePath, |
|
63 this ); |
|
64 |
|
65 CPhoneCenRepProxy::Instance()->NotifyChangeL( |
|
66 KCRUidThemes, |
|
67 KThemesCallImageSetting, |
|
68 this ); |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CPhoneCallThemeMonitor::NewL |
|
73 // Two-phased constructor. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 EXPORT_C CPhoneCallThemeMonitor* CPhoneCallThemeMonitor::NewL() |
|
77 { |
|
78 CPhoneCallThemeMonitor* self = |
|
79 new (ELeave) CPhoneCallThemeMonitor(); |
|
80 |
|
81 CleanupStack::PushL( self ); |
|
82 self->ConstructL(); |
|
83 CleanupStack::Pop( self ); |
|
84 |
|
85 return self; |
|
86 } |
|
87 |
|
88 // Destructor |
|
89 EXPORT_C CPhoneCallThemeMonitor::~CPhoneCallThemeMonitor() |
|
90 { |
|
91 delete iCallerImageThemePath; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CPhoneCallThemeMonitor::CallImageThemeSettings |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 EXPORT_C TInt CPhoneCallThemeMonitor::CallImageThemeSettings() const |
|
99 { |
|
100 __LOGMETHODSTARTEND( EPhoneUIUtils, "CPhoneCallThemeMonitor::CallImageThemeSettings ()" ); |
|
101 return iThemeCallImageSettings; |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CPhoneCallThemeMonitor::CallImageThemeFilePath |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 EXPORT_C TPtrC CPhoneCallThemeMonitor::CallImageThemeFilePath() const |
|
109 { |
|
110 __LOGMETHODSTARTEND( EPhoneUIUtils, "CPhoneCallThemeMonitor::CallImageThemeFilePath ()" ); |
|
111 if ( iCallerImageThemePath ) |
|
112 { |
|
113 return *iCallerImageThemePath; |
|
114 } |
|
115 else |
|
116 { |
|
117 return KNullDesC(); |
|
118 } |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CPhoneCallThemeMonitor::SetCallThemeSettingsObserver |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 EXPORT_C void CPhoneCallThemeMonitor::SetCallThemeSettingsObserver( |
|
126 MPhoneCallThemeSettingsObserver* aObserver ) |
|
127 { |
|
128 __ASSERT_DEBUG( iObserver == NULL, Panic( KErrNotSupported ) ); |
|
129 iObserver = aObserver; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------- |
|
133 // CPhoneCallThemeMonitor::HandleCenRepChangeL |
|
134 // ----------------------------------------------------------- |
|
135 // |
|
136 void CPhoneCallThemeMonitor::HandleCenRepChangeL( |
|
137 const TUid& aUid, |
|
138 const TUint aId ) |
|
139 { |
|
140 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneCallThemeMonitor::HandleCenRepChangeL( ) "); |
|
141 if ( aUid == KCRUidThemes ) |
|
142 { |
|
143 if (aId == KThemesCallImagePath || aId == KThemesCallImageSetting ) |
|
144 { |
|
145 ReadAllL(); |
|
146 if ( iObserver ) |
|
147 { |
|
148 iObserver->CallThemeSettingsChanged(); |
|
149 } |
|
150 } |
|
151 } |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CPhoneCallThemeMonitor::ReadAllL |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CPhoneCallThemeMonitor::ReadAllL() |
|
159 { |
|
160 __LOGMETHODSTARTEND( EPhoneUIUtils, "CPhoneCallThemeMonitor::ReadAllL ()" ); |
|
161 |
|
162 // Call image status |
|
163 TInt value( KErrNone ); |
|
164 TInt err( CPhoneCenRepProxy::Instance()->GetInt( |
|
165 KCRUidThemes, |
|
166 KThemesCallImageSetting, |
|
167 value ) ); |
|
168 |
|
169 if ( err == KErrNone ) |
|
170 { |
|
171 iThemeCallImageSettings = value; |
|
172 } |
|
173 |
|
174 if ( iThemeCallImageSettings == KPslnCRUserDefinedCallImage ) |
|
175 { |
|
176 delete iCallerImageThemePath; |
|
177 iCallerImageThemePath = NULL; |
|
178 iCallerImageThemePath = HBufC::NewL( KMaxFilePathLength ); |
|
179 TPtr imagePtr ( iCallerImageThemePath->Des() ); |
|
180 |
|
181 // Get image file path |
|
182 CPhoneCenRepProxy::Instance()->GetString( |
|
183 KCRUidThemes, |
|
184 KThemesCallImagePath, |
|
185 imagePtr ); |
|
186 |
|
187 __PHONELOG1( EBasic, EPhoneUIUtils, |
|
188 "CPhoneCallThemeMonitor::ReadAllL -> image path = %S", &imagePtr ); |
|
189 } |
|
190 else |
|
191 { |
|
192 delete iCallerImageThemePath; |
|
193 iCallerImageThemePath = NULL; |
|
194 } |
|
195 } |
|
196 |
|
197 // End of File |