1 /* |
|
2 * Copyright (c) 2005 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: Data Call Settings model implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "GSDataCallPluginModel.h" |
|
21 |
|
22 #include <commdb.h> |
|
23 #include <cdbcols.h> |
|
24 |
|
25 #include <settingsinternalcrkeys.h> |
|
26 |
|
27 // EXTERNAL DATA STRUCTURES |
|
28 |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // MACROS |
|
34 |
|
35 // LOCAL CONSTANTS AND MACROS |
|
36 // Autodisconnect time |
|
37 const TUint8 KGSOneSecond = 1; |
|
38 const TUint8 KGSSecondsInMinute = 60; |
|
39 const TUint KGSMaxTimeInSeconds = 5940; |
|
40 //const TUint8 KGSMaxTimeInMinutes = 99; |
|
41 |
|
42 _LIT( KGSCSDModem, "CSD Modem" ); |
|
43 |
|
44 // MODULE DATA STRUCTURES |
|
45 |
|
46 // LOCAL FUNCTION PROTOTYPES |
|
47 |
|
48 // FORWARD DECLARATIONS |
|
49 |
|
50 // ============================= LOCAL FUNCTIONS ============================== |
|
51 |
|
52 // ========================= MEMBER FUNCTIONS ================================= |
|
53 |
|
54 // ---------------------------------------------------------------------------- |
|
55 // CGSDataCallPluginModel::NewL |
|
56 // |
|
57 // Symbian OS two-phased constructor |
|
58 // ---------------------------------------------------------------------------- |
|
59 // |
|
60 CGSDataCallPluginModel* CGSDataCallPluginModel::NewL() |
|
61 { |
|
62 CGSDataCallPluginModel* self = new( ELeave ) CGSDataCallPluginModel; |
|
63 CleanupStack::PushL( self ); |
|
64 self->ConstructL(); |
|
65 |
|
66 CleanupStack::Pop( self ); |
|
67 return self; |
|
68 } |
|
69 |
|
70 |
|
71 // ---------------------------------------------------------------------------- |
|
72 // CGSDataCallPluginModel::CGSDataCallPluginModel |
|
73 // |
|
74 // |
|
75 // C++ default constructor can NOT contain any code, that might leave. |
|
76 // ---------------------------------------------------------------------------- |
|
77 // |
|
78 CGSDataCallPluginModel::CGSDataCallPluginModel() |
|
79 { |
|
80 } |
|
81 |
|
82 |
|
83 // ---------------------------------------------------------------------------- |
|
84 // CGSDataCallPluginModel::ConstructL |
|
85 // |
|
86 // Symbian OS default constructor can leave. |
|
87 // ---------------------------------------------------------------------------- |
|
88 // |
|
89 void CGSDataCallPluginModel::ConstructL() |
|
90 { |
|
91 iCommDb = CCommsDatabase::NewL( EDatabaseTypeIAP ); |
|
92 } |
|
93 |
|
94 |
|
95 // ---------------------------------------------------------------------------- |
|
96 // CGSDataCallPluginModel::~CGSDataCallPluginModel |
|
97 // |
|
98 // Destructor |
|
99 // ---------------------------------------------------------------------------- |
|
100 // |
|
101 CGSDataCallPluginModel::~CGSDataCallPluginModel() |
|
102 { |
|
103 delete iCommDb; |
|
104 } |
|
105 |
|
106 |
|
107 // ---------------------------------------------------------------------------- |
|
108 // CGSDataCallPluginModel::AutodisconnectTimeL |
|
109 // |
|
110 // Gets autodisconnect time. |
|
111 // ---------------------------------------------------------------------------- |
|
112 // |
|
113 TInt CGSDataCallPluginModel::AutodisconnectTimeL() |
|
114 { |
|
115 CCommsDbTableView* table = iCommDb->OpenViewMatchingTextLC( |
|
116 TPtrC( MODEM_BEARER ), |
|
117 TPtrC( COMMDB_NAME ), KGSCSDModem ); |
|
118 |
|
119 User::LeaveIfError( table->GotoFirstRecord() ); |
|
120 |
|
121 TUint32 timeOutValue = 0; |
|
122 table->ReadUintL( TPtrC( LAST_SOCKET_ACTIVITY_TIMEOUT ), timeOutValue ); |
|
123 CleanupStack::PopAndDestroy( table ); |
|
124 |
|
125 TInt timeInMinutes; |
|
126 |
|
127 if ( timeOutValue < KGSOneSecond ) |
|
128 { |
|
129 timeInMinutes = static_cast<TInt> ( KGSTimeUnlimited ); |
|
130 |
|
131 if ( timeOutValue != KGSTimeUnlimited ) |
|
132 { |
|
133 SetAutodisconnectTimeL( KGSTimeUnlimited ); |
|
134 } |
|
135 } |
|
136 else if ( timeOutValue < KGSSecondsInMinute ) |
|
137 { |
|
138 timeInMinutes = KGSOneMinute; |
|
139 } |
|
140 else if ( timeOutValue < KGSMaxTimeInSeconds ) |
|
141 { |
|
142 timeInMinutes = timeOutValue/KGSSecondsInMinute; |
|
143 } |
|
144 else |
|
145 { |
|
146 timeInMinutes = static_cast<TInt> ( KGSTimeUnlimited ); |
|
147 } |
|
148 return timeInMinutes; |
|
149 } |
|
150 |
|
151 |
|
152 // ---------------------------------------------------------------------------- |
|
153 // CGSDataCallPluginModel::SetAutodisconnectTimeL |
|
154 // |
|
155 // Sets autodisconnect time. |
|
156 // ---------------------------------------------------------------------------- |
|
157 // |
|
158 TBool CGSDataCallPluginModel::SetAutodisconnectTimeL( const TInt aTime ) |
|
159 { |
|
160 TInt time; |
|
161 |
|
162 if ( aTime >= KGSOneMinute ) |
|
163 { |
|
164 time = aTime * KGSSecondsInMinute; |
|
165 } |
|
166 else |
|
167 { |
|
168 time = static_cast<TInt> ( KGSTimeUnlimited ); |
|
169 } |
|
170 |
|
171 CCommsDbTableView* table = iCommDb->OpenViewMatchingTextLC( |
|
172 TPtrC( MODEM_BEARER ), |
|
173 TPtrC( COMMDB_NAME ), KGSCSDModem ); |
|
174 |
|
175 User::LeaveIfError( table->GotoFirstRecord() ); |
|
176 User::LeaveIfError( table->UpdateRecord() ); |
|
177 table->WriteUintL( TPtrC( LAST_SOCKET_ACTIVITY_TIMEOUT ), time ); |
|
178 table->WriteUintL( TPtrC( LAST_SOCKET_CLOSED_TIMEOUT ), time ); |
|
179 User::LeaveIfError( table->PutRecordChanges() ); |
|
180 CleanupStack::PopAndDestroy( table ); |
|
181 |
|
182 return ETrue; |
|
183 } |
|
184 |
|
185 |
|
186 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
187 |
|
188 // End of File |
|