|
1 // config.cpp |
|
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 #include "config.h" |
|
14 #include <fshell/settings.h> |
|
15 |
|
16 |
|
17 // Default values (used if the config file can't be read). |
|
18 _LIT(KDefaultConsole, "defcons.dll"); |
|
19 const TSize KDefaultSizeAdjustment(0, 0); |
|
20 |
|
21 // Config file details. |
|
22 _LIT(KConfigFileName, "\\system\\console\\iosrv.ini"); |
|
23 _LIT(KConfigDescriptionFile, "\\resource\\iosrv.idf"); |
|
24 |
|
25 // Configuration attributes. |
|
26 _LIT(KAttConsole, "console"); |
|
27 _LIT(KAttConsoleSizeAdjustment, "console_size_adjustment"); |
|
28 _LIT(KAttConsoleSizeDetect, "console_size_detect"); |
|
29 |
|
30 |
|
31 TIoConfig::TIoConfig() |
|
32 : iConsoleImplementation(KDefaultConsole), iConsoleSizeAdjustment(KDefaultSizeAdjustment), iConsoleSizeDetect(ETrue) |
|
33 { |
|
34 } |
|
35 |
|
36 TInt TIoConfig::Init() |
|
37 { |
|
38 LtkUtils::CIniFile* iniFile = NULL; |
|
39 TRAPD(ret, iniFile = LtkUtils::CIniFile::NewL(KConfigFileName, KConfigDescriptionFile)); |
|
40 if (ret == KErrNone) ret = DoInit(iniFile); |
|
41 delete iniFile; |
|
42 return ret; |
|
43 } |
|
44 |
|
45 TInt TIoConfig::DoInit(LtkUtils::CIniFile* iniFile) |
|
46 { |
|
47 TInt ret = KErrNone; |
|
48 iConsoleImplementation.Copy(iniFile->GetString(KAttConsole).Left(iConsoleImplementation.MaxLength())); |
|
49 iConsoleSizeDetect = iniFile->GetBool(KAttConsoleSizeDetect); |
|
50 const TDesC& sizeAdjust(iniFile->GetString(KAttConsoleSizeAdjustment)); |
|
51 if (sizeAdjust.Length()) |
|
52 { |
|
53 TLex lex(sizeAdjust); |
|
54 ret = lex.Val(iConsoleSizeAdjustment.iWidth); |
|
55 if (ret) return ret; |
|
56 lex.Get(); // Skip delimiter. |
|
57 ret = lex.Val(iConsoleSizeAdjustment.iHeight); |
|
58 if (ret) return ret; |
|
59 iConsoleSizeDetect = EFalse; |
|
60 } |
|
61 return ret; |
|
62 } |
|
63 |
|
64 const TDesC& TIoConfig::ConsoleImplementation() const |
|
65 { |
|
66 return iConsoleImplementation; |
|
67 } |
|
68 |
|
69 const TSize& TIoConfig::ConsoleSizeAdjustment() const |
|
70 { |
|
71 return iConsoleSizeAdjustment; |
|
72 } |
|
73 |
|
74 TBool TIoConfig::ConsoleSizeDetect() const |
|
75 { |
|
76 return iConsoleSizeDetect; |
|
77 } |