|
1 /* |
|
2 * Copyright (c) 2010 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: SW installation settings changer application. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "swinstsettingschanger.h" |
|
19 #include <hbmainwindow.h> |
|
20 #include <hbview.h> |
|
21 #include <QGraphicsLinearLayout> |
|
22 #include <hbcombobox.h> |
|
23 #include <hbtextedit.h> |
|
24 #include <hbcheckbox.h> |
|
25 #include <hbpushbutton.h> |
|
26 #include <centralrepository.h> |
|
27 #include <SWInstallerInternalCRKeys.h> |
|
28 |
|
29 |
|
30 SwInstSettingsChanger::SwInstSettingsChanger(int& argc, char* argv[]) : HbApplication(argc, argv), |
|
31 mMainWindow(0), mMainView(0), mOcspProcedure(0), mDefaultUrl(0), mAllowUntrusted(0) |
|
32 { |
|
33 mMainWindow = new HbMainWindow(); |
|
34 mMainView = new HbView(); |
|
35 mMainView->setTitle(tr("SWInstSettings")); |
|
36 |
|
37 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); |
|
38 |
|
39 HbPushButton *readButton = new HbPushButton("Read"); |
|
40 connect(readButton, SIGNAL(clicked()), this, SLOT(handleRead())); |
|
41 layout->addItem(readButton); |
|
42 |
|
43 HbPushButton *saveButton = new HbPushButton("Save"); |
|
44 connect(saveButton, SIGNAL(clicked()), this, SLOT(handleSave())); |
|
45 layout->addItem(saveButton); |
|
46 |
|
47 mOcspProcedure = new HbComboBox; |
|
48 mOcspProcedure->setEditable(false); |
|
49 QStringList ocspProcedureList; |
|
50 ocspProcedureList << "Off" << "On" << "Must"; |
|
51 mOcspProcedure->setItems(ocspProcedureList); |
|
52 layout->addItem(mOcspProcedure); |
|
53 |
|
54 mDefaultUrl = new HbTextEdit; |
|
55 layout->addItem(mDefaultUrl); |
|
56 |
|
57 mAllowUntrusted = new HbCheckBox; |
|
58 mAllowUntrusted->setText(tr("KSWInstallerAllowUntrusted")); |
|
59 layout->addItem(mAllowUntrusted); |
|
60 |
|
61 HbPushButton *closeButton = new HbPushButton("Close"); |
|
62 connect(closeButton, SIGNAL(clicked()), qApp, SLOT(quit())); |
|
63 layout->addItem(closeButton); |
|
64 |
|
65 mMainView->setLayout(layout); |
|
66 mMainWindow->addView(mMainView); |
|
67 mMainWindow->show(); |
|
68 |
|
69 handleRead(); |
|
70 } |
|
71 |
|
72 SwInstSettingsChanger::~SwInstSettingsChanger() |
|
73 { |
|
74 delete mMainView; |
|
75 delete mMainWindow; |
|
76 } |
|
77 |
|
78 void SwInstSettingsChanger::handleRead() |
|
79 { |
|
80 QT_TRAP_THROWING( DoHandleReadL() ); |
|
81 } |
|
82 |
|
83 void SwInstSettingsChanger::handleSave() |
|
84 { |
|
85 QT_TRAP_THROWING( DoHandleSaveL() ); |
|
86 } |
|
87 |
|
88 void SwInstSettingsChanger::DoHandleReadL() |
|
89 { |
|
90 CRepository* repository = CRepository::NewL( KCRUidSWInstallerSettings ); |
|
91 CleanupStack::PushL( repository ); |
|
92 |
|
93 TInt ocspProcedure = 0; |
|
94 User::LeaveIfError( repository->Get( KSWInstallerOcspProcedure, ocspProcedure ) ); |
|
95 mOcspProcedure->setCurrentIndex( ocspProcedure ); |
|
96 |
|
97 HBufC* ocspUrlBuf = HBufC::NewLC( NCentralRepositoryConstants::KMaxUnicodeStringLength ); |
|
98 TPtr ocspUrl( ocspUrlBuf->Des() ); |
|
99 User::LeaveIfError( repository->Get( KSWInstallerOcspDefaultURL, ocspUrl ) ); |
|
100 QString defaultUrl = QString::fromUtf16(ocspUrl.Ptr(), ocspUrl.Length()); |
|
101 mDefaultUrl->setPlainText( defaultUrl ); |
|
102 CleanupStack::PopAndDestroy( ocspUrlBuf ); |
|
103 |
|
104 TInt allowUntrusted = 0; |
|
105 User::LeaveIfError( repository->Get( KSWInstallerAllowUntrusted, allowUntrusted ) ); |
|
106 mAllowUntrusted->setChecked( allowUntrusted ); |
|
107 |
|
108 CleanupStack::PopAndDestroy( repository ); |
|
109 } |
|
110 |
|
111 void SwInstSettingsChanger::DoHandleSaveL() |
|
112 { |
|
113 CRepository* repository = CRepository::NewL( KCRUidSWInstallerSettings ); |
|
114 CleanupStack::PushL( repository ); |
|
115 |
|
116 TInt ocspProcedure = mOcspProcedure->currentIndex(); |
|
117 User::LeaveIfError( repository->Set( KSWInstallerOcspProcedure, ocspProcedure ) ); |
|
118 |
|
119 HBufC* ocspUrlBuf = HBufC::NewLC( NCentralRepositoryConstants::KMaxUnicodeStringLength ); |
|
120 TPtr ocspUrl( ocspUrlBuf->Des() ); |
|
121 QString string = mDefaultUrl->toPlainText(); |
|
122 TPtrC ptr( reinterpret_cast<const TText*>( string.constData() ) ); |
|
123 ocspUrl.Copy( ptr ); |
|
124 User::LeaveIfError( repository->Set( KSWInstallerOcspDefaultURL, ocspUrl ) ); |
|
125 CleanupStack::PopAndDestroy( ocspUrlBuf ); |
|
126 |
|
127 TInt allowUntrusted = mAllowUntrusted->isChecked(); |
|
128 User::LeaveIfError( repository->Set( KSWInstallerAllowUntrusted, allowUntrusted ) ); |
|
129 |
|
130 CleanupStack::PopAndDestroy( repository ); |
|
131 } |
|
132 |