webservices/wsdescription/src/senservicepattern.cpp
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 // INCLUDE FILES
       
    26 #include "SenServicePattern.h"
       
    27 #include "senconsumerpolicy.h"
       
    28 
       
    29 namespace
       
    30     {
       
    31     _LIT8(KConsumerPolicyLocalName, "ConsumerPolicy");
       
    32     }
       
    33 
       
    34 
       
    35 
       
    36 EXPORT_C CSenServicePattern* CSenServicePattern::NewL()
       
    37     {
       
    38     CSenServicePattern* pNew = NewLC();
       
    39     CleanupStack::Pop();
       
    40     return(pNew) ;
       
    41     }
       
    42 
       
    43 
       
    44 EXPORT_C CSenServicePattern* CSenServicePattern::NewLC()
       
    45     {
       
    46     CSenServicePattern* pNew = 
       
    47                             new (ELeave) CSenServicePattern(EServicePattern);
       
    48     CleanupStack::PushL(pNew);
       
    49     pNew->BaseConstructL();
       
    50     return pNew;
       
    51     }
       
    52 
       
    53 EXPORT_C CSenServicePattern* CSenServicePattern::NewL(
       
    54                                                 const TDesC8& aNamespaceURI)
       
    55     {
       
    56     CSenServicePattern* pNew = NewLC(aNamespaceURI);
       
    57     CleanupStack::Pop();
       
    58     return(pNew) ;
       
    59     }
       
    60 
       
    61 
       
    62 EXPORT_C CSenServicePattern* CSenServicePattern::NewLC(
       
    63                                                 const TDesC8& aNamespaceURI)
       
    64     {
       
    65     CSenServicePattern* pNew = 
       
    66                             new (ELeave) CSenServicePattern(EServicePattern);
       
    67     CleanupStack::PushL(pNew);
       
    68     pNew->BaseConstructL(aNamespaceURI);
       
    69     return pNew;
       
    70     }
       
    71 
       
    72 EXPORT_C CSenServicePattern* CSenServicePattern::NewL(const TDesC8& aEndPoint, 
       
    73                                                       const TDesC8& aContract)
       
    74     {
       
    75     CSenServicePattern* pNew = NewLC(aEndPoint, aContract);
       
    76     CleanupStack::Pop();
       
    77     return(pNew) ;
       
    78     }
       
    79 
       
    80 EXPORT_C CSenServicePattern* CSenServicePattern::NewLC(const TDesC8& aEndPoint, 
       
    81                                                        const TDesC8& aContract)
       
    82     {
       
    83     CSenServicePattern* pNew = 
       
    84                             new (ELeave) CSenServicePattern(EServicePattern);
       
    85     CleanupStack::PushL(pNew);
       
    86     pNew->BaseConstructL(aEndPoint, aContract);
       
    87     return pNew;
       
    88     }
       
    89 
       
    90 EXPORT_C CSenServicePattern::CSenServicePattern(
       
    91                         MSenServiceDescription::TDescriptionClassType aType)
       
    92 : CSenXmlServiceDescription(aType)
       
    93     {
       
    94     }
       
    95 
       
    96 EXPORT_C CSenServicePattern::~CSenServicePattern()
       
    97     {
       
    98     delete iConsumerPolicy;
       
    99     }
       
   100 
       
   101 EXPORT_C void CSenServicePattern::BaseConstructL()
       
   102     {
       
   103     CSenXmlServiceDescription::ConstructL();
       
   104     // construct empty consumer policy...
       
   105 
       
   106     // NOTE; iConsumerPolicy is, AS INTENDED, a separate XML object
       
   107     // from the "ServicePattern", which contains it
       
   108     iConsumerPolicy = CSenConsumerPolicy::NewL();
       
   109     }
       
   110 
       
   111 EXPORT_C void CSenServicePattern::BaseConstructL(const TDesC8& aNamespaceURI)
       
   112     {
       
   113     CSenXmlServiceDescription::ConstructL(aNamespaceURI);
       
   114     // construct empty consumer policy...
       
   115     iConsumerPolicy = CSenConsumerPolicy::NewL();
       
   116     }
       
   117 
       
   118 EXPORT_C void CSenServicePattern::BaseConstructL(const TDesC8& aEndPoint, 
       
   119                                                 const TDesC8& aContract)
       
   120     {
       
   121     CSenXmlServiceDescription::ConstructL(aEndPoint, aContract);
       
   122     // construct empty consumer policy...
       
   123     iConsumerPolicy = CSenConsumerPolicy::NewL();
       
   124     }
       
   125 
       
   126 
       
   127 EXPORT_C TBool CSenServicePattern::Matches(
       
   128                                     MSenServiceDescription& aServicePattern)
       
   129     {
       
   130     TBool matches = CSenXmlServiceDescription::Matches(aServicePattern);
       
   131     if(matches && aServicePattern.DescriptionClassType() == EServicePattern)
       
   132         {
       
   133         CSenServicePattern* pPattern = (CSenServicePattern*)&aServicePattern;
       
   134         return iConsumerPolicy->Accepts(*(MSenConsumerPolicy*)pPattern);
       
   135         }
       
   136     else 
       
   137         return EFalse; // even the service descriptions wont match
       
   138     }
       
   139 
       
   140 // from MSenConsumerPolicy
       
   141 EXPORT_C void CSenServicePattern::SetConsumerIapIdL(TUint32 aIapId)
       
   142     {
       
   143     iConsumerPolicy->SetIapIdL(aIapId);
       
   144     }
       
   145 
       
   146 // getter for IAP ID
       
   147 EXPORT_C TInt CSenServicePattern::ConsumerIapId(TUint32& aCurrentIapId)
       
   148     {
       
   149     return iConsumerPolicy->IapId(aCurrentIapId);
       
   150     }
       
   151 
       
   152 // setter for SNAP ID
       
   153 EXPORT_C void CSenServicePattern::SetConsumerSnapIdL(TUint32 aSnapId)
       
   154     {
       
   155     iConsumerPolicy->SetSnapIdL(aSnapId);
       
   156     }
       
   157 
       
   158 // getter for SNAP ID
       
   159 EXPORT_C TInt CSenServicePattern::ConsumerSnapId(TUint32& aCurrentSnapId)
       
   160     {
       
   161     return iConsumerPolicy->SnapId(aCurrentSnapId);
       
   162     }
       
   163 
       
   164 
       
   165 // Setter: overrides current values with the given values from the array
       
   166 EXPORT_C void CSenServicePattern::SetConsumerIdentityProviderIdsL(
       
   167                             CSenIdentityProviderIdArray8& aList)
       
   168     {
       
   169     iConsumerPolicy->SetIdentityProviderIdsL(aList);
       
   170     }
       
   171 
       
   172 // Adder: adds a new IDP ID value at the end of the current list value(s)
       
   173 // Does not insert duplicate values. 
       
   174 //
       
   175 // @return KErrAlreadyExists, if a duplicate is tried to add
       
   176 //         KErrArgument if a zero-length descriptor is tried to add 
       
   177 //         (aProviderId.Length() == 0)
       
   178 EXPORT_C TInt CSenServicePattern::AddConsumerIdentityProviderIdL(
       
   179                                         const TDesC8& aProviderId)
       
   180     {
       
   181     return iConsumerPolicy->AddIdentityProviderIdL(aProviderId);
       
   182     }
       
   183 
       
   184 
       
   185 // Getter: return an empty array if no IDP:s have been spesified
       
   186 // or a list of IDP arrays if such value(s) have been set.
       
   187 EXPORT_C const CSenIdentityProviderIdArray8&
       
   188                 CSenServicePattern::ConsumerIdentityProviderIds8L()
       
   189     {
       
   190     return iConsumerPolicy->IdentityProviderIds8L();
       
   191     }
       
   192 
       
   193 
       
   194 EXPORT_C TBool CSenServicePattern::AcceptsConsumerPolicy(
       
   195                                             MSenConsumerPolicy& aPolicyPattern)
       
   196     {
       
   197     return iConsumerPolicy->Accepts(aPolicyPattern);
       
   198     }
       
   199 
       
   200 EXPORT_C TBool CSenServicePattern::RebuildFromConsumerPolicy(
       
   201                                                 MSenConsumerPolicy& aTemplate)
       
   202     {
       
   203     return iConsumerPolicy->RebuildFrom(aTemplate);
       
   204     }
       
   205 
       
   206 // overrides CXmlServiceDescription
       
   207 EXPORT_C void CSenServicePattern::StartElementL(
       
   208                                     const TDesC8& aNsUri,
       
   209                                     const TDesC8& aLocalName,
       
   210                                     const TDesC8& aQName,
       
   211                                     const RAttributeArray& aAttributes)
       
   212     {
       
   213 
       
   214     if(aLocalName == KConsumerPolicyLocalName)
       
   215         {
       
   216         // get rid of existing stuff
       
   217         delete iConsumerPolicy;
       
   218         iConsumerPolicy = NULL;
       
   219         iConsumerPolicy = CSenConsumerPolicy::NewL();
       
   220 
       
   221         iConsumerPolicy->SetAttributesL(aAttributes);
       
   222         DelegateParsingL(*iConsumerPolicy);
       
   223         }
       
   224     else 
       
   225         {
       
   226         CSenXmlServiceDescription::StartElementL(
       
   227             aNsUri, aLocalName, aQName, aAttributes);
       
   228         }
       
   229     }
       
   230 
       
   231 EXPORT_C HBufC8* CSenServicePattern::ConsumerPolicyAsXmlL()
       
   232     {
       
   233     return iConsumerPolicy->AsXmlL();
       
   234     }
       
   235 
       
   236 // End of File