cpsecplugins/cpadvancedsecplugin/src/cpsecurityview.cpp
changeset 30 cc1cea6aabaf
parent 26 aad866c37519
child 59 881d92421467
equal deleted inserted replaced
26:aad866c37519 30:cc1cea6aabaf
    39 #include <hbabstractviewitem.h>
    39 #include <hbabstractviewitem.h>
    40 #include <HbMessageBox>
    40 #include <HbMessageBox>
    41 
    41 
    42 #include <memory>
    42 #include <memory>
    43 
    43 
       
    44 #include <../../inc/cpsecplugins.h>
       
    45 
    44 #include "cpsecurityview.h"
    46 #include "cpsecurityview.h"
    45 #include "cpsecmodview.h"
    47 #include "cpsecmodview.h"
    46 #include "cpcertview.h"
    48 #include "cpcertview.h"
    47 #include "cpsecmodmodel.h"
    49 #include "cpsecmodmodel.h"
    48 #include "cpsecmoduleinfoview.h"
    50 #include "cpsecmoduleinfoview.h"
    55 	  mCertView(NULL),
    57 	  mCertView(NULL),
    56 	  mCurrentView(NULL),
    58 	  mCurrentView(NULL),
    57 	  mPos(0),
    59 	  mPos(0),
    58 	  mNote(NULL)
    60 	  mNote(NULL)
    59 	{
    61 	{
       
    62 	RDEBUG("0", 0);
    60 	setTitle(hbTrId("txt_certificate_manager_setlabel_advanced_security"));
    63 	setTitle(hbTrId("txt_certificate_manager_setlabel_advanced_security"));
    61 	
    64 	
    62 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
    65 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
    63     HbListWidget* listCertView = q_check_ptr(new HbListWidget(this)); 
    66     HbListWidget* listCertView = q_check_ptr(new HbListWidget(this)); 
    64 
    67 
    85 
    88 
    86     connect(listCertView, SIGNAL(released(QModelIndex)), this, SLOT(displayCert(QModelIndex)));
    89     connect(listCertView, SIGNAL(released(QModelIndex)), this, SLOT(displayCert(QModelIndex)));
    87         
    90         
    88     HbListWidget* listSecView = q_check_ptr(new HbListWidget(this)); 
    91     HbListWidget* listSecView = q_check_ptr(new HbListWidget(this)); 
    89     QMap<QString,QString> keystoreLabels;
    92     QMap<QString,QString> keystoreLabels;
    90     
    93     RDEBUG("0", 0);
    91     try
    94     try
    92 		{
    95 		{
    93 		QT_TRAP_THROWING(
    96 		QT_TRAP_THROWING(
    94 		mSecModUIModel = CSecModUIModel::NewL();
    97 		mSecModUIModel = CSecModUIModel::NewL();
    95 		keystoreLabels = mSecModUIModel->LoadTokenLabelsL(); )
    98 		keystoreLabels = mSecModUIModel->LoadTokenLabelsL(); )
   121 		std::auto_ptr<HbListWidgetItem> emptyWidget(q_check_ptr(new HbListWidgetItem()));
   124 		std::auto_ptr<HbListWidgetItem> emptyWidget(q_check_ptr(new HbListWidgetItem()));
   122 		emptyWidget->setText("(no security modules)");
   125 		emptyWidget->setText("(no security modules)");
   123     	listSecView->addItem(emptyWidget.get());
   126     	listSecView->addItem(emptyWidget.get());
   124     	emptyWidget.release();
   127     	emptyWidget.release();
   125     	}
   128     	}
   126     
   129     RDEBUG("0", 0);
   127     std::auto_ptr<HbGroupBox> certificatesList(q_check_ptr(new HbGroupBox()));
   130     std::auto_ptr<HbGroupBox> certificatesList(q_check_ptr(new HbGroupBox()));
   128 	certificatesList->setHeading(hbTrId("txt_certificate_manager_setlabel_certificates"));
   131 	certificatesList->setHeading(hbTrId("txt_certificate_manager_setlabel_certificates"));
   129 	certificatesList->setContentWidget(listCertView);
   132 	certificatesList->setContentWidget(listCertView);
   130 	certificatesList->setCollapsed(true);
   133 	certificatesList->setCollapsed(true);
   131 	layout->addItem(certificatesList.get());
   134 	layout->addItem(certificatesList.get());
   142 	securityModuleList->setContentWidget(listSecView);
   145 	securityModuleList->setContentWidget(listSecView);
   143 	securityModuleList->setCollapsed(true);
   146 	securityModuleList->setCollapsed(true);
   144 	layout->addItem(securityModuleList.get());
   147 	layout->addItem(securityModuleList.get());
   145 	securityModuleList.release();
   148 	securityModuleList.release();
   146 	
   149 	
       
   150 	mContextMenu = q_check_ptr(new HbMenu());
       
   151 	
   147 	setLayout(layout.get()); 
   152 	setLayout(layout.get()); 
   148 	layout.release();
   153 	layout.release();
   149 	}
   154 	}
   150 
   155 
   151 
   156 
   172 		}
   177 		}
   173 	
   178 	
   174 	delete mSecModUIModel;  
   179 	delete mSecModUIModel;  
   175 	
   180 	
   176 	delete mNote;
   181 	delete mNote;
       
   182 	delete mContextMenu;
   177 	}
   183 	}
   178 
   184 
   179 void CpSecurityView::showCodeView()
   185 void CpSecurityView::showCodeView()
   180 	{
   186 	{
       
   187 	RDEBUG("0", 0);
   181 	try
   188 	try
   182 		{
   189 		{
   183 		mSecModView = q_check_ptr(new CpSecModView(mPos, *mSecModUIModel));    
   190 		mSecModView = q_check_ptr(new CpSecModView(mPos, *mSecModUIModel));    
   184 		QObject::connect(mSecModView , SIGNAL(aboutToClose()), this, SLOT(viewDone()));
   191 		QObject::connect(mSecModView , SIGNAL(aboutToClose()), this, SLOT(viewDone()));
   185 		mPreView = mainWindow()->currentView();   //suppose mPreView  is member variable of CpSecurityView
   192 		mPreView = mainWindow()->currentView();   //suppose mPreView  is member variable of CpSecurityView
   198 	showCodeView();	
   205 	showCodeView();	
   199 	}
   206 	}
   200 
   207 
   201 void CpSecurityView::showWIMview()
   208 void CpSecurityView::showWIMview()
   202 	{
   209 	{
       
   210 	RDEBUG("0", 0);
   203 	try
   211 	try
   204 		{
   212 		{
   205 		QObject::connect(mSecModView , SIGNAL(aboutToClose()), this, SLOT(viewDone()));
   213 		QObject::connect(mSecModView , SIGNAL(aboutToClose()), this, SLOT(viewDone()));
   206 		mPreView = mainWindow()->currentView();   //suppose mPreView  is member variable of CpSecurityView
   214 		mPreView = mainWindow()->currentView();   //suppose mPreView  is member variable of CpSecurityView
   207 		mainWindow()->addView(mSecModView);
   215 		mainWindow()->addView(mSecModView);
   228 		}
   236 		}
   229 	}
   237 	}
   230 
   238 
   231 void CpSecurityView::displayCert(const QModelIndex& modelIndex)
   239 void CpSecurityView::displayCert(const QModelIndex& modelIndex)
   232 	{
   240 	{
       
   241 	RDEBUG("0", 0);
   233 	try
   242 	try
   234 	{
   243 	{
   235 	mCertView = q_check_ptr(new CpCertView(modelIndex));    
   244 	mCertView = q_check_ptr(new CpCertView(modelIndex));    
   236 	connect(mCertView , SIGNAL(aboutToClose()), this, SLOT(displayPrevious()));
   245 	connect(mCertView , SIGNAL(aboutToClose()), this, SLOT(displayPrevious()));
   237 	mPreView = mainWindow()->currentView();   
   246 	mPreView = mainWindow()->currentView();   
   244 		}
   253 		}
   245 	}
   254 	}
   246 
   255 
   247 void CpSecurityView::displayPrevious()  
   256 void CpSecurityView::displayPrevious()  
   248 	{
   257 	{
       
   258 	RDEBUG("0", 0);
   249 	try
   259 	try
   250 		{
   260 		{
   251 		mainWindow()->removeView(mCertView);    
   261 		mainWindow()->removeView(mCertView);    
   252 		mCertView->deleteLater();
   262 		mCertView->deleteLater();
   253 		mCertView= NULL;
   263 		mCertView= NULL;
   259 		}
   269 		}
   260 	}
   270 	}
   261 
   271 
   262 void CpSecurityView::indicateLongPress(HbAbstractViewItem *item,QPointF coords)
   272 void CpSecurityView::indicateLongPress(HbAbstractViewItem *item,QPointF coords)
   263 	{
   273 	{
   264 	try
   274 	RDEBUG("0", 0);
   265 		{
   275 	try
   266 		std::auto_ptr<HbMenu> contextMenu(q_check_ptr(new HbMenu()));
   276 		{
       
   277 		mContextMenu->clearActions();
   267 		mPos = item->modelIndex().row();   
   278 		mPos = item->modelIndex().row();   
   268 		
   279 		
   269 		std::auto_ptr<HbAction> openModule(q_check_ptr(new HbAction("Open")));     
   280 		std::auto_ptr<HbAction> openModule(q_check_ptr(new HbAction("Open")));     
   270 		connect(openModule.get(), SIGNAL(triggered()), this, SLOT( showCodeView()));    
   281 		connect(openModule.get(), SIGNAL(triggered()), this, SLOT( showCodeView()));    
   271 		contextMenu->addAction(openModule.get());
   282 		mContextMenu->addAction(openModule.get());
   272 		openModule.release();
   283 		openModule.release();
   273 		
   284 		
   274 		if(mSecModUIModel->IsTokenDeletable(mPos))
   285 		if(mSecModUIModel->IsTokenDeletable(mPos))
   275 			{
   286 			{
   276 			std::auto_ptr<HbAction> deleteModule(q_check_ptr(new HbAction("Delete")));     
   287 			std::auto_ptr<HbAction> deleteModule(q_check_ptr(new HbAction("Delete")));     
   277 			connect(deleteModule.get(), SIGNAL(triggered()), this, SLOT( deleteModule()));    
   288 			connect(deleteModule.get(), SIGNAL(triggered()), this, SLOT( deleteModule()));    
   278 			contextMenu->addAction(deleteModule.get());
   289 			mContextMenu->addAction(deleteModule.get());
   279 			deleteModule.release();
   290 			deleteModule.release();
   280 			}
   291 			}
   281 		
   292 		
   282 		std::auto_ptr<HbAction> moduleInfo(q_check_ptr(new HbAction("Module Info")));     
   293 		std::auto_ptr<HbAction> moduleInfo(q_check_ptr(new HbAction("Module Info")));     
   283 		connect(moduleInfo.get(), SIGNAL(triggered()), this, SLOT( moduleDetails()));    
   294 		connect(moduleInfo.get(), SIGNAL(triggered()), this, SLOT( moduleDetails()));    
   284 		contextMenu->addAction(moduleInfo.get());
   295 		mContextMenu->addAction(moduleInfo.get());
   285 		moduleInfo.release();
   296 		moduleInfo.release();
   286 				
   297 				
   287 		contextMenu->open();
   298 		mContextMenu->setPreferredPos(coords);
   288 		contextMenu->setPreferredPos(coords);
   299 		mContextMenu->open();
   289 		}
   300 		}
   290 	catch(const std::exception& exception)
   301 	catch(const std::exception& exception)
   291 		{
   302 		{
   292 		HbMessageBox::information(exception.what());
   303 		HbMessageBox::information(exception.what());
   293 		}
   304 		}
   294 	}
   305 	}
   295 
   306 
   296 void CpSecurityView::deleteModule()
   307 void CpSecurityView::deleteModule()
   297 	{
   308 	{
       
   309 	RDEBUG("0", 0);
   298 	try
   310 	try
   299 		{
   311 		{
   300 		
   312 		
   301 		delete mNote;
   313 		delete mNote;
   302 		mNote = NULL;
   314 		mNote = NULL;
   318 		}
   330 		}
   319 
   331 
   320 }
   332 }
   321 void CpSecurityView::dialogClosed(HbAction* action)
   333 void CpSecurityView::dialogClosed(HbAction* action)
   322 {
   334 {
       
   335 	RDEBUG("0", 0);
   323 	if (action != mNote->primaryAction())
   336 	if (action != mNote->primaryAction())
   324 		{
   337 		{
   325 		return;
   338 		return;
   326 		}
   339 		}
   327 		
   340 		
   337 		}
   350 		}
   338 	}
   351 	}
   339 
   352 
   340 void CpSecurityView::moduleDetails()
   353 void CpSecurityView::moduleDetails()
   341 	{
   354 	{
       
   355 	RDEBUG("0", 0);
   342 	try
   356 	try
   343 		{
   357 		{
   344 		QVector< QPair<QString,QString> > securityDetails;
   358 		QVector< QPair<QString,QString> > securityDetails;
   345 		QT_TRAP_THROWING(securityDetails = mSecModUIModel->SecModDetailsL(mPos));
   359 		QT_TRAP_THROWING(securityDetails = mSecModUIModel->SecModDetailsL(mPos));
   346 		mModuleinfoView = q_check_ptr(new CpSecmoduleInfoView(securityDetails));
   360 		mModuleinfoView = q_check_ptr(new CpSecmoduleInfoView(securityDetails));
   356 		}
   370 		}
   357 	}
   371 	}
   358 
   372 
   359 void CpSecurityView::displayPreviousFromModInfo()  
   373 void CpSecurityView::displayPreviousFromModInfo()  
   360 	{
   374 	{
       
   375 	RDEBUG("0", 0);
   361 	try
   376 	try
   362 		{
   377 		{
   363 		mainWindow()->removeView(mModuleinfoView);    
   378 		mainWindow()->removeView(mModuleinfoView);    
   364 		mCertView->deleteLater();
   379 		mCertView->deleteLater();
   365 		mCertView= NULL;
   380 		mCertView= NULL;