37
|
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 |
TInt err = KErrNone;
|
|
54 |
|
|
55 |
if ( err == KErrNone )
|
|
56 |
{
|
|
57 |
iInputLanguageSetting = language;
|
|
58 |
}
|
|
59 |
|
|
60 |
// Start listen changes in setting and image path
|
|
61 |
CPhoneCenRepProxy::Instance()->NotifyChangeL(
|
|
62 |
KCRUidAknFep,
|
|
63 |
KAknFepInputTxtLang,
|
|
64 |
this );
|
|
65 |
}
|
|
66 |
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
// CPhoneLangSettingMonitor::NewL
|
|
69 |
// Two-phased constructor.
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
CPhoneLangSettingMonitor* CPhoneLangSettingMonitor::NewL()
|
|
73 |
{
|
|
74 |
CPhoneLangSettingMonitor* self =
|
|
75 |
new (ELeave) CPhoneLangSettingMonitor();
|
|
76 |
|
|
77 |
CleanupStack::PushL( self );
|
|
78 |
self->ConstructL();
|
|
79 |
CleanupStack::Pop( self );
|
|
80 |
|
|
81 |
return self;
|
|
82 |
}
|
|
83 |
|
|
84 |
// Destructor
|
|
85 |
CPhoneLangSettingMonitor::~CPhoneLangSettingMonitor()
|
|
86 |
{
|
|
87 |
iObserverArray.ResetAndDestroy();
|
|
88 |
}
|
|
89 |
|
|
90 |
// -----------------------------------------------------------------------------
|
|
91 |
// CPhoneLangSettingMonitor::AddObserverL
|
|
92 |
// -----------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
void CPhoneLangSettingMonitor::AddObserverL(
|
|
95 |
MPhoneLangSettingObserver& aObserver )
|
|
96 |
{
|
|
97 |
if ( iObserverArray.Find( &aObserver ) != KErrNone )
|
|
98 |
{
|
|
99 |
User::LeaveIfError( iObserverArray.Append( &aObserver ) );
|
|
100 |
}
|
|
101 |
}
|
|
102 |
|
|
103 |
// -----------------------------------------------------------------------------
|
|
104 |
// CPhoneLangSettingMonitor::RemoveObserver
|
|
105 |
// -----------------------------------------------------------------------------
|
|
106 |
//
|
|
107 |
void CPhoneLangSettingMonitor::RemoveObserver(
|
|
108 |
MPhoneLangSettingObserver& aObserver )
|
|
109 |
{
|
|
110 |
TInt index;
|
|
111 |
if ( iObserverArray.FindInAddressOrder( &aObserver, index ) == KErrNone )
|
|
112 |
{
|
|
113 |
iObserverArray.Remove( index );
|
|
114 |
}
|
|
115 |
}
|
|
116 |
// -----------------------------------------------------------------------------
|
|
117 |
// CPhoneLangSettingMonitor::HandleCenRepChangeL
|
|
118 |
// -----------------------------------------------------------------------------
|
|
119 |
//
|
|
120 |
void CPhoneLangSettingMonitor::HandleCenRepChangeL(
|
|
121 |
const TUid& aUid,
|
|
122 |
const TUint aId )
|
|
123 |
{
|
|
124 |
__LOGMETHODSTARTEND(EPhoneControl,
|
|
125 |
"CPhoneLangSettingMonitor::HandleCenRepChangeL( )");
|
|
126 |
|
|
127 |
if ( aUid == KCRUidAknFep && aId == KAknFepInputTxtLang )
|
|
128 |
{
|
|
129 |
TInt language(1); // english
|
|
130 |
TInt err( CPhoneCenRepProxy::Instance()->GetInt(
|
|
131 |
KCRUidAknFep,
|
|
132 |
KAknFepInputTxtLang,
|
|
133 |
language ));
|
|
134 |
|
|
135 |
if ( err == KErrNone && iInputLanguageSetting != language )
|
|
136 |
{
|
|
137 |
iInputLanguageSetting = language;
|
|
138 |
|
|
139 |
// Notify change to the observers.
|
|
140 |
for ( TInt i = 0; i < iObserverArray.Count(); i++ )
|
|
141 |
{
|
|
142 |
iObserverArray[i]->HandleInputLanguageSettingChange(
|
|
143 |
iInputLanguageSetting );
|
|
144 |
}
|
|
145 |
}
|
|
146 |
}
|
|
147 |
}
|
|
148 |
|
|
149 |
// -----------------------------------------------------------------------------
|
|
150 |
// CPhoneLangSettingMonitor::Language
|
|
151 |
// -----------------------------------------------------------------------------
|
|
152 |
//
|
|
153 |
TInt CPhoneLangSettingMonitor::InputLanguage() const
|
|
154 |
{
|
|
155 |
return iInputLanguageSetting;
|
|
156 |
}
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
// End of File
|