|
1 // clientserver.cpp |
|
2 // |
|
3 // Copyright (c) 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 #include "clientserver.h" |
|
14 |
|
15 |
|
16 _LIT(KDefaultServerName, "guicons"); |
|
17 |
|
18 //______________________________________________________________________________ |
|
19 // This function prodes the regular console DLL interface; it MUST be the first |
|
20 // export. |
|
21 EXPORT_C TAny* NewConsole() |
|
22 { |
|
23 return new CGuiConsClient; |
|
24 } |
|
25 |
|
26 //______________________________________________________________________________ |
|
27 // CGuiConsClient |
|
28 CGuiConsClient::CGuiConsClient() |
|
29 { |
|
30 } |
|
31 |
|
32 TInt CGuiConsClient::Create(const TDesC &aTitle, TSize aSize) |
|
33 { |
|
34 //TODO parse title for server name, font, etc |
|
35 TInt r = iConsole.Connect(KDefaultServerName); |
|
36 if (r==KErrNone) |
|
37 { |
|
38 r = CConsoleProxy::Create(aTitle, aSize); |
|
39 } |
|
40 return r; |
|
41 } |
|
42 |
|
43 |
|
44 EXPORT_C CServer2* StartGuiConsServerL(const TDesC& aServerName, MConsoleUi& aConsoleUi) |
|
45 { |
|
46 CConsoleProxyServer* server = CGuiConsServer::NewL(aServerName, aConsoleUi); |
|
47 return server; |
|
48 } |
|
49 |
|
50 //______________________________________________________________________________ |
|
51 // CGuiConsServer |
|
52 CGuiConsServer* CGuiConsServer::NewL(const TDesC& aServerName, MConsoleUi& aConsoleUi) |
|
53 { |
|
54 CGuiConsServer* self = new(ELeave)CGuiConsServer(aConsoleUi); |
|
55 CleanupStack::PushL(self); |
|
56 self->ConstructL(aServerName); |
|
57 CleanupStack::Pop(self); |
|
58 return self; |
|
59 } |
|
60 |
|
61 CGuiConsServer::~CGuiConsServer() |
|
62 { |
|
63 } |
|
64 |
|
65 void CGuiConsServer::ShutdownTimerExpired() |
|
66 { |
|
67 // we don't want to do anything here, we want the UI app to remain after all consoles have closed. |
|
68 } |
|
69 |
|
70 CGuiConsServer::CGuiConsServer(MConsoleUi& aConsoleUi) |
|
71 // set the AO priority higher than CCoeRedrawer so that multiple writes from the client only cause |
|
72 // a single redraw of the console, improving performance. |
|
73 : CConsoleProxyServer(NULL, EActivePriorityRedrawEvents+1) |
|
74 , iUi(aConsoleUi) |
|
75 { |
|
76 } |
|
77 |
|
78 CSession2* CGuiConsServer::NewSessionL(const TVersion&, const RMessage2&) const |
|
79 { |
|
80 return new(ELeave)CGuiConsSession(iUi); |
|
81 } |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 //______________________________________________________________________________ |
|
87 // CGuiConsSession |
|
88 CGuiConsSession::CGuiConsSession(MConsoleUi& aConsoleUi) |
|
89 : CConsoleProxySession((TConsoleCreateFunction)NULL), iUi(aConsoleUi) |
|
90 { |
|
91 } |
|
92 |
|
93 CGuiConsSession::~CGuiConsSession() |
|
94 { |
|
95 } |
|
96 |
|
97 MProxiedConsole* CGuiConsSession::InstantiateConsoleL() |
|
98 { |
|
99 CCoeEnv::Static()->RootWin().SetOrdinalPosition(0); |
|
100 |
|
101 const TDesC& fontFile(iUi.GetConsoleFont()); |
|
102 CConsoleControl* control; |
|
103 if (fontFile.Length()) |
|
104 { |
|
105 control = CConsoleControl::NewL(iUi.GetConsoleBufferSize(), fontFile, &iUi); |
|
106 } |
|
107 else |
|
108 { |
|
109 control = CConsoleControl::NewL(iUi.GetConsoleBufferSize(), &iUi); |
|
110 } |
|
111 CleanupStack::PushL(control); |
|
112 MProxiedConsole* result = new(ELeave)CGuiConsole(*control); |
|
113 CleanupStack::Pop(control); |
|
114 return result; |
|
115 } |
|
116 |
|
117 void CGuiConsSession::ConsoleCreatedL(MProxiedConsole* aConsole) |
|
118 { |
|
119 iUi.HandleNewConsoleL(&((CGuiConsole*)aConsole)->Control()); |
|
120 } |
|
121 |