PECengine/ListLibrary2/AttrListSrc/CPEngAttributeListTransDeleteAttrList.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 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:  Create attribute list transaction handler
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "CPEngAttributeListTransDeleteAttrList.h"
       
    20 #include "CPEngAttributeListItem.h"
       
    21 #include "MPEngAttributeListTransactionManager.h"
       
    22 
       
    23 #include "PEngListLibTools.h"
       
    24 #include "MPEngXMLSerializer.h"
       
    25 #include "MPEngXMLParser.h"
       
    26 
       
    27 #include "CPEngTransactionStatus.h"
       
    28 #include "PEngWVPresenceErrors2.h"
       
    29 #include <e32std.h>
       
    30 
       
    31 //Default granurality for ID lists
       
    32 const TInt KAttributeListIdGranurality = 3;
       
    33 
       
    34 
       
    35 // ============================ MEMBER FUNCTIONS ===============================
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CPEngAttributeListTransDeleteAttrList::CPEngAttributeListTransDeleteAttrList()
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CPEngAttributeListTransDeleteAttrList::CPEngAttributeListTransDeleteAttrList(
       
    42     MPEngAttributeListTransactionManager& aAttrListTransManager,
       
    43     CPEngContactListTransactionManager& aCntListTransManager,
       
    44     MDesCArray& aDeleteContactList,
       
    45     MDesCArray& aDeleteContactIds,
       
    46     TBool aDeleteDefault,
       
    47     TPEngWVCspVersion& aCSPVersion,
       
    48     TInt aOperationId )
       
    49         : CPEngAttributeListTransBase(  aAttrListTransManager,
       
    50                                         aCntListTransManager,
       
    51                                         aCSPVersion,
       
    52                                         aOperationId ),
       
    53         iArrayDeleteContactList( aDeleteContactList ),
       
    54         iArrayDeleteContactIds( aDeleteContactIds ),
       
    55         iDeleteDefaultAttrList( aDeleteDefault )
       
    56     {
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CPEngAttributeListTransDeleteAttrList::ConstructL()
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CPEngAttributeListTransDeleteAttrList::ConstructL()
       
    64     {
       
    65     CPEngAttributeListTransBase::ConstructL();
       
    66     }
       
    67 
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CPEngAttributeListTransDeleteAttrList::NewLC()
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 CPEngAttributeListTransDeleteAttrList* CPEngAttributeListTransDeleteAttrList::NewLC(
       
    74     MPEngAttributeListTransactionManager& aAttrListTransManager,
       
    75     CPEngContactListTransactionManager& aCntListTransManager,
       
    76     MDesCArray& aDeleteContactList,
       
    77     MDesCArray& aDeleteContactIds,
       
    78     TBool aDeleteDefault,
       
    79     TPEngWVCspVersion& aCSPVersion,
       
    80     TInt aOperationId )
       
    81     {
       
    82     CPEngAttributeListTransDeleteAttrList* self =
       
    83         new ( ELeave ) CPEngAttributeListTransDeleteAttrList(
       
    84         aAttrListTransManager,
       
    85         aCntListTransManager,
       
    86         aDeleteContactList,
       
    87         aDeleteContactIds,
       
    88         aDeleteDefault,
       
    89         aCSPVersion,
       
    90         aOperationId );
       
    91 
       
    92     CleanupStack::PushL( self );
       
    93     self->ConstructL();
       
    94 
       
    95     return self;
       
    96     }
       
    97 
       
    98 
       
    99 // Destructor
       
   100 CPEngAttributeListTransDeleteAttrList::~CPEngAttributeListTransDeleteAttrList()
       
   101     {
       
   102     }
       
   103 
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CPEngAttributeListTransDeleteAttrList::RequestL()
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 void CPEngAttributeListTransDeleteAttrList::RequestL(
       
   110     TDes8& aSendBuffer )
       
   111     {
       
   112     aSendBuffer.Zero();
       
   113     aSendBuffer.Zero();
       
   114     MPEngXMLSerializer* xmlSerializer = CreateXmlSerializerL( aSendBuffer );
       
   115     CleanupClosePushL( *xmlSerializer );
       
   116 
       
   117     // <TransactionContent xmlns="http://www.wireless -village.org/TRC1.1">
       
   118     NListLibTools::AppendTransactionContentTagXmlL( *xmlSerializer, iCSPVersion );
       
   119 
       
   120     // <DeleteAttributeList-Request>
       
   121     xmlSerializer->StartTagL( KDeleteAttributeList );
       
   122 
       
   123     XMLAppendContactIdsL( *xmlSerializer, iArrayDeleteContactIds );
       
   124     XMLAppendContactListsL( *xmlSerializer, iArrayDeleteContactList );
       
   125     XMLAppendDefaultFlagL( *xmlSerializer, iDeleteDefaultAttrList );
       
   126 
       
   127     // </DeleteAttributeList-Request>
       
   128     xmlSerializer->EndTagL( KDeleteAttributeList );
       
   129 
       
   130     // end of transaction
       
   131     // </TransactionContent>
       
   132     xmlSerializer->EndTagL( KTransactionContent );
       
   133     CleanupStack::PopAndDestroy( ); // xmlSerializer
       
   134     }
       
   135 
       
   136 
       
   137 // -----------------------------------------------------------------------------
       
   138 // CPEngAttributeListTransDeleteAttrList::DoConsumeMessageFromServerL()
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 void CPEngAttributeListTransDeleteAttrList::DoConsumeMessageFromServerL(
       
   142     const TDesC8& aResponse )
       
   143     {
       
   144     MPEngXMLParser* XMLparser = CreateXMLParserLC();
       
   145     TInt err ( XMLparser->ParseResultL( aResponse,
       
   146                                         iOperationId,
       
   147                                         *iTransactionStatus ) );
       
   148 
       
   149 
       
   150     CDesC16ArraySeg* contactIDs =
       
   151         new ( ELeave ) CDesC16ArraySeg( KAttributeListIdGranurality );
       
   152     CleanupStack::PushL( contactIDs );
       
   153     CopyDesArrayL( iArrayDeleteContactIds, * contactIDs );
       
   154 
       
   155     CDesC16ArraySeg* contactLists =
       
   156         new ( ELeave ) CDesC16ArraySeg( KAttributeListIdGranurality );
       
   157     CleanupStack::PushL( contactLists );
       
   158     CopyDesArrayL( iArrayDeleteContactList, *contactLists );
       
   159 
       
   160 
       
   161     switch ( err )
       
   162         {
       
   163         case KErrNone:
       
   164         case KPEngNwErrUnknownUser:
       
   165         case KPEngNwErrContactListDoesNotExist:
       
   166         case KPEngNwErrPartiallySuccessful:
       
   167             {
       
   168             // successful operation, all went fine, process according to it
       
   169             // when it failed cause of unknown contact list/wv ID, commit as
       
   170             // well since we are deleting anyway
       
   171             iAttributeListTransManager.CommitDefinedContactsL( contactLists, contactIDs );
       
   172 
       
   173             // if we were deleting also delfaul attribute lists, commit it as well
       
   174             if ( iDeleteDefaultAttrList )
       
   175                 {
       
   176                 iAttributeListTransManager.CommitDefaultL();
       
   177                 }
       
   178             break;
       
   179             }
       
   180 
       
   181         default:
       
   182             {
       
   183             // none of the IDs/cnts list was deleted, remove them from the delete lists
       
   184             iAttributeListTransManager.RollBackDefinedContactsL( contactLists, contactIDs );
       
   185             if ( iDeleteDefaultAttrList )
       
   186                 {
       
   187                 iAttributeListTransManager.RollBackDefaultL();
       
   188                 }
       
   189             break;
       
   190             }
       
   191         }
       
   192 
       
   193 
       
   194     iAttributeListTransManager.StoreChangesToStoreL();
       
   195     CleanupStack::PopAndDestroy( 3 ); // XMLparser, contactLists, contactIDs
       
   196     }
       
   197 
       
   198 
       
   199 //  End of File
       
   200