|
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: Monitor for language settings. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <bautils.h> |
|
22 #include <AknFepInternalCRKeys.h> |
|
23 #include "cphonelangsettingmonitor.h" |
|
24 #include "mphonelangsettingobserver.h" |
|
25 #include "phonelogger.h" |
|
26 #include "cphonecenrepproxy.h" |
|
27 #include "mphonecenrepobserver.h" |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CPhoneLangSettingMonitor::CPhoneLangSettingMonitor |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CPhoneLangSettingMonitor::CPhoneLangSettingMonitor() |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CPhoneLangSettingMonitor::ConstructL |
|
47 // Symbian 2nd phase constructor can leave. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void CPhoneLangSettingMonitor::ConstructL() |
|
51 { |
|
52 TInt language(1); // english |
|
53 |
|
54 TInt err( CPhoneCenRepProxy::Instance()->GetInt( |
|
55 KCRUidAknFep, |
|
56 KAknFepInputTxtLang, |
|
57 language )); |
|
58 |
|
59 if ( err == KErrNone ) |
|
60 { |
|
61 iInputLanguageSetting = language; |
|
62 } |
|
63 |
|
64 // Start listen changes in setting and image path |
|
65 CPhoneCenRepProxy::Instance()->NotifyChangeL( |
|
66 KCRUidAknFep, |
|
67 KAknFepInputTxtLang, |
|
68 this ); |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CPhoneLangSettingMonitor::NewL |
|
73 // Two-phased constructor. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CPhoneLangSettingMonitor* CPhoneLangSettingMonitor::NewL() |
|
77 { |
|
78 CPhoneLangSettingMonitor* self = |
|
79 new (ELeave) CPhoneLangSettingMonitor(); |
|
80 |
|
81 CleanupStack::PushL( self ); |
|
82 self->ConstructL(); |
|
83 CleanupStack::Pop( self ); |
|
84 |
|
85 return self; |
|
86 } |
|
87 |
|
88 // Destructor |
|
89 CPhoneLangSettingMonitor::~CPhoneLangSettingMonitor() |
|
90 { |
|
91 iObserverArray.ResetAndDestroy(); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CPhoneLangSettingMonitor::AddObserverL |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CPhoneLangSettingMonitor::AddObserverL( |
|
99 MPhoneLangSettingObserver& aObserver ) |
|
100 { |
|
101 if ( iObserverArray.Find( &aObserver ) != KErrNone ) |
|
102 { |
|
103 User::LeaveIfError( iObserverArray.Append( &aObserver ) ); |
|
104 } |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CPhoneLangSettingMonitor::RemoveObserver |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CPhoneLangSettingMonitor::RemoveObserver( |
|
112 MPhoneLangSettingObserver& aObserver ) |
|
113 { |
|
114 TInt index; |
|
115 if ( iObserverArray.FindInAddressOrder( &aObserver, index ) == KErrNone ) |
|
116 { |
|
117 iObserverArray.Remove( index ); |
|
118 } |
|
119 } |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CPhoneLangSettingMonitor::HandleCenRepChangeL |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 void CPhoneLangSettingMonitor::HandleCenRepChangeL( |
|
125 const TUid& aUid, |
|
126 const TUint aId ) |
|
127 { |
|
128 __LOGMETHODSTARTEND(EPhoneControl, |
|
129 "CPhoneLangSettingMonitor::HandleCenRepChangeL( )"); |
|
130 |
|
131 if ( aUid == KCRUidAknFep && aId == KAknFepInputTxtLang ) |
|
132 { |
|
133 TInt language(1); // english |
|
134 TInt err( CPhoneCenRepProxy::Instance()->GetInt( |
|
135 KCRUidAknFep, |
|
136 KAknFepInputTxtLang, |
|
137 language )); |
|
138 |
|
139 if ( err == KErrNone && iInputLanguageSetting != language ) |
|
140 { |
|
141 iInputLanguageSetting = language; |
|
142 |
|
143 // Notify change to the observers. |
|
144 for ( TInt i = 0; i < iObserverArray.Count(); i++ ) |
|
145 { |
|
146 iObserverArray[i]->HandleInputLanguageSettingChange( |
|
147 iInputLanguageSetting ); |
|
148 } |
|
149 } |
|
150 } |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CPhoneLangSettingMonitor::Language |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 TInt CPhoneLangSettingMonitor::InputLanguage() const |
|
158 { |
|
159 return iInputLanguageSetting; |
|
160 } |
|
161 |
|
162 |
|
163 |
|
164 // End of File |