phonebookengines/contactsmodel/cntplsql/inc/cntpplviewmanager.h
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /**
       
     2 * Copyright (c) 2007-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 #ifndef __CNTPPLVIEWMANAGER_H__
       
    27 #define __CNTPPLVIEWMANAGER_H__
       
    28 
       
    29 #include "cntsqlprovider.h"
       
    30 #include "persistencelayer.h" // For interface definitions.
       
    31 #include "persistencelayerimpl.h"
       
    32 #include <sqldb.h>
       
    33 
       
    34 class CViewContact;
       
    35 class CCntPplViewSession;
       
    36 class CCntSqlStatement;
       
    37 
       
    38 /**
       
    39 The CCntPplViewManager class provides the data source for the Contacts Model
       
    40 view framework.  The view item manager provides support for multiple
       
    41 iterators (used for view population) as well as the random access to the
       
    42 Contacts database (used for keeping the views synchronised with the changing
       
    43 database).
       
    44 */
       
    45 class NONSHARED CCntPplViewManager : public CBase, public MLplViewIteratorManager
       
    46 	{
       
    47 public:
       
    48 	static CCntPplViewManager* NewL(CPplContactsFile& aContactsFile, const CLplContactProperties& aContactProperties);
       
    49 	~CCntPplViewManager();
       
    50 	
       
    51 	//Methods defined in MLplViewIteratorManager
       
    52 	TInt OpenViewL(const CContactTextDef& aTextDef, const TContactViewPreferences aViewPrefs);
       
    53 	void CloseView(TInt aViewId);
       
    54 	void ChangeSortOrderL(TInt aViewId, const CContactTextDef& aTextDef);
       
    55 	void BeginIterateL(TInt aViewId);
       
    56 	void EndIterateL(TInt aViewId);
       
    57 	CViewContact* NextItemL(TInt aViewId, TContactViewPreferences aViewPrefs);
       
    58 	CViewContact* ItemAtL(TContactItemId aContactId, TInt aViewId);
       
    59 	
       
    60 	TUid ReadContactTextDefL(TContactItemId aContactId, TDes &aResult,const CContactTextDef& aTextDef);
       
    61     void TextFieldL(TInt aCntItemId,TFieldType aFieldType, TDes& aText);
       
    62 
       
    63 private:
       
    64 	void ConstructL();
       
    65 	CCntPplViewManager(CPplContactsFile& aContactsFile, const CLplContactProperties& aContactProperties);
       
    66 	
       
    67 	TInt FindViewSessionIndexById(TInt aViewId) const;
       
    68 	CCntPplViewSession* FindViewSessionByIdL(TInt aViewId) const;
       
    69 	
       
    70 private:
       
    71 	CPplContactsFile& iContactsFile;
       
    72 	const CLplContactProperties& iContactProperties;
       
    73 	
       
    74 	TInt  iNextViewId;
       
    75 	RPointerArray<CCntPplViewSession> iViewSessions;
       
    76 	
       
    77 	CCntSqlStatement* 		iSelectFullFieldsStmt;
       
    78 	};
       
    79 
       
    80 class NONSHARED CCntPplViewSession: public CTimer,
       
    81     public MLplSqlDatabaseObserver
       
    82 	{
       
    83 public:	
       
    84 	static CCntPplViewSession* NewL(CPplContactsFile& aContactsFile, const CLplContactProperties& aContactProperties, CCntSqlStatement& aSelectAllFields, TInt aViewId, const CContactTextDef& aTextDef, TContactViewPreferences aViewPrefs);
       
    85 	~CCntPplViewSession();
       
    86 	
       
    87 	void ChangeSortOrderL(const CContactTextDef& aTextDef);
       
    88 	
       
    89 	void BeginIterateL();
       
    90 	void EndIterate();
       
    91 	CViewContact* NextItemL(TContactViewPreferences aViewPrefs);
       
    92 	CViewContact* ItemAtL(TContactItemId aContactId);
       
    93 	
       
    94 	TInt ViewId() const;
       
    95 	
       
    96 	static void  TextFieldL(RSqlStatement& aSqlStatement, const CCntSqlStatement& aCntSqlStmt, const CContactTemplate& aSystemTemplate, TFieldType aFieldType, TDes& aText);
       
    97 	
       
    98 	// From MLplSqlDatabaseObserver
       
    99     void OnCloseL(); 
       
   100 	
       
   101 private:
       
   102 	void ConstructL(const CContactTextDef& aTextDef);
       
   103 	CCntPplViewSession(CPplContactsFile& aContactsFile, const CLplContactProperties& aContactProperties, CCntSqlStatement& aSelectAllFields, TInt aViewId, TContactViewPreferences aViewPrefs);
       
   104 	
       
   105 	CViewContact* CreateViewItemL(RSqlStatement& aSqlStmt, const CCntSqlStatement& aCntSqlStmt, const TContactViewPreferences& aViewPrefs);
       
   106 	void  FillViewItemL(CViewContact& aViewContact, RSqlStatement& aSqlStmt, const TContactViewPreferences& aViewPrefs);
       
   107 	
       
   108 	static CViewContact* InitialiseViewItemL(RSqlStatement& aSqlStmt, const CCntSqlStatement& aCntSqlStmt, const TContactViewPreferences& aViewPrefs);
       
   109 	static TBool HasTxtFieldInFastAccessFieldsL(RSqlStatement& aSelectStmt, const CCntSqlStatement& aCntSqlStmt, TDes& aText);
       
   110 	static TBool SpecificTxtFieldInFastAccessFieldsL(RSqlStatement& aSelectStmt, const CCntSqlStatement& aCntSqlStmt, const TFieldType aFieldType, TDes& aText);
       
   111 	static TUid  GetContactFieldMatchUid(const CViewContact& aViewContact, const TContactViewPreferences& aViewPreferences);
       
   112 	static void  AddFieldInViewContactL(CViewContact& aViewContact, TPtrC& aFieldPtrC, const TContactViewPreferences& aViewPreferences);
       
   113     static TBool ContactCorrectType(TUid aContactTypeUid, TContactViewPreferences aTypeToInclude);	
       
   114     
       
   115     void RunL();  //interface for CTimer
       
   116    
       
   117     CViewContact* doItemAtL(TContactItemId aContactId);
       
   118     void CleanupCachedPrepareStatement();
       
   119 private:
       
   120 	const TInt 				iViewId;
       
   121 	const CLplContactProperties& iContactProperties;
       
   122 	
       
   123 	CPplContactsFile& 		iContactsFile;
       
   124 	CCntSqlStatement&       iSqlSmtSelectAllFieldsById;
       
   125 	
       
   126 	TContactViewPreferences iViewPrefs;
       
   127 	
       
   128 	CContactTextDef*        iTextDef;
       
   129     CCntSqlStatement*       iCntSqlStatement;
       
   130     RSqlStatement           iRSqlStatement;
       
   131     TBool                   iRSqlStatementReady;
       
   132     RSqlStatement           iCachedSqlStatement;
       
   133     TBool                   iCachedSqlStatementReady;
       
   134     TBool                   iIsFastAccessFieldsOnly;
       
   135 	};
       
   136 	
       
   137 	
       
   138 #endif //__CNTPPLVIEWMANAGER_H__