24
|
1 |
/**
|
|
2 |
* Copyright (c) 2010 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: CUpnpTmServerDescriptionProvider class implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "upnptmserverdescriptionprovider.h"
|
|
19 |
#include <utf.h>
|
|
20 |
#include "OstTraceDefinitions.h"
|
|
21 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
22 |
#include "upnptmserverdescriptionproviderTraces.h"
|
|
23 |
#endif
|
|
24 |
|
|
25 |
|
|
26 |
_LIT(KPublic, "public\\");
|
|
27 |
_LIT(KIconPath, "icon");
|
|
28 |
|
|
29 |
// ---------------------------------------------------------------------------------
|
|
30 |
// CUpnpTmServerDescriptionProvider::NewL
|
|
31 |
//
|
|
32 |
// ---------------------------------------------------------------------------------
|
|
33 |
//
|
|
34 |
CUpnpTmServerDescriptionProvider* CUpnpTmServerDescriptionProvider::NewL()
|
|
35 |
{
|
|
36 |
OstTraceFunctionEntry0( CUPNPTMSERVERDESCRIPTIONPROVIDER_NEWL_ENTRY );
|
|
37 |
CUpnpTmServerDescriptionProvider* self = new (ELeave) CUpnpTmServerDescriptionProvider();
|
|
38 |
CleanupStack::PushL(self);
|
|
39 |
self->ConstructL();
|
|
40 |
CleanupStack::Pop(self);
|
|
41 |
OstTraceFunctionExit0( CUPNPTMSERVERDESCRIPTIONPROVIDER_NEWL_EXIT );
|
|
42 |
return self;
|
|
43 |
}
|
|
44 |
|
|
45 |
// ---------------------------------------------------------------------------------
|
|
46 |
// CUpnpTmServerDescriptionProvider::CUpnpTmServerDescriptionProvider
|
|
47 |
//
|
|
48 |
// ---------------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
CUpnpTmServerDescriptionProvider::CUpnpTmServerDescriptionProvider()
|
|
51 |
{
|
|
52 |
// No implementation required
|
|
53 |
}
|
|
54 |
|
|
55 |
// ---------------------------------------------------------------------------------
|
|
56 |
// CUpnpTmServerDescriptionProvider::~CUpnpTmServerDescriptionProvider
|
|
57 |
//
|
|
58 |
// ---------------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CUpnpTmServerDescriptionProvider::~CUpnpTmServerDescriptionProvider()
|
|
61 |
{
|
|
62 |
OstTraceFunctionEntry0( CUPNPTMSERVERDESCRIPTIONPROVIDER_CUPNPTMSERVERDESCRIPTIONPROVIDER_ENTRY );
|
|
63 |
iFs.Close();
|
|
64 |
OstTraceFunctionExit0( CUPNPTMSERVERDESCRIPTIONPROVIDER_CUPNPTMSERVERDESCRIPTIONPROVIDER_EXIT );
|
|
65 |
}
|
|
66 |
|
|
67 |
// ---------------------------------------------------------------------------------
|
|
68 |
// CUpnpTmServerDescriptionProvider::ConstructL
|
|
69 |
//
|
|
70 |
// ---------------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
void CUpnpTmServerDescriptionProvider::ConstructL()
|
|
73 |
{
|
|
74 |
OstTraceFunctionEntry0( CUPNPTMSERVERDESCRIPTIONPROVIDER_CONSTRUCTL_ENTRY );
|
|
75 |
User::LeaveIfError( iFs.Connect() );
|
|
76 |
OstTraceFunctionExit0( CUPNPTMSERVERDESCRIPTIONPROVIDER_CONSTRUCTL_EXIT );
|
|
77 |
}
|
|
78 |
|
|
79 |
|
|
80 |
// ---------------------------------------------------------------------------------
|
|
81 |
// CUpnpTmServerDescriptionProvider::OnDeviceDescription
|
|
82 |
//
|
|
83 |
// ---------------------------------------------------------------------------------
|
|
84 |
//
|
|
85 |
TInt CUpnpTmServerDescriptionProvider::OnDeviceDescription(
|
|
86 |
CUpnpDeviceDescriptionRequest& aRequest )
|
|
87 |
{
|
|
88 |
OstTraceFunctionEntry0( CUPNPTMSERVERDESCRIPTIONPROVIDER_ONDEVICEDESCRIPTION_ENTRY );
|
|
89 |
return OnRequest( aRequest );
|
|
90 |
}
|
|
91 |
|
|
92 |
// ---------------------------------------------------------------------------------
|
|
93 |
// CUpnpTmServerDescriptionProvider::OnServiceDescription
|
|
94 |
//
|
|
95 |
// ---------------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
TInt CUpnpTmServerDescriptionProvider::OnServiceDescription(
|
|
98 |
CUpnpDeviceDescriptionRequest& aRequest )
|
|
99 |
{
|
|
100 |
OstTraceFunctionEntry0( CUPNPTMSERVERDESCRIPTIONPROVIDER_ONSERVICEDESCRIPTION_ENTRY );
|
|
101 |
return OnRequest( aRequest );
|
|
102 |
}
|
|
103 |
|
|
104 |
// ---------------------------------------------------------------------------------
|
|
105 |
// CUpnpTmServerDescriptionProvider::OnIcon
|
|
106 |
//
|
|
107 |
// ---------------------------------------------------------------------------------
|
|
108 |
//
|
|
109 |
TInt CUpnpTmServerDescriptionProvider::OnIcon( CUpnpDeviceDescriptionRequest& aRequest )
|
|
110 |
{
|
|
111 |
OstTraceFunctionEntry0( CUPNPTMSERVERDESCRIPTIONPROVIDER_ONICON_ENTRY );
|
|
112 |
return OnRequest( aRequest );
|
|
113 |
}
|
|
114 |
|
|
115 |
// ---------------------------------------------------------------------------------
|
|
116 |
// CUpnpTmServerDescriptionProvider::GetFile
|
|
117 |
//
|
|
118 |
// ---------------------------------------------------------------------------------
|
|
119 |
//
|
|
120 |
TInt CUpnpTmServerDescriptionProvider::GetFile( const TDesC8& /*aUri*/, RFile& aFile )
|
|
121 |
{
|
|
122 |
OstTraceFunctionEntry0( CUPNPTMSERVERDESCRIPTIONPROVIDER_GETFILE_ENTRY );
|
|
123 |
return ( aFile.Open( iFs, iFilePath, EFileShareReadersOnly | EFileRead ));
|
|
124 |
}
|
|
125 |
|
|
126 |
// ---------------------------------------------------------------------------------
|
|
127 |
// CUpnpTmServerDescriptionProvider::OnRequest
|
|
128 |
//
|
|
129 |
// ---------------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
TInt CUpnpTmServerDescriptionProvider::OnRequest( CUpnpDeviceDescriptionRequest& aRequest )
|
|
132 |
{
|
|
133 |
OstTraceFunctionEntry0( CUPNPTMSERVERDESCRIPTIONPROVIDER_ONREQUEST_ENTRY );
|
|
134 |
TPtrC8 fileName;
|
|
135 |
TInt error(KErrNone);
|
|
136 |
TPtrC8 urlPath = UpnpFileUtil::ExtractUrlPath( aRequest.Uri(), fileName, error );
|
|
137 |
if( error == KErrNone)
|
|
138 |
{
|
|
139 |
TRAP( error, OnRequestL( urlPath,fileName ) );
|
|
140 |
}
|
|
141 |
OstTraceFunctionExit0( CUPNPTMSERVERDESCRIPTIONPROVIDER_ONREQUEST_EXIT );
|
|
142 |
return error;
|
|
143 |
}
|
|
144 |
|
|
145 |
// ---------------------------------------------------------------------------------
|
|
146 |
// CUpnpTmServerDescriptionProvider::OnRequestL
|
|
147 |
// @param aUrlPath URL
|
|
148 |
// @param aFileName FileName
|
|
149 |
// ---------------------------------------------------------------------------------
|
|
150 |
//
|
|
151 |
void CUpnpTmServerDescriptionProvider::OnRequestL( const TDesC8& aUrlPath,
|
|
152 |
const TDesC8& aFileName )
|
|
153 |
{
|
|
154 |
OstTraceFunctionEntry0( CUPNPTMSERVERDESCRIPTIONPROVIDER_ONREQUESTL_ENTRY );
|
|
155 |
// 8-bit to 16-bit conversion of URL path and file path
|
|
156 |
TBuf<UpnpString::KMaxFilenameLength> urlPath;
|
|
157 |
urlPath.Copy(aUrlPath);
|
|
158 |
TBuf<UpnpString::KMaxFilenameLength> fileName;
|
|
159 |
fileName.Copy(aFileName);
|
|
160 |
|
|
161 |
// Fetches the private directory
|
|
162 |
User::LeaveIfError( iFs.PrivatePath( iFilePath ) );
|
|
163 |
iFilePath.Append(KPublic());
|
|
164 |
/**
|
|
165 |
* Appends the filename to the file path.
|
|
166 |
* 1. In case of icon file, it first appends icon directory and then appends the filename.
|
|
167 |
* 2. In case of device and service xml files, it merely appends filename to the file path.
|
|
168 |
*/
|
|
169 |
if ( urlPath.Find(KIconPath()) != KErrNotFound )
|
|
170 |
{
|
|
171 |
// The request is for icon file
|
|
172 |
iFilePath.Append(urlPath.Left(urlPath.Locate(KForwardSlash)));
|
|
173 |
iFilePath.Append(UpnpString::KDoubleBackSlash16());
|
|
174 |
iFilePath.Append(KIconPath());
|
|
175 |
}
|
|
176 |
else
|
|
177 |
{
|
|
178 |
iFilePath.Append(urlPath);
|
|
179 |
}
|
|
180 |
iFilePath.Append(UpnpString::KDoubleBackSlash16());
|
|
181 |
// Appends filename to the file path.
|
|
182 |
iFilePath.Append(fileName);
|
|
183 |
OstTraceFunctionExit0( CUPNPTMSERVERDESCRIPTIONPROVIDER_ONREQUESTL_EXIT );
|
|
184 |
}
|
|
185 |
|