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