|
1 /** @file |
|
2 * Copyright (c) 2005-2006 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "upnptransferhandler.h" |
|
21 #include "upnpcontentdirectory.h" |
|
22 #include "upnpfiletransfer.h" |
|
23 #include "upnptransferdownloader.h" |
|
24 #include "upnptransferuploader.h" |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CUpnpTransferHandler::CUpnpTransferHandler |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CUpnpTransferHandler::CUpnpTransferHandler( ) |
|
31 { |
|
32 |
|
33 } |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CUpnpTransferHandler::ConstructL |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 void CUpnpTransferHandler::ConstructL() |
|
39 { |
|
40 iDownloader = CUpnpTransferDownloader::NewL( this ); |
|
41 iUploader = CUpnpTransferUploader::NewL( this ); |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CUpnpTransferHandler::NewL |
|
46 // Two-phased constructor. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CUpnpTransferHandler* CUpnpTransferHandler::NewL( ) |
|
50 { |
|
51 CUpnpTransferHandler* self = |
|
52 new (ELeave) CUpnpTransferHandler( ); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CUpnpTransferHandler destructor |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CUpnpTransferHandler::~CUpnpTransferHandler() |
|
64 { |
|
65 delete iDownloader; |
|
66 delete iUploader; |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CUpnpTransferHandler::UploadFileL |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CUpnpTransferHandler::UploadFileL( TInt aKey, const TDesC8& aUri, const TDesC& aTargetPath, |
|
74 const TDesC8& aContentType ) |
|
75 { |
|
76 if( iUploader ) |
|
77 { |
|
78 iUploader->UploadFileL(aUri, aTargetPath, aContentType, aKey); |
|
79 TrackUploadProgress(aKey, ETrue); |
|
80 } |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CUpnpTransferHandler::DownloadFileL |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void CUpnpTransferHandler::DownloadFileL(TInt aKey, const TDesC8& aUri,const TDesC& aTargetPath) |
|
88 { |
|
89 if( iDownloader ) |
|
90 { |
|
91 iDownloader->DownloadFileL(aUri, aTargetPath, aKey); |
|
92 TrackDownloadProgress(aKey, ETrue); |
|
93 } |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CUpnpTransferHandler::CancelUpload |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 void CUpnpTransferHandler::CancelUpload( TInt aKey ) |
|
101 { |
|
102 if( iUploader ) |
|
103 { |
|
104 iUploader->CancelTransfer( aKey); |
|
105 } |
|
106 } |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CUpnpTransferHandler::CancelDownload |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CUpnpTransferHandler::CancelDownload( TInt aKey ) |
|
112 { |
|
113 if( iDownloader ) |
|
114 { |
|
115 iDownloader->CancelTransfer( aKey); |
|
116 } |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CUpnpTransferHandler::HandleUploadL |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 void CUpnpTransferHandler::TransferCompletedL( TInt aKey, TInt aResultCode ) |
|
124 { |
|
125 iObserver->TransferCompletedL( aKey, aResultCode ); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CUpnpTransferHandler::SetObserver |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CUpnpTransferHandler::SetObserver( MUpnpTransferObserver* aObserver ) |
|
133 { |
|
134 iObserver = aObserver; |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CUpnpTransferHandler::TrackUploadProgress |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 void CUpnpTransferHandler::TrackUploadProgress( TInt aKey, TBool aSwitchOn ) |
|
142 { |
|
143 if( iUploader) |
|
144 { |
|
145 iUploader->TrackProgess(aKey, aSwitchOn); |
|
146 } |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CUpnpTransferHandler::TrackDownloadProgress |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CUpnpTransferHandler::TrackDownloadProgress( TInt aKey, TBool aSwitchOn ) |
|
154 { |
|
155 if( iDownloader) |
|
156 { |
|
157 iDownloader->TrackProgess(aKey, aSwitchOn); |
|
158 } |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CUpnpTransferHandler::TransferProgress |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CUpnpTransferHandler::TransferProgress( TInt aKey, TInt aBytes, TInt aTotalBytes) |
|
166 { |
|
167 iObserver->TransferProgress(aKey, aBytes, aTotalBytes); |
|
168 } |
|
169 |
|
170 // End of File |