summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/cntsrv/inc/ccntserver.h
blob: cc5db692a360bea6d3b68cfe2fa8ea0d815e7b8b (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* 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 CNTSERVER_H
#define CNTSERVER_H


#include <e32base.h>
#include <e32hashtab.h> // for rhashmap
#include "ccntmsghandlerfptr.h"


class CCntDbManagerController;
class CCntPackager;
class CCntServerCurrentItemMap;


const TInt KContactsServerPriority = 0;

const TUint KLockSrvMajorVersionNumber=1;
const TUint KLockSrvMinorVersionNumber=0;
const TUint KLockSrvBuildVersionNumber=0;

const TUint KLockSrvServerThreadHeapSize=0x2000;
const TUint KLockSrvServerMaxThreadHeapSize=0x100000;

const TInt KSlot0 = 0;
const TInt KSlot1 = 1;
const TInt KSlot2 = 2;
const TInt KSlot3 = 3;

const TUint KCntNullConnectionId = 0;


// Enumerations.
enum TLockSrvClientPanics
	{ 
	ELockSrvPanicBadDescriptor,
	ELockSrvPanicBadHandle,
	ELockSrvPanicInvalidOpcode,
	ELockSrvPanicAlreadyInitialised,
	ELockSrvPanicNoReplyBuffer,
	ELockSrvPanicEventDescriptor,
	ELockSrvPanicInvalidViewIndex,
	ELockSrvPanicMultipleSortableTextAtLengthCalls,
	ELockSrvPanicInvalidSortableTextAtCall,
	// 8.1 new panic codes
	ELockSrvPanicSessionFileNameNotSet,
	};


enum TCntServerType
	{
	ETransientServer,
	ENonTransientServer
	};	


// Literal constants - shared between client & server.
_LIT(KContactsServerName, "!CntLockServer");
_LIT(KContactsBaseFilename, "Contacts.cdb");


class CServerShutdown : public CTimer
	{
public:
	static CServerShutdown* NewL();
	void Start();

private:
	CServerShutdown();
	void ConstructL();
	void RunL();

private:
	// Shut down server if no clients connected for 5 seconds.
	enum {KServerShutdownDelay = 5000000};	
	};


class CCntServer : public CPolicyServer
	{
public:
	static CCntServer* NewL();
	virtual ~CCntServer();
	CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
	CCntDbManagerController& Controller();
	CObjectCon* NewContainerL();
	void RemoveObjectContainer(CObjectCon& aContainer);
	void SessionClosing();
	TInt SessionCount();
	void CreateMessageMapL();	
	RHashMap<TInt,MsgHandlerFptr>& MsgLut();

private:
	CCntServer();
	void ConstructL();

private:
	CCntDbManagerController*	iController;
	CCntPackager* 				iPackager;
	CObjectConIx* 				iContainerIndex;
	CServerShutdown* 			iServerShutdown;
	TCntServerType				iServerType;
	mutable TUint 				iNextSessionId;
	
    /** Message Handler Lookup table.
    Look table maps message functions (op codes) to appropriate
    message handler methods.
    */	
	RHashMap<TInt,MsgHandlerFptr> iMsgLut;
	};


#endif