|
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: Telephony Multimedia Service |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <rmmcustomapi.h> |
|
19 #include <gsmerror.h> |
|
20 #include "tmsdtmfprovider.h" |
|
21 #include "tmsdtmfobserver.h" |
|
22 #include "tmseteldtmfmonitor.h" |
|
23 #include "tmsutility.h" |
|
24 |
|
25 using namespace TMS; |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // TMSEtelDtmfMonitor::NewL. |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 TMSEtelDtmfMonitor* TMSEtelDtmfMonitor::NewL(TMSDTMFProvider& aObserver, |
|
32 RMmCustomAPI& aMmCustom) |
|
33 { |
|
34 TRACE_PRN_FN_ENT; |
|
35 TMSEtelDtmfMonitor* self = new (ELeave) TMSEtelDtmfMonitor(aObserver, |
|
36 aMmCustom); |
|
37 TRACE_PRN_FN_EXT; |
|
38 return self; |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // Destructs the object by canceling first ongoing monitoring. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 TMSEtelDtmfMonitor::~TMSEtelDtmfMonitor() |
|
46 { |
|
47 TRACE_PRN_FN_ENT; |
|
48 Cancel(); |
|
49 TRACE_PRN_FN_EXT; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // Starts the monitor. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void TMSEtelDtmfMonitor::StartMonitoring() |
|
57 { |
|
58 TRACE_PRN_FN_ENT; |
|
59 if (!IsActive()) |
|
60 { |
|
61 iStatus = KRequestPending; |
|
62 iMmCustom.NotifyDtmfEvent(iStatus, iEventData); |
|
63 SetActive(); |
|
64 } |
|
65 TRACE_PRN_FN_EXT; |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // From CActive. |
|
70 // Handles line status change notifying. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void TMSEtelDtmfMonitor::RunL() |
|
74 { |
|
75 TRACE_PRN_FN_ENT; |
|
76 TInt err = iStatus.Int(); |
|
77 TRACE_PRN_N1(_L("**TMS TMSEtelDtmfMonitor::RunL: status:%d"), err); |
|
78 |
|
79 if (err == KErrNone) |
|
80 { |
|
81 TMSDTMFObserver::TCCPDtmfEvent event; |
|
82 if (iEventData.iEvent == RMmCustomAPI::EDtmfStart |
|
83 && iEventData.iType == RMmCustomAPI::EDtmfManual) |
|
84 { |
|
85 event = TMSDTMFObserver::ECCPDtmfManualStart; |
|
86 } |
|
87 else if (iEventData.iEvent == RMmCustomAPI::EDtmfStart |
|
88 && iEventData.iType == RMmCustomAPI::EDtmfSequence) |
|
89 { |
|
90 event = TMSDTMFObserver::ECCPDtmfSequenceStart; |
|
91 } |
|
92 else if (iEventData.iEvent == RMmCustomAPI::EDtmfStop |
|
93 && iEventData.iType == RMmCustomAPI::EDtmfManual) |
|
94 { |
|
95 event = TMSDTMFObserver::ECCPDtmfManualStop; |
|
96 } |
|
97 else if (iEventData.iEvent == RMmCustomAPI::EDtmfStop |
|
98 && iEventData.iType == RMmCustomAPI::EDtmfSequence) |
|
99 { |
|
100 event = TMSDTMFObserver::ECCPDtmfSequenceStop; |
|
101 } |
|
102 else if (iEventData.iEvent == RMmCustomAPI::EDtmfAbort |
|
103 && iEventData.iType == RMmCustomAPI::EDtmfManual) |
|
104 { |
|
105 event = TMSDTMFObserver::ECCPDtmfManualAbort; |
|
106 } |
|
107 else if (iEventData.iEvent == RMmCustomAPI::EDtmfAbort |
|
108 && iEventData.iType == RMmCustomAPI::EDtmfSequence) |
|
109 { |
|
110 event = TMSDTMFObserver::ECCPDtmfSequenceAbort; |
|
111 } |
|
112 else |
|
113 { |
|
114 // Refresh and return (no observer notfiying). |
|
115 TRACE_PRN_N2(_L("**TMS TMSEtelDtmfMonitor::RunL: Unknown event \ |
|
116 = %¨d, type = %d"), iEventData.iEvent,iEventData.iType); |
|
117 StartMonitoring(); |
|
118 return; |
|
119 } |
|
120 |
|
121 iObserver.NotifyDTMFEvent(event, err, iEventData.iTone); |
|
122 } |
|
123 else |
|
124 { |
|
125 TRACE_PRN_N1(_L("**TMS TMSEtelDtmfMonitor::RunL: Error \ |
|
126 from DTMF: %d"),err); |
|
127 } |
|
128 |
|
129 // Continue if not in offline mode |
|
130 if (err != KErrGsmOfflineOpNotAllowed && err != KErrCancel |
|
131 && err != KErrNotSupported) |
|
132 { |
|
133 StartMonitoring(); |
|
134 } |
|
135 TRACE_PRN_FN_EXT; |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // From CActive |
|
140 // Canceling functionality. |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 void TMSEtelDtmfMonitor::DoCancel() |
|
144 { |
|
145 TRACE_PRN_FN_ENT; |
|
146 if (iStatus == KRequestPending) |
|
147 { |
|
148 iMmCustom.CancelAsyncRequest(ECustomNotifyDtmfEventIPC); |
|
149 } |
|
150 TRACE_PRN_FN_EXT; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // Constructs the monitor. |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 TMSEtelDtmfMonitor::TMSEtelDtmfMonitor(TMSDTMFProvider& aObserver, |
|
158 RMmCustomAPI& aMmCustom) : |
|
159 CActive(EPriorityStandard), |
|
160 iObserver(aObserver), |
|
161 iMmCustom(aMmCustom) |
|
162 { |
|
163 TRACE_PRN_FN_ENT; |
|
164 CActiveScheduler::Add(this); |
|
165 TRACE_PRN_FN_EXT; |
|
166 } |
|
167 |
|
168 // End of file |