|
1 /** @file |
|
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: Implements the CUpnpDeviceListContentHandler class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "upnpdevicelistcontenthandler.h" |
|
20 #include "upnpcontenthandlerscontroller.h" |
|
21 #include "upnpdevicetagcontenthandler.h" |
|
22 #include "upnpdevice.h" |
|
23 #include "upnpdeviceimplementation.h" |
|
24 #include "upnpsilentdeviceimplementation.h" |
|
25 #include "upnpdeviceliterals.h" |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CUpnpDeviceListContentHandler::NewL |
|
29 // Two-phased constructor |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CUpnpDeviceListContentHandler* CUpnpDeviceListContentHandler::NewL( |
|
33 CUpnpContentHandlersController& aController, CUpnpDevice& aResultDevice, |
|
34 TParseType aParseType ) |
|
35 { |
|
36 CUpnpDeviceListContentHandler* deviceListContentHandler = |
|
37 CUpnpDeviceListContentHandler::NewLC( aController, aResultDevice, |
|
38 aParseType ); |
|
39 CleanupStack::Pop( deviceListContentHandler ); |
|
40 return deviceListContentHandler; |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CUpnpDeviceListContentHandler::NewLC |
|
45 // Two-phased constructor. Leaves teh object on the CleanupStack |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CUpnpDeviceListContentHandler* CUpnpDeviceListContentHandler::NewLC( |
|
49 CUpnpContentHandlersController& aController, CUpnpDevice& aResultDevice, |
|
50 TParseType aParseType ) |
|
51 { |
|
52 CUpnpDeviceListContentHandler* deviceListContentHandler = |
|
53 new (ELeave) CUpnpDeviceListContentHandler( aController, aResultDevice, |
|
54 aParseType ); |
|
55 CleanupStack::PushL( deviceListContentHandler ); |
|
56 return deviceListContentHandler; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CUpnpDeviceListContentHandler::~CUpnpDeviceListContentHandler |
|
61 // Destructor of CUpnpDeviceListContentHandler class |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CUpnpDeviceListContentHandler::~CUpnpDeviceListContentHandler() |
|
65 { |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CUpnpDeviceListContentHandler::CUpnpDeviceListContentHandler |
|
70 // Constructor |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CUpnpDeviceListContentHandler::CUpnpDeviceListContentHandler( |
|
74 CUpnpContentHandlersController& aController, CUpnpDevice& aResultDevice, |
|
75 TParseType aParseType ) : |
|
76 CUpnpContentHandler( aController ), iResultDevice( aResultDevice ), |
|
77 iParseType( aParseType ) |
|
78 { |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CUpnpDeviceListContentHandler::OnStartElementL |
|
83 // This method is a callback to indicate an element has been parsed. |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CUpnpDeviceListContentHandler::OnStartElementL( |
|
87 const RTagInfo& aElement, const RAttributeArray& /*aAttributes*/) |
|
88 { |
|
89 if ( aElement.LocalName().DesC().Compare( KUpnpDevice ) == 0 ) |
|
90 { |
|
91 CUpnpDevice* device( NULL ); |
|
92 |
|
93 switch ( iParseType ) |
|
94 { |
|
95 case EDeviceImpl: |
|
96 device = new (ELeave) CUpnpDeviceImplementation(); |
|
97 break; |
|
98 case ESilentDeviceImpl: |
|
99 device = new (ELeave) CUpnpSilentDeviceImplementation(); |
|
100 break; |
|
101 case EDevice: |
|
102 device = new (ELeave) CUpnpDevice(); |
|
103 break; |
|
104 default: |
|
105 _LIT( KPanicString, "CUpnpDeviceListContentHandler::OnStartElementL" ); |
|
106 User::Panic( KPanicString, 1 ); |
|
107 } |
|
108 |
|
109 CleanupStack::PushL( device ); |
|
110 iResultDevice.AddDeviceL( device ); |
|
111 CleanupStack::Pop( device ); |
|
112 iController.SetCurrentContentHandlerL( CUpnpDeviceTagContentHandler::NewL( |
|
113 iController, *device, iParseType ) ); |
|
114 } |
|
115 else |
|
116 { |
|
117 SetIgnoreHandlerL(); |
|
118 } |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CUpnpDeviceListContentHandler::OnEndElementL |
|
123 // This method is a callback to indicate the end of the element has been reached. |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void CUpnpDeviceListContentHandler::OnEndElementL( const RTagInfo& aElement ) |
|
127 { |
|
128 ASSERT( aElement.LocalName().DesC().Compare(KUpnpDeviceList) == 0 ); |
|
129 iController.SetPreviousContentHandler(); |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CUpnpDeviceListContentHandler::OnContentL |
|
134 // This method is a callback that sends the content of the element. |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void CUpnpDeviceListContentHandler::OnContentL( const TDesC8& /*aBytes*/ ) |
|
138 { |
|
139 //User::Leave( KErrArgument ) |
|
140 } |
|
141 |
|
142 // End of File |