|
1 /* |
|
2 * Copyright (c) 2007 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: Source file for CUpnpMoveTask class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 // System |
|
21 #include <utf.h> // ConvertToUnicodeFromUtf8L |
|
22 |
|
23 // upnp stack api |
|
24 #include <upnpitem.h> // CUpnpItem |
|
25 #include <upnpobject.h> // CUpnpObject (cast) |
|
26 |
|
27 // upnp framework / avcontroller api |
|
28 #include "upnpavcontroller.h" // MUPnPAVController |
|
29 #include "upnpavcontrollerfactory.h" // UPnPAVControllerFactory |
|
30 #include "upnpavbrowsingsession.h" // MUPnPAVBrowsingSession |
|
31 #include "upnpavsessionbase.h" // ReserveLocalMSServicesCompleted() |
|
32 #include "upnpavdevice.h" // CUpnpAVDevice |
|
33 |
|
34 // upnp framework / internal api's |
|
35 #include "upnpcommonutils.h" // TUPnPItemType |
|
36 #include "upnpmetadatafetcher.h" // UPnPMetadataFetcher |
|
37 #include "upnpfiletransferengine.h" // CUpnpFileTransferEngine |
|
38 |
|
39 // upnp framework / command internal |
|
40 #include "upnpfilepipe.h" // CUpnpFilePipe |
|
41 #include "upnpcommandparameters.h" // CUpnpCommandParameters |
|
42 #include "upnptaskhandler.h" // MUpnpTaskHandler |
|
43 #include "upnpnotehandler.h" // CUpnpNoteHandler |
|
44 #include "upnpmovetask.h" |
|
45 #include "upnpcommand.h" |
|
46 #include "upnptaskresourceallocator.h" // CUpnpTaskResourceAllocator |
|
47 |
|
48 _LIT( KComponentLogfile, "upnpcommand.log"); |
|
49 #include "upnplog.h" |
|
50 |
|
51 // -------------------------------------------------------------------------- |
|
52 // CUpnpMoveTask::NewL |
|
53 // Creates an instance of the implementation. |
|
54 // -------------------------------------------------------------------------- |
|
55 // |
|
56 CUpnpTask* CUpnpMoveTask::NewL() |
|
57 { |
|
58 __LOG( "[UpnpCommand]\t CUpnpMoveTask::NewL" ); |
|
59 |
|
60 // Create instance |
|
61 CUpnpMoveTask* self = new (ELeave) CUpnpMoveTask(); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 CleanupStack::Pop( self ); |
|
65 return self; |
|
66 } |
|
67 |
|
68 // -------------------------------------------------------------------------- |
|
69 // CUpnpMoveTask::CUpnpMoveTask |
|
70 // First phase construction. |
|
71 // -------------------------------------------------------------------------- |
|
72 // |
|
73 CUpnpMoveTask::CUpnpMoveTask() |
|
74 : CUpnpFileTransferBaseTask() |
|
75 { |
|
76 __LOG( "[UpnpCommand]\t CUpnpMoveTask::Constructor" ); |
|
77 } |
|
78 |
|
79 // -------------------------------------------------------------------------- |
|
80 // Destructor. |
|
81 // -------------------------------------------------------------------------- |
|
82 // |
|
83 CUpnpMoveTask::~CUpnpMoveTask() |
|
84 { |
|
85 __LOG( "[UpnpCommand]\t CUpnpMoveTask::Destructor" ); |
|
86 } |
|
87 |
|
88 // -------------------------------------------------------------------------- |
|
89 // CUpnpMoveTask::ConstructL |
|
90 // Perform the second phase of two phase construction. Reserves the Upnp Fw |
|
91 // resources (they are released when the task is destroyed). |
|
92 // -------------------------------------------------------------------------- |
|
93 // |
|
94 void CUpnpMoveTask::ConstructL() |
|
95 { |
|
96 __LOG( "[UpnpCommand]\t CUpnpMoveTask::ConstructL" ); |
|
97 } |
|
98 |
|
99 // -------------------------------------------------------------------------- |
|
100 // CUpnpMoveTask::AllocateResourcesL |
|
101 // Allocates the Upnp Fw resources. |
|
102 // -------------------------------------------------------------------------- |
|
103 // |
|
104 void CUpnpMoveTask::AllocateResourcesL() |
|
105 { |
|
106 __LOG( "[UpnpCommand]\t CUpnpMoveTask::AllocateResourcesL" ); |
|
107 |
|
108 AllocateFileTransferResourcesL( |
|
109 CUpnpTaskResourceAllocator::EResourceAvController | |
|
110 CUpnpTaskResourceAllocator::EResourceSelectMoveServer ); |
|
111 } |
|
112 |
|
113 // -------------------------------------------------------------------------- |
|
114 // CUpnpMoveTask::ExecuteL |
|
115 // Executes the task. |
|
116 // -------------------------------------------------------------------------- |
|
117 // |
|
118 void CUpnpMoveTask::ExecuteL() |
|
119 { |
|
120 __LOG( "[UpnpCommand]\t CUpnpMoveTask::ExecuteL" ); |
|
121 |
|
122 if( !ResourceAllocator() ) |
|
123 { |
|
124 __LOG( "[UpnpCommand]\t CUpnpCopyTask::ExecuteL \ |
|
125 resources not allocated, leave" ); |
|
126 User::Leave( KErrNotReady ); |
|
127 } |
|
128 |
|
129 TInt transferredFiles = 0; |
|
130 |
|
131 TRAPD( status, ExecuteFileTransferL |
|
132 ( ETrue, transferredFiles ) ); |
|
133 __LOG1( "[UpnpCommand]\t CUpnpMoveTask::ExecuteL done status %d", status ); |
|
134 |
|
135 // inform user |
|
136 if( status == KErrNone ) |
|
137 { |
|
138 HBufC* deviceString = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
139 ResourceAllocator()->SelectedDevice().FriendlyName() ); |
|
140 CleanupStack::PushL( deviceString ); |
|
141 NoteHandler()->ShowMoveInfoNoteL( |
|
142 transferredFiles, *deviceString ); |
|
143 CleanupStack::PopAndDestroy( deviceString ); |
|
144 } |
|
145 else if( status == KErrNotSupported ) |
|
146 { |
|
147 NoteHandler()->ShowDrmNoteL(); |
|
148 } |
|
149 else if( status == KErrDisconnected || status == KErrSessionClosed ) |
|
150 { |
|
151 // check from if wlan is active |
|
152 // note shown only in device disappeared cases |
|
153 if( IsWlanActive() ) |
|
154 { |
|
155 NoteHandler()->ShowMoveDisconnectionErrorNoteL(); |
|
156 } |
|
157 } |
|
158 else if( status != KErrCancel ) |
|
159 { |
|
160 // some other generic error EXCEPT cancel |
|
161 NoteHandler()->ShowMoveErrorNoteL(); |
|
162 } |
|
163 |
|
164 // If there was an error, leave |
|
165 if( status != KErrNone ) |
|
166 { |
|
167 User::Leave( status ); |
|
168 } |
|
169 } |
|
170 |
|
171 |
|
172 // End of File |