|
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 |
|
19 #include "xmlnodeidgenerator.h" |
|
20 #include "aipropertyextension.h" |
|
21 #include "aicontentmodel.h" |
|
22 #include "aixmluiutils.h" |
|
23 #include "aixmluiconstants.h" |
|
24 #include "aistrcnv.h" |
|
25 |
|
26 using namespace AiXmlUiController; |
|
27 |
|
28 CXmlNodeIdGenerator::CXmlNodeIdGenerator() |
|
29 { |
|
30 } |
|
31 |
|
32 CXmlNodeIdGenerator* CXmlNodeIdGenerator::NewL() |
|
33 { |
|
34 return new(ELeave) CXmlNodeIdGenerator; |
|
35 } |
|
36 |
|
37 CXmlNodeIdGenerator::~CXmlNodeIdGenerator() |
|
38 { |
|
39 delete iContentNodeIdBuf; |
|
40 } |
|
41 |
|
42 TPtrC CXmlNodeIdGenerator::SettingsNodeIdL( const TAiPublisherInfo& aPubInfo ) |
|
43 { |
|
44 const TInt idLength = aPubInfo.iName.Length() |
|
45 + AiUiDef::xml::id::KSettingsIdSeparator().Length() |
|
46 + AiUiDef::xml::propertyClass::KSettings().Length(); |
|
47 TPtr bufPtr( AiUtility::EnsureBufMaxLengthL( iContentNodeIdBuf, idLength ) ); |
|
48 |
|
49 bufPtr.Copy( AiUiDef::xml::propertyClass::KSettings ); |
|
50 bufPtr.Append( AiUiDef::xml::id::KSettingsIdSeparator ); |
|
51 bufPtr.Append( aPubInfo.iName ); |
|
52 |
|
53 return bufPtr; |
|
54 } |
|
55 |
|
56 TPtrC CXmlNodeIdGenerator::ContentNodeIdL(MAiPropertyExtension& aPlugin, const TAiContentItem& aContentItem) |
|
57 { |
|
58 TAiPublisherInfo* info = static_cast<TAiPublisherInfo*>( aPlugin.GetPropertyL( EAiPublisherInfo ) ); |
|
59 |
|
60 LeaveIfNull( info, KErrNotFound ); |
|
61 |
|
62 return ContentNodeIdL(*info, aContentItem); |
|
63 } |
|
64 |
|
65 TPtrC CXmlNodeIdGenerator::ContentNodeIdL |
|
66 ( const TAiPublisherInfo& aPubInfo, const TAiContentItem& aContentItem ) |
|
67 { |
|
68 const TDesC& contentCid = ContentCid( aContentItem ); |
|
69 |
|
70 // Calculate buffer size and ensure buffer has enough room |
|
71 const TInt idLength = aPubInfo.iName.Length() |
|
72 + AiUiDef::xml::id::KContentIdSeparator().Length() |
|
73 + contentCid.Length(); |
|
74 TPtr bufPtr( AiUtility::EnsureBufMaxLengthL( iContentNodeIdBuf, idLength ) ); |
|
75 |
|
76 // Copy publisher info name to the buffer |
|
77 bufPtr.Copy( aPubInfo.iName ); |
|
78 |
|
79 // Append separator |
|
80 bufPtr.Append( AiUiDef::xml::id::KContentIdSeparator ); |
|
81 |
|
82 // Append content item id |
|
83 bufPtr.Append( contentCid ); |
|
84 |
|
85 return bufPtr; |
|
86 } |
|
87 |
|
88 TPtrC CXmlNodeIdGenerator::ResourceNodeIdL |
|
89 ( MAiPropertyExtension& aPlugin, const TAiContentItem& aContentItem ) |
|
90 { |
|
91 TAiPublisherInfo* info = static_cast<TAiPublisherInfo*>( aPlugin.GetPropertyL( EAiPublisherInfo ) ); |
|
92 |
|
93 LeaveIfNull( info, KErrNotFound ); |
|
94 |
|
95 return ResourceNodeIdL(*info, aContentItem); |
|
96 } |
|
97 |
|
98 TPtrC CXmlNodeIdGenerator::ResourceNodeIdL |
|
99 ( const TAiPublisherInfo& aPubInfo, const TAiContentItem& aContentItem ) |
|
100 { |
|
101 // Resources node id is similar to content node id |
|
102 return ContentNodeIdL( aPubInfo, aContentItem ); |
|
103 } |