|
1 /* |
|
2 * Copyright (c) 2006-2008 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: MsgIndicatorPlugin plugin implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <etelmm.h> |
|
21 #include <MessagingDomainCRKeys.h> |
|
22 #include "MsgWaitingObserver.h" |
|
23 #include "msgindicatorpluginlog.h" |
|
24 #include "msgindicatorpluginimplementation.h" |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // CMsgIndicatorPluginImplementation::CMsgIndicatorPluginImplementation |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 CWaitingObserver::CWaitingObserver( RMobilePhone &aMobilePhone, |
|
31 CMsgIndicatorPluginImplementation& iIndicatorPlugin ) : |
|
32 CActive( EPriorityNormal ), |
|
33 iChangeNotifySubscribed( EFalse ), |
|
34 iMobilePhone( aMobilePhone ), |
|
35 iMsgWaiting(), |
|
36 iMsgWaitingPckg( iMsgWaiting ), |
|
37 iIndicatorPlugin(iIndicatorPlugin) |
|
38 { |
|
39 CActiveScheduler::Add( this ); |
|
40 } |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CWaitingObserver::NewL |
|
43 // Two-phased constructor. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CWaitingObserver* CWaitingObserver::NewL( RMobilePhone &aMobilePhone, |
|
47 CMsgIndicatorPluginImplementation& iIndicatorPlugin ) |
|
48 { |
|
49 CWaitingObserver* self = new (ELeave) CWaitingObserver( aMobilePhone, iIndicatorPlugin); |
|
50 |
|
51 CleanupStack::PushL( self ); |
|
52 self->ConstructL(); |
|
53 CleanupStack::Pop( self ); |
|
54 |
|
55 return self; |
|
56 } |
|
57 // --------------------------------------------------------------------------- |
|
58 // CMsgIndicatorPluginImplementation::ConstructL |
|
59 // Symbian 2nd phase constructor can leave. |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 void CWaitingObserver::ConstructL() |
|
63 { |
|
64 MSGPLUGINLOGGER_WRITE_FORMAT( "::ConstructL: this 0x%x", |
|
65 this ); |
|
66 |
|
67 User::LeaveIfError( iTelServer.Connect() ); |
|
68 |
|
69 User::LeaveIfError( iTelServer.GetPhoneInfo( 0, iPhoneInfo ) ); |
|
70 |
|
71 User::LeaveIfError( iMobilePhone.Open( iTelServer, iPhoneInfo.iName ) ); |
|
72 |
|
73 iMobilePhone.GetIccMessageWaitingIndicators( iStatus, iMsgWaitingPckg ); |
|
74 SetActive(); |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CWaitingObserver::~CWaitingObserver() |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CWaitingObserver::~CWaitingObserver() |
|
82 { |
|
83 MSGPLUGINLOGGER_WRITE_FORMAT( "Destructor: this 0x%x", |
|
84 this ); |
|
85 Cancel(); |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CWaitingObserver::RunL() |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 void CWaitingObserver::RunL() |
|
93 { |
|
94 TInt err = iStatus.Int(); |
|
95 MSGPLUGINLOGGER_WRITE_FORMAT("RunL(): err: %d", err); |
|
96 // subscribe for notifications |
|
97 |
|
98 if ( err == KErrNone ) |
|
99 { |
|
100 UpdateIndicatorStatusL(); |
|
101 } |
|
102 |
|
103 iMobilePhone.NotifyIccMessageWaitingIndicatorsChange( iStatus, iMsgWaitingPckg ); |
|
104 SetActive(); |
|
105 |
|
106 // get-request completed, DoCancel() must now cancel notify request |
|
107 iChangeNotifySubscribed = ETrue; |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CWaitingObserver::DoCancel() |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void CWaitingObserver::DoCancel() |
|
115 { |
|
116 if ( iChangeNotifySubscribed ) |
|
117 { |
|
118 iMobilePhone.CancelAsyncRequest( EMobilePhoneNotifyIccMessageWaitingIndicatorsChange ); |
|
119 } |
|
120 else |
|
121 { |
|
122 iMobilePhone.CancelAsyncRequest( EMobilePhoneGetIccMessageWaitingIndicators ); |
|
123 } |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CWaitingObserver::GetMsgCount(const TIndicatorMessageType aMsgType) |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 TInt CWaitingObserver::GetMsgCount( const TIndicatorMessageType aMsgType ) |
|
131 { |
|
132 TInt msgCount = 0; |
|
133 MSGPLUGINLOGGER_WRITE( "GetMsgCount()"); |
|
134 switch( aMsgType ) |
|
135 { |
|
136 case EIndicatorMessageTypeFax: |
|
137 msgCount = iMsgWaiting.iFaxMsgs; |
|
138 MSGPLUGINLOGGER_WRITE_FORMAT( "GetMsgCount->FAX %d", msgCount ); |
|
139 MSGPLUGINLOGGER_WRITE_FORMAT( "GetMsgCount->FAX %d", iMsgWaiting.iFaxMsgs ); |
|
140 break; |
|
141 |
|
142 case EIndicatorMessageTypeVMLine1: |
|
143 msgCount = iMsgWaiting.iVoiceMsgs; |
|
144 MSGPLUGINLOGGER_WRITE_FORMAT( "GetMsgCount->LINE1 %d", msgCount ); |
|
145 MSGPLUGINLOGGER_WRITE_FORMAT( "GetMsgCount->LINE1 %d", iMsgWaiting.iVoiceMsgs ); |
|
146 break; |
|
147 |
|
148 case EIndicatorMessageTypeVMLine2: |
|
149 msgCount = iMsgWaiting.iAuxVoiceMsgs; |
|
150 MSGPLUGINLOGGER_WRITE_FORMAT( "GetMsgCount->LINE2 %d", msgCount ); |
|
151 MSGPLUGINLOGGER_WRITE_FORMAT( "GetMsgCount->LINE2 %d", iMsgWaiting.iAuxVoiceMsgs ); |
|
152 break; |
|
153 |
|
154 default: |
|
155 break; |
|
156 } |
|
157 MSGPLUGINLOGGER_WRITE_FORMAT( "GetMsgCount->RETURN %d", msgCount ); |
|
158 return msgCount; |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // CWaitingObserver::UpdateIndicatorStatusL() |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 void CWaitingObserver::UpdateIndicatorStatusL() |
|
166 { |
|
167 MSGPLUGINLOGGER_WRITE( "UpdateIndicatorStatus()"); |
|
168 |
|
169 MSGPLUGINLOGGER_WRITE_FORMAT( "::UpdateIndicatorStatus: Voice mail line 1 count %d", iMsgWaiting.iVoiceMsgs ); |
|
170 MSGPLUGINLOGGER_WRITE_FORMAT( "::UpdateIndicatorStatus: Fax count %d", iMsgWaiting.iFaxMsgs ); |
|
171 |
|
172 iMsgWaiting = iMsgWaitingPckg(); |
|
173 if(!CheckSupressNotificationSettingL()) |
|
174 { |
|
175 if(iMsgWaiting.iDisplayStatus & RMobilePhone::KDisplayVoicemailActive) |
|
176 { |
|
177 if ( !iIndicatorPlugin.IsALSSupported() ) |
|
178 { |
|
179 MSGPLUGINLOGGER_WRITE( "iIndicatorPlugin.UpdateTextL( EAknIndicatorVoiceMailWaiting )"); |
|
180 iIndicatorPlugin.UpdateL( EAknIndicatorVoiceMailWaiting ); |
|
181 } |
|
182 else |
|
183 { |
|
184 MSGPLUGINLOGGER_WRITE( "iIndicatorPlugin.UpdateTextL( EAknIndicatorVoiceMailWaitingOnLine1 )"); |
|
185 iIndicatorPlugin.UpdateL( EAknIndicatorVoiceMailWaitingOnLine1 ); |
|
186 } |
|
187 } |
|
188 } |
|
189 if ( iMsgWaiting.iDisplayStatus & RMobilePhone::KDisplayAuxVoicemailActive ) |
|
190 { |
|
191 MSGPLUGINLOGGER_WRITE( "iIndicatorPlugin.UpdateTextL( EAknIndicatorVoiceMailWaitingOnLine2 )"); |
|
192 iIndicatorPlugin.UpdateL( EAknIndicatorVoiceMailWaitingOnLine2 ); |
|
193 } |
|
194 if ( iMsgWaiting.iDisplayStatus & RMobilePhone::KDisplayFaxActive) |
|
195 { |
|
196 MSGPLUGINLOGGER_WRITE( "iIndicatorPlugin.UpdateTextL( EAknIndicatorFaxMessage )"); |
|
197 iIndicatorPlugin.UpdateL( EAknIndicatorFaxMessage ); |
|
198 } |
|
199 } |
|
200 // ------------------------------------------------------------------- |
|
201 // Check the KMuiuSupressAllNotificationConfiguration value |
|
202 // ------------------------------------------------------------------- |
|
203 // |
|
204 TBool CWaitingObserver::CheckSupressNotificationSettingL() |
|
205 { |
|
206 TBool result = EFalse; |
|
207 TInt value = 0; |
|
208 CRepository* repository = NULL; |
|
209 |
|
210 TRAPD( err, repository = CRepository::NewL( KCRUidMuiuMessagingConfiguration ) ); |
|
211 if( err == KErrNone && repository != NULL ) |
|
212 { |
|
213 CleanupStack::PushL( repository ); |
|
214 err = repository->Get( KMuiuSupressAllNotificationConfiguration, value ); |
|
215 |
|
216 if(err == KErrNone && (value & KMuiuNotificationSupressedForVoiceMail )) |
|
217 { |
|
218 result = ETrue; |
|
219 } |
|
220 } |
|
221 MSGPLUGINLOGGER_WRITE_FORMAT( "CWaitingObserver: SupressNotification %d", result ); |
|
222 CleanupStack::PopAndDestroy( repository ); |
|
223 return result; |
|
224 } |
|
225 // End of File |