cpsecplugins/cpadvancedsecplugin/src/cpcertview.cpp
changeset 59 881d92421467
parent 30 cc1cea6aabaf
equal deleted inserted replaced
53:25dd1e8b2663 59:881d92421467
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <QStringList>
    18 #include <QStringList>
    19 #include <QGraphicsLinearLayout>
    19 #include <QGraphicsLinearLayout>
    50 #include "cpcertmanuisyncwrapper.h"
    50 #include "cpcertmanuisyncwrapper.h"
    51 
    51 
    52 
    52 
    53 CpCertView::CpCertView(const QModelIndex& modelIndex, QGraphicsItem *parent /*= 0*/)
    53 CpCertView::CpCertView(const QModelIndex& modelIndex, QGraphicsItem *parent /*= 0*/)
    54 	: CpBaseSettingView(0,parent),
    54 	: CpBaseSettingView(0,parent),
    55 	  mPopup(NULL),
    55 	  mPopup(NULL), mOkAction(NULL),
    56 	  mPrevView(NULL),
    56 	  mPrevView(NULL),
    57 	  mCurrentView(NULL),
    57 	  mCurrentView(NULL),
    58 	  mRefreshedView(NULL),
    58 	  mRefreshedView(NULL),
    59 	  mListView(NULL),
    59 	  mListView(NULL),
    60 	  mSelectAllView(NULL),
    60 	  mSelectAllView(NULL),
    61 	  mOriginalView(NULL),
    61 	  mOriginalView(NULL),
    62 	  mNote(NULL)
    62 	  mNote(NULL)
    63 	{
    63 	{
    64 	RDEBUG("0", 0);
    64 	RDEBUG("0", 0);
    65 	mOriginalView = mainWindow()->currentView();
    65 	mOriginalView = mainWindow()->currentView();
    66 	
    66 
    67 	HbMenu* menu = this->menu();   
    67 	HbMenu* menu = this->menu();
    68 	std::auto_ptr<HbAction> deleteAction(new HbAction(hbTrId("txt_common_menu_delete")));
    68 	std::auto_ptr<HbAction> deleteAction(new HbAction(hbTrId("txt_common_menu_delete")));
    69 	connect(deleteAction.get(), SIGNAL(triggered()), this, SLOT(deleteList()));    
    69 	connect(deleteAction.get(), SIGNAL(triggered()), this, SLOT(deleteList()));
    70 	menu->addAction(deleteAction.get());
    70 	menu->addAction(deleteAction.get());
    71 	deleteAction.release();
    71 	deleteAction.release();
    72 	
    72 
    73 	std::auto_ptr<QGraphicsLinearLayout> layout(new QGraphicsLinearLayout(Qt::Vertical));
    73 	std::auto_ptr<QGraphicsLinearLayout> layout(new QGraphicsLinearLayout(Qt::Vertical));
    74 	
    74 
    75 	HbDataForm *form = q_check_ptr(new HbDataForm(this));
    75 	HbDataForm *form = q_check_ptr(new HbDataForm(this));
    76 	std::auto_ptr<HbDataFormModel> formModel(q_check_ptr(new HbDataFormModel()));
    76 	std::auto_ptr<HbDataFormModel> formModel(q_check_ptr(new HbDataFormModel()));
    77 	form->setModel(formModel.get());
    77 	form->setModel(formModel.get());
    78 	formModel.release();
    78 	formModel.release();
    79 	
    79 
    80 	HbListWidget* certificateList = q_check_ptr(new HbListWidget(this)); 
    80 	HbListWidget* certificateList = q_check_ptr(new HbListWidget(this));
    81 		
    81 
    82 	CpCertView::TCertificateViews currentView = (CpCertView::TCertificateViews)modelIndex.row(); 
    82 	CpCertView::TCertificateViews currentView = (CpCertView::TCertificateViews)modelIndex.row();
    83 	QString title;
    83 	QString title;
    84 	if(currentView == EPersonalView)
    84 	if(currentView == EPersonalView)
    85 		{
    85 		{
    86 		title = "Move to Device";
    86 		title = "Move to Device";
    87 		}
    87 		}
    88 	else if(currentView == EDeviceView)
    88 	else if(currentView == EDeviceView)
    89 		{
    89 		{
    90 		title = "Move to Personal";  
    90 		title = "Move to Personal";
    91 		}
    91 		}
    92 	RDEBUG("0", 0);
    92 	RDEBUG("0", 0);
    93 	if(currentView == EPersonalView || currentView == EDeviceView)
    93 	if(currentView == EPersonalView || currentView == EDeviceView)
    94 		{
    94 		{
    95 		std::auto_ptr<HbAction> moveToDeviceAction(q_check_ptr(new HbAction(title)));   
    95 		std::auto_ptr<HbAction> moveToDeviceAction(q_check_ptr(new HbAction(title)));
    96 		connect(moveToDeviceAction.get(), SIGNAL(triggered()), this, SLOT(moveCert()));    
    96 		connect(moveToDeviceAction.get(), SIGNAL(triggered()), this, SLOT(moveCert()));
    97 		menu->addAction(moveToDeviceAction.get());
    97 		menu->addAction(moveToDeviceAction.get());
    98 		moveToDeviceAction.release();
    98 		moveToDeviceAction.release();
    99 		}	
    99 		}
   100 	
   100 
   101 	setDetails(currentView);
   101 	setDetails(currentView);
   102 	TInt count = 0;
   102 	TInt count = 0;
   103 	try
   103 	try
   104 		{
   104 		{
   105 		QT_TRAP_THROWING(mCertDataContainer = CpCertDataContainer::NewL());
   105 		QT_TRAP_THROWING(mCertDataContainer = CpCertDataContainer::NewL());
   117 		std::auto_ptr<HbListWidgetItem> singleCert(q_check_ptr(new HbListWidgetItem()));
   117 		std::auto_ptr<HbListWidgetItem> singleCert(q_check_ptr(new HbListWidgetItem()));
   118 		singleCert->setText(certificateLabel);
   118 		singleCert->setText(certificateLabel);
   119 		certificateList->addItem(singleCert.get());
   119 		certificateList->addItem(singleCert.get());
   120 		singleCert.release();
   120 		singleCert.release();
   121 		}  // End of FOR loop
   121 		}  // End of FOR loop
   122 	
   122 
   123 	connect(certificateList, SIGNAL(activated(QModelIndex)), this, SLOT(openCertFromList(QModelIndex)));   
   123 	connect(certificateList, SIGNAL(activated(QModelIndex)), this, SLOT(openCertFromList(QModelIndex)));
   124 	connect(certificateList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF )), this, SLOT(indicateLongPress(HbAbstractViewItem*, QPointF))); 
   124 	connect(certificateList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF )), this, SLOT(indicateLongPress(HbAbstractViewItem*, QPointF)));
   125 	
   125 
   126 	layout->addItem(certificateList);
   126 	layout->addItem(certificateList);
   127 	setLayout(layout.get());
   127 	setLayout(layout.get());
   128 	layout.release();
   128 	layout.release();
   129 	
   129 
   130 	mPopup = q_check_ptr(new HbDialog());
   130 	mPopup = q_check_ptr(new HbDialog());
   131 	mContextMenu = q_check_ptr(new HbMenu());
   131 	mContextMenu = q_check_ptr(new HbMenu());
   132 	
   132 
   133 	RDEBUG("0", 0);
   133 	RDEBUG("0", 0);
   134 	}
   134 	}
   135 
   135 
   136 CpCertView::~CpCertView()
   136 CpCertView::~CpCertView()
   137 	{
   137 	{
   156 	if(mListView)
   156 	if(mListView)
   157 		{
   157 		{
   158 		mListView->deleteLater();
   158 		mListView->deleteLater();
   159 		mListView= NULL;
   159 		mListView= NULL;
   160 		}
   160 		}
   161 		
   161 
   162 	if(mSelectAllView)
   162 	if(mSelectAllView)
   163 	{
   163 	{
   164 	mSelectAllView->deleteLater();
   164 	mSelectAllView->deleteLater();
   165 	mSelectAllView = NULL;
   165 	mSelectAllView = NULL;
   166 	}
   166 	}
   167 	
   167 
   168 	mSelectionIndex.Close();
   168 	mSelectionIndex.Close();
   169 	
   169 
   170 	mIndexList.Close();
   170 	mIndexList.Close();
   171 	
   171 
   172 	delete mPopup;
   172 	delete mPopup;
   173 	
   173 
   174 	delete mNote;
   174 	delete mNote;
   175 	mNote = NULL;
   175 	mNote = NULL;
   176 	
   176 
   177 	delete mContextMenu;
   177 	delete mContextMenu;
   178 	
   178 
   179 	}
   179 	}
   180 	
   180 
   181 void CpCertView::setDetails(CpCertView::TCertificateViews currentView)
   181 void CpCertView::setDetails(CpCertView::TCertificateViews currentView)
   182 	{
   182 	{
   183 	RDEBUG("0", 0);
   183 	RDEBUG("0", 0);
   184 	switch(currentView)
   184 	switch(currentView)
   185 		{
   185 		{
   186 		case EAuthorityView:
   186 		case EAuthorityView:
   187 		setTitle(hbTrId("txt_certificate_manager_list_authority_certificate"));
   187 		setTitle(hbTrId("txt_certificate_manager_list_authority_certificate"));
   188 		mCertView = EAuthorityView;
   188 		mCertView = EAuthorityView;
   189 		break;
   189 		break;
   190 		
   190 
   191 		case ETrustedView:
   191 		case ETrustedView:
   192 		setTitle(hbTrId("txt_certificate_manager_list_trusted_site_certific"));
   192 		setTitle(hbTrId("txt_certificate_manager_list_trusted_site_certific"));
   193 		mCertView = ETrustedView;
   193 		mCertView = ETrustedView;
   194 		break;
   194 		break;
   195 		
   195 
   196 		case EPersonalView:
   196 		case EPersonalView:
   197 		setTitle(hbTrId("txt_certificate_manager_list_personal_certificates"));
   197 		setTitle(hbTrId("txt_certificate_manager_list_personal_certificates"));
   198 		mCertView = EPersonalView;
   198 		mCertView = EPersonalView;
   199 		break;
   199 		break;
   200 		
   200 
   201 		case EDeviceView:
   201 		case EDeviceView:
   202 		setTitle(hbTrId("txt_certificate_manager_list_device_certificates"));
   202 		setTitle(hbTrId("txt_certificate_manager_list_device_certificates"));
   203 		mCertView = EDeviceView;
   203 		mCertView = EDeviceView;
   204 		break;
   204 		break;
   205 		}
   205 		}
   207 
   207 
   208 void CpCertView::indicateLongPress(HbAbstractViewItem *item,QPointF coords)
   208 void CpCertView::indicateLongPress(HbAbstractViewItem *item,QPointF coords)
   209 	{
   209 	{
   210 	RDEBUG("0", 0);
   210 	RDEBUG("0", 0);
   211 	mPos = item->modelIndex().row();   // Pos will tell you what is the certificate clicked in particular view.
   211 	mPos = item->modelIndex().row();   // Pos will tell you what is the certificate clicked in particular view.
   212 	
   212 
   213 	mContextMenu->clearActions();
   213 	mContextMenu->clearActions();
   214 	std::auto_ptr<HbAction> open(q_check_ptr(new HbAction(hbTrId("txt_common_menu_open"))));
   214 	std::auto_ptr<HbAction> open(q_check_ptr(new HbAction(hbTrId("txt_common_menu_open"))));
   215 	connect(open.get(), SIGNAL(triggered()), this, SLOT( openCertificate()));
   215 	connect(open.get(), SIGNAL(triggered()), this, SLOT( openCertificate()));
   216 	mContextMenu->addAction(open.get());			
   216 	mContextMenu->addAction(open.get());
   217 	open.release();
   217 	open.release();
   218 	
   218 
   219 	QString moveTitle;
   219 	QString moveTitle;
   220 	
   220 
   221 	if(mCertView == EAuthorityView)
   221 	if(mCertView == EAuthorityView)
   222 		{
   222 		{
   223 		std::auto_ptr<HbAction> trustSettings(q_check_ptr(new HbAction(hbTrId("txt_certificate_manager_menu_trust_settings")))); 
   223 		std::auto_ptr<HbAction> trustSettings(q_check_ptr(new HbAction(hbTrId("txt_certificate_manager_menu_trust_settings"))));
   224 		connect(trustSettings.get(), SIGNAL(triggered()), this, SLOT(showTrustSettings()));    
   224 		connect(trustSettings.get(), SIGNAL(triggered()), this, SLOT(showTrustSettings()));
   225 		mContextMenu->addAction(trustSettings.get());
   225 		mContextMenu->addAction(trustSettings.get());
   226 		trustSettings.release();
   226 		trustSettings.release();
   227 		}
   227 		}
   228 	else if(mCertView == EPersonalView)
   228 	else if(mCertView == EPersonalView)
   229 		{
   229 		{
   230 		moveTitle = hbTrId("txt_certificate_manager_menu_move_to_device_certif");
   230 		moveTitle = hbTrId("txt_certificate_manager_menu_move_to_device_certif");
   231 		}
   231 		}
   232 	else if(mCertView == EDeviceView)
   232 	else if(mCertView == EDeviceView)
   233 		{
   233 		{
   234 		moveTitle = hbTrId("txt_certificate_manager_menu_move_to_personal_cert");
   234 		moveTitle = hbTrId("txt_certificate_manager_menu_move_to_personal_cert");
   235 		}	
   235 		}
   236 	
   236 
   237 	if(mCertView == EPersonalView || mCertView == EDeviceView )
   237 	if(mCertView == EPersonalView || mCertView == EDeviceView )
   238 		{
   238 		{
   239 		std::auto_ptr<HbAction> moveCert(q_check_ptr(new HbAction(moveTitle)));     
   239 		std::auto_ptr<HbAction> moveCert(q_check_ptr(new HbAction(moveTitle)));
   240 		connect(moveCert.get(), SIGNAL(triggered()), this, SLOT(moveSelectedCert()));    
   240 		connect(moveCert.get(), SIGNAL(triggered()), this, SLOT(moveSelectedCert()));
   241 		mContextMenu->addAction(moveCert.get());
   241 		mContextMenu->addAction(moveCert.get());
   242 		moveCert.release();
   242 		moveCert.release();
   243 		}
   243 		}
   244 	
   244 
   245 	RDEBUG("0", 0);
   245 	RDEBUG("0", 0);
   246 	if( certAt(mPos)->IsDeletable() )
   246 	if( certAt(mPos)->IsDeletable() )
   247 		{
   247 		{
   248 		std::auto_ptr<HbAction> menuDelete(q_check_ptr(new HbAction(hbTrId("txt_common_menu_delete")))); 
   248 		std::auto_ptr<HbAction> menuDelete(q_check_ptr(new HbAction(hbTrId("txt_common_menu_delete"))));
   249 		connect(menuDelete.get(), SIGNAL(triggered()), this, SLOT(deleteCertificate()));    
   249 		connect(menuDelete.get(), SIGNAL(triggered()), this, SLOT(deleteCertificate()));
   250 		mContextMenu->addAction(menuDelete.get());
   250 		mContextMenu->addAction(menuDelete.get());
   251 		menuDelete.release();
   251 		menuDelete.release();
   252 		}
   252 		}
   253 	mContextMenu->setPreferredPos(coords);
   253 	mContextMenu->setPreferredPos(coords);
   254 	mContextMenu->open();
   254 	mContextMenu->open();
   255 	}
   255 	}
   256 
   256 
   257 void CpCertView::openCertFromList(const QModelIndex& modelIndex)
   257 void CpCertView::openCertFromList(const QModelIndex& modelIndex)
   258 	{	
   258 	{
   259 	RDEBUG("0", 0);
   259 	RDEBUG("0", 0);
   260 	// Pos will tell you what is the certificate clicked in particular view.
   260 	// Pos will tell you what is the certificate clicked in particular view.
   261 	mPos = modelIndex.row();   
   261 	mPos = modelIndex.row();
   262 	openCertificate();
   262 	openCertificate();
   263 	}
   263 	}
   264 
   264 
   265 void CpCertView::openCertificate()
   265 void CpCertView::openCertificate()
   266 	{
   266 	{
   267 	RDEBUG("0", 0);
   267 	RDEBUG("0", 0);
   268 	mCurrentView = q_check_ptr(new CpCertDetailView(mCertView,mPos,*mCertDataContainer));    
   268 	mCurrentView = q_check_ptr(new CpCertDetailView(mCertView,mPos,*mCertDataContainer));
   269 	connect(mCurrentView, SIGNAL(aboutToClose()), this, SLOT(displayPreviousView()));
   269 	connect(mCurrentView, SIGNAL(aboutToClose()), this, SLOT(displayPreviousView()));
   270 	mPrevView = mainWindow()->currentView();   
   270 	mPrevView = mainWindow()->currentView();
   271 	mainWindow()->addView(mCurrentView);
   271 	mainWindow()->addView(mCurrentView);
   272 	mainWindow()->setCurrentView(mCurrentView);  		
   272 	mainWindow()->setCurrentView(mCurrentView);
   273 	}
   273 	}
   274 	
   274 
   275 void CpCertView::displayPreviousView()  
   275 void CpCertView::displayPreviousView()
   276 	{
   276 	{
   277 	RDEBUG("0", 0);
   277 	RDEBUG("0", 0);
   278 	mainWindow()->removeView(mCurrentView);    
   278 	mainWindow()->removeView(mCurrentView);
   279 	mCurrentView->deleteLater();
   279 	mCurrentView->deleteLater();
   280 	mCurrentView= NULL;
   280 	mCurrentView= NULL;
   281 	mainWindow()->setCurrentView(mPrevView);  	
   281 	mainWindow()->setCurrentView(mPrevView);
   282 	}
   282 	}
   283 	
   283 
   284 void CpCertView::deleteCertificate()
   284 void CpCertView::deleteCertificate()
   285 	{
   285 	{
   286 	RDEBUG("0", 0);
   286 	RDEBUG("0", 0);
   287 	RArray<TInt> pos;
   287 	RArray<TInt> pos;
   288 	pos.Append(mPos);
   288 	pos.Append(mPos);
   289 	QT_TRAP_THROWING(deleteCertsL(pos));
   289 	QT_TRAP_THROWING(deleteCertsL(pos));
   290 	}		
   290 	}
   291 	
   291 
   292 void CpCertView::deleteList()
   292 void CpCertView::deleteList()
   293 	{
   293 	{
   294 	RDEBUG("0", 0);
   294 	RDEBUG("0", 0);
   295 	mSelectAll = EFalse;
   295 	mSelectAll = EFalse;
   296 	mPopup->setDismissPolicy(HbDialog::NoDismiss);
   296 	mPopup->setDismissPolicy(HbDialog::NoDismiss);
   297 	// Set the label as heading widget
   297 	// Set the label as heading widget
   298 	mPopup->setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_setlabel_certificates"))));
   298 	mPopup->setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_setlabel_certificates"))));
   299 	
   299 
   300 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
   300 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
   301 		
   301 
   302 	mSelectAllView = q_check_ptr(new HbListView(this));
   302 	mSelectAllView = q_check_ptr(new HbListView(this));
   303 	QStandardItemModel* selectAllModel = q_check_ptr(new QStandardItemModel(this));
   303 	QStandardItemModel* selectAllModel = q_check_ptr(new QStandardItemModel(this));
   304 	// Populate the model with content
   304 	// Populate the model with content
   305 	std::auto_ptr<QStandardItem> selectAllItem(q_check_ptr(new QStandardItem()));
   305 	std::auto_ptr<QStandardItem> selectAllItem(q_check_ptr(new QStandardItem()));
   306 	selectAllItem->setData(QString("Select All"),Qt::DisplayRole);
   306 	selectAllItem->setData(QString("Select All"),Qt::DisplayRole);
   307 	selectAllModel->appendRow(selectAllItem.get());
   307 	selectAllModel->appendRow(selectAllItem.get());
   308 	selectAllItem.release();
   308 	selectAllItem.release();
   309 	
   309 
   310 	connect(mSelectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll()));
   310 	connect(mSelectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll()));
   311 	mSelectAllView->setModel(selectAllModel);
   311 	mSelectAllView->setModel(selectAllModel);
   312 	mSelectAllView->setSelectionMode(HbListView::MultiSelection);
   312 	mSelectAllView->setSelectionMode(HbListView::MultiSelection);
   313 	layout->addItem(mSelectAllView);
   313 	layout->addItem(mSelectAllView);
   314 	
   314 
   315 	mListView = q_check_ptr(new HbListView(this));
   315 	mListView = q_check_ptr(new HbListView(this));
   316 	// Connect to "activated" signal
   316 	// Connect to "activated" signal
   317 	connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex)));
   317 	connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex)));
   318 	
   318 
   319 	// Create a model
   319 	// Create a model
   320 	QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this));
   320 	QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this));
   321 	TInt count=0;
   321 	TInt count=0;
   322 	QT_TRAP_THROWING( count = refreshListL());
   322 	QT_TRAP_THROWING( count = refreshListL());
   323 	RDEBUG("0", 0);
   323 	RDEBUG("0", 0);
   332 			certItem->setData( certificateLabel, Qt::DisplayRole);
   332 			certItem->setData( certificateLabel, Qt::DisplayRole);
   333 			model->appendRow(certItem.get());
   333 			model->appendRow(certItem.get());
   334 			mSelectionIndex.Append(index);
   334 			mSelectionIndex.Append(index);
   335 			certItem.release();
   335 			certItem.release();
   336 			}
   336 			}
   337 		}	
   337 		}
   338 	// Set the model to the list view
   338 	// Set the model to the list view
   339 	mListView->setModel(model);
   339 	mListView->setModel(model);
   340 	mListView->setSelectionMode(HbListView::MultiSelection);
   340 	mListView->setSelectionMode(HbListView::MultiSelection);
   341 	layout->addItem(mListView);
   341 	layout->addItem(mListView);
   342 	
   342 
   343 	std::auto_ptr<HbWidget> widget( q_check_ptr(new HbWidget()));
   343 	std::auto_ptr<HbWidget> widget( q_check_ptr(new HbWidget()));
   344 	widget->setLayout(layout.get());
   344 	widget->setLayout(layout.get());
   345 	layout.release();
   345 	layout.release();
   346 	mPopup->setContentWidget(widget.get());
   346 	mPopup->setContentWidget(widget.get());
   347 	widget.release();
   347 	widget.release();
   348 	
   348 
   349 	mPopup->setPrimaryAction(q_check_ptr(new HbAction(hbTrId("txt_common_opt_delete"))));
   349     mPopup->clearActions();
   350 	mPopup->setSecondaryAction(q_check_ptr(new HbAction(hbTrId("txt_common_button_cancel"))));
   350 	mOkAction = q_check_ptr(new HbAction(hbTrId("txt_common_opt_delete")));
       
   351 	mPopup->addAction(mOkAction);
       
   352 	HbAction *cancelAction = q_check_ptr(new HbAction(hbTrId("txt_common_button_cancel")));
       
   353 	mPopup->addAction(cancelAction);
   351 	mPopup->setTimeout(HbPopup::NoTimeout);
   354 	mPopup->setTimeout(HbPopup::NoTimeout);
   352 	RDEBUG("0", 0);
   355 	RDEBUG("0", 0);
   353 	// Launch popup syncronously
   356 	// Launch popup syncronously
   354 	mPopup->open(this, SLOT(handleMultipleDelete(HbAction*)));
   357 	mPopup->open(this, SLOT(handleMultipleDelete(HbAction*)));
   355 
   358 
   356 }
   359 }
   357 
   360 
   358 void CpCertView::handleMultipleDelete(HbAction* action)
   361 void CpCertView::handleMultipleDelete(HbAction* action)
   359 {
   362 {
   360 	RDEBUG("0", 0);
   363 	RDEBUG("0", 0);
   361 	if(action == mPopup->primaryAction())
   364 	if(action == mOkAction)
   362 		{
   365 		{
   363 		QItemSelectionModel *selectionModel = mListView->selectionModel();
   366 		QItemSelectionModel *selectionModel = mListView->selectionModel();
   364 		QModelIndexList mWidgetItemsToRemove = selectionModel->selectedIndexes();
   367 		QModelIndexList mWidgetItemsToRemove = selectionModel->selectedIndexes();
   365 		TInt deleteCount = mWidgetItemsToRemove.count();
   368 		TInt deleteCount = mWidgetItemsToRemove.count();
   366 		// start deleting from end of array so that the indexes do not changes of the ones
   369 		// start deleting from end of array so that the indexes do not changes of the ones
   367 		// at the front.
   370 		// at the front.
   368 		RArray<TInt> actualIndex;
   371 		RArray<TInt> actualIndex;
   369 		QT_TRAP_THROWING
   372 		QT_TRAP_THROWING
   370 			(
   373 			(
   371 			CleanupClosePushL(actualIndex);
   374 			CleanupClosePushL(actualIndex);
   372 			for (TInt index = deleteCount-1; index>= 0 ; --index) 
   375 			for (TInt index = deleteCount-1; index>= 0 ; --index)
   373 				{
   376 				{
   374 				TInt selectedItemIndex = mWidgetItemsToRemove[index].row();
   377 				TInt selectedItemIndex = mWidgetItemsToRemove[index].row();
   375 				actualIndex.Append( mSelectionIndex[selectedItemIndex] );
   378 				actualIndex.Append( mSelectionIndex[selectedItemIndex] );
   376 				}
   379 				}
   377 			deleteCertsL(actualIndex);
   380 			deleteCertsL(actualIndex);
   380 		}
   383 		}
   381 	RDEBUG("0", 0);
   384 	RDEBUG("0", 0);
   382 	mListView->deleteLater();
   385 	mListView->deleteLater();
   383 	mListView = NULL;
   386 	mListView = NULL;
   384 	mSelectAllView->deleteLater();
   387 	mSelectAllView->deleteLater();
   385 	mSelectAllView = NULL; 
   388 	mSelectAllView = NULL;
   386 	}
   389 	}
   387 
   390 
   388 void CpCertView::moveCert()
   391 void CpCertView::moveCert()
   389 	{
   392 	{
   390 	RDEBUG("0", 0);
   393 	RDEBUG("0", 0);
   397 		}
   400 		}
   398 	else if(mCertView == EDeviceView)
   401 	else if(mCertView == EDeviceView)
   399 		{
   402 		{
   400 		mPopup->setHeadingWidget(q_check_ptr(new HbLabel(tr("Move To Personal"))));
   403 		mPopup->setHeadingWidget(q_check_ptr(new HbLabel(tr("Move To Personal"))));
   401 		}
   404 		}
   402 		
   405 
   403 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
   406 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
   404 			
   407 
   405 	mSelectAllView = q_check_ptr(new HbListView(this));
   408 	mSelectAllView = q_check_ptr(new HbListView(this));
   406 	QStandardItemModel* selectAllModel = q_check_ptr(new QStandardItemModel(this));
   409 	QStandardItemModel* selectAllModel = q_check_ptr(new QStandardItemModel(this));
   407 	// Populate the model with content
   410 	// Populate the model with content
   408 	std::auto_ptr<QStandardItem> selectAllItem(q_check_ptr(new QStandardItem()));
   411 	std::auto_ptr<QStandardItem> selectAllItem(q_check_ptr(new QStandardItem()));
   409 	selectAllItem->setData(QString("Select All"),Qt::DisplayRole);
   412 	selectAllItem->setData(QString("Select All"),Qt::DisplayRole);
   411 	selectAllItem.release();
   414 	selectAllItem.release();
   412 	connect(mSelectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll()));
   415 	connect(mSelectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll()));
   413 	mSelectAllView->setModel(selectAllModel);
   416 	mSelectAllView->setModel(selectAllModel);
   414 	mSelectAllView->setSelectionMode(HbListView::MultiSelection);
   417 	mSelectAllView->setSelectionMode(HbListView::MultiSelection);
   415 	layout->addItem(mSelectAllView);
   418 	layout->addItem(mSelectAllView);
   416 	
   419 
   417 	mListView = q_check_ptr(new HbListView(this));
   420 	mListView = q_check_ptr(new HbListView(this));
   418 	// Connect to "activated" signal
   421 	// Connect to "activated" signal
   419 	connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex)));
   422 	connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex)));
   420 	
   423 
   421 	// Create a model
   424 	// Create a model
   422 	QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this));
   425 	QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this));
   423 	TInt count =0;
   426 	TInt count =0;
   424 	RDEBUG("0", 0);
   427 	RDEBUG("0", 0);
   425 	QT_TRAP_THROWING(count = refreshListL());
   428 	QT_TRAP_THROWING(count = refreshListL());
   430 		QString certificateLabel = certLabel(index);
   433 		QString certificateLabel = certLabel(index);
   431 		certItem->setData( certificateLabel, Qt::DisplayRole);
   434 		certItem->setData( certificateLabel, Qt::DisplayRole);
   432 		model->appendRow(certItem.get());
   435 		model->appendRow(certItem.get());
   433 		mSelectionIndex.Append(index);
   436 		mSelectionIndex.Append(index);
   434 		certItem.release();
   437 		certItem.release();
   435 		}	
   438 		}
   436 	
   439 
   437 	// Set the model to the list view
   440 	// Set the model to the list view
   438 	mListView->setModel(model);
   441 	mListView->setModel(model);
   439 	mListView->setSelectionMode(HbListView::MultiSelection);
   442 	mListView->setSelectionMode(HbListView::MultiSelection);
   440 	layout->addItem(mListView);
   443 	layout->addItem(mListView);
   441 	
   444 
   442 	std::auto_ptr<HbWidget> widget(q_check_ptr(new HbWidget()));
   445 	std::auto_ptr<HbWidget> widget(q_check_ptr(new HbWidget()));
   443 	widget->setLayout(layout.get());	
   446 	widget->setLayout(layout.get());
   444 	layout.release();
   447 	layout.release();
   445 	mPopup->setContentWidget(widget.get());
   448 	mPopup->setContentWidget(widget.get());
   446 	widget.release();
   449 	widget.release();
   447 	RDEBUG("0", 0);
   450 	RDEBUG("0", 0);
   448 	mPopup->setPrimaryAction(q_check_ptr(new HbAction(tr("Yes"))));
   451     mPopup->clearActions();
   449 	mPopup->setSecondaryAction(q_check_ptr(new HbAction(tr("No"))));
   452 	mOkAction = q_check_ptr(new HbAction(tr("Yes")));
       
   453 	mPopup->addAction(mOkAction);
       
   454 	HbAction *noAction = q_check_ptr(new HbAction(tr("No")));
       
   455 	mPopup->addAction(noAction);
   450 	mPopup->setTimeout(HbPopup::NoTimeout);
   456 	mPopup->setTimeout(HbPopup::NoTimeout);
   451 	
   457 
   452 	// Launch popup syncronously
   458 	// Launch popup syncronously
   453 	 mPopup->open(this, SLOT(handleMoveCertDialog(HbAction*)));
   459 	 mPopup->open(this, SLOT(handleMoveCertDialog(HbAction*)));
   454 	 RDEBUG("0", 0);
   460 	 RDEBUG("0", 0);
   455 }
   461 }
   456 
   462 
   457 void CpCertView::handleMoveCertDialog(HbAction* action)
   463 void CpCertView::handleMoveCertDialog(HbAction* action)
   458 {	
   464 {
   459 	RDEBUG("0", 0);
   465 	RDEBUG("0", 0);
   460 	if(action == mPopup->primaryAction())
   466 	if(action == mOkAction)
   461 		{
   467 		{
   462 		QItemSelectionModel *selectionModel = mListView->selectionModel();
   468 		QItemSelectionModel *selectionModel = mListView->selectionModel();
   463 		QModelIndexList mWidgetItemsToRemove = selectionModel->selectedIndexes();
   469 		QModelIndexList mWidgetItemsToRemove = selectionModel->selectedIndexes();
   464 		TInt deleteCount = mWidgetItemsToRemove.count();
   470 		TInt deleteCount = mWidgetItemsToRemove.count();
   465 		// start deleting from end of array so that the indexes do not changes of the ones
   471 		// start deleting from end of array so that the indexes do not changes of the ones
   467 		RArray<TInt> actualIndex;
   473 		RArray<TInt> actualIndex;
   468 		RDEBUG("0", 0);
   474 		RDEBUG("0", 0);
   469 		QT_TRAP_THROWING
   475 		QT_TRAP_THROWING
   470 			(
   476 			(
   471 			CleanupClosePushL(actualIndex);
   477 			CleanupClosePushL(actualIndex);
   472 			 for (TInt index = deleteCount-1; index>= 0 ; --index) 
   478 			 for (TInt index = deleteCount-1; index>= 0 ; --index)
   473 				 {
   479 				 {
   474 				 TInt selectedItemIndex = mWidgetItemsToRemove[index].row();
   480 				 TInt selectedItemIndex = mWidgetItemsToRemove[index].row();
   475 				 actualIndex.Append(mSelectionIndex[selectedItemIndex]);	 
   481 				 actualIndex.Append(mSelectionIndex[selectedItemIndex]);
   476 				 }
   482 				 }
   477 			 moveCertList(actualIndex);
   483 			 moveCertList(actualIndex);
   478 			 CleanupStack::PopAndDestroy(&actualIndex);
   484 			 CleanupStack::PopAndDestroy(&actualIndex);
   479 			 )
   485 			 )
   480 		}
   486 		}
   481 	mListView->deleteLater();
   487 	mListView->deleteLater();
   482 	mListView = NULL;	
   488 	mListView = NULL;
   483 	mSelectAllView->deleteLater();
   489 	mSelectAllView->deleteLater();
   484 	mSelectAllView = NULL;
   490 	mSelectAllView = NULL;
   485 	RDEBUG("0", 0);
   491 	RDEBUG("0", 0);
   486 	}
   492 	}
   487 
   493 
   506     TInt count = indexList.Count();
   512     TInt count = indexList.Count();
   507     for(int index = 0;index <count;++index )
   513     for(int index = 0;index <count;++index )
   508     	{
   514     	{
   509 		mIndexList.Append(indexList[index]);
   515 		mIndexList.Append(indexList[index]);
   510     	}
   516     	}
   511     
   517 
   512   	mNote = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   518   	mNote = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   513 	QString deleteMsg;
   519 	QString deleteMsg;
   514 	QString sCount;
   520 	QString sCount;
   515 	if(count == 1)
   521 	if(count == 1)
   516 		{
   522 		{
   533 
   539 
   534 void CpCertView::handleDeleteDialog(HbAction* action)
   540 void CpCertView::handleDeleteDialog(HbAction* action)
   535 {
   541 {
   536 	RDEBUG("0", 0);
   542 	RDEBUG("0", 0);
   537 	TInt count = mIndexList.Count();
   543 	TInt count = mIndexList.Count();
   538 	
   544 
   539 	if (action != mNote->primaryAction() || count == 0 )
   545 	if (action != mNote->primaryAction() || count == 0 )
   540 		{
   546 		{
   541 		return;
   547 		return;
   542 		}
   548 		}
   543 		
   549 
   544     RPointerArray<CCTCertInfo> errCerts;
   550     RPointerArray<CCTCertInfo> errCerts;
   545     QT_TRAP_THROWING(
   551     QT_TRAP_THROWING(
   546     		CleanupClosePushL(errCerts);
   552     		CleanupClosePushL(errCerts);
   547     
   553 
   548 		for(TInt index = 0; index < count; ++index)
   554 		for(TInt index = 0; index < count; ++index)
   549 			{
   555 			{
   550 			const CCTCertInfo* entry = certAt(mIndexList[index]);
   556 			const CCTCertInfo* entry = certAt(mIndexList[index]);
   551 			
   557 
   552 			if( mCertView == EPersonalView || mCertView == EAuthorityView )
   558 			if( mCertView == EPersonalView || mCertView == EAuthorityView )
   553 				{
   559 				{
   554 				mCertDataContainer->iWrapper->DeleteCertL( 
   560 				mCertDataContainer->iWrapper->DeleteCertL(
   555 							mCertDataContainer->CertManager(), *entry );
   561 							mCertDataContainer->CertManager(), *entry );
   556 				}
   562 				}
   557 			else if( mCertView == ETrustedView )
   563 			else if( mCertView == ETrustedView )
   558 				{
   564 				{
   559 				mCertDataContainer->iWrapper->DeleteCertL( 
   565 				mCertDataContainer->iWrapper->DeleteCertL(
   560 							mCertDataContainer->CertManager(),*entry, KCMTrustedServerTokenUid );
   566 							mCertDataContainer->CertManager(),*entry, KCMTrustedServerTokenUid );
   561 				}
   567 				}
   562 			else if( mCertView == EDeviceView )
   568 			else if( mCertView == EDeviceView )
   563 				{
   569 				{
   564 				mCertDataContainer->iWrapper->DeleteCertL(
   570 				mCertDataContainer->iWrapper->DeleteCertL(
   565 							mCertDataContainer->CertManager(), *entry, KCMDeviceCertStoreTokenUid );
   571 							mCertDataContainer->CertManager(), *entry, KCMDeviceCertStoreTokenUid );
   566 				}	
   572 				}
   567 			errCerts.AppendL(entry);
   573 			errCerts.AppendL(entry);
   568 			}
   574 			}
   569 		RDEBUG("0", 0);
   575 		RDEBUG("0", 0);
   570 		if(errCerts.Count() > 0)
   576 		if(errCerts.Count() > 0)
   571 			{
   577 			{
   579 				}
   585 				}
   580 			HbMessageBox::warning(message);
   586 			HbMessageBox::warning(message);
   581 			}
   587 			}
   582 		count = refreshListL();
   588 		count = refreshListL();
   583 		refreshView(count);
   589 		refreshView(count);
   584 		
   590 
   585 		CleanupStack::PopAndDestroy(&errCerts);
   591 		CleanupStack::PopAndDestroy(&errCerts);
   586 		) // QT_TRAP_THROWING
   592 		) // QT_TRAP_THROWING
   587     
   593 
   588 	delete mNote;
   594 	delete mNote;
   589 	mNote = NULL;
   595 	mNote = NULL;
   590 	RDEBUG("0", 0);
   596 	RDEBUG("0", 0);
   591     }
   597     }
   592 
   598 
   694 		{
   700 		{
   695 		mRefreshedView->deleteLater();
   701 		mRefreshedView->deleteLater();
   696 		mRefreshedView = NULL;
   702 		mRefreshedView = NULL;
   697 		}
   703 		}
   698 
   704 
   699 	mRefreshedView = q_check_ptr(new CpBaseSettingView());  
   705 	mRefreshedView = q_check_ptr(new CpBaseSettingView());
   700 	switch(mCertView)
   706 	switch(mCertView)
   701 		{
   707 		{
   702 		case EAuthorityView:
   708 		case EAuthorityView:
   703 			{
   709 			{
   704 			mRefreshedView->setTitle(hbTrId("txt_certificate_manager_list_authority_certificate"));
   710 			mRefreshedView->setTitle(hbTrId("txt_certificate_manager_list_authority_certificate"));
   705 			break;
   711 			break;
   706 			}
   712 			}
   707 		case ETrustedView:
   713 		case ETrustedView:
   708 			{
   714 			{
   709 			mRefreshedView->setTitle(hbTrId("txt_certificate_manager_list_trusted_site_certific"));				
   715 			mRefreshedView->setTitle(hbTrId("txt_certificate_manager_list_trusted_site_certific"));
   710 			break;
   716 			break;
   711 			}
   717 			}
   712 		case EPersonalView:
   718 		case EPersonalView:
   713 			{
   719 			{
   714 			mRefreshedView->setTitle(hbTrId("txt_certificate_manager_list_personal_certificates"));				
   720 			mRefreshedView->setTitle(hbTrId("txt_certificate_manager_list_personal_certificates"));
   715 			break;
   721 			break;
   716 			}
   722 			}
   717 		case EDeviceView:
   723 		case EDeviceView:
   718 			{
   724 			{
   719 			mRefreshedView->setTitle(hbTrId("txt_certificate_manager_list_device_certificates"));				
   725 			mRefreshedView->setTitle(hbTrId("txt_certificate_manager_list_device_certificates"));
   720 			break;
   726 			break;
   721 			}
   727 			}
   722 		}	
   728 		}
   723 	
   729 
   724 	HbMenu* menu = mRefreshedView->menu();   
   730 	HbMenu* menu = mRefreshedView->menu();
   725 	RDEBUG("0", 0);
   731 	RDEBUG("0", 0);
   726 	std::auto_ptr<HbAction> endAction( q_check_ptr(new HbAction(hbTrId("txt_common_opt_delete"))) );
   732 	std::auto_ptr<HbAction> endAction( q_check_ptr(new HbAction(hbTrId("txt_common_opt_delete"))) );
   727 	connect(endAction.get(), SIGNAL(triggered()), this, SLOT(deleteList()));    
   733 	connect(endAction.get(), SIGNAL(triggered()), this, SLOT(deleteList()));
   728 	menu->addAction(endAction.get());
   734 	menu->addAction(endAction.get());
   729 	endAction.release();
   735 	endAction.release();
   730 	
   736 
   731 	QString title;
   737 	QString title;
   732 	if(mCertView == EPersonalView)
   738 	if(mCertView == EPersonalView)
   733 		{
   739 		{
   734 		title = "Move to Device";   
   740 		title = "Move to Device";
   735 		}
   741 		}
   736 	else if(mCertView == EDeviceView)
   742 	else if(mCertView == EDeviceView)
   737 		{
   743 		{
   738 		title = "Move to Personal";  
   744 		title = "Move to Personal";
   739 		}
   745 		}
   740 	std::auto_ptr<HbAction> moveAction(q_check_ptr(new HbAction(title)));
   746 	std::auto_ptr<HbAction> moveAction(q_check_ptr(new HbAction(title)));
   741 	connect(moveAction.get(), SIGNAL(triggered()), this, SLOT(moveCert()));    
   747 	connect(moveAction.get(), SIGNAL(triggered()), this, SLOT(moveCert()));
   742 	menu->addAction(moveAction.get());
   748 	menu->addAction(moveAction.get());
   743 	moveAction.release();
   749 	moveAction.release();
   744 	RDEBUG("0", 0);
   750 	RDEBUG("0", 0);
   745 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
   751 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
   746 			
   752 
   747 	HbListWidget* mCertificateList = q_check_ptr(new HbListWidget(this)); 
   753 	HbListWidget* mCertificateList = q_check_ptr(new HbListWidget(this));
   748 
   754 
   749 	for(int index = 0; index< count; index++)
   755 	for(int index = 0; index< count; index++)
   750 		{
   756 		{
   751 		QString certificateLabel = certLabel(index);
   757 		QString certificateLabel = certLabel(index);
   752 		std::auto_ptr<HbListWidgetItem> singleCert(q_check_ptr(new HbListWidgetItem()));
   758 		std::auto_ptr<HbListWidgetItem> singleCert(q_check_ptr(new HbListWidgetItem()));
   753 		singleCert->setText(certificateLabel);
   759 		singleCert->setText(certificateLabel);
   754 		mCertificateList->addItem(singleCert.get());
   760 		mCertificateList->addItem(singleCert.get());
   755 		singleCert.release();
   761 		singleCert.release();
   756 		}  // end of for loop
   762 		}  // end of for loop
   757 	
   763 
   758 	connect(mCertificateList, SIGNAL(activated(QModelIndex)), this, SLOT(openCertFromList(QModelIndex)));   
   764 	connect(mCertificateList, SIGNAL(activated(QModelIndex)), this, SLOT(openCertFromList(QModelIndex)));
   759 	connect(mCertificateList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF )), this, SLOT(indicateLongPress(HbAbstractViewItem*, QPointF))); 
   765 	connect(mCertificateList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF )), this, SLOT(indicateLongPress(HbAbstractViewItem*, QPointF)));
   760 	
   766 
   761 	layout->addItem(mCertificateList);
   767 	layout->addItem(mCertificateList);
   762 	RDEBUG("0", 0);
   768 	RDEBUG("0", 0);
   763 	// Refresh current view
   769 	// Refresh current view
   764 	QObject::connect(mRefreshedView , SIGNAL(aboutToClose()), this, SLOT(viewDone()));
   770 	QObject::connect(mRefreshedView , SIGNAL(aboutToClose()), this, SLOT(viewDone()));
   765 	mPrevView = mainWindow()->currentView();   
   771 	mPrevView = mainWindow()->currentView();
   766 	mainWindow()->addView(mRefreshedView);
   772 	mainWindow()->addView(mRefreshedView);
   767 	mainWindow()->setCurrentView(mRefreshedView); 
   773 	mainWindow()->setCurrentView(mRefreshedView);
   768 	mRefreshedView->setLayout(layout.get());
   774 	mRefreshedView->setLayout(layout.get());
   769 	layout.release();
   775 	layout.release();
   770 	RDEBUG("0", 0);
   776 	RDEBUG("0", 0);
   771 	}
   777 	}
   772 
   778 
   773 
   779 
   774 void CpCertView::viewDone()  
   780 void CpCertView::viewDone()
   775 	{
   781 	{
   776 	RDEBUG("0", 0);
   782 	RDEBUG("0", 0);
   777 	mCurrentView = mainWindow()->currentView();
   783 	mCurrentView = mainWindow()->currentView();
   778 	mCurrentView->deleteLater();
   784 	mCurrentView->deleteLater();
   779 	mCurrentView= NULL;
   785 	mCurrentView= NULL;
   780 	mainWindow()->setCurrentView(mOriginalView);  	
   786 	mainWindow()->setCurrentView(mOriginalView);
   781 	}
   787 	}
   782 void CpCertView::showTrustSettings()
   788 void CpCertView::showTrustSettings()
   783 	{
   789 	{
   784 	RDEBUG("0", 0);
   790 	RDEBUG("0", 0);
   785 	mCurrentView = q_check_ptr(new CpCertTrustView(mPos, *mCertDataContainer));    
   791 	mCurrentView = q_check_ptr(new CpCertTrustView(mPos, *mCertDataContainer));
   786 	connect(mCurrentView , SIGNAL(aboutToClose()), this, SLOT(saveTrustSettings()));
   792 	connect(mCurrentView , SIGNAL(aboutToClose()), this, SLOT(saveTrustSettings()));
   787 	mPrevView = mainWindow()->currentView();   
   793 	mPrevView = mainWindow()->currentView();
   788 	mainWindow()->addView(mCurrentView);
   794 	mainWindow()->addView(mCurrentView);
   789 	mainWindow()->setCurrentView(mCurrentView); 
   795 	mainWindow()->setCurrentView(mCurrentView);
   790 	}	
   796 	}
   791 
   797 
   792 void CpCertView::saveTrustSettings()
   798 void CpCertView::saveTrustSettings()
   793 	{
   799 	{
   794 	((CpCertTrustView*)mCurrentView)->saveTrustSettings();
   800 	((CpCertTrustView*)mCurrentView)->saveTrustSettings();
   795 	displayPreviousView();
   801 	displayPreviousView();
   815 		}
   821 		}
   816 	else if( mCertView == EDeviceView )
   822 	else if( mCertView == EDeviceView )
   817 		{
   823 		{
   818 		mNote->setText("Use of Personal certificates may require user confirmation. Proceed?");
   824 		mNote->setText("Use of Personal certificates may require user confirmation. Proceed?");
   819 		}
   825 		}
   820 	
   826 
   821 	mNote->setTimeout(HbPopup::NoTimeout);
   827 	mNote->setTimeout(HbPopup::NoTimeout);
   822 	mNote->setIconVisible (EFalse);
   828 	mNote->setIconVisible (EFalse);
   823 	mNote->open(this,SLOT(handleMoveDialog(HbAction*)));
   829 	mNote->open(this,SLOT(handleMoveDialog(HbAction*)));
   824 	RDEBUG("0", 0);
   830 	RDEBUG("0", 0);
   825 }
   831 }
   829 	RDEBUG("0", 0);
   835 	RDEBUG("0", 0);
   830 	if (action != mNote->primaryAction())
   836 	if (action != mNote->primaryAction())
   831 	    {
   837 	    {
   832 		return;
   838 		return;
   833 	    }
   839 	    }
   834 	
   840 
   835 	TInt count = mIndexList.Count();
   841 	TInt count = mIndexList.Count();
   836 	
   842 
   837 	for(TInt index = 0 ; index < count; ++index)
   843 	for(TInt index = 0 ; index < count; ++index)
   838 		{
   844 		{
   839 		CCTCertInfo* entry = NULL;
   845 		CCTCertInfo* entry = NULL;
   840 		if(mCertView == EPersonalView)
   846 		if(mCertView == EPersonalView)
   841 			{
   847 			{
   843 			}
   849 			}
   844 		else if(mCertView == EDeviceView)
   850 		else if(mCertView == EDeviceView)
   845 			{
   851 			{
   846 			entry = mCertDataContainer->iDeviceLabelEntries[ mIndexList[index] ]->iDeviceEntry;
   852 			entry = mCertDataContainer->iDeviceLabelEntries[ mIndexList[index] ]->iDeviceEntry;
   847 			}
   853 			}
   848 			
   854 
   849 		// Move key first
   855 		// Move key first
   850 		TCTKeyAttributeFilter keyFilter;
   856 		TCTKeyAttributeFilter keyFilter;
   851 		keyFilter.iKeyId = entry->SubjectKeyId();
   857 		keyFilter.iKeyId = entry->SubjectKeyId();
   852 		keyFilter.iPolicyFilter =  TCTKeyAttributeFilter::EAllKeys;
   858 		keyFilter.iPolicyFilter =  TCTKeyAttributeFilter::EAllKeys;
   853 		RDEBUG("0", 0);
   859 		RDEBUG("0", 0);
   854 		TUid sourceCertStoreUid = TUid::Uid(0);
   860 		TUid sourceCertStoreUid = TUid::Uid(0);
   855 		TUid targetCertStoreUid = TUid::Uid(0);
   861 		TUid targetCertStoreUid = TUid::Uid(0);
   856 		TUid sourceKeyStoreUid = TUid::Uid(0);
   862 		TUid sourceKeyStoreUid = TUid::Uid(0);
   857 		TUid targetKeyStoreUid = TUid::Uid(0);
   863 		TUid targetKeyStoreUid = TUid::Uid(0);
   858 				
   864 
   859 		if(mCertView == EPersonalView)
   865 		if(mCertView == EPersonalView)
   860 			{
   866 			{
   861 			sourceKeyStoreUid = KCMFileKeyStoreTokenUid;
   867 			sourceKeyStoreUid = KCMFileKeyStoreTokenUid;
   862 			targetKeyStoreUid = KCMDeviceKeyStoreTokenUid;
   868 			targetKeyStoreUid = KCMDeviceKeyStoreTokenUid;
   863 			sourceCertStoreUid = KCMFileCertStoreTokenUid;
   869 			sourceCertStoreUid = KCMFileCertStoreTokenUid;
   871 			targetCertStoreUid = KCMFileCertStoreTokenUid;
   877 			targetCertStoreUid = KCMFileCertStoreTokenUid;
   872 			}
   878 			}
   873 		RDEBUG("0", 0);
   879 		RDEBUG("0", 0);
   874 		try
   880 		try
   875 			{
   881 			{
   876 			
   882 
   877 			QT_TRAP_THROWING( mCertDataContainer->iWrapper->MoveKeyL( 
   883 			QT_TRAP_THROWING( mCertDataContainer->iWrapper->MoveKeyL(
   878 					mCertDataContainer->KeyManager(), keyFilter, sourceKeyStoreUid, targetKeyStoreUid ));
   884 					mCertDataContainer->KeyManager(), keyFilter, sourceKeyStoreUid, targetKeyStoreUid ));
   879 			
   885 
   880 			// Move certificate
   886 			// Move certificate
   881 			QT_TRAP_THROWING( mCertDataContainer->iWrapper->MoveCertL( 
   887 			QT_TRAP_THROWING( mCertDataContainer->iWrapper->MoveCertL(
   882 					mCertDataContainer->CertManager(), *entry, sourceCertStoreUid, targetCertStoreUid ) );
   888 					mCertDataContainer->CertManager(), *entry, sourceCertStoreUid, targetCertStoreUid ) );
   883 
   889 
   884 			}
   890 			}
   885 		catch(const std::exception& exception)
   891 		catch(const std::exception& exception)
   886 			{
   892 			{
   908 				QT_TRAP_THROWING(mCertDataContainer->ShowErrorNoteL( error.toInt()) );
   914 				QT_TRAP_THROWING(mCertDataContainer->ShowErrorNoteL( error.toInt()) );
   909 				User::Exit( KErrNone );
   915 				User::Exit( KErrNone );
   910 				}
   916 				}
   911 			// have to call straight away the Exit
   917 			// have to call straight away the Exit
   912 			// showing any error notes would corrupt the display
   918 			// showing any error notes would corrupt the display
   913 			User::Exit( error.toInt() );	
   919 			User::Exit( error.toInt() );
   914 			}
   920 			}
   915 		} // for
   921 		} // for
   916 	// Refresh current view
   922 	// Refresh current view
   917 	QT_TRAP_THROWING(refreshView(refreshListL()));	
   923 	QT_TRAP_THROWING(refreshView(refreshListL()));
   918 	delete mNote;
   924 	delete mNote;
   919 	mNote = NULL;
   925 	mNote = NULL;
   920 	RDEBUG("0", 0);
   926 	RDEBUG("0", 0);
   921 	}
   927 	}
   922 
   928