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: Class provides function used by UPnPAccess plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32math.h> |
|
21 #include <RsfwDirEnt.h> |
|
22 #include <f32file.h> |
|
23 #include <rsfwdirentattr.h> |
|
24 #include <rsfwdirent.h> |
|
25 |
|
26 |
|
27 #include "upnpavcpenginecommon.h" |
|
28 #include "upnpavcpenginerfsclient.h" |
|
29 |
|
30 typedef TBuf8<KMaxFileName> TFileName8; |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // RUpnpAVCPEngineRFSClient::RUpnpAVCPEngineRFSClient |
|
34 // C++ default constructor can NOT contain any code, that |
|
35 // might leave. |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 EXPORT_C RUpnpAVCPEngineRFSClient::RUpnpAVCPEngineRFSClient() |
|
39 :RUpnpAVCPEngineClient() |
|
40 { |
|
41 } |
|
42 |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // RUpnpAVCPEngineRFSClient::GetDirectoryL |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 EXPORT_C TInt RUpnpAVCPEngineRFSClient::GetDirectoryL(const TDesC8& aUUID, const TDesC& aPathName, RPointerArray<CRsfwDirEnt>& aDirList) |
|
49 { |
|
50 TFileName8 pathname; |
|
51 pathname.Copy(aPathName); |
|
52 |
|
53 TInt id; |
|
54 TInt size; |
|
55 TPckg<TInt> idPckg(id); |
|
56 TPckg<TInt> sizePckg(size); |
|
57 TInt err = SendReceive(EPrepareDirList,TIpcArgs(&idPckg,&sizePckg, &aUUID, &pathname )) ; |
|
58 if (err != KErrNone) |
|
59 { |
|
60 return err; |
|
61 } |
|
62 |
|
63 if ( size > 0 ) |
|
64 { |
|
65 TFileInfo* dirs = new TFileInfo[size]; |
|
66 // put array on cleanup stack |
|
67 TPtr8 result(reinterpret_cast<TUint8*>(dirs), sizeof(TFileInfo)*size, sizeof(TFileInfo)*size); |
|
68 err = SendReceive(EDownloadDirList,TIpcArgs(id, &result)); |
|
69 |
|
70 for (TInt i = 0; i < size; i++) |
|
71 { |
|
72 CRsfwDirEnt* entry = GetFileInformationL(dirs[i]); |
|
73 aDirList.AppendL(entry); |
|
74 } |
|
75 delete[] dirs; |
|
76 } |
|
77 return err; |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // RUpnpAVCPEngineRFSClient::GetDirectoryAttributeL |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 EXPORT_C TInt RUpnpAVCPEngineRFSClient::GetDirectoryAttributeL(const TDesC8& aUUID, const TDesC& aPathName, CRsfwDirEntAttr*& aDirAtt) |
|
85 { |
|
86 if (aPathName.Compare(KNullDesC) == 0) |
|
87 { |
|
88 TFileInfo fi; |
|
89 fi.iAtt |= KEntryAttDir; |
|
90 aDirAtt = GetFileAttributesL(fi); |
|
91 return KErrNone; |
|
92 } |
|
93 |
|
94 TFileName8 pathname; |
|
95 pathname.Copy(aPathName); |
|
96 TFileInfo fileInfo; |
|
97 TPckg<TFileInfo> attrPckg(fileInfo); |
|
98 TInt err = SendReceive(EDirAttributes, TIpcArgs(&aUUID, &pathname, &attrPckg) ); |
|
99 //convert TFileInfo to CDirEntAttr |
|
100 if (err == KErrNone) |
|
101 aDirAtt = GetFileAttributesL(fileInfo); |
|
102 |
|
103 return err; |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // RUpnpAVCPEngineRFSClient::GetFileAttributeL |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 EXPORT_C TInt RUpnpAVCPEngineRFSClient::GetFileAttributeL(const TDesC8& aUUID, const TDesC& aPathName, CRsfwDirEntAttr*& aFileAtt) |
|
111 { |
|
112 TFileName8 pathname; |
|
113 pathname.Copy(aPathName); |
|
114 |
|
115 TFileInfo fileInfo; |
|
116 TPckg<TFileInfo> attrPckg(fileInfo); |
|
117 TInt err = SendReceive(EFileAttributes, TIpcArgs(&aUUID, &pathname, &attrPckg) ) ; |
|
118 //convert TFileInfo to CDirEntAttr |
|
119 if (err == KErrNone) |
|
120 aFileAtt = GetFileAttributesL(fileInfo); |
|
121 |
|
122 return err; |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // RUpnpAVCPEngineRFSClient::GetFileL |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 EXPORT_C TInt RUpnpAVCPEngineRFSClient::GetFileL(const TDesC8& aUUID, const TDesC& aSrcPathName, const TDesC& aDstPathName, |
|
130 TInt aStart, TInt aLength, TUint aFlags, TInt& aRead) |
|
131 { |
|
132 TFileName8 srcpathname; |
|
133 srcpathname.Copy(aSrcPathName); |
|
134 |
|
135 TFilePosition position; |
|
136 position.iStart = aStart; |
|
137 position.iLength = aLength; |
|
138 position.iFlags = aFlags; |
|
139 |
|
140 TPckg<TFilePosition> posPckg(position); |
|
141 |
|
142 TInt err = SendReceive(EGetFile, TIpcArgs(&aUUID, &srcpathname, &aDstPathName, &posPckg) ) ; |
|
143 aRead = position.iLength; |
|
144 return err; |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // RUpnpAVCPEngineRFSClient::DeleteFileL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 EXPORT_C TInt RUpnpAVCPEngineRFSClient::DeleteFileL(const TDesC8& aUUID, const TDesC& aPathName) |
|
152 { |
|
153 TFileName8 pathname; |
|
154 pathname.Copy(aPathName); |
|
155 TInt err = SendReceive(EDeleteFile, TIpcArgs(&aUUID, &pathname) ); |
|
156 return err; |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // RUpnpAVCPEngineRFSClient::DeleteDirectoryL |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 EXPORT_C TInt RUpnpAVCPEngineRFSClient::DeleteDirectoryL(const TDesC8& aUUID, const TDesC& aPathName) |
|
164 { |
|
165 TFileName8 pathname; |
|
166 pathname.Copy(aPathName); |
|
167 TInt err = SendReceive(EDeleteDirectory, TIpcArgs(&aUUID, &pathname) ); |
|
168 return err; |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // RUpnpAVCPEngineRFSClient::CreateFileL |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 EXPORT_C TInt RUpnpAVCPEngineRFSClient::CreateFileL(const TDesC8& aUUID, const TDesC& aPathName) |
|
176 { |
|
177 TFileName8 pathname; |
|
178 pathname.Copy(aPathName); |
|
179 TInt err = SendReceive(ECreateFile, TIpcArgs(&aUUID, &pathname) ); |
|
180 return err; |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // RUpnpAVCPEngineRFSClient::MakeDirectoryL |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 EXPORT_C TInt RUpnpAVCPEngineRFSClient::MakeDirectoryL(const TDesC8& aUUID, const TDesC& aPathName) |
|
188 { |
|
189 TFileName8 pathname; |
|
190 pathname.Copy(aPathName); |
|
191 TInt err = SendReceive(ECreateDirectory, TIpcArgs(&aUUID, &pathname) ); |
|
192 return err; |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // RUpnpAVCPEngineRFSClient::PutFileL |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 EXPORT_C TInt RUpnpAVCPEngineRFSClient::PutFileL(const TDesC8& aUUID, const TDesC& aSrcPathName, const TDesC& aDstPathName) |
|
200 { |
|
201 TFileName8 dstpathname; |
|
202 dstpathname.Copy(aDstPathName); |
|
203 TInt err = SendReceive(EPutFile, TIpcArgs(&aUUID, &aSrcPathName, &dstpathname) ); |
|
204 return err; |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // RUpnpAVCPEngineRFSClient::GetAttributes |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 CRsfwDirEntAttr* RUpnpAVCPEngineRFSClient::GetFileAttributesL(TFileInfo& aFileInfo) |
|
212 { |
|
213 CRsfwDirEntAttr* result = CRsfwDirEntAttr::NewLC(); |
|
214 |
|
215 result->SetMimeTypeL(aFileInfo.iMimeType); |
|
216 result->SetModified(aFileInfo.iModified); |
|
217 result->SetAtt(aFileInfo.iAtt); |
|
218 result->SetSize(aFileInfo.iSize); |
|
219 CleanupStack::Pop(result); |
|
220 return result; |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // RUpnpAVCPEngineRFSClient::GetFileInformation |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 CRsfwDirEnt* RUpnpAVCPEngineRFSClient::GetFileInformationL(TFileInfo& aFileInfo) |
|
228 { |
|
229 return CRsfwDirEnt::NewL(aFileInfo.iName, GetFileAttributesL(aFileInfo)); |
|
230 } |
|
231 // End of File |
|