ncdengine/provider/protocol/src/ncdrequestconfiguration.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:   CNcdRequestBrowseSearch implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdrequestconfiguration.h"
       
    20 #include "ncdrequestbase.h"
       
    21 #include "ncdrequestconfigurationdata.h"
       
    22 #include "ncdprotocolutils.h"
       
    23 #include "ncdprotocolwords.h"
       
    24 #include "catalogsdebug.h"
       
    25 
       
    26 CNcdRequestConfiguration* CNcdRequestConfiguration::NewL()
       
    27     {
       
    28     //DLTRACEIN(( _L("NewL")));
       
    29     CNcdRequestConfiguration* self = 
       
    30         CNcdRequestConfiguration::NewLC( );
       
    31     CleanupStack::Pop();
       
    32     //DLTRACEOUT(( _L("NewL")));
       
    33     return self;
       
    34     }
       
    35 
       
    36 CNcdRequestConfiguration* CNcdRequestConfiguration::NewLC()
       
    37     {
       
    38     //DLTRACEIN(( _L("NewLC")));
       
    39     CNcdRequestConfiguration* self = 
       
    40         new (ELeave) CNcdRequestConfiguration();
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL();
       
    43     //DLTRACEOUT(( _L("NewLC")));
       
    44     return self;
       
    45     }
       
    46 
       
    47 void CNcdRequestConfiguration::ConstructL()
       
    48     {
       
    49     DLTRACEIN((""));
       
    50 //    iRootName.SetL();
       
    51     CNcdRequestBase::ConstructL( KTagConfigurationRequest );
       
    52     iNamespaceUri.SetL( KCdpNamespaceUri );
       
    53     iPrefix.SetL( KNullDesC8 );
       
    54     iVersion.SetL( KConfigurationReqVersion );
       
    55     iType.SetL( KDefaultRequestType );
       
    56     DLTRACEOUT((""));
       
    57     }
       
    58     
       
    59 CNcdRequestConfiguration::CNcdRequestConfiguration()
       
    60     : CNcdRequestBase()
       
    61     {
       
    62     }
       
    63 
       
    64 CNcdRequestConfiguration::~CNcdRequestConfiguration()
       
    65     {
       
    66     DLTRACEIN((""));
       
    67     iType.Free();
       
    68     iNamespaceUri.Free();
       
    69     iPrefix.Free();
       
    70     delete iBundles;
       
    71     DLTRACEOUT((""));
       
    72     }
       
    73 
       
    74 void CNcdRequestConfiguration::AddCatalogBundleRequestL( TDesC8& aBundleId )
       
    75     {
       
    76     if ( !iBundles ) 
       
    77         {
       
    78         iBundles = new (ELeave) CDesC8ArrayFlat(1);
       
    79         }
       
    80     iBundles->AppendL( aBundleId );
       
    81     }
       
    82 
       
    83 // generates the dom nodes
       
    84 HBufC8* CNcdRequestConfiguration::CreateRequestL()
       
    85     {
       
    86     // generate browse part of the request
       
    87     DLTRACEIN((_L("entry")));
       
    88 
       
    89     // override request root element name and namespace
       
    90 #ifndef RD_XML_ENGINE_API_CHANGE
       
    91     TXmlEngString configurationRequest;
       
    92     NcdProtocolUtils::DesToStringL( configurationRequest, KTagConfigurationRequest );
       
    93     iRoot = iDocument.CreateDocumentElementL( configurationRequest );
       
    94     configurationRequest.Free();
       
    95     
       
    96     TXmlEngString cdpUri;
       
    97     NcdProtocolUtils::DesToStringL( cdpUri, KCdpNamespaceUri );
       
    98     TXmlEngString cdpPrefix;
       
    99     NcdProtocolUtils::DesToStringL( cdpPrefix, KCdpNamespacePrefix);
       
   100     iRoot.SetDefaultNamespaceL( cdpUri );
       
   101     iCdpNamespace = iRoot.AddNamespaceDeclarationL( cdpUri, cdpPrefix );
       
   102     cdpUri.Free();
       
   103     cdpPrefix.Free();
       
   104 
       
   105     TXmlEngString xsUri;
       
   106     TXmlEngString xsPrefix;
       
   107     NcdProtocolUtils::DesToStringL( xsUri, KXsNamespaceUri );
       
   108     NcdProtocolUtils::DesToStringL( xsPrefix, KXsNamespacePrefix );
       
   109     iXsNamespace = iRoot.AddNamespaceDeclarationL( xsUri, xsPrefix );
       
   110     xsUri.Free();
       
   111     xsPrefix.Free();
       
   112     
       
   113     TXmlEngString xsiUri;
       
   114     TXmlEngString xsiPrefix;
       
   115     NcdProtocolUtils::DesToStringL( xsiUri, KXsiNamespaceUri );
       
   116     NcdProtocolUtils::DesToStringL( xsiPrefix, KXsiNamespacePrefix );
       
   117     iXsiNamespace = iRoot.AddNamespaceDeclarationL( xsiUri, xsiPrefix );
       
   118     xsiUri.Free();
       
   119     xsiPrefix.Free();
       
   120     
       
   121 #else
       
   122     iRoot = iDocument.CreateDocumentElementL( KTagConfigurationRequest );
       
   123     iRoot.SetDefaultNamespaceL( KCdpNamespaceUri );
       
   124     iCdpNamespace = iRoot.AddNamespaceDeclarationL( KCdpNamespaceUri, KCdpNamespacePrefix );
       
   125     iXsNamespace = iRoot.AddNamespaceDeclarationL( KXsNamespaceUri, KXsNamespacePrefix );
       
   126     iXsiNamespace = iRoot.AddNamespaceDeclarationL( KXsiNamespaceUri, KXsiNamespacePrefix );
       
   127 #endif
       
   128 
       
   129     NcdProtocolUtils::NewAttributeL( iRoot, KAttrVersion, iVersion);
       
   130     NcdProtocolUtils::NewAttributeL( iRoot, KAttrType, iType);
       
   131     
       
   132     // no request if there is no configuration data
       
   133     if ( !iConfiguration )
       
   134         {
       
   135         DLTRACEOUT(( "exit with null" ));
       
   136         return NULL;
       
   137         }
       
   138     
       
   139     // prefix not needed in configuration request
       
   140     iConfiguration->SetNamespacePrefixL( KNullDesC8 );
       
   141 
       
   142     // network    
       
   143     TXmlEngElement network = 
       
   144         iConfiguration->GetNetworkConfigurationElementL( iDocument );
       
   145     if ( network.NotNull() )
       
   146         iRoot.AppendChildL( network );
       
   147     
       
   148     DLTRACE(("Adding %d client-infos", 
       
   149         iConfiguration->ClientConfigurationCount() ));
       
   150         
       
   151     for ( TInt clientIndex = 0; 
       
   152           clientIndex < iConfiguration->ClientConfigurationCount(); 
       
   153           ++clientIndex )
       
   154         {        
       
   155         // client
       
   156         TXmlEngElement client = 
       
   157             iConfiguration->GetClientConfigurationElementL( 
       
   158                 iDocument, clientIndex );
       
   159                 
       
   160         if ( client.NotNull() )
       
   161             iRoot.AppendChildL( client );
       
   162         }
       
   163         
       
   164     // cookies
       
   165     TXmlEngElement cookies = iConfiguration->GetCookiesElementL( iDocument );
       
   166     if ( cookies.NotNull() )
       
   167         iRoot.AppendChildL( cookies );
       
   168     
       
   169 
       
   170     // queryResponse
       
   171     TXmlEngElement queryResponses = GetQueryResponsesElementL( KNullDesC8 );
       
   172     if ( queryResponses.NotNull() )
       
   173         iRoot.AppendChildL( queryResponses );
       
   174 
       
   175     // details
       
   176     TXmlEngElement details = GetDetailsElementL( KNullDesC8 );
       
   177     if ( details.NotNull() ) 
       
   178         iRoot.AppendChildL( details );
       
   179     // catalog bundle requests
       
   180     if ( iBundles && iBundles->MdcaCount() > 0 ) 
       
   181         {
       
   182         if ( details.IsNull() ) 
       
   183             {
       
   184             details = 
       
   185                 NcdProtocolUtils::NewElementL( iDocument, iRoot, KTagDetails );
       
   186             }
       
   187         for ( TInt i = 0; i < iBundles->MdcaCount(); ++i ) 
       
   188             {
       
   189             TPtrC8 ptr = iBundles->MdcaPoint( i );
       
   190             TXmlEngElement detail = 
       
   191                 NcdProtocolUtils::NewElementL( iDocument, details, KTagDetail );
       
   192             NcdProtocolUtils::NewAttributeL( detail, KAttrId, KValueCatalogRequest );
       
   193             NcdProtocolUtils::NewAttributeL( detail, KAttrValue, ptr );
       
   194             }
       
   195         }
       
   196     
       
   197     DLTRACEOUT((_L("exit")));
       
   198     // base class CreateRequestL not needed
       
   199     return CNcdRequestBase::ExternalizeL();
       
   200     }
       
   201