|
1 /* |
|
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: Source file for CUpnpCommandParameters class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 // upnpframework / command api |
|
21 #include "upnpcommandcallback.h" // MUpnpCommandCallback |
|
22 |
|
23 // command internal |
|
24 #include "upnpcommandparameters.h" |
|
25 |
|
26 _LIT( KComponentLogfile, "upnpcommand.log"); |
|
27 #include "upnplog.h" |
|
28 |
|
29 // -------------------------------------------------------------------------- |
|
30 // CUpnpCommandParameters::NewL |
|
31 // Creates an instance of the implementation. |
|
32 // -------------------------------------------------------------------------- |
|
33 // |
|
34 CUpnpCommandParameters* CUpnpCommandParameters::NewL() |
|
35 { |
|
36 __LOG( "[UpnpCommand]\t CUpnpCommandParameters::NewL" ); |
|
37 |
|
38 return new (ELeave) CUpnpCommandParameters; |
|
39 } |
|
40 |
|
41 // -------------------------------------------------------------------------- |
|
42 // CUpnpCommandParameters::CUpnpCommandParameters |
|
43 // First phase construction. |
|
44 // -------------------------------------------------------------------------- |
|
45 // |
|
46 CUpnpCommandParameters::CUpnpCommandParameters() |
|
47 { |
|
48 __LOG( "[UpnpCommand]\t CUpnpCommandParameters::Constructor" ); |
|
49 |
|
50 iCollectionName = NULL; |
|
51 iCallback = NULL; |
|
52 } |
|
53 |
|
54 // -------------------------------------------------------------------------- |
|
55 // Destructor. |
|
56 // -------------------------------------------------------------------------- |
|
57 // |
|
58 CUpnpCommandParameters::~CUpnpCommandParameters() |
|
59 { |
|
60 __LOG( "[UpnpCommand]\t CUpnpCommandParameters::Destructor" ); |
|
61 |
|
62 // Reset the parameters |
|
63 Reset(); |
|
64 } |
|
65 |
|
66 // -------------------------------------------------------------------------- |
|
67 // CUpnpCommandParameters::SetObserver |
|
68 // Sets the observer. |
|
69 // -------------------------------------------------------------------------- |
|
70 // |
|
71 void CUpnpCommandParameters::SetObserver( MUpnpCommandCallback* aCallback ) |
|
72 { |
|
73 __LOG( "[UpnpCommand]\t CUpnpCommandParameters::SetObserver" ); |
|
74 |
|
75 // Parameter check |
|
76 __ASSERTD( aCallback!=0, __FILE__, __LINE__ ); |
|
77 |
|
78 // Set the variable |
|
79 iCallback = aCallback; |
|
80 } |
|
81 |
|
82 // -------------------------------------------------------------------------- |
|
83 // CUpnpCommandParameters::Observer |
|
84 // Gets the observer. |
|
85 // -------------------------------------------------------------------------- |
|
86 // |
|
87 MUpnpCommandCallback* CUpnpCommandParameters::Observer() |
|
88 { |
|
89 return iCallback; |
|
90 } |
|
91 |
|
92 // -------------------------------------------------------------------------- |
|
93 // CUpnpCommandParameters::SetL |
|
94 // Sets a parameter |
|
95 // -------------------------------------------------------------------------- |
|
96 // |
|
97 void CUpnpCommandParameters::SetL( |
|
98 UpnpCommand::TUpnpParameterType aParamType, |
|
99 const TDesC& aParamValue ) |
|
100 { |
|
101 __LOG( "[UpnpCommand]\t CUpnpCommandParameters::SetL" ); |
|
102 |
|
103 switch( aParamType ) |
|
104 { |
|
105 case UpnpCommand::EParamCollectionName: |
|
106 { |
|
107 // Parameter check |
|
108 if( aParamValue == KNullDesC ) |
|
109 { |
|
110 User::Leave( KErrArgument ); |
|
111 } |
|
112 // allocation |
|
113 HBufC* newCollectionName = aParamValue.AllocL(); |
|
114 delete iCollectionName; |
|
115 iCollectionName = newCollectionName; |
|
116 newCollectionName = NULL; |
|
117 } |
|
118 break; |
|
119 case UpnpCommand::EParamMediaType: // flow through |
|
120 case UpnpCommand::EParamDeviceUuid: // flow through |
|
121 case UpnpCommand::EParamDeviceName: |
|
122 // do nothing |
|
123 break; |
|
124 default: |
|
125 __PANICD( __FILE__, __LINE__ ); |
|
126 } |
|
127 |
|
128 } |
|
129 |
|
130 // -------------------------------------------------------------------------- |
|
131 // CUpnpCommandParameters::Get |
|
132 // Returns a parameter by given type |
|
133 // -------------------------------------------------------------------------- |
|
134 // |
|
135 const TDesC& CUpnpCommandParameters::Get( |
|
136 UpnpCommand::TUpnpParameterType aParamType ) |
|
137 { |
|
138 __LOG( "[UpnpCommand]\t CUpnpCommandParameters::Get" ); |
|
139 |
|
140 switch( aParamType ) |
|
141 { |
|
142 case UpnpCommand::EParamCollectionName: |
|
143 { |
|
144 if( iCollectionName ) |
|
145 { |
|
146 return *iCollectionName; |
|
147 } |
|
148 } |
|
149 break; |
|
150 case UpnpCommand::EParamMediaType: // flow through |
|
151 case UpnpCommand::EParamDeviceUuid: // flow through |
|
152 case UpnpCommand::EParamDeviceName: |
|
153 return KNullDesC; |
|
154 default: |
|
155 __PANICD( __FILE__, __LINE__ ); |
|
156 } |
|
157 |
|
158 return KNullDesC; |
|
159 } |
|
160 |
|
161 // -------------------------------------------------------------------------- |
|
162 // CUpnpCommandParameters::Reset |
|
163 // Resets variables. |
|
164 // -------------------------------------------------------------------------- |
|
165 // |
|
166 void CUpnpCommandParameters::Reset() |
|
167 { |
|
168 __LOG( "[UpnpCommand]\t CUpnpCommandParameters::Reset" ); |
|
169 |
|
170 // Delete/reset the variables |
|
171 delete iCollectionName; |
|
172 iCollectionName = NULL; |
|
173 } |
|
174 |
|
175 // End of File |