|
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: Object push controller implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "BTSOPPController.h" |
|
22 #include "BTSUDebug.h" |
|
23 |
|
24 // ============================ MEMBER FUNCTIONS =============================== |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CBTSOPPController::CBTSOPPController |
|
28 // C++ default constructor can NOT contain any code, that |
|
29 // might leave. |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CBTSOPPController::CBTSOPPController( MBTServiceObserver* aObserver, |
|
33 CBTServiceParameterList* aList ) : |
|
34 iListPtr( aList ), |
|
35 iObserverPtr( aObserver ) |
|
36 { |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CBTSOPPController::ConstructL |
|
41 // Symbian 2nd phase constructor can leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 void CBTSOPPController::ConstructL( const TUint aRemotePort, const TBTDevAddr& aRemoteDeviceAddr ) |
|
45 { |
|
46 FLOG(_L("[BTSS]\t CBTSOPPController::ConstructL()")); |
|
47 |
|
48 RArray<CObexHeader*> headerList; |
|
49 CleanupClosePushL( headerList ); |
|
50 CreateClientL ( this, aRemoteDeviceAddr, aRemotePort, headerList ); |
|
51 CleanupStack::Pop(); |
|
52 headerList.Close(); |
|
53 |
|
54 FLOG(_L("[BTSS]\t CBTSOPPController::ConstructL() completed")); |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CBTSOPPController::NewL |
|
59 // Two-phased constructor. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CBTSOPPController* CBTSOPPController::NewL( MBTServiceObserver* aObserver, |
|
63 const TUint aRemotePort, |
|
64 const TBTDevAddr& aRemoteDeviceAddr, |
|
65 CBTServiceParameterList* aList ) |
|
66 { |
|
67 CBTSOPPController* self = new( ELeave ) CBTSOPPController( aObserver, aList ); |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL( aRemotePort, aRemoteDeviceAddr ); |
|
70 CleanupStack::Pop(); |
|
71 return self; |
|
72 } |
|
73 |
|
74 // Destructor |
|
75 CBTSOPPController::~CBTSOPPController() |
|
76 { |
|
77 FLOG(_L("[BTSU]\t CBTSOPPController::Destructor()")); |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CBTSOPPController::ConnectCompleted |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 void CBTSOPPController::ConnectCompleted( TInt aStatus ) |
|
85 { |
|
86 FLOG(_L("[BTSS]\t CBTSOPPController::ConnectCompleted()")); |
|
87 |
|
88 if ( aStatus == KErrNone ) |
|
89 { |
|
90 TRAPD( error, HandleConnectCompleteIndicationL() ); |
|
91 if ( error != KErrNone ) |
|
92 { |
|
93 // Sending initialisation has failed |
|
94 // |
|
95 iObserverPtr->ControllerComplete( EBTSConnectingFailed ); |
|
96 } |
|
97 } |
|
98 else |
|
99 { |
|
100 //Error on Obex level |
|
101 // |
|
102 iObserverPtr->ControllerComplete( EBTSConnectingFailed ); |
|
103 } |
|
104 |
|
105 FLOG(_L("[BTSS]\t CBTSOPPController::ConnectCompleted() completed")); |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CBTSOPPController::ClientConnectionClosed |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void CBTSOPPController::ClientConnectionClosed() |
|
113 { |
|
114 FLOG(_L("[BTSS]\t CBTSOPPController::ClientConnectionClosed()")); |
|
115 |
|
116 // Everything ready, stop service |
|
117 // |
|
118 iObserverPtr->ControllerComplete( EBTSNoError ); |
|
119 |
|
120 FLOG(_L("[BTSS]\t CBTSOPPController::ClientConnectionClosed() completed")); |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CBTSOPPController::PutCompleted |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CBTSOPPController::PutCompleted( TInt aStatus, const CObexHeaderSet* aPutResponse ) |
|
128 { |
|
129 FLOG(_L("[BTSS]\t CBTSOPPController::PutCompleted()")); |
|
130 aPutResponse=aPutResponse; |
|
131 |
|
132 |
|
133 if ( aStatus == KErrNone ) |
|
134 { |
|
135 iFileIndex++; |
|
136 Send(); |
|
137 } |
|
138 else |
|
139 { |
|
140 iObserverPtr->ControllerComplete( EBTSPuttingFailed ); |
|
141 } |
|
142 |
|
143 FLOG(_L("[BTSS]\t CBTSOPPController::PutCompleted() done")); |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CBTSOPPController::GetCompleted |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void CBTSOPPController::GetCompleted( TInt /*aStatus*/, CObexBufObject* /*aGetResponse*/ ) |
|
151 { |
|
152 FLOG(_L("[BTSS]\t CBTSOPPController::GetCompleted() Not used with OPP")); |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CBTSOPPController::Send |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CBTSOPPController::Send() |
|
160 { |
|
161 FLOG(_L("[BTSS]\t CBTSOPPController::Send()")); |
|
162 |
|
163 |
|
164 if ( iListPtr->ObjectCount() > 0 && iFileIndex < iListPtr->ObjectCount() ) |
|
165 { |
|
166 RArray<CObexHeader*> headerList; // the array does not need to be closed |
|
167 TRAPD( error, iClient->PutObjectL( headerList, iListPtr->ObjectAtL( iFileIndex ) )); |
|
168 |
|
169 if ( error ) |
|
170 { |
|
171 FTRACE(FPrint(_L("[BTSU]\t CBTSOPPController::Send() putting leaved with %d"), error )); |
|
172 iObserverPtr->ControllerComplete( EBTSPuttingFailed ); |
|
173 } |
|
174 } |
|
175 else |
|
176 { |
|
177 FLOG(_L("[BTSU]\t CBTSOPPController::Send() all objects sent, closing connection")); |
|
178 |
|
179 // All objects sent, close client connection. |
|
180 // |
|
181 iClient->CloseClientConnection(); |
|
182 } |
|
183 |
|
184 FLOG(_L("[BTSS]\t CBTSOPPController::Send() Done")); |
|
185 } |
|
186 |
|
187 //----------------------------------------------------------------------------- |
|
188 // void CBTSOPPController::ConnectTimedOut() |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CBTSOPPController::ConnectTimedOut() |
|
192 { |
|
193 iObserverPtr->ConnectTimedOut(); |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CBTSOPPController::HandleConnectCompleteIndicationL |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void CBTSOPPController::HandleConnectCompleteIndicationL() |
|
201 { |
|
202 FLOG(_L("[BTSS]\t CBTSOPPController::HandleConnectCompleteIndicationL()")); |
|
203 TBTSUImageParam imgparam; |
|
204 if ( iListPtr->ImageCount() > 0 ) |
|
205 { |
|
206 for( TInt index = 0; index < iListPtr->ImageCount(); index++ ) |
|
207 { |
|
208 // Copy files from Image list to Object list |
|
209 // from now on we use only object list. |
|
210 imgparam = iListPtr->ImageAtL( index ); |
|
211 if(!imgparam.iSend) |
|
212 { |
|
213 iListPtr->AddObjectL( imgparam.iFile); |
|
214 } |
|
215 } |
|
216 } |
|
217 iObserverPtr->LaunchProgressNoteL( iClient, iListPtr->ObjectListSizeL() ); |
|
218 iFileIndex = 0; |
|
219 Send(); |
|
220 } |
|
221 |
|
222 // End of File |