|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <eikchlst.h> |
|
19 #include <eikdef.h> |
|
20 #include <eikenv.h> |
|
21 #include "CTcIAPManager.h" |
|
22 |
|
23 #include "CTcSettingsDialog.h" |
|
24 #include "TTcSettings.h" |
|
25 #include "TestClient.hrh" |
|
26 #include <TestClient.rsg> |
|
27 |
|
28 CTcSettingsDialog::CTcSettingsDialog( TTcSettings& aSettings ) |
|
29 : iSettings( aSettings ) |
|
30 { |
|
31 } |
|
32 |
|
33 CTcSettingsDialog::~CTcSettingsDialog() |
|
34 { |
|
35 delete iIAPManager; |
|
36 } |
|
37 |
|
38 void CTcSettingsDialog::ConstructL() |
|
39 { |
|
40 iIAPManager = CTcIAPManager::NewL(); |
|
41 } |
|
42 |
|
43 void CTcSettingsDialog::PreLayoutDynInitL() |
|
44 { |
|
45 CEikChoiceList* iapList = |
|
46 reinterpret_cast< CEikChoiceList* >( Control( ECtrlIAPName ) ); |
|
47 |
|
48 CDesCArray* names = iapList->DesCArray(); |
|
49 names->Delete( 0 ); // delete dummy item from array |
|
50 |
|
51 TInt count = iIAPManager->MdcaCount(); |
|
52 for( TInt i = 0; i < count; i++ ) |
|
53 { |
|
54 TBuf< KCommsDbSvrMaxFieldLength > name16; |
|
55 name16.Copy( iIAPManager->MdcaPoint( i ) ); |
|
56 names->AppendL( name16 ); |
|
57 if( (TInt)iIAPManager->Id( i ) == iSettings.iIAPId ) |
|
58 { |
|
59 iapList->SetCurrentItem( i ); |
|
60 } |
|
61 } |
|
62 |
|
63 SetChoiceListCurrentItem( ECtrlConnection, iSettings.iBearerType ); |
|
64 |
|
65 TBuf<40> remoteAddrText; |
|
66 iSettings.iTCPRemoteAddr.Output( remoteAddrText ); |
|
67 SetEdwinTextL(ECtrlRemoteAddr, &remoteAddrText); |
|
68 |
|
69 SetNumberEditorValue( ECtrlTcpPort, iSettings.iTCPPort ); |
|
70 |
|
71 SetChoiceListCurrentItem( ECtrlCSYName, iSettings.iCSYName ); |
|
72 SetChoiceListCurrentItem( ECtrlCommPort, iSettings.iCommPort ); |
|
73 SetNumberEditorValue( ECtrlBaudrate, iSettings.iBaudrate ); |
|
74 |
|
75 TInt autoconnect( 1 ); |
|
76 if( !iSettings.iAutoConnect ) |
|
77 { |
|
78 autoconnect = 0; // no autoconnect |
|
79 } |
|
80 SetChoiceListCurrentItem( ECtrlAutoConnect, autoconnect ); |
|
81 } |
|
82 |
|
83 TBool CTcSettingsDialog::OkToExitL( TInt /*aKeycode*/ ) |
|
84 { |
|
85 CEikChoiceList* iapList = |
|
86 reinterpret_cast< CEikChoiceList* >( Control( ECtrlIAPName ) ); |
|
87 iSettings.iIAPId = iIAPManager->Id( iapList->CurrentItem() ); |
|
88 |
|
89 iSettings.iBearerType = ChoiceListCurrentItem( ECtrlConnection ); |
|
90 |
|
91 TBuf<40> remoteAddrText; |
|
92 GetEdwinText(remoteAddrText, ECtrlRemoteAddr); |
|
93 if (KErrNone != iSettings.iTCPRemoteAddr.Input(remoteAddrText)) |
|
94 { |
|
95 _LIT(KInvalidAddressText, "Invalid remote IP"); |
|
96 CEikonEnv::Static()->AlertWin(KInvalidAddressText); |
|
97 return EFalse; |
|
98 } |
|
99 |
|
100 iSettings.iTCPPort = NumberEditorValue( ECtrlTcpPort ); |
|
101 |
|
102 iSettings.iCSYName = ChoiceListCurrentItem( ECtrlCSYName ); |
|
103 |
|
104 iSettings.iCommPort = ChoiceListCurrentItem( ECtrlCommPort ); |
|
105 |
|
106 iSettings.iBaudrate = NumberEditorValue( ECtrlBaudrate ); |
|
107 |
|
108 if( ChoiceListCurrentItem( ECtrlAutoConnect ) == 1 ) |
|
109 { |
|
110 iSettings.iAutoConnect = ETrue; |
|
111 } |
|
112 else |
|
113 { |
|
114 iSettings.iAutoConnect = EFalse; |
|
115 } |
|
116 |
|
117 iSettings.Store(); |
|
118 return ETrue; |
|
119 } |
|
120 |