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