e8545ecc3abceeba3d4833cf91361b326a7e6c0a
[reactos.git] / win32ss / user / winsrv / consrv / frontendctl.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: win32ss/user/winsrv/consrv/frontendctl.c
5 * PURPOSE: Terminal Front-Ends Control
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include "consrv.h"
12
13 #define NDEBUG
14 #include <debug.h>
15
16 /* PUBLIC SERVER APIS *********************************************************/
17
18 /**********************************************************************
19 * HardwareStateProperty
20 *
21 * DESCRIPTION
22 * Set/Get the value of the HardwareState and switch
23 * between direct video buffer ouput and GDI windowed
24 * output.
25 * ARGUMENTS
26 * Client hands us a CONSOLE_GETSETHWSTATE object.
27 * We use the same object to Request.
28 * NOTE
29 * ConsoleHwState has the correct size to be compatible
30 * with NT's, but values are not.
31 */
32 #if 0
33 static NTSTATUS
34 SetConsoleHardwareState(PCONSOLE Console, ULONG ConsoleHwState)
35 {
36 DPRINT1("Console Hardware State: %d\n", ConsoleHwState);
37
38 if ((CONSOLE_HARDWARE_STATE_GDI_MANAGED == ConsoleHwState)
39 ||(CONSOLE_HARDWARE_STATE_DIRECT == ConsoleHwState))
40 {
41 if (Console->HardwareState != ConsoleHwState)
42 {
43 /* TODO: implement switching from full screen to windowed mode */
44 /* TODO: or back; now simply store the hardware state */
45 Console->HardwareState = ConsoleHwState;
46 }
47
48 return STATUS_SUCCESS;
49 }
50
51 return STATUS_INVALID_PARAMETER_3; /* Client: (handle, set_get, [mode]) */
52 }
53 #endif
54
55 CSR_API(SrvGetConsoleHardwareState)
56 {
57 #if 0
58 NTSTATUS Status;
59 PCONSOLE_GETSETHWSTATE HardwareStateRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HardwareStateRequest;
60 PCONSOLE_SCREEN_BUFFER Buff;
61 PCONSOLE Console;
62
63 Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
64 HardwareStateRequest->OutputHandle,
65 &Buff,
66 GENERIC_READ,
67 TRUE);
68 if (!NT_SUCCESS(Status))
69 {
70 DPRINT1("Failed to get console handle in SrvGetConsoleHardwareState\n");
71 return Status;
72 }
73
74 Console = Buff->Header.Console;
75 HardwareStateRequest->State = Console->HardwareState;
76
77 ConSrvReleaseScreenBuffer(Buff, TRUE);
78 return Status;
79 #else
80 UNIMPLEMENTED;
81 return STATUS_NOT_IMPLEMENTED;
82 #endif
83 }
84
85 CSR_API(SrvSetConsoleHardwareState)
86 {
87 #if 0
88 NTSTATUS Status;
89 PCONSOLE_GETSETHWSTATE HardwareStateRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HardwareStateRequest;
90 PCONSOLE_SCREEN_BUFFER Buff;
91 PCONSOLE Console;
92
93 Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
94 HardwareStateRequest->OutputHandle,
95 &Buff,
96 GENERIC_WRITE,
97 TRUE);
98 if (!NT_SUCCESS(Status))
99 {
100 DPRINT1("Failed to get console handle in SrvSetConsoleHardwareState\n");
101 return Status;
102 }
103
104 DPRINT("Setting console hardware state.\n");
105 Console = Buff->Header.Console;
106 Status = SetConsoleHardwareState(Console, HardwareStateRequest->State);
107
108 ConSrvReleaseScreenBuffer(Buff, TRUE);
109 return Status;
110 #else
111 UNIMPLEMENTED;
112 return STATUS_NOT_IMPLEMENTED;
113 #endif
114 }
115
116 CSR_API(SrvGetConsoleDisplayMode)
117 {
118 NTSTATUS Status;
119 PCONSOLE_GETDISPLAYMODE GetDisplayModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetDisplayModeRequest;
120 PCONSOLE Console;
121
122 Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
123 &Console, TRUE);
124 if (!NT_SUCCESS(Status)) return Status;
125
126 GetDisplayModeRequest->DisplayMode = TermGetDisplayMode(Console);
127
128 ConSrvReleaseConsole(Console, TRUE);
129 return STATUS_SUCCESS;
130 }
131
132 CSR_API(SrvSetConsoleDisplayMode)
133 {
134 NTSTATUS Status;
135 PCONSOLE_SETDISPLAYMODE SetDisplayModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetDisplayModeRequest;
136 PCONSOLE Console;
137 PCONSOLE_SCREEN_BUFFER Buff;
138
139 Status = ConSrvGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
140 SetDisplayModeRequest->OutputHandle,
141 &Buff,
142 GENERIC_WRITE,
143 TRUE);
144 if (!NT_SUCCESS(Status)) return Status;
145
146 Console = Buff->Header.Console;
147
148 if (TermSetDisplayMode(Console, SetDisplayModeRequest->DisplayMode))
149 {
150 SetDisplayModeRequest->NewSBDim = Buff->ScreenBufferSize;
151 Status = STATUS_SUCCESS;
152 }
153 else
154 {
155 Status = STATUS_INVALID_PARAMETER;
156 }
157
158 ConSrvReleaseScreenBuffer(Buff, TRUE);
159 return Status;
160 }
161
162 CSR_API(SrvGetLargestConsoleWindowSize)
163 {
164 NTSTATUS Status;
165 PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetLargestWindowSizeRequest;
166 PCONSOLE_SCREEN_BUFFER Buff;
167 PCONSOLE Console;
168
169 Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
170 GetLargestWindowSizeRequest->OutputHandle,
171 &Buff,
172 GENERIC_READ,
173 TRUE);
174 if (!NT_SUCCESS(Status)) return Status;
175
176 Console = Buff->Header.Console;
177 TermGetLargestConsoleWindowSize(Console, &GetLargestWindowSizeRequest->Size);
178
179 ConSrvReleaseScreenBuffer(Buff, TRUE);
180 return STATUS_SUCCESS;
181 }
182
183 CSR_API(SrvShowConsoleCursor)
184 {
185 NTSTATUS Status;
186 PCONSOLE_SHOWCURSOR ShowCursorRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ShowCursorRequest;
187 PCONSOLE Console;
188 PCONSOLE_SCREEN_BUFFER Buff;
189
190 Status = ConSrvGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
191 ShowCursorRequest->OutputHandle,
192 &Buff,
193 GENERIC_WRITE,
194 TRUE);
195 if (!NT_SUCCESS(Status)) return Status;
196
197 Console = Buff->Header.Console;
198
199 ShowCursorRequest->RefCount = TermShowMouseCursor(Console, ShowCursorRequest->Show);
200
201 ConSrvReleaseScreenBuffer(Buff, TRUE);
202 return STATUS_SUCCESS;
203 }
204
205 CSR_API(SrvSetConsoleCursor)
206 {
207 NTSTATUS Status;
208 BOOL Success;
209 PCONSOLE_SETCURSOR SetCursorRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetCursorRequest;
210 PCONSOLE Console;
211 PCONSOLE_SCREEN_BUFFER Buff;
212
213 // FIXME: Tests show that this function is used only for graphics screen buffers
214 // and otherwise it returns FALSE + sets last error to invalid handle.
215 // NOTE: I find that behaviour is ridiculous but ok, let's accept that at the moment...
216 Status = ConSrvGetGraphicsBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
217 SetCursorRequest->OutputHandle,
218 &Buff,
219 GENERIC_WRITE,
220 TRUE);
221 if (!NT_SUCCESS(Status)) return Status;
222
223 Console = Buff->Header.Console;
224
225 Success = TermSetMouseCursor(Console, SetCursorRequest->CursorHandle);
226
227 ConSrvReleaseScreenBuffer(Buff, TRUE);
228 return (Success ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL);
229 }
230
231 CSR_API(SrvConsoleMenuControl)
232 {
233 NTSTATUS Status;
234 PCONSOLE_MENUCONTROL MenuControlRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.MenuControlRequest;
235 PCONSOLE Console;
236 PCONSOLE_SCREEN_BUFFER Buff;
237
238 Status = ConSrvGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
239 MenuControlRequest->OutputHandle,
240 &Buff,
241 GENERIC_WRITE,
242 TRUE);
243 if (!NT_SUCCESS(Status)) return Status;
244
245 Console = Buff->Header.Console;
246
247 MenuControlRequest->MenuHandle = TermMenuControl(Console,
248 MenuControlRequest->CmdIdLow,
249 MenuControlRequest->CmdIdHigh);
250
251 ConSrvReleaseScreenBuffer(Buff, TRUE);
252 return STATUS_SUCCESS;
253 }
254
255 CSR_API(SrvSetConsoleMenuClose)
256 {
257 NTSTATUS Status;
258 BOOL Success;
259 PCONSOLE_SETMENUCLOSE SetMenuCloseRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetMenuCloseRequest;
260 PCONSOLE Console;
261
262 Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
263 &Console, TRUE);
264 if (!NT_SUCCESS(Status)) return Status;
265
266 Success = TermSetMenuClose(Console, SetMenuCloseRequest->Enable);
267
268 ConSrvReleaseConsole(Console, TRUE);
269 return (Success ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL);
270 }
271
272 CSR_API(SrvGetConsoleWindow)
273 {
274 NTSTATUS Status;
275 PCONSOLE_GETWINDOW GetWindowRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetWindowRequest;
276 PCONSOLE Console;
277
278 Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
279 if (!NT_SUCCESS(Status)) return Status;
280
281 GetWindowRequest->WindowHandle = TermGetConsoleWindowHandle(Console);
282
283 ConSrvReleaseConsole(Console, TRUE);
284 return STATUS_SUCCESS;
285 }
286
287 CSR_API(SrvSetConsoleIcon)
288 {
289 NTSTATUS Status;
290 PCONSOLE_SETICON SetIconRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetIconRequest;
291 PCONSOLE Console;
292
293 Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
294 if (!NT_SUCCESS(Status)) return Status;
295
296 Status = (TermChangeIcon(Console, SetIconRequest->IconHandle)
297 ? STATUS_SUCCESS
298 : STATUS_UNSUCCESSFUL);
299
300 ConSrvReleaseConsole(Console, TRUE);
301 return Status;
302 }
303
304 CSR_API(SrvGetConsoleSelectionInfo)
305 {
306 NTSTATUS Status;
307 PCONSOLE_GETSELECTIONINFO GetSelectionInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetSelectionInfoRequest;
308 PCONSOLE Console;
309
310 Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
311 if (!NT_SUCCESS(Status)) return Status;
312
313 Status = (TermGetSelectionInfo(Console, &GetSelectionInfoRequest->Info)
314 ? STATUS_SUCCESS
315 : STATUS_UNSUCCESSFUL);
316
317 ConSrvReleaseConsole(Console, TRUE);
318 return Status;
319 }
320
321
322
323 CSR_API(SrvGetConsoleNumberOfFonts)
324 {
325 DPRINT1("%s not yet implemented\n", __FUNCTION__);
326 return STATUS_NOT_IMPLEMENTED;
327 }
328
329 CSR_API(SrvGetConsoleFontInfo)
330 {
331 DPRINT1("%s not yet implemented\n", __FUNCTION__);
332 return STATUS_NOT_IMPLEMENTED;
333 }
334
335 CSR_API(SrvGetConsoleFontSize)
336 {
337 DPRINT1("%s not yet implemented\n", __FUNCTION__);
338 return STATUS_NOT_IMPLEMENTED;
339 }
340
341 CSR_API(SrvGetConsoleCurrentFont)
342 {
343 DPRINT1("%s not yet implemented\n", __FUNCTION__);
344 return STATUS_NOT_IMPLEMENTED;
345 }
346
347 CSR_API(SrvSetConsoleFont)
348 {
349 DPRINT1("%s not yet implemented\n", __FUNCTION__);
350 return STATUS_NOT_IMPLEMENTED;
351 }
352
353 /* EOF */