|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 #include "CSendDTMF.h" |
|
18 |
|
19 /** |
|
20 Factory constructor. |
|
21 |
|
22 @param aController Pointer to MExecAsync object passed to constructor of |
|
23 CISVAPIBase |
|
24 @return Instance of CSendDTMF class |
|
25 */ |
|
26 CSendDTMF* CSendDTMF::NewL(MExecAsync* aController) |
|
27 { |
|
28 CSendDTMF* self = new(ELeave) CSendDTMF(aController); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 /** |
|
36 Destructor. Cancels outstanding requests. |
|
37 */ |
|
38 CSendDTMF::~CSendDTMF() |
|
39 { |
|
40 Cancel(); |
|
41 } |
|
42 |
|
43 /** |
|
44 Sends DTMF tones as specified in aNumber. |
|
45 |
|
46 @param aNumber Descriptor containing the DTMF tones to send |
|
47 */ |
|
48 void CSendDTMF::DoStartRequestL(const TDesC& aNumber) |
|
49 { |
|
50 if (aNumber.Length() == 1) |
|
51 { |
|
52 iSingleTone = ETrue; |
|
53 } |
|
54 else |
|
55 { |
|
56 iSingleTone = EFalse; |
|
57 } |
|
58 |
|
59 // Transmits DTMF tones across all the currently active voice calls. |
|
60 iTelephony->SendDTMFTones(iStatus, aNumber); |
|
61 SetActive(); |
|
62 } |
|
63 |
|
64 /** |
|
65 Constructor. |
|
66 |
|
67 @param aController Pointer to MExecAsync object passed to constructor of |
|
68 CISVAPIBase |
|
69 */ |
|
70 CSendDTMF::CSendDTMF(MExecAsync* aController) |
|
71 : CISVAPIAsync(aController, KSendDTMF) |
|
72 { |
|
73 // Empty method |
|
74 } |
|
75 |
|
76 /** |
|
77 Second phase constructor. |
|
78 */ |
|
79 void CSendDTMF::ConstructL() |
|
80 { |
|
81 iSingleTone = EFalse; |
|
82 } |
|
83 |
|
84 /** |
|
85 Checks iStatus and prints details to console. |
|
86 */ |
|
87 void CSendDTMF::RunL() |
|
88 { |
|
89 if(iStatus != KErrNone) |
|
90 { |
|
91 iConsole->Printf(KError); |
|
92 |
|
93 // Print error status code |
|
94 iConsole->Printf(_L("%d\n"), iStatus.Int()); |
|
95 } |
|
96 else |
|
97 { |
|
98 if (iSingleTone) |
|
99 { |
|
100 iConsole->Printf(_L("Beep\n")); |
|
101 ExampleNotify(); |
|
102 } |
|
103 else |
|
104 { |
|
105 iConsole->Printf(_L("Beeps\n")); |
|
106 ExampleComplete(); |
|
107 } |
|
108 } |
|
109 } |
|
110 |
|
111 /** |
|
112 Cancels asynchronous request to CTelephony::SendDTMFTones(). |
|
113 */ |
|
114 void CSendDTMF::DoCancel() |
|
115 { |
|
116 // Cancels an outstanding asynchronous request. |
|
117 iTelephony->CancelAsync(CTelephony::ESendDTMFTonesCancel); |
|
118 } |