|
1 /* |
|
2 * Copyright (c) 2002 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: Ext Phone for dialing. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32std.h> |
|
22 #include "MPhCltExtPhoneObserver.h" |
|
23 #include "CPhCltExtPhone.h" |
|
24 #include "CPhCltExtPhoneDialData.h" |
|
25 |
|
26 // LOCAL CONSTANTS AND MACROS |
|
27 |
|
28 // Panic codes. |
|
29 enum TPhCltExtPhonePanic |
|
30 { |
|
31 EPhCltExtPhonePanicNoObserver, // No observer found. |
|
32 EPhCltExtPhonePanicInvalidOperationMode // Operation mode was invalid. |
|
33 }; |
|
34 |
|
35 |
|
36 // LOCAL FUNCTION PROTOTYPES |
|
37 |
|
38 // Panic function. Called if panic situation happens. |
|
39 void Panic( TPhCltExtPhonePanic aPanic ); |
|
40 |
|
41 |
|
42 // ============================= LOCAL FUNCTIONS =============================== |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // Panic |
|
46 // |
|
47 // Panics the client |
|
48 // |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void Panic( TPhCltExtPhonePanic aPanic ) |
|
52 { |
|
53 _LIT(KPhCltExtPhonePanicCategory, "CPhCltExtPhone"); |
|
54 User::Panic( KPhCltExtPhonePanicCategory, aPanic ); |
|
55 } |
|
56 |
|
57 // ============================ MEMBER FUNCTIONS =============================== |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CPhCltExtPhone::NewL |
|
61 // Two-phased constructor. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CPhCltExtPhone* CPhCltExtPhone::NewL( MPhCltExtPhoneObserver* aObserver ) |
|
65 { |
|
66 CPhCltExtPhone* self = new ( ELeave ) CPhCltExtPhone( aObserver ); |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop(); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // Destructor |
|
74 CPhCltExtPhone::~CPhCltExtPhone() |
|
75 { |
|
76 delete iPackage; |
|
77 |
|
78 // Cancel, close subsessions and finally close the session. |
|
79 Cancel(); |
|
80 iCall.Close(); |
|
81 iServer.Close(); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CPhCltExtPhone::DialL |
|
86 // |
|
87 // If a request is pending, leave with error code KErrInUse. |
|
88 // Otherwise, create a dial request. |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CPhCltExtPhone::DialL( CPhCltExtPhoneDialData& aData ) |
|
92 { |
|
93 DialPreconditionCheckL(); |
|
94 delete iPackage; |
|
95 iPackage = NULL; |
|
96 |
|
97 // packs params |
|
98 iPackage = aData.PackLC(); |
|
99 CleanupStack::Pop( iPackage ); |
|
100 TInt datalength = aData.CalculatePackageSize(); |
|
101 if ( iPackage ) |
|
102 { |
|
103 iCall.Dial( iStatus, *iPackage, datalength ); |
|
104 } |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CPhCltExtPhone::CPhCltExtPhone |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 CPhCltExtPhone::CPhCltExtPhone( MPhCltExtPhoneObserver* aObserver ) |
|
112 : CPhCltExtPhoneBase( aObserver ), iMode( EIdle ) |
|
113 { |
|
114 CActiveScheduler::Add( this ); |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CPhCltExtPhone::ConstructL |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CPhCltExtPhone::ConstructL() |
|
122 { |
|
123 User::LeaveIfError( iServer.Connect() ); |
|
124 User::LeaveIfError( iCall.Open( iServer ) ); |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CPhCltExtPhone::RunL |
|
129 // |
|
130 // The method is called when a request is completed. Thus, |
|
131 // it calls appropriate observer method. |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CPhCltExtPhone::RunL() |
|
135 { |
|
136 __ASSERT_ALWAYS( iObserver, Panic( EPhCltExtPhonePanicNoObserver ) ); |
|
137 switch( iMode ) |
|
138 { |
|
139 case EDialling: |
|
140 iObserver->HandleDialL( iStatus.Int() ); |
|
141 break; |
|
142 case EIdle: |
|
143 break; |
|
144 default: |
|
145 Panic( EPhCltExtPhonePanicInvalidOperationMode ); |
|
146 break; |
|
147 } |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CPhCltExtPhone::DoCancel |
|
152 // |
|
153 // Cancels the pending request. |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CPhCltExtPhone::DoCancel() |
|
157 { |
|
158 switch( iMode ) |
|
159 { |
|
160 case EDialling: |
|
161 iCall.CancelDial(); |
|
162 break; |
|
163 case EIdle: |
|
164 break; |
|
165 default: |
|
166 Panic( EPhCltExtPhonePanicInvalidOperationMode ); |
|
167 break; |
|
168 } |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // CPhCltExtPhone::DialPreconditionCheckL |
|
173 // |
|
174 // See header |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void CPhCltExtPhone::DialPreconditionCheckL() |
|
178 { |
|
179 if( IsActive() ) |
|
180 { |
|
181 User::Leave( KErrInUse ); |
|
182 } |
|
183 if( iCall.SubSessionHandle() == 0 ) |
|
184 { |
|
185 User::Leave( KErrBadHandle ); |
|
186 } |
|
187 iMode = EDialling; |
|
188 SetActive(); |
|
189 } |
|
190 |
|
191 // End of File |