webservices/idwsfplugin/src/idwsfresourceoffering.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 <SenCredential.h>
       
    27 
       
    28 #include "idwsfresourceoffering.h"
       
    29 
       
    30 CIdWsfResourceOffering* CIdWsfResourceOffering::NewL()
       
    31     {
       
    32     CIdWsfResourceOffering* pNew = new (ELeave) CIdWsfResourceOffering;
       
    33     CleanupStack::PushL(pNew);
       
    34     pNew->ConstructL();
       
    35     CleanupStack::Pop(); // pNew;
       
    36     return pNew;
       
    37     }
       
    38 
       
    39 CIdWsfResourceOffering::CIdWsfResourceOffering()
       
    40     {
       
    41     }
       
    42 
       
    43 void CIdWsfResourceOffering::ConstructL()
       
    44     {
       
    45     // Leave everything uninitialized for now
       
    46     }
       
    47 
       
    48 CIdWsfResourceOffering::~CIdWsfResourceOffering()
       
    49     {
       
    50     delete ipResourceId;
       
    51     iServices.ResetAndDestroy();
       
    52     }
       
    53 
       
    54 TPtrC8 CIdWsfResourceOffering::ResourceId()
       
    55     {
       
    56     if(ipResourceId)
       
    57         return *ipResourceId;
       
    58     else
       
    59         return KNullDesC8();
       
    60     }
       
    61 
       
    62 void CIdWsfResourceOffering::SetResourceIdL(const TDesC8& aId)
       
    63     {
       
    64     HBufC8* pNew = NULL;
       
    65     if(aId.Length()>0)
       
    66         pNew = aId.AllocL();
       
    67     delete ipResourceId;
       
    68     ipResourceId = pNew;
       
    69     }
       
    70 
       
    71 CIdWsfServiceInstance& CIdWsfResourceOffering::LastServiceL()
       
    72     {
       
    73     __ASSERT_ALWAYS(iServices.Count() > 0, User::Leave(KErrNotFound));
       
    74     return *(iServices[iServices.Count() - 1]);
       
    75     }
       
    76 
       
    77 void CIdWsfResourceOffering::AddServiceInstanceL(
       
    78                                             CIdWsfServiceInstance* aInstance)
       
    79     {
       
    80     if(ipResourceId)
       
    81         {
       
    82         aInstance->SetResourceIdL(*ipResourceId);
       
    83         }
       
    84     User::LeaveIfError(iServices.Append(aInstance));
       
    85     }
       
    86 
       
    87 void CIdWsfResourceOffering::AddCredentialL(const CSenCredential& aCredential)
       
    88     {
       
    89     // Replace all credentials with the given id, with the credential
       
    90     for (TInt i = 0; i < iServices.Count(); i++)
       
    91         {
       
    92         iServices[i]->SetCredentialL(aCredential);
       
    93         }
       
    94     }
       
    95 
       
    96 RPointerArray<CIdWsfServiceInstance>& CIdWsfResourceOffering::ServicesL()
       
    97     {
       
    98     return iServices;
       
    99     }
       
   100 
       
   101 TInt CIdWsfResourceOffering::SetFacetL(CSenFacet& aFacet)
       
   102     {
       
   103     TInt retVal = KErrNone;
       
   104 
       
   105     TInt count(iServices.Count());
       
   106     for (TInt i=0; i<count; i++)
       
   107         {
       
   108         retVal = iServices[i]->SetFacetL(aFacet);
       
   109         if (retVal != KErrNone) return retVal;
       
   110         }
       
   111 
       
   112     return retVal;
       
   113     }
       
   114 
       
   115 // End of File