|
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 CUpnpActionContentHandler class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "upnpactioncontenthandler.h" |
|
20 #include "upnpcontenthandlerscontroller.h" |
|
21 #include "upnpignorecontenthandler.h" |
|
22 #include "upnpactionnamecontenthandler.h" |
|
23 #include "upnpargumentlistcontenthandler.h" |
|
24 #include "upnpaction.h" |
|
25 #include "upnpserviceliterals.h" |
|
26 |
|
27 enum TFlagsPositions |
|
28 { |
|
29 EName = 0, |
|
30 EArgumentList |
|
31 }; |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CUpnpActionContentHandler::NewL |
|
35 // Two-phased constructor |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CUpnpActionContentHandler* CUpnpActionContentHandler::NewL( |
|
39 CUpnpContentHandlersController& aController, CUpnpAction& aResultAction ) |
|
40 { |
|
41 CUpnpActionContentHandler* actionContentHandler = |
|
42 CUpnpActionContentHandler::NewLC( aController, aResultAction ); |
|
43 CleanupStack::Pop( actionContentHandler ); |
|
44 return actionContentHandler; |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CUpnpActionContentHandler::NewLC |
|
49 // Two-phased constructor. Leaves teh object on the CleanupStack |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CUpnpActionContentHandler* CUpnpActionContentHandler::NewLC( |
|
53 CUpnpContentHandlersController& aController, CUpnpAction& aResultAction ) |
|
54 { |
|
55 CUpnpActionContentHandler* actionContentHandler = |
|
56 new (ELeave) CUpnpActionContentHandler( aController, aResultAction ); |
|
57 CleanupStack::PushL( actionContentHandler ); |
|
58 return actionContentHandler; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CUpnpActionContentHandler::~CUpnpActionContentHandler |
|
63 // Destructor of CUpnpActionContentHandler class |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CUpnpActionContentHandler::~CUpnpActionContentHandler() |
|
67 { |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CUpnpActionContentHandler::CUpnpActionContentHandler |
|
72 // Constructor |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CUpnpActionContentHandler::CUpnpActionContentHandler( |
|
76 CUpnpContentHandlersController& aController, CUpnpAction& aResultAction ) : |
|
77 CUpnpContentHandler( aController ), iResultAction( aResultAction ) |
|
78 { |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CUpnpActionContentHandler::OnStartElementL |
|
83 // This method is a callback to indicate an element has been parsed. |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CUpnpActionContentHandler::OnStartElementL( const RTagInfo& aElement, |
|
87 const RAttributeArray& /*aAttributes*/ ) |
|
88 { |
|
89 const TDesC8& elementName( aElement.LocalName().DesC() ); |
|
90 if ( elementName.Compare( KUpnpArgumentList ) == 0 ) |
|
91 { |
|
92 RepeatedTagCheckL( EArgumentList, iFoundTags ); |
|
93 iController.SetCurrentContentHandlerL( |
|
94 CUpnpArgumentListContentHandler::NewL( |
|
95 iController, iResultAction.Service(), iResultAction ) ); |
|
96 } |
|
97 else |
|
98 if ( elementName.Compare( KUpnpName ) == 0 ) |
|
99 { |
|
100 RepeatedTagCheckL( EName, iFoundTags ); |
|
101 iController.SetCurrentContentHandlerL( |
|
102 CUpnpActionNameContentHandler::NewL( iController, iResultAction ) ); |
|
103 } |
|
104 else |
|
105 { |
|
106 iController.SetCurrentContentHandlerL( |
|
107 CUpnpIgnoreContentHandler::NewL( iController ) ); |
|
108 } |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CUpnpActionContentHandler::OnEndElementL |
|
113 // This method is a callback to indicate the end of the element has been reached. |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CUpnpActionContentHandler::OnEndElementL( const RTagInfo& aElement ) |
|
117 { |
|
118 ASSERT( aElement.LocalName().DesC().Compare( KUpnpAction ) == 0 ); |
|
119 if ( iFoundTags.IsClear( EName ) ) |
|
120 { |
|
121 User::Leave( KErrArgument ); //required |
|
122 } |
|
123 iController.SetPreviousContentHandler(); |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CUpnpActionContentHandler::OnContentL |
|
128 // This method is a callback that sends the content of the element. |
|
129 // aErrorCode must be KErrNone, and that aBytes should contains complete |
|
130 // content (one chunk). |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void CUpnpActionContentHandler::OnContentL( const TDesC8& /*aBytes*/ ) |
|
134 { |
|
135 //User::Leave( KErrArgument ) |
|
136 } |
|
137 |
|
138 // End of File |