|
1 /* |
|
2 * Copyright (c) 2009 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: Field event queue implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cmrsystemnotifier.h" |
|
19 #include "cesmrfieldeventqueue.h" |
|
20 #include "cesmrfieldcommandevent.h" |
|
21 #include "esmrdef.h" |
|
22 #include "emailtrace.h" |
|
23 |
|
24 #include <bacntf.h> |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // CMRSystemNotifier::CESMRFieldEventQueue |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CMRSystemNotifier::CMRSystemNotifier( CESMRFieldEventQueue& aEventQueue ) |
|
33 : iEventQueue( aEventQueue ) |
|
34 { |
|
35 FUNC_LOG; |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CMRSystemNotifier::CESMRFieldEventQueue |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CMRSystemNotifier::~CMRSystemNotifier() |
|
43 { |
|
44 FUNC_LOG; |
|
45 delete iSystemNotifier; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CMRSystemNotifier::CESMRFieldEventQueue |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CMRSystemNotifier* CMRSystemNotifier::NewL( |
|
53 CESMRFieldEventQueue& aEventQueue ) |
|
54 { |
|
55 FUNC_LOG; |
|
56 CMRSystemNotifier* self = new (ELeave) CMRSystemNotifier( aEventQueue ); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop( self ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CMRSystemNotifier::CESMRFieldEventQueue |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void CMRSystemNotifier::ConstructL() |
|
68 { |
|
69 FUNC_LOG; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CMRSystemNotifier::CESMRFieldEventQueue |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void CMRSystemNotifier::StartL() |
|
77 { |
|
78 FUNC_LOG; |
|
79 |
|
80 if ( !iSystemNotifier ) |
|
81 { |
|
82 TCallBack envCallback( EnvChangeCallbackL, this ); |
|
83 |
|
84 iSystemNotifier = |
|
85 CEnvironmentChangeNotifier::NewL( |
|
86 EPriorityNormal, |
|
87 envCallback ); |
|
88 |
|
89 iSystemNotifier->Start(); |
|
90 } |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CMRSystemNotifier::CESMRFieldEventQueue |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CMRSystemNotifier::Stop() |
|
98 { |
|
99 FUNC_LOG; |
|
100 delete iSystemNotifier; |
|
101 iSystemNotifier = NULL; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CMRSystemNotifier::CESMRFieldEventQueue |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 TInt CMRSystemNotifier::EnvChangeCallbackL( TAny* aThisPtr ) |
|
109 { |
|
110 CMRSystemNotifier* thisObject = static_cast<CMRSystemNotifier*>(aThisPtr); |
|
111 |
|
112 ASSERT( thisObject ); |
|
113 |
|
114 thisObject->DoEnvChangeL(); |
|
115 |
|
116 return KErrNone; |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // CMRSystemNotifier::DoEnvChangeL |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 void CMRSystemNotifier::DoEnvChangeL() |
|
124 { |
|
125 FUNC_LOG; |
|
126 |
|
127 // EChangesLocale |
|
128 TInt change( iSystemNotifier->Change() ); |
|
129 |
|
130 if ( EChangesLocale & change ) |
|
131 { |
|
132 // Broadcast MRUI event |
|
133 iEventQueue.NotifyEventAsyncL( |
|
134 CESMRFieldCommandEvent::NewL( NULL, EMRCmdDoEnvironmentChange) ); |
|
135 } |
|
136 } |
|
137 |
|
138 // EOF |