ncdengine/provider/client/src/ncdqueryitemimpl.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <s32strm.h>
       
    20 
       
    21 #include "ncdqueryitemimpl.h"
       
    22 #include "ncd_cp_queryelement.h"
       
    23 #include "catalogsinterfaceidentifier.h"
       
    24 #include "catalogsutils.h"
       
    25 #include "ncdstring.h"
       
    26 #include "ncdlocalizerutils.h"
       
    27 #include "ncdqueryimpl.h"
       
    28 
       
    29 // ======== MEMBER FUNCTIONS ========
       
    30 
       
    31 void CNcdQueryItem::InternalizeL( RReadStream& aReadStream )
       
    32     {
       
    33     delete iId;
       
    34     iId = NULL;
       
    35     iId = HBufC::NewL( aReadStream, KMaxTInt );
       
    36     iSemantics = static_cast<MNcdQueryItem::TSemantics>(
       
    37         aReadStream.ReadInt32L());
       
    38     delete iLabel;
       
    39     iLabel = NULL;
       
    40     iLabel = CNcdString::NewL( aReadStream );
       
    41     delete iMessage;
       
    42     iMessage = NULL;
       
    43     iMessage = CNcdString::NewL( aReadStream );
       
    44     delete iDescription;
       
    45     iDescription = NULL;
       
    46     iDescription = CNcdString::NewL( aReadStream );
       
    47     iIsOptional = aReadStream.ReadInt32L();
       
    48     iIsSet = aReadStream.ReadInt32L();
       
    49     iIsInvisible = aReadStream.ReadInt32L();
       
    50     }
       
    51     
       
    52 void CNcdQueryItem::InternalizeL( const MNcdConfigurationProtocolQueryElement& aQueryElement )
       
    53     {
       
    54     delete iId;
       
    55     iId = NULL;
       
    56     iId = aQueryElement.Id().AllocL();    
       
    57     iSemantics = static_cast<MNcdQueryItem::TSemantics>(
       
    58         aQueryElement.Semantics());
       
    59     delete iLabel;
       
    60     iLabel = NULL;
       
    61     iLabel = CNcdString::NewL( aQueryElement.Label().Key(), aQueryElement.Label().Data() );
       
    62     delete iMessage;
       
    63     iMessage = NULL;
       
    64     iMessage = CNcdString::NewL( aQueryElement.Message().Key(), aQueryElement.Message().Data() );
       
    65     delete iDescription;
       
    66     iDescription = NULL;
       
    67     iDescription = CNcdString::NewL( aQueryElement.Description().Key(), aQueryElement.Description().Data() );
       
    68     iIsOptional = aQueryElement.Optional();
       
    69     iIsSet = EFalse;
       
    70     if( aQueryElement.Type() == 
       
    71         MNcdConfigurationProtocolQueryElement::EConfiguration )
       
    72         {
       
    73         iIsInvisible = ETrue;
       
    74         }
       
    75     }
       
    76     
       
    77 void CNcdQueryItem::ExternalizeL( RWriteStream& aWriteStream ) const
       
    78     {
       
    79     aWriteStream << *iId;
       
    80     aWriteStream.WriteInt32L( iSemantics );
       
    81     iLabel->ExternalizeL( aWriteStream );
       
    82     iMessage->ExternalizeL( aWriteStream );
       
    83     iDescription->ExternalizeL( aWriteStream );
       
    84     aWriteStream.WriteInt32L( iIsOptional );
       
    85     aWriteStream.WriteInt32L( iIsSet );
       
    86     aWriteStream.WriteInt32L( iIsInvisible );
       
    87     }
       
    88     
       
    89 const TDesC& CNcdQueryItem::Id() const
       
    90     {
       
    91     return *iId;
       
    92     }
       
    93 
       
    94 TBool CNcdQueryItem::IsSet() const
       
    95     {
       
    96     return iIsSet;
       
    97     }
       
    98 
       
    99 TBool CNcdQueryItem::IsInvisible() const
       
   100     {
       
   101     return iIsInvisible;
       
   102     }
       
   103 
       
   104 TNcdInterfaceId CNcdQueryItem::Type() const
       
   105     {
       
   106     return static_cast<TNcdInterfaceId>(MNcdQueryItem::KInterfaceUid);
       
   107     }
       
   108     
       
   109 MNcdQueryItem::TSemantics CNcdQueryItem::Semantics() const
       
   110     {
       
   111     return iSemantics;
       
   112     }
       
   113 
       
   114 const TDesC& CNcdQueryItem::Label() const
       
   115     {
       
   116     DLTRACEIN((""));
       
   117     MNcdClientLocalizer* localizer = iParentQuery.ClientLocalizer();
       
   118     return CNcdLocalizerUtils::LocalizedString(
       
   119         *iLabel, localizer, iLocalizedLabel );
       
   120     }
       
   121     
       
   122 const TDesC& CNcdQueryItem::Message() const
       
   123     {
       
   124     DLTRACEIN((""));
       
   125     MNcdClientLocalizer* localizer = iParentQuery.ClientLocalizer();
       
   126     return CNcdLocalizerUtils::LocalizedString(
       
   127         *iMessage, localizer, iLocalizedMessage );
       
   128     }
       
   129     
       
   130 const TDesC& CNcdQueryItem::Description() const
       
   131     {
       
   132     DLTRACEIN((""));
       
   133     MNcdClientLocalizer* localizer = iParentQuery.ClientLocalizer();
       
   134     return CNcdLocalizerUtils::LocalizedString(
       
   135         *iDescription, localizer, iLocalizedDescription );
       
   136     }
       
   137     
       
   138 TBool CNcdQueryItem::IsOptional() const
       
   139     {
       
   140     return iIsOptional;
       
   141     }
       
   142 
       
   143 CNcdQueryItem::CNcdQueryItem( CNcdQuery& aParent ) : 
       
   144     CCatalogsInterfaceBase( NULL ), iParentQuery( aParent )
       
   145     {
       
   146     }
       
   147 
       
   148 CNcdQueryItem::~CNcdQueryItem()
       
   149     {
       
   150     delete iId;
       
   151     delete iLabel;
       
   152     delete iDescription;
       
   153     delete iLocalizedLabel;
       
   154     delete iLocalizedMessage;
       
   155     delete iLocalizedDescription;
       
   156     delete iValue;
       
   157     delete iMessage;
       
   158     }
       
   159     
       
   160 void CNcdQueryItem::ConstructL()
       
   161     {
       
   162 	AssignDesL( iId, KNullDesC );
       
   163 	AssignDesL( iValue, KNullDesC );
       
   164 	iLabel = CNcdString::NewL();
       
   165 	iDescription = CNcdString::NewL();
       
   166 	iMessage = CNcdString::NewL();
       
   167 	
       
   168     // Register the interfaces of this object
       
   169     MNcdQueryItem* queryItem( this );
       
   170     AddInterfaceL( 
       
   171         CCatalogsInterfaceIdentifier::NewL(
       
   172             queryItem, this, MNcdQueryItem::KInterfaceUid ) );
       
   173     }
       
   174         
       
   175