|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <mctauthobject.h> |
|
19 |
|
20 |
|
21 #include <qstringlist.h> |
|
22 #include <qgraphicslinearlayout.h> |
|
23 |
|
24 #include <hblineedit.h> |
|
25 #include <hbdataform.h> |
|
26 #include <hbdataformmodel.h> |
|
27 #include <hbdataformmodelitem.h> |
|
28 #include <hblabel.h> |
|
29 #include <hbpushbutton.h> |
|
30 #include <hbmenu.h> |
|
31 #include <hbaction.h> |
|
32 #include <hbmessageBox.h> |
|
33 #include <hblistwidget.h> |
|
34 #include <hblistwidgetitem.h> |
|
35 #include <hbgroupbox.h> |
|
36 #include <hbpushbutton.h> |
|
37 #include <hbdataform.h> |
|
38 #include <hbdataformmodel.h> |
|
39 #include <hbdataformmodelitem.h> |
|
40 #include <hbabstractviewitem.h> |
|
41 #include <hbmainwindow.h> |
|
42 #include <HbMessageBox> |
|
43 |
|
44 #include <memory> |
|
45 |
|
46 #include "cpsecmodview.h" |
|
47 #include "cpsecmodmodel.h" |
|
48 #include "cpmoduleview.h" |
|
49 |
|
50 CpSecModView::CpSecModView(TInt currentPos, CSecModUIModel& secModUIModel, QGraphicsItem *parent /*= 0*/) |
|
51 : CpBaseSettingView(0,parent), |
|
52 mSecModUIModel(secModUIModel), |
|
53 mPos(currentPos), |
|
54 mCurrentView(EAccessView), |
|
55 mAccessView(NULL), |
|
56 mPrevView(NULL) |
|
57 { |
|
58 try |
|
59 { |
|
60 QT_TRAP_THROWING(mSecModUIModel.OpenTokenL(mPos)); |
|
61 QString title = mSecModUIModel.TokenLabelForTitle(); |
|
62 setTitle(title); |
|
63 |
|
64 TInt count = 0; |
|
65 // display code view |
|
66 QT_TRAP_THROWING(count = mSecModUIModel.CheckCodeViewStringsL()); |
|
67 |
|
68 std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical))); |
|
69 HbListWidget* listSecView = q_check_ptr(new HbListWidget(this)); |
|
70 |
|
71 std::auto_ptr<HbListWidgetItem> moduleWidget(q_check_ptr(new HbListWidgetItem())); |
|
72 moduleWidget->setText("\tModule PIN"); |
|
73 listSecView->addItem(moduleWidget.get()); |
|
74 moduleWidget.release(); |
|
75 |
|
76 if( count == 2 ) |
|
77 { |
|
78 std::auto_ptr<HbListWidgetItem> signingWidget(q_check_ptr(new HbListWidgetItem())); |
|
79 signingWidget->setText("\tSigning PIN"); |
|
80 listSecView->addItem(signingWidget.get()); |
|
81 signingWidget.release(); |
|
82 } |
|
83 |
|
84 connect(listSecView, SIGNAL(activated(QModelIndex)), this, SLOT(showNextView(QModelIndex))); |
|
85 |
|
86 layout->addItem(listSecView); |
|
87 setLayout(layout.get()); |
|
88 layout.release(); |
|
89 } |
|
90 catch(const std::exception& exception) |
|
91 { |
|
92 QString error(exception.what()); |
|
93 HbMessageBox::information(error); |
|
94 QT_RETHROW; |
|
95 } |
|
96 } |
|
97 |
|
98 CpSecModView::~CpSecModView() |
|
99 { |
|
100 if(mAccessView) |
|
101 { |
|
102 mAccessView->deleteLater(); |
|
103 mAccessView = NULL; |
|
104 } |
|
105 if(mPrevView) |
|
106 { |
|
107 mPrevView->deleteLater(); |
|
108 mPrevView = NULL; |
|
109 } |
|
110 } |
|
111 |
|
112 |
|
113 void CpSecModView::showNextView( const QModelIndex& modelIndex ) |
|
114 { |
|
115 try |
|
116 { |
|
117 mAccessView = q_check_ptr(new CpModuleView((TSecModViews)modelIndex.row(),mSecModUIModel)); |
|
118 QObject::connect(mAccessView , SIGNAL(aboutToClose()), this, SLOT(displayPrevious())); |
|
119 mPrevView = mainWindow()->currentView(); //suppose iPreView is member variable of CpSecurityView |
|
120 mainWindow()->addView(mAccessView); |
|
121 mainWindow()->setCurrentView(mAccessView); |
|
122 } |
|
123 catch(const std::exception& exception) |
|
124 { |
|
125 HbMessageBox::information(exception.what()); |
|
126 } |
|
127 } |
|
128 |
|
129 void CpSecModView::displayPrevious() |
|
130 { |
|
131 try |
|
132 { |
|
133 mainWindow()->removeView(mAccessView); |
|
134 } |
|
135 catch(const std::exception& exception) |
|
136 { |
|
137 HbMessageBox::information(exception.what()); |
|
138 } |
|
139 } |
|
140 |