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