34
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-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: Builder class for XML UI node identifiers.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System includes
|
|
19 |
|
|
20 |
// User includes
|
|
21 |
#include <hscontentpublisher.h>
|
|
22 |
#include <hspublisherinfo.h>
|
|
23 |
#include "aicontentmodel.h"
|
|
24 |
#include "aixmluiutils.h"
|
|
25 |
#include "aixmluiconstants.h"
|
|
26 |
#include "aistrcnv.h"
|
|
27 |
|
|
28 |
#include "xmlnodeidgenerator.h"
|
|
29 |
|
|
30 |
using namespace AiXmlUiController;
|
|
31 |
|
|
32 |
// ----------------------------------------------------------------------------
|
|
33 |
// CXmlNodeIdGenerator::CXmlNodeIdGenerator
|
|
34 |
//
|
|
35 |
// ----------------------------------------------------------------------------
|
|
36 |
//
|
|
37 |
CXmlNodeIdGenerator::CXmlNodeIdGenerator()
|
|
38 |
{
|
|
39 |
}
|
|
40 |
|
|
41 |
// ----------------------------------------------------------------------------
|
|
42 |
// CXmlNodeIdGenerator::NewL
|
|
43 |
//
|
|
44 |
// ----------------------------------------------------------------------------
|
|
45 |
//
|
|
46 |
CXmlNodeIdGenerator* CXmlNodeIdGenerator::NewL()
|
|
47 |
{
|
|
48 |
return new ( ELeave ) CXmlNodeIdGenerator;
|
|
49 |
}
|
|
50 |
|
|
51 |
// ----------------------------------------------------------------------------
|
|
52 |
// CXmlNodeIdGenerator::CXmlNodeIdGenerator
|
|
53 |
//
|
|
54 |
// ----------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CXmlNodeIdGenerator::~CXmlNodeIdGenerator()
|
|
57 |
{
|
|
58 |
delete iContentNodeIdBuf;
|
|
59 |
}
|
|
60 |
|
|
61 |
// ----------------------------------------------------------------------------
|
|
62 |
// CXmlNodeIdGenerator::SettingsNodeIdL
|
|
63 |
//
|
|
64 |
// ----------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
TPtrC CXmlNodeIdGenerator::SettingsNodeIdL(
|
|
67 |
const THsPublisherInfo& aPublisherInfo )
|
|
68 |
{
|
|
69 |
const TInt idLength( aPublisherInfo.Name().Length() +
|
|
70 |
AiUiDef::xml::id::KSettingsIdSeparator().Length() +
|
|
71 |
AiUiDef::xml::propertyClass::KSettings().Length() );
|
|
72 |
|
|
73 |
TPtr bufPtr(
|
|
74 |
AiUtility::EnsureBufMaxLengthL( iContentNodeIdBuf, idLength ) );
|
|
75 |
|
|
76 |
bufPtr.Copy( AiUiDef::xml::propertyClass::KSettings );
|
|
77 |
bufPtr.Append( AiUiDef::xml::id::KSettingsIdSeparator );
|
|
78 |
bufPtr.Append( aPublisherInfo.Name() );
|
|
79 |
|
|
80 |
return bufPtr;
|
|
81 |
}
|
|
82 |
|
|
83 |
// ----------------------------------------------------------------------------
|
|
84 |
// CXmlNodeIdGenerator::CXmlNodeIdGenerator
|
|
85 |
//
|
|
86 |
// ----------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
TPtrC CXmlNodeIdGenerator::ContentNodeIdL( CHsContentPublisher& aPlugin,
|
|
89 |
const TAiContentItem& aContentItem )
|
|
90 |
{
|
|
91 |
const THsPublisherInfo& info( aPlugin.PublisherInfo() );
|
|
92 |
|
|
93 |
return ContentNodeIdL( info, aContentItem );
|
|
94 |
}
|
|
95 |
|
|
96 |
// ----------------------------------------------------------------------------
|
|
97 |
// CXmlNodeIdGenerator::CXmlNodeIdGenerator
|
|
98 |
//
|
|
99 |
// ----------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
TPtrC CXmlNodeIdGenerator::ContentNodeIdL(
|
|
102 |
const THsPublisherInfo& aPublisherInfo,
|
|
103 |
const TAiContentItem& aContentItem )
|
|
104 |
{
|
|
105 |
const TDesC& contentCid( ContentCid( aContentItem ) );
|
|
106 |
|
|
107 |
// Calculate buffer size and ensure buffer has enough room
|
|
108 |
const TInt idLength( aPublisherInfo.Name().Length() +
|
|
109 |
AiUiDef::xml::id::KContentIdSeparator().Length() + contentCid.Length() );
|
|
110 |
|
|
111 |
TPtr bufPtr(
|
|
112 |
AiUtility::EnsureBufMaxLengthL( iContentNodeIdBuf, idLength ) );
|
|
113 |
|
|
114 |
// Copy publisher info name to the buffer
|
|
115 |
bufPtr.Copy( aPublisherInfo.Name() );
|
|
116 |
|
|
117 |
// Append separator
|
|
118 |
bufPtr.Append( AiUiDef::xml::id::KContentIdSeparator );
|
|
119 |
|
|
120 |
// Append content item id
|
|
121 |
bufPtr.Append( contentCid );
|
|
122 |
|
|
123 |
return bufPtr;
|
|
124 |
}
|
|
125 |
|
|
126 |
// ----------------------------------------------------------------------------
|
|
127 |
// CXmlNodeIdGenerator::CXmlNodeIdGenerator
|
|
128 |
//
|
|
129 |
// ----------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
TPtrC CXmlNodeIdGenerator::ResourceNodeIdL(
|
|
132 |
CHsContentPublisher& aPlugin, const TAiContentItem& aContentItem )
|
|
133 |
{
|
|
134 |
const THsPublisherInfo& info( aPlugin.PublisherInfo() );
|
|
135 |
|
|
136 |
return ResourceNodeIdL( info, aContentItem );
|
|
137 |
}
|
|
138 |
|
|
139 |
// ----------------------------------------------------------------------------
|
|
140 |
// CXmlNodeIdGenerator::CXmlNodeIdGenerator
|
|
141 |
//
|
|
142 |
// ----------------------------------------------------------------------------
|
|
143 |
//
|
|
144 |
TPtrC CXmlNodeIdGenerator::ResourceNodeIdL(
|
|
145 |
const THsPublisherInfo& aPublisherInfo,
|
|
146 |
const TAiContentItem& aContentItem )
|
|
147 |
{
|
|
148 |
// Resources node id is similar to content node id
|
|
149 |
return ContentNodeIdL( aPublisherInfo, aContentItem );
|
|
150 |
}
|
|
151 |
|
|
152 |
// End of file
|