|
1 // server.h |
|
2 // |
|
3 // Copyright (c) 2006 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #ifndef __SERVER_H__ |
|
14 #define __SERVER_H__ |
|
15 |
|
16 #ifdef EKA2 |
|
17 #define RMsg RMessage2 |
|
18 #else |
|
19 #define RMsg RMessage |
|
20 #endif |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <f32file.h> |
|
24 #include <e32hashtab.h> |
|
25 #include "iocli.h" |
|
26 #include "clientserver.h" |
|
27 #include "log.h" |
|
28 #include "config.h" |
|
29 |
|
30 enum TIoPanicReason |
|
31 { |
|
32 EPanicBadDescriptor = 0, |
|
33 EPanicBadHandle = 1, |
|
34 EPanicUnknownOpcode = 2, |
|
35 EPanicReadAlreadyPending = 3, |
|
36 EPanicReadKeyAlreadyPending = 4, |
|
37 EPanicReadWhenNotAttached = 5, |
|
38 EPanicWriteAlreadyPending = 6, |
|
39 EPanicWriteWhenNotAttached = 7, |
|
40 EPanicReadKeyWhenNotAttached = 8, |
|
41 EPanicCursorPosWhenNotAttached = 9, |
|
42 EPanicSetCursorPosAbsWhenNotAttached = 10, |
|
43 EPanicSetCursorPosRelWhenNotAttached = 11, |
|
44 EPanicSetCursorHeightWhenNotAttached = 12, |
|
45 EPanicSetTitleWhenNotAttached = 13, |
|
46 EPanicClearScreenWhenNotAttached = 14, |
|
47 EPanicClearToEndOfLineWhenNotAttached = 15, |
|
48 EPanicScreenSizeWhenNotAttached = 16, |
|
49 EPanicInvalidPipeId = 17, |
|
50 EPanicSetConsoleModeWhenNotAttached = 18, |
|
51 EPanicNotAnEndPoint = 19, |
|
52 EPanicNotAPipe = 20, |
|
53 EPanicNotAConsole = 21, |
|
54 EPanicNotAReadWriteObject = 22, |
|
55 EPanicNotAReadObject = 23, |
|
56 EPanicNotAWriteObject = 24, |
|
57 EPanicNotAPersistentConsole = 25, |
|
58 EPanicNotAValidContainerType = 26, |
|
59 EPanicFindNextWithNoFindFirst = 27, |
|
60 EPanicOpenFoundWithNoFind = 28, |
|
61 EPanicSetTitleAlreadyPending = 29, |
|
62 EPanicCursorPosAlreadyPending = 30, |
|
63 EPanicSetCursorPosAlreadyPending = 31, |
|
64 EPanicSetCursorHeightAlreadyPending = 32, |
|
65 EPanicClearScreenAlreadyPending = 33, |
|
66 EPanicClearToEndOfLineAlreadyPending = 34, |
|
67 EPanicScreenSizeAlreadyPending = 35, |
|
68 EPanicSetReadModeAlreadyPending = 36, |
|
69 EPanicCannotReadFromUnderlyingConsole = 37, |
|
70 EPanicSetAttributesWhenNotAttached = 38, |
|
71 EPanicSetAttributesAlreadyPending = 39, |
|
72 EPanicSetModeAlreadyPending = 40 |
|
73 }; |
|
74 |
|
75 void PanicClient(const RMsg& aMessage, TIoPanicReason aReason); |
|
76 |
|
77 class CIoObject; |
|
78 class CIoLog; |
|
79 class CIoPipe; |
|
80 class CIoConsole; |
|
81 class CIoFile; |
|
82 class CIoNull; |
|
83 class CIoPersistentConsole; |
|
84 class CIoReadWriteObject; |
|
85 class CIoReadObject; |
|
86 class CIoWriteObject; |
|
87 class MIoWriteEndPoint; |
|
88 |
|
89 class CShutdownTimer : public CTimer |
|
90 { |
|
91 enum {KShutdownDelay = 0x2000000}; |
|
92 public: |
|
93 CShutdownTimer(); |
|
94 void ConstructL(); |
|
95 void Start(); |
|
96 private: |
|
97 void RunL(); |
|
98 }; |
|
99 |
|
100 |
|
101 #ifdef EKA2 |
|
102 class CIoServer : public CServer2 |
|
103 #else |
|
104 class CIoServer : public CServer |
|
105 #endif |
|
106 { |
|
107 public: |
|
108 #ifdef EKA2 |
|
109 static CServer2* NewLC(); |
|
110 #else |
|
111 static CServer* NewLC(); |
|
112 #endif |
|
113 ~CIoServer(); |
|
114 void AddSession(); |
|
115 void DropSession(); |
|
116 CIoPipe& CreatePipeLC(); |
|
117 CIoConsole& CreateConsoleLC(const TDesC& aImplementation, const TDesC& aTitle, TSize aSize, MIoWriteEndPoint* aUnderlyingConsole, TUint aOptions); |
|
118 CIoFile& CreateFileLC(const TDesC& aName, RIoFile::TMode aMode); |
|
119 CIoNull& CreateNullLC(); |
|
120 CIoPersistentConsole& CreatePersistentConsoleLC(const TDesC& aName, const TDesC& aTitle, const RMsg& aMessage); |
|
121 CIoReadObject& CreateReadObjLC(); |
|
122 CIoWriteObject& CreateWriteObjLC(); |
|
123 CIoReadObject* NextReadObj(TThreadId aOwningThread) const; |
|
124 CIoWriteObject* NextWriteObj(TThreadId aOwningThread) const; |
|
125 CIoReadObject* LastOpenedReadObj(TThreadId aOwningThread) const; |
|
126 CIoWriteObject* LastOpenedWriteObj(TThreadId aOwningThread) const; |
|
127 CIoPersistentConsole& FindPersistentConsoleL(const TDesC& aName); |
|
128 CIoObject* FindObjectByName(RIoHandle::TType aType, TInt& aFindHandle, const TDesC& aMatch, TName& aName) const; |
|
129 CIoObject& OpenObjectLC(TInt aFindHandle); |
|
130 const TIoConfig& Config(); |
|
131 void PersistentConsoleAddL(const TDesC16& aName, const CIoPersistentConsole& aCons); |
|
132 void PersistentConsoleRemove(const TDesC16& aName, const CIoPersistentConsole& aCons); |
|
133 private: |
|
134 CIoServer(); |
|
135 void ConstructL(); |
|
136 #ifdef EKA2 |
|
137 virtual CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
|
138 #else |
|
139 virtual CSharableSession* NewSessionL(const TVersion& aVersion) const; |
|
140 #endif |
|
141 TInt RunError(TInt aError); |
|
142 CIoReadWriteObject* DoFindObj(RIoHandle::TType aType, TThreadId aOwningThread, TBool aNext) const; |
|
143 private: |
|
144 RFs iFs; |
|
145 TInt iSessionCount; |
|
146 CShutdownTimer iShutdownTimer; |
|
147 CObjectConIx* iIoObjectContainerIndex; |
|
148 CObjectCon* iIoObjectContainer; |
|
149 TUint iNextReadObjId; |
|
150 TUint iNextWriteObjId; |
|
151 TIoConfig iConfig; |
|
152 RPtrHashMap<TDesC16, CIoPersistentConsole> iPersistentConsoleNames; |
|
153 #ifdef IOSRV_LOGGING |
|
154 CIoLog* iLog; |
|
155 #endif |
|
156 }; |
|
157 |
|
158 |
|
159 TInt DesLengthL(const RMsg& aMessage, TInt aParam); |
|
160 TInt MaxDesLengthL(const RMsg& aMessage, TInt aParam); |
|
161 void MessageReadL(const RMsg& aMessage, TInt aParam, TDes8& aDes); |
|
162 void MessageReadL(const RMsg& aMessage, TInt aParam, TDes8& aDes, TInt aOffset); |
|
163 void MessageReadL(const RMsg& aMessage, TInt aParam, TDes16& aDes); |
|
164 void MessageReadL(const RMsg& aMessage, TInt aParam, TDes16& aDes, TInt aOffset); |
|
165 void MessageWriteL(const RMsg& aMessage, TInt aParam, const TDesC8& aDes); |
|
166 void MessageWriteL(const RMsg& aMessage, TInt aParam, const TDesC16& aDes); |
|
167 TInt MessageWrite(const RMsg& aMessage, TInt aParam, const TDesC8& aDes); |
|
168 TInt MessageWrite(const RMsg& aMessage, TInt aParam, const TDesC16& aDes); |
|
169 TBool MessagePending(const RMsg& aMessage); |
|
170 TThreadId ClientThreadIdL(const RMsg& aMessage); |
|
171 TFullName ClientNameL(const RMsg& aMessage); |
|
172 void Complete(const RMsg& aMessage, TInt aError); |
|
173 void CompleteIfPending(const RMsg& aMessage, TInt aError); |
|
174 |
|
175 #endif // __SERVER_H__ |
|
176 |