|
1 /* |
|
2 * Copyright (c) 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: Protocol factory implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "mvtprotocolhandler.h" |
|
19 #include "cdatasourceproxy.h" |
|
20 #include "cdatasinkproxy.h" |
|
21 #include "csessionhandler.h" |
|
22 #include "caudioconfighandler.h" |
|
23 #include "cvtuserinput.h" |
|
24 #include "ccommserver.h" |
|
25 |
|
26 #ifdef _DEBUG |
|
27 # define __IF_DEBUG(t) {RDebug::t;} |
|
28 #else |
|
29 # define __IF_DEBUG(t) |
|
30 #endif |
|
31 // ----------------------------------------------------------------------------- |
|
32 // VTProtocolFactory::CreateSessionCommandL |
|
33 // Create one instance. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 EXPORT_C MVtSessionCommand* VTProtocolFactory::CreateSessionCommandL(MVtProtocolHandler* aProtocolHandler, TBool aEnableProxy, TVt3G324MSupported& a3G324MSupported) |
|
37 { |
|
38 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateSessionCommandL<"))); |
|
39 a3G324MSupported = EVt3G324MMissing; |
|
40 TSessionHandler * sessionHandler = new (ELeave)TSessionHandler(aProtocolHandler); |
|
41 CleanupStack::PushL(sessionHandler); |
|
42 CSessionCommand* sessionCommand = new (ELeave)CSessionCommand(sessionHandler); |
|
43 CleanupStack::Pop(); |
|
44 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateSessionCommandL sessionCommand %d>"), sessionCommand)); |
|
45 return sessionCommand; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // VTProtocolFactory::DeleteSessionCommand |
|
50 // This function allows the application to delete an instance of a terminal |
|
51 // and reclaim all allocated resources. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 EXPORT_C void VTProtocolFactory::DeleteSessionCommand( MVtSessionCommand* aSessionCommand ) |
|
55 { |
|
56 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeleteSessionCommand<"))); |
|
57 CSessionCommand* sessionCommand = static_cast<CSessionCommand*>(aSessionCommand); |
|
58 delete aSessionCommand; |
|
59 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeleteSessionCommand>"))); |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // VTProtocolFactory::CreateAudioSource |
|
64 // Creates an instance of a DevSound audio data source. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 EXPORT_C MVTAudioSource* VTProtocolFactory::CreateAudioSource() |
|
68 { |
|
69 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateAudioSource<"))); |
|
70 TInt err( KErrNone ); |
|
71 CAudioSourceProxy* audioSourceProxy = NULL; |
|
72 TRAP (err, audioSourceProxy = new (ELeave) CAudioSourceProxy() ); |
|
73 if (err != KErrNone) |
|
74 { |
|
75 return NULL; |
|
76 } |
|
77 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateAudioSource audioSourceProxy %d>"), audioSourceProxy)); |
|
78 return audioSourceProxy; |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // VTProtocolFactory::DeletAudioSource |
|
83 // Deletes an instance of a DevSound audio data source. |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 EXPORT_C TInt VTProtocolFactory::DeletAudioSource(MVTAudioSource *aSource) |
|
87 { |
|
88 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeletAudioSource<"))); |
|
89 CAudioSourceProxy* audioSourceProxy = static_cast<CAudioSourceProxy*>(aSource); |
|
90 delete aSource; |
|
91 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeletAudioSource>"))); |
|
92 return KErrNone; |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // VTProtocolFactory::CreateAudioSink |
|
97 // Creates an instance of a DevSound audio data sink. |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C MVTAudioSink* VTProtocolFactory::CreateAudioSink() |
|
101 { |
|
102 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateAudioSink<"))); |
|
103 TInt err( KErrNone ); |
|
104 CAudioSinkProxy* audioSinkProxy = NULL; |
|
105 TRAP(err, audioSinkProxy = new (ELeave) CAudioSinkProxy() ); |
|
106 if (err != KErrNone) |
|
107 { |
|
108 return NULL; |
|
109 } |
|
110 |
|
111 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateAudioSink audioSinkProxy %d>"), audioSinkProxy)); |
|
112 return audioSinkProxy; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // VTProtocolFactory::DeleteAudioSink |
|
117 // Deletes an instance of a DevSound audio data sink |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 EXPORT_C TInt VTProtocolFactory::DeleteAudioSink(MVTAudioSink *aSink) |
|
121 { |
|
122 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeleteAudioSink<"))); |
|
123 CAudioSinkProxy* audioSinkProxy = static_cast<CAudioSinkProxy*>(aSink); |
|
124 delete aSink; |
|
125 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeleteAudioSink>"))); |
|
126 return KErrNone; |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // VTProtocolFactory::CreateCommServerL |
|
131 // Creates an instance of a comm server of a particular name, to be used to |
|
132 // initialize the terminal. |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C MCommServer* VTProtocolFactory::CreateCommServerL(const TDesC & aName, TBool aEnableBitReversal) |
|
136 { |
|
137 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateCommServerL<"))); |
|
138 CCommServer* commServer = new (ELeave)CCommServer(); |
|
139 CleanupStack::PushL(commServer); |
|
140 CleanupStack::Pop(); |
|
141 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateCommServerL commServer %d>"), commServer)); |
|
142 return commServer; |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // VTProtocolFactory::DeleteCommServerL |
|
147 // This function allows the application to delete an instance of a comm server |
|
148 // and reclaim all allocated resources. |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 EXPORT_C void VTProtocolFactory::DeleteCommServerL(MCommServer* aCommServer) |
|
152 { |
|
153 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeleteCommServerL<"))); |
|
154 CCommServer* commServer = static_cast<CCommServer*>(aCommServer); |
|
155 delete aCommServer; |
|
156 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeleteCommServerL>"))); |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // VTProtocolFactory::CreateUserInputIndication |
|
161 // Create instance . |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 EXPORT_C MVTUserInput* VTProtocolFactory::CreateUserInputIndication(TUserInputType aUIIType, TUint8 aTone) |
|
165 { |
|
166 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateUserInputIndication"))); |
|
167 if (aUIIType == EVtUiiDTFM) |
|
168 { |
|
169 CVTUserInputDtmf* uii = CVTUserInputDtmf::NewL(aTone); |
|
170 return uii; |
|
171 } |
|
172 else if (aUIIType == EVtUiiAlphaNumeric) |
|
173 { |
|
174 CVTUserInputAlphanumeric* uii = CVTUserInputAlphanumeric::NewL(aTone); |
|
175 return uii; |
|
176 } |
|
177 else |
|
178 { |
|
179 return NULL; |
|
180 } |
|
181 |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // VTProtocolFactory::DeleteUserInputIndication |
|
186 // Delete instance. |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 EXPORT_C void VTProtocolFactory::DeleteUserInputIndication(MVTUserInput* aUII) |
|
190 { |
|
191 delete aUII; |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // VTProtocolFactory::GetAudioConfigCommandL |
|
196 // Get one instance. |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 EXPORT_C MVtAudioConfigCommand* VTProtocolFactory::GetAudioConfigCommandL(MVTAudioSink* aAudioSink) |
|
200 { |
|
201 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::GetAudioConfigCommandL<"))); |
|
202 CAudioSinkProxy* audioSinkProxy = static_cast<CAudioSinkProxy*>(aAudioSink); |
|
203 CAudioConfigCommand* audioConfigCommand = new (ELeave)CAudioConfigCommand(); |
|
204 __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::GetAudioConfigCommandL audioConfigCommand %d>"), audioConfigCommand)); |
|
205 return audioConfigCommand; |
|
206 } |
|
207 |
|
208 // end of file |