phonebookengines_old/contactsmodel/cntplsql/inc/rpplicccontactstore.h
branchGCC_SURGE
changeset 41 d11de32a5e6f
parent 40 b46a585f6909
equal deleted inserted replaced
38:11319788d38f 41:d11de32a5e6f
       
     1 /**
       
     2 * Copyright (c) 2005-2009 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  @file
       
    22  @internalComponent
       
    23  @released
       
    24 */
       
    25 
       
    26 
       
    27 #ifndef __RPPLICCCONTACTSTORE_H__
       
    28 #define __RPPLICCCONTACTSTORE_H__
       
    29 
       
    30 #include <cntsync.h>
       
    31 #include "persistencelayer.h"
       
    32 
       
    33 /**
       
    34 The RPplIccContactStore class works as an adaptor between the Persistence Layer
       
    35 and the phonebook synchroniser server.
       
    36 
       
    37 From one side it behaves like a Persistence Layer table and is registered as a
       
    38 child of the Contacts table.  This is achieved by implementing the
       
    39 MPplContactItemPersistor interface.
       
    40 
       
    41 From the other side it uses the contact synchroniser plugin to communicate with
       
    42 the phonebook synchroniser.
       
    43 
       
    44 Since DBMS and all the tables in the Persistence Layer support transactions and
       
    45 the phonebook synchroniser does not, the RPplIccContactStore class takes this
       
    46 responsibility.  The class implements the MLplTransactionManager interface and
       
    47 uses an internal array to keep all the actions required for transaction rollback
       
    48 during the transaction.
       
    49 */
       
    50 class NONSHARED RPplIccContactStore // : public MLplTransactionManager//,  public MPplContactItemPersistor
       
    51 	{
       
    52 public:
       
    53 	enum TIccContactOperationType
       
    54 		{
       
    55 		EIccContactCreate,
       
    56 		// Reading is not supported.
       
    57 		EIccContactUpdate,
       
    58 		EIccContactDelete
       
    59 		};
       
    60 	
       
    61 	struct TIccContactOperation
       
    62 		{
       
    63 		TIccContactOperation(CContactItem& aItem, TIccContactOperationType aType)
       
    64 			: iContact(aItem), iType(aType) {}
       
    65 		CContactItem& iContact;
       
    66 		TIccContactOperationType iType;
       
    67 		};
       
    68 	
       
    69 	RPplIccContactStore(CLplContactProperties& aContactProperties);
       
    70 	void Close();
       
    71 	
       
    72 	// From MLplTransactionManager.
       
    73 	void StartTransactionL();
       
    74 	void CommitCurrentTransactionL(TUint aSessionId);
       
    75 	void RollbackCurrentTransaction(TUint aSessionId);
       
    76 	TBool IsTransactionActive() const;
       
    77 	
       
    78 	TContactItemId CreateInDbL (CContactItem& aItem, TUint aSessionId);
       
    79 	void ReadL(CContactItem& aItem, TInt aInfoToRead, TUint aSessionId, TBool aIccOpenCheck=EFalse) const;	
       
    80 	void UpdateL(CContactItem& aNewItem, TUint aSessionId);
       
    81 	void DeleteL(const CContactItem& aItem, TUint aSessionId);
       
    82 	
       
    83 	void PersistorChangeTypeL(TContactItemId aItemId, TUid aNewType);
       
    84 	void ExecuteTransaction();
       
    85 	
       
    86 private:
       
    87 	void ConstructL();
       
    88 	void ExecuteTransactionL(TUint aSessionId);
       
    89 	void RollbackTransactionL(TUint aSessionId);
       
    90 	void CreateIccContactL(CContactItem& aItem, TUint aSessionId);
       
    91 	void UpdateIccContactL(CContactItem& aItem, TUint aSessionId);
       
    92 	void DeleteIccContactL(const CContactItem& aItem, TUint aSessionId);
       
    93 	void ValidateIccContactL(MContactSynchroniser::TValidateOperation aOp,
       
    94 							 CContactItem& aItem, TUint aSessionId) const;
       
    95 	
       
    96 private:
       
    97 	TBool iTransactionActive;
       
    98 	RArray<TIccContactOperation> iTransactionOps;
       
    99 	CLplContactProperties& iProperties;
       
   100 	};
       
   101 
       
   102 
       
   103 #endif // __RPPLICCCONTACTSTORE_H__