|
1 /* |
|
2 * Copyright (c) 2008-2009 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: This module contains the implementation of CIAUpdateAutomaticCheck class |
|
15 * member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 //INCLUDES |
|
22 |
|
23 #include "iaupdateautomaticcheck.h" |
|
24 #include "iaupdatedialogutil.h" |
|
25 #include "iaupdatefirsttimeinfo.h" |
|
26 #include "iaupdate.hrh" |
|
27 #include "iaupdateprivatecrkeys.h" |
|
28 #include "iaupdateapplication.h" |
|
29 |
|
30 #include <avkon.rsg> |
|
31 #include <avkon.hrh> |
|
32 #include <iaupdate.rsg> |
|
33 #include <centralrepository.h> |
|
34 |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // CIAUpdateAutomaticCheck::NewL |
|
38 // Two-phased constructor. |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CIAUpdateAutomaticCheck* CIAUpdateAutomaticCheck::NewL() |
|
42 { |
|
43 CIAUpdateAutomaticCheck* self = CIAUpdateAutomaticCheck::NewLC(); |
|
44 CleanupStack::Pop( self ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CIAUpdateAutomaticCheck::NewLC |
|
50 // Two-phased constructor. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CIAUpdateAutomaticCheck* CIAUpdateAutomaticCheck::NewLC() |
|
54 { |
|
55 CIAUpdateAutomaticCheck* self = new( ELeave ) CIAUpdateAutomaticCheck(); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CIAUpdateAutomaticCheck::ConstructL |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 void CIAUpdateAutomaticCheck::ConstructL() |
|
67 { |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CIAUpdateAutomaticCheck::CIAUpdateAutomaticCheck |
|
72 // constructor |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CIAUpdateAutomaticCheck::CIAUpdateAutomaticCheck() |
|
76 { |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CIAUpdateAutomaticCheck::~CIAUpdateAutomaticCheck |
|
81 // Destructor |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CIAUpdateAutomaticCheck::~CIAUpdateAutomaticCheck() |
|
85 { |
|
86 } |
|
87 |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CIAUpdateAutomaticCheck::AcceptAutomaticCheckL |
|
91 // |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 TBool CIAUpdateAutomaticCheck::AcceptAutomaticCheckL() |
|
95 { |
|
96 TBool acceptChecks = ETrue; |
|
97 CIAUpdateFirstTimeInfo* firstTimeInfo = CIAUpdateFirstTimeInfo::NewLC(); |
|
98 if ( !firstTimeInfo->AutomaticUpdateChecksAskedL() ) |
|
99 { |
|
100 if ( AutoUpdateCheckEnabledL() ) |
|
101 { |
|
102 // if automatic update check configured as enabled, confirmation is not asked |
|
103 firstTimeInfo->SetAutomaticUpdatesAskedL(); |
|
104 } |
|
105 else |
|
106 { |
|
107 TInt ret = IAUpdateDialogUtil::ShowConfirmationQueryL( |
|
108 R_IAUPDATE_TURN_ON_AUTOUPD_CHECKS, |
|
109 R_AVKON_SOFTKEYS_YES_NO ); |
|
110 firstTimeInfo->SetAutomaticUpdatesAskedL(); |
|
111 if ( ret == EAknSoftkeyYes ) |
|
112 { |
|
113 EnableAutoUpdateCheckL( ETrue ); |
|
114 } |
|
115 } |
|
116 } |
|
117 CleanupStack::PopAndDestroy( firstTimeInfo ); |
|
118 return acceptChecks; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // CIAUpdateAutomaticCheck::AutoUpdateCheckEnabledL |
|
123 // |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 TBool CIAUpdateAutomaticCheck::AutoUpdateCheckEnabledL() |
|
127 { |
|
128 TBool enabled = EFalse; |
|
129 TInt autoUpdateCheckValue( 0 ); |
|
130 CRepository* cenrep( CRepository::NewLC( KCRUidIAUpdateSettings ) ); |
|
131 User::LeaveIfError( cenrep->Get( KIAUpdateAutoUpdateCheck, |
|
132 autoUpdateCheckValue ) ); |
|
133 CleanupStack::PopAndDestroy( cenrep ); |
|
134 if ( autoUpdateCheckValue == EIAUpdateSettingValueDisableWhenRoaming || |
|
135 autoUpdateCheckValue == EIAUpdateSettingValueEnable ) |
|
136 { |
|
137 enabled = ETrue; |
|
138 } |
|
139 return enabled; |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CIAUpdateAutomaticCheck::EnableAutoUpdateCheckL |
|
144 // |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void CIAUpdateAutomaticCheck::EnableAutoUpdateCheckL( TBool aEnable ) |
|
148 { |
|
149 CRepository* cenrep = CRepository::NewLC( KCRUidIAUpdateSettings ); |
|
150 TInt err = cenrep->StartTransaction( CRepository::EReadWriteTransaction ); |
|
151 User::LeaveIfError( err ); |
|
152 cenrep->CleanupCancelTransactionPushL(); |
|
153 |
|
154 if ( aEnable ) |
|
155 { |
|
156 err = cenrep->Set( KIAUpdateAutoUpdateCheck, |
|
157 EIAUpdateSettingValueDisableWhenRoaming ); |
|
158 } |
|
159 else |
|
160 { |
|
161 err = cenrep->Set( KIAUpdateAutoUpdateCheck, |
|
162 EIAUpdateSettingValueDisable ); |
|
163 } |
|
164 User::LeaveIfError( err ); |
|
165 |
|
166 TUint32 ignore = KErrNone; |
|
167 User::LeaveIfError( cenrep->CommitTransaction( ignore ) ); |
|
168 CleanupStack::PopAndDestroy(); // CleanupCancelTransactionPushL() |
|
169 CleanupStack::PopAndDestroy( cenrep ); |
|
170 } |
|
171 |
|
172 |
|
173 // End of File |