|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "deviceinfoparser.h" |
|
17 #include "upnpdescriptionschema.h" |
|
18 #include "deviceiconparser.h" |
|
19 #include "serviceinfoparser.h" |
|
20 _LIT8(KDlnaNameSpace,"urn:schemas-dlna-org:device-1-0"); |
|
21 |
|
22 CDeviceInfoParser* CDeviceInfoParser::NewL(CUPnPDevice *aDeviceInfo, const RStringPool& aStringPool) |
|
23 { |
|
24 CDeviceInfoParser* self = new (ELeave) CDeviceInfoParser(aDeviceInfo, aStringPool); |
|
25 return self; |
|
26 } |
|
27 |
|
28 CDeviceInfoParser::CDeviceInfoParser(CUPnPDevice *aDeviceInfo, const RStringPool& aStringPool) : iDeviceInfo(aDeviceInfo), iStringPool(aStringPool) |
|
29 { |
|
30 } |
|
31 |
|
32 CDeviceInfoParser::~CDeviceInfoParser() |
|
33 { |
|
34 } |
|
35 |
|
36 void CDeviceInfoParser::ParseStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes) |
|
37 { |
|
38 iSiblingsCount++; |
|
39 iString = iStringPool.OpenStringL(aElement.LocalName().DesC()); |
|
40 const TDesC8& info = iString.DesC(); |
|
41 TInt tblIndex = iString.Index ( UPNPDESCRIPTIONXMLTAGS::Table ); |
|
42 switch(tblIndex) |
|
43 { |
|
44 case UPNPDESCRIPTIONXMLTAGS::EDevice: |
|
45 { |
|
46 if(!(iFlags & EDevice)) |
|
47 { |
|
48 iFlags = iFlags | EDevice; |
|
49 } |
|
50 else if(iFlags & EEmbeddedDevice) |
|
51 { |
|
52 iSiblingsCount--; |
|
53 CUPnPDevice* deviceInfo = CUPnPDevice::NewL(); |
|
54 CleanupStack::PushL( deviceInfo ); |
|
55 iDeviceInfo->AppendToEmbeddedDeviceInfoTableL(deviceInfo); |
|
56 CleanupStack::Pop( deviceInfo ); |
|
57 CDeviceInfoParser* deviceParser = CDeviceInfoParser::NewL(deviceInfo, iStringPool); |
|
58 CleanupStack::PushL(deviceParser); |
|
59 StartChildParserL(deviceParser, aElement, aAttributes); |
|
60 CleanupStack::Pop( deviceParser ); |
|
61 } |
|
62 } |
|
63 break; |
|
64 case UPNPDESCRIPTIONXMLTAGS::EIcon: |
|
65 { |
|
66 iSiblingsCount--; |
|
67 CUPnPIconInfo *iconInfo = CUPnPIconInfo::NewL(); |
|
68 CleanupStack::PushL( iconInfo ); |
|
69 iDeviceInfo->AppendToIconInfoTableL(iconInfo); |
|
70 CleanupStack::Pop(); |
|
71 CDeviceIconParser* deviceIconParser = CDeviceIconParser::NewL(iconInfo, iStringPool); |
|
72 CleanupStack::PushL( deviceIconParser ); |
|
73 StartChildParserL(deviceIconParser, aElement, aAttributes); |
|
74 CleanupStack::Pop(deviceIconParser); |
|
75 } |
|
76 break; |
|
77 case UPNPDESCRIPTIONXMLTAGS::EService: |
|
78 { |
|
79 iSiblingsCount--; |
|
80 CUPnPServiceInfo *serviceInfo = CUPnPServiceInfo::NewL(); |
|
81 CleanupStack::PushL(serviceInfo); |
|
82 iDeviceInfo->AppendToServiceInfoTableL(serviceInfo); |
|
83 CleanupStack::Pop( serviceInfo ); |
|
84 CServiceInfoParser* serviceInfoParser = CServiceInfoParser::NewL(serviceInfo, iStringPool); |
|
85 CleanupStack::PushL(serviceInfoParser); |
|
86 StartChildParserL(serviceInfoParser, aElement, aAttributes); |
|
87 CleanupStack::Pop(serviceInfoParser); |
|
88 } |
|
89 break; |
|
90 |
|
91 // Default: Don't do anything |
|
92 } |
|
93 |
|
94 } |
|
95 |
|
96 |
|
97 void CDeviceInfoParser::ParseEndElementL(const RTagInfo& /*aElement*/) |
|
98 { |
|
99 iSiblingsCount--; |
|
100 iDeviceInfo->SetPropertyStatus(iString,ETrue); |
|
101 iString.Close(); |
|
102 } |
|
103 |
|
104 void CDeviceInfoParser::ParseContentL(const TDesC8& aBytes) |
|
105 { |
|
106 if ( !IsBlankSpace( aBytes ) ) |
|
107 iDeviceInfo->SetPropertyL(iString,aBytes); |
|
108 } |
|
109 |
|
110 void CDeviceInfoParser::ParsePrefixL(const RString& aPrefix, const RString& aUri) |
|
111 { |
|
112 _LIT8(KDlna,"dlna"); |
|
113 const TDesC8& prefix = aPrefix.DesC(); |
|
114 if ( prefix == KDlna ) |
|
115 { |
|
116 const TDesC8& uri = aUri.DesC(); |
|
117 if ( uri == KDlnaNameSpace) |
|
118 { |
|
119 iDeviceInfo->SetDlna( ETrue ); |
|
120 } |
|
121 else |
|
122 User::Leave(KErrCorrupt); |
|
123 } |
|
124 } |