summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/cntsrv/inc/ccntdbmanagercontroller.h
blob: 229caf6859eebac8d60aaa6c3e11723762d852a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
* Contact: http://www.qt-project.org/legal
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/




/**
 @file
 @internalComponent
 @released
*/

#ifndef CCNTDBMANAGERCONTROLLER_H
#define CCNTDBMANAGERCONTROLLER_H

#include <e32base.h>
#include <f32file.h> // for tdriveunit.
#include "ccntserver.h" // for tcntservertype.
#include "ccntdbmanager.h" // for tcntfilemode.
#include "cinifilemanager.h" // for tsavetype.


class CCntDbManager;
class CPersistenceLayer;
class CReqAsyncOpen;
class CCntServerSpeedDialManager;
class CCntBackupRestoreAgent;
class CCntPermanentData;
		

/**
The CCntDbManagerController instantiates and controls all CCntDbManager
instances.

There is one CCntDbManagerController class per CCntServer instance.
*/
class CCntDbManagerController : public CBase
	{
public:
	static CCntDbManagerController* NewLC(TCntServerType aServerType);
	virtual ~CCntDbManagerController();

	CCntDbManager* GetDbManagerL(TDes& aCntFile, TCntFileMode aMode);
	CCntDbManager* DbManagerL(const TDesC& aCntFile) const;

	// Database management methods.
	void DeleteDatabaseL(TDes& aCntFile) const;
	void DefaultDatabaseL(TDes& aCntFile) const;
	void DatabaseDrive(TDriveUnit& aDrive) const;	
	void SetDatabaseDriveL(TDriveUnit aDrive,TBool aCopy);
	void RestoreDatabaseDrive(TDriveUnit& aDrive);
	TBool DatabaseExistsL(const TDesC& aCntFile) const;
	void ListDatabasesL(CBufFlat*& aList,TDriveUnit* aDriveUnit = NULL) const;
	void CloseDatabase(CCntDbManager& aManager);
	void SetCurrentDbL(const TDesC& aNewCurrentDb, TUint aSessionId);
	const TDesC& CurrentDb() const;
	
	void HandleBackupRestoreEventL(TContactDbObserverEventV2 aEvent);
	
	void ScheduleSaveIniFileSettings(TInt aSaveFlags, TBool aReplace=EFalse);
		
	// Access methods.
	CCntBackupRestoreAgent& BackupRestoreAgent() const;
	CIniFileManager& IniFileManager() const;

private:
	CCntDbManagerController();
	void ConstructL(TCntServerType aServerType);
	
	TInt FindExistingFileManager(const TDesC& aCntFile) const;

	void NotifyDbManagersL(TContactDbObserverEventV2 aEvent);
		
private:
	RPointerArray<CCntDbManager>	iManagers;
	CPersistenceLayer*				iPersistenceLayer;
	TDriveUnit						iDefaultDriveUnit;

	CCntBackupRestoreAgent*			iBackupRestoreAgent;
	CIniFileManager*				iIniFileManager;
	CCntPermanentData*				iPermanentData;

	RFs iFs;
	};

#endif