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: CUpnpTmInfoElement class implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// Include Files
|
|
19 |
#include "upnptminfoelement.h"
|
|
20 |
#include "OstTraceDefinitions.h"
|
|
21 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
22 |
#include "upnptminfoelementTraces.h"
|
|
23 |
#endif
|
|
24 |
|
|
25 |
// ============================ MEMBER FUNCTIONS ===================================
|
|
26 |
|
|
27 |
// ---------------------------------------------------------------------------------
|
|
28 |
// CUpnpTmInfoElement::NewL
|
|
29 |
// Two-phased constructor.
|
|
30 |
// ---------------------------------------------------------------------------------
|
|
31 |
//
|
|
32 |
CUpnpTmInfoElement* CUpnpTmInfoElement::NewL( TTerminalModeInfoType aTerminalModeInfoType )
|
|
33 |
{
|
|
34 |
OstTraceFunctionEntry0( CUPNPTMINFOELEMENT_NEWL_ENTRY );
|
|
35 |
CUpnpTmInfoElement* self = new (ELeave) CUpnpTmInfoElement();
|
|
36 |
CleanupStack::PushL(self);
|
|
37 |
self->ConstructL( aTerminalModeInfoType );
|
|
38 |
CleanupStack::Pop(self);
|
|
39 |
OstTraceFunctionExit0( CUPNPTMINFOELEMENT_NEWL_EXIT );
|
|
40 |
return self;
|
|
41 |
}
|
|
42 |
|
|
43 |
// ---------------------------------------------------------------------------------
|
|
44 |
// CUpnpTmInfoElement::CUpnpTmInfoElement
|
|
45 |
// C++ default constructor can NOT contain any code, that
|
|
46 |
// might leave.
|
|
47 |
// ---------------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
CUpnpTmInfoElement::CUpnpTmInfoElement( )
|
|
50 |
{
|
|
51 |
|
|
52 |
}
|
|
53 |
|
|
54 |
// ---------------------------------------------------------------------------------
|
|
55 |
// CUpnpTmInfoElement::ConstructL
|
|
56 |
// Symbian 2nd phase constructor can leave.
|
|
57 |
// @param aTerminalModeInfoType Type of info element. Enum value.
|
|
58 |
// @see TTerminalModeInfoType enumeration
|
|
59 |
// ---------------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
void CUpnpTmInfoElement::ConstructL( TTerminalModeInfoType aTerminalModeInfoType )
|
|
62 |
{
|
|
63 |
OstTraceFunctionEntry0( CUPNPTMINFOELEMENT_CONSTRUCTL_ENTRY );
|
|
64 |
switch( aTerminalModeInfoType )
|
|
65 |
{
|
|
66 |
case ERemotingInfo:
|
|
67 |
{
|
|
68 |
iInfoTypeBuffer = KRemotingInfo().AllocL();
|
|
69 |
}
|
|
70 |
break;
|
|
71 |
case EAppInfo:
|
|
72 |
{
|
|
73 |
iInfoTypeBuffer = KAppInfo().AllocL();
|
|
74 |
}
|
|
75 |
break;
|
|
76 |
case EDisplayInfo:
|
|
77 |
{
|
|
78 |
iInfoTypeBuffer = KDisplayInfo().AllocL();
|
|
79 |
}
|
|
80 |
break;
|
|
81 |
case EAudioInfo:
|
|
82 |
{
|
|
83 |
iInfoTypeBuffer = KAudioInfo().AllocL();
|
|
84 |
}
|
|
85 |
break;
|
|
86 |
default:
|
|
87 |
{
|
|
88 |
// Undefined. Should not come here at all.
|
|
89 |
User::Leave(KErrArgument);
|
|
90 |
}
|
|
91 |
break;
|
|
92 |
}
|
|
93 |
OstTraceFunctionExit0( CUPNPTMINFOELEMENT_CONSTRUCTL_EXIT );
|
|
94 |
}
|
|
95 |
|
|
96 |
// ------------------------------------------------------------------------------------------
|
|
97 |
// CUpnpTmInfoElement::~CUpnpTmInfoElement
|
|
98 |
// Destructor
|
|
99 |
// ------------------------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
CUpnpTmInfoElement::~CUpnpTmInfoElement()
|
|
102 |
{
|
|
103 |
OstTraceFunctionEntry0( CUPNPTMINFOELEMENT_CUPNPTMINFOELEMENT_ENTRY );
|
|
104 |
// Cleans up the arrays
|
|
105 |
for ( TInt i(0); i < iInfoElementNameArray.Count(); i++ )
|
|
106 |
{
|
|
107 |
iInfoElementNameArray[i].Close();
|
|
108 |
}
|
|
109 |
for ( TInt i(0); i < iInfoElementValueArray.Count(); i++ )
|
|
110 |
{
|
|
111 |
iInfoElementValueArray[i].Close();
|
|
112 |
}
|
|
113 |
iInfoElementNameArray.Close();
|
|
114 |
iInfoElementValueArray.Close();
|
|
115 |
delete iInfoTypeBuffer;
|
|
116 |
OstTraceFunctionExit0( CUPNPTMINFOELEMENT_CUPNPTMINFOELEMENT_EXIT );
|
|
117 |
}
|
|
118 |
|
|
119 |
// ---------------------------------------------------------------------------------
|
|
120 |
// CUpnpTmInfoElement::AddTmInfoElementL
|
|
121 |
// Method is used to add key-value pair
|
|
122 |
// @param aName Name of the key
|
|
123 |
// @param aValue value for the key
|
|
124 |
// ---------------------------------------------------------------------------------
|
|
125 |
//
|
|
126 |
EXPORT_C void CUpnpTmInfoElement::AddTmInfoElementL( const TDesC8& aName,
|
|
127 |
const TDesC8& aValue )
|
|
128 |
{
|
|
129 |
OstTraceFunctionEntry0( CUPNPTMINFOELEMENT_ADDTMINFOELEMENTL_ENTRY );
|
|
130 |
iElementName.CreateL(aName);
|
|
131 |
iElementValue.CreateL(aValue);
|
|
132 |
iInfoElementNameArray.AppendL(iElementName);
|
|
133 |
iInfoElementValueArray.AppendL(iElementValue);
|
|
134 |
OstTraceFunctionExit0( CUPNPTMINFOELEMENT_ADDTMINFOELEMENTL_EXIT );
|
|
135 |
}
|
|
136 |
|
|
137 |
// ---------------------------------------------------------------------------------
|
|
138 |
// CUpnpTmInfoElement::GetTmInfoElement
|
|
139 |
// Method is used to fetch the key-value pair for the index provided in the input.
|
|
140 |
// @param aInfoElementName[out] Name of the key
|
|
141 |
// @param aInfoElementValue[out] Value for the key
|
|
142 |
// @param aIndex Index of the array for which key-value pair is needed
|
|
143 |
// ---------------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
void CUpnpTmInfoElement::GetTmInfoElementL( RBuf8& aInfoElementName,
|
|
146 |
RBuf8& aInfoElementValue, TInt aIndex )const
|
|
147 |
{
|
|
148 |
OstTraceFunctionEntry0( CUPNPTMINFOELEMENT_GETTMINFOELEMENTLIST_ENTRY );
|
|
149 |
OstTrace1( TRACE_NORMAL, CUPNPTMINFOELEMENT_GETTMINFOELEMENTL, "CUpnpTmInfoElement::GetTmInfoElementL;aIndex=%d", aIndex );
|
|
150 |
if ( ( aIndex < KErrNone ) || ( aIndex >= iInfoElementNameArray.Count()) )
|
|
151 |
{
|
|
152 |
// Leaves in case of invalid array index
|
|
153 |
User::Leave(KErrArgument);
|
|
154 |
}
|
|
155 |
aInfoElementName.Close();
|
|
156 |
aInfoElementName.CreateL(iInfoElementNameArray[aIndex]);
|
|
157 |
aInfoElementValue.Close();
|
|
158 |
aInfoElementValue.CreateL(iInfoElementValueArray[aIndex]);
|
|
159 |
OstTraceFunctionExit0( CUPNPTMINFOELEMENT_GETTMINFOELEMENTLIST_EXIT );
|
|
160 |
}
|
|
161 |
|