# HG changeset patch # User hgs # Date 1287053771 -10800 # Node ID 989397f9511c8e58360447f698c9beeaaa5b9ae7 # Parent 3255e7d5bd6768fd305c46cd96611f135abd915f 201039_03 diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/cpadvancedsecplugin.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/cpadvancedsecplugin.pro Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,108 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: Advanced security settings (control panel plugin) +# + +TEMPLATE = lib +TARGET = cpadvancedsecplugin +CONFIG += hb plugin +LIBS += -lcpframework + +HEADERS += inc/advsecsettingsloader.h \ + inc/advsecsettingscertificatemodel.h \ + inc/advsecsettingscertificate.h \ + inc/advsecsettingstrustedcertusageuids.h \ + inc/advsecsettingsstoreuids.h \ + inc/advsecsettingsviewbase.h \ + inc/advsecsettingsmainview.h \ + inc/advsecsettingscertificatelistview.h \ + inc/advsecsettingscertificatedetailview.h \ + inc/advsecsettingscerttrustsettingsview.h \ + inc/advsecsettingssecuritymodulemodel.h \ + inc/advsecsettingssecuritymoduleview.h \ + inc/advsecsettingssecuritymoduledetailview.h + +SOURCES += src/advsecsettingsloader.cpp \ + src/advsecsettingscertificatemodel.cpp \ + src/advsecsettingscertificate.cpp \ + src/advsecsettingsviewbase.cpp \ + src/advsecsettingsmainview.cpp \ + src/advsecsettingscertificatelistview.cpp \ + src/advsecsettingscertificatedetailview.cpp \ + src/advsecsettingscerttrustsettingsview.cpp \ + src/advsecsettingssecuritymodulemodel.cpp \ + src/advsecsettingssecuritymoduleview.cpp \ + src/advsecsettingssecuritymoduledetailview.cpp + +symbian: { + TARGET.CAPABILITY = CAP_ECOM_PLUGIN + TARGET.UID3 = 0X2002E684 + TARGET.EPOCALLOWDLLDATA = 1 + + INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE + + LIBS += -lefsrv # RFs + LIBS += -lcertstore # CUnifiedCertStore + LIBS += -lctframework # CCTCertInfo + LIBS += -lx509 # CX509Certificate + LIBS += -lpkixcert # CPKIXValidationResult + LIBS += -lX509CertNameParser # X509CertNameParser + LIBS += -lhash # CMD5 + LIBS += -lDevTokenClient # CTrustSitesStore + LIBS += -lcryptography # CRSAParameters, CDSAPublicKey, TInteger::BitCount + LIBS += -lcrypto # CValidityPeriod, CSignedObject, CAlgorithmIdentifier + + PLUGIN_STUB_PATH = /resource/qt/plugins/controlpanel + + deploy.path = C: + pluginstub.sources = $${TARGET}.dll + pluginstub.path = $$PLUGIN_STUB_PATH + DEPLOYMENT += pluginstub + + qtplugins.path = $$PLUGIN_STUB_PATH + qtplugins.sources += qmakepluginstubs/$${TARGET}.qtplugin + + BLD_INF_RULES.prj_exports += \ + "$${LITERAL_HASH}include " \ + "rom/cpadvancedsecplugin.iby CORE_APP_LAYER_IBY_EXPORT_PATH(cpadvancedsecplugin.iby)" \ + "rom/cpadvancedsecplugin_resources.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(cpadvancedsecplugin_resources.iby)" + + for(qtplugin, qtplugins.sources):BLD_INF_RULES.prj_exports += "./$$qtplugin $$deploy.path$$qtplugins.path/$$basename(qtplugin)" + + MMP_RULES += SMPSAFE + + HEADERS += inc/advsecsettingscertificatemodel_symbian_p.h \ + inc/advsecsettingscertlistbuilder_symbian.h \ + inc/advsecsettingscertdetailsbuilder_symbian.h \ + inc/advsecsettingslabeledcertinfo_symbian.h \ + inc/advsecsettingscertmover_symbian.h \ + inc/advsecsettingssecuritymodulemodel_symbian_p.h \ + inc/advsecsettingssecuritymodule_symbian.h \ + inc/advsecsettingssecuritymoduleeraser_symbian.h + SOURCES += src/advsecsettingscertificatemodel_symbian_p.cpp \ + src/advsecsettingscertlistbuilder_symbian.cpp \ + src/advsecsettingscertdetailsbuilder_symbian.cpp \ + src/advsecsettingslabeledcertinfo_symbian.cpp \ + src/advsecsettingscertmover_symbian.cpp \ + src/advsecsettingssecuritymodulemodel_symbian_p.cpp \ + src/advsecsettingssecuritymodule_symbian.cpp \ + src/advsecsettingssecuritymoduleeraser_symbian.cpp +} else { + HEADERS += inc/advsecsettingscertificatemodel_stub_p.h \ + inc/advsecsettingssecuritymodulemodel_stub_p.h + SOURCES += src/advsecsettingscertificatemodel_stub_p.cpp \ + src/advsecsettingssecuritymodulemodel_stub_p.cpp +} + +TRANSLATIONS = certificate_manager.ts diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/group/advancedsecplugin.pri --- a/cpsecplugins/cpadvancedsecplugin/group/advancedsecplugin.pri Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# Initial Contributors: -# Nokia Corporation - initial contribution. -# Contributors: -# Description: advancedsecplugin source files - -# Input -HEADERS += ../inc/cpcertdatacontainer.h \ - ../inc/cpcertdetailview.h \ - ../inc/cpcertmanuisyncwrapper.h \ - ../inc/cpcerttrustview.h \ - ../inc/cpcertview.h \ - ../inc/cpcertpluginloader.h \ - ../inc/cpsecurityview.h \ - ../inc/cpuitrustids.h \ - ../inc/cpsecmodview.h \ - ../inc/cpsecmodmodel.h \ - ../inc/cpsecmodsyncwrapper.h \ - ../inc/cpmoduleview.h \ - ../inc/cpsecmoduleinfoview.h - -SOURCES += ../src/cpcertdatacontainer.cpp \ - ../src/cpcertdetailview.cpp \ - ../src/cpcertmanuisyncwrapper.cpp \ - ../src/cpcerttrustview.cpp \ - ../src/cpcertview.cpp \ - ../src/cpcertpluginloader.cpp \ - ../src/cpsecurityview.cpp \ - ../src/cpsecmodview.cpp \ - ../src/cpsecmodsyncwrapper.cpp \ - ../src/cpsecmodmodel.cpp \ - ../src/cpmoduleview.cpp \ - ../src/cpsecmoduleinfoview.cpp - diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/group/advancedsecplugin.pro --- a/cpsecplugins/cpadvancedsecplugin/group/advancedsecplugin.pro Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ - -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# - -TEMPLATE = lib -TARGET = cpadvancedsecplugin - -CONFIG += hb plugin - -LIBS += -lcpframework - -include ( advancedsecplugin.pri ) -include ( ../rom/cpsecplugins_rom.pri ) - -symbian: { - TARGET.CAPABILITY = CAP_ECOM_PLUGIN - TARGET.UID3 = 0X2002E684 - INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE - INCLUDEPATH += ../inc - TARGET.EPOCALLOWDLLDATA = 1 - LIBS += -lcertstore - LIBS += -lCTFramework - LIBS += -lX509 - LIBS += -lpkixcert - LIBS += -lx509certnameparser - LIBS += -lhash - LIBS += -lcryptography - LIBS += -lDevTokenClient - LIBS += -lcrypto - LIBS += -lefsrv - - PLUGIN_STUB_PATH = /resource/qt/plugins/controlpanel - - deploy.path = C: - pluginstub.sources = $${TARGET}.dll - pluginstub.path = $$PLUGIN_STUB_PATH - DEPLOYMENT += pluginstub - - qtplugins.path = $$PLUGIN_STUB_PATH - qtplugins.sources += qmakepluginstubs/$${TARGET}.qtplugin - - for(qtplugin, qtplugins.sources):BLD_INF_RULES.prj_exports += "./$$qtplugin $$deploy.path$$qtplugins.path/$$basename(qtplugin)" - } - -TRANSLATIONS= certificate_manager.ts diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertdetailsbuilder_symbian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertdetailsbuilder_symbian.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to construct certificate details +* +*/ + +#ifndef ADVSECSETTINGSCERTDETAILSBUILDER_SYMBIAN_H +#define ADVSECSETTINGSCERTDETAILSBUILDER_SYMBIAN_H + +#include // CActive +#include // RMPointerArray +#include // CUnifiedCertStore +#include + +class RFs; +class CUnifiedCertStore; +class CUnifiedKeyStore; +class CCTCertInfo; +class CCTKeyInfo; +class CCertAttributeFilter; +class TCTKeyAttributeFilter; + + +/** + * Certificate details helper class. + */ +class CAdvSecSettingsCertDetailsBuilder : public CActive +{ +public: // constructor and destructor + static CAdvSecSettingsCertDetailsBuilder *NewL(RFs &aFs, CUnifiedCertStore &aCertStore); + ~CAdvSecSettingsCertDetailsBuilder(); + +public: // new functions + void GetDetailsL(const CCTCertInfo &aCert, QMap &aDetails, + TRequestStatus &aStatus); + +protected: // from CActive + void DoCancel(); + void RunL(); + TInt RunError(TInt aError); + +private: // new functions + CAdvSecSettingsCertDetailsBuilder(RFs &aFs, CUnifiedCertStore &aCertStore); + void ConstructL(); + void InitializeKeyStoreL(); + void RetrieveCertificateL(); + void ListKeysL(); + void ReturnCertificateDetailsL(); + void AppendLabelL(); + void AppendIssuerL(); + void AppendSubjectL(); + void AppendValidityPeriodL(); + void AppendLocationL(); + void AppendFormatL(); + void AppendKeyUsageL(); + void AppendAlgorithmL(); + void AppendSerialNumberL(); + void AppendFingerprintsL(); + void AppendPublicKeyL(); + void AppendTrustedSitesL(); + QString CertificateFormatStringL(const TCertificateFormat aFormat) const; + QString AlgorithmNameStringL(TAlgorithmId aAlgorithmId) const; + +private: // data + RFs &iFs; + CUnifiedCertStore &iCertStore; + const CCTCertInfo *iCertInfo; // not owned + TRequestStatus *iClientStatus; // not owned + QMap *iDetails; // not owned + + CCertificate *iCertificate; + HBufC8 *iCertificateUrl; + TPtr8 iCertUrlPtr; + + CUnifiedKeyStore *iKeyStore; + TCTKeyAttributeFilter *iKeyFilter; + RMPointerArray iKeys; + + enum TDetailsBuilderState { + ENotInitialized, + EInitializingKeyStore, + ERetrievingCertificate, + EListingKeys, + EIdle, + EFailed + } iState; +}; + +#endif // ADVSECSETTINGSCERTDETAILSBUILDER_SYMBIAN_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertificate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertificate.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Certificate class in advanced security settings +* +*/ + +#ifndef ADVSECSETTINGSCERTIFICATE_H +#define ADVSECSETTINGSCERTIFICATE_H + +#include + + +/** + * Certificate class in advances security settings. + */ +class AdvSecSettingsCertificate : public QObject +{ + Q_OBJECT + +public: // new definitions + enum CertificateType { + NotDefined, + AuthorityCertificate, + TrustedSiteCertificate, + PersonalCertificate, + DeviceCertificate + }; + +public: // constructor and destructor + explicit AdvSecSettingsCertificate(QObject *parent = 0); + virtual ~AdvSecSettingsCertificate(); + +public: // new functions + CertificateType certType() const; + void setCertType(CertificateType type); + + const QString &label() const; + void setLabel(const QString &label); + + int modelIndex() const; + void setModelIndex(int index); + +private: // new functions + Q_DISABLE_COPY(AdvSecSettingsCertificate) + +private: // data + CertificateType mCertType; + QString mLabel; + int mModelIndex; +}; + + +#endif // ADVSECSETTINGSCERTIFICATE_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertificatedetailview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertificatedetailview.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Certificate detail view in advanced security settings +* +*/ + +#ifndef ADVSECSETTINGSCERTIFICATEDETAILVIEW_H +#define ADVSECSETTINGSCERTIFICATEDETAILVIEW_H + +#include "advsecsettingsviewbase.h" + +class AdvSecSettingsCertificate; +class AdvSecSettingsCertificateModel; +class HbGroupBox; +class HbScrollArea; +class HbLabel; + + +/** + * Certificate detail view in advanced security settings. Certificate + * detail view shows certificate details (subject, issuer, validity + * dates, fingerprints, etc). + */ +class AdvSecSettingsCertificateDetailView : public AdvSecSettingsViewBase +{ + Q_OBJECT + +public: // constructor and destructor + explicit AdvSecSettingsCertificateDetailView(AdvSecSettingsCertificateModel &model, + QGraphicsItem *parent = 0); + virtual ~AdvSecSettingsCertificateDetailView(); + +public: // new functions + void setCertificate(const AdvSecSettingsCertificate &cert); + +private slots: + void certificateDetailsCompleted(); + void showTrustSettings(); + void deleteCertificate(); + void deleteConfirmationAccepted(); + +private: // data + AdvSecSettingsCertificateModel &mModel; + const AdvSecSettingsCertificate *mCertificate; // not owned + QMap mDetails; + HbGroupBox *mViewLabel; + HbScrollArea *mScrollArea; + HbLabel *mDetailsText; +}; + +#endif // ADVSECSETTINGSCERTIFICATEDETAILVIEW_H + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertificatelistview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertificatelistview.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Certificate list view in advanced security settings +* +*/ + +#ifndef ADVSECSETTINGSCERTIFICATELISTVIEW_H +#define ADVSECSETTINGSCERTIFICATELISTVIEW_H + +#include "advsecsettingsviewbase.h" +#include "advsecsettingscertificate.h" // CertificateType + +class HbAbstractViewItem; +class HbGroupBox; +class HbListWidget; +class HbLabel; +class HbStackedWidget; +class AdvSecSettingsCertificateModel; +class AdvSecSettingsCertificateDetailView; +class AdvSecSettingsCertTrustSettingsView; + + +/** + * Certificate list view in advanced security settings. Certificate + * list view shows certificate list -- either authority certificates, + * list, trusted site certificates list, personal certificates list, + * or dervice certificates list. + */ +class AdvSecSettingsCertificateListView : public AdvSecSettingsViewBase +{ + Q_OBJECT + +public: // constructor and destructor + explicit AdvSecSettingsCertificateListView(QGraphicsItem *parent = 0); + virtual ~AdvSecSettingsCertificateListView(); + +public: // new functions + void displayCertificates(AdvSecSettingsCertificate::CertificateType type); + void setCurrentIndex(const QModelIndex& index); + +private slots: + void indicateLongPress(HbAbstractViewItem *item, const QPointF &position); + void openCertificate(const QModelIndex& modelIndex); + void openCurrentCertificate(); + void displayCurrentCertTrustSettings(); + void deleteCurrentCertificate(); + void deleteConfirmationAccepted(); + void moveCurrentCertToDeviceCertificates(); + void moveToDeviceCertsConfirmationAccepted(); + void moveCurrentCertToPersonalCertificates(); + void moveToPersonalCertsConfirmationAccepted(); + void readAllCertificatesFromModel(); + void displayAllCertificatesReadFromModel(); + void refreshAfterCurrentCertRemoved(); + +private: // new functions + void clearModelCertificates(); + void refreshDisplayedCertificates(); + +private: // data + AdvSecSettingsCertificate::CertificateType mCertType; + HbGroupBox *mViewLabel; + HbListWidget *mListWidget; // Displayed cert list, for example Authority certificates + HbLabel *mEmptyText; + HbLabel *mRetrievingText; + HbStackedWidget *mStackedWidget; + bool mIsRetrieving; + QList mModelCertificateList; // All certs read from model + QList mDisplayedCertificates; // Displayed (like Authority) certs + AdvSecSettingsCertificateModel *mModel; + AdvSecSettingsCertificateDetailView *mDetailView; + AdvSecSettingsCertTrustSettingsView *mTrustSettingsView; + AdvSecSettingsCertificate *mCurrentCertificate; // not owned +}; + +#endif // ADVSECSETTINGSCERTIFICATELISTVIEW_H + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertificatemodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertificatemodel.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Certificate handling model in advanced security settings +* +*/ + +#ifndef ADVSECSETTINGSCERTIFICATEMODEL_H +#define ADVSECSETTINGSCERTIFICATEMODEL_H + +#include +#include +#include + +class AdvSecSettingsCertificateModelPrivate; +class AdvSecSettingsCertificate; + + +/** + * Certificate handling engine in advanced security settings control panel plugin. + */ +class AdvSecSettingsCertificateModel : public QObject +{ + Q_OBJECT + +public: // constructor and destructor + explicit AdvSecSettingsCertificateModel(QObject *parent = 0); + virtual ~AdvSecSettingsCertificateModel(); + +public: // new definitions + enum AdvSecSettingsCertificateDetailsField { + Label, + Issuer, + Subject, + ValidFrom, + ValidTo, + Location, + Format, + KeyUsage, + KeyLocation, + Algorithm, + SerialNumber, + FingerprintSHA1, + FingerprintMD5, + PublicKey, + TrustedSites + }; + +public: // new functions + void initialize(); // asynchronous + void getCertificates(QList &certList); // asynchronous + void getCertificateDetails(const AdvSecSettingsCertificate &cert, + QMap &details); // asynchronous + bool isDeletable(const AdvSecSettingsCertificate &cert) const; + void deleteCertificate(const AdvSecSettingsCertificate &cert); // asynchronous + void getTrustSettings(const AdvSecSettingsCertificate &cert, + QMap &usageIdAndTrust); // asynchronous + void setTrustSettings(const AdvSecSettingsCertificate &cert, + const QMap &usageIdAndTrust); // asynchronous + void getCertificateUsageNames(QMap &usageIdAndName); + void moveToPersonalCertificates(const AdvSecSettingsCertificate &cert); // asynchronous + void moveToDeviceCertificates(const AdvSecSettingsCertificate &cert); // asynchronous + +signals: // new signals + void initializeCompleted(); + void getCertificatesCompleted(); + void getCertificateDetailsCompleted(); + void deleteCertificateCompleted(); + void getTrustSettingsCompleted(); + void setTrustSettingsCompleted(); + void moveToPersonalCertificatesCompleted(); + void moveToDeviceCertificatesCompleted(); + void errorOccurred(int error); + +protected: // new functions + void handleInitializeCompleted(); + void handleGetCertificatesCompleted(); + void handleGetCertificateDetailsCompleted(); + void handleDeleteCertificateCompleted(); + void handleGetTrustSettingsCompleted(); + void handleSetTrustSettingsCompleted(); + void handleMoveToPersonalCertificateCompleted(); + void handleMoveToDeviceCertificatesCompleted(); + void handleError(int error); + +private: // data + Q_DISABLE_COPY(AdvSecSettingsCertificateModel) + friend class AdvSecSettingsCertificateModelPrivate; + AdvSecSettingsCertificateModelPrivate *d_ptr; +}; + +#endif // ADVSECSETTINGSCERTIFICATEMODEL_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertificatemodel_stub_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertificatemodel_stub_p.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Generic stub for platform specific private certificate handling model +* +*/ + +#ifndef ADVSECSETTINGSCERTIFICATEMODELPRIVATE_STUB_H +#define ADVSECSETTINGSCERTIFICATEMODELPRIVATE_STUB_H + +#include +#include + +class AdvSecSettingsCertificateModel; +class AdvSecSettingsCertificate; + + +/** + * Generic stub for platform specific private certificate handling model. + * This is just a stub. Real functionality is provided in platform specific + * AdvSecSettingsCertificateModelPrivate implementations. + */ +class AdvSecSettingsCertificateModelPrivate : public QObject +{ + Q_OBJECT + +public: + explicit AdvSecSettingsCertificateModelPrivate( + AdvSecSettingsCertificateModel *q); + virtual ~AdvSecSettingsCertificateModelPrivate(); + + void initialize(); + void getCertificates(QList &certList); + void getCertificateDetails(const AdvSecSettingsCertificate &cert, + QMap &details); + bool isDeletable(const AdvSecSettingsCertificate &cert) const; + void deleteCertificate(const AdvSecSettingsCertificate &cert); + void getTrustSettings(const AdvSecSettingsCertificate &cert, + QMap &usageIdAndTrust); + void setTrustSettings(const AdvSecSettingsCertificate &cert, + const QMap &usageIdAndTrust); + void getCertificateUsageNames(QMap &usageIdAndName); + void moveToPersonalCertificates(const AdvSecSettingsCertificate &cert); + void moveToDeviceCertificates(const AdvSecSettingsCertificate &cert); + +private: + Q_DISABLE_COPY(AdvSecSettingsCertificateModelPrivate) + AdvSecSettingsCertificateModel *q_ptr; +}; + +#endif // ADVSECSETTINGSCERTIFICATEMODELPRIVATE_STUB_H + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertificatemodel_symbian_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertificatemodel_symbian_p.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Symbian specific advanced security settings certificate model +* +*/ + +#ifndef CPADVSECSETTINGSMODELPRIVATE_SYMBIAN_H +#define CPADVSECSETTINGSMODELPRIVATE_SYMBIAN_H + +#include // CActive +#include // RFs +#include // CUnifiedCertStore related +#include + +class AdvSecSettingsCertificateModel; +class AdvSecSettingsCertificate; +class CAdvSecSettingsCertListBuilder; +class CAdvSecSettingsCertDetailsBuilder; +class CCertificateAppInfoManager; +class CAdvSecSettingsCertMover; + + +/** + * Symbian specific advanced security settings certificate model. + */ +class AdvSecSettingsCertificateModelPrivate : public CActive +{ +public: // constructor and destructor + explicit AdvSecSettingsCertificateModelPrivate( + AdvSecSettingsCertificateModel *q = 0); + ~AdvSecSettingsCertificateModelPrivate(); + +public: // new functions + void initialize(); + void getCertificates(QList &certList); + void getCertificateDetails(const AdvSecSettingsCertificate &cert, + QMap &details); + bool isDeletable(const AdvSecSettingsCertificate &cert) const; + void deleteCertificate(const AdvSecSettingsCertificate &cert); + void getTrustSettings(const AdvSecSettingsCertificate &cert, + QMap &usageIdAndTrust); + void setTrustSettings(const AdvSecSettingsCertificate &cert, + const QMap &usageIdAndTrust); + void getCertificateUsageNames(QMap &usageIdAndName); + void moveToPersonalCertificates(const AdvSecSettingsCertificate &cert); + void moveToDeviceCertificates(const AdvSecSettingsCertificate &cert); + +protected: // from CActive + void DoCancel(); + void RunL(); + TInt RunError(TInt aError); + +private: // new functions + Q_DISABLE_COPY(AdvSecSettingsCertificateModelPrivate) + void ConstructL(); + TInt ResetCertAttributeFilter(); + TInt ResetCertInfoArray(); + void ReturnTrustSettingsDetails(); + void DoGetCertificateUsageNamesL(QMap &usageIdAndName); + const CCTCertInfo *CertificateInfo(const AdvSecSettingsCertificate &cert) const; + +private: // data + AdvSecSettingsCertificateModel *q_ptr; + + enum TState { + ENotInitialized, + EInitializing, + EIdle, + EGettingCertificatesList, + EGettingCertificatesRetrieve, + EBuildingCertificateDetails, + EDeletingCertificate, + EReadingApplications, + EWritingApplications, + EMovingCertificateToPersonalStore, + EMovingCertificateToDeviceStore + } iState; + + RFs iFs; + CUnifiedCertStore *iCertStore; + + /* + * Common to all certificate specific asynchronous methods. Member iCertInfo + * contains pointer to the current certificate being processed. Member + * iCertInfoArray contains all certificates read from certificate databases. + */ + const CCTCertInfo *iCertInfo; // not owned + RMPointerArray iCertInfoArray; + + /* + * for getCertificates method. Certificate list is constructed using + * iCertListBuilder member, which returns data directly to the client. + */ + CAdvSecSettingsCertListBuilder *iCertListBuilder; + + /* + * For getCertificateDetails method. Certificate details are constructed + * using iDetailsBuilder member, which returns data directly to the client. + */ + CAdvSecSettingsCertDetailsBuilder *iDetailsBuilder; + + /* + * For getTrustSettings method. Data is retrieved from certificate store into + * iApplications member, and then returned to client via iTrustedUids member. + */ + QMap *iTrustedUids; // not owned + RArray iApplications; + + /* + * For getTrustSettings and getCertificateUsageNames methods to get possible + * certificate application (usage) ids and their names. + */ + CCertificateAppInfoManager *iCertAppInfoManager; + + /* + * For moveToPersonalCertificates and moveToDeviceCertificates methods. + * Takes care of moving certificate and it's key to given target store. + */ + CAdvSecSettingsCertMover *iMover; +}; + +#endif // CPADVSECSETTINGSMODELPRIVATE_SYMBIAN_H + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertlistbuilder_symbian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertlistbuilder_symbian.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to construct certificate list +* +*/ + +#ifndef ADVSECSETTINGSCERTLISTBUILDER_SYMBIAN_H +#define ADVSECSETTINGSCERTLISTBUILDER_SYMBIAN_H + +#include // CActive +#include "advsecsettingscertificate.h" // CertificateType +#include // RMPointerArray +#include // CUnifiedCertStore +#include + +class RFs; +class CCTCertInfo; +class CCertAttributeFilter; +class CAdvSecSettingsLabeledCertInfo; + + +/** + * Certificate list builder helper class. + */ +class CAdvSecSettingsCertListBuilder : public CActive +{ +public: // constructor and destructor + static CAdvSecSettingsCertListBuilder *NewL(RFs &aFs, CUnifiedCertStore &aCertStore); + ~CAdvSecSettingsCertListBuilder(); + +public: // new functions + void GetCertificateList(QList &certList, + RMPointerArray &aCertInfoArray, TRequestStatus &aStatus); + +protected: // from CActive + void DoCancel(); + void RunL(); + TInt RunError(TInt aError); + +private: // new functions + CAdvSecSettingsCertListBuilder(RFs &aFs, CUnifiedCertStore &aCertStore); + void ConstructL(); + void ResetCertAttributeFilter(); + void ProcessFirstCertificateL(); + void ProcessNextCertificateL(); + void StartProcessingCertificateL(); + void CompleteProcessingCertificateL(); + void ReturnCertificateListL(); + AdvSecSettingsCertificate::CertificateType CertType(const CCTCertInfo &aCertInfo); + +private: // data + RFs &iFs; + CUnifiedCertStore &iCertStore; + TRequestStatus *iClientStatus; // not owned + QList *iCertList; // not owned + RMPointerArray *iClientInfoArray; // not owned + RMPointerArray iCertInfoArray; + CCertAttributeFilter *iCertAttributeFilter; + TInt iCertInfoIndex; + HBufC8 *iCertificate; + TPtr8 iCertPtr; + RPointerArray iLabeledCertInfos; + + enum TCertListBuilderState { + EIdle, + EListingCerts, + ERetrievingCert, + EProcessingCert + } iState; +}; + +#endif // ADVSECSETTINGSCERTLISTBUILDER_SYMBIAN_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertmover_symbian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscertmover_symbian.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to move certificates +* +*/ + +#ifndef ADVSECSETTINGSCERTMOVER_SYMBIAN_H +#define ADVSECSETTINGSCERTMOVER_SYMBIAN_H + +#include // CActive +#include // RMPointerArray +#include // TCTTokenObjectHandle + +class RFs; +class CUnifiedCertStore; +class CUnifiedKeyStore; +class CCTCertInfo; +class CCTKeyInfo; +class CCertAttributeFilter; +class TCTKeyAttributeFilter; +class MCTWritableCertStore; +class MCTKeyStoreManager; + + +/** + * Certificate mover helper class. + */ +class CAdvSecSettingsCertMover : public CActive +{ +public: // constructor and destructor + static CAdvSecSettingsCertMover *NewL(RFs &aFs); + ~CAdvSecSettingsCertMover(); + +public: // new functions + void Move(const CCTCertInfo &aCert, TInt aSourceStoreTokenId, + TInt aTargetStoreTokenId, TRequestStatus &aStatus); + +protected: // from CActive + void DoCancel(); + void RunL(); + TInt RunError(TInt aError); + +private: // new functions + CAdvSecSettingsCertMover(RFs &aFs); + void ConstructL(); + void StartMoveOperationL(); + TInt CorrespondingKeyStoreTokenId(TInt aCertStoreTokenId); + void StartMovingKeysL(); + void FindSourceAndTargetKeyStoresL(); + void FindSourceAndTargetCertStoreL(); + void ExportFirstKeyL(); + void ExportOneKeyL(); + void ExportNextKeyL(); + void SaveExportedKeyL(); + void DeleteOriginalKeyL(); + void StartMovingCertificatesL(); + void RetrieveFirstCertL(); + void RetrieveOneCertL(); + void RetrieveNextCertL(); + void SaveRetrievedCertL(); + void DeleteOriginalCertL(); + + +private: // data + RFs &iFs; + const CCTCertInfo *iCertInfo; // not owned + TInt iSourceCertStoreTokenId; + TInt iTargetCertStoreTokenId; + TRequestStatus *iClientStatus; // not owned + HBufC8 *iDataBuffer; + + CUnifiedCertStore *iCertStore; + MCTWritableCertStore *iSourceCertStore; // not owned + MCTWritableCertStore *iTargetCertStore; // not owned + CCertAttributeFilter *iCertFilter; + RMPointerArray iCerts; + TInt iCertIndex; + TPtr8 iDataPtr; + + CUnifiedKeyStore *iKeyStore; + MCTKeyStoreManager *iSourceKeyStore; // not owned + MCTKeyStoreManager *iTargetKeyStore; // not owned + TCTKeyAttributeFilter *iKeyFilter; + RMPointerArray iKeys; + TInt iKeyIndex; + TCTTokenObjectHandle iSourceKeyHandle; + CCTKeyInfo *iSavedKeyInfo; + + enum TMoverState { + ENotInitialized, + EInitializingCertStore, + EInitializingKeyStore, + EIdle, + EMovingKeyListingKeys, + EMovingKeyExportingKeys, + EMovingKeyImportingKeys, + EMovingKeyDeletingOriginal, + EMovingCertListingCerts, + EMovingCertRetrievingCerts, + EMovingCertAddingCerts, + EMovingCertDeletingOriginal, + EFailed + } iState; +}; + +#endif // ADVSECSETTINGSCERTMOVER_SYMBIAN_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscerttrustsettingsview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingscerttrustsettingsview.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Certificate trust settings view in advanced security settings +* +*/ + +#ifndef ADVSECSETTINGSCERTTRUSTSETTINGSVIEW_H +#define ADVSECSETTINGSCERTTRUSTSETTINGSVIEW_H + +#include "advsecsettingsviewbase.h" + +class AdvSecSettingsCertificate; +class AdvSecSettingsCertificateModel; +class HbGroupBox; +class HbDataForm; +class HbDataFormModel; + + +/** + * Certificate trust settings view in advanced security settings. Certificate + * detail view shows certificate details (subject, issuer, validity + * dates, fingerprints, etc). + */ +class AdvSecSettingsCertTrustSettingsView : public AdvSecSettingsViewBase +{ + Q_OBJECT + +public: // constructor and destructor + explicit AdvSecSettingsCertTrustSettingsView( + AdvSecSettingsCertificateModel &model, QGraphicsItem *parent = 0); + virtual ~AdvSecSettingsCertTrustSettingsView(); + +public: // new functions + void setCertificate(const AdvSecSettingsCertificate &cert); + +private slots: + void refreshDisplay(); + void toggleChange(const QModelIndex &itemIndex); + void saveTrustSettings(); + void deleteCertificate(); + void deleteConfirmationAccepted(); + +private: // new functions + QString usageName(int usageId); + +private: // data + AdvSecSettingsCertificateModel &mModel; + const AdvSecSettingsCertificate *mCertificate; // not owned + bool mIsCertDeletable; + HbGroupBox *mViewLabel; + HbDataForm *mDataForm; + HbDataFormModel *mDataFormModel; + QMap mUsageIdAndTrust; + QMap mUsageIdAndName; +}; + +#endif // ADVSECSETTINGSCERTTRUSTSETTINGSVIEW_H + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingslabeledcertinfo_symbian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingslabeledcertinfo_symbian.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to contain a labeled CCTCertInfo object +* +*/ + +#ifndef CPADVSECSETTINGSLABELEDCERTINFO_SYMBIAN_H +#define CPADVSECSETTINGSLABELEDCERTINFO_SYMBIAN_H + +#include // CBase + +class CCTCertInfo; + + +/** + * Displayed certificate labels are constructed using CCTCertInfo + * label and subject name. CAdvSecSettingsLabeledCertInfo class + * is used as contained class for labeled CCTCertInfo objects. + */ +class CAdvSecSettingsLabeledCertInfo : public CBase +{ +public: // constructor and destructor + CAdvSecSettingsLabeledCertInfo(const CCTCertInfo &aCertInfo); + ~CAdvSecSettingsLabeledCertInfo(); + +public: // new functions + const CCTCertInfo &CertInfo() const; + const TDesC &Label() const; + void SetLabelL(const TDesC &aLabel); + void AppendLabelL(const TDesC &aSeparator, const TDesC &aAdditionalText); + static TInt Compare(const CAdvSecSettingsLabeledCertInfo& aLeft, + const CAdvSecSettingsLabeledCertInfo& aRight); + +private: // data + const CCTCertInfo& iCertInfo; + HBufC* iLabel; +}; + +#endif // CPADVSECSETTINGSLABELEDCERTINFO_SYMBIAN_H + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingsloader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingsloader.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0"" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Advanced security settings plugin loader + * + */ +#ifndef ADVSECSETTINGSLOADER_H +#define ADVSECSETTINGSLOADER_H + +#include +#include // CpPluginInterface + +class HbTranslator; + + +/** + * Control panel plugin loader for advanced security settings. + */ +class AdvSecSettingsLoader : public QObject, public CpPluginInterface +{ + Q_OBJECT + Q_INTERFACES(CpPluginInterface) + +public: // constructor and destructor + AdvSecSettingsLoader(); + ~AdvSecSettingsLoader(); + +public: // new functions + QList createSettingFormItemData( + CpItemDataHelper &itemDataHelper) const; + +private: // data + HbTranslator* mTranslator; +}; + +#endif // ADVSECSETTINGSLOADER_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingsmainview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingsmainview.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Advanced security settings main view +* +*/ + +#ifndef ADVSECSETTINGSMAINVIEW_H +#define ADVSECSETTINGSMAINVIEW_H + +#include "advsecsettingsviewbase.h" + +class AdvSecSettingsSecurityModuleModel; +class AdvSecSettingsCertificateListView; +class AdvSecSettingsSecurityModuleView; +class HbWidget; +class HbGroupBox; +class HbListWidget; + + +/** + * Main view for the advanced security settings. The main advanced + * security settings view contains certificates, protected content, + * and security module group boxes. + */ +class AdvSecSettingsMainView : public AdvSecSettingsViewBase +{ + Q_OBJECT + +public: // constructor and destructor + explicit AdvSecSettingsMainView(QGraphicsItem *parent = 0); + virtual ~AdvSecSettingsMainView(); + +public slots: + void displayCertListView(const QModelIndex& modelIndex); + void displaySecurityModuleView(const QModelIndex& modelIndex); + void securityModuleInitialized(); + +private: // new functions + HbWidget *createCertificatesTopLevel(); + HbWidget *createProtectedContentTopLevel(); + HbWidget *createSecurityModuleTopLevel(); + bool isSecurityModulesAvailable(); + +private: // data + AdvSecSettingsSecurityModuleModel *mSecModModel; + AdvSecSettingsCertificateListView *mCertListView; + AdvSecSettingsSecurityModuleView *mSecModView; + HbGroupBox *mSecModGroupBox; + HbListWidget *mSecModList; + HbMenu *mContextMenu; +}; + +#endif // ADVSECSETTINGSMAINVIEW_H + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymodule_symbian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymodule_symbian.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Symbian specific container class for a security module +* +*/ + +#ifndef ADVSECSETTINGSSECURITYMODULE_SYMBIAN_H +#define ADVSECSETTINGSSECURITYMODULE_SYMBIAN_H + +#include // CBase +#include // RMPointerArray + +class CCTKeyInfo; +class MCTKeyStore; +class MCTAuthenticationObject; + + +/** + * Symbian specific container class for a security module. + */ +class CAdvSecSettingsSecurityModuleSymbian : public CBase +{ +public: // constructor and destructor + CAdvSecSettingsSecurityModuleSymbian(MCTKeyStore &aProtectedKeyStore); + ~CAdvSecSettingsSecurityModuleSymbian(); + +public: // new functions + const TDesC &Label() const; + TBool IsDeletable() const; + TBool IsSigningPinSupported() const; + RMPointerArray &KeyInfoArray(); + +private: // data + MCTKeyStore &iProtectedKeyStore; + RMPointerArray iKeyInfoArray; + RMPointerArray iAuthenticationObjects; +}; + +#endif // ADVSECSETTINGSSECURITYMODULE_SYMBIAN_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymoduledetailview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymoduledetailview.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Security module detail view in advanced security settings +* +*/ + +#ifndef ADVSECSETTINGSSECURITYMODULEDETAILVIEW_H +#define ADVSECSETTINGSSECURITYMODULEDETAILVIEW_H + +#include "advsecsettingsviewbase.h" + +class AdvSecSettingsSecurityModuleModel; +class HbGroupBox; +class HbLabel; + + +/** + * Shows security module detail view. + */ +class AdvSecSettingsSecurityModuleDetailView : public AdvSecSettingsViewBase +{ + Q_OBJECT + +public: // constructor and destructor + explicit AdvSecSettingsSecurityModuleDetailView( + AdvSecSettingsSecurityModuleModel &model, QGraphicsItem *parent = 0); + virtual ~AdvSecSettingsSecurityModuleDetailView(); + +public: // new functions + void setSecurityModule(int index); + +private slots: + void detailsCompleted(QMap details); + void deleteSecurityModule(); + void deleteConfirmationAccepted(); + +private: // data + AdvSecSettingsSecurityModuleModel &mModel; + int mModuleIndex; + HbGroupBox *mViewLabel; + HbLabel *mDetailsText; +}; + +#endif // ADVSECSETTINGSSECURITYMODULEDETAILVIEW_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymoduleeraser_symbian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymoduleeraser_symbian.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to remove a security module +* +*/ + +#ifndef ADVSECSETTINGSSECURITYMODULEERASER_SYMBIAN_H +#define ADVSECSETTINGSSECURITYMODULEERASER_SYMBIAN_H + +#include // CActive +#include // RMPointerArray + +class CUnifiedKeyStore; +class CCTKeyInfo; +class TCTKeyAttributeFilter; +class MCTKeyStore; + + +/** + * Security module removing helper class. This class deletes the security + * module by deleting all the keys controlled by the module. + */ +class CAdvSecSettingsSecurityModuleEraser : public CActive +{ +public: // constructor and destructor + static CAdvSecSettingsSecurityModuleEraser *NewL(CUnifiedKeyStore &aKeyStore); + ~CAdvSecSettingsSecurityModuleEraser(); + +public: // new functions + void Erase(TInt aKeyStoreIndex, TRequestStatus &aStatus); + +protected: // from CActive + void DoCancel(); + void RunL(); + TInt RunError(TInt aError); + +private: // new functions + CAdvSecSettingsSecurityModuleEraser(CUnifiedKeyStore &aKeyStore); + void ConstructL(); + void DeleteFirstKeyL(); + void DeleteOneKeyL(); + void DeleteNextKeyL(); + +private: // data + TRequestStatus *iClientStatus; // not owned + CUnifiedKeyStore &iKeyStore; + MCTKeyStore *iTargetKeyStore; // not owned + TCTKeyAttributeFilter *iKeyFilter; + RMPointerArray iKeys; + TInt iKeyIndex; + + enum TEraserState { + EIdle, + EListingKeys, + EDeletingKey + } iState; +}; + +#endif // ADVSECSETTINGSSECURITYMODULEERASER_SYMBIAN_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymodulemodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymodulemodel.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Security module model in advanced security settings +* +*/ + +#ifndef ADVSECSETTINGSSECURITYMODULEMODEL_H +#define ADVSECSETTINGSSECURITYMODULEMODEL_H + +#include +#include + +class AdvSecSettingsSecurityModule; +class AdvSecSettingsSecurityModuleModelPrivate; + + +/** + * Security module model in advanced security settings. + */ +class AdvSecSettingsSecurityModuleModel : public QObject +{ + Q_OBJECT + +public: // constructor and destructor + explicit AdvSecSettingsSecurityModuleModel(QObject *parent = 0); + virtual ~AdvSecSettingsSecurityModuleModel(); + +public: // new definitions + enum SecurityModuleDetailsField { + Label, + Version, + Location, + SerialNumber, + Manufacturer + }; + enum AuthenticationStatus { + EPinEntered = 0x01, // Set if the module is open, PIN already entered + EPinRequested = 0x02, // Set if PIN code required to open the module + EPinChangeAllowed = 0x04, // Set if PIN code change is allowed + EPinBlocked = 0x10, // Set if PIN code is blocked, requires unblocking PIN + EBlockedPermanently = 0x20, // Set if PIN code blocked and cannot be unblocked + }; + +public: // new functions + void initialize(); + int moduleCount() const; + QMap moduleLabelsAndLocations() const; + void getModuleDetails(int moduleIndex); + void getModuleStatus(int moduleIndex); + // Functions related to PIN-G (aka access PIN, login PIN) + void setPinCodeRequestState(int moduleIndex, bool isRequested); + void changePinCode(int moduleIndex); // unblocks PIN code if EPinBlocked + void closeModule(int moduleIndex); + // Functions related to PIN-NR (aka signature PIN, signing PIN) + bool isSigningPinSupported(int moduleIndex) const; + void changeSigningPinCode(int moduleIndex); + bool isDeletable(int moduleIndex) const; + void deleteModule(int moduleIndex); + +signals: + void initializeCompleted(); + void detailsCompleted(QMap details); + void statusCompleted(int authenticationStatus); + void statusChanged(int moduleIndex, int authenticationStatus); + void pinCodeRequestStateCompleted(); + void pinCodeChangeCompleted(); + void closeCompleted(); + void signingPinCodeChangeCompleted(); + void deleteCompleted(); + void errorOccurred(int error); + +private: // new functions + void handleInitializeCompleted(); + void handleStatusCompleted(int authenticationStatus); + void handleStatusChanged(int moduleIndex, int authenticationStatus); + void handlePinCodeRequestSet(); + void handlePinCodeChanged(); + void handleModuleClosed(); + void handleSigningPinCodeChanged(); + void handleModuleDeleted(); + void handleError(int error); + +private: // data + Q_DISABLE_COPY(AdvSecSettingsSecurityModuleModel) + friend class AdvSecSettingsSecurityModuleModelPrivate; + AdvSecSettingsSecurityModuleModelPrivate *d_ptr; +}; + +#endif // ADVSECSETTINGSSECURITYMODULEMODEL_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymodulemodel_stub_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymodulemodel_stub_p.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Generic stub for platform specific private security module model +* +*/ + +#ifndef ADVSECSETTINGSSECURITYMODULEMODELPRIVATE_STUB_H +#define ADVSECSETTINGSSECURITYMODULEMODELPRIVATE_STUB_H + +#include + +class AdvSecSettingsSecurityModuleModel; +class AdvSecSettingsSecurityModule; + + +/** + * Generic stub for platform specific private security module model. + * This is just a stub. Real functionality is provided in platform specific + * AdvSecSettingsSecurityModuleModelPrivate implementation. + */ +class AdvSecSettingsSecurityModuleModelPrivate : public QObject +{ + Q_OBJECT + +public: // constructor and destructor + explicit AdvSecSettingsSecurityModuleModelPrivate(AdvSecSettingsSecurityModuleModel *q); + virtual ~AdvSecSettingsSecurityModuleModelPrivate(); + +public: // new functions + void initialize(); + int moduleCount() const; + QMap moduleLabelsAndLocations() const; + void getModuleStatus(int moduleIndex); + void setPinCodeRequestState(int moduleIndex, bool isRequested); + void changePinCode(int moduleIndex); // unblocks PIN code if EPinBlocked + void closeModule(int moduleIndex); + bool isSigningPinSupported(int moduleIndex) const; + void changeSigningPinCode(int moduleIndex); + bool isDeletable(int moduleIndex) const; + void deleteModule(int moduleIndex); + +private: // data + Q_DISABLE_COPY(AdvSecSettingsSecurityModuleModelPrivate) + AdvSecSettingsSecurityModuleModel *q_ptr; +}; + +#endif // ADVSECSETTINGSSECURITYMODULEMODELPRIVATE_STUB_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymodulemodel_symbian_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymodulemodel_symbian_p.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,104 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Symbian specific private security module model +* +*/ + +#ifndef ADVSECSETTINGSSECURITYMODULEMODELPRIVATE_SYMBIAN_H +#define ADVSECSETTINGSSECURITYMODULEMODELPRIVATE_SYMBIAN_H + +#include // CActive +#include // RFs +#include // RMPointerArray +#include + +class AdvSecSettingsSecurityModuleModel; +class CAdvSecSettingsSecurityModuleEraser; +class CUnifiedKeyStore; +class MCTKeyStore; +class MCTAuthenticationObject; +class CCTKeyInfo; +class TCTKeyAttributeFilter; + + +/** + * Symbian specific private security module model. + */ +class AdvSecSettingsSecurityModuleModelPrivate : public CActive +{ +public: // constructor and destructor + explicit AdvSecSettingsSecurityModuleModelPrivate(AdvSecSettingsSecurityModuleModel *q); + ~AdvSecSettingsSecurityModuleModelPrivate(); + +public: // new functions + void initialize(); + int moduleCount() const; + QMap moduleLabelsAndLocations() const; + void getModuleStatus(int moduleIndex); + void setPinCodeRequestState(int moduleIndex, bool isRequested); + void changePinCode(int moduleIndex); // unblocks PIN code if EPinBlocked + void closeModule(int moduleIndex); + bool isSigningPinSupported(int moduleIndex) const; + void changeSigningPinCode(int moduleIndex); + bool isDeletable(int moduleIndex) const; + void deleteModule(int moduleIndex); + +protected: // from CActive + void DoCancel(); + void RunL(); + TInt RunError(TInt aError); + +private: // new functions + void ConstructL(); + void ListKeysFromFirstKeyStoreL(); + void ListKeysFromOneKeyStoreL(); + void ListKeysFromNextKeyStoreL(); + void AppendKeyStoresWithProtectedKeysL(); + void ChangeCurrentAuthObjectPinCode(); + TInt DoStartDeletingModule(TInt aModuleIndex); + void ReturnModuleStatusL(); + void ReturnPinChanged(); + void ReturnPinRequestStateChanged(); + void ReturnModuleClosed(); + void ReturnModuleDeleted(); + +private: // data + AdvSecSettingsSecurityModuleModel *q_ptr; // not owned + RFs iFs; + CUnifiedKeyStore *iUnifiedKeyStore; + RMPointerArray iProtectedKeyStores; // items not owned + RMPointerArray iAuthenticationObjects; // items not owned + TInt iKeyStoreIndex; + RMPointerArray iKeys; + TCTKeyAttributeFilter *iAllKeysFilter; + MCTKeyStore *iCurrentKeyStore; // not owned + MCTAuthenticationObject *iCurrentAuthObject; // not owned + TInt iTimeRemaining; + CAdvSecSettingsSecurityModuleEraser *iModuleEraser; + enum TState { + ENotInitialized, + EInitializing, + EListingKeys, + EReadingTimeRemaining, + EChangingPinCode, + EUnblockingToChangePinCode, + EEnablingPinCodeRequest, + EDisablingPinCodeRequest, + EClosingAuthObject, + EDeletingModule, + EIdle + } iState; +}; + +#endif // ADVSECSETTINGSSECURITYMODULEMODELPRIVATE_SYMBIAN_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymoduleview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingssecuritymoduleview.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Security module view in advanced security settings +* +*/ + +#ifndef ADVSECSETTINGSSECURITYMODULEVIEW_H +#define ADVSECSETTINGSSECURITYMODULEVIEW_H + +#include "advsecsettingsviewbase.h" + +class AdvSecSettingsSecurityModuleModel; +class HbGroupBox; +class HbDataFormModel; +class HbDataFormModelItem; + + +/** + * Shows info about one security module (such as WIM or personal + * key store). Provides also functionality to change access codes + * (like module PIN code, and signing PIN code). + */ +class AdvSecSettingsSecurityModuleView : public AdvSecSettingsViewBase +{ + Q_OBJECT + +public: // constructor and destructor + explicit AdvSecSettingsSecurityModuleView(AdvSecSettingsSecurityModuleModel &model, + QGraphicsItem *parent = 0); + virtual ~AdvSecSettingsSecurityModuleView(); + +public: // new functions + void setSecurityModule(const QString &moduleTitle, int modelIndex); + +private slots: + void updateModuleStatus(); + void moduleStatusChanged(int status); + void itemActivated(const QModelIndex &itemIndex); + +private: // data + AdvSecSettingsSecurityModuleModel &mModel; + HbGroupBox *mViewLabel; + HbDataFormModel *mDataFormModel; + HbDataFormModelItem *mModulePin; + HbDataFormModelItem *mModulePinRequested; + HbDataFormModelItem *mModuleStatus; + HbDataFormModelItem *mSigningPin; + int mModelIndex; +}; + +#endif // ADVSECSETTINGSSECURITYMODULEVIEW_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingsstoreuids.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingsstoreuids.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Certificate and key store identifiers +* +*/ + + +#ifndef ADVSECSETTINGSSTOREUIDS_H +#define ADVSECSETTINGSSTOREUIDS_H + + +// Certificate and key store UID values +const TInt KAdvSecSettingsFileCertStore = 0x101F501A; // 270487578 +const TInt KAdvSecSettingsFileKeyStore = 0x101F7333; // 270496563 +const TInt KAdvSecSettingsTrustedServerCertStore = 0x101FB66F; // 270513775 +const TInt KAdvSecSettingsDeviceCertStore = 0x101FB668; // 270513768 +const TInt KAdvSecSettingsDeviceKeyStore = 0x101FB66A; // 270513770 +const TInt KAdvSecSettingsWIMCertAndKeyStore = 0x101F79D9; // 270498265 +const TInt KAdvSecSettingsMidpCertStore = 0x101F5B71; // 270490481 +const TInt KAdvSecSettingsSWICertStore = 0x102042BA; // 270549690 + + +#endif // ADVSECSETTINGSSTOREUIDS_H + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingstrustedcertusageuids.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingstrustedcertusageuids.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Trusted certificate usage identifiers +* +*/ + +#ifndef ADVSECSETTINGSTRUSTEDCERTUSAGEUIDS_H +#define ADVSECSETTINGSTRUSTEDCERTUSAGEUIDS_H + + +// Trusted certificate usage UID values +const int KAdvSecSettingsTrustedUsageSwInstallNativeSis = 0x100042AB; // 268452523 +const int KAdvSecSettingsTrustedUsageSwInstallSisOcsp = 0x1000A8B6; // 268478646 +const int KAdvSecSettingsTrustedUsageSwInstallJava = 0x101F9B28; // 270506792 +const int KAdvSecSettingsTrustedUsageSwInstallWidget = 0x200267D2; // 537028562 +const int KAdvSecSettingsTrustedUsageInternet = 0x1000183D; // 268441661 +const int KAdvSecSettingsTrustedUsageWap = 0x1000AA53; // 268479059 +const int KAdvSecSettingsTrustedUsageVPN = 0x101F7993; // 270498195 + + +#endif // ADVSECSETTINGSTRUSTEDCERTUSAGEUIDS_H + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/advsecsettingsviewbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/advsecsettingsviewbase.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Base class for advanced security settings views +* +*/ + +#ifndef ADVSECSETTINGSVIEWBASE_H +#define ADVSECSETTINGSVIEWBASE_H + +#include // CpBaseSettingView + +class HbMenu; + + +/** + * Base class for advanced security settings views. + */ +class AdvSecSettingsViewBase : public CpBaseSettingView +{ + Q_OBJECT + +public: // constructor and destructor + explicit AdvSecSettingsViewBase(QGraphicsWidget *widget = 0, + QGraphicsItem *parent = 0); + virtual ~AdvSecSettingsViewBase(); + +public slots: + void displayPreviousView(); + +protected slots: + virtual void displayError(int error); + +public: // new functions + void displayView(AdvSecSettingsViewBase *view); + bool hasPreviousView() const; + void setDeleteOnClose(bool deleteOnClose); + +protected: // new functions + void clearItemSpecificMenu(); + void addItemSpecificMenuAction(const QString &text, const QObject *receiver, + const char *member); + void displayItemSpecificMenu(const QPointF &position); + void displayQuestionNote(const QString &text, const QObject *receiver, + const char *accepedMember); + +private: // data + HbView *mPreviousView; // not owned + HbMenu *mItemSpecificMenu; + bool mDeleteOnClose; +}; + +#endif // ADVSECSETTINGSVIEWBASE_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/cpcertdatacontainer.h --- a/cpsecplugins/cpadvancedsecplugin/inc/cpcertdatacontainer.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,216 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Declaration of the CCertManUIKeeper class -* -*/ - -#ifndef CPCERTDATACONTAINER_H -#define CPCERTDATACONTAINER_H - -// INCLUDES -#include -#include -#include - -// FORWARD DECLARATIONS -class CpCertManUISyncWrapper; -class CpCertManUICertData; - -// CONSTANTS -const TUid KCMDeviceCertStoreTokenUid = { 0x101FB668 }; -const TUid KCMDeviceKeyStoreTokenUid = { 0x101FB66A }; -const TUid KCMTrustedServerTokenUid = { 0x101FB66F }; -const TUid KCMFileKeyStoreTokenUid = { 0x101F7333 }; -const TUid KCMFileCertStoreTokenUid = { 0x101F501A }; - - -// CLASS DECLARATION - -/** -* CpCertDataContainer retrieves and holds certificates. -* -*/ -class CpCertDataContainer : public CBase - { - public: // functions - - /** - * Default constructor - */ - CpCertDataContainer(); - - /** - * Destructor. - */ - ~CpCertDataContainer(); - - /** - * NewL - */ - static class CpCertDataContainer* NewL(); - - /** - * NewLC - */ - static class CpCertDataContainer* NewLC(); - - CUnifiedCertStore*& CertManager(); - - CUnifiedKeyStore*& KeyManager(); - - /** - * Checks that cacerts.dat file is not corrupt - * and returns CA certificates from it. - */ - void RefreshCAEntriesL(); - - /** - * Checks that cacerts.dat file is not corrupt - * and returns user certificates from it. - */ - void RefreshUserCertEntriesL(); - - /** - * Returns peer certificates. - */ - void RefreshPeerCertEntriesL(); - - /** - * Returns peer certificates. - */ - void RefreshDeviceCertEntriesL(); - - /** - * Shows error note - */ - void ShowErrorNoteL(TInt aError); - - public: //data - - /** - * To store CA certificate entries for Authority and Trust view - * Includes label from x509certnameparser. - */ - RMPointerArray iCALabelEntries; - - /** - * To store CA certificate entries for Authority and Trust view - * Includes label from x509certnameparser. - */ - RMPointerArray iUserLabelEntries; - - /** - * To store Peer certificate entries for Trusted Site view - * Includes label from x509certnameparser. - */ - RMPointerArray iPeerLabelEntries; - - /** - * To store Peer certificate entries for Device certificate view - * Includes label from x509certnameparser. - */ - RMPointerArray iDeviceLabelEntries; - - /** - * Used to wrap asynchronous calls - */ - CpCertManUISyncWrapper* iWrapper; - - /** - * File session handle. - */ - RFs iRfs; - - private: // functions - - void ConstructL(); - - private: //data - - /** - * To list certificates with criteria. - */ - CCertAttributeFilter* iFilter; - - /** - * To list keys with criteria. - */ - - TCTKeyAttributeFilter* iKeyFilter; - - /** - * UnifiedCertStore - */ - CUnifiedCertStore* iStore; - - /** - * UnifiedKeyStore - */ - CUnifiedKeyStore* iKeyStore; - - /** - * To store CA certificate entries. - */ - RMPointerArray iCAEntries; - - /** - * To store User certificate entries. - */ - RMPointerArray iUserEntries; - - /** - * To store Peer certificate entries. - */ - RMPointerArray iPeerEntries; - - /** - * To store Device certificate entries. - */ - RMPointerArray iDeviceEntries; - - /** - * To store Key entries - */ - RMPointerArray iKeyEntries; - - }; - -/** -* Small helper class to put label and certificate in same class. -* -*/ -class CpCertManUICertData : public CBase - { - public: - - CpCertManUICertData(); - - void Release(); - - HBufC* iCAEntryLabel; - HBufC* iUserEntryLabel; - HBufC* iPeerEntryLabel; - HBufC* iDeviceEntryLabel; - CCTCertInfo* iCAEntry; - CCTCertInfo* iUserEntry; - CCTCertInfo* iPeerEntry; - CCTCertInfo* iDeviceEntry; - - private: - ~CpCertManUICertData(); - - }; - - -#endif // CPCERTDATACONTAINER_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/cpcertdetailview.h --- a/cpsecplugins/cpadvancedsecplugin/inc/cpcertdetailview.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0"" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef CPCERTDETAILVIEW_H -#define CPCERTDETAILVIEW_H - -#include -#include -#include -#include - -class CpCertDataContainer; -class CX509Certificate; -class CCertificate; -class HbListWidget; -class HbAbstractViewItem; -class CCTCertInfo; - -class QString; -class QSizeF; - -class CpCertDetailView : public CpBaseSettingView -{ - Q_OBJECT -public: - explicit CpCertDetailView( CpCertView::TCertificateViews currentView, TInt pos, - CpCertDataContainer& certDataContainer, - QGraphicsItem *parent = 0 ); - virtual ~CpCertDetailView(); - -private: - void viewCertificateDetailsL( TInt index, CpCertView::TCertificateViews type ); - void validateCertificateL(TInt index, const CCertificate& certDetails, const CCTCertInfo& certInfo, CpCertView::TCertificateViews type ); - CArrayFixFlat* validateX509CertificateL( const CX509Certificate& certDetails ); - TKeyUsagePKCS15 keyUsageAndLocationL( const CCTCertInfo& certEntry, TUid* keyLocation ); - void setLocationInfo( TBool certificate, TUid locUid, HbListWidget& certDisplayDetails ); - void divideIntoBlocks( const TDesC8& input, TPtr& output ); - - void addToListWidget( HbListWidget& certDisplayDetails, const QString& data ); - void addToListWidget( HbListWidget& certDisplayDetails, - const QString& displayString, const QString& displayDetails ); - - const CCTCertInfo* certInfo( TInt index, CpCertView::TCertificateViews certView ); - void addTrustedSitesL( const CCertificate& certDetails, HbListWidget& certDisplayDetails); - void addLabel( const CCTCertInfo& certInfo, HbListWidget& certDisplayDetails); - void addIssuerL( const CCertificate& certDetails, HbListWidget& certDisplayDetails ); - void addSubjectL( const CCertificate& certDetails, HbListWidget& certDisplayDetails ); - void addCertUsage( TKeyUsagePKCS15 usage, HbListWidget& certDisplayDetails ); - void addValidityPeriod( const CCertificate& certDetails, HbListWidget& certDisplayDetails); - void setURLLocation( HBufC8& urlDetails, HbListWidget& certDisplayDetails ); - void addCertFormat( TCertificateFormat certFormat, HbListWidget& certDisplayDetails ); - void addAlgoDetails( const CCertificate& certificate, HbListWidget& certDisplayDetails ); - void addSerialNo( const CCertificate& certificate, HbListWidget& certDisplayDetails ); - void addFingerprint( const CCertificate& certificate, HbListWidget& certDisplayDetails ); - void addPublicKeyDetailsL( const CCertificate& certificate, HbListWidget& certDisplayDetails ); - QString asymmetricAlgoId( const CCertificate& certificate ); - -private: - CpCertDataContainer& mCertDataContainer; - -}; - -#endif // CPCERTDETAILVIEW_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/cpcertmanuisyncwrapper.h --- a/cpsecplugins/cpadvancedsecplugin/inc/cpcertmanuisyncwrapper.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,319 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Wrapper class for Symbian's Security Framework's calls -* -*/ - - -#ifndef CPCERTMANUISYNCWRAPPER_H -#define CPCERTMANUISYNCWRAPPER_H - - -// INCLUDES -#include - -// FORWARD DECLERATIONS -class CCertificate; -class CPKIXValidationResult; -class CPKIXCertChain; -class CUnifiedCertStore; - -// CLASS DECLARATION - -/** -* Wrapper class for Symbian's Security Framework's calls. -* Shows error notes if an error happenes. -* -* @lib certmanui.dll -* @since S60 2.0 -*/ -class CpCertManUISyncWrapper : public CActive - { - public: - - /** - * Two-phased constructor. - */ - static CpCertManUISyncWrapper* NewLC(); - - /** - * Two-phased constructor. - */ - static CpCertManUISyncWrapper* NewL(); - - /** - * Destructor. - */ - ~CpCertManUISyncWrapper(); - - public: // New functions - - /** - * TInt ListL - * @param aStore reference to store where operation is done. - * @param aArray Keys are stored here. - * @param aFilter Information on what kind keys are looked. - */ - - void ListL( CUnifiedKeyStore*& aStore, - RMPointerArray* aArray, - const TCTKeyAttributeFilter& aFilter ); - - /** - * TInt ListL - * @param aStore reference to store where operation is done. - * @param aArray Keys are stored here. - * @param aFilter Information on what kind keys are looked. - * @param aTokenUid Token UID of key store - */ - - void ListL( CUnifiedKeyStore*& aStore, - RMPointerArray* aArray, - const TCTKeyAttributeFilter& aFilter, - const TUid aTokenUid ); - - /** - * TInt ListL - * @param aStore reference to store where operation is done. - * @param aArray certificates are stored here. - * @param aFilter Information on what kind certificates are looked. - */ - void ListL( CUnifiedCertStore*& aStore, - RMPointerArray* aArray, - const CCertAttributeFilter& aFilter ); - - /** - * TInt ListL - * @param aStore reference to store where operation is done. - * @param aArray certificates are stored here. - * @param aFilter Information on what kind certificates are looked. - * @param aTokenUid Token UID of certificate store - */ - void ListL( CUnifiedCertStore*& aStore, - RMPointerArray* aArray, - const CCertAttributeFilter& aFilter, - const TUid aTokenUid ); - - - /** - * TInt GetCertificateL - * @param aStore reference to store where operation is done. - * @param aCertInfo Certificate that's detailed information is fetched. - * @param aCert Fetched certificate. - */ - void GetCertificateL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, CCertificate*& aCert ); - - /** - * TInt GetCertificateL - * @param aStore reference to store where operation is done. - * @param aCertInfo Certificate that's detailed information is fetched. - * @param aCert Fetched certificate. - */ - void GetCertificateL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, CCertificate*& aCert, TUid aTokenUid ); - - - /** - * TInt GetUrlCertificateL - * @param aStore reference to store where operation is done. - * @param aCertInfo Certificate that's detailed information is fetched. - * @param aUrl Fetched URL. - */ - void GetUrlCertificateL( - CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, - TDes8& aUrl) ; - - /** - * TInt GetApplicationsL - * @param aStore reference to store where operation is done. - * @param aCertInfo Certificate that applications are fetched. - * @param Certificates applications are stoted here. - */ - void GetApplicationsL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, RArray& aApps ); - - /** - * TInt ValidateX509RootCertificateL - * @param aValidationResult Result of validation. - * @param aValidationTime Time of validation. - * @param aChain Chain to be validated. - */ - void ValidateX509RootCertificateL( - CPKIXValidationResult*& aValidationResult, - const TTime& aValidationTime, CPKIXCertChain*& aChain ); - - /** - * TInt InitStoreL - * @param aStore reference to store to be initialized. - */ - void InitStoreL( CUnifiedCertStore*& aStore ); - - /** - * void InitStoreL - * @param aStore reference to store to be initialized. - */ - void InitStoreL( CUnifiedKeyStore*& aStore ); - - /** - * TInt DeleteCertL - * @param aStore reference to store where operation is done. - * @param aCertInfo Certificate to be deleted. - */ - void DeleteCertL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo ); - - /** - * TInt DeleteCertL - * @param aStore reference to store where operation is done. - * @param aCertInfo Certificate to be deleted. - */ - void DeleteCertL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, - TUid aTokenUid ); - - /** - * TInt IsApplicableL - * @since S60 2.0 - * @param aStore reference to store where operation is done. - * @param aCertInfo Certificate thats applicability is queried. - * @param aApplication Application that's status is queried. - * @param aIsApplicable ETrue if applcable. - * @return TInt Status Symbian's API's call. - */ - TInt IsApplicableL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, TUid aApplication, - TBool& aIsApplicable ); - - /** - * TInt IsTrustedL - * @since S60 2.0 - * @param aStore reference to store where operation is done. - * @param aCertInfo Certificate that's trust status is queried. - * @param aTrusted ETrue if trusted. - * @return TInt Status Symbian's API's call. - */ - TInt IsTrustedL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, TBool& aTrusted ); - - /** - * TInt SetApplicabilityL - * @param aStore reference to store where operation is done. - * @param aCertInfo Certificate thats applicability is set. - * @param aApplications New applicability settings. - */ - void SetApplicabilityL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, - RArray& aApplications ); - - /** - * void MoveCertL - * @since S60 3.2 - * @param aStore reference to store where operation is done - * @param aCertInfo Certificate info - * @param aSourceStore UID of source certificate store - * @param aTargetStore UID of source certificate store - * @return TInt Number of moved certificates - */ - TInt MoveCertL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, - const TUid aSourceTokenId, - const TUid aTargetTokenId ); - - /** - * void MoveKeyL - * @param aStore reference to store where operation is done - * @param CCTKeyInfo Key info - * @param aSourceStore UID of source key store - * @param aTargetStore UID of source key store - */ - void MoveKeyL( CUnifiedKeyStore*& aStore, - const TCTKeyAttributeFilter& aFilter, - const TUid aSourceTokenId, - const TUid aTargetTokenId ); - - /** - * TInt GetInterface - * @since S60 3.0 - * @param aToken reference to token - * @param aTokenInterface Pointer to returned interface - * @return TInt Status Symbian's API's call. - */ - TInt GetInterface( TUid aRequiredInterface, - MCTToken& aToken, - MCTTokenInterface*& aReturnedInterface ); - - protected: - - void DoCancel(); - void RunL(); - - private: - - CpCertManUISyncWrapper(); - void ConstructL(); - - void HandleErrorL(); - - private: //Data - - // Internal operation states. - enum TOperation - { - EOperationNone, - EOperationInit, - EOperationList, - EGetCertificate, - EAddCertificate, - ERetriveURLCertificate, - EOperationDelete, - EOperationGetApps, - EOperationIsApplicable, - EOperationIsTrusted, - EOperationSetApplicability, - EOperationSetToTrusted, - EOperationValidateX509Root, - EShowErrorNote, - EOperationInitKeyStore, - EOperationKeyList, - EOperationGetInterface, - EOperationExportKey, - EOperationImportKey, - EOperationDeleteKey - }; - - // For wrapping asynchronous calls. - CActiveSchedulerWait iWait; - - // Internal state of operation. - TOperation iOperation; - - // Just for cancelling a operation. Does not own. - CUnifiedCertStore* iStore; - - // Just for cancelling a operation. Does not own. - CUnifiedKeyStore* iKeyStore; - - // Just for cancelling a operation. Does not own. - CPKIXCertChain* iChain; - - // For retrieving a certificate. - TPtr8 iCertPtr; - - }; - -#endif // CPCERTMANUISYNCWRAPPER_H - -// End of File diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/cpcertpluginloader.h --- a/cpsecplugins/cpadvancedsecplugin/inc/cpcertpluginloader.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * under the terms of "Eclipse Public License v1.0"" - * which accompanies this distribution, and is available - * at the URL "http://www.eclipse.org/legal/epl-v10.html". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: - * - */ -#ifndef CPCERTPLUGINLOADER_H -#define CPCERTPLUGINLOADER_H - -#include -#include -#include -class CpCertPluginLoader : public QObject, public CpPluginInterface -{ - Q_OBJECT - Q_INTERFACES(CpPluginInterface) -public: - CpCertPluginLoader(); - virtual ~CpCertPluginLoader(); - virtual QListcreateSettingFormItemData(CpItemDataHelper &itemDataHelper) const; -private: - QTranslator* mTranslator; -}; - -#endif //CPCERTPLUGINLOADER_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/cpcerttrustview.h --- a/cpsecplugins/cpadvancedsecplugin/inc/cpcerttrustview.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Declaration of the CCertManUIContainerTrust class -* Maintains correct list of trusted clients depending -* on the certificate that was in focus in Authority -* certificates view when Trust Settings view was entered. -* Shows and changes correct Yes/No text for the Trusted client. -* -*/ - - -#ifndef CPCERTTRUSTVIEW_H -#define CPCERTTRUSTVIEW_H - -// INCLUDES -#include -#include - -// CONSTANTS -const TInt KTrustSettingsResourceIndexWAP = 0; -const TInt KTrustSettingsResourceIndexMailAndImageConn = 1; -const TInt KTrustSettingsResourceIndexAppCtrl = 2; -const TInt KTrustSettingsResourceIndexJavaInstall = 3; -const TInt KTrustSettingsResourceIndexOCSPCheck = 4; -const TInt KTrustSettingsResourceIndexVPN = 5; -const TInt KTrustSettingsResourceIndexWidget = 6; -const TInt KTrustSettingsResourceIndexValueYes = 0; -const TInt KTrustSettingsResourceIndexValueNo = 1; - -// FORWARD DECLARATIONS -class CCertificateAppInfoManager; -class CpCertDataContainer; -class TCertificateAppInfo; -class CCTCertInfo; - -class QString; - -class HbDataFormModel; - -// CLASS DECLARATION -class CpCertTrustView : public CpBaseSettingView - { - Q_OBJECT - - public: - explicit CpCertTrustView( TInt certificateIndex, - CpCertDataContainer& certDataContainer, - QGraphicsItem *parent = 0 ); - virtual ~CpCertTrustView(); - void saveTrustSettings(); - - private: - void viewTrustSettings(); - void updateListBoxL(); - TInt trustIdIndex( TUid aTrusterUid ) const; - TBool checkCertificateClientTrustL( const TUid clientUid, const CCTCertInfo& entry ) const; - TUid trusterId(const QString& clientDescription) const; - - private: - CpCertDataContainer& mCertDataContainer; - /** - * Application manager class, used to get applications in system. - */ - CCertificateAppInfoManager* mAppInfoManager; - - /** - * Client Uids of the certstore - */ - RArray mClientUids; - - /** - * To get the names of the trusted clients from the resources - */ - QList mTrustedClients; - - /** - * To get the yes/no trust texts from the resources - */ - QList mTrustValues; - - TInt mCertificateIndex; - - HbDataFormModel* mFormModel; - - }; - -#endif // CPCERTTRUSTVIEW_H - -// End of File diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/cpcertview.h --- a/cpsecplugins/cpadvancedsecplugin/inc/cpcertview.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0"" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef CPCERTVIEW_H -#define CPCERTVIEW_H - -#include - -class HbAbstractViewItem; -class CpCertDataContainer; -class CCTCertInfo; -class HbListView; -class HbAction; -class HbDialog; -class HbMessageBox; -class HbAction; - -class CpCertView : public CpBaseSettingView - { - Q_OBJECT - - public: - explicit CpCertView(const QModelIndex& index, QGraphicsItem *parent = 0); - virtual ~CpCertView(); - - public: - enum TCertificateViews - { - EAuthorityView=0, - ETrustedView, - EPersonalView, - EDeviceView - }; - - public slots: - void displayPreviousView(); - - private slots: - void openCertificate(); - void openCertFromList(const QModelIndex& modelIndex); - void showTrustSettings(); - void saveTrustSettings(); - void indicateLongPress(HbAbstractViewItem*, QPointF); - - void deleteCertificate(); - TInt refreshListL(); - void refreshView( TInt aCount ); - - void moveSelectedCert(); - void deleteList(); - void selectAll(); - void moveCert(); - void viewDone(); - void handleMultipleDelete(HbAction* action); - void handleMoveDialog(HbAction* action); - void handleDeleteDialog(HbAction* action); - void handleMoveCertDialog(HbAction* action); - private: - const CCTCertInfo* certAt(TInt index) const; - QString certLabel(TInt index) const; - void deleteCertsL( RArray& indexList ); - void setDetails(CpCertView::TCertificateViews currentView); - void moveCertList( RArray& indexList ); - - private: - CpCertView::TCertificateViews mCertView; - TInt mPos; - CpCertDataContainer* mCertDataContainer; - TBool mSelectAll; - RArray mSelectionIndex; - RArray mIndexList; - - HbDialog* mPopup; - HbAction* mOkAction; - HbView* mPrevView; - HbView* mCurrentView; - CpBaseSettingView* mRefreshedView; - HbListView* mListView; - HbListView* mSelectAllView; - HbView* mOriginalView; - HbMessageBox* mNote; - HbMenu* mContextMenu; - }; - -#endif /* CPCERTVIEW_H */ diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/cpmoduleview.h --- a/cpsecplugins/cpadvancedsecplugin/inc/cpmoduleview.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0"" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef CPMODULEVIEW_H -#define CPMODULEVIEW_H - -#include -#include "cpsecmodview.h" - -class HbAbstractViewItem; -class CpItemDataHelper; -class CSecModUIModel; -class CpSecModView; - -class CpModuleView : public CpBaseSettingView -{ - Q_OBJECT -public: - explicit CpModuleView( CpSecModView::TSecModViews currentView, - CSecModUIModel& secModUIModel, - QGraphicsItem *parent = 0 ); - virtual ~CpModuleView(); - -private slots: - void handleAccessView( const QModelIndex& modelIndex ); - void handleAccessView(); - void handleSigView(); - void handleSigViewCommand(); - void indicateLongPress(HbAbstractViewItem *item,QPointF coords); - -private: - void showAccessView(); - void showSignatureView(TBool showBlockedNote); - -private: - enum TSecModAccessCodeCommandIds - { - EIndexCodeLabel = 0, - EIndexCodeRequest, - EIndexCodeStatus - }; - - enum TSecModSignatureCommandIds - { - ESecModUICmdOpen = 0, - ESecModUICmdModuleInfo, - ESecModUICmdDelKeyStore, - ESecModUICmdChange, - ESecModUICmdUnblock, - ESecModUICmdClose, - ESecModUICmdAppTest - }; - -private: - CpSecModView::TSecModViews mCurrentView; - CSecModUIModel& mSecModUIModel; - TInt mPos; - HbMenu* mContextMenu; -}; - -#endif /* CPMODULEVIEW_H */ diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/cpsecmodmodel.h --- a/cpsecplugins/cpadvancedsecplugin/inc/cpsecmodmodel.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,341 +0,0 @@ -/* -* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Declaration of the CSecModUIModel class -* -*/ - - -#ifndef CSECMODUIMODEL_H -#define CSECMODUIMODEL_H - -// INCLUDES -#include -#include -#include -#include - -#include -#include -#include -#include - -class QString; -class HbListWidget; - -// CONSTANTS -const TInt KMaxSettItemSize = 200; - -const TInt KPinGSettIndex = 0; -const TInt KPinNrSettIndex = 1; - -const TUid KUidSecMod = { 0x101F8668 }; - -// Panic strings -_LIT(KPanicNullPointer, "SecModUI: invalid pointer"); -_LIT(KPanicIndexOutOfRange, "SecModUI: array indexed out of range"); - -// FORWARD DECLARATIONS -class CUnifiedKeyStore; -class MCTAuthenticationObject; -class MCTAuthenticationObjectList; -class CSecModUISyncWrapper; -class MCTKeyStore; -class MCTToken; - -class QString; - -// FUNCTION PROTOTYPES -GLREF_C void Panic( TInt aPanic ); - -// CLASS DECLARATION - -/** -* class CSecModUIModel -* Model of the application -* -* @lib SecModUI.lib -* @since Series 60 3.0 -*/ -class CSecModUIModel : public CBase - { - public: // Constructors and destructLoadTokenLabelsLor - - /** - * Two-phased constructor. - */ - static CSecModUIModel* NewL(); - - /** - * Destructor. - */ - virtual ~CSecModUIModel(); - - public: // New functions - /** - * Initializes unified keystore - */ - void InitializeKeyStoreL(); - - /** - * Retrieves the description and location of all tokens. - * @return Map containing the label and the appripriate location. - */ - QMap LoadTokenLabelsL(); - - /** - * Shows error note if needed. - * @param aError - * @return void - */ - void ShowErrorNote(TInt aError) const; - - /** - * Retrieves the appropriate token based on the index. - * @param aTokenIndex Index of the token to be opened. - * @return void - */ - void OpenTokenL(TInt aTokenIndex); - - /** - * Initialize the auth objects and return the total count. - * @param aItemArray contains localised stings - * @return void - */ - TInt CheckCodeViewStringsL(); - - /** - * Retrieves description of the token based on UID of the current active keystore. - * @return Description - */ - QString TokenLabelForTitle() const; - - /** - * Returns status of the selected auth object. - * @param index - * @return status - */ - TUint32 AuthStatus(TInt aIndex) const; - - /** - * Returns status of the auth object based on its persistent properties set - * by security module implementation. - * @param aIndex Index of the authentication object - * @param aShowBlockedNote If ETrue, shows code blocked if code is blocked. - * @return status of the pin. - */ - QString PINStatus( TInt aIndex, TBool aShowBlockedNote ) const; - - /** - * Checks whether the Pin is still available. - * @param aIndex Index of the authentication object. - * @return status - */ - TBool PinOpen(TInt aIndex) const; - - /** - * Based on the property of auth object the pin can be - * changed or unblocked. - * @param aIndex Index of the auth object - * @return ?description - */ - void ChangeOrUnblockPinL(TInt aIndex); - - /** - * Changes the value of the PIN. - * @param aIndex Index of the AO - * @return void - */ - void ChangePinL(TInt aIndex); - - /** - * Toggles the value of auth object if possible. - * @param ?arg1 ?description - * @return ?description - */ - TInt ChangeCodeRequest(TInt aIndex); - - /** - * If the auth object is open then closes it. - * @param aIndex Index of the AO to be closed. - * @return void - */ - void CloseAuthObjL(TInt aIndex); - - /** - * Unblocks PIN - * @param aIndex Index of the AO - * @return void - */ - void UnblockPinL(TInt aIndex); - - /** - * Deletes key from the appropriate keystore. - * @param aTokenIndex Index of the token to be deleted. - * @return ETrue if keystore was deleted. - */ - void DeleteKeysL(TInt aTokenIndex); - - /** - * Returns ETrue if PIN is changeable. - * @param aIndex Index of the AO - * @return ETrue / EFalse - */ - TBool PinChangeable(TInt aIndex) const; - - /** - * Displays security module details dialog. - * @param aTokenIndex Index of the token, which details are shown. - * @return void - */ - QVector< QPair > SecModDetailsL(TInt aTokenIndex); - - /** - * Displays details dialog of the active security module . - * @return void - */ - QVector< QPair > GetSecModDetailsL(); - - /** - * Appends the location of the keystore. - * @return void - */ - void AppendLocation( QVector< QPair >& aSecModDetails, - TUid aLocUid, - QString aCertDisplayDetails ); - - /** - * Appends the value of a label if present otherwise appends empty descriotion. - * @return void - */ - void AppendItem( QVector< QPair >& aSecModDetails, - QString aLabel, - const TDesC& aValue, - QString aNullDescription ); - - /** - * Generate details of signing security module. - * @return void - */ - void AppendPinNRs(QVector< QPair >& aSecModDetails); - - QVector< QPair > AuthDetails(); - - /** - * Changes PIN-NR - * @param aIndex Index of the AO - * @return void - */ - void ChangePinNrL(TInt aIndex); - - /** - * Unblocks PIN-NR - * @param aIndex Index of the AO - * @return void - */ - void UnblockPinNrL(TInt aIndex); - - /** - * Retrieves the UID of the current active keystore. - * @return uid - */ - TInt KeyStoreUID(); - - /** - * Retrieves the auth object at the speficied index. - * @return auth object - */ - const MCTAuthenticationObject& AuthObj(TInt aIndex); - - /** - * Returns ETrue if PIN is unblockable. - * @param aIndex Index of the AO - * @return ETrue / EFalse - */ - TBool PinUnblockable(TInt aIndex) const; - - - /** - * Returns ETrue if PIN request can be disabled / enabled. - * @param aIndex Index of the AO - * @return ETrue / EFalse - */ - TBool PinRequestChangeable(TInt aIndex) const; - - /** - * Returns ETrue if token is deletable. - * @param aTokenIndex Index of the token to be deleted. - * @return ETrue / EFalse - */ - TBool IsTokenDeletable(TInt aTokenIndex); - - - private: - - /** - * C++ default constructor. - */ - CSecModUIModel(); - - /** - * By default Symbian 2nd phase constructor is private. - */ - void ConstructL(); - - void ResetAndDestroyCTObjects(); - - void ResetAndDestroyAOs(); - - void InitAuthObjectsL(); - - void ListAuthObjectsL(); - - void CreateSettingItem(const TDesC& aTitle, - const TDesC& aValue, - TDes& aItem) const; - - QString Location( TUid aUid ) const; - - void AppendPinNRsL( TDes& aMessage ) const; - - private: - // DATA TYPES - enum TSecModPanicCode - { - EPanicNullPointer, - EPanicIndexOutOfRange - }; - - private: // Data - // Resource file offsets - TInt iResourceFileOffset; - TInt iResourceFileOffset2; - TInt iResourceFileOffset3; - - CSecModUISyncWrapper* iWrapper; // owned - RFs iRfs; - - /** - * Crypto Token objects - */ - CUnifiedKeyStore* iUnifiedKeyStore; // owned - MCTKeyStore* iKeyStore; // not owned - MCTAuthenticationObjectList* iAOList; // owned, items not owned - RMPointerArray iAOArray; // items not owned - - RMPointerArray iAOKeyStores; // items not owned - }; - -#endif // CSECMODUIMODEL_H - -// End of File diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/cpsecmodsyncwrapper.h --- a/cpsecplugins/cpadvancedsecplugin/inc/cpsecmodsyncwrapper.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,125 +0,0 @@ -/* -* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Wrapper class for Symbian's Security Framework's calls. -* -*/ - -#ifndef CPSECMODUISYNCWRAPPER_H -#define CPSECMODUISYNCWRAPPER_H - -#include -#include -#include -#include -#include - -class MCTToken; -class MCTAuthenticationObject; -class MCTAuthenticationObjectList; -class CUnifiedKeyStore; -class MCTTokenInterface; -class TCTTokenObjectHandle; - - - -/** -* class CSecModUISyncWrapper -* Wrapper class for Symbian's Security Framework's calls. -* -* @lib wimmanui.dll -* @since Series 60 2.0 -*/ -class CSecModUISyncWrapper : public CActive - { - public: // Constructors and destructor - - static CSecModUISyncWrapper* NewLC(); - static CSecModUISyncWrapper* NewL(); - virtual ~CSecModUISyncWrapper(); - - public: // New functions - - TInt Initialize(CUnifiedKeyStore& aKeyStore ); - - TInt OpenWIM(); - - TInt GetAuthObjectInterface( - MCTToken& aToken, - MCTTokenInterface*& aTokenInterface); - - TInt ListAuthObjects( - MCTAuthenticationObjectList& aAuthObjList, - RMPointerArray& aAuthObjects ); - - TInt ListKeys( - MCTKeyStore& aKeyStore, - RMPointerArray& aKeysInfos, - const TCTKeyAttributeFilter& aFilter); - - TInt DeleteKey( - CUnifiedKeyStore& aKeyStore, - TCTTokenObjectHandle aHandle); - - TInt ChangeReferenceData( MCTAuthenticationObject& aAuthObject ); - - TInt UnblockAuthObject( MCTAuthenticationObject& aAuthObject ); - - TInt EnableAuthObject( MCTAuthenticationObject& aAuthObject ); - - TInt DisableAuthObject( MCTAuthenticationObject& aAuthObject ); - - TInt CloseAuthObject( MCTAuthenticationObject& aAuthObject ); - - TInt TimeRemaining( MCTAuthenticationObject& aAuthObject, TInt& aStime ); - - protected: // From CActive - - void DoCancel(); - void RunL(); - - private: // New functions - - CSecModUISyncWrapper(); - - private: // Data - - // Internal operation states. - enum TOperation - { - EOperationInit, - EOperationGetAOInterface, - EOperationListAOs, - EOperationListKeys, - EOperationDelKey, - EOperationChangeReferenceData, - EOperationUnblockAO, - EOperationEnableAO, - EOperationDisableAO, - EOperationCloseAO, - EOperationTimeRemAO, - EOperationNone - }; - - // For wrapping asynchronous calls. - CActiveSchedulerWait iWait; - - // Internal state of operation. - TOperation iOperation; - - // CT objects - TAny* iObject; - }; - - -#endif // CPSECMODUISYNCWRAPPER_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/cpsecmoduleinfoview.h --- a/cpsecplugins/cpadvancedsecplugin/inc/cpsecmoduleinfoview.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0"" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef CPSECMODULEINFOIEW_H -#define CPSECMODULEINFOIEW_H - -#include - - - -class CpSecmoduleInfoView : public CpBaseSettingView -{ - Q_OBJECT -public: - explicit CpSecmoduleInfoView(const QVector< QPair >& securityDetails,QGraphicsItem *parent = 0); - virtual ~CpSecmoduleInfoView(); - -public slots: - - -private: - - -}; - -#endif // CPSECMODULEINFOIEW_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/cpsecmodview.h --- a/cpsecplugins/cpadvancedsecplugin/inc/cpsecmodview.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0"" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef CPSECMODVIEW_H -#define CPSECMODVIEW_H - -#include - -class HbAbstractViewItem; -class CpItemDataHelper; -class CSecModUIModel; - -class CpSecModView : public CpBaseSettingView -{ - Q_OBJECT -public: - explicit CpSecModView(TInt aCurrentPos, CSecModUIModel& aSecModUIModel, QGraphicsItem *parent = 0); - virtual ~CpSecModView(); - -private slots: - void displayPrevious(); - void showNextView( const QModelIndex& modelIndex ); - -public: - enum TSecModViews - { - EAccessView=0, - ESignatureView - }; - - -private: - CSecModUIModel& mSecModUIModel; - TInt mPos; - TSecModViews mCurrentView; - HbView* mAccessView; - HbView* mPrevView; - -}; - -#endif /* CPPLACEHOLDERENTRYITEMDATA_H */ diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/cpsecurityview.h --- a/cpsecplugins/cpadvancedsecplugin/inc/cpsecurityview.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0"" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef CPSECURITYVIEW_H -#define CPSECURITYVIEW_H - -#include - -class HbAbstractViewItem; -class CpItemDataHelper; -class CpSecModView; -class CpCertView; -class CSecModUIModel; -class QModelIndex; -class CpSecmoduleInfoView; -class HbMessageBox; -class HbAction; - -class CpSecurityView : public CpBaseSettingView -{ - Q_OBJECT -public: - explicit CpSecurityView(QGraphicsItem *parent = 0); - virtual ~CpSecurityView(); - -public slots: - void viewDone(); - void showWIMview(); - void displayCert(const QModelIndex& modelIndex); - void displayPrevious(); - void showCodeView(); - void showCodeView( const QModelIndex& modelIndex); - void indicateLongPress(HbAbstractViewItem *item,QPointF coords); - void deleteModule(); - void moduleDetails(); - void displayPreviousFromModInfo(); - void dialogClosed(HbAction* action); -private: - CSecModUIModel* mSecModUIModel; - CpSecModView* mSecModView; - HbView* mPreView; - CpCertView* mCertView; - CpSecmoduleInfoView* mModuleinfoView; - HbView* mCurrentView; - TInt mPos; - HbMessageBox* mNote; - HbAction* mOkAction; - HbMenu* mContextMenu; - -}; - -#endif // CPSECURITYVIEW_H diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/cpuitrustids.h --- a/cpsecplugins/cpadvancedsecplugin/inc/cpuitrustids.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Contains the TUids of supported clients for certificate's Trust Setting View -* -*/ - - -#ifndef CPUITRUSTIDS_H -#define CPUITRUSTIDS_H - -// CONSTANTS -const TUid KCertManUINullId = {0}; -const TUid KCertManUIViewTrustWapConnectionId = {268479059}; -const TUid KCertManUIViewTrustApplicationControllerId = {268452523}; -const TUid KCertManUIViewTrustMailAndImageConnId = {268441661}; -const TUid KCertManUIViewTrustJavaInstallingId = {270506792}; -const TUid KCertManUIViewOCSPCheckInstallingId = {268478646}; -const TUid KCertManUIViewTrustVPNId = {270498195}; -const TUid KCertManUIViewTrustWidgetInstallId = {537028562}; - -#endif // CPUITRUSTIDS_H - -// End of File diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/inc/trace.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/inc/trace.h Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: TRACE macros +* +*/ + +#ifndef TRACE_H +#define TRACE_H + +#include // RDebug + + +// TODO: replace with OST tracing +#ifdef _DEBUG +#define TRACE( a, ARGS... ) DebugPrint( _L( a ), ##ARGS ) +#define TRACE_FUNC( ) RDebug::Printf( "%s %s (%u)", __FILE__, __PRETTY_FUNCTION__, __LINE__ ) +#else +#define TRACE( a, ARGS... ) +#define TRACE_FUNC( ) +#endif + + +// --------------------------------------------------------------------------- +// DebugPrint() +// --------------------------------------------------------------------------- +// +#ifdef _DEBUG +const TInt KMaxPrintSize = 256; +inline void DebugPrint( TRefByValue aFmt, ... ) + { + VA_LIST list; + VA_START( list, aFmt ); + TBuf buf; + buf.AppendFormatList( aFmt, list ); + RDebug::Print( buf ); + } +#endif + + +#endif // CPADVSECSETTINGSTRACE_H + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/rom/advancedsecurity_resources.iby --- a/cpsecplugins/cpadvancedsecplugin/rom/advancedsecurity_resources.iby Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Advanced security settings resources -* -*/ - -#ifndef ADVANCEDSECPLUGIN_RESOURCES_IBY -#define ADVANCEDSECPLUGIN_RESOURCES_IBY - -#include - -data=DATAZ_\QT_TRANSLATIONS_DIR\certificate_manager.qm QT_TRANSLATIONS_DIR\certificate_manager.qm - -#endif // ADVANCEDSECPLUGIN_RESOURCES_IBY diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/rom/cpadvancedsecplugin.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/rom/cpadvancedsecplugin.iby Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Advanced security settings (control panel plugin) +* +*/ + +#ifndef CPADVANCEDSECPLUGIN_IBY +#define CPADVANCEDSECPLUGIN_IBY + +file=ABI_DIR\BUILD_DIR\cpadvancedsecplugin.dll SHARED_LIB_DIR\cpadvancedsecplugin.dll +data=\epoc32\data\c\resource\qt\plugins\controlpanel\cpadvancedsecplugin.qtplugin resource\qt\plugins\controlpanel\cpadvancedsecplugin.qtplugin + +#endif // CPADVANCEDSECPLUGIN_IBY diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/rom/cpadvancedsecplugin_resources.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/rom/cpadvancedsecplugin_resources.iby Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Advanced security settings resources +* +*/ + +#ifndef ADVANCEDSECPLUGIN_RESOURCES_IBY +#define ADVANCEDSECPLUGIN_RESOURCES_IBY + +#include + +data=DATAZ_\QT_TRANSLATIONS_DIR\certificate_manager.qm QT_TRANSLATIONS_DIR\certificate_manager.qm + +#endif // ADVANCEDSECPLUGIN_RESOURCES_IBY diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/rom/cpsecplugins.iby --- a/cpsecplugins/cpadvancedsecplugin/rom/cpsecplugins.iby Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef CPSECPLUGINS_IBY -#define CPSECPLUGINS_IBY - -file=ABI_DIR\BUILD_DIR\cpadvancedsecplugin.dll SHARED_LIB_DIR\cpadvancedsecplugin.dll - -data=\epoc32\data\c\resource\qt\plugins\controlpanel\cpadvancedsecplugin.qtplugin resource\qt\plugins\controlpanel\cpadvancedsecplugin.qtplugin - -#endif diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/rom/cpsecplugins_rom.pri --- a/cpsecplugins/cpadvancedsecplugin/rom/cpsecplugins_rom.pri Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -# -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# - - -symbian { -BLD_INF_RULES.prj_exports += "../rom/cpsecplugins.iby CORE_APP_LAYER_IBY_EXPORT_PATH(cpsecplugins.iby)" -BLD_INF_RULES.prj_exports += "../rom/advancedsecurity_resources.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(advancedsecurity_resources.iby )" -} \ No newline at end of file diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertdetailsbuilder_symbian.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertdetailsbuilder_symbian.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,707 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to construct certificate details +* +*/ + +#include "advsecsettingscertdetailsbuilder_symbian.h" +#include "advsecsettingscertificatemodel.h" +#include "advsecsettingstrustedcertusageuids.h" +#include "advsecsettingsstoreuids.h" +#include // CUnifiedKeyStore +#include // CCTKeyInfo +#include // CCTCertInfo +#include // CX509Certificate +#include // X509CertNameParser +#include // MD5 fingerprint +#include +#include +#include +#include + +// TODO: fix this +#include "../../../pkiutilities/DeviceToken/inc/TrustedSitesStore.h" // CTrustSitesStore + +_LIT(KLocAlgorithmRSA, "txt_certificate_list_rsa"); +_LIT(KLocAlgorithmDSA, "txt_certificate_list_dsa"); +_LIT(KLocAlgorithmDH, "txt_certificate_list_dh"); +_LIT(KLocAlgorithmMD2, "txt_certificate_list_md2"); +_LIT(KLocAlgorithmMD5, "txt_certificate_list_md5"); +_LIT(KLocAlgorithmSHA1, "txt_certificate_list_sha1"); +_LIT(KLocAlgorithmSHA2, "txt_certificate_list_sha2"); +_LIT(KLocAlgorithmUnknown, "txt_certificate_list_unknown"); +_LIT(KLocCertTypeX509, "txt_certificate_list_x509"); +_LIT(KLocCertTypeUnknown, "txt_certificate_list_unknown"); + +const QString KFormatForAlgorithmNames = "%1%2"; +const QString KTrustedSitesSeparator = ", "; + +const int KCertManUiContinuousHexString = 0; +const int KCertManUiTwoDigitsInBlock = 2; + +// implemented in advsecsettingssecuritymodulemodel_symbian_p.cpp +QString CopyStringL(const TDesC16 &aDes16); +QString CopyStringL(const TDesC8 &aDes8); + + +// ======== LOCAL FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CopyDateL() +// --------------------------------------------------------------------------- +// +void CopyDateL(const TDateTime& aFromDateTime, QDateTime& aToDateTime) +{ + QT_TRYCATCH_LEAVING( + QDate date(aFromDateTime.Year(), aFromDateTime.Month()+1, aFromDateTime.Day()+1); + aToDateTime.setDate(date)); +} + +// --------------------------------------------------------------------------- +// HexFormattedStringL() +// --------------------------------------------------------------------------- +// +QString HexFormattedStringL(const TDesC8& aDes, int blockSize = KCertManUiContinuousHexString) +{ + QString string; + int blockIndex = 1; + for (TInt index = 0; index < aDes.Length(); ++index) { + QString number; + QT_TRYCATCH_LEAVING( + number.sprintf("%02X", aDes[ index ]); + string.append(number)); + if (blockIndex == blockSize) { + string.append(" "); + blockIndex = 1; + } else { + ++blockIndex; + } + } + return string; +} + +// --------------------------------------------------------------------------- +// ResetAndDestroyCleanup() +// --------------------------------------------------------------------------- +// +QString Location(const TUid &aTokenType) +{ + QString location; + switch (aTokenType.iUid) { + // TODO: localized UI strings needed + case KAdvSecSettingsFileCertStore: + case KAdvSecSettingsFileKeyStore: + case KAdvSecSettingsTrustedServerCertStore: + case KAdvSecSettingsDeviceCertStore: + case KAdvSecSettingsDeviceKeyStore: + case KAdvSecSettingsSWICertStore: + //: Certificate details location, phone memory + location = QObject::tr("Phone memory"); + break; + case KAdvSecSettingsWIMCertAndKeyStore: + //: Certificate details location, SIM or WIM card + location = QObject::tr("Smart card"); + break; + default: + break; + } + return location; +} + +// --------------------------------------------------------------------------- +// ResetAndDestroyCleanup() +// --------------------------------------------------------------------------- +// +void ResetAndDestroyCleanup( TAny* aAny ) + { + RPointerArray* array = reinterpret_cast *>( aAny ); + array->ResetAndDestroy(); + } + +// --------------------------------------------------------------------------- +// CleanupResetAndDestroyPushL() +// --------------------------------------------------------------------------- +// +void CleanupResetAndDestroyPushL( RPointerArray& aArray ) + { + TCleanupItem item( &ResetAndDestroyCleanup, &aArray ); + CleanupStack::PushL( item ); + } + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::NewL() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsCertDetailsBuilder *CAdvSecSettingsCertDetailsBuilder::NewL( + RFs &aFs, CUnifiedCertStore &aCertStore) +{ + CAdvSecSettingsCertDetailsBuilder *self = new(ELeave) CAdvSecSettingsCertDetailsBuilder( + aFs, aCertStore); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::~CAdvSecSettingsCertDetailsBuilder() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsCertDetailsBuilder::~CAdvSecSettingsCertDetailsBuilder() +{ + Cancel(); + delete iCertificate; + delete iCertificateUrl; + iKeys.Close(); + delete iKeyFilter; + delete iKeyStore; + + // not owned + iDetails = NULL; + iClientStatus = NULL; + iCertInfo = NULL; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::GetDetailsL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::GetDetailsL(const CCTCertInfo &aCert, + QMap &aDetails, TRequestStatus &aStatus) +{ + if (!iClientStatus && (iState == ENotInitialized || + iState == EInitializingKeyStore || iState == EIdle)) { + iCertInfo = &aCert; + iDetails = &aDetails; + iClientStatus = &aStatus; + aStatus = KRequestPending; + + if (!iKeyStore) { + InitializeKeyStoreL(); // Retrieving starts after initialization is complete + } else { + RetrieveCertificateL(); + } + } else { + TRequestStatus *status = &aStatus; + User::RequestComplete(status, KErrGeneral); + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::DoCancel() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::DoCancel() +{ + switch (iState) { + case EInitializingKeyStore: + iKeyStore->CancelInitialize(); + iState = ENotInitialized; + break; + case ERetrievingCertificate: + iCertStore.CancelRetrieve(); + iState = EIdle; + break; + case EListingKeys: + iKeyStore->CancelList(); + iState = EIdle; + break; + default: + break; + } + User::RequestComplete(iClientStatus, KErrCancel); + iClientStatus = NULL; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::RunL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::RunL() +{ + User::LeaveIfError(iStatus.Int()); + + switch (iState) { + case EInitializingKeyStore: + RetrieveCertificateL(); + break; + case ERetrievingCertificate: + ListKeysL(); + break; + case EListingKeys: + ReturnCertificateDetailsL(); + break; + default: + ASSERT(EFalse); + break; + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::RunError() +// --------------------------------------------------------------------------- +// +TInt CAdvSecSettingsCertDetailsBuilder::RunError(TInt aError) +{ + User::RequestComplete(iClientStatus, aError); + if (iState != EInitializingKeyStore) { + iState = EIdle; + } else { + iState = EFailed; + } + return KErrNone; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsCertDetailsBuilder::CAdvSecSettingsCertDetailsBuilder(RFs &aFs, + CUnifiedCertStore &aCertStore) : CActive(CActive::EPriorityLow), iFs(aFs), + iCertStore(aCertStore), iCertUrlPtr(0, 0) +{ + CActiveScheduler::Add(this); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::ConstructL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::ConstructL() +{ +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::InitializeKeyStoreL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::InitializeKeyStoreL() +{ + ASSERT(!iKeyStore); + iKeyStore = CUnifiedKeyStore::NewL(iFs); + iKeyStore->Initialize(iStatus); + iState = EInitializingKeyStore; + SetActive(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::RetrieveCertificateL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::RetrieveCertificateL() +{ + ASSERT(iCertInfo); + if (iCertificate) { + delete iCertificate; + iCertificate = NULL; + } + if (iCertificateUrl) { + delete iCertificateUrl; + iCertificateUrl = NULL; + } + + if (iCertInfo->CertificateFormat() == EX509Certificate) { + iCertStore.Retrieve(*iCertInfo, iCertificate, iStatus); + } else { + iCertificateUrl = HBufC8::NewL(iCertInfo->Size()); + iCertUrlPtr.Set(iCertificateUrl->Des()); + iCertStore.Retrieve(*iCertInfo, iCertUrlPtr, iStatus); + } + iState = ERetrievingCertificate; + SetActive(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::ListKeysL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::ListKeysL() +{ + ASSERT(iKeyStore); + if (!iKeyFilter) { + iKeyFilter = new TCTKeyAttributeFilter; + } + iKeyFilter->iKeyId = iCertInfo->SubjectKeyId(); + iKeys.Close(); + iKeyStore->List(iKeys, *iKeyFilter, iStatus); + iState = EListingKeys; + SetActive(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::ReturnCertificateDetailsL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::ReturnCertificateDetailsL() +{ + AppendLabelL(); + AppendIssuerL(); + AppendSubjectL(); + AppendValidityPeriodL(); + AppendLocationL(); + AppendFormatL(); + AppendKeyUsageL(); + AppendAlgorithmL(); + AppendSerialNumberL(); + AppendFingerprintsL(); + AppendPublicKeyL(); + AppendTrustedSitesL(); + + User::RequestComplete(iClientStatus, KErrNone); + iClientStatus = NULL; + iState = EIdle; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::CertificateFormatStringL() +// --------------------------------------------------------------------------- +// +QString CAdvSecSettingsCertDetailsBuilder::CertificateFormatStringL( + const TCertificateFormat aFormat) const +{ + HBufC* format = NULL; + + switch (aFormat) { + case EX509Certificate: + format = HbTextResolverSymbian::LoadLC(KLocCertTypeX509); + break; + case EWTLSCertificate: + // TODO: localized UI strings needed + format = _L("WTLS").AllocLC(); + break; + case EX968Certificate: + // TODO: localized UI strings needed + format = _L("X968").AllocLC(); + break; + case EX509CertificateUrl: + // TODO: localized UI strings needed + format = _L("X509 URL").AllocLC(); + break; + case EWTLSCertificateUrl: + // TODO: localized UI strings needed + format = _L("WTLS URL").AllocLC(); + break; + case EX968CertificateUrl: + // TODO: localized UI strings needed + format = _L("X968 URL").AllocLC(); + break; + case EUnknownCertificate: + default: + //: Unknown certificate format type + format = HbTextResolverSymbian::LoadLC(KLocCertTypeUnknown); + break; + } + + QString formatString = CopyStringL(*format); + CleanupStack::PopAndDestroy(format); + return formatString; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::AlgorithmNameStringL() +// --------------------------------------------------------------------------- +// +QString CAdvSecSettingsCertDetailsBuilder::AlgorithmNameStringL( + TAlgorithmId aAlgorithmId) const +{ + HBufC* algorithm = NULL; + + switch (aAlgorithmId) { + case ERSA: + algorithm = HbTextResolverSymbian::LoadLC(KLocAlgorithmRSA); + break; + case EDSA: + algorithm = HbTextResolverSymbian::LoadLC(KLocAlgorithmDSA); + break; + case EDH: + algorithm = HbTextResolverSymbian::LoadLC(KLocAlgorithmDH); + break; + case EMD2: + algorithm = HbTextResolverSymbian::LoadLC(KLocAlgorithmMD2); + break; + case EMD5: + algorithm = HbTextResolverSymbian::LoadLC(KLocAlgorithmMD5); + break; + case ESHA1: + algorithm = HbTextResolverSymbian::LoadLC(KLocAlgorithmSHA1); + break; + case ESHA224: + case ESHA256: + case ESHA384: + case ESHA512: + algorithm = HbTextResolverSymbian::LoadLC(KLocAlgorithmSHA2); + break; + default: + break; + } + + QString algorithmName; + if (algorithm) { + algorithmName = CopyStringL(*algorithm); + CleanupStack::PopAndDestroy(algorithm); + } + return algorithmName; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::AppendLabelL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::AppendLabelL() +{ + ASSERT(iCertInfo); + HBufC *label = NULL; + if (iCertInfo->CertificateFormat() == EX509Certificate) { + CX509Certificate *cert = static_cast(iCertificate); + HBufC* secondaryName = NULL; + X509CertNameParser::PrimaryAndSecondaryNameL(*cert, label, secondaryName); + delete secondaryName; + } else { + label = iCertInfo->Label().AllocL(); + } + CleanupStack::PushL(label); + iDetails->insert(AdvSecSettingsCertificateModel::Label, CopyStringL(*label)); + CleanupStack::PopAndDestroy(label); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::AppendIssuerL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::AppendIssuerL() +{ + if (iCertificate) { + HBufC *issuer = NULL; + ASSERT(iCertInfo); + if (iCertInfo->CertificateFormat() == EX509Certificate) { + CX509Certificate* cert = static_cast( iCertificate ); + X509CertNameParser::IssuerFullNameL(*cert, issuer); + } else { + issuer = iCertificate->IssuerL(); + } + CleanupStack::PushL(issuer); + iDetails->insert(AdvSecSettingsCertificateModel::Issuer, CopyStringL(*issuer)); + CleanupStack::PopAndDestroy(issuer); + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::AppendSubjectL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::AppendSubjectL() +{ + if (iCertificate) { + HBufC *subject = NULL; + ASSERT(iCertInfo); + if (iCertInfo->CertificateFormat() == EX509Certificate) { + CX509Certificate* cert = static_cast( iCertificate ); + X509CertNameParser::SubjectFullNameL(*cert, subject); + } else { + subject = iCertificate->SubjectL(); + } + CleanupStack::PushL(subject); + iDetails->insert(AdvSecSettingsCertificateModel::Subject, CopyStringL(*subject)); + CleanupStack::PopAndDestroy(subject); + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::AppendValidityPeriodL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::AppendValidityPeriodL() +{ + if (iCertificate) { + CValidityPeriod validityPeriod(iCertificate->ValidityPeriod()); + + TDateTime sValidFrom(validityPeriod.Start().DateTime()); + QDateTime qValidFrom; + CopyDateL(sValidFrom, qValidFrom); + QString validFrom(qValidFrom.toString(Qt::DefaultLocaleShortDate)); + iDetails->insert(AdvSecSettingsCertificateModel::ValidFrom, validFrom); + + TDateTime sValidTo(validityPeriod.Finish().DateTime()); + QDateTime qValidTo; + CopyDateL(sValidTo, qValidTo); + QString validTo(qValidTo.toString(Qt::DefaultLocaleShortDate)); + iDetails->insert(AdvSecSettingsCertificateModel::ValidTo, validTo); + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::AppendLocationL() +{ + ASSERT(iCertInfo); + QString location; + if (iCertificateUrl) { + if (iCertInfo->CertificateFormat() == EX509CertificateUrl) { + location = CopyStringL(*iCertificateUrl); + } + } else { + location = Location(iCertInfo->Token().TokenType().Type()); + } + if (!location.isEmpty()) { + iDetails->insert(AdvSecSettingsCertificateModel::Location, location); + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::AppendFormatL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::AppendFormatL() +{ + ASSERT(iCertInfo); + QString certFormat = CertificateFormatStringL(iCertInfo->CertificateFormat()); + iDetails->insert(AdvSecSettingsCertificateModel::Format, certFormat); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::AppendKeyUsageL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::AppendKeyUsageL() +{ + // TODO: should be displayed only for user and device certicates + if (iKeys.Count()) { + const TInt KFirstKeyIndex = 0; + // TODO: localized UI strings needed + + // Key Usage + QString keyUsage; + TKeyUsagePKCS15 usage = iKeys[KFirstKeyIndex]->Usage(); + if ((usage & EPKCS15UsageSign) || (usage & EPKCS15UsageSignRecover)) { + keyUsage = QObject::tr("Client authentication"); + } + if (usage & EPKCS15UsageNonRepudiation) { + keyUsage = QObject::tr("Digital signing"); + } + if (!keyUsage.isEmpty()) { + iDetails->insert(AdvSecSettingsCertificateModel::KeyUsage, keyUsage); + } + + // Key Location + QString keyLocation; + keyLocation = Location(iKeys[KFirstKeyIndex]->Token().TokenType().Type()); + if (!keyLocation.isEmpty()) { + iDetails->insert(AdvSecSettingsCertificateModel::KeyLocation, keyLocation); + } + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::AppendAlgorithmL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::AppendAlgorithmL() +{ + if (iCertificate) { + QString digestAlg = AlgorithmNameStringL( + iCertificate->SigningAlgorithm().DigestAlgorithm().Algorithm()); + QString asymmerticAlg = AlgorithmNameStringL( + iCertificate->SigningAlgorithm().AsymmetricAlgorithm().Algorithm()); + if (digestAlg.isNull() || asymmerticAlg.isNull()) { + HBufC* unknownAlg = HbTextResolverSymbian::LoadLC(KLocAlgorithmUnknown); + iDetails->insert(AdvSecSettingsCertificateModel::Algorithm, CopyStringL(*unknownAlg)); + CleanupStack::PopAndDestroy(unknownAlg); + } else { + QString algorithm(KFormatForAlgorithmNames.arg(digestAlg, asymmerticAlg)); + iDetails->insert(AdvSecSettingsCertificateModel::Algorithm, algorithm); + } + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::AppendSerialNumberL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::AppendSerialNumberL() +{ + if (iCertificate) { + TPtrC8 serialNumber = iCertificate->SerialNumber(); + iDetails->insert(AdvSecSettingsCertificateModel::SerialNumber, + HexFormattedStringL(serialNumber)); + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::AppendFingerprintsL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::AppendFingerprintsL() +{ + if (iCertificate) { + // Fingerprint (SHA1) + TPtrC8 sha1Fingerprint = iCertificate->Fingerprint(); + iDetails->insert(AdvSecSettingsCertificateModel::FingerprintSHA1, + HexFormattedStringL(sha1Fingerprint, KCertManUiTwoDigitsInBlock)); + + // Fingerprint (MD5) + CMD5* md5 = CMD5::NewL(); + CleanupStack::PushL(md5); + const TInt KRsaFingerprintLength = 20; + TBuf8 rsaFingerprint = md5->Hash(iCertificate->Encoding()); + iDetails->insert(AdvSecSettingsCertificateModel::FingerprintMD5, + HexFormattedStringL(rsaFingerprint, KCertManUiTwoDigitsInBlock)); + CleanupStack::PopAndDestroy(md5); + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::AppendPublicKeyL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::AppendPublicKeyL() +{ + if (iCertificate) { + TPtrC8 publicKey = iCertificate->PublicKey().KeyData(); + iDetails->insert(AdvSecSettingsCertificateModel::PublicKey, + HexFormattedStringL(publicKey, KCertManUiTwoDigitsInBlock)); + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertDetailsBuilder::AppendTrustedSitesL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertDetailsBuilder::AppendTrustedSitesL() +{ + if (iCertificate) { + CTrustSitesStore* trustedSitesStore = CTrustSitesStore::NewL(); + CleanupStack::PushL(trustedSitesStore); + + QStringList trustedSitesList; + RPointerArray trustedSitesArray; + CleanupResetAndDestroyPushL(trustedSitesArray); + trustedSitesStore->GetTrustedSitesL(iCertificate->Encoding(), trustedSitesArray); + TInt count = trustedSitesArray.Count(); + if (count) { + for (TInt index = 0; index < trustedSitesArray.Count(); index++) { + trustedSitesList.append(CopyStringL(*(trustedSitesArray[index]))); + } + // TODO: might be better to return trusted sites as a QStringList (in QVariant) + iDetails->insert(AdvSecSettingsCertificateModel::TrustedSites, + trustedSitesList.join(KTrustedSitesSeparator)); + } + CleanupStack::PopAndDestroy(2, trustedSitesStore); // trustedSitesArray, trustedSitesStore + } +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertificate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertificate.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Certificate class in advances security settings +* +*/ + +#include "advsecsettingscertificate.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CpAdvSecSettingsCertificate::CpAdvSecSettingsCertificate() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificate::AdvSecSettingsCertificate(QObject *parent) + : QObject(parent), mCertType(NotDefined), mLabel(), mModelIndex(0) +{ +} + +// --------------------------------------------------------------------------- +// CpAdvSecSettingsCertificate::~CpAdvSecSettingsCertificate() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificate::~AdvSecSettingsCertificate() +{ +} + +// --------------------------------------------------------------------------- +// CpAdvSecSettingsCertificate::label() +// --------------------------------------------------------------------------- +// +const QString &AdvSecSettingsCertificate::label() const +{ + return mLabel; +} + +// --------------------------------------------------------------------------- +// CpAdvSecSettingsCertificate::setLabel() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificate::setLabel(const QString &label) +{ + mLabel = label; +} + +// --------------------------------------------------------------------------- +// CpAdvSecSettingsCertificate::certType() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificate::CertificateType + AdvSecSettingsCertificate::certType() const +{ + return mCertType; +} + +// --------------------------------------------------------------------------- +// CpAdvSecSettingsCertificate::setCertType() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificate::setCertType(CertificateType type) +{ + mCertType = type; +} + +// --------------------------------------------------------------------------- +// CpAdvSecSettingsCertificate::modelIndex() +// --------------------------------------------------------------------------- +// +int AdvSecSettingsCertificate::modelIndex() const +{ + return mModelIndex; +} + +// --------------------------------------------------------------------------- +// CpAdvSecSettingsCertificate::setModelIndex() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificate::setModelIndex(int index) +{ + mModelIndex = index; +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertificatedetailview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertificatedetailview.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,221 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Certificate detail view in advanced security settings +* +*/ + +#include "advsecsettingscertificatedetailview.h" +#include "advsecsettingscertificatemodel.h" +#include "advsecsettingscertificate.h" +#include "advsecsettingscerttrustsettingsview.h" +#include +#include +#include +#include +#include +#include +#include + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateDetailView::AdvSecSettingsCertificateDetailView() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificateDetailView::AdvSecSettingsCertificateDetailView( + AdvSecSettingsCertificateModel &model, QGraphicsItem *parent) : + AdvSecSettingsViewBase(0, parent), mModel(model), mCertificate(0), + mDetails(), mViewLabel(0), mScrollArea(0), mDetailsText(0) +{ + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); + + mViewLabel = new HbGroupBox; + layout->addItem(mViewLabel); + + mScrollArea = new HbScrollArea; + mDetailsText = new HbLabel; + mDetailsText->setTextWrapping(Hb::TextWordWrap); + mScrollArea->setContentWidget(mDetailsText); + mScrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOn); + layout->addItem(mScrollArea); + + setLayout(layout); + + connect(&mModel, SIGNAL(getCertificateDetailsCompleted()), + this, SLOT(certificateDetailsCompleted())); + connect(&mModel, SIGNAL(deleteCertificateCompleted()), + this, SLOT(displayPreviousView())); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateDetailView::~AdvSecSettingsCertificateDetailView() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificateDetailView::~AdvSecSettingsCertificateDetailView() +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateDetailView::setCertificate() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateDetailView::setCertificate( + const AdvSecSettingsCertificate &cert) +{ + mCertificate = &cert; + + menu()->clearActions(); + if (cert.certType() == AdvSecSettingsCertificate::AuthorityCertificate) { + HbAction *trustSettingsAction = 0; + trustSettingsAction = new HbAction(hbTrId("txt_certificate_manager_menu_trust_settings")); + connect(trustSettingsAction, SIGNAL(triggered()), this, SLOT(showTrustSettings())); + menu()->addAction(trustSettingsAction); + } + if (mModel.isDeletable(cert)) { + HbAction *deleteAction = new HbAction(hbTrId("txt_common_menu_delete")); + connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteCertificate())); + menu()->addAction(deleteAction); + } + + mDetails.clear(); + mModel.getCertificateDetails(cert, mDetails); + + mDetailsText->clear(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateDetailView::certificateDetailsCompleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateDetailView::certificateDetailsCompleted() +{ + QString label; + QString details; + QTextStream stream(&details); + + bool isFirst(true); + QMapIterator iter(mDetails); + while (iter.hasNext()) { + if (!isFirst) { + stream << endl; + } + isFirst = false; + + int key = iter.next().key(); + switch (key) { + case AdvSecSettingsCertificateModel::Label: + label = iter.value(); + break; + case AdvSecSettingsCertificateModel::Issuer: + stream << hbTrId("txt_certificate_list_issuer") << endl + << iter.value() << endl; + break; + case AdvSecSettingsCertificateModel::Subject: + stream << hbTrId("txt_certificate_list_subject") << endl + << iter.value() << endl; + break; + case AdvSecSettingsCertificateModel::ValidFrom: + stream << hbTrId("txt_certificate_list_valid_from") << endl + << iter.value() << endl; + break; + case AdvSecSettingsCertificateModel::ValidTo: + stream << hbTrId("txt_certificate_list_valid_until") << endl + << iter.value() << endl; + break; + case AdvSecSettingsCertificateModel::Location: + // TODO: localized UI string needed + stream << tr("Location:") << endl << iter.value() << endl; + break; + case AdvSecSettingsCertificateModel::Format: + stream << hbTrId("txt_certificate_list_certificate_format") << endl + << iter.value() << endl; + break; + case AdvSecSettingsCertificateModel::KeyUsage: + // TODO: localized UI string needed + stream << tr("Key usage:") << endl << iter.value() << endl; + break; + case AdvSecSettingsCertificateModel::KeyLocation: + // TODO: localized UI string needed + stream << tr("Key location:") << endl << iter.value() << endl; + break; + case AdvSecSettingsCertificateModel::Algorithm: + stream << hbTrId("txt_certificate_list_algorithm") << endl + << iter.value() << endl; + break; + case AdvSecSettingsCertificateModel::SerialNumber: + stream << hbTrId("txt_certificate_list_serial_number") << endl + << iter.value() << endl; + break; + case AdvSecSettingsCertificateModel::FingerprintSHA1: + stream << hbTrId("txt_certificate_list_fingerprint_sha1") << endl + << iter.value() << endl; + break; + case AdvSecSettingsCertificateModel::FingerprintMD5: + stream << hbTrId("txt_certificate_list_fingerprint_md5") << endl + << iter.value() << endl; + break; + case AdvSecSettingsCertificateModel::PublicKey: + // TODO: localized UI string needed + stream << tr("Public key:") << endl << iter.value() << endl; + break; + case AdvSecSettingsCertificateModel::TrustedSites: + // TODO: localized UI string needed + stream << tr("Trusted sites:") << endl << iter.value() << endl; + break; + default: + break; + } + } + + mViewLabel->setHeading(label); + mDetailsText->setPlainText(details); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateDetailView::showTrustSettings() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateDetailView::showTrustSettings() +{ + Q_ASSERT(mCertificate != 0); + AdvSecSettingsCertTrustSettingsView *trustSettingsView = + new AdvSecSettingsCertTrustSettingsView(mModel); + trustSettingsView->setDeleteOnClose(true); + trustSettingsView->setCertificate(*mCertificate); + displayView(trustSettingsView); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateDetailView::deleteCertificate() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateDetailView::deleteCertificate() +{ + Q_ASSERT(mCertificate != 0); + // TODO: localized UI string needed + QString confirmText(tr("Delete %1?").arg(mCertificate->label())); + displayQuestionNote(confirmText, this, SLOT(deleteConfirmationAccepted())); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateDetailView::deleteConfirmationAccepted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateDetailView::deleteConfirmationAccepted() +{ + Q_ASSERT(mCertificate != 0); + mModel.deleteCertificate(*mCertificate); +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertificatelistview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertificatelistview.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,380 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Certificate list view in advanced security settings +* +*/ + +#include "advsecsettingscertificatelistview.h" +#include "advsecsettingscertificatemodel.h" +#include "advsecsettingscertificatedetailview.h" +#include "advsecsettingscerttrustsettingsview.h" +#include +#include +#include +#include +#include +#include +#include + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::AdvSecSettingsCertificateListView() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificateListView::AdvSecSettingsCertificateListView( + QGraphicsItem *parent) : AdvSecSettingsViewBase(0, parent), + mCertType(AdvSecSettingsCertificate::NotDefined), + mListWidget(0), mEmptyText(0), mRetrievingText(0), mStackedWidget(0), + mIsRetrieving(true), mModelCertificateList(), mDisplayedCertificates(), + mModel(0), mDetailView(), mTrustSettingsView(0), mCurrentCertificate(0) +{ + mModel = new AdvSecSettingsCertificateModel(this); + mModel->initialize(); + connect(mModel, SIGNAL(initializeCompleted()), + this, SLOT(readAllCertificatesFromModel())); + connect(mModel, SIGNAL(getCertificatesCompleted()), + this, SLOT(displayAllCertificatesReadFromModel())); + connect(mModel, SIGNAL(deleteCertificateCompleted()), + this, SLOT(refreshAfterCurrentCertRemoved())); + connect(mModel, SIGNAL(moveToPersonalCertificatesCompleted()), + this, SLOT(refreshAfterCurrentCertRemoved())); + connect(mModel, SIGNAL(moveToDeviceCertificatesCompleted()), + this, SLOT(refreshAfterCurrentCertRemoved())); + connect(mModel, SIGNAL(errorOccurred(int)), + this, SLOT(displayError(int))); + + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); + + // View title + mViewLabel = new HbGroupBox; + layout->addItem(mViewLabel); + + // Certificate list or empty text + mStackedWidget = new HbStackedWidget; + + mListWidget = new HbListWidget; + connect(mListWidget, SIGNAL(activated(QModelIndex)), + this, SLOT(openCertificate(QModelIndex))); + connect(mListWidget, SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), + this, SLOT(indicateLongPress(HbAbstractViewItem*, QPointF))); + mStackedWidget->addWidget(mListWidget); + + // TODO: localized UI string needed + mEmptyText = new HbLabel(tr("No certificates")); + mEmptyText->setAlignment(Qt::AlignCenter); + mStackedWidget->addWidget(mEmptyText); + + mRetrievingText = new HbLabel(tr("Retrieving...")); + mRetrievingText->setAlignment(Qt::AlignCenter); + mStackedWidget->addWidget(mRetrievingText); + + mStackedWidget->setCurrentWidget(mRetrievingText); + layout->addItem(mStackedWidget); + + setLayout(layout); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::~AdvSecSettingsCertificateListView() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificateListView::~AdvSecSettingsCertificateListView() +{ + clearModelCertificates(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::displayCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::displayCertificates( + AdvSecSettingsCertificate::CertificateType type) +{ + if (type != mCertType) { + mCertType = type; + switch (mCertType) { + case AdvSecSettingsCertificate::AuthorityCertificate: + mViewLabel->setHeading(hbTrId("txt_certificate_manager_subhead_authority_certific")); + break; + case AdvSecSettingsCertificate::TrustedSiteCertificate: + mViewLabel->setHeading(hbTrId("txt_certificate_manager_subhead_trusted_site_certi")); + break; + case AdvSecSettingsCertificate::PersonalCertificate: + mViewLabel->setHeading(hbTrId("txt_certificate_manager_subhead_personal_certifica")); + break; + case AdvSecSettingsCertificate::DeviceCertificate: + mViewLabel->setHeading(hbTrId("txt_certificate_manager_subhead_device_certificate")); + break; + default: + break; + } + } + refreshDisplayedCertificates(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::setCurrentIndex() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::setCurrentIndex(const QModelIndex& index) +{ + mListWidget->setCurrentIndex(index, QItemSelectionModel::SelectCurrent); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::indicateLongPress() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::indicateLongPress( + HbAbstractViewItem *item, const QPointF &position) +{ + Q_ASSERT(item != 0); + mCurrentCertificate = mDisplayedCertificates.at(item->modelIndex().row()); + + clearItemSpecificMenu(); + addItemSpecificMenuAction(hbTrId("txt_common_menu_open"), + this, SLOT(openCurrentCertificate())); + + switch (mCertType) { + case AdvSecSettingsCertificate::AuthorityCertificate: + addItemSpecificMenuAction(hbTrId("txt_certificate_manager_menu_trust_settings"), + this, SLOT(displayCurrentCertTrustSettings())); + break; + case AdvSecSettingsCertificate::TrustedSiteCertificate: + break; + case AdvSecSettingsCertificate::PersonalCertificate: + addItemSpecificMenuAction(hbTrId("txt_certificate_manager_menu_move_to_device_certif"), + this, SLOT(moveCurrentCertToDeviceCertificates())); + break; + case AdvSecSettingsCertificate::DeviceCertificate: + addItemSpecificMenuAction(hbTrId("txt_certificate_manager_menu_move_to_personal_cert"), + this, SLOT(moveCurrentCertToPersonalCertificates())); + break; + default: + break; + } + + Q_ASSERT(mCurrentCertificate != 0); + if (mModel->isDeletable(*mCurrentCertificate)) { + addItemSpecificMenuAction(hbTrId("txt_common_menu_delete"), + this, SLOT(deleteCurrentCertificate())); + } + + displayItemSpecificMenu(position); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::openCertificate() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::openCertificate(const QModelIndex& modelIndex) +{ + mCurrentCertificate = mDisplayedCertificates.at(modelIndex.row()); + openCurrentCertificate(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::openCurrentCertificate() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::openCurrentCertificate() +{ + if (!mDetailView) { + mDetailView = new AdvSecSettingsCertificateDetailView(*mModel, this); + } + Q_ASSERT(mCurrentCertificate != 0); + mDetailView->setCertificate(*mCurrentCertificate); + displayView(mDetailView); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::displayCurrentCertTrustSettings() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::displayCurrentCertTrustSettings() +{ + if (!mTrustSettingsView) { + mTrustSettingsView = new AdvSecSettingsCertTrustSettingsView(*mModel, this); + } + Q_ASSERT(mCurrentCertificate != 0); + mTrustSettingsView->setCertificate(*mCurrentCertificate); + displayView(mTrustSettingsView); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::deleteCurrentCertificate() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::deleteCurrentCertificate() +{ + Q_ASSERT(mCurrentCertificate != 0); + // TODO: localized UI string needed + QString confirmText(tr("Delete %1?").arg(mCurrentCertificate->label())); + displayQuestionNote(confirmText, this, SLOT(deleteConfirmationAccepted())); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::deleteConfirmationAccepted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::deleteConfirmationAccepted() +{ + Q_ASSERT(mCurrentCertificate != 0); + mModel->deleteCertificate(*mCurrentCertificate); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::moveCurrentCertToDeviceCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::moveCurrentCertToDeviceCertificates() +{ + Q_ASSERT(mCurrentCertificate != 0); + QString confirmText(hbTrId("txt_certificate_info_device_certificates_can_be_us")); + displayQuestionNote(confirmText, this, SLOT(moveToDeviceCertsConfirmationAccepted())); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::moveToDeviceCertsConfirmationAccepted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::moveToDeviceCertsConfirmationAccepted() +{ + Q_ASSERT(mCurrentCertificate != 0); + mModel->moveToDeviceCertificates(*mCurrentCertificate); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::moveCurrentCertToPersonalCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::moveCurrentCertToPersonalCertificates() +{ + Q_ASSERT(mCurrentCertificate != 0); + // TODO: localized UI string needed + QString confirmText(tr("Using personal certificates may require user confirmation. Continue?")); + displayQuestionNote(confirmText, this, SLOT(moveToPersonalCertsConfirmationAccepted())); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::moveToPersonalCertsConfirmationAccepted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::moveToPersonalCertsConfirmationAccepted() +{ + Q_ASSERT(mCurrentCertificate != 0); + mModel->moveToPersonalCertificates(*mCurrentCertificate); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::readAllCertificatesFromModel() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::readAllCertificatesFromModel() +{ + clearModelCertificates(); + mModel->getCertificates(mModelCertificateList); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::displayAllCertificatesReadFromModel() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::displayAllCertificatesReadFromModel() +{ + if (mCertType != AdvSecSettingsCertificate::NotDefined) { + mIsRetrieving = false; + refreshDisplayedCertificates(); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::clearModelCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::clearModelCertificates() +{ + if (!mModelCertificateList.isEmpty()) { + QMutableListIterator iter(mModelCertificateList); + while (iter.hasNext()) { + delete iter.next(); + } + mModelCertificateList.clear(); + } + mCurrentCertificate = 0; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::refreshDisplayedCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::refreshDisplayedCertificates() +{ + int currentRow = mListWidget->currentRow(); + mListWidget->clear(); + mDisplayedCertificates.clear(); + QListIterator iter(mModelCertificateList); + while (iter.hasNext()) { + AdvSecSettingsCertificate *cert = iter.next(); + if (cert->certType() == mCertType) { + mDisplayedCertificates.append(cert); + HbListWidgetItem *item = new HbListWidgetItem; + item->setText(cert->label()); + mListWidget->addItem(item); + } + } + if (mListWidget->count()) { + if (currentRow < mListWidget->count()) { + mListWidget->setCurrentRow(currentRow); + } + mStackedWidget->setCurrentWidget(mListWidget); + } else { + if (mIsRetrieving) { + mStackedWidget->setCurrentWidget(mRetrievingText); + } else { + mStackedWidget->setCurrentWidget(mEmptyText); + } + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateListView::refreshAfterCurrentCertRemoved() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateListView::refreshAfterCurrentCertRemoved() +{ + Q_ASSERT(mCurrentCertificate != 0); + + QString currentCertLabel = mCurrentCertificate->label(); + for (TInt row = 0; row < mListWidget->count(); row++) { + HbListWidgetItem *item = mListWidget->item(row); + if (item->text() == currentCertLabel) { + item = mListWidget->takeItem(row); + delete item; + } + } + if (mListWidget->count()) { + mStackedWidget->setCurrentWidget(mListWidget); + } else { + mStackedWidget->setCurrentWidget(mEmptyText); + } + + mDisplayedCertificates.removeAll(mCurrentCertificate); + mCurrentCertificate = 0; + + readAllCertificatesFromModel(); +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertificatemodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertificatemodel.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,251 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Advanced security settings certificate model +* +*/ + +#include "advsecsettingscertificatemodel.h" +#include + +#if defined(Q_OS_SYMBIAN) +#include "advsecsettingscertificatemodel_symbian_p.h" +#else +#include "advsecsettingscertificatemodel_stub_p.h" +#endif + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::AdvSecSettingsCertificateModel() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificateModel::AdvSecSettingsCertificateModel(QObject *parent) : + QObject(parent), d_ptr(0) +{ + d_ptr = new AdvSecSettingsCertificateModelPrivate(this); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::~AdvSecSettingsCertificateModel() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificateModel::~AdvSecSettingsCertificateModel() +{ + delete d_ptr; + d_ptr = 0; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::initialize() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::initialize() +{ + if (d_ptr) { + d_ptr->initialize(); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::getCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::getCertificates( + QList &certList) +{ + if (d_ptr) { + d_ptr->getCertificates(certList); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::getCertificateDetails() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::getCertificateDetails( + const AdvSecSettingsCertificate &cert, QMap &details) +{ + if (d_ptr) { + d_ptr->getCertificateDetails(cert, details); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::isDeletable() +// --------------------------------------------------------------------------- +// +bool AdvSecSettingsCertificateModel::isDeletable( + const AdvSecSettingsCertificate &cert) const +{ + if (d_ptr) { + return d_ptr->isDeletable(cert); + } + return false; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::deleteCertificate() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::deleteCertificate( + const AdvSecSettingsCertificate &cert) +{ + if (d_ptr) { + d_ptr->deleteCertificate(cert); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::getTrustSettings() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::getTrustSettings( + const AdvSecSettingsCertificate &cert, QMap &usageIdAndTrust) +{ + if (d_ptr) { + d_ptr->getTrustSettings(cert, usageIdAndTrust); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::setTrustSettings() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::setTrustSettings( + const AdvSecSettingsCertificate &cert, + const QMap &usageIdAndTrust) +{ + if (d_ptr) { + d_ptr->setTrustSettings(cert, usageIdAndTrust); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::getCertificateUsageNames() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::getCertificateUsageNames( + QMap &usageIdAndName) +{ + if (d_ptr) { + d_ptr->getCertificateUsageNames(usageIdAndName); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::moveToPersonalCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::moveToPersonalCertificates( + const AdvSecSettingsCertificate &cert) +{ + if (d_ptr) { + d_ptr->moveToPersonalCertificates(cert); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::moveToDeviceCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::moveToDeviceCertificates( + const AdvSecSettingsCertificate &cert) +{ + if (d_ptr) { + d_ptr->moveToDeviceCertificates(cert); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::handleInitializeCompleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::handleInitializeCompleted() +{ + emit initializeCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::handleGetCertificatesCompleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::handleGetCertificatesCompleted() +{ + emit getCertificatesCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::handleGetCertificateDetailsCompleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::handleGetCertificateDetailsCompleted() +{ + emit getCertificateDetailsCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::handleDeleteCertificateCompleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::handleDeleteCertificateCompleted() +{ + emit deleteCertificateCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::handleGetTrustSettingsCompleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::handleGetTrustSettingsCompleted() +{ + emit getTrustSettingsCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::handleSetTrustSettingsCompleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::handleSetTrustSettingsCompleted() +{ + emit setTrustSettingsCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::handleMoveToPersonalCertificateCompleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::handleMoveToPersonalCertificateCompleted() +{ + emit moveToPersonalCertificatesCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::handleMoveToDeviceCertificatesCompleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::handleMoveToDeviceCertificatesCompleted() +{ + emit moveToDeviceCertificatesCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModel::handleError() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModel::handleError(int error) +{ + emit errorOccurred(error); +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertificatemodel_stub_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertificatemodel_stub_p.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Platform specific private certificate handling model +* +*/ + + +#include "advsecsettingscertificatemodel_stub_p.h" +#include "advsecsettingscertificate.h" +#include + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::AdvSecSettingsCertificateModelPrivate() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificateModelPrivate::AdvSecSettingsCertificateModelPrivate( + AdvSecSettingsCertificateModel *q) : QObject(0), q_ptr(q) +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::~AdvSecSettingsCertificateModelPrivate() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificateModelPrivate::~AdvSecSettingsCertificateModelPrivate() +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::initialize() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::initialize() +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::getCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::getCertificates( + QList &/*certList*/) +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::getCertificateDetails() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::getCertificateDetails( + const AdvSecSettingsCertificate &/*cert*/, + QMap& /*details*/) +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::isDeletable() +// --------------------------------------------------------------------------- +// +bool AdvSecSettingsCertificateModelPrivate::isDeletable( + const AdvSecSettingsCertificate &/*cert*/) const +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::deleteCertificate() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::deleteCertificate( + const AdvSecSettingsCertificate &/*cert*/) +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::getTrustSettings() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::getTrustSettings( + const AdvSecSettingsCertificate &/*cert*/, + QMap &/*usageIdAndTrust*/) +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::setTrustSettings() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::setTrustSettings( + const AdvSecSettingsCertificate &/*cert*/, + const QMap &/*usageIdAndTrust*/) +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::getCertificateUsageNames() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::getCertificateUsageNames( + QMap &/*usageIdAndName*/) +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::moveToPersonalCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::moveToPersonalCertificates( + const AdvSecSettingsCertificate &/*cert*/) +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::moveToDeviceCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::moveToDeviceCertificates( + const AdvSecSettingsCertificate &/*cert*/) +{ +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertificatemodel_symbian_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertificatemodel_symbian_p.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,539 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Symbian specific advanced security settings certificate model +* +*/ + +#include "advsecsettingscertificatemodel_symbian_p.h" +#include "advsecsettingscertificatemodel.h" +#include "advsecsettingscertificate.h" +#include "advsecsettingstrustedcertusageuids.h" +#include "advsecsettingsstoreuids.h" +#include "advsecsettingscertlistbuilder_symbian.h" +#include "advsecsettingscertdetailsbuilder_symbian.h" +#include "advsecsettingscertmover_symbian.h" +#include // CCTCertInfo +#include // CCertificateAppInfoManager +#include + +_LIT(KTranslationFile, "z:\\resource\\qt\\translations"); +_LIT(KTranslationPath, "certificate_manager_"); + +_LIT(KLocNativeInstallationUsage, "txt_certificate_manager_formlabel_symbian_instal"); +_LIT(KLocJavaInstallationUsage, "txt_certificate_manager_formlabel_java_installing"); +_LIT(KLocWidgetInstallationUsage, "txt_certificate_manager_formlabel_widget_installat"); +_LIT(KLocInternetUsage, "txt_certificate_manager_formlabel_internet"); +_LIT(KLocOcspUsage, "txt_certificate_manager_formlabel_online_certifica"); +_LIT(KLocVPNUsage, "txt_certificate_manager_formlabel_vpn"); + +#define TRAP_HANDLE_AND_RETURN_IF_ERROR(_f) \ +{ \ + TInt __thr_error = KErrNone; \ + TRAP(__thr_error, _f); \ + if (__thr_error) { \ + q_ptr->handleError(__thr_error); \ + return; \ + } \ +} + + +// ======== LOCAL FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CopyStringL() +// --------------------------------------------------------------------------- +// +QString CopyStringL(const TDesC16 &aDes16) +{ + QString string; + QT_TRYCATCH_LEAVING(string = QString::fromUtf16(aDes16.Ptr(), aDes16.Length())); + return string; +} + +// --------------------------------------------------------------------------- +// CopyStringL() +// --------------------------------------------------------------------------- +// +QString CopyStringL(const TDesC8 &aDes8) +{ + QString string; + QT_TRYCATCH_LEAVING(string = QString::fromUtf8( + reinterpret_cast(aDes8.Ptr()), aDes8.Length())); + return string; +} + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::AdvSecSettingsCertificateModelPrivate() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificateModelPrivate::AdvSecSettingsCertificateModelPrivate( + AdvSecSettingsCertificateModel *q) : CActive(CActive::EPriorityLow), q_ptr(q), + iState(ENotInitialized) +{ + CActiveScheduler::Add(this); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::~AdvSecSettingsCertificateModelPrivate() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificateModelPrivate::~AdvSecSettingsCertificateModelPrivate() +{ + Cancel(); + + delete iMover; + delete iCertAppInfoManager; + delete iCertStore; + iFs.Close(); + + iCertInfo = NULL; + iCertInfoArray.Close(); + delete iCertListBuilder; + delete iDetailsBuilder; + + iTrustedUids = NULL; + iApplications.Reset(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::initialize() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::initialize() +{ + if (!IsActive() && (iState == ENotInitialized)) { + TRAP_HANDLE_AND_RETURN_IF_ERROR(ConstructL()); + iCertStore->Initialize(iStatus); + iState = EInitializing; + SetActive(); + } else { + q_ptr->handleError(KErrAlreadyExists); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::getCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::getCertificates( + QList &certList) +{ + if (!IsActive() && (iState == EIdle)) { + if (!iCertListBuilder) { + TRAP_HANDLE_AND_RETURN_IF_ERROR(iCertListBuilder = + CAdvSecSettingsCertListBuilder::NewL(iFs, *iCertStore)); + } + iCertListBuilder->GetCertificateList(certList, iCertInfoArray, iStatus); + iState = EGettingCertificatesList; + SetActive(); + } else { + q_ptr->handleError(KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::getCertificateDetails() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::getCertificateDetails( + const AdvSecSettingsCertificate &cert, QMap &details) +{ + if (!IsActive() && (iState == EIdle)) { + iCertInfo = CertificateInfo(cert); + if (iCertInfo) { + if (!iDetailsBuilder) { + TRAP_HANDLE_AND_RETURN_IF_ERROR(iDetailsBuilder = + CAdvSecSettingsCertDetailsBuilder::NewL(iFs, *iCertStore)); + } + TRAP_HANDLE_AND_RETURN_IF_ERROR( + iDetailsBuilder->GetDetailsL(*iCertInfo, details, iStatus)); + iState = EBuildingCertificateDetails; + SetActive(); + } + } else { + q_ptr->handleError(KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::isDeletable() +// --------------------------------------------------------------------------- +// +bool AdvSecSettingsCertificateModelPrivate::isDeletable( + const AdvSecSettingsCertificate &cert) const +{ + const CCTCertInfo* certInfo = CertificateInfo(cert); + if (certInfo) { + return certInfo->IsDeletable(); + } + return false; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::deleteCertificate() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::deleteCertificate( + const AdvSecSettingsCertificate &cert) +{ + if (!IsActive() && (iState == EIdle)) { + iCertInfo = CertificateInfo(cert); + if (iCertInfo) { + iCertStore->Remove(*iCertInfo, iStatus); + iState = EDeletingCertificate; + SetActive(); + } + } else { + q_ptr->handleError(KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::getTrustSettings() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::getTrustSettings( + const AdvSecSettingsCertificate &cert, QMap &usageIdAndTrust) +{ + if (!IsActive() && (iState == EIdle)) { + iCertInfo = CertificateInfo(cert); + if (iCertInfo) { + iTrustedUids = &usageIdAndTrust; + iApplications.Reset(); + iCertStore->Applications(*iCertInfo, iApplications, iStatus); + iState = EReadingApplications; + SetActive(); + } + } else { + q_ptr->handleError(KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::setTrustSettings() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::setTrustSettings( + const AdvSecSettingsCertificate &cert, const QMap &usageIdAndTrust) +{ + if (!IsActive() && (iState == EIdle)) { + iCertInfo = CertificateInfo(cert); + if (iCertInfo) { + iApplications.Reset(); + QMapIterator usageIter(usageIdAndTrust); + while (usageIter.hasNext()) { + usageIter.next(); + if (usageIter.value()) { + iApplications.Append(TUid::Uid(usageIter.key())); + } + } + + iCertStore->SetApplicability(*iCertInfo, iApplications, iStatus); + iState = EWritingApplications; + SetActive(); + } + } else { + q_ptr->handleError(KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::getCertificateUsageNames() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::getCertificateUsageNames( + QMap &usageIdAndName) +{ + usageIdAndName.clear(); + QT_TRAP_THROWING(DoGetCertificateUsageNamesL(usageIdAndName)); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::moveToPersonalCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::moveToPersonalCertificates( + const AdvSecSettingsCertificate &cert) +{ + if (!IsActive() && (iState == EIdle)) { + iCertInfo = CertificateInfo(cert); + if (iCertInfo) { + if (!iMover) { + TRAP_HANDLE_AND_RETURN_IF_ERROR(iMover = + CAdvSecSettingsCertMover::NewL(iFs)); + } + // personal certificate store == file certificate store + iMover->Move(*iCertInfo, KAdvSecSettingsDeviceCertStore, + KAdvSecSettingsFileCertStore, iStatus); + iState = EMovingCertificateToPersonalStore; + SetActive(); + } + } else { + q_ptr->handleError(KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::moveToDeviceCertificates() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::moveToDeviceCertificates( + const AdvSecSettingsCertificate &cert) +{ + if (!IsActive() && (iState == EIdle)) { + iCertInfo = CertificateInfo(cert); + if (iCertInfo) { + if (!iMover) { + TRAP_HANDLE_AND_RETURN_IF_ERROR(iMover = + CAdvSecSettingsCertMover::NewL(iFs)); + } + iMover->Move(*iCertInfo, KAdvSecSettingsFileCertStore, + KAdvSecSettingsDeviceCertStore, iStatus); + iState = EMovingCertificateToDeviceStore; + SetActive(); + } + } else { + q_ptr->handleError(KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::DoCancel() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::DoCancel() +{ + switch (iState) { + case EInitializing: + iCertStore->CancelInitialize(); + break; + case EGettingCertificatesList: + delete iCertListBuilder; + iCertListBuilder = NULL; + break; + case EBuildingCertificateDetails: + delete iDetailsBuilder; + iDetailsBuilder = NULL; + break; + case EDeletingCertificate: + iCertStore->CancelRemove(); + break; + case EReadingApplications: + iCertStore->CancelApplications(); + break; + case EWritingApplications: + iCertStore->CancelSetApplicability(); + break; + case EMovingCertificateToPersonalStore: + case EMovingCertificateToDeviceStore: + delete iMover; + iMover = NULL; + break; + default: + break; + } + if (iState == EInitializing) { + iState = ENotInitialized; + } else { + iState = EIdle; + } + q_ptr->handleError(KErrCancel); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::RunL() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::RunL() +{ + User::LeaveIfError(iStatus.Int()); + + switch (iState) { + case EInitializing: + iState = EIdle; + q_ptr->handleInitializeCompleted(); + break; + case EGettingCertificatesList: + iState = EIdle; + q_ptr->handleGetCertificatesCompleted(); + break; + case EBuildingCertificateDetails: + iState = EIdle; + q_ptr->handleGetCertificateDetailsCompleted(); + break; + case EDeletingCertificate: + iState = EIdle; + q_ptr->handleDeleteCertificateCompleted(); + break; + case EReadingApplications: + ReturnTrustSettingsDetails(); + iState = EIdle; + q_ptr->handleGetTrustSettingsCompleted(); + break; + case EWritingApplications: + iState = EIdle; + q_ptr->handleSetTrustSettingsCompleted(); + break; + case EMovingCertificateToPersonalStore: + iState = EIdle; + q_ptr->handleMoveToPersonalCertificateCompleted(); + break; + case EMovingCertificateToDeviceStore: + iState = EIdle; + q_ptr->handleMoveToDeviceCertificatesCompleted(); + break; + default: + ASSERT(EFalse); + break; + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::RunError() +// --------------------------------------------------------------------------- +// +TInt AdvSecSettingsCertificateModelPrivate::RunError(TInt aError) +{ + if (iState == EInitializing) { + iState = ENotInitialized; + } else { + iState = EIdle; + } + q_ptr->handleError(aError); + return KErrNone; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::ConstructL() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::ConstructL() +{ + User::LeaveIfError(iFs.Connect()); + const TBool KWriteMode = ETrue; + iCertStore = CUnifiedCertStore::NewL(iFs, KWriteMode); + iCertAppInfoManager = CCertificateAppInfoManager::NewL(); + if (!HbTextResolverSymbian::Init(KTranslationFile, KTranslationPath)) { + // TODO: text resolver initialisation failed + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::ReturnTrustSettingsDetails() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::ReturnTrustSettingsDetails() +{ + if (iTrustedUids && iCertInfo) { + iTrustedUids->clear(); + + // Set applicable trusted usages for different kinds of certs. + TUid tokenType(iCertInfo->Token().TokenType().Type()); + if (tokenType.iUid == KAdvSecSettingsSWICertStore) { + iTrustedUids->insert(KAdvSecSettingsTrustedUsageSwInstallNativeSis, false); + iTrustedUids->insert(KAdvSecSettingsTrustedUsageSwInstallSisOcsp, false); + } else if (tokenType.iUid == KAdvSecSettingsMidpCertStore) { + iTrustedUids->insert(KAdvSecSettingsTrustedUsageSwInstallJava, false); + } else { + const RArray &apps(iCertAppInfoManager->Applications()); + for (TInt index = 0; index < apps.Count(); ++index) { + const TCertificateAppInfo &appInfo = apps[index]; + int usageId = appInfo.Id().iUid; + iTrustedUids->insert(usageId, false); + } + } + + // Set trusted usages, usually this just replaces some of the values set above. + TInt count = iApplications.Count(); + for (TInt index = 0; index < count; ++index ) { + iTrustedUids->insert(iApplications[index].iUid, true); + } + + // Native and Java installation use certs only from SWI and MIDP cert stores. + // Hence, native and Java install usages are not displayed for certs in file + // cert store. + if (tokenType.iUid == KAdvSecSettingsFileCertStore) { + iTrustedUids->remove(KAdvSecSettingsTrustedUsageSwInstallNativeSis); + iTrustedUids->remove(KAdvSecSettingsTrustedUsageSwInstallJava); + } + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::DoGetCertificateUsageNamesL() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertificateModelPrivate::DoGetCertificateUsageNamesL( + QMap &usageIdAndName) +{ + // Pre-defined localized usage names + HBufC* usageName = HbTextResolverSymbian::LoadLC(KLocNativeInstallationUsage); + usageIdAndName[KAdvSecSettingsTrustedUsageSwInstallNativeSis] = CopyStringL(*usageName); + CleanupStack::PopAndDestroy(usageName); + + usageName = HbTextResolverSymbian::LoadLC(KLocJavaInstallationUsage); + usageIdAndName[KAdvSecSettingsTrustedUsageSwInstallJava] = CopyStringL(*usageName); + CleanupStack::PopAndDestroy(usageName); + + usageName = HbTextResolverSymbian::LoadLC(KLocWidgetInstallationUsage); + usageIdAndName[KAdvSecSettingsTrustedUsageSwInstallWidget] = CopyStringL(*usageName); + CleanupStack::PopAndDestroy(usageName); + + usageName = HbTextResolverSymbian::LoadLC(KLocInternetUsage); + usageIdAndName[KAdvSecSettingsTrustedUsageInternet] = CopyStringL(*usageName); + CleanupStack::PopAndDestroy(usageName); + + usageName = HbTextResolverSymbian::LoadLC(KLocOcspUsage); + usageIdAndName[KAdvSecSettingsTrustedUsageSwInstallSisOcsp] = CopyStringL(*usageName); + CleanupStack::PopAndDestroy(usageName); + + usageName = HbTextResolverSymbian::LoadLC(KLocVPNUsage); + usageIdAndName[KAdvSecSettingsTrustedUsageVPN] = CopyStringL(*usageName); + CleanupStack::PopAndDestroy(usageName); + + // TODO: localized UI string needed + usageIdAndName[KAdvSecSettingsTrustedUsageWap] = QString("Wap"); + + // Possible additional usage names defined in system databases + if (iCertAppInfoManager) { + const RArray &apps(iCertAppInfoManager->Applications()); + for(TInt index = 0; index < apps.Count(); ++index) { + const TCertificateAppInfo &appInfo = apps[index]; + + int usageId = appInfo.Id().iUid; + if (!usageIdAndName.contains(usageId)) { + QString usageName = CopyStringL(appInfo.Name()); + usageIdAndName.insert(usageId, usageName); + } + } + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertificateModelPrivate::CertificateInfo() +// --------------------------------------------------------------------------- +// +const CCTCertInfo *AdvSecSettingsCertificateModelPrivate::CertificateInfo( + const AdvSecSettingsCertificate &cert) const +{ + TInt index = cert.modelIndex(); + if (index >= 0 && index < iCertInfoArray.Count()) { + return iCertInfoArray[index]; + } + return NULL; +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertlistbuilder_symbian.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertlistbuilder_symbian.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,344 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to construct certificate list +* +*/ + +#include "advsecsettingscertlistbuilder_symbian.h" +#include "advsecsettingslabeledcertinfo_symbian.h" +#include "advsecsettingsstoreuids.h" // KAdvSecSettingsDeviceCertStore +#include // CX509Certificate +#include // CCertAttributeFilter +#include // X509CertNameParser::PrimaryAndSecondaryNameL +#include // std::auto_ptr + +_LIT(KNameSeparator, " "); + +// implemented in advsecsettingssecuritymodulemodel_symbian_p.cpp +QString CopyStringL(const TDesC16 &aDes16); + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::NewL() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsCertListBuilder *CAdvSecSettingsCertListBuilder::NewL( + RFs &aFs, CUnifiedCertStore &aCertStore) +{ + CAdvSecSettingsCertListBuilder *self = new(ELeave) CAdvSecSettingsCertListBuilder( + aFs, aCertStore); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::~CAdvSecSettingsCertListBuilder() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsCertListBuilder::~CAdvSecSettingsCertListBuilder() +{ + Cancel(); + iLabeledCertInfos.ResetAndDestroy(); + delete iCertificate; + delete iCertAttributeFilter; + iCertInfoArray.Close(); + iCertList = NULL; + iClientInfoArray = NULL; + iClientStatus = NULL; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::GetCertificateList() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertListBuilder::GetCertificateList( + QList &certList, + RMPointerArray &aCertInfoArray, + TRequestStatus &aStatus) +{ + aStatus = KRequestPending; + if (!IsActive() && (iState == EIdle)) { + iClientStatus = &aStatus; + iCertList = &certList; + iClientInfoArray = &aCertInfoArray; + + iCertInfoArray.Close(); + ResetCertAttributeFilter(); + iCertStore.List(iCertInfoArray, *iCertAttributeFilter, iStatus); + iState = EListingCerts; + SetActive(); + } else { + TRequestStatus *status = &aStatus; + User::RequestComplete(status, KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::DoCancel() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertListBuilder::DoCancel() +{ + switch (iState) { + case EListingCerts: + iCertStore.CancelList(); + break; + case ERetrievingCert: + iCertStore.CancelRetrieve(); + break; + case EProcessingCert: + // nothing to do + break; + default: + break; + } + User::RequestComplete(iClientStatus, KErrCancel); + iClientStatus = NULL; + iState = EIdle; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::RunL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertListBuilder::RunL() +{ + User::LeaveIfError(iStatus.Int()); + switch (iState) { + case EListingCerts: + ProcessFirstCertificateL(); + break; + case ERetrievingCert: + ProcessNextCertificateL(); + break; + case EProcessingCert: + ProcessNextCertificateL(); + break; + default: + ASSERT(EFalse); + break; + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::RunError() +// --------------------------------------------------------------------------- +// +TInt CAdvSecSettingsCertListBuilder::RunError(TInt aError) +{ + User::RequestComplete(iClientStatus, aError); + iClientStatus = NULL; + iState = EIdle; + return KErrNone; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::CAdvSecSettingsCertListBuilder() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsCertListBuilder::CAdvSecSettingsCertListBuilder(RFs &aFs, + CUnifiedCertStore &aCertStore) : CActive(CActive::EPriorityLow), + iFs(aFs), iCertStore(aCertStore), iCertPtr(0,0) +{ + CActiveScheduler::Add(this); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::ConstructL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertListBuilder::ConstructL() +{ + iCertAttributeFilter = CCertAttributeFilter::NewL(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::ResetCertAttributeFilter() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertListBuilder::ResetCertAttributeFilter() +{ + ASSERT(iCertAttributeFilter); + iCertAttributeFilter->iLabelIsSet = EFalse; + iCertAttributeFilter->iUidIsSet = EFalse; + iCertAttributeFilter->iFormatIsSet = EFalse; + iCertAttributeFilter->iKeyUsage = EX509UsageAll; + iCertAttributeFilter->iOwnerTypeIsSet = EFalse; + iCertAttributeFilter->iSubjectKeyIdIsSet = EFalse; + iCertAttributeFilter->iIssuerKeyIdIsSet = EFalse; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::ProcessFirstCertificateL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertListBuilder::ProcessFirstCertificateL() +{ + iCertInfoIndex = 0; + StartProcessingCertificateL(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::ProcessNextCertificateL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertListBuilder::ProcessNextCertificateL() +{ + CompleteProcessingCertificateL(); + ++iCertInfoIndex; + StartProcessingCertificateL(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::StartProcessingCertificateL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertListBuilder::StartProcessingCertificateL() +{ + if (iCertInfoIndex < iCertInfoArray.Count()) { + CCTCertInfo *certInfo = iCertInfoArray[iCertInfoIndex]; + + if ((certInfo->CertificateOwnerType() == ECACertificate) && + (certInfo->CertificateFormat() == EX509Certificate)) { + // Have to retrieve the cert to add parts of subject + // to certificate label. For example, all Java certs + // have the same label by default. + if (iCertificate) { + delete iCertificate; + iCertificate = NULL; + } + iCertificate = HBufC8::NewL(certInfo->Size()); + iCertPtr.Set(iCertificate->Des()); + iCertStore.Retrieve(*certInfo, iCertPtr, iStatus); + iState = ERetrievingCert; + SetActive(); + } else { + // Certificate label can be used as such. + TRequestStatus *status = &iStatus; + User::RequestComplete(status, KErrNone); + iState = EProcessingCert; + SetActive(); + } + + } else { + ReturnCertificateListL(); + + User::RequestComplete(iClientStatus, KErrNone); + iClientStatus = NULL; + iState = EIdle; + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::CompleteProcessingCertificateL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertListBuilder::CompleteProcessingCertificateL() +{ + ASSERT(iCertInfoIndex < iCertInfoArray.Count()); + CCTCertInfo *certInfo = iCertInfoArray[iCertInfoIndex]; + + CAdvSecSettingsLabeledCertInfo *labeledCertInfo = + new(ELeave) CAdvSecSettingsLabeledCertInfo(*certInfo); + CleanupStack::PushL(labeledCertInfo); + labeledCertInfo->SetLabelL(certInfo->Label()); + + if (iCertificate) { + CX509Certificate *cert = CX509Certificate::NewL(*iCertificate); + CleanupStack::PushL(cert); + + HBufC *primaryName = NULL; + HBufC *secondaryName = NULL; + TInt err = X509CertNameParser::PrimaryAndSecondaryNameL(*cert, + primaryName, secondaryName, certInfo->Label()); + if (!err) { + if (primaryName && primaryName->Length()) { + labeledCertInfo->AppendLabelL(KNameSeparator, *primaryName); + } else { + if (secondaryName && secondaryName->Length()) { + labeledCertInfo->AppendLabelL(KNameSeparator, *secondaryName); + } + } + } + + CleanupStack::PopAndDestroy(cert); + delete iCertificate; + iCertificate = NULL; + } + + iLabeledCertInfos.AppendL(labeledCertInfo); + CleanupStack::Pop(labeledCertInfo); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::ReturnCertificateListL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertListBuilder::ReturnCertificateListL() +{ + TLinearOrder order( CAdvSecSettingsLabeledCertInfo::Compare ); + iLabeledCertInfos.Sort( order ); + + iCertList->clear(); + iClientInfoArray->Reset(); + TInt count = iLabeledCertInfos.Count(); + for (TInt index = 0; index < count; index++) { + const CCTCertInfo &certInfo = iLabeledCertInfos[index]->CertInfo(); + iClientInfoArray->AppendL(&certInfo); + + std::auto_ptr cert(new(ELeave) AdvSecSettingsCertificate); + cert->setModelIndex(index); + cert->setCertType(CertType(certInfo)); + cert->setLabel(CopyStringL(iLabeledCertInfos[index]->Label())); + iCertList->append(cert.release()); + } + iLabeledCertInfos.ResetAndDestroy(); + iCertInfoArray.Reset(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertListBuilder::CertType() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertificate::CertificateType CAdvSecSettingsCertListBuilder::CertType( + const CCTCertInfo &aCertInfo) +{ + AdvSecSettingsCertificate::CertificateType type = + AdvSecSettingsCertificate::NotDefined; + TUid storeType; + switch (aCertInfo.CertificateOwnerType()) { + case ECACertificate: + type = AdvSecSettingsCertificate::AuthorityCertificate; + break; + case EUserCertificate: + storeType = aCertInfo.Handle().iTokenHandle.iTokenTypeUid; + if (storeType.iUid == KAdvSecSettingsDeviceCertStore) { + type = AdvSecSettingsCertificate::DeviceCertificate; + } else { + type = AdvSecSettingsCertificate::PersonalCertificate; + } + break; + case EPeerCertificate: + type = AdvSecSettingsCertificate::TrustedSiteCertificate; + break; + default: + break; + } + return type; +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertmover_symbian.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingscertmover_symbian.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,578 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to move certificates +* +*/ + +#include "advsecsettingscertmover_symbian.h" +#include "advsecsettingsstoreuids.h" +#include // CUnifiedCertStore +#include // CUnifiedKeyStore +#include // CCTCertInfo +#include // MCTWritableCertStore +#include // MCTKeyStoreManager + +const TInt KMaxBufferLength = 0x3000; // 12kB, for keys and certificates +_LIT_SECURITY_POLICY_C1( KKeyStoreUsePolicy, ECapabilityReadUserData ); + +// TODO: replace with proper logging +#ifdef _DEBUG +#define TRACE(x) RDebug::Printf(x) +#define TRACE1(x, y) RDebug::Printf((x), (y)) +#define TRACE2(x, y, z) RDebug::Printf((x), (y), (z)) +#else +#define TRACE(x) +#define TRACE1(x, y) +#define TRACE2(x, y, z) +#endif + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::NewL() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsCertMover *CAdvSecSettingsCertMover::NewL(RFs &aFs) +{ + TRACE("CAdvSecSettingsCertMover::NewL()"); + CAdvSecSettingsCertMover* self = new( ELeave ) CAdvSecSettingsCertMover(aFs); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::~CAdvSecSettingsCertMover() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsCertMover::~CAdvSecSettingsCertMover() +{ + TRACE("CAdvSecSettingsCertMover::~CAdvSecSettingsCertMover()"); + Cancel(); + delete iCertStore; + iTargetCertStore = NULL; + delete iCertFilter; + iCerts.Close(); + + delete iKeyStore; + iSourceKeyStore = NULL; + iTargetKeyStore = NULL; + delete iKeyFilter; + iKeys.Close(); + if (iSavedKeyInfo) { + iSavedKeyInfo->Release(); + } + + delete iDataBuffer; + iClientStatus = NULL; + iCertInfo = NULL; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::Move() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::Move(const CCTCertInfo &aCert, + TInt aSourceCertStoreTokenId, TInt aTargetCertStoreTokenId, + TRequestStatus &aStatus) +{ + TRACE("CAdvSecSettingsCertMover::Move()"); + aStatus = KRequestPending; + if (!iClientStatus) { + iClientStatus = &aStatus; + + iCertInfo = &aCert; + iSourceCertStoreTokenId = aSourceCertStoreTokenId; + iTargetCertStoreTokenId = aTargetCertStoreTokenId; + + if (iState <= EIdle) { + // Start move operation if initializations are complete. + if (iState == EIdle) { + TRAPD(err, StartMoveOperationL()); + if (err) { + TRACE1("CAdvSecSettingsCertMover::Move(), error %d", err); + User::RequestComplete(iClientStatus, err); + iClientStatus = NULL; + } + } + // If initializations are not complete yet, then moving + // starts in RunL() after initializations are completed. + } else { + // Possibly initializations have failed. + TRACE("CAdvSecSettingsCertMover::Move(), RequestComplete KErrGeneral"); + User::RequestComplete(iClientStatus, KErrGeneral); + iClientStatus = NULL; + } + } else { + TRACE("CAdvSecSettingsCertMover::Move(), RequestComplete KErrInUse"); + TRequestStatus* status = &aStatus; + User::RequestComplete(status, KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::DoCancel() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::DoCancel() +{ + TRACE("CAdvSecSettingsCertMover::DoCancel()"); + switch (iState) { + case EInitializingCertStore: + iCertStore->CancelInitialize(); + iState = ENotInitialized; + break; + case EInitializingKeyStore: + iKeyStore->CancelInitialize(); + iState = ENotInitialized; + break; + case EMovingKeyListingKeys: + iKeyStore->CancelList(); + iState = EIdle; + break; + case EMovingKeyExportingKeys: + iSourceKeyStore->CancelExportKey(); + iState = EIdle; + break; + case EMovingKeyImportingKeys: + iTargetKeyStore->CancelImportKey(); + iState = EIdle; + break; + case EMovingKeyDeletingOriginal: + iSourceKeyStore->CancelDeleteKey(); + iState = EIdle; + break; + case EMovingCertListingCerts: + iCertStore->CancelList(); + iState = EIdle; + break; + case EMovingCertRetrievingCerts: + iSourceCertStore->CancelRetrieve(); + iState = EIdle; + break; + case EMovingCertAddingCerts: + iTargetCertStore->CancelAdd(); + iState = EIdle; + break; + case EMovingCertDeletingOriginal: + iSourceCertStore->CancelRemove(); + iState = EIdle; + break; + default: + break; + } + + if (iClientStatus) { + TRACE("CAdvSecSettingsCertMover::DoCancel(), RequestComplete KErrCancel"); + User::RequestComplete(iClientStatus, KErrCancel); + iClientStatus = NULL; + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::RunL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::RunL() +{ + TRACE2("CAdvSecSettingsCertMover::RunL(), iState=%d, iStatus.Int()=%d", iState, iStatus.Int()); + User::LeaveIfError(iStatus.Int()); + + switch (iState) { + case EInitializingCertStore: + iKeyStore->Initialize(iStatus); + iState = EInitializingKeyStore; + SetActive(); + break; + case EInitializingKeyStore: + iState = EIdle; + if (iClientStatus) { + StartMoveOperationL(); + } + break; + case EMovingKeyListingKeys: + ExportFirstKeyL(); + break; + case EMovingKeyExportingKeys: + SaveExportedKeyL(); + break; + case EMovingKeyImportingKeys: + DeleteOriginalKeyL(); + break; + case EMovingKeyDeletingOriginal: + ExportNextKeyL(); + break; + case EMovingCertListingCerts: + RetrieveFirstCertL(); + break; + case EMovingCertRetrievingCerts: + SaveRetrievedCertL(); + break; + case EMovingCertAddingCerts: + DeleteOriginalCertL(); + break; + case EMovingCertDeletingOriginal: + RetrieveNextCertL(); + break; + default: + ASSERT(EFalse); + break; + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::RunError() +// --------------------------------------------------------------------------- +// +TInt CAdvSecSettingsCertMover::RunError(TInt aError) +{ + TRACE1("CAdvSecSettingsCertMover::RunError(), aError=%d", aError); + if (iClientStatus) { + TRACE1("CAdvSecSettingsCertMover::RunError(), RequestComplete %d", aError); + User::RequestComplete(iClientStatus, aError); + iClientStatus = NULL; + } + if (iState < EIdle) { + iState = EFailed; + } else { + iState = EIdle; + } + return KErrNone; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::CAdvSecSettingsCertMover() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsCertMover::CAdvSecSettingsCertMover(RFs &aFs) : + CActive(CActive::EPriorityLow), iFs(aFs), iDataPtr(0,0) +{ + CActiveScheduler::Add(this); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::ConstructL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::ConstructL() +{ + TRACE("CAdvSecSettingsCertMover::ConstructL()"); + const TBool KWriteMode = ETrue; + iCertStore = CUnifiedCertStore::NewL(iFs, KWriteMode); + iKeyStore = CUnifiedKeyStore::NewL(iFs); + + iDataBuffer = HBufC8::New(KMaxBufferLength); + iDataPtr.Set(iDataBuffer->Des()); + + iCertStore->Initialize(iStatus); + iState = EInitializingCertStore; + SetActive(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::StartMoveOperationL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::StartMoveOperationL() +{ + TRACE("CAdvSecSettingsCertMover::StartMoveOperationL()"); + FindSourceAndTargetKeyStoresL(); + FindSourceAndTargetCertStoreL(); + StartMovingKeysL(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::FindSourceAndTargetKeyStoresL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::FindSourceAndTargetKeyStoresL() +{ + TRACE("CAdvSecSettingsCertMover::FindSourceAndTargetKeyStoresL()"); + TInt keyStoreSourceTokenId = CorrespondingKeyStoreTokenId(iSourceCertStoreTokenId); + TInt keyStoreTargetTokenId = CorrespondingKeyStoreTokenId(iTargetCertStoreTokenId); + TInt keyStoreSourceIndex = KErrNotFound; + TInt keyStoreTargetIndex = KErrNotFound; + + TInt count = iKeyStore->KeyStoreManagerCount(); + for (TInt index = 0; index < count; index++) { + MCTKeyStoreManager& keystoremanager = iKeyStore->KeyStoreManager(index); + MCTToken& token = keystoremanager.Token(); + TUid tokenTypeUid = token.Handle().iTokenTypeUid; + if (tokenTypeUid.iUid == keyStoreSourceTokenId) { + keyStoreSourceIndex = index; + } + if (tokenTypeUid.iUid == keyStoreTargetTokenId) { + keyStoreTargetIndex = index; + } + } + + if (keyStoreSourceIndex == KErrNotFound || keyStoreTargetIndex == KErrNotFound) { + User::Leave(KErrNotFound); + } + + iSourceKeyStore = &( iKeyStore->KeyStoreManager(keyStoreSourceIndex) ); + iTargetKeyStore = &( iKeyStore->KeyStoreManager(keyStoreTargetIndex) ); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::FindSourceAndTargetCertStoreL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::FindSourceAndTargetCertStoreL() +{ + TRACE("CAdvSecSettingsCertMover::FindSourceAndTargetCertStoreL()"); + TInt certStoreSourceIndex = KErrNotFound; + TInt certStoreTargetIndex = KErrNotFound; + + TInt count = iCertStore->WritableCertStoreCount(); + for (TInt index = 0; index < count; index++) { + MCTWritableCertStore& writablestore = iCertStore->WritableCertStore(index); + MCTToken& token = writablestore.Token(); + TUid tokenTypeUid = token.Handle().iTokenTypeUid; + if (tokenTypeUid.iUid == iSourceCertStoreTokenId) { + certStoreSourceIndex = index; + } + if (tokenTypeUid.iUid == iTargetCertStoreTokenId) { + certStoreTargetIndex = index; + } + } + + if (certStoreSourceIndex == KErrNotFound || certStoreTargetIndex == KErrNotFound) { + User::Leave(KErrNotFound); + } + + iSourceCertStore = &( iCertStore->WritableCertStore(certStoreSourceIndex) ); + iTargetCertStore = &( iCertStore->WritableCertStore(certStoreTargetIndex) ); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::CorrespondingKeyStoreTokenId() +// --------------------------------------------------------------------------- +// +TInt CAdvSecSettingsCertMover::CorrespondingKeyStoreTokenId(TInt aCertStoreTokenId) +{ + TInt keyStoreTokenId = KErrNotFound; + switch (aCertStoreTokenId) { + case KAdvSecSettingsFileCertStore: + keyStoreTokenId = KAdvSecSettingsFileKeyStore; + break; + case KAdvSecSettingsDeviceCertStore: + keyStoreTokenId = KAdvSecSettingsDeviceKeyStore; + break; + default: + ASSERT(EFalse); // Unsupported cert store token id used + break; + } + return keyStoreTokenId; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::StartMovingKeysL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::StartMovingKeysL() +{ + TRACE("CAdvSecSettingsCertMover::StartMovingKeysL()"); + if (iKeyFilter) { + delete iKeyFilter; + iKeyFilter = NULL; + } + iKeyFilter = new( ELeave ) TCTKeyAttributeFilter; + iKeyFilter->iKeyId = iCertInfo->SubjectKeyId(); + iKeyFilter->iPolicyFilter = TCTKeyAttributeFilter::EAllKeys; + iKeyStore->List(iKeys, *iKeyFilter, iStatus); + iState = EMovingKeyListingKeys; + SetActive(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::ExportFirstKeyL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::ExportFirstKeyL() +{ + TRACE1("CAdvSecSettingsCertMover::ExportFirstKeyL(), iKeys.Count()=%d", iKeys.Count()); + iKeyIndex = 0; + ExportOneKeyL(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::ExportOneKeyL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::ExportOneKeyL() +{ + TRACE("CAdvSecSettingsCertMover::ExportOneKeyL()"); + if (iKeyIndex < iKeys.Count()) { + const CCTKeyInfo& keyInfo = *(iKeys[iKeyIndex]); + iSourceKeyStore->ExportKey(keyInfo.Handle(), iDataBuffer, iStatus); + iState = EMovingKeyExportingKeys; + SetActive(); + } else { + TRACE("CAdvSecSettingsCertMover::ExportOneKeyL(), all done"); + StartMovingCertificatesL(); + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::ExportNextKeyL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::ExportNextKeyL() +{ + TRACE("CAdvSecSettingsCertMover::ExportNextKeyL()"); + ++iKeyIndex; + ExportOneKeyL(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::SaveExportedKeyL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::SaveExportedKeyL() +{ + TRACE("CAdvSecSettingsCertMover::SaveExportedKeyL()"); + const CCTKeyInfo& keyInfo = *(iKeys[iKeyIndex]); + iSourceKeyHandle = keyInfo.Handle(); + + // TODO: is this needed? should iSavedKeyInfo be always used? + // Keys having CCTKeyInfo::ELocal access type cannot be imported. + // Workaround is to create almost identical copy of CCTKeyInfo without + // ELocal access type flag. UsePolicy is also updated. + TInt accessType = keyInfo.AccessType(); + if (accessType & CCTKeyInfo::ELocal) { + accessType ^= CCTKeyInfo::ELocal; + + HBufC* label = keyInfo.Label().AllocLC(); + if (iSavedKeyInfo) { + iSavedKeyInfo->Release(); + iSavedKeyInfo = NULL; + } + iSavedKeyInfo = CCTKeyInfo::NewL( keyInfo.ID(), keyInfo.Usage(), + keyInfo.Size(), NULL, label, keyInfo.Token(), keyInfo.HandleID(), + KKeyStoreUsePolicy, keyInfo.ManagementPolicy(),keyInfo.Algorithm(), + keyInfo.AccessType(), keyInfo.Native(), keyInfo.StartDate(), + keyInfo.EndDate() ); + CleanupStack::Pop(label); + + iTargetKeyStore->ImportKey(*iDataBuffer, iSavedKeyInfo, iStatus); + } else { + iTargetKeyStore->ImportKey(*iDataBuffer, iKeys[iKeyIndex], iStatus); + } + iState = EMovingKeyImportingKeys; + SetActive(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::DeleteOriginalKeyL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::DeleteOriginalKeyL() +{ + TRACE("CAdvSecSettingsCertMover::DeleteOriginalKeyL()"); + iSourceKeyStore->DeleteKey(iSourceKeyHandle, iStatus); + iState = EMovingKeyDeletingOriginal; + SetActive(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::StartMovingCertificatesL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::StartMovingCertificatesL() +{ + TRACE("CAdvSecSettingsCertMover::StartMovingCertificatesL()"); + if (iCertFilter) { + delete iCertFilter; + iCertFilter = NULL; + } + iCertFilter = CCertAttributeFilter::NewL(); + iCertFilter->SetOwnerType(EUserCertificate); + iCertFilter->SetSubjectKeyId(iCertInfo->SubjectKeyId()); + iCertStore->List(iCerts, *iCertFilter, iStatus); + iState = EMovingCertListingCerts; + SetActive(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::RetrieveFirstCertL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::RetrieveFirstCertL() +{ + TRACE1("CAdvSecSettingsCertMover::RetrieveFirstCertL(), iCerts.Count()=%d", iCerts.Count()); + iCertIndex = 0; + RetrieveOneCertL(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::RetrieveOneCertL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::RetrieveOneCertL() +{ + TRACE("CAdvSecSettingsCertMover::RetrieveOneCertL()"); + if (iCertIndex < iCerts.Count()) { + const CCTCertInfo& certInfo = *(iCerts[iCertIndex]); + iSourceCertStore->Retrieve(certInfo, iDataPtr, iStatus); + iState = EMovingCertRetrievingCerts; + SetActive(); + } else { + TRACE("CAdvSecSettingsCertMover::RetrieveOneCertL(), all done"); + iState = EIdle; + User::RequestComplete(iClientStatus, KErrNone); + iClientStatus = NULL; + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::RetrieveNextCertL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::RetrieveNextCertL() +{ + TRACE("CAdvSecSettingsCertMover::RetrieveNextCertL()"); + ++iCertIndex; + RetrieveOneCertL(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::SaveRetrievedCertL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::SaveRetrievedCertL() +{ + TRACE("CAdvSecSettingsCertMover::SaveRetrievedCertL()"); + const CCTCertInfo& certInfo = *(iCerts[iCertIndex]); + iTargetCertStore->Add(certInfo.Label(), EX509Certificate, EUserCertificate, + &(certInfo.SubjectKeyId()), &(certInfo.IssuerKeyId()), *iDataBuffer, iStatus); + iState = EMovingCertAddingCerts; + SetActive(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsCertMover::DeleteOriginalCertL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsCertMover::DeleteOriginalCertL() +{ + TRACE("CAdvSecSettingsCertMover::DeleteOriginalCertL()"); + const CCTCertInfo& certInfo = *(iCerts[iCertIndex]); + iSourceCertStore->Remove(certInfo, iStatus); + iState = EMovingCertDeletingOriginal; + SetActive(); +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingscerttrustsettingsview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingscerttrustsettingsview.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,212 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Certificate trust settings view in advanced security settings +* +*/ + +#include "advsecsettingscerttrustsettingsview.h" +#include "advsecsettingstrustedcertusageuids.h" +#include "advsecsettingscertificatemodel.h" +#include "advsecsettingscertificate.h" +#include +#include +#include +#include +#include +#include + +const QString KText("text"); +const QString KAdditionalText("additionalText"); +const QString KHexUsageIdFormat("0x%1"); +const int KHexFieldWidth = 8; +const int KHexBase = 16; + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertTrustSettingsView::AdvSecSettingsCertTrustSettingsView() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertTrustSettingsView::AdvSecSettingsCertTrustSettingsView( + AdvSecSettingsCertificateModel &model, QGraphicsItem *parent) : + AdvSecSettingsViewBase(0, parent), mModel(model), mCertificate(0), + mIsCertDeletable(false), mViewLabel(0), mDataForm(0), mDataFormModel(0) +{ + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); + + mViewLabel = new HbGroupBox; + layout->addItem(mViewLabel); + + HbScrollArea *scrollArea = new HbScrollArea; + mDataForm = new HbDataForm; + scrollArea->setContentWidget(mDataForm); + layout->addItem(scrollArea); + + setLayout(layout); + + connect(&mModel, SIGNAL(getTrustSettingsCompleted()), this, SLOT(refreshDisplay())); + connect(&mModel, SIGNAL(deleteCertificateCompleted()), this, SLOT(close())); + connect(this, SIGNAL(aboutToClose()), this, SLOT(saveTrustSettings())); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertTrustSettingsView::~AdvSecSettingsCertTrustSettingsView() +// --------------------------------------------------------------------------- +// +AdvSecSettingsCertTrustSettingsView::~AdvSecSettingsCertTrustSettingsView() +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertTrustSettingsView::setCertificate() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertTrustSettingsView::setCertificate(const AdvSecSettingsCertificate &cert) +{ + mCertificate = &cert; + mIsCertDeletable = mModel.isDeletable(cert); + + menu()->clearActions(); + if (mIsCertDeletable) { + HbAction *deleteAction = new HbAction(hbTrId("txt_common_menu_delete")); + connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteCertificate())); + menu()->addAction(deleteAction); + } + + mUsageIdAndTrust.clear(); + mModel.getTrustSettings(cert, mUsageIdAndTrust); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertTrustSettingsView::refreshDisplay() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertTrustSettingsView::refreshDisplay() +{ + if (mDataFormModel) { + mDataForm->setModel(0); + delete mDataFormModel; + mDataFormModel = 0; + } + mDataFormModel = new HbDataFormModel(this); + + QMapIterator iter(mUsageIdAndTrust); + while (iter.hasNext()) { + iter.next(); + HbDataFormModelItem *item = mDataFormModel->appendDataFormItem( + HbDataFormModelItem::ToggleValueItem, usageName(iter.key())); + if (iter.value()) { + // TODO: localized UI string needed + item->setContentWidgetData(KText, tr("On")); + item->setContentWidgetData(KAdditionalText, tr("Off")); + } else { + // TODO: localized UI string needed + item->setContentWidgetData(KText, tr("Off")); + item->setContentWidgetData(KAdditionalText, tr("On")); + } + if (!mIsCertDeletable) { + item->setEnabled(false); + } + } + connect(mDataFormModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), + this, SLOT(toggleChange(QModelIndex))); + + mViewLabel->setHeading(mCertificate->label()); + mDataForm->setModel(mDataFormModel); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertTrustSettingsView::toggleChange() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertTrustSettingsView::toggleChange(const QModelIndex &itemIndex) +{ + if (mIsCertDeletable) { + HbDataFormModelItem *item = mDataFormModel->itemFromIndex(itemIndex); + + int usageId = 0; + QString label = item->label(); + QMapIterator iter(mUsageIdAndName); + while (iter.hasNext() && !usageId) { + iter.next(); + if (label == iter.value()) { + usageId = iter.key(); + } + } + + if (usageId) { + QVariant data = item->contentWidgetData(KText); + if (data.toString() == tr("On")) { // TODO: use localized UI string + mUsageIdAndTrust[usageId] = true; + } else { + mUsageIdAndTrust[usageId] = false; + } + } + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertTrustSettingsView::saveTrustSettings() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertTrustSettingsView::saveTrustSettings() +{ + if (mIsCertDeletable) { + Q_ASSERT(mCertificate != 0); + mModel.setTrustSettings(*mCertificate, mUsageIdAndTrust); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertTrustSettingsView::deleteCertificate() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertTrustSettingsView::deleteCertificate() +{ + Q_ASSERT(mCertificate != 0); + // TODO: localized UI string needed + QString confirmText(tr("Delete %1?").arg(mCertificate->label())); + displayQuestionNote(confirmText, this, SLOT(deleteConfirmationAccepted())); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertTrustSettingsView::deleteConfirmationAccepted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsCertTrustSettingsView::deleteConfirmationAccepted() +{ + Q_ASSERT(mCertificate != 0); + mModel.deleteCertificate(*mCertificate); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsCertTrustSettingsView::usageName() +// --------------------------------------------------------------------------- +// +QString AdvSecSettingsCertTrustSettingsView::usageName(int usageId) +{ + if (mUsageIdAndName.isEmpty()) { + mModel.getCertificateUsageNames(mUsageIdAndName); + } + + QString name; + if (mUsageIdAndName.contains(usageId)) { + name = mUsageIdAndName.value(usageId); + } else { + name = QString(KHexUsageIdFormat).arg(usageId, KHexFieldWidth, KHexBase); + } + return name; +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingslabeledcertinfo_symbian.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingslabeledcertinfo_symbian.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to contain a labeled CCTCertInfo object +* +*/ + +#include "advsecsettingslabeledcertinfo_symbian.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CAdvSecSettingsLabeledCertInfo::CAdvSecSettingsLabeledCertInfo() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsLabeledCertInfo::CAdvSecSettingsLabeledCertInfo( + const CCTCertInfo &aCertInfo) : iCertInfo(aCertInfo) +{ +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsLabeledCertInfo::~CAdvSecSettingsLabeledCertInfo() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsLabeledCertInfo::~CAdvSecSettingsLabeledCertInfo() +{ + delete iLabel; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsLabeledCertInfo::CertInfo() +// --------------------------------------------------------------------------- +// +const CCTCertInfo &CAdvSecSettingsLabeledCertInfo::CertInfo() const +{ + return iCertInfo; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsLabeledCertInfo::Label() +// --------------------------------------------------------------------------- +// +const TDesC &CAdvSecSettingsLabeledCertInfo::Label() const +{ + if (iLabel) { + return *iLabel; + } + return KNullDesC; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsLabeledCertInfo::SetLabelL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsLabeledCertInfo::SetLabelL(const TDesC &aLabel) +{ + if (iLabel) { + delete iLabel; + iLabel = NULL; + } + iLabel = aLabel.AllocL(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsLabeledCertInfo::AppendLabelL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsLabeledCertInfo::AppendLabelL(const TDesC &aSeparator, + const TDesC &aAdditionalText) +{ + if (iLabel && iLabel->Length()) { + TInt length = iLabel->Length() + aSeparator.Length() + aAdditionalText.Length(); + iLabel = iLabel->ReAllocL(length); + TPtr labelPtr = iLabel->Des(); + labelPtr.Append(aSeparator); + labelPtr.Append(aAdditionalText); + } else { + SetLabelL(aAdditionalText); + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsLabeledCertInfo::Compare() +// --------------------------------------------------------------------------- +// +TInt CAdvSecSettingsLabeledCertInfo::Compare(const CAdvSecSettingsLabeledCertInfo& aLeft, + const CAdvSecSettingsLabeledCertInfo& aRight) +{ + return (aLeft.Label().CompareF(aRight.Label())); +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingsloader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingsloader.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0"" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Advanced security settings loader + * + */ + +#include "advsecsettingsloader.h" // AdvSecSettingsLoader +#include "advsecsettingsmainview.h" // AdvSecSettingsMainView +#include // CpSettingFormEntryItemDataImpl +#include // qApp +#include + +const QString KTranslationsPath = "/resource/qt/translations/"; +const QString KTranslationsFile = "certificate_manager"; + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsLoader::AdvSecSettingsLoader() +// --------------------------------------------------------------------------- +// +AdvSecSettingsLoader::AdvSecSettingsLoader() +{ + mTranslator = new HbTranslator(KTranslationsPath, KTranslationsFile); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsLoader::~AdvSecSettingsLoader() +// --------------------------------------------------------------------------- +// +AdvSecSettingsLoader::~AdvSecSettingsLoader() +{ + delete mTranslator; + mTranslator = 0; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsLoader::createSettingFormItemData() +// --------------------------------------------------------------------------- +// +QList AdvSecSettingsLoader::createSettingFormItemData( + CpItemDataHelper &itemDataHelper) const +{ + CpSettingFormEntryItemData *advancedSecuritySettingsItem = + new CpSettingFormEntryItemDataImpl( + CpSettingFormEntryItemData::ButtonEntryItem, + itemDataHelper, hbTrId("txt_certificate_manager_setlabel_advanced_security")); + advancedSecuritySettingsItem->setContentWidgetData("textAlignment", + QVariant( Qt::AlignHCenter | Qt::AlignVCenter) ); + advancedSecuritySettingsItem->setContentWidgetData("objectName", + "advancedSecuritySettingsButton" ); + return QList() << advancedSecuritySettingsItem; +} + + +Q_EXPORT_PLUGIN2(cpadvancedsecplugin, AdvSecSettingsLoader); + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingsmainview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingsmainview.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,236 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Advanced security settings main view +* +*/ + +#include "advsecsettingsmainview.h" +#include "advsecsettingscertificatelistview.h" +#include "advsecsettingssecuritymodulemodel.h" +#include "advsecsettingssecuritymoduleview.h" +#include +#include +#include +#include +#include + +const int KAuthorityCertsRow = 0; +const int KTrustedSiteCertsRow = 1; +const int KPersonalCertsRow = 2; +const int KDeviceCertsRow = 3; + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsMainView::AdvSecSettingsMainView() +// --------------------------------------------------------------------------- +// +AdvSecSettingsMainView::AdvSecSettingsMainView( + QGraphicsItem *parent) : AdvSecSettingsViewBase(0, parent), + mSecModModel(0), mCertListView(0), mSecModView(0), + mSecModGroupBox(0), mSecModList(0), mContextMenu(0) +{ + Q_ASSERT(mSecModModel == 0); + mSecModModel = new AdvSecSettingsSecurityModuleModel(this); + connect(mSecModModel, SIGNAL(initializeCompleted()), this, SLOT(securityModuleInitialized())); + connect(mSecModModel, SIGNAL(errorOccurred(int)), this, SLOT(displayError(int))); + mSecModModel->initialize(); + + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); + HbGroupBox *groupBox = 0; + + // View title + groupBox = new HbGroupBox; + groupBox->setHeading(hbTrId("txt_certificate_manager_setlabel_advanced_security")); + layout->addItem(groupBox); + + // Certificates group + groupBox = new HbGroupBox; + groupBox->setHeading(hbTrId("txt_certificate_manager_setlabel_certificates")); + groupBox->setContentWidget(createCertificatesTopLevel()); + groupBox->setCollapsed(true); + layout->addItem(groupBox); + + // Protected content group + groupBox = new HbGroupBox; + // TODO: localized UI string needed + groupBox->setHeading("Protected Content"); + groupBox->setContentWidget(createProtectedContentTopLevel()); + groupBox->setCollapsed(true); + layout->addItem(groupBox); + + // Security module group + Q_ASSERT(mSecModGroupBox == 0); + mSecModGroupBox = new HbGroupBox; + // TODO: localized UI string needed + mSecModGroupBox->setHeading("Security Module"); + mSecModGroupBox->setVisible(false); // set in securityModuleInitialized() + layout->addItem(mSecModGroupBox); + + setLayout(layout); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsMainView::~AdvSecSettingsMainView() +// --------------------------------------------------------------------------- +// +AdvSecSettingsMainView::~AdvSecSettingsMainView() + { + } + +// --------------------------------------------------------------------------- +// AdvSecSettingsMainView::displayCertListView() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsMainView::displayCertListView(const QModelIndex& modelIndex) +{ + if (!mCertListView) { + mCertListView = new AdvSecSettingsCertificateListView(this); + } + + AdvSecSettingsCertificate::CertificateType type = + AdvSecSettingsCertificate::AuthorityCertificate; + switch (modelIndex.row()) { + case KAuthorityCertsRow: + type = AdvSecSettingsCertificate::AuthorityCertificate; + break; + case KTrustedSiteCertsRow: + type = AdvSecSettingsCertificate::TrustedSiteCertificate; + break; + case KPersonalCertsRow: + type = AdvSecSettingsCertificate::PersonalCertificate; + break; + case KDeviceCertsRow: + type = AdvSecSettingsCertificate::DeviceCertificate; + break; + default: + break; + } + + mCertListView->displayCertificates(type); + displayView(mCertListView); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsMainView::displaySecurityModuleView() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsMainView::displaySecurityModuleView(const QModelIndex& modelIndex) +{ + if (!mSecModView) { + mSecModView = new AdvSecSettingsSecurityModuleView(*mSecModModel, this); + } + + int row = modelIndex.row(); + mSecModView->setSecurityModule(mSecModList->item(row)->text(), row); + displayView(mSecModView); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsMainView::securityModuleInitialized() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsMainView::securityModuleInitialized() +{ + if (isSecurityModulesAvailable()) { + mSecModGroupBox->setContentWidget(createSecurityModuleTopLevel()); + mSecModGroupBox->setCollapsed(true); + mSecModGroupBox->setVisible(true); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsMainView:: +// --------------------------------------------------------------------------- +// +HbWidget *AdvSecSettingsMainView::createCertificatesTopLevel() +{ + HbListWidget *list = new HbListWidget; + HbListWidgetItem *item = 0; + + // KAuthorityCertsRow + item = new HbListWidgetItem; + item->setText(hbTrId("txt_certificate_manager_list_authority_certificate")); + list->addItem(item); + + // KTrustedSiteCertsRow + item = new HbListWidgetItem; + item->setText(hbTrId("txt_certificate_manager_list_trusted_site_certific")); + list->addItem(item); + + // KPersonalCertsRow + item = new HbListWidgetItem; + item->setText(hbTrId("txt_certificate_manager_list_personal_certificates")); + list->addItem(item); + + // KDeviceCertsRow + item = new HbListWidgetItem; + item->setText(hbTrId("txt_certificate_manager_list_device_certificates")); + list->addItem(item); + + connect(list, SIGNAL(released(QModelIndex)), this, SLOT(displayCertListView(QModelIndex))); + + return list; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsMainView:: +// --------------------------------------------------------------------------- +// +HbWidget *AdvSecSettingsMainView::createProtectedContentTopLevel() +{ + HbListWidget* list = new HbListWidget; + + // TODO: implement + + return list; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsMainView:: +// --------------------------------------------------------------------------- +// +HbWidget *AdvSecSettingsMainView::createSecurityModuleTopLevel() +{ + Q_ASSERT(mSecModList == 0); + mSecModList = new HbListWidget; + + QMap labelAndLocation = mSecModModel->moduleLabelsAndLocations(); + QMapIterator iter(labelAndLocation); + while (iter.hasNext()) { + iter.next(); + HbListWidgetItem *item = new HbListWidgetItem; + item->setText(iter.key()); + item->setSecondaryText(iter.value()); + mSecModList->addItem(item); + } + + connect(mSecModList, SIGNAL(activated(QModelIndex)), + this, SLOT(displaySecurityModuleView(QModelIndex))); + connect(mSecModList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), + this, SLOT(indicateLongPress(HbAbstractViewItem*, QPointF))); // TODO: implement + + return mSecModList; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsMainView::isSecurityModulesAvailable() +// --------------------------------------------------------------------------- +// +bool AdvSecSettingsMainView::isSecurityModulesAvailable() +{ + return (mSecModModel && mSecModModel->moduleCount()); +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymodule_symbian.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymodule_symbian.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Symbian specific container class for a security module +* +*/ + +#include "advsecsettingssecuritymodule_symbian.h" +#include // CCTCertInfo +#include // CCTKeyInfo + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleSymbian::CAdvSecSettingsSecurityModuleSymbian() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsSecurityModuleSymbian::CAdvSecSettingsSecurityModuleSymbian( + MCTKeyStore &aProtectedKeyStore) : CBase(), iProtectedKeyStore(aProtectedKeyStore) +{ +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleSymbian::~CAdvSecSettingsSecurityModuleSymbian() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsSecurityModuleSymbian::~CAdvSecSettingsSecurityModuleSymbian() +{ + iKeyInfoArray.Close(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleSymbian::Label() +// --------------------------------------------------------------------------- +// +const TDesC &CAdvSecSettingsSecurityModuleSymbian::Label() const +{ + return KNullDesC; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleSymbian::IsDeletable() +// --------------------------------------------------------------------------- +// +TBool CAdvSecSettingsSecurityModuleSymbian::IsDeletable() const +{ + return EFalse; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleSymbian::IsSigningPinSupported() +// --------------------------------------------------------------------------- +// +TBool CAdvSecSettingsSecurityModuleSymbian::IsSigningPinSupported() const +{ + return EFalse; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleSymbian::KeyInfoArray() +// --------------------------------------------------------------------------- +// +RMPointerArray &CAdvSecSettingsSecurityModuleSymbian::KeyInfoArray() +{ + return iKeyInfoArray; +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymoduledetailview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymoduledetailview.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Security module detail view in advanced security settings +* +*/ + +#include "advsecsettingssecuritymoduledetailview.h" +#include "advsecsettingssecuritymodulemodel.h" +#include +#include +#include +#include +#include +#include + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleDetailView::AdvSecSettingsSecurityModuleDetailView() +// --------------------------------------------------------------------------- +// +AdvSecSettingsSecurityModuleDetailView::AdvSecSettingsSecurityModuleDetailView( + AdvSecSettingsSecurityModuleModel &model, QGraphicsItem *parent) : + AdvSecSettingsViewBase(0, parent), mModel(model), mModuleIndex(0), + mViewLabel(0), mDetailsText(0) +{ + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); + + mViewLabel = new HbGroupBox; + layout->addItem(mViewLabel); + + HbScrollArea *scrollArea = new HbScrollArea; + mDetailsText = new HbLabel; + mDetailsText->setTextWrapping(Hb::TextWordWrap); + scrollArea->setContentWidget(mDetailsText); + scrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOn); + layout->addItem(scrollArea); + + setLayout(layout); + + connect(&mModel, SIGNAL(detailsCompleted(QMap)), + this, SLOT(detailsCompleted(QMap))); + connect(&mModel, SIGNAL(deleteCompleted()), + this, SLOT(displayPreviousView())); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleDetailView::~AdvSecSettingsSecurityModuleDetailView() +// --------------------------------------------------------------------------- +// +AdvSecSettingsSecurityModuleDetailView::~AdvSecSettingsSecurityModuleDetailView() +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleDetailView::setSecurityModule() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleDetailView::setSecurityModule(int index) +{ + mModuleIndex = index; + // TODO: remove + mDetailsText->setPlainText(tr("TODO: Add info for module %1").arg(index)); + + menu()->clearActions(); + if (mModel.isDeletable(index)) { + HbAction *deleteAction = new HbAction(hbTrId("txt_common_menu_delete")); + connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteSecurityModule())); + menu()->addAction(deleteAction); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleDetailView::detailsCompleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleDetailView::detailsCompleted(QMap /*details*/) +{ + // TODO: implement +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleDetailView::deleteSecurityModule() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleDetailView::deleteSecurityModule() +{ + Q_ASSERT(mViewLabel != 0); + // TODO: localized UI string needed + QString confirmText(tr("Delete %1?").arg(mViewLabel->heading())); + displayQuestionNote(confirmText, this, SLOT(deleteConfirmationAccepted())); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleDetailView::deleteConfirmationAccepted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleDetailView::deleteConfirmationAccepted() +{ + mModel.deleteModule(mModuleIndex); +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymoduleeraser_symbian.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymoduleeraser_symbian.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,189 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to remove a security module +* +*/ + + +#include "advsecsettingssecuritymoduleeraser_symbian.h" +#include // CUnifiedKeyStore +#include // TCTTokenObjectHandle + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleEraser::NewL() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsSecurityModuleEraser *CAdvSecSettingsSecurityModuleEraser::NewL( + CUnifiedKeyStore &aKeyStore) +{ + CAdvSecSettingsSecurityModuleEraser *self = new(ELeave) CAdvSecSettingsSecurityModuleEraser( + aKeyStore); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleEraser::~CAdvSecSettingsSecurityModuleEraser() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsSecurityModuleEraser::~CAdvSecSettingsSecurityModuleEraser() +{ + iKeys.Close(); + delete iKeyFilter; + iTargetKeyStore = NULL; + iClientStatus = NULL; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleEraser::Erase() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsSecurityModuleEraser::Erase(TInt aKeyStoreIndex, TRequestStatus &aStatus) +{ + aStatus = KRequestPending; + if (!IsActive() && (iState == EIdle)) { + if (aKeyStoreIndex >= 0 && aKeyStoreIndex < iKeyStore.KeyStoreCount()) { + iTargetKeyStore = &(iKeyStore.KeyStore(aKeyStoreIndex)); + iClientStatus = &aStatus; + + iKeys.Reset(); + iTargetKeyStore->List(iKeys, *iKeyFilter, iStatus); + iState = EListingKeys; + SetActive(); + } else { + TRequestStatus *status = &aStatus; + User::RequestComplete(status, KErrArgument); + } + } else { + TRequestStatus *status = &aStatus; + User::RequestComplete(status, KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleEraser::DoCancel() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsSecurityModuleEraser::DoCancel() +{ + switch (iState) { + case EListingKeys: + iTargetKeyStore->CancelList(); + break; + case EDeletingKey: + iKeyStore.CancelDeleteKey(); + break; + default: + break; + } + iState = EIdle; + + User::RequestComplete(iClientStatus, KErrCancel); + iClientStatus = NULL; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleEraser::RunL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsSecurityModuleEraser::RunL() +{ + switch (iState) { + case EListingKeys: + DeleteFirstKeyL(); + break; + case EDeletingKey: + DeleteNextKeyL(); + break; + default: + ASSERT(EFalse); + break; + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleEraser::RunError() +// --------------------------------------------------------------------------- +// +TInt CAdvSecSettingsSecurityModuleEraser::RunError(TInt aError) +{ + User::RequestComplete(iClientStatus, aError); + iClientStatus = NULL; + iState = EIdle; + return KErrNone; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleEraser::CAdvSecSettingsSecurityModuleEraser() +// --------------------------------------------------------------------------- +// +CAdvSecSettingsSecurityModuleEraser::CAdvSecSettingsSecurityModuleEraser( + CUnifiedKeyStore &aKeyStore) : CActive(CActive::EPriorityStandard), + iKeyStore(aKeyStore) +{ + CActiveScheduler::Add(this); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleEraser::ConstructL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsSecurityModuleEraser::ConstructL() +{ + iKeyFilter = new(ELeave) TCTKeyAttributeFilter; + iKeyFilter->iPolicyFilter = TCTKeyAttributeFilter::EAllKeys; +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleEraser::DeleteFirstKeyL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsSecurityModuleEraser::DeleteFirstKeyL() +{ + iKeyIndex = 0; + DeleteOneKeyL(); +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleEraser::DeleteOneKeyL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsSecurityModuleEraser::DeleteOneKeyL() +{ + if (iKeyIndex < iKeys.Count()) { + iKeyStore.DeleteKey(iKeys[iKeyIndex]->Handle(), iStatus); + iState = EDeletingKey; + SetActive(); + } else { + User::RequestComplete(iClientStatus, KErrNone); + iClientStatus = NULL; + iState = EIdle; + } +} + +// --------------------------------------------------------------------------- +// CAdvSecSettingsSecurityModuleEraser::DeleteNextKeyL() +// --------------------------------------------------------------------------- +// +void CAdvSecSettingsSecurityModuleEraser::DeleteNextKeyL() +{ + ++iKeyIndex; + DeleteOneKeyL(); +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymodulemodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymodulemodel.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,258 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Security module model in advanced security settings +* +*/ + +#include "advsecsettingssecuritymodulemodel.h" + +#if defined(Q_OS_SYMBIAN) +#include "advsecsettingssecuritymodulemodel_symbian_p.h" +#else +#include "advsecsettingssecuritymodulemodel_stub_p.h" +#endif + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::AdvSecSettingsSecurityModuleModel() +// --------------------------------------------------------------------------- +// +AdvSecSettingsSecurityModuleModel::AdvSecSettingsSecurityModuleModel( + QObject *parent) : QObject(parent) +{ + d_ptr = new AdvSecSettingsSecurityModuleModelPrivate(this); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::~AdvSecSettingsSecurityModuleModel() +// --------------------------------------------------------------------------- +// +AdvSecSettingsSecurityModuleModel::~AdvSecSettingsSecurityModuleModel() +{ + delete d_ptr; + d_ptr = 0; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::initialize() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::initialize() +{ + if (d_ptr) { + d_ptr->initialize(); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::moduleCount() +// --------------------------------------------------------------------------- +// +int AdvSecSettingsSecurityModuleModel::moduleCount() const +{ + if (d_ptr) { + return d_ptr->moduleCount(); + } + return 0; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::moduleLabelsAndLocations() +// --------------------------------------------------------------------------- +// +QMap AdvSecSettingsSecurityModuleModel::moduleLabelsAndLocations() const +{ + if (d_ptr) { + return d_ptr->moduleLabelsAndLocations(); + } + QMap emptyMap; + return emptyMap; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::getModuleStatus() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::getModuleStatus(int moduleIndex) +{ + if (d_ptr) { + d_ptr->getModuleStatus(moduleIndex); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::setPinCodeRequestState() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::setPinCodeRequestState(int moduleIndex, + bool isRequested) +{ + if (d_ptr) { + d_ptr->setPinCodeRequestState(moduleIndex, isRequested); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::changePinCode() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::changePinCode(int moduleIndex) +{ + if (d_ptr) { + d_ptr->changePinCode(moduleIndex); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::closeModule() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::closeModule(int moduleIndex) +{ + if (d_ptr) { + d_ptr->closeModule(moduleIndex); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::isSigningPinSupported() +// --------------------------------------------------------------------------- +// +bool AdvSecSettingsSecurityModuleModel::isSigningPinSupported(int moduleIndex) const +{ + if (d_ptr) { + return d_ptr->isSigningPinSupported(moduleIndex); + } + return false; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::changeSigningPinCode() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::changeSigningPinCode(int moduleIndex) +{ + if (d_ptr) { + d_ptr->changeSigningPinCode(moduleIndex); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::isDeletable() +// --------------------------------------------------------------------------- +// +bool AdvSecSettingsSecurityModuleModel::isDeletable(int moduleIndex) const +{ + if (d_ptr) { + return d_ptr->isDeletable(moduleIndex); + } + return false; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::deleteModule() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::deleteModule(int moduleIndex) +{ + if (d_ptr) { + d_ptr->deleteModule(moduleIndex); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::handleInitializeCompleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::handleInitializeCompleted() +{ + emit initializeCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::handleStatusCompleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::handleStatusCompleted( + int authenticationStatus) +{ + emit statusCompleted(authenticationStatus); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::handleStatusChanged() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::handleStatusChanged(int moduleIndex, + int authenticationStatus) +{ + emit statusChanged(moduleIndex, authenticationStatus); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::handlePinCodeRequestSet() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::handlePinCodeRequestSet() +{ + emit pinCodeRequestStateCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::handlePinCodeChanged() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::handlePinCodeChanged() +{ + emit pinCodeChangeCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::handleModuleClosed() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::handleModuleClosed() +{ + emit closeCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::handleSigningPinCodeChanged() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::handleSigningPinCodeChanged() +{ + emit signingPinCodeChangeCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::handleModuleDeleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::handleModuleDeleted() +{ + emit deleteCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModel::handleError() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModel::handleError(int error) +{ + emit errorOccurred(error); +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymodulemodel_stub_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymodulemodel_stub_p.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,140 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Generic stub for platform specific private security module model +* +*/ + +#include "advsecsettingssecuritymodulemodel_stub_p.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::AdvSecSettingsSecurityModuleModelPrivate() +// --------------------------------------------------------------------------- +// +AdvSecSettingsSecurityModuleModelPrivate::AdvSecSettingsSecurityModuleModelPrivate( + AdvSecSettingsSecurityModuleModel *q) : QObject(0), q_ptr(q) +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::~AdvSecSettingsSecurityModuleModelPrivate() +// --------------------------------------------------------------------------- +// +AdvSecSettingsSecurityModuleModelPrivate::~AdvSecSettingsSecurityModuleModelPrivate() +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::initialize() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::initialize() +{ + q_ptr->handleInitializeCompleted(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::moduleCount() +// --------------------------------------------------------------------------- +// +int AdvSecSettingsSecurityModuleModelPrivate::moduleCount() const +{ + return 0; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::moduleLabelsAndLocations() +// --------------------------------------------------------------------------- +// +QMap AdvSecSettingsSecurityModuleModelPrivate::moduleLabelsAndLocations() const +{ + QMap emptyMap; + return emptyMap; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::getModuleStatus() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::getModuleStatus(int /*moduleIndex*/) +{ + q_ptr->handleStatusCompleted(0, false, false); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::setPinCodeRequestState() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::setPinCodeRequestState( + int /*moduleIndex*/, bool /*isRequested*/) +{ + q_ptr->handlePinCodeRequestSet(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::changePinCode() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::changePinCode(int /*moduleIndex*/) +{ + q_ptr->handlePinCodeChanged(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::closeModule() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::closeModule(int /*moduleIndex*/) +{ + q_ptr->handleModuleClosed(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::isSigningPinSupported() +// --------------------------------------------------------------------------- +// +bool AdvSecSettingsSecurityModuleModelPrivate::isSigningPinSupported(int /*moduleIndex*/) const +{ + return false; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::changeSigningPinCode() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::changeSigningPinCode(int /*moduleIndex*/) +{ + q_ptr->handleSigningPinCodeChanged(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::isDeletable() +// --------------------------------------------------------------------------- +// +bool AdvSecSettingsSecurityModuleModelPrivate::isDeletable(int /*moduleIndex*/) const +{ + return false; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::deleteModule() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::deleteModule(int /*moduleIndex*/) +{ + q_ptr->handleModuleDeleted(); +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymodulemodel_symbian_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymodulemodel_symbian_p.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,618 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Symbian specific private security module model +* +*/ + +#include "advsecsettingssecuritymodulemodel_symbian_p.h" +#include "advsecsettingssecuritymodulemodel.h" +#include "advsecsettingsstoreuids.h" +#include "advsecsettingssecuritymoduleeraser_symbian.h" +#include // CUnifiedKeyStore +#include // MCTAuthenticationObject +#include + +// TODO: split implementation into smaller parts, use CAdvSecSettingsSecurityModuleSymbian + +// Local functions in other cpp-files within this project +QString CopyStringL(const TDesC16 &aDes16); +QString Location(const TUid &aTokenType); + +// TODO: replace with proper logging +#ifdef _DEBUG +#define TRACE(x) RDebug::Printf(x) +#define TRACE1(x,y) RDebug::Printf((x),(y)) +#define TRACE2(x,y,z) RDebug::Printf((x),(y),(z)) +#else +#define TRACE(x) +#define TRACE1(x,y) +#define TRACE2(x,y,z) +#endif + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::AdvSecSettingsSecurityModuleModelPrivate() +// --------------------------------------------------------------------------- +// +AdvSecSettingsSecurityModuleModelPrivate::AdvSecSettingsSecurityModuleModelPrivate( + AdvSecSettingsSecurityModuleModel *q) : CActive(CActive::EPriorityLow), q_ptr(q), + iState(ENotInitialized) +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::AdvSecSettingsSecurityModuleModelPrivate"); + CActiveScheduler::Add(this); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::~AdvSecSettingsSecurityModuleModelPrivate() +// --------------------------------------------------------------------------- +// +AdvSecSettingsSecurityModuleModelPrivate::~AdvSecSettingsSecurityModuleModelPrivate() +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::~AdvSecSettingsSecurityModuleModelPrivate"); + Cancel(); + delete iModuleEraser; + iCurrentKeyStore = NULL; + iCurrentAuthObject = NULL; + iProtectedKeyStores.Reset(); + iAuthenticationObjects.Reset(); + iKeys.Close(); + delete iAllKeysFilter; + delete iUnifiedKeyStore; + iFs.Close(); + q_ptr = NULL; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::initialize() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::initialize() +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::initialize"); + if ((iState == ENotInitialized) && !IsActive()) { + TRAPD(err, ConstructL()); + if (err == KErrNone) { + iUnifiedKeyStore->Initialize(iStatus); + iState = EInitializing; + SetActive(); + } else { + q_ptr->handleError(err); + } + } else { + q_ptr->handleError(KErrAlreadyExists); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::moduleCount() +// --------------------------------------------------------------------------- +// +int AdvSecSettingsSecurityModuleModelPrivate::moduleCount() const +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::moduleCount"); + return iProtectedKeyStores.Count(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::moduleLabelsAndLocations() +// --------------------------------------------------------------------------- +// +QMap AdvSecSettingsSecurityModuleModelPrivate::moduleLabelsAndLocations() const +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::moduleLabelsAndLocations"); + QMap map; + + for (TInt index = 0; index < iProtectedKeyStores.Count(); index++) { + MCTToken &keyStoreToken = iProtectedKeyStores[index]->Token(); + + QString label; + if (keyStoreToken.TokenType().Type().iUid == KAdvSecSettingsFileKeyStore) { + // TODO: localized UI string needed + label = CopyStringL(_L("Phone key store")); + } else { + label = CopyStringL(keyStoreToken.Label()); + } + + map[label] = Location(keyStoreToken.TokenType().Type()); + } + + return map; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::getModuleStatus() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::getModuleStatus(int moduleIndex) +{ + TRACE1("AdvSecSettingsSecurityModuleModelPrivate::getModuleStatus, moduleIndex=%d", moduleIndex); + if ((iState == EIdle) && !IsActive()) { + if (moduleIndex >= 0 && moduleIndex < iAuthenticationObjects.Count()) { + // TODO: this does not work yet +#if 0 + iCurrentAuthObject = iAuthenticationObjects[moduleIndex]; + iTimeRemaining = 0; + iCurrentAuthObject->TimeRemaining(iTimeRemaining, iStatus); + iState = EReadingTimeRemaining; + SetActive(); +#else + TInt tempStatus = AdvSecSettingsSecurityModuleModel::EPinRequested; + q_ptr->handleStatusCompleted(tempStatus); +#endif + } else { + q_ptr->handleError(KErrArgument); + } + } else { + q_ptr->handleError(KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::setPinCodeRequestState() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::setPinCodeRequestState(int moduleIndex, + bool isRequested) +{ + TRACE2("AdvSecSettingsSecurityModuleModelPrivate::setPinCodeRequestState, moduleIndex=%d isRequested=%d", + moduleIndex, isRequested); + if ((iState == EIdle) && !IsActive()) { + if (moduleIndex >= 0 && moduleIndex < iAuthenticationObjects.Count()) { + iCurrentAuthObject = iAuthenticationObjects[moduleIndex]; + if (isRequested) { + iCurrentAuthObject->Enable(iStatus); + iState = EEnablingPinCodeRequest; + } else { + iCurrentAuthObject->Disable(iStatus); + iState = EDisablingPinCodeRequest; + } + SetActive(); + } else { + q_ptr->handleError(KErrArgument); + } + } else { + q_ptr->handleError(KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::changePinCode() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::changePinCode(int moduleIndex) +{ + TRACE1("AdvSecSettingsSecurityModuleModelPrivate::changePinCode, moduleIndex=%d", moduleIndex); + if ((iState == EIdle) && !IsActive()) { + if (moduleIndex >= 0 && moduleIndex < iAuthenticationObjects.Count()) { + iCurrentAuthObject = iAuthenticationObjects[moduleIndex]; + ChangeCurrentAuthObjectPinCode(); + } else { + q_ptr->handleError(KErrArgument); + } + } else { + q_ptr->handleError(KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::closeModule() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::closeModule(int moduleIndex) +{ + TRACE1("AdvSecSettingsSecurityModuleModelPrivate::closeModule, moduleIndex=%d", moduleIndex); + if ((iState == EIdle) && !IsActive()) { + if (moduleIndex >= 0 && moduleIndex < iAuthenticationObjects.Count()) { + iCurrentAuthObject = iAuthenticationObjects[moduleIndex]; + iCurrentAuthObject->Close(iStatus); + iState = EClosingAuthObject; + SetActive(); + } else { + q_ptr->handleError(KErrArgument); + } + } else { + q_ptr->handleError(KErrInUse); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::isSigningPinSupported() +// --------------------------------------------------------------------------- +// +bool AdvSecSettingsSecurityModuleModelPrivate::isSigningPinSupported(int moduleIndex) const +{ + TRACE1("AdvSecSettingsSecurityModuleModelPrivate::isSigningPinSupported, moduleIndex=%d", + moduleIndex); + if (moduleIndex >= 0 && moduleIndex < iProtectedKeyStores.Count()) { + MCTToken &keyStoreToken = iProtectedKeyStores[moduleIndex]->Token(); + if (keyStoreToken.TokenType().Type().iUid == KAdvSecSettingsFileKeyStore) { + return false; + } else { + return true; + } + } else { + return false; + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::changeSigningPinCode() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::changeSigningPinCode(int /*moduleIndex*/) +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::changeSigningPinCode" ); + + // TODO: implement + q_ptr->handleError(KErrNotSupported); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::isDeletable() +// --------------------------------------------------------------------------- +// +bool AdvSecSettingsSecurityModuleModelPrivate::isDeletable(int moduleIndex) const +{ + TRACE1("AdvSecSettingsSecurityModuleModelPrivate::isDeletable, moduleIndex=%d", + moduleIndex); + if (moduleIndex >= 0 && moduleIndex < iProtectedKeyStores.Count()) { + MCTToken &keyStoreToken = iProtectedKeyStores[moduleIndex]->Token(); + if (keyStoreToken.TokenType().Type().iUid == KAdvSecSettingsFileKeyStore) { + TRACE("AdvSecSettingsSecurityModuleModelPrivate::isDeletable, true"); + return true; + } + } + TRACE("AdvSecSettingsSecurityModuleModelPrivate::isDeletable, false"); + return false; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::deleteModule() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::deleteModule(int moduleIndex) +{ + TRACE1("AdvSecSettingsSecurityModuleModelPrivate::deleteModule, moduleIndex=%d", + moduleIndex); + if (moduleIndex >= 0 && moduleIndex < iProtectedKeyStores.Count()) { + MCTToken &keyStoreToken = iProtectedKeyStores[moduleIndex]->Token(); + if (keyStoreToken.TokenType().Type().iUid == KAdvSecSettingsFileKeyStore) { + TInt err = DoStartDeletingModule(moduleIndex); + if (err) { + q_ptr->handleError(err); + } + } + } else { + q_ptr->handleError(KErrArgument); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::DoCancel() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::DoCancel() +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::DoCancel"); + switch (iState) { + case EInitializing: + iUnifiedKeyStore->CancelInitialize(); + iState = ENotInitialized; + break; + case EListingKeys: + iCurrentKeyStore->CancelList(); + iState = ENotInitialized; + break; + case EReadingTimeRemaining: + iCurrentAuthObject->CancelTimeRemaining(); + iState = EIdle; + break; + case EChangingPinCode: + iCurrentAuthObject->CancelChangeReferenceData(); + iState = EIdle; + break; + case EUnblockingToChangePinCode: + iCurrentAuthObject->CancelUnblock(); + iState = EIdle; + break; + case EEnablingPinCodeRequest: + iCurrentAuthObject->CancelEnable(); + iState = EIdle; + break; + case EDisablingPinCodeRequest: + iCurrentAuthObject->CancelDisable(); + iState = EIdle; + break; + case EClosingAuthObject: + iCurrentAuthObject->CancelClose(); + iState = EIdle; + break; + case EDeletingModule: + delete iModuleEraser; + iModuleEraser = NULL; + break; + default: + break; + } + q_ptr->handleError(KErrCancel); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::RunL() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::RunL() +{ + TRACE2("AdvSecSettingsSecurityModuleModelPrivate::RunL, status=%d state=%d", iStatus.Int(), iState); + User::LeaveIfError(iStatus.Int()); + switch (iState) { + case EInitializing: + TRACE("AdvSecSettingsSecurityModuleModelPrivate::RunL, EInitializing"); + iAuthenticationObjects.Reset(); + iProtectedKeyStores.Reset(); + ListKeysFromFirstKeyStoreL(); + break; + case EListingKeys: + TRACE("AdvSecSettingsSecurityModuleModelPrivate::RunL, EListingKeys"); + AppendKeyStoresWithProtectedKeysL(); + ListKeysFromNextKeyStoreL(); + break; + case EReadingTimeRemaining: + TRACE("AdvSecSettingsSecurityModuleModelPrivate::RunL, EReadingTimeRemaining"); + ReturnModuleStatusL(); + break; + case EChangingPinCode: + TRACE("AdvSecSettingsSecurityModuleModelPrivate::RunL, EChangingPinCode"); + ReturnPinChanged(); + break; + case EUnblockingToChangePinCode: + TRACE("AdvSecSettingsSecurityModuleModelPrivate::RunL, EUnblockingToChangePinCode"); + ChangeCurrentAuthObjectPinCode(); + break; + case EEnablingPinCodeRequest: + case EDisablingPinCodeRequest: + TRACE("AdvSecSettingsSecurityModuleModelPrivate::RunL, EEnabling/DisablingPinCodeRequest"); + ReturnPinRequestStateChanged(); + break; + case EClosingAuthObject: + TRACE("AdvSecSettingsSecurityModuleModelPrivate::RunL, EClosingAuthObject"); + ReturnModuleClosed(); + break; + case EDeletingModule: + TRACE("AdvSecSettingsSecurityModuleModelPrivate::RunL, EDeletingModule"); + ReturnModuleDeleted(); + break; + default: + TRACE("AdvSecSettingsSecurityModuleModelPrivate::RunL, default"); + ASSERT(EFalse); + break; + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::RunError() +// --------------------------------------------------------------------------- +// +TInt AdvSecSettingsSecurityModuleModelPrivate::RunError(TInt aError) +{ + TRACE1("AdvSecSettingsSecurityModuleModelPrivate::RunError, aError=%d", aError); + q_ptr->handleError(aError); + return KErrNone; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::ConstructL() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::ConstructL() +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::ConstructL"); + User::LeaveIfError(iFs.Connect()); + iUnifiedKeyStore = CUnifiedKeyStore::NewL(iFs); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::ListKeysFromFirstKeyStoreL() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::ListKeysFromFirstKeyStoreL() +{ + TRACE1("AdvSecSettingsSecurityModuleModelPrivate::ListKeysFromFirstKeyStoreL, count=%d", + iUnifiedKeyStore->KeyStoreCount()); + iKeyStoreIndex = 0; + ListKeysFromOneKeyStoreL(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::ListKeysFromOneKeyStoreL() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::ListKeysFromOneKeyStoreL() +{ + TRACE1("AdvSecSettingsSecurityModuleModelPrivate::ListKeysFromOneKeyStoreL, index=%d", + iKeyStoreIndex); + if (iKeyStoreIndex < iUnifiedKeyStore->KeyStoreCount()) { + iKeys.Close(); + if (!iAllKeysFilter) { + iAllKeysFilter = new( ELeave ) TCTKeyAttributeFilter; + iAllKeysFilter->iPolicyFilter = TCTKeyAttributeFilter::EAllKeys; + } + iCurrentKeyStore = &(iUnifiedKeyStore->KeyStore(iKeyStoreIndex)); + iCurrentKeyStore->List(iKeys, *iAllKeysFilter, iStatus); + iState = EListingKeys; + SetActive(); + } else { + iState = EIdle; + q_ptr->handleInitializeCompleted(); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::ListKeysFromNextKeyStoreL() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::ListKeysFromNextKeyStoreL() +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::ListKeysFromNextKeyStoreL"); + ++iKeyStoreIndex; + ListKeysFromOneKeyStoreL(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::AppendKeyStoresWithProtectedKeysL() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::AppendKeyStoresWithProtectedKeysL() +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::AppendKeyStoresWithProtectedKeysL"); + for (TInt index = 0; index < iKeys.Count(); index++) { + const CCTKeyInfo &keyInfo = *(iKeys[index]); + if (keyInfo.Protector()) { + TRACE("AdvSecSettingsSecurityModuleModelPrivate::AppendKeyStoresWithProtectedKeysL, added"); + iAuthenticationObjects.AppendL(keyInfo.Protector()); + iProtectedKeyStores.AppendL(&(iUnifiedKeyStore->KeyStore(iKeyStoreIndex))); + } + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::ChangeCurrentAuthObjectPinCode() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::ChangeCurrentAuthObjectPinCode() +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::ChangeCurrentAuthObjectPinCode"); + TInt32 currentAuthObjectStatus = iCurrentAuthObject->Status(); + if (currentAuthObjectStatus & EAuthObjectBlocked) { + TRACE("AdvSecSettingsSecurityModuleModelPrivate::ChangeCurrentAuthObjectPinCode, blocked"); + if (currentAuthObjectStatus & EUnblockDisabled) { + TRACE("AdvSecSettingsSecurityModuleModelPrivate::ChangeCurrentAuthObjectPinCode, permanently"); + iState = EIdle; + q_ptr->handleError(KErrPermissionDenied); + } else { + TRACE("AdvSecSettingsSecurityModuleModelPrivate::ChangeCurrentAuthObjectPinCode, unblocking"); + iCurrentAuthObject->Unblock(iStatus); + iState = EUnblockingToChangePinCode; + SetActive(); + } + } else { + if (currentAuthObjectStatus & EChangeDisabled) { + TRACE("AdvSecSettingsSecurityModuleModelPrivate::ChangeCurrentAuthObjectPinCode, cannot change"); + iState = EIdle; + q_ptr->handleError(KErrPermissionDenied); + } else { + TRACE("AdvSecSettingsSecurityModuleModelPrivate::ChangeCurrentAuthObjectPinCode, changing pin"); + iCurrentAuthObject->ChangeReferenceData(iStatus); + iState = EChangingPinCode; + SetActive(); + } + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::DoStartDeletingModule() +// --------------------------------------------------------------------------- +// +TInt AdvSecSettingsSecurityModuleModelPrivate::DoStartDeletingModule(TInt aModuleIndex) +{ + if (!iModuleEraser) { + TRAPD(err, iModuleEraser = CAdvSecSettingsSecurityModuleEraser::NewL(*iUnifiedKeyStore)); + if (err) { + return err; + } + } + iModuleEraser->Erase(aModuleIndex, iStatus); + iState = EDeletingModule; + SetActive(); + return KErrNone; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::ReturnModuleStatusL() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::ReturnModuleStatusL() +{ + int advSecSettingsStatus = 0; + + TUint32 currentTCTAuthenticationStatus = iCurrentAuthObject->Status(); + if (currentTCTAuthenticationStatus & EUnblockDisabled) { + advSecSettingsStatus |= AdvSecSettingsSecurityModuleModel::EBlockedPermanently; + } + if (currentTCTAuthenticationStatus & EAuthObjectBlocked) { + advSecSettingsStatus |= AdvSecSettingsSecurityModuleModel::EPinBlocked; + } + advSecSettingsStatus |= AdvSecSettingsSecurityModuleModel::EPinChangeAllowed; + if (currentTCTAuthenticationStatus & EChangeDisabled) { + advSecSettingsStatus ^= AdvSecSettingsSecurityModuleModel::EPinChangeAllowed; + } + if (currentTCTAuthenticationStatus & EEnabled) { + advSecSettingsStatus |= AdvSecSettingsSecurityModuleModel::EPinRequested; + } + if (iTimeRemaining > 0) { + advSecSettingsStatus |= AdvSecSettingsSecurityModuleModel::EPinEntered; + } + + TRACE1("AdvSecSettingsSecurityModuleModelPrivate::ReturnModuleStatusL 0x%08x", + advSecSettingsStatus); + iState = EIdle; + q_ptr->handleStatusCompleted(advSecSettingsStatus); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::ReturnPinChanged() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::ReturnPinChanged() +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::ReturnPinChanged"); + iState = EIdle; + q_ptr->handlePinCodeChanged(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::ReturnPinRequestStateChanged() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::ReturnPinRequestStateChanged() +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::ReturnPinRequestStateChanged"); + iState = EIdle; + q_ptr->handlePinCodeRequestSet(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::ReturnModuleClosed() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::ReturnModuleClosed() +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::ReturnModuleClosed"); + iState = EIdle; + q_ptr->handleModuleClosed(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleModelPrivate::ReturnModuleDeleted() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleModelPrivate::ReturnModuleDeleted() +{ + TRACE("AdvSecSettingsSecurityModuleModelPrivate::ReturnModuleDeleted"); + iState = EIdle; + q_ptr->handleModuleDeleted(); +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymoduleview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingssecuritymoduleview.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,226 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Security module view in advanced security settings. +* +*/ + +#include "advsecsettingssecuritymoduleview.h" +#include "advsecsettingssecuritymodulemodel.h" +#include +#include +#include +#include +#include +#include + +const QString KEchoModeProperty = "echoMode"; +const QString KTextProperty = "text"; +const QString KAdditionalTextProperty = "additionalText"; +const QString KReadOnlyProperty = "readOnly"; +const QString KPasswordValue = "****"; + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleView::AdvSecSettingsSecurityModuleView() +// --------------------------------------------------------------------------- +// +AdvSecSettingsSecurityModuleView::AdvSecSettingsSecurityModuleView( + AdvSecSettingsSecurityModuleModel &model, QGraphicsItem *parent) : + AdvSecSettingsViewBase(0, parent), mModel(model), mViewLabel(0), + mModulePin(0), mModulePinRequested(0), mModuleStatus(0), mSigningPin(0), + mModelIndex(0) +{ + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); + + // View title + mViewLabel = new HbGroupBox; + layout->addItem(mViewLabel); + + HbDataForm *dataForm = new HbDataForm; + mDataFormModel = new HbDataFormModel; + HbDataFormModelItem *rootItem = mDataFormModel->invisibleRootItem(); + + // Module PIN + // TODO: localized UI strings needed + HbDataFormModelItem *moduleGroup = 0; + moduleGroup = mDataFormModel->appendDataFormGroup(tr("Module PIN"), rootItem); + mModulePin = mDataFormModel->appendDataFormItem(HbDataFormModelItem::TextItem, + tr("PIN code"), moduleGroup); + mModulePin->setContentWidgetData(KEchoModeProperty, HbLineEdit::Password); + mModulePin->setContentWidgetData(KTextProperty, KPasswordValue); + mModulePin->setContentWidgetData(KReadOnlyProperty, true); + + // Module PIN Request + mModulePinRequested = mDataFormModel->appendDataFormItem( + HbDataFormModelItem::ToggleValueItem, tr("PIN code required"), moduleGroup); + mModulePinRequested->setContentWidgetData(KTextProperty, tr("On")); + //mModulePinRequested->setContentWidgetData(KAdditionalTextProperty, tr("Changing...")); + // TODO: remove + mModulePinRequested->setEnabled(false); + + // Module Status + mModuleStatus = mDataFormModel->appendDataFormItem( + HbDataFormModelItem::ToggleValueItem, tr("Status"), moduleGroup); + mModuleStatus->setContentWidgetData(KTextProperty, tr("Closed")); + mModuleStatus->setEnabled(false); + + dataForm->setModel(mDataFormModel); + layout->addItem(dataForm); + setLayout(layout); + + connect(dataForm, SIGNAL(activated(const QModelIndex &)), + this, SLOT(itemActivated(const QModelIndex &))); + connect(&mModel, SIGNAL(statusCompleted(int)), this, SLOT(moduleStatusChanged(int))); + connect(&mModel, SIGNAL(statusChanged(int)), this, SLOT(moduleStatusChanged(int))); + connect(&mModel, SIGNAL(pinCodeRequestStateCompleted()), this, SLOT(updateModuleStatus())); + connect(&mModel, SIGNAL(pinCodeChangeCompleted()), this, SLOT(updateModuleStatus())); + connect(&mModel, SIGNAL(closeCompleted()), this, SLOT(updateModuleStatus())); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleView::~AdvSecSettingsSecurityModuleView() +// --------------------------------------------------------------------------- +// +AdvSecSettingsSecurityModuleView::~AdvSecSettingsSecurityModuleView() +{ +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleView::setSecurityModule() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleView::setSecurityModule(const QString &moduleTitle, + int modelIndex) +{ + mViewLabel->setHeading(moduleTitle); + mModelIndex = modelIndex; + + // Signing PIN + if (mModel.isSigningPinSupported(mModelIndex)) { + if (!mSigningPin) { + HbDataFormModelItem *rootItem = mDataFormModel->invisibleRootItem(); + HbDataFormModelItem *signingGroup = 0; + signingGroup = mDataFormModel->appendDataFormGroup(tr("Signing PIN"), rootItem); + mSigningPin = mDataFormModel->appendDataFormItem(HbDataFormModelItem::TextItem, + tr("PIN code"), signingGroup); + mSigningPin->setContentWidgetData(KEchoModeProperty, HbLineEdit::Password); + mSigningPin->setContentWidgetData(KTextProperty, KPasswordValue); + mSigningPin->setContentWidgetData(KReadOnlyProperty, true); + } + } else { + if (mSigningPin) { + mDataFormModel->removeItem(mSigningPin); + mSigningPin = 0; + } + } + + updateModuleStatus(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleView::updateModuleStatus() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleView::updateModuleStatus() +{ + mModel.getModuleStatus(mModelIndex); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleView::moduleStatusChanged() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleView::moduleStatusChanged(int status) +{ + // TODO: localized UI strings needed + if (status & AdvSecSettingsSecurityModuleModel::EBlockedPermanently) { + mModulePinRequested->setContentWidgetData(KTextProperty, tr("Blocked")); + mModulePinRequested->setEnabled(false); + } else if (status & AdvSecSettingsSecurityModuleModel::EPinBlocked) { + mModulePinRequested->setContentWidgetData(KTextProperty, tr("Blocked")); + // TODO: mModulePinRequested->setEnabled(true); + mModulePinRequested->setEnabled(false); + } else { + if (status & AdvSecSettingsSecurityModuleModel::EPinRequested) { + mModulePinRequested->setContentWidgetData(KTextProperty, tr("On")); + } else { + mModulePinRequested->setContentWidgetData(KTextProperty, tr("Off")); + } + if (status & AdvSecSettingsSecurityModuleModel::EPinChangeAllowed) { + // TODO: + //mModulePinRequested->setContentWidgetData(KAdditionalTextProperty, tr("Changing...")); + //mModulePinRequested->setEnabled(true); + mModulePinRequested->setEnabled(false); + } else { + mModulePinRequested->setContentWidgetData(KAdditionalTextProperty, QString()); + mModulePinRequested->setEnabled(false); + } + } + if (status & AdvSecSettingsSecurityModuleModel::EPinEntered) { + mModuleStatus->setContentWidgetData(KTextProperty, tr("Open")); + // TODO: + //mModuleStatus->setContentWidgetData(KAdditionalTextProperty, tr("Closing...")); + //mModuleStatus->setEnabled(true); + mModuleStatus->setEnabled(false); + } else { + mModuleStatus->setContentWidgetData(KTextProperty, tr("Closed")); + mModuleStatus->setContentWidgetData(KAdditionalTextProperty, QString()); + mModuleStatus->setEnabled(false); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsSecurityModuleView::itemActivated() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsSecurityModuleView::itemActivated(const QModelIndex &/*itemIndex*/) +{ + // TODO: this does not work yet +#if 0 + bool isOperationStarted = false; + HbDataFormModelItem *item = mDataFormModel->itemFromIndex(itemIndex); + if (item == mModulePin) { + mModel.changePinCode(mModelIndex); + isOperationStarted = true; + } else if (item == mModulePinRequested) { + QString contentData = mModulePinRequested->contentWidgetData(KTextProperty).toString(); + bool enable = (contentData != tr("On")); + mModel.setPinCodeRequestState(mModelIndex, enable); + isOperationStarted = true; + } else if (item == mModuleStatus) { + QString contentData = mModulePinRequested->contentWidgetData(KTextProperty).toString(); + bool isClosed = (contentData == tr("Closed")); + if (!isClosed) { + mModel.closeModule(mModelIndex); + isOperationStarted = true; + } + } else if (item == mSigningPin) { + mModel.changeSigningPinCode(mModelIndex); + isOperationStarted = true; + } else { + // ignored, one of the group titles + } + if (isOperationStarted) { + mModulePin->setEnabled(false); + mModulePinRequested->setEnabled(false); + mModuleStatus->setEnabled(false); + if (mSigningPin) { + mSigningPin->setEnabled(false); + } + } +#endif +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/advsecsettingsviewbase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpsecplugins/cpadvancedsecplugin/src/advsecsettingsviewbase.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -0,0 +1,170 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Base class for advanced security settings views +* +*/ + +#include "advsecsettingsviewbase.h" +#include +#include +#include +#include + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// AdvSecSettingsViewBase::AdvSecSettingsViewBase() +// --------------------------------------------------------------------------- +// +AdvSecSettingsViewBase::AdvSecSettingsViewBase(QGraphicsWidget *widget, + QGraphicsItem *parent) : CpBaseSettingView(widget, parent), mPreviousView(0), + mItemSpecificMenu(0), mDeleteOnClose(false) +{ + connect(this, SIGNAL(aboutToClose()), this, SLOT(displayPreviousView())); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsViewBase::AdvSecSettingsViewBase() +// --------------------------------------------------------------------------- +// +AdvSecSettingsViewBase::~AdvSecSettingsViewBase() +{ + delete mItemSpecificMenu; + mItemSpecificMenu = 0; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsViewBase::displayPreviousView() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsViewBase::displayPreviousView() +{ + if (mPreviousView) { + HbMainWindow &window = *mainWindow(); + HbView *currentView = window.currentView(); + window.setCurrentView(mPreviousView); + mPreviousView = 0; + if (mDeleteOnClose) { + window.removeView(currentView); + currentView->deleteLater(); + } + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsViewBase::displayError() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsViewBase::displayError(int error) +{ + HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning); + messageBox->setAttribute(Qt::WA_DeleteOnClose); + messageBox->setStandardButtons(HbMessageBox::Ok); + + // TODO: proper error texts, localised UI texts needed + QString text = tr("Error %1").arg(error); + messageBox->setText(text); + messageBox->open(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsViewBase::displayView() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsViewBase::displayView(AdvSecSettingsViewBase *view) +{ + HbMainWindow &window = *mainWindow(); + QList addedViews = window.views(); + if (!addedViews.contains(view)) { + window.addView(view); + } + view->mPreviousView = window.currentView(); + window.setCurrentView(view); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsViewBase::hasPreviousView() +// --------------------------------------------------------------------------- +// +bool AdvSecSettingsViewBase::hasPreviousView() const +{ + return (mPreviousView != 0); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsViewBase::setDeleteOnClose() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsViewBase::setDeleteOnClose(bool deleteOnClose) +{ + mDeleteOnClose = deleteOnClose; +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsViewBase::clearItemSpecificMenu() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsViewBase::clearItemSpecificMenu() +{ + if (!mItemSpecificMenu) { + mItemSpecificMenu = new HbMenu; + } else { + mItemSpecificMenu->clearActions(); + } +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsViewBase::addItemSpecificMenuAction() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsViewBase::addItemSpecificMenuAction(const QString &text, + const QObject *receiver, const char *member) +{ + HbAction *action = new HbAction(text); + connect(action, SIGNAL(triggered()), receiver, member); + mItemSpecificMenu->addAction(action); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsViewBase::displayItemSpecificMenu() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsViewBase::displayItemSpecificMenu(const QPointF &position) +{ + mItemSpecificMenu->setPreferredPos(position); + mItemSpecificMenu->open(); +} + +// --------------------------------------------------------------------------- +// AdvSecSettingsViewBase::displayQuestionNote() +// --------------------------------------------------------------------------- +// +void AdvSecSettingsViewBase::displayQuestionNote(const QString &text, + const QObject *receiver, const char *accepedMember) +{ + HbMessageBox *messageBox = new HbMessageBox; + messageBox->setAttribute(Qt::WA_DeleteOnClose); + + messageBox->clearActions(); + HbAction *yesAction = new HbAction(hbTrId("txt_common_button_yes")); + connect(yesAction, SIGNAL(triggered()), receiver, accepedMember); + messageBox->addAction(yesAction); + HbAction *noAction = new HbAction(hbTrId("txt_common_button_no")); + messageBox->addAction(noAction); + + messageBox->setText(text); + messageBox->open(); +} + diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/cpcertdatacontainer.cpp --- a/cpsecplugins/cpadvancedsecplugin/src/cpcertdatacontainer.cpp Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,757 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation of class CCertManUIKeeper -* Creates and destroys all the views CertManUI uses. -* Handles changing CertManUI views. -* -*/ - - -// INCLUDE FILES -#include -#include -#include -#include - -#include - -#include -#include <../../inc/cpsecplugins.h> -#include "cpcertdatacontainer.h" -#include "cpcertmanuisyncwrapper.h" - -// CONSTANTS -_LIT( KNameSeparator, " " ); - -// ============================= LOCAL FUNCTIONS =============================== - -// ----------------------------------------------------------------------------- -// TInt CompareCALabels( const CCTCertInfo& cert1, const CCTCertInfo& cert2 ) -// Compares two labels. -// ----------------------------------------------------------------------------- -// -TInt CompareCALabels( - const CpCertManUICertData& cert1, - const CpCertManUICertData& cert2 ) - { - return ( (cert1.iCAEntryLabel->Des()). - CompareF( cert2.iCAEntryLabel->Des() ) ); - } - -// ----------------------------------------------------------------------------- -// TInt CompareUserLabels( const CCTCertInfo& cert1, const CCTCertInfo& cert2 ) -// Compares two labels. -// ----------------------------------------------------------------------------- -// -TInt CompareUserLabels( - const CpCertManUICertData& cert1, - const CpCertManUICertData& cert2 ) - { - return ( (cert1.iUserEntryLabel->Des()). - CompareF( cert2.iUserEntryLabel->Des() ) ); - } - -// ----------------------------------------------------------------------------- -// TInt ComparePeerLabels( const CCTCertInfo& cert1, const CCTCertInfo& cert2 ) -// Compares two labels. -// ----------------------------------------------------------------------------- -// -TInt ComparePeerLabels( - const CpCertManUICertData& cert1, - const CpCertManUICertData& cert2 ) - { - return ( (cert1.iPeerEntryLabel->Des()). - CompareF( cert2.iPeerEntryLabel->Des() ) ); - } - -// ----------------------------------------------------------------------------- -// TInt CompareDeviceLabels( const CCTCertInfo& cert1, const CCTCertInfo& cert2 ) -// Compares two labels. -// ----------------------------------------------------------------------------- -// -TInt CompareDeviceLabels( - const CpCertManUICertData& cert1, - const CpCertManUICertData& cert2 ) - { - return ( (cert1.iDeviceEntryLabel->Des()). - CompareF( cert2.iDeviceEntryLabel->Des() ) ); - } - - -// ================= HELPER CLASS =========================== - -// Constructor. -CpCertManUICertData::CpCertManUICertData() - { - } - -// Destructor. -CpCertManUICertData::~CpCertManUICertData() - { - delete iCAEntryLabel; - delete iUserEntryLabel; - delete iPeerEntryLabel; - delete iDeviceEntryLabel; - } - -// Releases Certificate entries. -void CpCertManUICertData::Release() - { - RDEBUG("0", 0); - if ( iCAEntry ) - { - iCAEntry->Release(); - } - - if ( iUserEntry ) - { - iUserEntry->Release(); - } - - if ( iPeerEntry ) - { - iPeerEntry->Release(); - } - - if ( iDeviceEntry ) - { - iDeviceEntry->Release(); - } - - delete this; - } - -// ================= MEMBER FUNCTIONS ======================= - -// --------------------------------------------------------- -// CCertManUIKeeper::CCertManUIKeeper() -// Constructor with parent -// --------------------------------------------------------- -// -CpCertDataContainer::CpCertDataContainer() - { - } - -// --------------------------------------------------------- -// CCertManUIKeeper::~CCertManUIKeeper() -// Destructor -// --------------------------------------------------------- -// -CpCertDataContainer::~CpCertDataContainer() - { - iCALabelEntries.Close(); - iUserLabelEntries.Close(); - iPeerLabelEntries.Close(); - iDeviceLabelEntries.Close(); - - if ( iWrapper ) - { - iWrapper->Cancel(); - } - delete iWrapper; - - delete iFilter; - delete iKeyFilter; - delete iStore; - delete iKeyStore; - - iCAEntries.Close(); - iUserEntries.Close(); - iPeerEntries.Close(); - iDeviceEntries.Close(); - iKeyEntries.Close(); - - iRfs.Close(); - } - -// --------------------------------------------------------- -// CCertManUIKeeper* CCertManUIKeeper::NewL(const TRect& aRect, TUid aViewId) -// --------------------------------------------------------- -// - -CpCertDataContainer* CpCertDataContainer::NewL() - { - CpCertDataContainer* self = new ( ELeave ) CpCertDataContainer; - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// --------------------------------------------------------- -// CCertManUIKeeper* CCertManUIKeeper::NewLC( -// const TRect& aRect, TUid aViewId) -// --------------------------------------------------------- -// -CpCertDataContainer* CpCertDataContainer::NewLC() - { - CpCertDataContainer* self = new ( ELeave ) CpCertDataContainer; - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - - -// --------------------------------------------------------- -// CCertManUIKeeper::ConstructL( - // const TRect& aRect, TUid aViewId -// -// --------------------------------------------------------- -// -void CpCertDataContainer::ConstructL() - { - RDEBUG("0", 0); - // Ensure that file server session is succesfully created - User::LeaveIfError( iRfs.Connect() ); - - TRAPD ( error, iStore = CUnifiedCertStore::NewL( iRfs, ETrue ) ); - - if ( error == KErrNotSupported || error == KErrNotReady - || error == KErrArgument || error == KErrNotFound ) - { - // Something may be wrong with the databases - ShowErrorNoteL( error ); - } - - User::LeaveIfError( error ); - - iWrapper = CpCertManUISyncWrapper::NewL(); - iWrapper->InitStoreL( iStore ); - - iFilter = CCertAttributeFilter::NewL(); - - TRAP( error, iKeyStore = CUnifiedKeyStore::NewL( iRfs ) ); - - if (error == KErrNotSupported || error == KErrNotReady - || error == KErrArgument || error == KErrNotFound) - { - // Something is wrong with key stores - ShowErrorNoteL( error ); - } - - User::LeaveIfError( error ); - - iWrapper->InitStoreL( iKeyStore ); - iKeyEntries.Close(); - - } - - -// --------------------------------------------------------- -// CCertManUIKeeper::CertManager() -// --------------------------------------------------------- -// -CUnifiedCertStore*& CpCertDataContainer::CertManager() - { - return iStore; - } - -// --------------------------------------------------------- -// CCertManUIKeeper::KeyManager() -// --------------------------------------------------------- -// -CUnifiedKeyStore*& CpCertDataContainer::KeyManager() - { - return iKeyStore; - } - -// --------------------------------------------------------- -// CCertManUIKeeper::RefreshCAEntriesL() -// Checks that cacerts.dat file is not corrupted and -// returns CA certificates from it -// --------------------------------------------------------- -// -void CpCertDataContainer::RefreshCAEntriesL() - { - RDEBUG("0", 0); - iFilter->SetOwnerType( ECACertificate ); - iCAEntries.Close(); - CUnifiedCertStore*& store = CertManager(); - iWrapper->ListL( store, &iCAEntries, *iFilter ); - - iCALabelEntries.Close(); - for ( TInt ii = 0; ii < iCAEntries.Count(); ii++ ) - { - switch ( iCAEntries[ii]->CertificateFormat() ) - { - case EX509Certificate: - { - CpCertManUICertData* data = new ( ELeave ) CpCertManUICertData(); - CleanupStack::PushL( data ); - data->iCAEntry = CCTCertInfo::NewL( *iCAEntries[ii] ); - - HBufC* pri = NULL; - HBufC* sec = NULL; - - CCertificate* cert; - - TRAPD(err, iWrapper->GetCertificateL( CertManager(), *iCAEntries[ii], cert )); - if (( err == KErrArgument ) || ( err == KErrCorrupt )) - { - // This indicates that certificate is not according to X509 - // specification or it is corrupted. Ignore certificate - if(data->iCAEntry) - { - data->iCAEntry->Release(); - } - CleanupStack::PopAndDestroy( data ); // data - continue; - } - else - { - User::LeaveIfError( err ); - } - - CleanupStack::PushL( cert ); - - X509CertNameParser::PrimaryAndSecondaryNameL - ( *((CX509Certificate*)cert), pri, sec, iCAEntries[ii]->Label()); - - CleanupStack::PushL( pri ); - CleanupStack::PushL( sec ); - - TInt lenght = 0; - - lenght += iCAEntries[ii]->Label().Length(); - - if ( pri ) - { - lenght += pri->Length(); - } - if ( sec && !(iCAEntries[ii]->Label().Length()) ) - { - lenght += sec->Length(); - } - lenght += KNameSeparator.iTypeLength; - - HBufC* label = HBufC::NewL( lenght ); - label->Des().Append( iCAEntries[ii]->Label() ); - - if ( pri ) - { - label->Des().Append( KNameSeparator ); - label->Des().Append( pri->Des() ); - } - if ( sec && !(iCAEntries[ii]->Label().Length()) ) - { - label->Des().Append( sec->Des() ); - } - - data->iCAEntryLabel = label; - iCALabelEntries.Append( data ); - - CleanupStack::PopAndDestroy( 3, cert ); // pri, sec - CleanupStack::Pop( data ); - break; - } // EX509Certificate - - case EWTLSCertificate: - // Do nothing for wtls certificates - break; - default: - { - User::Leave( KErrNotSupported ); - } - } // switch - - } // for - - // Sort the certificates. - TLinearOrder order( CompareCALabels ); - iCALabelEntries.Sort( order ); - - } - -// --------------------------------------------------------- -// CCertManUIKeeper::RefreshPeerCertEntriesL() -// Checks that Trusted site certificate store is -// not corrupted and returns Peer certificates from it -// --------------------------------------------------------- -// -void CpCertDataContainer::RefreshPeerCertEntriesL() - { - RDEBUG("0", 0); - iFilter->SetOwnerType( EPeerCertificate ); - iPeerEntries.Close(); - CUnifiedCertStore*& store = CertManager(); - - iWrapper->ListL( store, &iPeerEntries, *iFilter, KCMTrustedServerTokenUid ); - - iPeerLabelEntries.Close(); - - for ( TInt ii = 0; ii < iPeerEntries.Count(); ii++ ) - { - switch ( iPeerEntries[ii]->CertificateFormat() ) - { - case EX509Certificate: - { - CpCertManUICertData* data = new (ELeave) CpCertManUICertData(); - CleanupStack::PushL( data ); - data->iPeerEntry = CCTCertInfo::NewL( *iPeerEntries[ii] ); - - CCertificate* cert; - - TRAPD( err, iWrapper->GetCertificateL( CertManager(), *iPeerEntries[ii], cert, KCMTrustedServerTokenUid )); - if (( err == KErrArgument ) || ( err == KErrCorrupt )) - { - // This indicates that certificate is not according to X509 - // specification or it is corrupted. Ignore certificate - if( data->iPeerEntry ) - { - data->iPeerEntry->Release(); - } - CleanupStack::PopAndDestroy( data ); // data - continue; - } - else - { - User::LeaveIfError( err ); - } - - CleanupStack::PushL( cert ); - - TInt lenght = 0; - - lenght += iPeerEntries[ii]->Label().Length(); - - HBufC* label = HBufC::NewL( lenght ); - label->Des().Append( iPeerEntries[ii]->Label() ); - - data->iPeerEntryLabel = label; - iPeerLabelEntries.Append( data ); - - CleanupStack::PopAndDestroy( cert ); // cert - CleanupStack::Pop( data ); // data - break; - } // EX509Certificate - - case EWTLSCertificate: - // Do nothing for wtls certificates - break; - default: - { - User::Leave( KErrNotSupported ); - } - } // switch - - } // for - - // Sort the certificates. - TLinearOrder order( ComparePeerLabels ); - iPeerLabelEntries.Sort( order ); - - } - - -// --------------------------------------------------------- -// CCertManUIKeeper::RefreshUserCertEntriesL() -// Checks that cacerts.dat file is not corrupted and -// returns User certificates from it -// --------------------------------------------------------- -// -void CpCertDataContainer::RefreshUserCertEntriesL() - { - RDEBUG("0", 0); - iFilter->SetOwnerType( EUserCertificate ); - iUserEntries.Close(); - CUnifiedCertStore*& store = CertManager(); - iWrapper->ListL( store, &iUserEntries, *iFilter ); - - iUserLabelEntries.Close(); - - for ( TInt i = 0; i < iUserEntries.Count(); i++ ) - { - - if ( iUserEntries[i]->Handle().iTokenHandle.iTokenTypeUid == KCMDeviceCertStoreTokenUid ) - { - // User certificates from DeviceCertStore are not - // shown in Personal certificate view. Ignore this certificate. - break; - } - - switch ( iUserEntries[i]->CertificateFormat() ) - { - case EX509Certificate: - { - CpCertManUICertData* data = new (ELeave) CpCertManUICertData(); - CleanupStack::PushL( data ); - data->iUserEntry = CCTCertInfo::NewL( *iUserEntries[i] ); - - HBufC* pri = NULL; - HBufC* sec = NULL; - - CCertificate* cert = NULL; - TRAPD(error, iWrapper->GetCertificateL( CertManager(), *iUserEntries[i], cert )); - - if( error == KErrArgument) - { - CleanupStack::PopAndDestroy( data ); - break; - } - else if ( error != KErrNone ) - { - User::Leave( error ); - } - else - { - CleanupStack::PushL( cert ); - } - - X509CertNameParser::PrimaryAndSecondaryNameL - ( *((CX509Certificate*)cert), pri, sec, iUserEntries[i]->Label()); - - CleanupStack::PushL( pri ); - CleanupStack::PushL( sec ); - - TInt lenght = 0; - - lenght += iUserEntries[i]->Label().Length(); - - if ( pri ) - { - lenght += pri->Length(); - } - if ( sec && !(iUserEntries[i]->Label().Length()) ) - { - lenght += sec->Length(); - } - lenght += KNameSeparator.iTypeLength; - - HBufC* label = HBufC::NewL( lenght ); - label->Des().Append( iUserEntries[i]->Label() ); - - if ( pri ) - { - label->Des().Append( KNameSeparator ); - label->Des().Append( pri->Des() ); - } - if ( sec && !(iUserEntries[i]->Label().Length()) ) - { - label->Des().Append( sec->Des() ); - } - - data->iUserEntryLabel = label; - iUserLabelEntries.Append( data ); - - CleanupStack::PopAndDestroy( 3, cert ); // pri, sec - CleanupStack::Pop( data ); // data - break; - } // EX509Certificate - - case EX509CertificateUrl: - { - CpCertManUICertData* urlCertData = new (ELeave) CpCertManUICertData(); - CleanupStack::PushL( urlCertData ); - urlCertData->iUserEntry = CCTCertInfo::NewL( *iUserEntries[i] ); - - CCertificate* cert = NULL; - TRAPD(error, iWrapper->GetCertificateL( CertManager(), *iUserEntries[i], cert )); - if( error == KErrArgument ) - { - CleanupStack::PopAndDestroy( urlCertData ); // urlCertData - break; - } - else if ( error != KErrNone ) - { - User::Leave(error); - } - else - { - CleanupStack::PushL( cert ); - } - - _LIT(KUrlUserCert, "URL UserCert"); - HBufC* UrlLabel = HBufC::NewL( KUrlUserCert().Length() ); - UrlLabel->Des().Append( KUrlUserCert()); - - urlCertData->iUserEntryLabel = UrlLabel; - iUserLabelEntries.Append( urlCertData ); - - CleanupStack::PopAndDestroy( cert ); // cert - CleanupStack::Pop( urlCertData ); // data - break; - } - } // switch - - } // for - - // Sort the certificates. - TLinearOrder order( CompareUserLabels ); - iUserLabelEntries.Sort( order ); - - } - -// --------------------------------------------------------- -// CCertManUIKeeper::RefreshDeviceCertEntriesL() -// returns device certificates -// --------------------------------------------------------- -// -void CpCertDataContainer::RefreshDeviceCertEntriesL() - { - RDEBUG("0", 0); - iFilter->SetOwnerType( EUserCertificate ); - iDeviceEntries.Close(); - CUnifiedCertStore*& store = CertManager(); - - iWrapper->ListL( store, &iDeviceEntries, *iFilter, KCMDeviceCertStoreTokenUid ); - - iDeviceLabelEntries.Close(); - for ( TInt i = 0; i < iDeviceEntries.Count(); i++ ) - { - switch ( iDeviceEntries[i]->CertificateFormat() ) - { - case EX509Certificate: - { - CpCertManUICertData* data = new (ELeave) CpCertManUICertData(); - CleanupStack::PushL( data ); - data->iDeviceEntry = CCTCertInfo::NewL( *iDeviceEntries[i] ); - - HBufC* pri = NULL; - HBufC* sec = NULL; - - CCertificate* cert = NULL; - TRAPD(error, iWrapper->GetCertificateL( CertManager(), *iDeviceEntries[i], cert, KCMDeviceCertStoreTokenUid )); - - if( error == KErrArgument) - { - CleanupStack::PopAndDestroy( data ); - break; - } - else if ( error != KErrNone ) - { - User::Leave( error ); - } - else - { - CleanupStack::PushL( cert ); - } - - X509CertNameParser::PrimaryAndSecondaryNameL - ( *((CX509Certificate*)cert), pri, sec, iDeviceEntries[i]->Label()); - - CleanupStack::PushL( pri ); - CleanupStack::PushL( sec ); - - TInt lenght = 0; - - lenght += iDeviceEntries[i]->Label().Length(); - - if ( pri ) - { - lenght += pri->Length(); - } - if ( sec && !(iDeviceEntries[i]->Label().Length()) ) - { - lenght += sec->Length(); - } - lenght += KNameSeparator.iTypeLength; - - HBufC* label = HBufC::NewL( lenght ); - label->Des().Append( iDeviceEntries[i]->Label() ); - - if ( pri ) - { - label->Des().Append( KNameSeparator ); - label->Des().Append( pri->Des() ); - } - if ( sec && !(iDeviceEntries[i]->Label().Length()) ) - { - label->Des().Append( sec->Des() ); - } - - data->iDeviceEntryLabel = label; - iDeviceLabelEntries.Append( data ); - - CleanupStack::PopAndDestroy( 3, cert ); // pri, sec - CleanupStack::Pop( data ); // data - break; - } // EX509Certificate - - case EX509CertificateUrl: - { - CpCertManUICertData* urlCertData = new (ELeave) CpCertManUICertData(); - CleanupStack::PushL( urlCertData ); - urlCertData->iDeviceEntry = CCTCertInfo::NewL( *iDeviceEntries[i] ); - - CCertificate* cert = NULL; - TRAPD(error, iWrapper->GetCertificateL( CertManager(), *iDeviceEntries[i], cert, KCMDeviceCertStoreTokenUid )); - if( error == KErrArgument) - { - CleanupStack::PopAndDestroy( urlCertData ); // urlCertData - break; - } - else if ( error != KErrNone ) - { - User::Leave(error); - } - else - { - CleanupStack::PushL( cert ); - } - - _LIT(KUrlUserCert, "URL UserCert"); - HBufC* UrlLabel = HBufC::NewL( KUrlUserCert().Length() ); - UrlLabel->Des().Append( KUrlUserCert()); - - - urlCertData->iDeviceEntryLabel = UrlLabel; - iDeviceLabelEntries.Append( urlCertData ); - - CleanupStack::PopAndDestroy( cert ); // cert - CleanupStack::Pop( urlCertData ); // data - break; - } - } // switch - - } // for - - // Sort the certificates. - TLinearOrder order( CompareDeviceLabels ); - iDeviceLabelEntries.Sort( order ); - - } - -// --------------------------------------------------------- -// CCertManUIKeeper::ShowErrorNoteL( TInt aError ) -// Shows error note -// --------------------------------------------------------- -// -void CpCertDataContainer::ShowErrorNoteL( TInt aError ) - { - QString sError; - switch ( aError ) - { - case KErrCorrupt: - { - sError = "Database corrupted. Some data might have been lost."; - break; - } - case KErrCancel: - { - // Show nothing - break; - } - default: - { - sError = "Internal error"; - break; - } - } - - if ( sError.length() != 0 ) - { - HbMessageBox::information(sError); - } - } - diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/cpcertdetailview.cpp --- a/cpsecplugins/cpadvancedsecplugin/src/cpcertdetailview.cpp Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,887 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0"" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include -#include -#include -#include -#include -#include // MD5 fingerprint -#include - -#include // Pow -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include <../../inc/cpsecplugins.h> -#include "cpcertdetailview.h" -#include "cpcertview.h" -#include "cpcertdatacontainer.h" -#include "cpcertmanuisyncwrapper.h" -#include "../../../pkiutilities/DeviceToken/Inc/TrustedSitesStore.h" - -const TInt KFileCertStoreUid( 0x101F501A ); -const TInt KTrustedServerCertStoreUid( 0x101FB66F ); -const TInt KDeviceCertStoreUid( 0x101FB668 ); -const TInt KDeviceKeyStoreUid( 0x101FB66A ); -const TInt KWIMCertStoreUid ( 0x101F79D9 ); - -const TInt KMaxLengthTextSerialNumberFormatting = 3; -_LIT( KCertManUIDetailsViewHexaFormat, "%02X" ); -_LIT( KBlockSeparator, " " ); - -template -class CleanupResetAndDestroy - { -public: - inline static void PushL( T& aRef ); -private: - static void ResetAndDestroy( TAny *aPtr ); - }; - -template -inline void CleanupResetAndDestroyPushL( T& aRef ); - -template -inline void CleanupResetAndDestroy::PushL( T& aRef ) - { - CleanupStack::PushL( TCleanupItem( &ResetAndDestroy, &aRef ) ); - } - -template -void CleanupResetAndDestroy::ResetAndDestroy( TAny *aPtr ) - { - if( aPtr ) - { - static_cast( aPtr )->ResetAndDestroy(); - } - } - -template -inline void CleanupResetAndDestroyPushL( T& aRef ) - { - CleanupResetAndDestroy::PushL( aRef ); - } - -CpCertDetailView::CpCertDetailView(CpCertView::TCertificateViews aCurrentView,TInt aPos, CpCertDataContainer& aCertDataContainer, QGraphicsItem *parent /*= 0*/) -: CpBaseSettingView(0,parent), mCertDataContainer(aCertDataContainer) - { - setTitle(tr("Certificate Details")); - - try - { - QT_TRAP_THROWING(viewCertificateDetailsL(aPos, aCurrentView)); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - throw(exception); - } - } - - -CpCertDetailView::~CpCertDetailView() - {} - -void CpCertDetailView::viewCertificateDetailsL( TInt aIndex, CpCertView::TCertificateViews aType ) - { - RDEBUG("0", 0); - QGraphicsLinearLayout *layout = q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)); - setLayout(layout); - - HbListWidget* mCertDetails = q_check_ptr(new HbListWidget(this)); - - HBufC8* urlBuf = NULL; - CCertificate* details = NULL; - CUnifiedCertStore*& store = mCertDataContainer.CertManager(); - - const CCTCertInfo* entry = certInfo(aIndex, aType); - TCertificateFormat certificateFormat = entry->CertificateFormat(); - - if( certificateFormat != EX509CertificateUrl ) - { - mCertDataContainer.iWrapper->GetCertificateL( store, *entry, details ); - CleanupStack::PushL( details ); - validateCertificateL( aIndex, *details, *entry, aType ); - } - else - { - urlBuf = HBufC8::NewLC( entry->Size() ); - TPtr8 urlPtr = urlBuf->Des(); - mCertDataContainer.iWrapper->GetUrlCertificateL( store, *entry, urlPtr ); - } - - if( aType == CpCertView::ETrustedView ) - { - addTrustedSitesL(*details, *mCertDetails); - } - else - { - addLabel(*entry, *mCertDetails); - } - RDEBUG("0", 0); - // certificate issuer and owner - if( certificateFormat == EX509Certificate ) - { - addIssuerL(*details, *mCertDetails); - addSubjectL(*details, *mCertDetails); - } - - // Get key usage and location. This is done only client certificates. - const TInt KLocationUnknown = 0; - TUid keyLocation = { KLocationUnknown }; - - if(( aType == CpCertView::EPersonalView ) || ( aType == CpCertView::EDeviceView )) - { - TKeyUsagePKCS15 usage = keyUsageAndLocationL( *entry, &keyLocation ); - addCertUsage(usage, *mCertDetails); - } - RDEBUG("0", 0); - if( certificateFormat == EX509Certificate ) - { - addValidityPeriod( *details, *mCertDetails ); - TUid certLoc; - certLoc.iUid = entry->Token().TokenType().Type().iUid; - // add the location of the certificate - setLocationInfo( ETrue, certLoc, *mCertDetails ); - } - else if( certificateFormat == EX509CertificateUrl ) - { - setURLLocation( *urlBuf, *mCertDetails ); - } - else - { - // nothing - } - - addCertFormat(certificateFormat, *mCertDetails); - - // Private key location, only for user and device certicates - if(( aType == CpCertView::EPersonalView ) || ( aType == CpCertView::EDeviceView )) - { - setLocationInfo( EFalse, keyLocation, *mCertDetails ); - } - - if( certificateFormat == EX509Certificate ) - { - addAlgoDetails( *details, *mCertDetails); - addSerialNo( *details, *mCertDetails ); - addFingerprint( *details, *mCertDetails); - addPublicKeyDetailsL( *details, *mCertDetails ); - } - else - { - // SetUrlCertAlgorihm() - } - RDEBUG("0", 0); - if( certificateFormat != EX509CertificateUrl ) - { - CleanupStack::PopAndDestroy( details ); - } - else - { - CleanupStack::PopAndDestroy( urlBuf ); - } - - layout->addItem(mCertDetails); - } - -const CCTCertInfo* CpCertDetailView::certInfo( TInt index, CpCertView::TCertificateViews certView ) - { - RDEBUG("0", 0); - const CCTCertInfo* certinfo = NULL; - - if( certView == CpCertView::EAuthorityView ) - { - certinfo = ( mCertDataContainer.iCALabelEntries )[ index ]->iCAEntry; - } - else if( certView == CpCertView::ETrustedView ) - { - certinfo = ( mCertDataContainer.iPeerLabelEntries )[ index ]->iPeerEntry; - } - else if( certView == CpCertView::EDeviceView ) - { - certinfo = ( mCertDataContainer.iDeviceLabelEntries )[ index ]->iDeviceEntry; - } - else if( certView == CpCertView::EPersonalView ) - { - certinfo = ( mCertDataContainer.iUserLabelEntries )[ index ]->iUserEntry; - } - return certinfo; - } - -void CpCertDetailView::addTrustedSitesL( const CCertificate& certDetails, HbListWidget& certDisplayDetails ) - { - RDEBUG("0", 0); - CTrustSitesStore* trustedSitesStore = CTrustSitesStore::NewL(); - CleanupStack::PushL( trustedSitesStore ); - - RPointerArray trustedSites; - CleanupResetAndDestroyPushL( trustedSites ); - trustedSitesStore->GetTrustedSitesL( certDetails.Encoding(), trustedSites ); - - QString sTrustedSites = "Site:"; - if( trustedSites.Count() > 0 ) - { - // display trusted sites - sTrustedSites = "Site:"; - } - addToListWidget(certDisplayDetails, sTrustedSites); - - for(int index=0;indexPtr()), trustedSites[index]->Length()); - addToListWidget(certDisplayDetails, trustedSiteDetail); - } - - CleanupStack::PopAndDestroy( &trustedSites ); - CleanupStack::PopAndDestroy( trustedSitesStore ); - - } - -void CpCertDetailView::addLabel( const CCTCertInfo& aCertInfo, HbListWidget& certDisplayDetails ) - { - RDEBUG("0", 0); - QString sLabel("Label:"); - QString sLabelDetails = "(No label)"; - if(aCertInfo.Label().Length() != 0) - { - sLabelDetails = QString((QChar*)(aCertInfo.Label().Ptr()),aCertInfo.Label().Length()); - } - addToListWidget(certDisplayDetails, sLabel, sLabelDetails); - } - -void CpCertDetailView::addIssuerL( const CCertificate& aCertDetails, - HbListWidget& certDisplayDetails ) - { - HBufC* issuer = NULL; - X509CertNameParser::IssuerFullNameL( (CX509Certificate&)aCertDetails, issuer ); - CleanupStack::PushL( issuer ); - - QString sIssuer = "Issuer:"; - QString sIssuerDetails = "(Not defined)"; - if(issuer->Des().Length() != 0) - { - sIssuerDetails = QString((QChar*)issuer->Des().Ptr(),issuer->Des().Length()); - } - addToListWidget(certDisplayDetails, sIssuer, sIssuerDetails); - - CleanupStack::PopAndDestroy( issuer ); - } - -void CpCertDetailView::addSubjectL( const CCertificate& aCertDetails, - HbListWidget& certDisplayDetails ) - { - RDEBUG("0", 0); - HBufC* subject = NULL; - X509CertNameParser::SubjectFullNameL( (CX509Certificate&)aCertDetails, subject ); - CleanupStack::PushL( subject ); - - QString sSubject = "Subject:"; - QString sSubjectDetails = "(No subject)"; - if(subject->Des().Length() != 0) - { - sSubjectDetails = QString((QChar*)subject->Des().Ptr(),subject->Des().Length()); - } - - addToListWidget(certDisplayDetails, sSubject, sSubjectDetails); - - CleanupStack::PopAndDestroy( subject ); - } - -void CpCertDetailView::addCertUsage( TKeyUsagePKCS15 usage, HbListWidget& certDisplayDetails ) - { - RDEBUG("0", 0); - QString strUsage; - switch( usage ) - { - case EPKCS15UsageSignSignRecover: - case EPKCS15UsageSignDecrypt: - case EPKCS15UsageSign: - strUsage = "Client authentication"; - break; - case EPKCS15UsageNonRepudiation: - strUsage = "Digital signing"; - break; - default: - strUsage = "(Not defined)"; - break; - } - addToListWidget(certDisplayDetails, strUsage ); - } - - -void CpCertDetailView::addValidityPeriod( const CCertificate& aCertDetails, - HbListWidget& certDisplayDetails) - { - RDEBUG("0", 0); - // Certificate validity period - // Hometime's offset to UTC - TLocale locale; - TTimeIntervalSeconds offSet = locale.UniversalTimeOffset(); - - QString sValidFrom("Valid from: "); - const CValidityPeriod& validityPeriod = aCertDetails.ValidityPeriod(); - TTime startValue = validityPeriod.Start(); - startValue += offSet; - TDateTime dateTime = startValue.DateTime(); - TMonth month = dateTime.Month(); - TInt day = dateTime.Day(); - TInt year = dateTime.Year(); - QDateTime qValidityPeriod(QDate(year, month, day)); - QString sValidFromDetail = qValidityPeriod.toString("MM\\dd\\yyyy"); - - addToListWidget(certDisplayDetails, sValidFrom, sValidFromDetail); - - QString sValidUntil("Valid until: "); - TTime finishValue = validityPeriod.Finish(); - finishValue += offSet; - dateTime = finishValue.DateTime(); - month = dateTime.Month(); - day = dateTime.Day(); - year = dateTime.Year(); - qValidityPeriod.setDate(QDate(year, month, day)); - QString sValidUntilDetail = qValidityPeriod.toString("MM\\dd\\yyyy"); - - addToListWidget(certDisplayDetails, sValidUntil, sValidUntilDetail); - - } - -void CpCertDetailView::setURLLocation( HBufC8& urlDetails, HbListWidget& certDisplayDetails ) - { - RDEBUG("0", 0); - TPtr8 urlPtr = urlDetails.Des(); - - QString certUrl = "Location:"; - QString certURLDetail = "(Not defined)"; - TInt length = urlPtr.Length(); - if(length != 0) - { - certURLDetail = QString((QChar*)urlPtr.Ptr(),urlPtr.Length()); - } - addToListWidget(certDisplayDetails, certUrl, certURLDetail); - } - -void CpCertDetailView::addCertFormat( TCertificateFormat aCertFormat, HbListWidget& certDisplayDetails ) - { - RDEBUG("0", 0); - // certificate format - QString certFormat = "Certificate format:"; - QString certFormatDetails = "(Not defined)"; - if( aCertFormat == EX509Certificate || aCertFormat == EX509CertificateUrl) - { - certFormatDetails = "X509"; - } - addToListWidget(certDisplayDetails, certFormat, certFormatDetails); - } - -void CpCertDetailView::addAlgoDetails( const CCertificate& certificate, - HbListWidget& certDisplayDetails ) - { - RDEBUG("0", 0); - // certificate algorithms - QString sDgstAlgoDetails = "Unknown"; - // digest algorithm - TAlgorithmId algorithmId = certificate.SigningAlgorithm().DigestAlgorithm().Algorithm(); - switch( algorithmId ) - { - case EMD2: - { - sDgstAlgoDetails = "MD2"; - break; - } - case EMD5: - { - sDgstAlgoDetails = "MD5"; - break; - } - case ESHA1: - { - sDgstAlgoDetails = "SHA1"; - break; - } - } - - QString sAsymmetricAlgoDetails = asymmetricAlgoId(certificate); - QString sAlgorithm("Algorithm:"); - QString sAlgoDetails = "Unknown"; - // If other algorithm is unknown - if( sDgstAlgoDetails != "Unknown" && sAsymmetricAlgoDetails != "Unknown" ) - { - sAlgoDetails = sDgstAlgoDetails; - sAlgoDetails.append(sAsymmetricAlgoDetails); - } - addToListWidget(certDisplayDetails, sAlgorithm, sAlgoDetails); - } - -void CpCertDetailView::addSerialNo( const CCertificate& certificate, - HbListWidget& certDisplayDetails ) - { - RDEBUG("0", 0); - // certificate serial number - QString sCertSerialNo("Serial number:"); - QString sCertSerialNoDetails = 0; - TPtrC8 serialNumber = certificate.SerialNumber(); - TBuf buf2; - - for( TInt i = 0; i < serialNumber.Length(); i++ ) - { - buf2.Format( KCertManUIDetailsViewHexaFormat, serialNumber[i] ); - sCertSerialNoDetails.append( QString( (QChar*)buf2.Ptr(),buf2.Length() ) ); - } - addToListWidget(certDisplayDetails, sCertSerialNo, sCertSerialNoDetails); - } - -void CpCertDetailView::addFingerprint( const CCertificate& certificate, - HbListWidget& certDisplayDetails) - { - RDEBUG("0", 0); - // certificate fingerprint SHA-1 - QString sSha1("Fingerprint (SHA1):"); - TPtrC8 sha1_fingerprint = certificate.Fingerprint(); - HBufC* finalSha1 = NULL; - QString sSha1Details = NULL; - - QT_TRAP_THROWING - ( - finalSha1 = HBufC::NewLC(100); - TPtr finalShaPtr = finalSha1->Des(); - divideIntoBlocks( sha1_fingerprint, finalShaPtr ); - sSha1Details = QString( (QChar*)finalShaPtr.Ptr(), finalShaPtr.Length() ); - CleanupStack::PopAndDestroy(finalSha1); - ) - - addToListWidget(certDisplayDetails, sSha1, sSha1Details); - - // certificate fingerprint MD5 - QString sMd5("Fingerprint (MD5):"); - CMD5* md5= NULL; - QT_TRAP_THROWING - ( - md5 = CMD5::NewL(); - CleanupStack::PushL( md5 ); - TBuf8<20> fingerprint = md5->Hash( certificate.Encoding() ); - CleanupStack::PopAndDestroy( md5 ); - HBufC* finalMd5 = NULL; - finalMd5 = HBufC::NewLC(100); - TPtr finalMd5Ptr = finalMd5->Des(); - divideIntoBlocks( fingerprint, finalMd5Ptr ); - QString sMd5Details = QString( (QChar*)finalMd5Ptr.Ptr(), finalMd5Ptr.Length()); - CleanupStack::PopAndDestroy(finalMd5); - addToListWidget(certDisplayDetails, sMd5, sMd5Details); - ) - } - -void CpCertDetailView::addPublicKeyDetailsL( const CCertificate& certificate, - HbListWidget& certDisplayDetails ) - { - RDEBUG("0", 0); - // Public key - // Should look like: "Public key (%0U %1N bit):" - - QString sPublicKey("Public key ("); // %S %d bits):"); - sPublicKey.append(asymmetricAlgoId(certificate)); - - // Get public key already here to get length of it for string loader. - const CSubjectPublicKeyInfo& publicKey = certificate.PublicKey(); - TPtrC8 keyData = publicKey.KeyData(); - TInt size = keyData.Size(); // %1N - - // To get key size decode DER encoded key got from the certificate. - TX509KeyFactory key; - - // There doesn't seem to be definition of MAX_INT anywhere so calculate it. - TReal maxInt; - TReal intBits = sizeof( TInt ) * 8; - Math::Pow( maxInt, 2, intBits ); - maxInt = ( maxInt / 2 ) - 1; - - TAlgorithmId algorithmId = certificate.SigningAlgorithm().AsymmetricAlgorithm().Algorithm(); - switch( algorithmId ) - { - case ERSA: - { - const CRSAPublicKey* keyRSA = key.RSAPublicKeyL( keyData ); - - const TInteger& n = keyRSA->N(); - - TUint keySizeN = n.BitCount(); - - // Play it safe. - if( keySizeN < maxInt ) - { - size = keySizeN; - } - - delete keyRSA; - - break; - } - case EDSA: - { - TPtrC8 params = publicKey.EncodedParams(); - const CDSAPublicKey* keyDSA = key.DSAPublicKeyL( params, keyData ); - - const TInteger& y = keyDSA->Y(); - - TUint keySizeY = y.BitCount(); - - // Play it safe. - if( keySizeY < maxInt ) - { - size = keySizeY; - } - - delete keyDSA; - - break; - } - // There doesn't seem to be TX509KeyFactory function for DH keys. - // If the key is DH or unknown, just multiply length of the key - // in bytes with 8. It is not correct but at least gives an idea. - // Without setting something to size 'unknown' text should be used - // below for the string which is much more error prone than setting - // at least something. - case EDH: - default: - { - size = 8 * keyData.Size(); - } - } - - sPublicKey.append(" ").append(QString::number(size)).append(" bits):"); - - // Finally append the public key. - HBufC* pubKey = HBufC::NewLC(size*3); - TPtr pubKeyPtr = pubKey->Des(); - divideIntoBlocks( keyData, pubKeyPtr ); - QString sPublicKeyDetails = QString ( (QChar*)pubKeyPtr.Ptr(), pubKeyPtr.Length()); - CleanupStack::PopAndDestroy(pubKey); - addToListWidget(certDisplayDetails, sPublicKey, sPublicKeyDetails); - } - -QString CpCertDetailView::asymmetricAlgoId( const CCertificate& certificate ) - { - RDEBUG("0", 0); - QString sAsymmetricAlgoId = 0; - // public-key algorithm - TAlgorithmId algorithmId = certificate.SigningAlgorithm().AsymmetricAlgorithm().Algorithm(); - switch( algorithmId ) - { - case ERSA: - { - sAsymmetricAlgoId = "RSA"; - break; - } - case EDSA: - { - sAsymmetricAlgoId = "DSA"; - break; - } - case EDH: - { - sAsymmetricAlgoId = "DH"; - break; - } - default: - { - sAsymmetricAlgoId = "Unknown"; - } - } - return sAsymmetricAlgoId; - } - -void CpCertDetailView::addToListWidget(HbListWidget& certDisplayDetails, const QString& data ) - { - HbListWidgetItem* wItem = q_check_ptr(new HbListWidgetItem()); - wItem->setText(data); - certDisplayDetails.addItem(wItem); - } - -void CpCertDetailView::addToListWidget( HbListWidget& certDisplayDetails, - const QString& displayString, - const QString& displayDetails ) - { - HbListWidgetItem* wDisplayString = q_check_ptr(new HbListWidgetItem()); - wDisplayString->setText(displayString); - certDisplayDetails.addItem(wDisplayString); - - HbListWidgetItem* wDisplayDetails = q_check_ptr(new HbListWidgetItem()); - wDisplayDetails->setText(displayDetails); - certDisplayDetails.addItem(wDisplayDetails); - } - -void CpCertDetailView::validateCertificateL( - TInt aIndex, const CCertificate& certDetails, const CCTCertInfo& aCertInfo, CpCertView::TCertificateViews aType ) - { - RDEBUG("0", 0); - TInt poppableItems = 0; - // Check allways first the validity period - // Show Expired/Not yet valid notes - const CValidityPeriod& validityPeriod = certDetails.ValidityPeriod(); - const TTime& startValue = validityPeriod.Start(); - const TTime& finishValue = validityPeriod.Finish(); - TTime current; - current.UniversalTime(); - - if ( startValue > current ) - { - // certificate is not valid yet - HbMessageBox::warning("The certificate is not valid yet"); - } - else if ( finishValue < current ) - { - // certificate is expired - HbMessageBox::warning("The certificate has expired"); - } - else - { - // put here check for certificate status, show warning notes if needed - TBool noValidationError = ETrue; - CArrayFixFlat* validationError = NULL; - // set it to the most common cert format - TCertificateFormat certificateFormat = EX509Certificate; - - if ( aType == CpCertView::EAuthorityView ) - { - certificateFormat = mCertDataContainer.iCALabelEntries[aIndex]-> - iCAEntry->CertificateFormat(); - } - else if ( aType == CpCertView::ETrustedView ) - { - certificateFormat = mCertDataContainer.iPeerLabelEntries[aIndex]-> - iPeerEntry->CertificateFormat(); - } - else if ( aType == CpCertView::EDeviceView ) - { - certificateFormat = mCertDataContainer.iDeviceLabelEntries[aIndex]-> - iDeviceEntry->CertificateFormat(); - } - else if( aType == CpCertView::EPersonalView ) - { - certificateFormat = mCertDataContainer.iUserLabelEntries[aIndex]-> - iUserEntry->CertificateFormat(); - } - - switch ( certificateFormat ) - { - case EX509Certificate: - { - validationError = validateX509CertificateL((CX509Certificate&)certDetails ); - break; - } - default: - { - validationError = new ( ELeave) CArrayFixFlat( 1 ); - break; - } - } - CleanupStack::PushL( validationError ); - poppableItems++; - - TInt errorCount = validationError->Count(); - TBool ready = EFalse; - for ( TInt i = 0; i < errorCount && !ready; i++ ) - { - TValidationError errorType = validationError->At(i); - - switch ( errorType ) - { - case EValidatedOK: - case EChainHasNoRoot: - case EBadKeyUsage: - // Ignore these errors - //LOG_WRITE( "Ignored certificate validation error" ); - break; - - default: - // certificate is corrupted - noValidationError = EFalse; - HbMessageBox::warning("The certificate is corrupted"); - ready = ETrue; - break; - } - } - - if ( noValidationError && (aType == CpCertView::EAuthorityView )) - // Check for last if the CA certificate has no clients, - // ie. the trust state of every client is No - // For user certificates we don't do the check - { - - RArray trusterUids; - CleanupClosePushL( trusterUids ); - poppableItems++; - - mCertDataContainer.iWrapper->GetApplicationsL( - mCertDataContainer.CertManager(), aCertInfo, trusterUids ); - - if ( trusterUids.Count() == 0) - { - HbMessageBox::warning("Certificate not trusted"); - } - } - } - CleanupStack::PopAndDestroy( poppableItems ); - } - -CArrayFixFlat* CpCertDetailView::validateX509CertificateL( const CX509Certificate& certDetails ) - { - RDEBUG("0", 0); - TInt poppableItems = 0; - CArrayFixFlat* validationError = - new ( ELeave ) CArrayFixFlat( 1 ); - CleanupStack::PushL( validationError ); //This is returned, so it isn't destroyed at the end. - - TTime GMTTime; - GMTTime.UniversalTime(); // Get Universal Time - RPointerArray certArray; - certArray.Append( &certDetails ); - - CPKIXCertChain* chain = CPKIXCertChain::NewLC( - mCertDataContainer.iRfs, certDetails.Encoding(), certArray ); - ++poppableItems; - - CPKIXValidationResult* result = CPKIXValidationResult::NewLC(); - ++poppableItems; - mCertDataContainer.iWrapper->ValidateX509RootCertificateL( result, GMTTime, chain ); - - TValidationStatus validationStatus = result->Error(); - //Set reserve space. One for error, other for warnings. - validationError->SetReserveL( 1 + result->Warnings().Count() ); - validationError->AppendL(validationStatus.iReason); - for ( TUint8 i = 0; i < result->Warnings().Count(); i++ ) - { - validationError->AppendL( result->Warnings().At(0).iReason ); - } - - CleanupStack::PopAndDestroy( poppableItems, chain ); // All but validationError. - CleanupStack::Pop(validationError); - return validationError; - } - -TKeyUsagePKCS15 CpCertDetailView::keyUsageAndLocationL( const CCTCertInfo& certEntry, - TUid* keyLocation ) - { - TKeyUsagePKCS15 keyUsage; - RDEBUG("0", 0); - // Check whether we have key for this certificate - RMPointerArray keyEntry; - TCTKeyAttributeFilter filter; - filter.iKeyId = certEntry.SubjectKeyId(); - - mCertDataContainer.iWrapper->ListL( mCertDataContainer.KeyManager(), &keyEntry, filter ); - - if (keyEntry.Count()) - { - keyUsage = keyEntry[0]->Usage(); - // Get Location - keyLocation->iUid = keyEntry[0]->Token().TokenType().Type().iUid ; - } - else - { - keyUsage = EPKCS15UsageNone; - } - - keyEntry.Close(); - return keyUsage; - } - -// --------------------------------------------------------- -// CCertManUICertificateHelper::setLocationInfo( (HBufC& aMessage, -// TBool certificate, -// TUid* aLocUid) -// Adds certificate/private key's location info to certificate details -// --------------------------------------------------------- -// -void CpCertDetailView::setLocationInfo(TBool certificate, TUid locUid, HbListWidget& certDisplayDetails) - { - RDEBUG("0", 0); - QString locationDetails = "(Not defined)"; - - switch ( locUid.iUid ) - { - case KFileCertStoreUid: - case KTrustedServerCertStoreUid: - case KDeviceCertStoreUid: - case KDeviceKeyStoreUid: - case KTokenTypeFileKeystore: - locationDetails = "Phone memory"; - break; - - case KWIMCertStoreUid: - locationDetails = "Smart card"; - break; - - default: - if ( !certificate ) - { - locationDetails = "No private key"; - } - break; - } - - QString location = "Location:"; - if ( !certificate ) - { - location = "Private key location:"; - } - - addToListWidget(certDisplayDetails, location, locationDetails ); - - } - -// --------------------------------------------------------- -// CCertManUICertificateHelper::divideIntoBlocks -// --------------------------------------------------------- -// -void CpCertDetailView::divideIntoBlocks( const TDesC8& input, TPtr& output ) - { - RDEBUG("0", 0); - const TInt KBlockLength = 2; - TInt blockIndex = 0; - for ( TInt j = 0 ; j < input.Length() ; j++ ) - { - if ( blockIndex == KBlockLength ) - { - output.Append( KBlockSeparator ); - blockIndex = 0; - } - output.AppendNumFixedWidthUC( (TUint)(input[ j ]), EHex, 2 ); - ++blockIndex; - } - } - - diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/cpcertmanuisyncwrapper.cpp --- a/cpsecplugins/cpadvancedsecplugin/src/cpcertmanuisyncwrapper.cpp Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,777 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implements a synchronous wrapper for easier use of Symbian's -* Security Frameworks's API's. -* -*/ - - -// INCLUDE FILES -#include -#include -#include -#include -#include -#include <../../inc/cpsecplugins.h> -#include "cpcertmanuisyncwrapper.h" - -// CONSTANTS -_LIT_SECURITY_POLICY_C1( KKeyStoreUsePolicy, ECapabilityReadUserData ); -// Maximum length of a certificate -const TInt KMaxCertificateLength = 5000; -const TInt KMaxKeyLength = 10000; - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::ListL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::ListL( - CUnifiedCertStore*& aStore, - RMPointerArray* aArray, - const CCertAttributeFilter& aFilter, - const TUid aTokenUid ) - { - RDEBUG("0", 0); - if ( IsActive() ) - { - // Wrapper is active. Don't go further - User::Leave(KErrGeneral); - } - - TInt count = aStore->CertStoreCount(); - for ( TInt ii = 0; ii < count; ii++ ) - { - MCTCertStore& certstore = aStore->CertStore( ii ); - MCTToken& token = certstore.Token(); - TUid tokenuid = token.Handle().iTokenTypeUid; - if ( tokenuid == aTokenUid ) - { - certstore.List( *aArray, aFilter, iStatus ); - iOperation = EOperationList; - iStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - break; - } - } - iOperation = EOperationNone; - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::ListL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::ListL( - CUnifiedKeyStore*& aStore, - RMPointerArray* aArray, - const TCTKeyAttributeFilter& aFilter ) - { - RDEBUG("0", 0); - if ( IsActive() ) - { - // Wrapper is active. Don't go further - User::Leave(KErrGeneral); - } - - aStore->List( *aArray, aFilter, iStatus ); - iOperation = EOperationKeyList; - iKeyStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - iOperation = EOperationNone; - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::GetCertificateL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::GetCertificateL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, - CCertificate*& aCert, - TUid aTokenUid ) - { - aCert = NULL; - RDEBUG("0", 0); - HBufC8* buf = HBufC8::NewLC( KMaxCertificateLength ); - iCertPtr.Set( buf->Des() ); - - TInt count = aStore->CertStoreCount(); - for (TInt i = 0; i < count; i++) - { - MCTCertStore& certstore = aStore->CertStore( i ); - MCTToken& token = certstore.Token(); - TUid tokenuid = token.Handle().iTokenTypeUid; - if ( tokenuid == aTokenUid ) - { - certstore.Retrieve( aCertInfo, iCertPtr, iStatus ); - iOperation = EGetCertificate; - iStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - break; - } - } - - - switch ( aCertInfo.CertificateFormat() ) - { - case EX509Certificate: - { - aCert = CX509Certificate::NewL( iCertPtr ); - break; - } - case EX509CertificateUrl: - { - break; - } - default: - { - break; - } - } - - CleanupStack::PopAndDestroy(buf); - iOperation = EOperationNone; - - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::DeleteCertL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::DeleteCertL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo ) - { - RDEBUG("0", 0); - aStore->Remove( aCertInfo, iStatus ); - iOperation = EOperationDelete; - iStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - iOperation = EOperationNone; - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::DeleteCertL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::DeleteCertL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, - TUid aTokenUid ) - { - RDEBUG("0", 0); - TInt count = aStore->WritableCertStoreCount(); - for (TInt i = 0; i < count; i++) - { - MCTWritableCertStore& writablestore = aStore->WritableCertStore( i ); - MCTToken& token = writablestore.Token(); - TUid tokenuid = token.Handle().iTokenTypeUid; - if ( tokenuid == aTokenUid ) - { - writablestore.Remove( aCertInfo, iStatus ); - iOperation = EOperationDelete; - iStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - break; - } - } - iOperation = EOperationNone; - } - -// ============================ MEMBER FUNCTIONS =============================== - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::CpCertManUISyncWrapper() -// C++ default constructor can NOT contain any code, that -// might leave. -// ----------------------------------------------------------------------------- -// -CpCertManUISyncWrapper::CpCertManUISyncWrapper() : CActive( EPriorityStandard ), iCertPtr(0,0) - { - CActiveScheduler::Add( this ); - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::ConstructL() -// Symbian 2nd phase constructor can leave. -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::ConstructL() - { - } - - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::NewLC -// Two-phased constructor. -// ----------------------------------------------------------------------------- -// -CpCertManUISyncWrapper* CpCertManUISyncWrapper::NewLC() - { - CpCertManUISyncWrapper* wrap = new ( ELeave ) CpCertManUISyncWrapper(); - CleanupStack::PushL( wrap ); - wrap->ConstructL(); - return wrap; - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::NewL -// Two-phased constructor. -// ----------------------------------------------------------------------------- -// -CpCertManUISyncWrapper* CpCertManUISyncWrapper::NewL() - { - CpCertManUISyncWrapper* wrap = CpCertManUISyncWrapper::NewLC(); - CleanupStack::Pop(wrap); - return wrap; - } - -// Destructor -CpCertManUISyncWrapper::~CpCertManUISyncWrapper() - { - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::RunL -// If no errors happened, stop. Show an error note if needed. -// ----------------------------------------------------------------------------- -// - -void CpCertManUISyncWrapper::RunL() - { - RDEBUG("0", 0); - if ( iWait.IsStarted() ) - { - iWait.AsyncStop(); - } - - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::DoCancel -// Cancels the ongoing operation if possible. -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::DoCancel() - { - RDEBUG("iOperation", iOperation); - switch ( iOperation ) - { - case EOperationInit: - { - iStore->CancelInitialize(); - break; - } - case EOperationList: - { - iStore->CancelList(); - break; - } - case EGetCertificate: - { - iStore->CancelRetrieve(); - break; - } - case EAddCertificate: - { - iStore->Cancel(); - break; - } - case ERetriveURLCertificate: - { - iStore->CancelRetrieve(); - break; - } - case EOperationDelete: - { - iStore->CancelRemove(); - break; - } - case EOperationGetApps: - { - iStore->CancelApplications(); - break; - } - case EOperationValidateX509Root: - { - iChain->CancelValidate(); - break; - } - case EShowErrorNote: - { - break; - } - case EOperationInitKeyStore: - { - iKeyStore->CancelInitialize(); - break; - } - case EOperationKeyList: - { - iKeyStore->CancelList(); - break; - } - case EOperationExportKey: - { - iKeyStore->CancelExportKey(); - break; - } - case EOperationImportKey: - { - iKeyStore->CancelImportKey(); - break; - } - case EOperationDeleteKey: - { - iKeyStore->CancelDeleteKey(); - break; - } - default: - { - break; - } - } - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::InitStoreL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::InitStoreL( CUnifiedCertStore*& aStore ) - { - aStore->Initialize( iStatus ); - iOperation = EOperationInit; - iStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - iOperation = EOperationNone; - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::InitStoreL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::InitStoreL( CUnifiedKeyStore*& aStore ) - { - aStore->Initialize( iStatus ); - iOperation = EOperationInitKeyStore; - iKeyStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - iOperation = EOperationNone; - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::ListL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::ListL( - CUnifiedCertStore*& aStore, - RMPointerArray* aArray, - const CCertAttributeFilter& aFilter ) - { - - if ( IsActive() ) - { - // Wrapper is active. Don't go further - User::Leave(KErrGeneral); - } - - aStore->List( *aArray, aFilter, iStatus ); - iOperation = EOperationList; - iStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - iOperation = EOperationNone; - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::ListL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::ListL( - CUnifiedKeyStore*& aStore, - RMPointerArray* aArray, - const TCTKeyAttributeFilter& aFilter, - const TUid aTokenUid ) - { - - if ( IsActive() ) - { - // Wrapper is active. Don't go further - User::Leave(KErrGeneral); - } - - TInt count = aStore->KeyStoreManagerCount(); - for ( TInt ii = 0; ii < count; ii++ ) - { - MCTKeyStoreManager& keystoremanager = aStore->KeyStoreManager( ii ); - MCTToken& token = keystoremanager.Token(); - TUid tokenuid = token.Handle().iTokenTypeUid; - if ( tokenuid == aTokenUid ) - { - keystoremanager.List( *aArray, aFilter, iStatus ); - iOperation = EOperationKeyList; - iKeyStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - break; - } - } - iOperation = EOperationNone; - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::GetCertificateL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::GetCertificateL( - CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, - CCertificate*& aCert ) - { - aCert = NULL; - HBufC8* buf = HBufC8::NewLC( KMaxCertificateLength ); - iCertPtr.Set( buf->Des() ); - aStore->Retrieve( aCertInfo, iCertPtr, iStatus); - iOperation = EGetCertificate; - iStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - - switch ( aCertInfo.CertificateFormat() ) - { - case EX509Certificate: - { - aCert = CX509Certificate::NewL( iCertPtr ); - break; - } - case EX509CertificateUrl: - { - break; - } - default: - { - break; - } - } - CleanupStack::PopAndDestroy(buf); - iOperation = EOperationNone; - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::ValidateX509RootCertificateL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::ValidateX509RootCertificateL( - CPKIXValidationResult*& aValidationResult, - const TTime& aValidationTime, CPKIXCertChain*& aChain ) - { - - aChain->ValidateL( *aValidationResult, aValidationTime, iStatus ); - iOperation = EOperationValidateX509Root; - iChain = aChain; - SetActive(); - iWait.Start(); - iOperation = EOperationNone; - User::LeaveIfError(iStatus.Int()); - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::GetUrlCertificateL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::GetUrlCertificateL( - CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, - TDes8& aUrl ) - { - - aStore->Retrieve( aCertInfo, aUrl, iStatus); - iOperation = ERetriveURLCertificate; - iStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - iOperation = EOperationNone; - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::GetApplicationsL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::GetApplicationsL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, RArray& aApps ) - { - - aStore->Applications( aCertInfo, aApps, iStatus ); - iOperation = EOperationGetApps; - iStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - iOperation = EOperationNone; - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::SetApplicabilityL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::SetApplicabilityL( CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, - RArray& aApplications ) - { - - aStore->SetApplicability( aCertInfo, aApplications, iStatus ); - iOperation = EOperationSetApplicability; - iStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - aStore->SetTrust( aCertInfo, ETrue, iStatus ); - iOperation = EOperationSetToTrusted; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - iOperation = EOperationNone; - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::MoveKeyL -// ----------------------------------------------------------------------------- -// -void CpCertManUISyncWrapper::MoveKeyL( - CUnifiedKeyStore*& aStore, - const TCTKeyAttributeFilter& aFilter, - const TUid aSourceTokenId, - const TUid aTargetTokenId ) - { - - TInt sourceIndex(-1); - TInt targetIndex(-1); - - // Find the index of key stores - TInt count = aStore->KeyStoreManagerCount(); - - for (TInt ii = 0; ii < count; ii++) - { - MCTKeyStoreManager& keystoremanager = aStore->KeyStoreManager( ii ); - MCTToken& token = keystoremanager.Token(); - TUid tokenuid = token.Handle().iTokenTypeUid; - - if ( tokenuid == aSourceTokenId ) - { - sourceIndex = ii; - } - - if ( tokenuid == aTargetTokenId ) - { - targetIndex = ii; - } - } - - if (( sourceIndex == -1 ) || ( targetIndex == -1 )) - { - // Key store(s) doesn't exist - User::Leave( KErrNotFound ); - } - - RMPointerArray keyEntries; - - MCTKeyStoreManager& sourcekeystore = - aStore->KeyStoreManager( sourceIndex ); - - MCTKeyStoreManager& targetkeystore = - aStore->KeyStoreManager( targetIndex ); - - - ListL( aStore, &keyEntries, aFilter, aSourceTokenId ); - - // Go through all matching keys and move them to - // target store - for ( TInt ii = 0; ii < keyEntries.Count(); ii++ ) - { - HBufC8* keyData = HBufC8::NewLC( KMaxKeyLength ); - - // Retrieve key from source key store - sourcekeystore.ExportKey( (*keyEntries[ii]).Handle(), keyData, iStatus ); - iOperation = EOperationExportKey; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - - TCTTokenObjectHandle sourceKeyHandle = (*keyEntries[ii]).Handle(); - - // Import key to target key store - - // If key info access type indicates that key is local, then importing is - // not possible. The following is the workarround. Almost identical - // copy of keyinfo is created without CCTKeyInfo::ELocal access type flag. - // UsePolicy is also updated - TInt accessType = (*keyEntries[ii]).AccessType(); - if ( accessType & CCTKeyInfo::ELocal ) - { - // CCTKeyInfo::ELocal is set in key info - HBufC* label = (*keyEntries[ii]).Label().AllocLC(); - - // The following XOR operation will clear local bit if it is on. - accessType ^= CCTKeyInfo::ELocal; - - CCTKeyInfo* keyInfo = CCTKeyInfo::NewL( (*keyEntries[ii]).ID(), - (*keyEntries[ii]).Usage(), - (*keyEntries[ii]).Size(), - NULL, - label, - (*keyEntries[ii]).Token(), - (*keyEntries[ii]).HandleID(), - KKeyStoreUsePolicy, - (*keyEntries[ii]).ManagementPolicy(), - (*keyEntries[ii]).Algorithm(), - accessType, - (*keyEntries[ii]).Native(), - (*keyEntries[ii]).StartDate(), - (*keyEntries[ii]).EndDate() ); - - CleanupStack::Pop(label); - targetkeystore.ImportKey( *keyData, keyInfo, iStatus ); - } - else - { - targetkeystore.ImportKey( *keyData, keyEntries[ii], iStatus ); - } - - iOperation = EOperationImportKey; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - - // Delete key from source key store - sourcekeystore.DeleteKey( sourceKeyHandle, iStatus ); - iOperation = EOperationDeleteKey; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - - CleanupStack::PopAndDestroy(keyData); - } - - } - -// ----------------------------------------------------------------------------- -// CpCertManUISyncWrapper::MoveCertL -// ----------------------------------------------------------------------------- -// -TInt CpCertManUISyncWrapper::MoveCertL( - CUnifiedCertStore*& aStore, - const CCTCertInfo& aCertInfo, - const TUid aSourceTokenId, - const TUid aTargetTokenId ) - { - - TInt sourceIndex(-1); - TInt targetIndex(-1); - TInt certCount (0); - - // Find the index of certificate stores - TInt count = aStore->WritableCertStoreCount(); - for (TInt ii = 0; ii < count; ii++) - { - MCTWritableCertStore& writablestore = aStore->WritableCertStore( ii ); - MCTToken& token = writablestore.Token(); - TUid tokenuid = token.Handle().iTokenTypeUid; - - if ( tokenuid == aSourceTokenId ) - { - sourceIndex = ii; - } - - if ( tokenuid == aTargetTokenId ) - { - targetIndex = ii; - } - } - - if (( sourceIndex == -1 ) || ( targetIndex == -1 )) - { - // Certificate store(s) doesn't exist - User::Leave( KErrNotFound ); - } - - - MCTWritableCertStore& sourcewritablestore = - aStore->WritableCertStore( sourceIndex ); - - // All of the certificates that are associated with same - // private key will be moved to target certificate store. - CCertAttributeFilter* filter = CCertAttributeFilter::NewL(); - filter->SetOwnerType( EUserCertificate ); - filter->SetSubjectKeyId( aCertInfo.SubjectKeyId() ); - RMPointerArray certEntries; - - // List certificates from source certificate store - ListL( aStore, &certEntries, *filter, aSourceTokenId ); - - delete filter; - - for ( TInt ii = 0; ii < certEntries.Count(); ii++ ) - { - // Retrieve certificate from source certificate store - HBufC8* buf = HBufC8::NewLC( KMaxCertificateLength ); - iCertPtr.Set( buf->Des() ); - sourcewritablestore.Retrieve( *certEntries[ii], iCertPtr, iStatus ); - iOperation = EGetCertificate; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - - // Add certificate to target certificate store - MCTWritableCertStore& targetwritablestore = - aStore->WritableCertStore( targetIndex ); - - targetwritablestore.Add( (*certEntries[ii]).Label(), EX509Certificate, - EUserCertificate, &((*certEntries[ii]).SubjectKeyId()), - &((*certEntries[ii]).IssuerKeyId()), *buf, iStatus ); - - iOperation = EAddCertificate; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - - // Delete certificate from source certificate store - sourcewritablestore.Remove( *certEntries[ii], iStatus ); - iOperation = EOperationDelete; - iStore = aStore; - SetActive(); - iWait.Start(); - User::LeaveIfError( iStatus.Int() ); - iOperation = EOperationNone; - certCount++; - CleanupStack::PopAndDestroy(buf); - } - - return certCount; - } - - diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/cpcertpluginloader.cpp --- a/cpsecplugins/cpadvancedsecplugin/src/cpcertpluginloader.cpp Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * under the terms of "Eclipse Public License v1.0"" - * which accompanies this distribution, and is available - * at the URL "http://www.eclipse.org/legal/epl-v10.html". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: - * - */ - -#include - -#include "cpcertpluginloader.h" -#include "cpsecurityview.h" -#include -#include <../../inc/cpsecplugins.h> - -CpCertPluginLoader::CpCertPluginLoader() - { - RDEBUG("0", 0); - mTranslator = q_check_ptr( new QTranslator()); - QString path = "z:/resource/qt/translations/"; - QString appName = "certificate_manager_"; - QString lang = QLocale::system().name(); - mTranslator->load(path + appName + lang); - qApp->installTranslator(mTranslator); - } - -CpCertPluginLoader::~CpCertPluginLoader() - { - if (mTranslator) - { - if (mTranslator->isEmpty() == false) - qApp->removeTranslator(mTranslator); - delete mTranslator; - } - } - -QList CpCertPluginLoader::createSettingFormItemData(CpItemDataHelper &itemDataHelper) const - { - RDEBUG("0", 0); - CpSettingFormEntryItemData *advancedSecuritySettingsItem = - new CpSettingFormEntryItemDataImpl( - CpSettingFormEntryItemData::ButtonEntryItem, - itemDataHelper, hbTrId("txt_certificate_manager_setlabel_advanced_security")); - advancedSecuritySettingsItem->setContentWidgetData("textAlignment", - QVariant( Qt::AlignHCenter | Qt::AlignVCenter) ); - advancedSecuritySettingsItem->setContentWidgetData("objectName", - "advancedSecuritySettingsButton" ); - return QList() << advancedSecuritySettingsItem; - } - -Q_EXPORT_PLUGIN2(cpcertpluginloader, CpCertPluginLoader); diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/cpcerttrustview.cpp --- a/cpsecplugins/cpadvancedsecplugin/src/cpcerttrustview.cpp Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,379 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation of class CCertManUIContainerTrust. -* Maintains correct list of trusted clients depending -* on the certificate that was in focus in Authority -* certificates view when Trust Settings view was entered. -* Shows and changes correct Yes/No text for the Trusted client. -* -*/ - -// INCLUDE FILES -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include <../../inc/cpsecplugins.h> -#include "cpcerttrustview.h" -#include "cpcertdatacontainer.h" -#include "cpcertmanuisyncwrapper.h" -#include "cpuitrustids.h" - -const TInt KMidpCertStoreUid = 0x101F5B71; - -// ============================= LOCAL FUNCTIONS =============================== - -// ================= MEMBER FUNCTIONS ======================= - -CpCertTrustView::CpCertTrustView( TInt certificateIndex, CpCertDataContainer& certDataContainer, QGraphicsItem *parent /*= 0*/) - : CpBaseSettingView(0,parent), mCertDataContainer(certDataContainer), mCertificateIndex(certificateIndex) - { - setTitle(tr("Trust Settings")); - viewTrustSettings(); - } - -// --------------------------------------------------------- -// CpCertTrustView::~CpCertTrustView() -// Destructor -// --------------------------------------------------------- -// -CpCertTrustView::~CpCertTrustView() - { - delete mAppInfoManager; - mClientUids.Close(); - delete mFormModel; - mTrustedClients.erase(mTrustedClients.begin(), mTrustedClients.end()); - mTrustValues.erase(mTrustValues.begin(), mTrustValues.end()); - } - - -void CpCertTrustView::viewTrustSettings() - { - RDEBUG("0", 0); - mTrustedClients << " \tWAP connection\t\t"; - mTrustedClients << " \tMail and Image conn.\t\t"; - mTrustedClients << " \tNative installing\t\t"; - mTrustedClients << " \tJava installing\t\t"; - mTrustedClients << " \tOCSP validation\t\t"; - mTrustedClients << " \tVPN\t\t"; - mTrustedClients << " \tWidget Installation\t\t"; - - mTrustValues << "On"; - mTrustValues << "Off"; - - try - { - QT_TRAP_THROWING( mAppInfoManager = - CCertificateAppInfoManager::NewL( mCertDataContainer.iRfs, EFalse ); - updateListBoxL();) - } - catch(std::exception& exception) - { - QString error(exception.what()); - QT_TRAP_THROWING( mCertDataContainer.ShowErrorNoteL( error.toInt()) ); - throw(exception); - } - } - - -// --------------------------------------------------------------------------- -// CpCertTrustView::UpdateListBoxL() -// Puts correct Trust Settings text to listbox and correct value (yes/no) -// to the setting, asks the value from CheckCertificateClientTrust -// For X509 certificates, only one Application is currently supported -// (Application controller), more applications maybe added later however, -// so one additional application has been left in comments as an example. -// WAP connection and Application installer have their names from resources -// and thus localized, other additional application get their names from -// TCertificateAppInfo's Name() function. -// --------------------------------------------------------------------------- -// - -void CpCertTrustView::updateListBoxL() - { - RDEBUG("0", 0); - mClientUids.Reset(); - - TInt clientCount = 0; - - // Use certificate index from previous view - CCTCertInfo* entry = mCertDataContainer.iCALabelEntries[ mCertificateIndex ]->iCAEntry; - - // Here MCTCertApps should be used to get client options, but it is not properly - // supported in any cert store. It should be possible to get the MCTCertApps - // through token's GetInterface function. - if ( entry->Token().TokenType().Type() == TUid::Uid( KTokenTypeFileCertstore ) ) - { - if ( !mAppInfoManager ) - { - User::Leave( KErrArgument ); - } - RArray apps; - apps = mAppInfoManager->Applications(); - for ( TInt i = 0; i < apps.Count(); i++ ) - { - if ( apps[i].Id() != KCertManUIViewTrustJavaInstallingId && - apps[i].Id() != KCertManUIViewTrustApplicationControllerId ) - { - mClientUids.Append( apps[i].Id() ); - } - } - } - else - { - mCertDataContainer.iWrapper->GetApplicationsL( - mCertDataContainer.CertManager(), *entry, mClientUids ); - } - - // This is needed because MIDPCertStore does not support MCTCertApps - if ( mClientUids.Count() == 0 && - entry->Token().TokenType().Type() == TUid::Uid( KMidpCertStoreUid ) ) - { - mClientUids.Append( KCertManUIViewTrustJavaInstallingId ); - } - - if ( EX509Certificate != entry->CertificateFormat() ) - { - return; - } - TInt resIndex = KErrNotFound; - QList itemArray; - QList trustValue; - clientCount = mClientUids.Count(); - if ( clientCount > 0 ) - { - for ( TInt k = 0; k < clientCount; k++ ) - { - resIndex = trustIdIndex( mClientUids[k] ); - if ( resIndex == KErrNotFound ) - { - continue; - } - - // based on the trust list update the array - TBool trustState = EFalse; - QString item = mTrustedClients[ resIndex ]; - trustState = checkCertificateClientTrustL( mClientUids[k], *entry ); - // insert the index which would be used to retrieve the value from mTrustedClients - itemArray.insert(k,resIndex); - - if ( trustState ) - { - trustValue.insert(k,1); - } - else - { - trustValue.insert(k,0); - } - } - } - // display the list - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); - setLayout(layout); - std::auto_ptr form(new HbDataForm()); - mFormModel = new HbDataFormModel(); - - HbListWidget* mCertLabelList = new HbListWidget(this); - std::auto_ptr certLabel(q_check_ptr(new HbListWidgetItem())); - const TDesC& label = entry->Label(); - certLabel->setText(QString( (QChar*)label.Ptr(),label.Length() ) ); - mCertLabelList->addItem(certLabel.get()); - certLabel.release(); - - RDEBUG("0", 0); - - int count = itemArray.size(); - for( int index = 0 ;index < count; ++index) - { - std::auto_ptr item (q_check_ptr(new HbDataFormModelItem( - HbDataFormModelItem::ToggleValueItem, - mTrustedClients[itemArray[index]] ) )); - - if( trustValue[index] == 1) - { - item->setContentWidgetData("text",mTrustValues[0]); - item->setContentWidgetData("additionalText",mTrustValues[1]); - } - else - { - item->setContentWidgetData("text",mTrustValues[1]); - item->setContentWidgetData("additionalText",mTrustValues[0]); - } - mFormModel->appendDataFormItem(item.get()); - item.release(); - } - - form->setModel(mFormModel); - layout->addItem(mCertLabelList); - layout->addItem(form.get()); - form.release(); - } - - -void CpCertTrustView::saveTrustSettings() - { - RDEBUG("0", 0); - CCTCertInfo& entry = *( mCertDataContainer.iCALabelEntries[ mCertificateIndex ]->iCAEntry ); - if ( entry.IsDeletable() ) - { - TInt itemCount = mFormModel->rowCount(); - RArray newUids; - QT_TRAP_THROWING - ( - CleanupClosePushL( newUids ); - - for(int index = 0;indexitem(index); - QString trustValue = item->contentWidgetData("text").toString(); - if(trustValue == "On") - { - newUids.Append(trusterId(mTrustedClients[index])); - } - } - if(newUids.Count() > 0 ) - { - mCertDataContainer.iWrapper->SetApplicabilityL( mCertDataContainer.CertManager(), entry, newUids ); - } - CleanupStack::PopAndDestroy(&newUids); - ) - } - } - -TUid CpCertTrustView::trusterId(const QString& clientDescription) const - { - RDEBUG("0", 0); - TUid retValue = TUid::Uid(0); - if( clientDescription == " \tWAP connection\t\t" ) - retValue = KCertManUIViewTrustWapConnectionId; - else if( clientDescription == " \tMail and Image conn.\t\t" ) - retValue = KCertManUIViewTrustMailAndImageConnId; - else if( clientDescription == " \tNative installing\t\t" ) - retValue = KCertManUIViewTrustApplicationControllerId; - else if( clientDescription == " \tJava installing\t\t" ) - retValue = KCertManUIViewTrustJavaInstallingId; - else if( clientDescription == " \tOCSP validation\t\t" ) - retValue = KCertManUIViewOCSPCheckInstallingId; - else if( clientDescription == " \tVPN\t\t" ) - retValue = KCertManUIViewTrustVPNId; - else if( clientDescription == " \tWidget Installation\t\t" ) - retValue = KCertManUIViewTrustWidgetInstallId; - return retValue; - } - -// --------------------------------------------------------------------------- -// CpCertTrustView::trustIdIndex( TUid trustUid ) -// --------------------------------------------------------------------------- -// -TInt CpCertTrustView::trustIdIndex( TUid trustUid ) const - { - RDEBUG("0", 0); - TInt resIndex = KErrNotFound; - - if ( trustUid == KCertManUIViewTrustApplicationControllerId ) - { - resIndex = KTrustSettingsResourceIndexAppCtrl; - } - else if( trustUid == KCertManUIViewTrustWapConnectionId ) - { - resIndex = KTrustSettingsResourceIndexWAP; - } - else if ( trustUid == KCertManUIViewTrustMailAndImageConnId ) - { - resIndex = KTrustSettingsResourceIndexMailAndImageConn; - } - else if ( trustUid == KCertManUIViewTrustJavaInstallingId ) - { - resIndex = KTrustSettingsResourceIndexJavaInstall; - } - else if ( trustUid == KCertManUIViewOCSPCheckInstallingId ) - { - resIndex = KTrustSettingsResourceIndexOCSPCheck; - } - else if ( trustUid == KCertManUIViewTrustVPNId ) - { - resIndex = KTrustSettingsResourceIndexVPN; - } - else if ( trustUid == KCertManUIViewTrustWidgetInstallId ) - { - resIndex = KTrustSettingsResourceIndexWidget; - } - return resIndex; - } - - -// --------------------------------------------------------------------------- -// CpCertTrustView::CheckCertificateClientTrustL(const TUid aClientTUid, -// CCTCertInfo& aEntry) const -// Checks if a certificate trusts a client -// * Certificate format == ECrX509Certificate ECrX968Certificate ECrCertificateURL -// are not supported if certificate location == ECrCertLocationWIMCard -// * Certificate format == ECrX968Certificate ECrCertificateURL are not supported -// if certificate location == ECrCertLocationCertMan -// * Certificate location == ECrCertLocationWIMURL ECrCertLocationPhoneMemory -// ECrCertLocationPhoneMemoryURL are not supported -// --------------------------------------------------------------------------- -// -TBool CpCertTrustView::checkCertificateClientTrustL( - const TUid clientUid, const CCTCertInfo& entry ) const - { - RDEBUG("0", 0); - TBool trustSettingTrusted = EFalse; - TCertificateFormat format = entry.CertificateFormat(); - - if ( format == EX509Certificate ) - { - - RArray trusterUids; - CleanupClosePushL( trusterUids ); - - //Owned by mCertDataContainer. - CUnifiedCertStore*& store = mCertDataContainer.CertManager(); - // Get trusting applications' Uids for the one selected - // certificate entry - mCertDataContainer.iWrapper->GetApplicationsL( store, entry, trusterUids ); - - // get the number of trusting applications for one - // selected certificate entry - TInt trusterCount = trusterUids.Count(); - // in this loop, for every trusting application in one - // selected certificate entry - for ( TInt i = 0; i < trusterCount; ++i ) - { - // put the trusting application's Uid to TUid truster - if ( clientUid == trusterUids[i] ) - { - trustSettingTrusted = ETrue; - break; - } - } - CleanupStack::PopAndDestroy(&trusterUids); - } - - return trustSettingTrusted; - } - -// End of File - diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/cpcertview.cpp --- a/cpsecplugins/cpadvancedsecplugin/src/cpcertview.cpp Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,928 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0"" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include <../../inc/cpsecplugins.h> -#include "cpcertdetailview.h" -#include "cpcertview.h" -#include "cpcertdatacontainer.h" -#include "cpcerttrustview.h" -#include "cpcertmanuisyncwrapper.h" - - -CpCertView::CpCertView(const QModelIndex& modelIndex, QGraphicsItem *parent /*= 0*/) - : CpBaseSettingView(0,parent), - mPopup(NULL), mOkAction(NULL), - mPrevView(NULL), - mCurrentView(NULL), - mRefreshedView(NULL), - mListView(NULL), - mSelectAllView(NULL), - mOriginalView(NULL), - mNote(NULL) - { - RDEBUG("0", 0); - mOriginalView = mainWindow()->currentView(); - - HbMenu* menu = this->menu(); - std::auto_ptr deleteAction(new HbAction(hbTrId("txt_common_menu_delete"))); - connect(deleteAction.get(), SIGNAL(triggered()), this, SLOT(deleteList())); - menu->addAction(deleteAction.get()); - deleteAction.release(); - - std::auto_ptr layout(new QGraphicsLinearLayout(Qt::Vertical)); - - HbDataForm *form = q_check_ptr(new HbDataForm(this)); - std::auto_ptr formModel(q_check_ptr(new HbDataFormModel())); - form->setModel(formModel.get()); - formModel.release(); - - HbListWidget* certificateList = q_check_ptr(new HbListWidget(this)); - - CpCertView::TCertificateViews currentView = (CpCertView::TCertificateViews)modelIndex.row(); - QString title; - if(currentView == EPersonalView) - { - title = "Move to Device"; - } - else if(currentView == EDeviceView) - { - title = "Move to Personal"; - } - RDEBUG("0", 0); - if(currentView == EPersonalView || currentView == EDeviceView) - { - std::auto_ptr moveToDeviceAction(q_check_ptr(new HbAction(title))); - connect(moveToDeviceAction.get(), SIGNAL(triggered()), this, SLOT(moveCert())); - menu->addAction(moveToDeviceAction.get()); - moveToDeviceAction.release(); - } - - setDetails(currentView); - TInt count = 0; - try - { - QT_TRAP_THROWING(mCertDataContainer = CpCertDataContainer::NewL()); - QT_TRAP_THROWING(count = refreshListL()); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - throw(exception); - } - RDEBUG("0", 0); - for(int index = 0; index< count; index++) - { - QString certificateLabel = certLabel(index); - std::auto_ptr singleCert(q_check_ptr(new HbListWidgetItem())); - singleCert->setText(certificateLabel); - certificateList->addItem(singleCert.get()); - singleCert.release(); - } // End of FOR loop - - connect(certificateList, SIGNAL(activated(QModelIndex)), this, SLOT(openCertFromList(QModelIndex))); - connect(certificateList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF )), this, SLOT(indicateLongPress(HbAbstractViewItem*, QPointF))); - - layout->addItem(certificateList); - setLayout(layout.get()); - layout.release(); - - mPopup = q_check_ptr(new HbDialog()); - mContextMenu = q_check_ptr(new HbMenu()); - - RDEBUG("0", 0); - } - -CpCertView::~CpCertView() - { - delete mCertDataContainer; - mCertDataContainer = NULL; - RDEBUG("0", 0); - if(mPrevView) - { - mPrevView->deleteLater(); - mPrevView= NULL; - } - if(mCurrentView) - { - mCurrentView->deleteLater(); - mCurrentView= NULL; - } - if(mRefreshedView) - { - mRefreshedView->deleteLater(); - mRefreshedView= NULL; - } - if(mListView) - { - mListView->deleteLater(); - mListView= NULL; - } - - if(mSelectAllView) - { - mSelectAllView->deleteLater(); - mSelectAllView = NULL; - } - - mSelectionIndex.Close(); - - mIndexList.Close(); - - delete mPopup; - - delete mNote; - mNote = NULL; - - delete mContextMenu; - - } - -void CpCertView::setDetails(CpCertView::TCertificateViews currentView) - { - RDEBUG("0", 0); - switch(currentView) - { - case EAuthorityView: - setTitle(hbTrId("txt_certificate_manager_list_authority_certificate")); - mCertView = EAuthorityView; - break; - - case ETrustedView: - setTitle(hbTrId("txt_certificate_manager_list_trusted_site_certific")); - mCertView = ETrustedView; - break; - - case EPersonalView: - setTitle(hbTrId("txt_certificate_manager_list_personal_certificates")); - mCertView = EPersonalView; - break; - - case EDeviceView: - setTitle(hbTrId("txt_certificate_manager_list_device_certificates")); - mCertView = EDeviceView; - break; - } - } - -void CpCertView::indicateLongPress(HbAbstractViewItem *item,QPointF coords) - { - RDEBUG("0", 0); - mPos = item->modelIndex().row(); // Pos will tell you what is the certificate clicked in particular view. - - mContextMenu->clearActions(); - std::auto_ptr open(q_check_ptr(new HbAction(hbTrId("txt_common_menu_open")))); - connect(open.get(), SIGNAL(triggered()), this, SLOT( openCertificate())); - mContextMenu->addAction(open.get()); - open.release(); - - QString moveTitle; - - if(mCertView == EAuthorityView) - { - std::auto_ptr trustSettings(q_check_ptr(new HbAction(hbTrId("txt_certificate_manager_menu_trust_settings")))); - connect(trustSettings.get(), SIGNAL(triggered()), this, SLOT(showTrustSettings())); - mContextMenu->addAction(trustSettings.get()); - trustSettings.release(); - } - else if(mCertView == EPersonalView) - { - moveTitle = hbTrId("txt_certificate_manager_menu_move_to_device_certif"); - } - else if(mCertView == EDeviceView) - { - moveTitle = hbTrId("txt_certificate_manager_menu_move_to_personal_cert"); - } - - if(mCertView == EPersonalView || mCertView == EDeviceView ) - { - std::auto_ptr moveCert(q_check_ptr(new HbAction(moveTitle))); - connect(moveCert.get(), SIGNAL(triggered()), this, SLOT(moveSelectedCert())); - mContextMenu->addAction(moveCert.get()); - moveCert.release(); - } - - RDEBUG("0", 0); - if( certAt(mPos)->IsDeletable() ) - { - std::auto_ptr menuDelete(q_check_ptr(new HbAction(hbTrId("txt_common_menu_delete")))); - connect(menuDelete.get(), SIGNAL(triggered()), this, SLOT(deleteCertificate())); - mContextMenu->addAction(menuDelete.get()); - menuDelete.release(); - } - mContextMenu->setPreferredPos(coords); - mContextMenu->open(); - } - -void CpCertView::openCertFromList(const QModelIndex& modelIndex) - { - RDEBUG("0", 0); - // Pos will tell you what is the certificate clicked in particular view. - mPos = modelIndex.row(); - openCertificate(); - } - -void CpCertView::openCertificate() - { - RDEBUG("0", 0); - mCurrentView = q_check_ptr(new CpCertDetailView(mCertView,mPos,*mCertDataContainer)); - connect(mCurrentView, SIGNAL(aboutToClose()), this, SLOT(displayPreviousView())); - mPrevView = mainWindow()->currentView(); - mainWindow()->addView(mCurrentView); - mainWindow()->setCurrentView(mCurrentView); - } - -void CpCertView::displayPreviousView() - { - RDEBUG("0", 0); - mainWindow()->removeView(mCurrentView); - mCurrentView->deleteLater(); - mCurrentView= NULL; - mainWindow()->setCurrentView(mPrevView); - } - -void CpCertView::deleteCertificate() - { - RDEBUG("0", 0); - RArray pos; - pos.Append(mPos); - QT_TRAP_THROWING(deleteCertsL(pos)); - } - -void CpCertView::deleteList() - { - RDEBUG("0", 0); - mSelectAll = EFalse; - mPopup->setDismissPolicy(HbDialog::NoDismiss); - // Set the label as heading widget - mPopup->setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_setlabel_certificates")))); - - std::auto_ptr layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical))); - - mSelectAllView = q_check_ptr(new HbListView(this)); - QStandardItemModel* selectAllModel = q_check_ptr(new QStandardItemModel(this)); - // Populate the model with content - std::auto_ptr selectAllItem(q_check_ptr(new QStandardItem())); - selectAllItem->setData(QString("Select All"),Qt::DisplayRole); - selectAllModel->appendRow(selectAllItem.get()); - selectAllItem.release(); - - connect(mSelectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll())); - mSelectAllView->setModel(selectAllModel); - mSelectAllView->setSelectionMode(HbListView::MultiSelection); - layout->addItem(mSelectAllView); - - mListView = q_check_ptr(new HbListView(this)); - // Connect to "activated" signal - connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex))); - - // Create a model - QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this)); - TInt count=0; - QT_TRAP_THROWING( count = refreshListL()); - RDEBUG("0", 0); - for(TInt index = 0; index < count ; ++index) - { - const CCTCertInfo* cert = certAt(index); - if( cert->IsDeletable() ) - { - // Populate the model with content - std::auto_ptr certItem(q_check_ptr(new QStandardItem())); - QString certificateLabel = certLabel(index); - certItem->setData( certificateLabel, Qt::DisplayRole); - model->appendRow(certItem.get()); - mSelectionIndex.Append(index); - certItem.release(); - } - } - // Set the model to the list view - mListView->setModel(model); - mListView->setSelectionMode(HbListView::MultiSelection); - layout->addItem(mListView); - - std::auto_ptr widget( q_check_ptr(new HbWidget())); - widget->setLayout(layout.get()); - layout.release(); - mPopup->setContentWidget(widget.get()); - widget.release(); - - mPopup->clearActions(); - mOkAction = q_check_ptr(new HbAction(hbTrId("txt_common_opt_delete"))); - mPopup->addAction(mOkAction); - HbAction *cancelAction = q_check_ptr(new HbAction(hbTrId("txt_common_button_cancel"))); - mPopup->addAction(cancelAction); - mPopup->setTimeout(HbPopup::NoTimeout); - RDEBUG("0", 0); - // Launch popup syncronously - mPopup->open(this, SLOT(handleMultipleDelete(HbAction*))); - -} - -void CpCertView::handleMultipleDelete(HbAction* action) -{ - RDEBUG("0", 0); - if(action == mOkAction) - { - QItemSelectionModel *selectionModel = mListView->selectionModel(); - QModelIndexList mWidgetItemsToRemove = selectionModel->selectedIndexes(); - TInt deleteCount = mWidgetItemsToRemove.count(); - // start deleting from end of array so that the indexes do not changes of the ones - // at the front. - RArray actualIndex; - QT_TRAP_THROWING - ( - CleanupClosePushL(actualIndex); - for (TInt index = deleteCount-1; index>= 0 ; --index) - { - TInt selectedItemIndex = mWidgetItemsToRemove[index].row(); - actualIndex.Append( mSelectionIndex[selectedItemIndex] ); - } - deleteCertsL(actualIndex); - CleanupStack::PopAndDestroy(&actualIndex); - ) // QT_TRAP_THROWING - } - RDEBUG("0", 0); - mListView->deleteLater(); - mListView = NULL; - mSelectAllView->deleteLater(); - mSelectAllView = NULL; - } - -void CpCertView::moveCert() - { - RDEBUG("0", 0); - mSelectAll = EFalse; - mPopup->setDismissPolicy(HbDialog::NoDismiss); - // Set the label as heading widget - if(mCertView == EPersonalView) - { - mPopup->setHeadingWidget(q_check_ptr(new HbLabel(tr("Move To Device")))); - } - else if(mCertView == EDeviceView) - { - mPopup->setHeadingWidget(q_check_ptr(new HbLabel(tr("Move To Personal")))); - } - - std::auto_ptr layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical))); - - mSelectAllView = q_check_ptr(new HbListView(this)); - QStandardItemModel* selectAllModel = q_check_ptr(new QStandardItemModel(this)); - // Populate the model with content - std::auto_ptr selectAllItem(q_check_ptr(new QStandardItem())); - selectAllItem->setData(QString("Select All"),Qt::DisplayRole); - selectAllModel->appendRow(selectAllItem.get()); - selectAllItem.release(); - connect(mSelectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll())); - mSelectAllView->setModel(selectAllModel); - mSelectAllView->setSelectionMode(HbListView::MultiSelection); - layout->addItem(mSelectAllView); - - mListView = q_check_ptr(new HbListView(this)); - // Connect to "activated" signal - connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex))); - - // Create a model - QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this)); - TInt count =0; - RDEBUG("0", 0); - QT_TRAP_THROWING(count = refreshListL()); - for(TInt index = 0; index < count ; ++index) - { - // Populate the model with content - std::auto_ptr certItem(q_check_ptr(new QStandardItem())); - QString certificateLabel = certLabel(index); - certItem->setData( certificateLabel, Qt::DisplayRole); - model->appendRow(certItem.get()); - mSelectionIndex.Append(index); - certItem.release(); - } - - // Set the model to the list view - mListView->setModel(model); - mListView->setSelectionMode(HbListView::MultiSelection); - layout->addItem(mListView); - - std::auto_ptr widget(q_check_ptr(new HbWidget())); - widget->setLayout(layout.get()); - layout.release(); - mPopup->setContentWidget(widget.get()); - widget.release(); - RDEBUG("0", 0); - mPopup->clearActions(); - mOkAction = q_check_ptr(new HbAction(tr("Yes"))); - mPopup->addAction(mOkAction); - HbAction *noAction = q_check_ptr(new HbAction(tr("No"))); - mPopup->addAction(noAction); - mPopup->setTimeout(HbPopup::NoTimeout); - - // Launch popup syncronously - mPopup->open(this, SLOT(handleMoveCertDialog(HbAction*))); - RDEBUG("0", 0); -} - -void CpCertView::handleMoveCertDialog(HbAction* action) -{ - RDEBUG("0", 0); - if(action == mOkAction) - { - QItemSelectionModel *selectionModel = mListView->selectionModel(); - QModelIndexList mWidgetItemsToRemove = selectionModel->selectedIndexes(); - TInt deleteCount = mWidgetItemsToRemove.count(); - // start deleting from end of array so that the indexes do not changes of the ones - // at the front. - RArray actualIndex; - RDEBUG("0", 0); - QT_TRAP_THROWING - ( - CleanupClosePushL(actualIndex); - for (TInt index = deleteCount-1; index>= 0 ; --index) - { - TInt selectedItemIndex = mWidgetItemsToRemove[index].row(); - actualIndex.Append(mSelectionIndex[selectedItemIndex]); - } - moveCertList(actualIndex); - CleanupStack::PopAndDestroy(&actualIndex); - ) - } - mListView->deleteLater(); - mListView = NULL; - mSelectAllView->deleteLater(); - mSelectAllView = NULL; - RDEBUG("0", 0); - } - -void CpCertView::selectAll() - { - RDEBUG("0", 0); - if(mSelectAll == EFalse) - { - mListView->selectAll(); - mSelectAll= ETrue; - } - else - { - mListView->clearSelection(); - mSelectAll= EFalse; - } - } - -void CpCertView::deleteCertsL( RArray& indexList ) - { - RDEBUG("0", 0); - TInt count = indexList.Count(); - for(int index = 0;index Label().Ptr(),entry->Label().Length()); - } - else - { - deleteMsg = "Delete %1 items?"; - sCount.setNum(count); - } - RDEBUG("0", 0); - deleteMsg = deleteMsg.arg(sCount); - mNote->setText(deleteMsg); - mNote->setTimeout(HbPopup::NoTimeout); - mNote->open(this,SLOT(handleDeleteDialog(HbAction*))); - -} - -void CpCertView::handleDeleteDialog(HbAction* action) -{ - RDEBUG("0", 0); - TInt count = mIndexList.Count(); - - if (action != mNote->primaryAction() || count == 0 ) - { - return; - } - - RPointerArray errCerts; - QT_TRAP_THROWING( - CleanupClosePushL(errCerts); - - for(TInt index = 0; index < count; ++index) - { - const CCTCertInfo* entry = certAt(mIndexList[index]); - - if( mCertView == EPersonalView || mCertView == EAuthorityView ) - { - mCertDataContainer->iWrapper->DeleteCertL( - mCertDataContainer->CertManager(), *entry ); - } - else if( mCertView == ETrustedView ) - { - mCertDataContainer->iWrapper->DeleteCertL( - mCertDataContainer->CertManager(),*entry, KCMTrustedServerTokenUid ); - } - else if( mCertView == EDeviceView ) - { - mCertDataContainer->iWrapper->DeleteCertL( - mCertDataContainer->CertManager(), *entry, KCMDeviceCertStoreTokenUid ); - } - errCerts.AppendL(entry); - } - RDEBUG("0", 0); - if(errCerts.Count() > 0) - { - QString message("Unable to delete the following certificate: \n"); - TInt count = errCerts.Count(); - for(TInt index=0;indexLabel(); - QString certName = QString((QChar*)certLabel.Ptr(),certLabel.Length()); - message.append(certName).append("\n"); - } - HbMessageBox::warning(message); - } - count = refreshListL(); - refreshView(count); - - CleanupStack::PopAndDestroy(&errCerts); - ) // QT_TRAP_THROWING - - delete mNote; - mNote = NULL; - RDEBUG("0", 0); - } - -const CCTCertInfo* CpCertView::certAt(TInt index) const - { - RDEBUG("0", 0); - CCTCertInfo* currentCert = NULL; - switch(mCertView) - { - case EAuthorityView: - { - currentCert = mCertDataContainer->iCALabelEntries[ index ]->iCAEntry; - break; - } - case ETrustedView: - { - currentCert = mCertDataContainer->iPeerLabelEntries[ index ]->iPeerEntry; - break; - } - case EDeviceView: - { - currentCert = mCertDataContainer->iDeviceLabelEntries[ index ]->iDeviceEntry; - break; - } - case EPersonalView: - { - currentCert = mCertDataContainer->iUserLabelEntries[ index ]->iUserEntry; - break; - } - }; - return currentCert; - } - -QString CpCertView::certLabel(TInt index) const - { - RDEBUG("0", 0); - CpCertManUICertData* certData = NULL; - HBufC* label = NULL; - TInt length = 0; - switch(mCertView) - { - case EAuthorityView: - { - certData = mCertDataContainer->iCALabelEntries[index]; - label = certData->iCAEntryLabel; - length = certData->iCAEntryLabel->Length(); - break; - } - case ETrustedView: - { - certData = mCertDataContainer->iPeerLabelEntries[index]; - label = certData->iPeerEntryLabel; - length = certData->iPeerEntryLabel->Length(); - break; - } - case EPersonalView: - { - certData = mCertDataContainer->iUserLabelEntries[index]; - label = certData->iUserEntryLabel; - length = certData->iUserEntryLabel->Length(); - break; - } - case EDeviceView: - { - certData = mCertDataContainer->iDeviceLabelEntries[index]; - label = certData->iDeviceEntryLabel; - length = certData->iDeviceEntryLabel->Length(); - break; - } - } - return QString((QChar*)label->Des().Ptr(), length); - } - -TInt CpCertView::refreshListL() - { - RDEBUG("0", 0); - TInt count = 0; - switch(mCertView) - { - case EAuthorityView: - mCertDataContainer->RefreshCAEntriesL(); - count = mCertDataContainer->iCALabelEntries.Count(); - break; - case ETrustedView: - mCertDataContainer->RefreshPeerCertEntriesL(); - count = mCertDataContainer->iPeerLabelEntries.Count(); - break; - case EPersonalView: - mCertDataContainer->RefreshUserCertEntriesL(); - count = mCertDataContainer->iUserLabelEntries.Count(); - break; - case EDeviceView: - mCertDataContainer->RefreshDeviceCertEntriesL(); - count = mCertDataContainer->iDeviceLabelEntries.Count(); - break; - }; - return count; - } - - -void CpCertView::refreshView( TInt count ) - { - RDEBUG("0", 0); - if(mRefreshedView) - { - mRefreshedView->deleteLater(); - mRefreshedView = NULL; - } - - mRefreshedView = q_check_ptr(new CpBaseSettingView()); - switch(mCertView) - { - case EAuthorityView: - { - mRefreshedView->setTitle(hbTrId("txt_certificate_manager_list_authority_certificate")); - break; - } - case ETrustedView: - { - mRefreshedView->setTitle(hbTrId("txt_certificate_manager_list_trusted_site_certific")); - break; - } - case EPersonalView: - { - mRefreshedView->setTitle(hbTrId("txt_certificate_manager_list_personal_certificates")); - break; - } - case EDeviceView: - { - mRefreshedView->setTitle(hbTrId("txt_certificate_manager_list_device_certificates")); - break; - } - } - - HbMenu* menu = mRefreshedView->menu(); - RDEBUG("0", 0); - std::auto_ptr endAction( q_check_ptr(new HbAction(hbTrId("txt_common_opt_delete"))) ); - connect(endAction.get(), SIGNAL(triggered()), this, SLOT(deleteList())); - menu->addAction(endAction.get()); - endAction.release(); - - QString title; - if(mCertView == EPersonalView) - { - title = "Move to Device"; - } - else if(mCertView == EDeviceView) - { - title = "Move to Personal"; - } - std::auto_ptr moveAction(q_check_ptr(new HbAction(title))); - connect(moveAction.get(), SIGNAL(triggered()), this, SLOT(moveCert())); - menu->addAction(moveAction.get()); - moveAction.release(); - RDEBUG("0", 0); - std::auto_ptr layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical))); - - HbListWidget* mCertificateList = q_check_ptr(new HbListWidget(this)); - - for(int index = 0; index< count; index++) - { - QString certificateLabel = certLabel(index); - std::auto_ptr singleCert(q_check_ptr(new HbListWidgetItem())); - singleCert->setText(certificateLabel); - mCertificateList->addItem(singleCert.get()); - singleCert.release(); - } // end of for loop - - connect(mCertificateList, SIGNAL(activated(QModelIndex)), this, SLOT(openCertFromList(QModelIndex))); - connect(mCertificateList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF )), this, SLOT(indicateLongPress(HbAbstractViewItem*, QPointF))); - - layout->addItem(mCertificateList); - RDEBUG("0", 0); - // Refresh current view - QObject::connect(mRefreshedView , SIGNAL(aboutToClose()), this, SLOT(viewDone())); - mPrevView = mainWindow()->currentView(); - mainWindow()->addView(mRefreshedView); - mainWindow()->setCurrentView(mRefreshedView); - mRefreshedView->setLayout(layout.get()); - layout.release(); - RDEBUG("0", 0); - } - - -void CpCertView::viewDone() - { - RDEBUG("0", 0); - mCurrentView = mainWindow()->currentView(); - mCurrentView->deleteLater(); - mCurrentView= NULL; - mainWindow()->setCurrentView(mOriginalView); - } -void CpCertView::showTrustSettings() - { - RDEBUG("0", 0); - mCurrentView = q_check_ptr(new CpCertTrustView(mPos, *mCertDataContainer)); - connect(mCurrentView , SIGNAL(aboutToClose()), this, SLOT(saveTrustSettings())); - mPrevView = mainWindow()->currentView(); - mainWindow()->addView(mCurrentView); - mainWindow()->setCurrentView(mCurrentView); - } - -void CpCertView::saveTrustSettings() - { - ((CpCertTrustView*)mCurrentView)->saveTrustSettings(); - displayPreviousView(); - } - -void CpCertView::moveSelectedCert() - { - RDEBUG("0", 0); - RArray pos; - pos.Append(mPos); - moveCertList(pos); - } - -void CpCertView::moveCertList(RArray& indexList) - { - RDEBUG("0", 0); - mIndexList = indexList; - mNote = new HbMessageBox(HbMessageBox::MessageTypeQuestion); - mNote->setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_info_move")))); - if( mCertView == EPersonalView ) - { - mNote->setText(hbTrId("txt_certificate_manager_info_device_certificates_c")); - } - else if( mCertView == EDeviceView ) - { - mNote->setText("Use of Personal certificates may require user confirmation. Proceed?"); - } - - mNote->setTimeout(HbPopup::NoTimeout); - mNote->setIconVisible (EFalse); - mNote->open(this,SLOT(handleMoveDialog(HbAction*))); - RDEBUG("0", 0); -} - -void CpCertView::handleMoveDialog(HbAction* action) -{ - RDEBUG("0", 0); - if (action != mNote->primaryAction()) - { - return; - } - - TInt count = mIndexList.Count(); - - for(TInt index = 0 ; index < count; ++index) - { - CCTCertInfo* entry = NULL; - if(mCertView == EPersonalView) - { - entry = mCertDataContainer->iUserLabelEntries[ mIndexList[index] ]->iUserEntry; - } - else if(mCertView == EDeviceView) - { - entry = mCertDataContainer->iDeviceLabelEntries[ mIndexList[index] ]->iDeviceEntry; - } - - // Move key first - TCTKeyAttributeFilter keyFilter; - keyFilter.iKeyId = entry->SubjectKeyId(); - keyFilter.iPolicyFilter = TCTKeyAttributeFilter::EAllKeys; - RDEBUG("0", 0); - TUid sourceCertStoreUid = TUid::Uid(0); - TUid targetCertStoreUid = TUid::Uid(0); - TUid sourceKeyStoreUid = TUid::Uid(0); - TUid targetKeyStoreUid = TUid::Uid(0); - - if(mCertView == EPersonalView) - { - sourceKeyStoreUid = KCMFileKeyStoreTokenUid; - targetKeyStoreUid = KCMDeviceKeyStoreTokenUid; - sourceCertStoreUid = KCMFileCertStoreTokenUid; - targetCertStoreUid = KCMDeviceCertStoreTokenUid; - } - else if(mCertView == EDeviceView) - { - sourceKeyStoreUid = KCMDeviceKeyStoreTokenUid; - targetKeyStoreUid = KCMFileKeyStoreTokenUid; - sourceCertStoreUid = KCMDeviceCertStoreTokenUid; - targetCertStoreUid = KCMFileCertStoreTokenUid; - } - RDEBUG("0", 0); - try - { - - QT_TRAP_THROWING( mCertDataContainer->iWrapper->MoveKeyL( - mCertDataContainer->KeyManager(), keyFilter, sourceKeyStoreUid, targetKeyStoreUid )); - - // Move certificate - QT_TRAP_THROWING( mCertDataContainer->iWrapper->MoveCertL( - mCertDataContainer->CertManager(), *entry, sourceCertStoreUid, targetCertStoreUid ) ); - - } - catch(const std::exception& exception) - { - QString error(exception.what()); - QT_TRAP_THROWING(mCertDataContainer->ShowErrorNoteL( error.toInt() )); - User::Exit( KErrNone ); - } - RDEBUG("0", 0); - try - { - if(mCertView == EPersonalView) - { - QT_TRAP_THROWING( mCertDataContainer->RefreshUserCertEntriesL() ); - } - else if(mCertView == EDeviceView) - { - QT_TRAP_THROWING( mCertDataContainer->RefreshDeviceCertEntriesL() ); - } - } - catch(const std::exception& exception) - { - QString error(exception.what()); - if ( error.toInt() == KErrCorrupt ) - { - QT_TRAP_THROWING(mCertDataContainer->ShowErrorNoteL( error.toInt()) ); - User::Exit( KErrNone ); - } - // have to call straight away the Exit - // showing any error notes would corrupt the display - User::Exit( error.toInt() ); - } - } // for - // Refresh current view - QT_TRAP_THROWING(refreshView(refreshListL())); - delete mNote; - mNote = NULL; - RDEBUG("0", 0); - } - diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/cpmoduleview.cpp --- a/cpsecplugins/cpadvancedsecplugin/src/cpmoduleview.cpp Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,364 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0"" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include <../../inc/cpsecplugins.h> -#include "cpmoduleview.h" -#include "cpsecmodmodel.h" -#include "cpsecmodview.h" - -CpModuleView::CpModuleView( CpSecModView::TSecModViews currentView, - CSecModUIModel& secModUIModel, - QGraphicsItem *parent /*= 0*/ ) -: CpBaseSettingView(0,parent), - mCurrentView(currentView), - mSecModUIModel(secModUIModel) - { - RDEBUG("0", 0); - QString title = mSecModUIModel.TokenLabelForTitle(); - setTitle(title); - - mContextMenu = (q_check_ptr(new HbMenu())); - - if(currentView == CpSecModView::EAccessView) - { - showAccessView(); - } - else if(currentView == CpSecModView::ESignatureView) - { - showSignatureView(ETrue); - } - } - -CpModuleView::~CpModuleView() - {} - -void CpModuleView::showAccessView() - { - RDEBUG("0", 0); - HbMenu* menu = this->menu(); - std::auto_ptr endAction(q_check_ptr(new HbAction("Module Info"))); - connect(endAction.get(), SIGNAL(triggered()), this, SLOT(saveProv())); - - menu->addAction(endAction.get()); - endAction.release(); - - std::auto_ptr layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical))); - - std::auto_ptr form(q_check_ptr(new HbDataForm())); - std::auto_ptr formModel(q_check_ptr(new HbDataFormModel())); - form->setModel(formModel.get()); - formModel.release(); - - QString titleName; - if (mSecModUIModel.KeyStoreUID() == KTokenTypeFileKeystore) - { - titleName = "Phone key store code"; - } - else - { - const TDesC& label = mSecModUIModel.AuthObj(KPinGSettIndex).Label(); - titleName = QString((QChar*)label.Ptr(), label.Length()); - } - RDEBUG("0", 0); - HbListWidget* accessDetails = q_check_ptr(new HbListWidget(this)); - - std::auto_ptr codeLabel(q_check_ptr(new HbListWidgetItem())); - codeLabel->setText(titleName); - accessDetails->addItem(codeLabel.get()); - codeLabel.release(); - - std::auto_ptr codeText(q_check_ptr(new HbListWidgetItem())); - codeText->setText("****"); - accessDetails->addItem(codeText.get()); - codeText.release(); - - std::auto_ptr requestLabel(q_check_ptr(new HbListWidgetItem())); - requestLabel->setText("Access Code Request"); - accessDetails->addItem(requestLabel.get()); - requestLabel.release(); - - TUint32 status = mSecModUIModel.AuthStatus(KPinGSettIndex); - std::auto_ptr requestText(q_check_ptr(new HbListWidgetItem())); - requestText->setText("Off"); - if (status & EEnabled) - { - requestText->setText("On"); - } - accessDetails->addItem(requestText.get()); - requestText.release(); - RDEBUG("0", 0); - std::auto_ptr statusLabel(q_check_ptr(new HbListWidgetItem())); - statusLabel->setText("Status"); - accessDetails->addItem(statusLabel.get()); - statusLabel.release(); - - std::auto_ptr statusText(q_check_ptr(new HbListWidgetItem())); - QString pinStatus = mSecModUIModel.PINStatus(KPinGSettIndex, ETrue); - statusText->setText(pinStatus); - accessDetails->addItem(statusText.get()); - statusText.release(); - - connect(accessDetails, SIGNAL(longPressed(HbAbstractViewItem*, QPointF )), this, SLOT(indicateLongPress(HbAbstractViewItem*, QPointF))); - connect(formModel.get(), SIGNAL(activated(QModelIndex)), this, SLOT(handleAccessView(QModelIndex))); - - layout->addItem(accessDetails); - layout->addItem(form.get()); - form.release(); - setLayout(layout.get()); - layout.release(); - RDEBUG("0", 0); - } - -void CpModuleView::showSignatureView(TBool showBlockedNote) - { - RDEBUG("0", 0); - mCurrentView = CpSecModView::ESignatureView; - std::auto_ptr layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical))); - std::auto_ptr form(q_check_ptr(new HbDataForm())); - std::auto_ptr formModel(q_check_ptr(new HbDataFormModel())); - - QVector< QPair > authDetails = mSecModUIModel.AuthDetails(); - QVectorIterator< QPair > authDetailsIter(authDetails); - - HbListWidget* accessDetails = q_check_ptr(new HbListWidget(this)); - - while(authDetailsIter.hasNext()) - { - QPair pair = authDetailsIter.next(); - QString label = pair.first; - TUint32 status = pair.second; - QString blockedDetails = NULL; - if ( status & EAuthObjectBlocked) - { - if (showBlockedNote) - { - QString totalBlocked(" is blocked. PUK code is needed to unblock the code"); - if (status & EUnblockDisabled) - { - totalBlocked = " totalblocked, contact your module vendor."; - } - totalBlocked.prepend(label); - HbMessageBox::information(totalBlocked); - } - blockedDetails = label.append(" Blocked"); - RDEBUG("0", 0); - std::auto_ptr statusLabel(q_check_ptr(new HbListWidgetItem())); - statusLabel->setText(tr("Status")); - accessDetails->addItem(statusLabel.get()); - statusLabel.release(); - - std::auto_ptr statusText(q_check_ptr(new HbListWidgetItem())); - QString pinStatus = mSecModUIModel.PINStatus(KPinNrSettIndex, ETrue); - statusText->setText(pinStatus); - accessDetails->addItem(statusText.get()); - statusText.release(); - } - else - { - std::auto_ptr unblockedLabel(q_check_ptr(new HbListWidgetItem())); - unblockedLabel->setText(label); - accessDetails->addItem(unblockedLabel.get()); - unblockedLabel.release(); - - std::auto_ptr unblockedText(q_check_ptr(new HbListWidgetItem())); - unblockedText->setText("****"); - accessDetails->addItem(unblockedText.get()); - unblockedText.release(); - } - } - form->setModel(formModel.get()); - formModel.release(); - layout->addItem(accessDetails); - - connect(accessDetails, SIGNAL(longPressed(HbAbstractViewItem*, QPointF )), this, SLOT(indicateLongPress(HbAbstractViewItem*, QPointF))); - connect(formModel.get(), SIGNAL(activated(QModelIndex)), this, SLOT(handleSigView())); - - layout->addItem(form.get()); - form.release(); - setLayout(layout.get()); - layout.release(); - RDEBUG("0", 0); - } - -void CpModuleView::indicateLongPress(HbAbstractViewItem *item,QPointF coords) - { - RDEBUG("0", 0); - try - { - mContextMenu->clearActions(); - mPos = item->modelIndex().row(); - - if(mCurrentView == CpSecModView::EAccessView) - { - if( mPos == EIndexCodeLabel && mSecModUIModel.PinChangeable(KPinGSettIndex) - || mPos == EIndexCodeRequest && mSecModUIModel.PinRequestChangeable(KPinGSettIndex) - || mPos == EIndexCodeStatus ) - { - std::auto_ptr changePIN(q_check_ptr(new HbAction("Change"))); - connect(changePIN.get(), SIGNAL(triggered()), this, SLOT( handleAccessView())); - mContextMenu->addAction(changePIN.get()); - changePIN.release(); - } - if( mSecModUIModel.PinUnblockable(KPinGSettIndex) ) - { - std::auto_ptr unblockPIN(q_check_ptr(new HbAction("Unblock"))); - connect(unblockPIN.get(), SIGNAL(triggered()), this, SLOT( handleAccessView())); - mContextMenu->addAction(unblockPIN.get()); - unblockPIN.release(); - } - if( mSecModUIModel.PinOpen(KPinGSettIndex) ) - { - std::auto_ptr closePIN(q_check_ptr(new HbAction("Close"))); - connect(closePIN.get(), SIGNAL(triggered()), this, SLOT( handleAccessView())); - mContextMenu->addAction(closePIN.get()); - closePIN.release(); - } - } - else if(mCurrentView == CpSecModView::ESignatureView) - { - if (mSecModUIModel.PinChangeable(KPinNrSettIndex)) - { - std::auto_ptr changePIN(q_check_ptr(new HbAction("Change"))); - connect(changePIN.get(), SIGNAL(triggered()), this, SLOT( handleSigViewCommand())); - mContextMenu->addAction(changePIN.get()); - changePIN.release(); - } - if (mSecModUIModel.PinUnblockable(KPinNrSettIndex)) - { - std::auto_ptr unblockPIN(q_check_ptr(new HbAction("Unblock"))); - connect(unblockPIN.get(), SIGNAL(triggered()), this, SLOT( handleSigViewCommand())); - mContextMenu->addAction(unblockPIN.get()); - unblockPIN.release(); - } - } - - mContextMenu->setPreferredPos(coords); - mContextMenu->open(); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - RDEBUG("0", 0); - } - -void CpModuleView::handleAccessView( const QModelIndex& modelIndex ) - { - RDEBUG("0", 0); - try - { - mPos = modelIndex.row(); - handleAccessView(); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - -void CpModuleView::handleAccessView() - { - RDEBUG("0", 0); - try - { - if(mPos == EIndexCodeLabel) - { - QT_TRAP_THROWING(mSecModUIModel.ChangeOrUnblockPinL(KPinGSettIndex)); - } - else if(mPos == EIndexCodeRequest) - { - if (KErrCancel == mSecModUIModel.ChangeCodeRequest(KPinGSettIndex)) - { - return; - } - } - else if ( mPos == EIndexCodeStatus) - { - QT_TRAP_THROWING(mSecModUIModel.CloseAuthObjL(KPinGSettIndex)); - } - showAccessView(); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - -void CpModuleView::handleSigView() - { - RDEBUG("0", 0); - try - { - QT_TRAP_THROWING(mSecModUIModel.ChangeOrUnblockPinL(KPinNrSettIndex)); - showSignatureView(EFalse); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - -void CpModuleView::handleSigViewCommand() - { - RDEBUG("0", 0); - try - { - switch(mPos) - { - case ESecModUICmdChange: - QT_TRAP_THROWING(mSecModUIModel.ChangePinNrL(mPos)); - showSignatureView(EFalse); - break; - case ESecModUICmdUnblock: - QT_TRAP_THROWING(mSecModUIModel.UnblockPinNrL(mPos)); - showSignatureView(EFalse); - break; - }; - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - - diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/cpsecmodmodel.cpp --- a/cpsecplugins/cpadvancedsecplugin/src/cpsecmodmodel.cpp Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,935 +0,0 @@ -/* -* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation of the CSecModUIModel class -* -*/ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include <../../inc/cpsecplugins.h> -#include "cpsecmodmodel.h" -#include "cpsecmodsyncwrapper.h" - -const TInt KWIMStoreUid ( 0x101F79D9 ); -_LIT(KSecModUIPanic, "Security Module UI panic"); - -// ============================= LOCAL FUNCTIONS =============================== -GLDEF_C void Panic(TInt aPanic) - { - User::Panic(KSecModUIPanic, aPanic); - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::NewL() -// Two-phased constructor. -// ----------------------------------------------------------------------------- -// -CSecModUIModel* CSecModUIModel::NewL() - { - RDEBUG("0", 0); - CSecModUIModel* self = new( ELeave ) CSecModUIModel(); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::CSecModUIModel -// C++ default constructor can NOT contain any code, that might leave. -// ----------------------------------------------------------------------------- -// -CSecModUIModel::CSecModUIModel() - {} - -// ----------------------------------------------------------------------------- -// CSecModUIModel::~CSecModUIModel -// C++ destructor -// ----------------------------------------------------------------------------- -// - -CSecModUIModel::~CSecModUIModel() - { - delete iWrapper; - ResetAndDestroyCTObjects(); - } -// ----------------------------------------------------------------------------- -// CSecModUIModel::ResetAndDestroyCTObjects(): Cleans up all objects referenced -// through the crypto token framework. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::ResetAndDestroyCTObjects() - { - ResetAndDestroyAOs(); - iAOKeyStores.Reset(); - delete iUnifiedKeyStore; - iUnifiedKeyStore = NULL; - iKeyStore = NULL; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::ResetAndDestroyAOs(): Cleans up the list of auth objects. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::ResetAndDestroyAOs() - { - RDEBUG("0", 0); - if (iAOList) - { - iAOList->Release(); - iAOList = NULL; - } - if (iAOArray.Count() > 0 && - iAOArray[0]->Token().TokenType().Type().iUid == KTokenTypeFileKeystore) - { - iAOArray.Reset(); - } - else - { - iAOArray.Close(); - } - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::ConstructL() -// Symbian 2nd phase constructor can leave. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::ConstructL() - { - InitializeKeyStoreL(); - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::InitializeKeyStoreL() -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::InitializeKeyStoreL() - { - RDEBUG("0", 0); - ResetAndDestroyCTObjects(); - - // Ensure that file server session is succesfully created - User::LeaveIfError( iRfs.Connect() ); - - iUnifiedKeyStore = CUnifiedKeyStore::NewL(iRfs); - - if (iWrapper == NULL) - { - iWrapper = CSecModUISyncWrapper::NewL(); - } - - TInt err = iWrapper->Initialize(*iUnifiedKeyStore); - - ShowErrorNote(err); - if (KErrNone != err && KErrHardwareNotAvailable != err) - { - User::Leave(err); - } - TInt keyStoreCount = iUnifiedKeyStore->KeyStoreCount(); - if (0 >= keyStoreCount) - { - return; - } - - RMPointerArray keyInfos; - CleanupClosePushL(keyInfos); - TCTKeyAttributeFilter filter; - TInt keyInfoCount = 0; - filter.iPolicyFilter = TCTKeyAttributeFilter::EAllKeys; - - for (TInt i = 0; i < keyStoreCount; i++) - { - err = iWrapper->ListKeys(iUnifiedKeyStore->KeyStore(i), keyInfos, filter); - User::LeaveIfError(err); - //If list ok, append the AO, otherwise go next - keyInfoCount = keyInfos.Count(); - for (TInt j = 0; j < keyInfoCount; j++) - { - // Check that keystore has at least one AO. - if (NULL != keyInfos[j]->Protector()) - { - // If keystore has AO, add it to the array. - User::LeaveIfError( - iAOKeyStores.Append(&(iUnifiedKeyStore->KeyStore(i)))); - break; - } - } - } - CleanupStack::PopAndDestroy(&keyInfos); - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::LoadTokenLabelsL() -// Retrieves the description and location of all tokens. -// ----------------------------------------------------------------------------- -// -QMap CSecModUIModel::LoadTokenLabelsL() - { - RDEBUG("0", 0); - TInt keyStoreCount = iAOKeyStores.Count(); - QMap labelList; - - if (0 == keyStoreCount) - { - return labelList; - } - - for (TInt i = 0; i < keyStoreCount; i++) - { - QString keystoreLabel = 0; - if (iAOKeyStores[i]->Token().TokenType().Type().iUid == KTokenTypeFileKeystore ) - { - keystoreLabel = "Phone keystore"; - } - else if(iAOKeyStores[i]->Token().TokenType().Type().iUid == KWIMStoreUid ) - { - const TDesC& label = iAOKeyStores[i]->Token().Label(); - keystoreLabel = QString( (QChar*) label.Ptr(), label.Length()); - } - else - { - continue; - } - QString location = Location(iAOKeyStores[i]->Token().TokenType().Type()); - labelList.insert(keystoreLabel,location); - } - return labelList; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::Location() -// Identifies the location of the keystore based on the Uid. -// ----------------------------------------------------------------------------- -// -QString CSecModUIModel::Location( TUid aUid ) const - { - RDEBUG("0", 0); - QString location = 0; - - switch ( aUid.iUid ) - { - case KTokenTypeFileKeystore: - { - location = "\nPhone memory"; - break; - } - case KWIMStoreUid: - { - location = "\nSmart card"; - break; - } - default: - { - break; - } - } - return location; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::ShowErrorNote(TInt aError) const -// Displays appropriate error message based on the error code. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::ShowErrorNote(TInt aError) const - { - QString sError; - RDEBUG("aError", aError); - switch (aError) - { - case KErrCancel: - case KErrLocked: - case KErrNone: - { - break; - } - case KErrInUse: - { - sError = "Key is currently in use. Unable to delete. Close applications and try again."; - break; - } - case KErrBadPassphrase: - { - sError = "Code incorrect"; - break; - } - case KErrHardwareNotAvailable: // flow thru - default: - { - sError = "Security module internal error"; - break; - } - } - - if ( sError.length() != 0 ) - { - HbMessageBox::information(sError); - } - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::OpenTokenL(TInt aTokenIndex) -// Retrieves the appropriate token based on the index. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::OpenTokenL(TInt aTokenIndex) - { - RDEBUG("0", 0); - ResetAndDestroyAOs(); - iKeyStore = iAOKeyStores[aTokenIndex]; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::CheckCodeViewStringsL() -// Initialize the auth objects and return the total count. -// ----------------------------------------------------------------------------- -// -TInt CSecModUIModel::CheckCodeViewStringsL() - { - InitAuthObjectsL(); - ListAuthObjectsL(); - return iAOArray.Count(); - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::InitAuthObjectsL() -// Retrieve the authentication object associated with the appropriate key store -// implementation. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::InitAuthObjectsL() - { - RDEBUG("0", 0); - TInt err = KErrNone; - // Symbian's file key store does not support - // MCTAuthenticationObjectList interface, so we need to use - // other way to get AO. - if (iKeyStore->Token().TokenType().Type().iUid == KTokenTypeFileKeystore) - { - if (iAOArray.Count()==0) - { - RMPointerArray keyInfos; - CleanupClosePushL(keyInfos); - TCTKeyAttributeFilter filter; - TInt keyInfoCount = 0; - filter.iPolicyFilter = TCTKeyAttributeFilter::EAllKeys; - err = iWrapper->ListKeys(*iKeyStore, keyInfos, filter); - ShowErrorNote(err); - User::LeaveIfError(err); - keyInfoCount = keyInfos.Count(); - for (TInt j = 0; j < keyInfoCount; j++) - { - // Check that keystore has at least one AO. - if (NULL != keyInfos[j]->Protector()) - { - // If keystore has AO, add it to the array. - User::LeaveIfError(iAOArray.Append(keyInfos[j]->Protector())); - break; - } - } - CleanupStack::PopAndDestroy(&keyInfos); //keyInfos - } - } - else - { - if (NULL == iAOList) - { - MCTTokenInterface* tokenInterface = NULL; - err = iWrapper->GetAuthObjectInterface( - iKeyStore->Token(), tokenInterface); - if ( KErrNone != err || NULL == tokenInterface ) - { - ShowErrorNote(err); - User::Leave(err); - } - iAOList = (MCTAuthenticationObjectList*)tokenInterface; - } - } - } -// ----------------------------------------------------------------------------- -// CSecModUIModel::ListAuthObjectsL() -// list the auth objects. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::ListAuthObjectsL() - { - RDEBUG("0", 0); - if (0 >= iAOArray.Count()) - { - __ASSERT_ALWAYS(iAOList, Panic(EPanicNullPointer)); - TInt err = iWrapper->ListAuthObjects(*iAOList, iAOArray); - if (err) - { - ShowErrorNote(err); - User::Leave(err); - } - } - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::TokenLabelForTitle() const -// Retrieves description of the token based on UID of the current active keystore. -// ----------------------------------------------------------------------------- -// -QString CSecModUIModel::TokenLabelForTitle() const - { - QString qLabel; - if (iKeyStore->Token().TokenType().Type().iUid - == KTokenTypeFileKeystore) - { - qLabel = "Phone keystore"; - } - else - { - const TDesC& label = iKeyStore->Token().Label(); - qLabel = QString((QChar*)label.Ptr(),label.Length()); - } - return qLabel; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::AuthStatus(TInt aIndex) const -// Returns status of the selected auth object. -// ----------------------------------------------------------------------------- -// -TUint32 CSecModUIModel::AuthStatus(TInt aIndex) const - { - return iAOArray[aIndex]->Status(); - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::PINStatus( TInt aIndex, TBool aShowBlockedNote ) const -// Returns status of the auth object based on its persistent properties set -// by security module implementation. -// ----------------------------------------------------------------------------- -// -QString CSecModUIModel::PINStatus( TInt aIndex, TBool aShowBlockedNote ) const - { - RDEBUG("0", 0); - __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange)); - QString pinStatus; - TUint32 status = iAOArray[aIndex]->Status(); - - if (status & EAuthObjectBlocked) - { - if (aShowBlockedNote) - { - QString information = 0; - if (status & EUnblockDisabled) - { - information = " totalblocked, contact your module vendor."; - } - else - { - information = " is blocked. PUK code is needed to unblock the code"; - } - information.prepend(QString( (QChar*)(iAOArray[aIndex]->Label()).Ptr(),iAOArray[aIndex]->Label().Length() ) ); - HbMessageBox::information(information); - } - pinStatus = "Blocked"; - } - else if ( PinOpen(aIndex) ) - { - pinStatus = "Open"; - } - else - { - pinStatus = "Closed"; - } - return pinStatus; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::PinOpen(TInt aIndex) const -// Checks whether the Pin is still available. -// ----------------------------------------------------------------------------- -// -TBool CSecModUIModel::PinOpen(TInt aIndex) const - { - __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange)); - TInt timeRemaining = 0; - TInt err = iWrapper->TimeRemaining(*(iAOArray[aIndex]), timeRemaining); - TBool ret = ETrue; - if ( 0 < timeRemaining ) - { - ret = ETrue; - } - else if( timeRemaining == -1 ) - { - ret = ETrue; - } - else - { - ret = EFalse; - } - return ret; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::ChangeOrUnblockPinL(TInt aIndex) -// Based on the property of auth object the pin can be changed or unblocked. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::ChangeOrUnblockPinL(TInt aIndex) - { - RDEBUG("0", 0); - __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange)); - TUint32 status = iAOArray[aIndex]->Status(); - - if ((status & EAuthObjectBlocked) && (status & EUnblockDisabled)) - { - return; // We cannot do anything. PIN is total bolcked. - } - else if (status & EAuthObjectBlocked) - { - // Let's unblock the PIN - UnblockPinL(aIndex); - } - else if (status & EEnabled) - { - // PIN is enabled. Let's change the PIN. - ChangePinL(aIndex); - } - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::UnblockPinL(TInt aIndex) -// Unblocks PIN. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::UnblockPinL(TInt aIndex) - { - __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange)); - TInt err = iWrapper->UnblockAuthObject(*(iAOArray[aIndex])); - if (KErrNone == err) - { - HbMessageBox::information("Code unblocked"); - } - else - { - ShowErrorNote(err); - } - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::ChangePinL(TInt aIndex) -// Changes the value of the PIN. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::ChangePinL(TInt aIndex) - { - RDEBUG("0", 0); - __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange)); - TInt err = KErrNone; - - err = iWrapper->ChangeReferenceData(*(iAOArray[aIndex])); - if (err) - { - ShowErrorNote(err); - } - else - { - HbMessageBox::information("Code changed"); - } - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::ChangeCodeRequestL(TInt aIndex) -// Toggles the value of auth object if possible. -// ----------------------------------------------------------------------------- -// -TInt CSecModUIModel::ChangeCodeRequest(TInt aIndex) - { - __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange)); - TUint32 status = iAOArray[aIndex]->Status(); - TInt err = KErrNone; - if (status & EDisableAllowed && !(status & EAuthObjectBlocked)) - { - if ( status & EEnabled ) - { - err = iWrapper->DisableAuthObject(*(iAOArray[aIndex])); - } - else - { - err = iWrapper->EnableAuthObject(*(iAOArray[aIndex])); - } - ShowErrorNote(err); - } - return err; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::CloseAuthObjL(TInt aIndex) -// If the auth object is open then closes it. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::CloseAuthObjL(TInt aIndex) - { - if (PinOpen(aIndex)) - { - __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange)); - TInt err = iWrapper->CloseAuthObject(*(iAOArray[aIndex])); - if (err) - { - ShowErrorNote(err); - User::Leave(err); - } - } - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::DeleteKeysL(TInt aTokenIndex) -// Deletes key from the appropriate keystore. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::DeleteKeysL(TInt aTokenIndex) - { - RDEBUG("0", 0); - __ASSERT_ALWAYS(aTokenIndex < iAOKeyStores.Count(), Panic(EPanicIndexOutOfRange)); - RMPointerArray keyInfos; - CleanupClosePushL(keyInfos); - TCTKeyAttributeFilter filter; - filter.iPolicyFilter = TCTKeyAttributeFilter::EAllKeys; - TInt err = iWrapper->ListKeys(*iAOKeyStores[aTokenIndex], keyInfos, filter); - ShowErrorNote(err); - User::LeaveIfError(err); - for (TInt i = 0; i < keyInfos.Count(); ++i) - { - err = iWrapper->DeleteKey(*iUnifiedKeyStore, keyInfos[i]->Handle()); - ShowErrorNote(err); - - if (KErrHardwareNotAvailable == err ) - { - break; // Break the loop, if keystore not available - } - } - CleanupStack::PopAndDestroy(&keyInfos); //keyInfos - ResetAndDestroyCTObjects(); - InitializeKeyStoreL(); - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::SecModDetailsL(TInt aTokenIndex) -// Retrieve security module details and cleansup all currently held auth objects. -// ----------------------------------------------------------------------------- -// -QVector< QPair > CSecModUIModel::SecModDetailsL(TInt aTokenIndex) - { - iKeyStore = iAOKeyStores[aTokenIndex]; - InitAuthObjectsL(); - ListAuthObjectsL(); - QVector< QPair > securityDetails = GetSecModDetailsL(); - iKeyStore = NULL; // not owned - if (iAOList) - { - iAOList->Release(); - iAOList = NULL; - } - iAOArray.Reset(); - return securityDetails; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::GetSecModDetailsL() -// Retrieve security module details. -// ----------------------------------------------------------------------------- -// -QVector< QPair > CSecModUIModel::GetSecModDetailsL() - { - RDEBUG("0", 0); - MCTToken& token = iKeyStore->Token(); - QVector< QPair > securityModDetails; - - if (token.TokenType().Type().iUid == KTokenTypeFileKeystore) - { - QPair name("Name:","Phone keystore"); - securityModDetails.append(name); - } - else - { - QPair name("Name:","(No label)"); - securityModDetails.append(name); - } - - AppendItem(securityModDetails, "Version:", token.Information( MCTToken::EVersion ), "(Not defined)" ); - AppendLocation(securityModDetails, token.TokenType().Type(), QString("Security module location:")); - - if (token.TokenType().Type().iUid == KTokenTypeFileKeystore) - { - QPair accessCode("Access code:","Phone keystore code"); - securityModDetails.append(accessCode); - } - else - { - AppendItem(securityModDetails, "Access code:", iAOArray[0]->Label(), "Access code:" ); - } - - AppendPinNRs(securityModDetails); - - AppendItem( securityModDetails, "Serial number:", - token.Information( MCTToken::ESerialNo), - "(Not defined)"); - - AppendItem( securityModDetails, "Manufacturer:", - token.Information( MCTToken::EManufacturer), - "(Not defined)"); - return securityModDetails; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::AppendLocation() -// Appends the location of the keystore. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::AppendLocation( QVector< QPair >& aSecModDetails, - TUid aLocUid, - QString aCertDisplayDetails ) - { - QString locationDetails = "(Not defined)"; - - switch ( aLocUid.iUid ) - { - case KTokenTypeFileKeystore: - locationDetails = "Phone memory"; - break; - - case KWIMStoreUid: - locationDetails = "Smart card"; - break; - - default: - break; - } - aSecModDetails.append(QPair(aCertDisplayDetails, locationDetails)); - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::AppendItem() -// Appends the value of a label if present otherwise appends empty descriotion. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::AppendItem( QVector< QPair >& aSecModDetails, - QString aLabel, - const TDesC& aValue, - QString aNullDescription) - { - RDEBUG("0", 0); - if( aValue.Length() == 0 ) - { - aSecModDetails.append(QPair(aLabel, aNullDescription)); - } - else - { - QString value = QString((QChar*) aValue.Ptr(),aValue.Length()); - aSecModDetails.append(QPair(aLabel, value)); - } - } - -// ------------------------------------------------------------------------------- -// CSecModUIModel::AppendPinNRs(QVector< QPair >& aSecModDetails) -// Generate details of signing security module. -// ------------------------------------------------------------------------------- -// -void CSecModUIModel::AppendPinNRs(QVector< QPair >& aSecModDetails) - { - TInt pinCount = iAOArray.Count(); - TInt j = 0; - - for (TInt i=1; iLabel(); - if(label.Length() == 0) - { - noLabelDetails.append(++j); - } - QString signingCode = "Signing code:"; - AppendItem(aSecModDetails, signingCode , iAOArray[i]->Label(), noLabelDetails); - } - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::AuthDetails() const -// Return the list of pair of description and status of each auth object. -// ----------------------------------------------------------------------------- -// -QVector > CSecModUIModel::AuthDetails() - { - QVector > authDetails; - - // Here is assumed that the first AO is always PIN-G - for (TInt i = 1; i < iAOArray.Count(); i++) - { - const TDesC& label = iAOArray[i]->Label(); - TUint32 status = iAOArray[i]->Status(); - QString sLabel = QString((QChar*) label.Ptr(), label.Length()); - QPair pair(sLabel, status); - authDetails.append(pair); - } - return authDetails; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::ChangePinNrL(TInt aIndex) -// Change the pin value for the singing module. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::ChangePinNrL(TInt aIndex) - { - RDEBUG("0", 0); - ChangePinL(aIndex+1); - } - - -// ----------------------------------------------------------------------------- -// CSecModUIModel::UnblockPinNrL(TInt aIndex) -// Unblock the value for the signing code module. -// ----------------------------------------------------------------------------- -// -void CSecModUIModel::UnblockPinNrL(TInt aIndex) - { - UnblockPinL(aIndex+1); - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::KeyStoreUID() -// Retrieves the UID of the current active keystore. -// ----------------------------------------------------------------------------- -// -TInt CSecModUIModel::KeyStoreUID() - { - return iKeyStore->Token().TokenType().Type().iUid; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::AuthObj(TInt aIndex) -// Retrieves the auth object at the speficied index. -// ----------------------------------------------------------------------------- -// -const MCTAuthenticationObject& CSecModUIModel::AuthObj(TInt aIndex) - { - return *iAOArray[aIndex]; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::PinChangeable(TInt aIndex) const -// Returns the status accordingly if the pin is changeable or not. -// ----------------------------------------------------------------------------- -// -TBool CSecModUIModel::PinChangeable(TInt aIndex) const - { - RDEBUG("0", 0); - __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange)); - TUint32 status = iAOArray[aIndex]->Status(); - TBool ret = ETrue; - if ( (status & EAuthObjectBlocked) || (status & EChangeDisabled) ) - { - ret = EFalse; - } - else if ( status & EEnabled ) - { - ret = ETrue; - } - else // PIN is disabled; - { - ret = EFalse; - } - return ret; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::PinUnblockable(TInt aIndex) const -// Returns the status accordingly if the pin is unblockable or not. -// ----------------------------------------------------------------------------- -// -TBool CSecModUIModel::PinUnblockable(TInt aIndex) const - { - TUint32 status = iAOArray[aIndex]->Status(); - TBool ret = ETrue; - if ( status & EUnblockDisabled ) - { - ret = EFalse; - } - else if ( status & EAuthObjectBlocked ) - { - ret = ETrue; - } - else // PIN is not blocked; - { - ret = EFalse; - } - return ret; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::PinRequestChangeable(TInt aIndex) const -// Returns the status accordingly if the pin is changeable or not. -// ----------------------------------------------------------------------------- -// -TBool CSecModUIModel::PinRequestChangeable(TInt aIndex) const - { - RDEBUG("0", 0); - __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange)); - TUint32 status = iAOArray[aIndex]->Status(); - TBool ret = EFalse; - if ( status & EAuthObjectBlocked ) - { - ret = EFalse; - } - else if ( status & EDisableAllowed ) - { - ret = ETrue; - } - else // Disable not allowed; - { - ret = EFalse; - } - return ret; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::IsTokenDeletable(TInt aTokenIndex) -// Returns the status accordingly if the token is deletable or not. -// ----------------------------------------------------------------------------- -// -TBool CSecModUIModel::IsTokenDeletable(TInt aTokenIndex) - { - __ASSERT_ALWAYS(aTokenIndex < iAOKeyStores.Count(), Panic(EPanicIndexOutOfRange)); - TBool ret = EFalse; - if (iAOKeyStores[aTokenIndex]->Token().TokenType().Type().iUid - == KTokenTypeFileKeystore) - { - ret = ETrue; - } - else - { - ret = EFalse; - } - return ret; - } - -// End of File - - diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/cpsecmodsyncwrapper.cpp --- a/cpsecplugins/cpadvancedsecplugin/src/cpsecmodsyncwrapper.cpp Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,401 +0,0 @@ -/* -* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation of the CSecModUISyncWrapper class -* Implements a synchronous wrapper for easier use of Symbian's -* Security Frameworks's API's. -* -*/ - - -#include "cpsecmodsyncwrapper.h" -#include -#include -#include -#include -#include -#include -#include -#include <../../inc/cpsecplugins.h> - - -// ============================ MEMBER FUNCTIONS =============================== - -// ----------------------------------------------------------------------------- -// CSecModUISyncWrapper::CSecModUISyncWrapper() -// C++ default constructor can NOT contain any code, that -// might leave. -// ----------------------------------------------------------------------------- -// -CSecModUISyncWrapper::CSecModUISyncWrapper() : CActive( EPriorityStandard ) - { - CActiveScheduler::Add(this); - } - - -// ----------------------------------------------------------------------------- -// CSecModUISyncWrapper::NewLC -// Two-phased constructor. -// ----------------------------------------------------------------------------- -// -CSecModUISyncWrapper* CSecModUISyncWrapper::NewLC() - { - CSecModUISyncWrapper* wrap = new (ELeave) CSecModUISyncWrapper(); - CleanupStack::PushL(wrap); - return wrap; - } - -// ----------------------------------------------------------------------------- -// CSecModUISyncWrapper::NewL -// Two-phased constructor. -// ----------------------------------------------------------------------------- -// -CSecModUISyncWrapper* CSecModUISyncWrapper::NewL() - { - RDEBUG("0", 0); - CSecModUISyncWrapper* wrap = CSecModUISyncWrapper::NewLC(); - CleanupStack::Pop(wrap); - return wrap; - } - -// Destructor -CSecModUISyncWrapper::~CSecModUISyncWrapper() - { - Cancel(); - iOperation = EOperationNone; - } - -// ----------------------------------------------------------------------------- -// CSecModUISyncWrapper::Initialize(CUnifiedKeyStore& aKeyStore) -// Two-phased constructor. -// ----------------------------------------------------------------------------- -// - -TInt CSecModUISyncWrapper::Initialize(CUnifiedKeyStore& aKeyStore) - { - if( !IsActive() && !iWait.IsStarted() ) - { - iOperation = EOperationInit; - iObject = STATIC_CAST(TAny*, &aKeyStore); - aKeyStore.Initialize(iStatus); - SetActive(); - iWait.Start(); - iOperation = EOperationNone; - return iStatus.Int(); - } - return KErrInUse; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::GetAuthObjectInterface(...) -// ----------------------------------------------------------------------------- -// -TInt CSecModUISyncWrapper::GetAuthObjectInterface( - MCTToken& aToken, MCTTokenInterface*& aTokenInterface) - { - RDEBUG("0", 0); - if( !IsActive() && !iWait.IsStarted() ) - { - iOperation = EOperationGetAOInterface; - iObject = STATIC_CAST(TAny*, &aToken); - const TUid KUidInterfaceAO = { KCTInterfaceAuthenticationObject }; - aToken.GetInterface(KUidInterfaceAO, aTokenInterface, iStatus); - iOperation = EOperationGetAOInterface; - SetActive(); - iWait.Start(); - iOperation = EOperationNone; - return iStatus.Int(); - } - return KErrInUse; - } - -// ----------------------------------------------------------------------------- -// CSecModUISyncWrapper::ListAuthObjects(...) -// ----------------------------------------------------------------------------- -// -TInt CSecModUISyncWrapper::ListAuthObjects( - MCTAuthenticationObjectList& aAuthObjList, - RMPointerArray& aAuthObjects) - { - if( !IsActive() && !iWait.IsStarted() ) - { - iOperation = EOperationListAOs; - iObject = STATIC_CAST(TAny*, &aAuthObjList); - aAuthObjList.List( aAuthObjects, iStatus ); - iOperation = EOperationListAOs; - SetActive(); - iWait.Start(); - iOperation = EOperationNone; - return iStatus.Int(); - } - return KErrInUse; - } - -// ----------------------------------------------------------------------------- -// CSecModUISyncWrapper::ListKeys(...) -// ----------------------------------------------------------------------------- -// -TInt CSecModUISyncWrapper::ListKeys( - MCTKeyStore& aKeyStore, - RMPointerArray& aKeysInfos, - const TCTKeyAttributeFilter& aFilter) - { - RDEBUG("0", 0); - if( !IsActive() && !iWait.IsStarted() ) - { - iOperation = EOperationListKeys; - iObject = STATIC_CAST(TAny*, &aKeyStore); - aKeyStore.List(aKeysInfos, aFilter, iStatus); - SetActive(); - iWait.Start(); - iOperation = EOperationNone; - return iStatus.Int(); - } - return KErrInUse; - } - -// ----------------------------------------------------------------------------- -// CSecModUISyncWrapper::DeleteKey(...) -// ----------------------------------------------------------------------------- -// -TInt CSecModUISyncWrapper::DeleteKey( - CUnifiedKeyStore& aKeyStore, - TCTTokenObjectHandle aHandle) - { - RDEBUG("0", 0); - if( !IsActive() && !iWait.IsStarted() ) - { - iOperation = EOperationDelKey; - iObject = STATIC_CAST(TAny*, &aKeyStore); - aKeyStore.DeleteKey(aHandle, iStatus); - SetActive(); - iWait.Start(); - iOperation = EOperationNone; - return iStatus.Int(); - } - return KErrInUse; - } - -// ----------------------------------------------------------------------------- -// CSecModUISyncWrapper::ChangeReferenceData(MCTAuthenticationObject& aAuthObject) -// ----------------------------------------------------------------------------- -// -TInt CSecModUISyncWrapper::ChangeReferenceData( - MCTAuthenticationObject& aAuthObject) - { - RDEBUG("0", 0); - if( !IsActive() && !iWait.IsStarted() ) - { - iOperation = EOperationChangeReferenceData; - iObject = STATIC_CAST(TAny*, &aAuthObject); - aAuthObject.ChangeReferenceData(iStatus); - SetActive(); - iWait.Start(); - iOperation = EOperationNone; - return iStatus.Int(); - } - return KErrInUse; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::UnblockAuthObject(MCTAuthenticationObject& aAuthObject) -// ----------------------------------------------------------------------------- -// -TInt CSecModUISyncWrapper::UnblockAuthObject( - MCTAuthenticationObject& aAuthObject) - { - RDEBUG("0", 0); - if( !IsActive() && !iWait.IsStarted() ) - { - iOperation = EOperationUnblockAO; - iObject = STATIC_CAST(TAny*, &aAuthObject); - aAuthObject.Unblock(iStatus); - SetActive(); - iWait.Start(); - iOperation = EOperationNone; - return iStatus.Int(); - } - return KErrInUse; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::EnableAuthObject(MCTAuthenticationObject& aAuthObject) -// ----------------------------------------------------------------------------- -// -TInt CSecModUISyncWrapper::EnableAuthObject( - MCTAuthenticationObject& aAuthObject) - { - RDEBUG("0", 0); - if( !IsActive() && !iWait.IsStarted() ) - { - iOperation = EOperationEnableAO; - iObject = STATIC_CAST(TAny*, &aAuthObject); - aAuthObject.Enable(iStatus); - iOperation = EOperationUnblockAO; - SetActive(); - iWait.Start(); - iOperation = EOperationNone; - return iStatus.Int(); - } - return KErrInUse; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::DisableAuthObject(MCTAuthenticationObject& aAuthObject) -// ----------------------------------------------------------------------------- -// -TInt CSecModUISyncWrapper::DisableAuthObject( - MCTAuthenticationObject& aAuthObject) - { - if( !IsActive() && !iWait.IsStarted() ) - { - iOperation = EOperationDisableAO; - iObject = STATIC_CAST(TAny*, &aAuthObject); - aAuthObject.Disable(iStatus); - SetActive(); - iWait.Start(); - iOperation = EOperationNone; - return iStatus.Int(); - } - return KErrInUse; - } - -// ----------------------------------------------------------------------------- -// CSecModUISyncWrapper::CloseAuthObject(MCTAuthenticationObject& aAuthObject) -// ----------------------------------------------------------------------------- -// -TInt CSecModUISyncWrapper::CloseAuthObject( - MCTAuthenticationObject& aAuthObject) - { - if( !IsActive() && !iWait.IsStarted() ) - { - iOperation = EOperationCloseAO; - iObject = STATIC_CAST(TAny*, &aAuthObject); - aAuthObject.Close(iStatus); - SetActive(); - iWait.Start(); - iOperation = EOperationNone; - return iStatus.Int(); - } - return KErrInUse; - } - -// ----------------------------------------------------------------------------- -// CSecModUIModel::TimeRemaining(...) -// ----------------------------------------------------------------------------- -// -TInt CSecModUISyncWrapper::TimeRemaining( - MCTAuthenticationObject& aAuthObject, - TInt& aStime ) - { - RDEBUG("0", 0); - if( !IsActive() && !iWait.IsStarted() ) - { - iOperation = EOperationTimeRemAO; - iObject = STATIC_CAST(TAny*, &aAuthObject); - aAuthObject.TimeRemaining(aStime, iStatus); - SetActive(); - iWait.Start(); - iOperation = EOperationNone; - return iStatus.Int(); - } - return KErrInUse; - } - -// ----------------------------------------------------------------------------- -// CSecModUISyncWrapper::DoCancel -// Cancels the ongoing operation if possible. -// ----------------------------------------------------------------------------- -// -void CSecModUISyncWrapper::DoCancel() - { - RDEBUG("iOperation", iOperation); - switch ( iOperation ) - { - case EOperationInit: - { - STATIC_CAST(CUnifiedKeyStore*, iObject)->CancelInitialize(); - break; - } - case EOperationGetAOInterface: - { - STATIC_CAST(MCTToken*, iObject)->CancelGetInterface(); - break; - } - case EOperationListAOs: - { - STATIC_CAST(MCTAuthenticationObjectList*, iObject)->CancelList(); - break; - } - case EOperationListKeys: - { - STATIC_CAST(MCTKeyStore*, iObject)->CancelList(); - break; - } - case EOperationDelKey: - { - STATIC_CAST(CUnifiedKeyStore*, iObject)->CancelDeleteKey(); - break; - } - case EOperationChangeReferenceData: - { - STATIC_CAST(MCTAuthenticationObject*, iObject)-> - CancelChangeReferenceData(); - break; - } - case EOperationUnblockAO: - { - STATIC_CAST(MCTAuthenticationObject*, iObject)->CancelUnblock(); - break; - } - case EOperationEnableAO: - { - STATIC_CAST(MCTAuthenticationObject*, iObject)->CancelEnable(); - break; - } - case EOperationDisableAO: - { - STATIC_CAST(MCTAuthenticationObject*, iObject)->CancelDisable(); - break; - } - case EOperationCloseAO: - { - STATIC_CAST(MCTAuthenticationObject*, iObject)->CancelClose(); - break; - } - case EOperationTimeRemAO: - { - STATIC_CAST(MCTAuthenticationObject*, iObject)->CancelTimeRemaining(); - break; - } - default: - { - break; - } - } - if (iWait.IsStarted()) - { - iWait.AsyncStop(); - } - } - -// ----------------------------------------------------------------------------- -// CSecModUISyncWrapper::RunL -// If no errors happened, stop. Show an error note if needed. -// ----------------------------------------------------------------------------- -// -void CSecModUISyncWrapper::RunL() - { - iWait.AsyncStop(); - } - diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/cpsecmoduleinfoview.cpp --- a/cpsecplugins/cpadvancedsecplugin/src/cpsecmoduleinfoview.cpp Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ - -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0"" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include <../../inc/cpsecplugins.h> -#include "cpsecmoduleinfoview.h" - - -CpSecmoduleInfoView::CpSecmoduleInfoView(const QVector< QPair >& securityDetails, QGraphicsItem *parent /*= 0*/) - : CpBaseSettingView(0,parent) - { - RDEBUG("0", 0); - setTitle(tr("Module info")); - - std::auto_ptr layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical))); - HbListWidget* listSecurityDetails = q_check_ptr(new HbListWidget(this)); - - QVectorIterator< QPair > secDetIter(securityDetails); - while(secDetIter.hasNext()) - { - QPair pair = secDetIter.next(); - - std::auto_ptr label(q_check_ptr(new HbListWidgetItem())); - label->setText(pair.first); - listSecurityDetails->addItem(label.get()); - label.release(); - - std::auto_ptr description(q_check_ptr(new HbListWidgetItem())); - description->setText(pair.second); - listSecurityDetails->addItem(description.get()); - description.release(); - } - - layout->addItem(listSecurityDetails); - setLayout(layout.get()); - layout.release(); - RDEBUG("0", 0); - } - -CpSecmoduleInfoView::~CpSecmoduleInfoView() - {} - -// End of file - diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/cpsecmodview.cpp --- a/cpsecplugins/cpadvancedsecplugin/src/cpsecmodview.cpp Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0"" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include <../../inc/cpsecplugins.h> -#include "cpsecmodview.h" -#include "cpsecmodmodel.h" -#include "cpmoduleview.h" - -CpSecModView::CpSecModView(TInt currentPos, CSecModUIModel& secModUIModel, QGraphicsItem *parent /*= 0*/) -: CpBaseSettingView(0,parent), - mSecModUIModel(secModUIModel), - mPos(currentPos), - mCurrentView(EAccessView), - mAccessView(NULL), - mPrevView(NULL) - { - RDEBUG("0", 0); - try - { - QT_TRAP_THROWING(mSecModUIModel.OpenTokenL(mPos)); - QString title = mSecModUIModel.TokenLabelForTitle(); - setTitle(title); - - TInt count = 0; - // display code view - QT_TRAP_THROWING(count = mSecModUIModel.CheckCodeViewStringsL()); - - std::auto_ptr layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical))); - HbListWidget* listSecView = q_check_ptr(new HbListWidget(this)); - - std::auto_ptr moduleWidget(q_check_ptr(new HbListWidgetItem())); - moduleWidget->setText("\tModule PIN"); - listSecView->addItem(moduleWidget.get()); - moduleWidget.release(); - RDEBUG("count", count); - if( count == 2 ) - { - std::auto_ptr signingWidget(q_check_ptr(new HbListWidgetItem())); - signingWidget->setText("\tSigning PIN"); - listSecView->addItem(signingWidget.get()); - signingWidget.release(); - } - - connect(listSecView, SIGNAL(activated(QModelIndex)), this, SLOT(showNextView(QModelIndex))); - - layout->addItem(listSecView); - setLayout(layout.get()); - layout.release(); - } - catch(const std::exception& exception) - { - QString error(exception.what()); - HbMessageBox::information(error); - QT_RETHROW; - } - } - -CpSecModView::~CpSecModView() - { - if(mAccessView) - { - mAccessView->deleteLater(); - mAccessView = NULL; - } - if(mPrevView) - { - mPrevView->deleteLater(); - mPrevView = NULL; - } - } - - -void CpSecModView::showNextView( const QModelIndex& modelIndex ) - { - RDEBUG("0", 0); - try - { - mAccessView = q_check_ptr(new CpModuleView((TSecModViews)modelIndex.row(),mSecModUIModel)); - QObject::connect(mAccessView , SIGNAL(aboutToClose()), this, SLOT(displayPrevious())); - mPrevView = mainWindow()->currentView(); //suppose iPreView is member variable of CpSecurityView - mainWindow()->addView(mAccessView); - mainWindow()->setCurrentView(mAccessView); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - -void CpSecModView::displayPrevious() - { - RDEBUG("0", 0); - try - { - mainWindow()->removeView(mAccessView); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpadvancedsecplugin/src/cpsecurityview.cpp --- a/cpsecplugins/cpadvancedsecplugin/src/cpsecurityview.cpp Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,391 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0"" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include <../../inc/cpsecplugins.h> - -#include "cpsecurityview.h" -#include "cpsecmodview.h" -#include "cpcertview.h" -#include "cpsecmodmodel.h" -#include "cpsecmoduleinfoview.h" - -CpSecurityView::CpSecurityView(QGraphicsItem *parent /*= 0*/) - : CpBaseSettingView(0,parent), - mSecModUIModel(NULL), - mSecModView(NULL), - mPreView(NULL), - mCertView(NULL), - mCurrentView(NULL), - mPos(0), - mNote(NULL), mOkAction(NULL) - { - RDEBUG("0", 0); - setTitle(hbTrId("txt_certificate_manager_setlabel_advanced_security")); - - std::auto_ptr layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical))); - HbListWidget* listCertView = q_check_ptr(new HbListWidget(this)); - - std::auto_ptr authcert(q_check_ptr(new HbListWidgetItem())); - authcert->setText(hbTrId("txt_certificate_manager_list_authority_certificate")); - - std::auto_ptr trustedsitecert(q_check_ptr(new HbListWidgetItem())); - trustedsitecert->setText(hbTrId("txt_certificate_manager_list_trusted_site_certific")); - - std::auto_ptr personalcert(q_check_ptr(new HbListWidgetItem())); - personalcert->setText(hbTrId("txt_certificate_manager_list_personal_certificates")); - - std::auto_ptr devicecert(q_check_ptr(new HbListWidgetItem())); - devicecert->setText(hbTrId("txt_certificate_manager_list_device_certificates")); - - listCertView->addItem(authcert.get()); - authcert.release(); - listCertView->addItem(trustedsitecert.get()); - trustedsitecert.release(); - listCertView->addItem(personalcert.get()); - personalcert.release(); - listCertView->addItem(devicecert.get()); - devicecert.release(); - - connect(listCertView, SIGNAL(released(QModelIndex)), this, SLOT(displayCert(QModelIndex))); - - HbListWidget* listSecView = q_check_ptr(new HbListWidget(this)); - QMap keystoreLabels; - RDEBUG("0", 0); - try - { - QT_TRAP_THROWING( - mSecModUIModel = CSecModUIModel::NewL(); - keystoreLabels = mSecModUIModel->LoadTokenLabelsL(); ) - } - catch(const std::exception& exception) - { - QString error(exception.what()); - HbMessageBox::information(error); - QT_RETHROW; - } - - QMapIterator labelIter(keystoreLabels); - if(keystoreLabels.count() != 0) - { - while(labelIter.hasNext()) - { - labelIter.next(); - std::auto_ptr widget(q_check_ptr(new HbListWidgetItem())); - widget->setText(labelIter.key()); - widget->setSecondaryText(labelIter.value()); - listSecView->addItem(widget.get()); - widget.release(); - } - connect(listSecView, SIGNAL(activated(QModelIndex)), this, SLOT(showCodeView(QModelIndex))); - connect(listSecView, SIGNAL(longPressed(HbAbstractViewItem*, QPointF )), this, SLOT(indicateLongPress(HbAbstractViewItem*, QPointF))); - } - else - { - std::auto_ptr emptyWidget(q_check_ptr(new HbListWidgetItem())); - emptyWidget->setText("(no security modules)"); - listSecView->addItem(emptyWidget.get()); - emptyWidget.release(); - } - RDEBUG("0", 0); - std::auto_ptr certificatesList(q_check_ptr(new HbGroupBox())); - certificatesList->setHeading(hbTrId("txt_certificate_manager_setlabel_certificates")); - certificatesList->setContentWidget(listCertView); - certificatesList->setCollapsed(true); - layout->addItem(certificatesList.get()); - certificatesList.release(); - - std::auto_ptr protectedContentList(q_check_ptr(new HbGroupBox())); - protectedContentList->setHeading("Protected Content"); - protectedContentList->setCollapsed(true); - layout->addItem(protectedContentList.get()); - protectedContentList.release(); - - std::auto_ptr securityModuleList(q_check_ptr(new HbGroupBox())); - securityModuleList->setHeading("Security Module"); - securityModuleList->setContentWidget(listSecView); - securityModuleList->setCollapsed(true); - layout->addItem(securityModuleList.get()); - securityModuleList.release(); - - mContextMenu = q_check_ptr(new HbMenu()); - - setLayout(layout.get()); - layout.release(); - } - - -CpSecurityView::~CpSecurityView() - { - if(mSecModView) - { - mSecModView->deleteLater(); - } - - if(mPreView) - { - mPreView->deleteLater(); - } - - if(mCertView) - { - mCertView->deleteLater(); - } - - if(mCurrentView) - { - mCurrentView->deleteLater(); - } - - delete mSecModUIModel; - - delete mNote; - delete mContextMenu; - } - -void CpSecurityView::showCodeView() - { - RDEBUG("0", 0); - try - { - mSecModView = q_check_ptr(new CpSecModView(mPos, *mSecModUIModel)); - QObject::connect(mSecModView , SIGNAL(aboutToClose()), this, SLOT(viewDone())); - mPreView = mainWindow()->currentView(); //suppose mPreView is member variable of CpSecurityView - mainWindow()->addView(mSecModView); - mainWindow()->setCurrentView(mSecModView); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - -void CpSecurityView::showCodeView( const QModelIndex& aModelIndex) - { - mPos = aModelIndex.row(); - showCodeView(); - } - -void CpSecurityView::showWIMview() - { - RDEBUG("0", 0); - try - { - QObject::connect(mSecModView , SIGNAL(aboutToClose()), this, SLOT(viewDone())); - mPreView = mainWindow()->currentView(); //suppose mPreView is member variable of CpSecurityView - mainWindow()->addView(mSecModView); - mainWindow()->setCurrentView(mSecModView); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - -void CpSecurityView::viewDone() - { - try - { - mainWindow()->removeView(mSecModView); - mSecModView->deleteLater(); - mSecModView= NULL; - mainWindow()->setCurrentView(mPreView); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - -void CpSecurityView::displayCert(const QModelIndex& modelIndex) - { - RDEBUG("0", 0); - try - { - mCertView = q_check_ptr(new CpCertView(modelIndex)); - connect(mCertView , SIGNAL(aboutToClose()), this, SLOT(displayPrevious())); - mPreView = mainWindow()->currentView(); - mainWindow()->addView(mCertView); - mainWindow()->setCurrentView(mCertView); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - -void CpSecurityView::displayPrevious() - { - RDEBUG("0", 0); - try - { - mainWindow()->removeView(mCertView); - mCertView->deleteLater(); - mCertView= NULL; - mainWindow()->setCurrentView(mPreView); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - -void CpSecurityView::indicateLongPress(HbAbstractViewItem *item,QPointF coords) - { - RDEBUG("0", 0); - try - { - mContextMenu->clearActions(); - mPos = item->modelIndex().row(); - - std::auto_ptr openModule(q_check_ptr(new HbAction("Open"))); - connect(openModule.get(), SIGNAL(triggered()), this, SLOT( showCodeView())); - mContextMenu->addAction(openModule.get()); - openModule.release(); - - if(mSecModUIModel->IsTokenDeletable(mPos)) - { - std::auto_ptr deleteModule(q_check_ptr(new HbAction("Delete"))); - connect(deleteModule.get(), SIGNAL(triggered()), this, SLOT( deleteModule())); - mContextMenu->addAction(deleteModule.get()); - deleteModule.release(); - } - - std::auto_ptr moduleInfo(q_check_ptr(new HbAction("Module Info"))); - connect(moduleInfo.get(), SIGNAL(triggered()), this, SLOT( moduleDetails())); - mContextMenu->addAction(moduleInfo.get()); - moduleInfo.release(); - - mContextMenu->setPreferredPos(coords); - mContextMenu->open(); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - -void CpSecurityView::deleteModule() - { - RDEBUG("0", 0); - try - { - - delete mNote; - mNote = NULL; - - mNote = new HbMessageBox(HbMessageBox::MessageTypeQuestion); - mNote->setHeadingWidget(q_check_ptr(new HbLabel(tr("Delete...")))); - mNote->setText("Delete keystore and password?"); - mNote->clearActions(); - mOkAction = q_check_ptr(new HbAction("Yes")); - mNote->addAction(mOkAction); - HbAction* cancelAction = q_check_ptr(new HbAction("No")); - mNote->addAction(cancelAction); - mNote->setTimeout(HbPopup::NoTimeout); - mNote->setIconVisible (EFalse); - mNote->open(this,SLOT(dialogClosed(HbAction*))); - } - catch(const std::exception& exception) - { - HbMessageBox *box = new HbMessageBox(exception.what()); - box->setAttribute(Qt::WA_DeleteOnClose); - box->open(); - } - -} -void CpSecurityView::dialogClosed(HbAction* action) -{ - RDEBUG("0", 0); - if (action != mOkAction) - { - return; - } - - try - { - QT_TRAP_THROWING(mSecModUIModel->DeleteKeysL(mPos)); - } - catch(const std::exception& exception) - { - HbMessageBox *box = new HbMessageBox(exception.what()); - box->setAttribute(Qt::WA_DeleteOnClose); - box->open(); - } - } - -void CpSecurityView::moduleDetails() - { - RDEBUG("0", 0); - try - { - QVector< QPair > securityDetails; - QT_TRAP_THROWING(securityDetails = mSecModUIModel->SecModDetailsL(mPos)); - mModuleinfoView = q_check_ptr(new CpSecmoduleInfoView(securityDetails)); - - connect(mModuleinfoView , SIGNAL(aboutToClose()), this, SLOT(displayPreviousFromModInfo())); - mPreView = mainWindow()->currentView(); - mainWindow()->addView(mModuleinfoView); - mainWindow()->setCurrentView(mModuleinfoView); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - -void CpSecurityView::displayPreviousFromModInfo() - { - RDEBUG("0", 0); - try - { - mainWindow()->removeView(mModuleinfoView); - mCertView->deleteLater(); - mCertView= NULL; - mainWindow()->setCurrentView(mPreView); - } - catch(const std::exception& exception) - { - HbMessageBox::information(exception.what()); - } - } - diff -r 3255e7d5bd67 -r 989397f9511c cpsecplugins/cpsecplugins.pro --- a/cpsecplugins/cpsecplugins.pro Thu Oct 07 14:07:34 2010 +0300 +++ b/cpsecplugins/cpsecplugins.pro Thu Oct 14 13:56:11 2010 +0300 @@ -16,7 +16,7 @@ TEMPLATE = subdirs -# temporarilly skip, because too many deprecations SUBDIRS += devicelockplugin/devicelockplugin.pro SUBDIRS += simpincodeplugin/pincodeplugin.pro -SUBDIRS += cpadvancedsecplugin/group/advancedsecplugin.pro +SUBDIRS += cpadvancedsecplugin/cpadvancedsecplugin.pro + diff -r 3255e7d5bd67 -r 989397f9511c layers.sysdef.xml --- a/layers.sysdef.xml Thu Oct 07 14:07:34 2010 +0300 +++ b/layers.sysdef.xml Thu Oct 14 13:56:11 2010 +0300 @@ -18,9 +18,6 @@ - - - diff -r 3255e7d5bd67 -r 989397f9511c package_definition.xml --- a/package_definition.xml Thu Oct 07 14:07:34 2010 +0300 +++ b/package_definition.xml Thu Oct 14 13:56:11 2010 +0300 @@ -134,6 +134,12 @@ + + + + + + @@ -162,8 +168,8 @@ - - + + diff -r 3255e7d5bd67 -r 989397f9511c pkiutilities/securitydialognotifiersrv/inc/securitydialogoperserverauthfail.h --- a/pkiutilities/securitydialognotifiersrv/inc/securitydialogoperserverauthfail.h Thu Oct 07 14:07:34 2010 +0300 +++ b/pkiutilities/securitydialognotifiersrv/inc/securitydialogoperserverauthfail.h Thu Oct 14 13:56:11 2010 +0300 @@ -86,6 +86,7 @@ RMPointerArray iCertInfos; TInt iRetrieveCertIndex; HBufC8* iRetrievedCertBuffer; + TPtr8 iRetrievedCertBufPtr; enum { EInitialiseCertStore, diff -r 3255e7d5bd67 -r 989397f9511c pkiutilities/securitydialognotifiersrv/src/securitydialogoperserverauthfail.cpp --- a/pkiutilities/securitydialognotifiersrv/src/securitydialogoperserverauthfail.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/pkiutilities/securitydialognotifiersrv/src/securitydialogoperserverauthfail.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -212,7 +212,8 @@ // CServerAuthFailOperation::CServerAuthFailOperation( MSecurityDialogOperationObserver& aObserver, const RMessage2& aMessage, - TInt aReplySlot ) : CSecurityDialogOperation( aObserver, aMessage, aReplySlot ) + TInt aReplySlot ) : CSecurityDialogOperation( aObserver, aMessage, aReplySlot ), + iRetrievedCertBufPtr(0, 0) { TRACE( "CServerAuthFailOperation::CServerAuthFailOperation" ); } @@ -457,9 +458,9 @@ iRetrievedCertBuffer = NULL; } iRetrievedCertBuffer = HBufC8::NewL( cert.Size() ); - TPtr8 buffer = iRetrievedCertBuffer->Des(); + iRetrievedCertBufPtr.Set( iRetrievedCertBuffer->Des() ); - iTrustedSiteCertStore->Retrieve( cert, buffer, iStatus ); + iTrustedSiteCertStore->Retrieve( cert, iRetrievedCertBufPtr, iStatus ); iMode = ERetrieveTrustedSiteCert; SetActive(); } diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/Autolock/Autolock.pro --- a/securitydialogs/Autolock/Autolock.pro Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/Autolock/Autolock.pro Thu Oct 14 13:56:11 2010 +0300 @@ -41,6 +41,7 @@ LIBS += -ltstaskmonitorclient # for TsTaskSettings LIBS += -lavkon # for KeySounds LIBS += -lapgrfx # for CApaWindowGroupName +LIBS += -lscpclient # SCP server SERVICE.FILE = service_conf.xml SERVICE.OPTIONS = embeddable diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/Autolock/src/Autolock.cpp --- a/securitydialogs/Autolock/src/Autolock.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/Autolock/src/Autolock.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -1,39 +1,29 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -// #include "xqservicelog.h" + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 2.1 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, + * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". + * + * Description: + * + */ #include #include #include -#include -#include -#include -#include #include -#include -#include -#include #include -#include #include #include #include @@ -46,28 +36,22 @@ #include -#include - -#include - -#include - #include "Autolock.h" #include - #include "autolockuseractivityservice.h" - -#include // CenRep keys +#include // CenRep keys #include #include +#include #include #include #include #include #include - +#include #include +#include #include #include @@ -76,90 +60,107 @@ #include "../PubSub/securityuisprivatepskeys.h" #include #include +#include + +#include #include +// handled now directly but screensaver +// #include const TInt KPhoneIndex(0); const TInt KTriesToConnectServer(2); const TInt KTimeBeforeRetryingServerConnection(50000); - -#define ESecUiTypeLock 0x00100000 - +#define ESecUiTypeDeviceLock 0x00100000 +#define ESecUiTypeKeyguard 0x00200000 _LIT( KMmTsyModuleName, "PhoneTsy"); +// Constant definitions to control screensaver view types +static const char *KSnsrViewTypeKey = "view_type"; +enum TSnsrViewType + { + ESnsrViewTypeInitial = 0, // default initial state, depends on the configuration + ESnsrViewTypeActive, + ESnsrViewTypeStandby, + ESnsrViewTypeDisabled, + }; +static const char *KSnsrCmdUnlock = "unlock"; +static const char *KSnsrCmdSwitchLights = "switch_lights"; +static const char *KSnsrCmdSwitchLowPower = "switch_low_power"; + Autolock::Autolock(QWidget *parent, Qt::WFlags f) : - QWidget(parent, f), mService(NULL) + QWidget(parent, f), + mService(NULL), + mPowerKeyCaptureHandle(0), + mApplicationKeyCaptureHandle(0), + mApplicationLongKeyCaptureHandle(0), + mEKeyDeviceFCaptureHandle(0), + mEKeyBellCaptureHandle(0), + mEKeyYesCaptureHandle(0), + mEKeyNoCaptureHandle(0), + iLockCodeQueryInDisplay(false), + mScreensaverModeTimer(0) + { RDEBUG("start autolock", 0); - // The very first thing is to define the properties, so that others can use them. + // The very first thing is to define the properties, so that others can use them. TSecurityPolicy readPolicy(ECapabilityReadDeviceData); TSecurityPolicy writePolicy(ECapabilityWriteDeviceData); - TInt ret = RProperty::Define(KPSUidSecurityUIs, - KSecurityUIsSecUIOriginatedQuery, RProperty::EInt, readPolicy, - writePolicy); + TInt ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, RProperty::EInt, readPolicy, writePolicy); RDEBUG("defined KSecurityUIsSecUIOriginatedQuery", ret); - ret = RProperty::Define(KPSUidSecurityUIs, - KSecurityUIsQueryRequestCancel, RProperty::EInt, readPolicy, - writePolicy); + ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, RProperty::EInt, readPolicy, writePolicy); RDEBUG("defined KSecurityUIsQueryRequestCancel", ret); - _LIT_SECURITY_POLICY_PASS( KReadPolicy); _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData); - ret = RProperty::Define(KPSUidCoreApplicationUIs, - KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy, - KWritePolicy); + ret = RProperty::Define(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy, KWritePolicy); RDEBUG("defined KCoreAppUIsAutolockStatus", ret); - + // This is important: we set the status through a property TInt autolockState; - RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); + ret = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); RDEBUG("Get KCoreAppUIsAutolockStatus", ret); RDEBUG("autolockState", autolockState); - if(autolockState==EAutolockStatusUninitialized) - { - autolockState = EAutolockOff; // not-initialized means taht the unlock-query hasn't been displayed. Therefore the device should not stay locked. - } - ret = RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, - autolockState); // this might re-set it. That's not bad. It will re-notify all listeners. + if (autolockState == EAutolockStatusUninitialized) + { + autolockState = EAutolockOff; // not-initialized means taht the unlock-query hasn't been displayed. Therefore the device should not stay locked. + } + ret = RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); // this might re-set it. That's not bad. It will re-notify all listeners. RDEBUG("Set KCoreAppUIsAutolockStatus", ret); - ret = RProperty::Define(KPSUidAvkonDomain, KAknKeyguardStatus, - RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), - KWritePolicy); + ret = RProperty::Define(KPSUidAvkonDomain, KAknKeyguardStatus, RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), KWritePolicy); RDEBUG("defined KAknKeyguardStatus", ret); - ret = RProperty::Define(KPSUidSecurityUIs, - KSecurityUIsLockInitiatorUID, RProperty::EInt, readPolicy, - writePolicy); + ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsLockInitiatorUID, RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), writePolicy); RDEBUG("defined KSecurityUIsLockInitiatorUID", ret); - ret = RProperty::Define(KPSUidSecurityUIs, - KSecurityUIsLockInitiatorTimeHigh, RProperty::EInt, readPolicy, - writePolicy); + ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeHigh, RProperty::EInt, readPolicy, writePolicy); RDEBUG("defined KSecurityUIsLockInitiatorTimeHigh", ret); - ret = RProperty::Define(KPSUidSecurityUIs, - KSecurityUIsLockInitiatorTimeLow, RProperty::EInt, readPolicy, - writePolicy); + ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeLow, RProperty::EInt, readPolicy, writePolicy); RDEBUG("defined KSecurityUIsLockInitiatorTimeLow", ret); - ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsLights, - RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), - TSecurityPolicy(TSecurityPolicy::EAlwaysPass)); + ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsLights, RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), TSecurityPolicy(TSecurityPolicy::EAlwaysPass)); RDEBUG("defined KAknKeyguardStatus", ret); - ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsDismissDialog, - RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), - TSecurityPolicy(TSecurityPolicy::EAlwaysPass)); + ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsDismissDialog, RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), TSecurityPolicy( + TSecurityPolicy::EAlwaysPass)); RDEBUG("defined KSecurityUIsDismissDialog", ret); - + // call TARM so that it verifies that configuration is in sync. This might internally accept the (default) lock code, but doesn't dismiss the query. + // Note: this is fast : 0.02 seconds + RSCPClient scpClientConfiguration; + User::LeaveIfError( scpClientConfiguration.Connect() ); + CleanupClosePushL( scpClientConfiguration ); + RDEBUG("call CheckConfiguration KSCPComplete", KSCPComplete); + TInt finalConfStatus = scpClientConfiguration.CheckConfiguration( KSCPComplete ); + RDEBUG("finalConfStatus", finalConfStatus); + CleanupStack::PopAndDestroy(); // scpClientConfiguration mService = new AutolockService(this); /* Adjust the palette */ #if defined(Q_WS_S60) - // this is defined. + // this is defined. RDEBUG( "Q_WS_S60", 1 ); QPalette p = qApp->palette(); QColor color(192,192,192); @@ -178,8 +179,8 @@ RDEBUG("connect", 1); - #if defined(Q_WS_X11) || defined(Q_WS_WIN) + RDEBUG( "Q_WS_X11", 1 ); setFixedSize(QSize(360,640)); // nHD #elif defined(Q_WS_S60) // this doesn't work well @@ -194,10 +195,14 @@ TInt lightsTimeout = 0; CRepository* repository = NULL; TInt cRresult = 0; + iLockCodeQueryInDisplay = EFalse; + Q_UNUSED(cRresult); + TInt err = 0; + iProcessingEvent = -1; iLockStatusPrev = ELockNotActive; iLockStatus = ELockNotActive; - QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidSecuritySettings) ); + QT_TRAP_THROWING(repository = CRepository::NewL(KCRUidSecuritySettings)); cRresult = repository->Get(KSettingsAutolockStatus, lockValue); RDEBUG("KSettingsAutolockStatus", KSettingsAutolockStatus); RDEBUG("cRresult", cRresult); @@ -208,91 +213,113 @@ adjustInactivityTimers(0); - QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidProfileEngine) ); + QT_TRAP_THROWING(repository = CRepository::NewL(KCRUidProfileEngine)); cRresult = repository->Get(KProEngActiveProfile, lightsTimeout); // this value is not used for now delete repository; - QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidLightSettings) ); + QT_TRAP_THROWING(repository = CRepository::NewL(KCRUidLightSettings)); cRresult = repository->Get(KDisplayLightsTimeout, lightsTimeout); // this value is not used for now delete repository; // subscribe to settings changes - subscriberKSettingsAutolockStatus = new QValueSpaceSubscriber( - "/KCRUidSecuritySettings/KSettingsAutolockStatus", this); - connect(subscriberKSettingsAutolockStatus, SIGNAL(contentsChanged()), - this, SLOT(subscriberKSettingsAutolockStatusChanged())); - subscriberKSettingsAutoLockTime = new QValueSpaceSubscriber( - "/KCRUidSecuritySettings/KSettingsAutoLockTime", this); - connect(subscriberKSettingsAutoLockTime, SIGNAL(contentsChanged()), this, - SLOT(subscriberKSettingsAutoLockTimeChanged())); - subscriberKSettingsAutomaticKeyguardTime = new QValueSpaceSubscriber( - "/KCRUidSecuritySettings/KSettingsAutomaticKeyguardTime", this); - connect(subscriberKSettingsAutomaticKeyguardTime, SIGNAL( - contentsChanged()), this, SLOT( - subscriberKSettingsAutomaticKeyguardTimeChanged())); - subscriberKDisplayLightsTimeout = new QValueSpaceSubscriber( - "/KCRUidLightSettings/KDisplayLightsTimeout", this); - connect(subscriberKDisplayLightsTimeout, SIGNAL(contentsChanged()), this, - SLOT(subscriberKDisplayLightsTimeoutChanged())); - subscriberKProEngActiveProfile = new QValueSpaceSubscriber( - "/KCRUidProfileEngine/KProEngActiveProfile", this); - connect(subscriberKProEngActiveProfile, SIGNAL(contentsChanged()), this, - SLOT(subscriberKProEngActiveProfileChanged())); + subscriberKSettingsAutolockStatus = new QValueSpaceSubscriber("/KCRUidSecuritySettings/KSettingsAutolockStatus", this); + err = connect(subscriberKSettingsAutolockStatus, SIGNAL(contentsChanged()), this, SLOT(subscriberKSettingsAutolockStatusChanged())); + RDEBUG("err", err); + subscriberKSettingsAutoLockTime = new QValueSpaceSubscriber("/KCRUidSecuritySettings/KSettingsAutoLockTime", this); + err = connect(subscriberKSettingsAutoLockTime, SIGNAL(contentsChanged()), this, SLOT(subscriberKSettingsAutoLockTimeChanged())); + RDEBUG("err", err); + subscriberKSettingsAutomaticKeyguardTime = new QValueSpaceSubscriber("/KCRUidSecuritySettings/KSettingsAutomaticKeyguardTime", this); + err = connect(subscriberKSettingsAutomaticKeyguardTime, SIGNAL(contentsChanged()), this, SLOT(subscriberKSettingsAutomaticKeyguardTimeChanged())); + RDEBUG("err", err); + subscriberKDisplayLightsTimeout = new QValueSpaceSubscriber("/KCRUidLightSettings/KDisplayLightsTimeout", this); + err = connect(subscriberKDisplayLightsTimeout, SIGNAL(contentsChanged()), this, SLOT(subscriberKDisplayLightsTimeoutChanged())); + RDEBUG("err", err); + subscriberKProEngActiveProfile = new QValueSpaceSubscriber("/KCRUidProfileEngine/KProEngActiveProfile", this); + err = connect(subscriberKProEngActiveProfile, SIGNAL(contentsChanged()), this, SLOT(subscriberKProEngActiveProfileChanged())); + RDEBUG("err", err); + + subscriberKSecurityUIsDismissDialog = new QValueSpaceSubscriber("/KPSUidSecurityUIs/KSecurityUIsDismissDialog", this); + err = connect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, SLOT(subscriberKSecurityUIsDismissDialogChanged())); + RDEBUG("err", err); // subscribe to environment changes - subscriberKHWRMGripStatus = new QValueSpaceSubscriber( - "/KPSUidHWRM/KHWRMGripStatus"); - connect(subscriberKHWRMGripStatus, SIGNAL(contentsChanged()), this, - SLOT(subscriberKHWRMGripStatusChanged())); + subscriberKHWRMGripStatus = new QValueSpaceSubscriber("/KPSUidHWRM/KHWRMGripStatus", this); + err = connect(subscriberKHWRMGripStatus, SIGNAL(contentsChanged()), this, SLOT(subscriberKHWRMGripStatusChanged())); + RDEBUG("err", err); + + subscriberKAknKeyguardStatus = new QValueSpaceSubscriber("/KPSUidAvkonDomain/KAknKeyguardStatus", this); + err = connect(subscriberKAknKeyguardStatus, SIGNAL(contentsChanged()), this, SLOT(subscriberKAknKeyguardStatusChanged())); + RDEBUG("err", err); - subscriberKAknKeyguardStatus = new QValueSpaceSubscriber( - "/KPSUidAvkonDomain/KAknKeyguardStatus"); - connect(subscriberKAknKeyguardStatus, SIGNAL(contentsChanged()), this, - SLOT(subscriberKAknKeyguardStatusChanged())); + subscriberKCoreAppUIsAutolockStatus = new QValueSpaceSubscriber("/KPSUidCoreApplicationUIs/KCoreAppUIsAutolockStatus", this); + err = connect(subscriberKCoreAppUIsAutolockStatus, SIGNAL(contentsChanged()), this, SLOT(subscriberKCoreAppUIsAutolockStatusChanged())); + RDEBUG("err", err); - subscriberKCoreAppUIsAutolockStatus = new QValueSpaceSubscriber( - "/KPSUidCoreApplicationUIs/KCoreAppUIsAutolockStatus"); - connect(subscriberKCoreAppUIsAutolockStatus, SIGNAL(contentsChanged()), this, - SLOT(subscriberKCoreAppUIsAutolockStatusChanged())); + subscriberKCTsyCallState = new QValueSpaceSubscriber("/KPSUidCtsyCallInformation/KCTsyCallState", this); + err = connect(subscriberKCTsyCallState, SIGNAL(contentsChanged()), this, SLOT(subscriberKCTsyCallStateChanged())); + RDEBUG("err", err); + subscriberKSecurityUIsTestCode = new QValueSpaceSubscriber("/KPSUidSecurityUIs/KSecurityUIsTestCode", this); + err = connect(subscriberKSecurityUIsTestCode, SIGNAL(contentsChanged()), this, SLOT(subscriberKSecurityUIsTestCodeChanged())); + RDEBUG("err", err); // inactivity connect(serviceKeyguard, SIGNAL(active()), this, SLOT(activeKeyguard())); - connect(serviceKeyguard, SIGNAL(notActive()), this, SLOT( - notActiveKeyguard())); - connect(serviceDevicelock, SIGNAL(active()), this, SLOT( - activeDevicelock())); - connect(serviceDevicelock, SIGNAL(notActive()), this, SLOT( - notActiveDevicelock())); + connect(serviceKeyguard, SIGNAL(notActive()), this, SLOT(notActiveKeyguard())); + connect(serviceDevicelock, SIGNAL(active()), this, SLOT(activeDevicelock())); + connect(serviceDevicelock, SIGNAL(notActive()), this, SLOT(notActiveDevicelock())); RWindowGroup& groupWin = CEikonEnv::Static()->RootWin(); RDEBUG("got groupWin", 1); - // TODO if I want to release, I should do: mKeyCaptureHandle = env->RootWin().CaptureKey(EKeyBackspace, 0, 0); - groupWin.CaptureKey(EKeyBackspace, 0, 0); - groupWin.CaptureKey(EKeyDeviceF, 0, 0); - groupWin.CaptureKey(EKeyBell, 0, 0); - groupWin.CaptureKey(EKeyTab, 0, 0); - groupWin.CaptureKey(EKeyInsert, 0, 0); + // if I want to release, I should do: mKeyCaptureHandle = env->RootWin().CaptureKey(EKeyBackspace, 0, 0); + mEKeyDeviceFCaptureHandle = groupWin.CaptureKey(EKeyDeviceF, 0, 0); + RDEBUG("mEKeyDeviceFCaptureHandle", mEKeyDeviceFCaptureHandle); + mEKeyBellCaptureHandle = groupWin.CaptureKey(EKeyBell, 0, 0); + RDEBUG("mEKeyBellCaptureHandle", mEKeyBellCaptureHandle); RDEBUG("got mKeyCaptureHandle", 1); + iTempDisableOnlyKeyguardBecauseIncomingCall=0; + iSecQueryUiCreated = -1; - iDeviceDialogCreated = -1; - // TODO for now, always starts unlocked + setDeviceDialogStatus( EDeviceDialogUninitialized ); + iDeviceDialog = NULL; + // for now, always starts unlocked. This is correct because if locked, the unlock-query (from starter) is on top // TryChangeStatus(iLockStatus); TryChangeStatus( ELockNotActive); lower(); hide(); - // not needed: new AutolockService(this); + + iDeviceDialog = new HbDeviceDialog(HbDeviceDialog::NoFlags, this); + connect(iDeviceDialog, SIGNAL(dataReceived(QVariantMap)), SLOT(handleMessageFromScreensaver(QVariantMap)), Qt::QueuedConnection); // Qt::QueuedConnection needed to avoid deadlock at waitForClosed + connect(iDeviceDialog, SIGNAL(deviceDialogClosed()), SLOT(handleScreensaverClosed())); + + // screensaver standby mode timer + mScreensaverModeTimer = new QTimer(this); + mScreensaverModeTimer->setInterval(5 * 1000); // milliseconds, TODO: read from cenrep + connect(mScreensaverModeTimer, SIGNAL(timeout()), SLOT(switchScreensaverToPowerSaveMode())); + // screensaver AMOLED low power mode support + + // handled now directly but screensaver + // mScreensaverPowerSave = CPowerSaveDisplayMode::NewL(); + // mScreensaverPowerSavePixelBuffer = HBufC16::NewL(360 * 640); + // mScreensaverPowerSavePixelBuffer->Des().Fill(0); + RDEBUG("99", 0x99); } +// destructor Autolock::~Autolock() { RDEBUG("0", 0); delete mService; + // handled now directly but screensaver + // delete mScreensaverPowerSave; + // delete mScreensaverPowerSavePixelBuffer; + RDEBUG("99", 0x99); } +// when detected some settings change, syncronize all of them void Autolock::adjustInactivityTimers(int aReason) { RDEBUG("aReason", aReason); @@ -300,46 +327,100 @@ TInt lockTime = 0; CRepository* repository = NULL; TInt cRresult = 0; + Q_UNUSED(cRresult); - QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidSecuritySettings) ); - cRresult = repository->Get(KSettingsAutomaticKeyguardTime, keyguardTime); // in seconds + QT_TRAP_THROWING(repository = CRepository::NewL(KCRUidSecuritySettings)); + cRresult = repository->Get(KSettingsAutomaticKeyguardTime, keyguardTime); // in seconds RDEBUG("KSettingsAutomaticKeyguardTime", KSettingsAutomaticKeyguardTime); RDEBUG("cRresult", cRresult); RDEBUG("keyguardTime", keyguardTime); - if (keyguardTime > 0 && keyguardTime < 1000) + if (keyguardTime > 2 && keyguardTime < 24 * 60 * 60) // limit it to 1 day { serviceKeyguard->setInactivityPeriod(keyguardTime); } else { - serviceKeyguard->setInactivityPeriod(12 * 31 * 24 * 60 * 60); + serviceKeyguard->setInactivityPeriod(12 * 31 * 24 * 60 * 60); // if not set, fake it to 1 year } - cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes, handled internally as seconds + cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes, handled internally as seconds lockTime *= 60; RDEBUG("KSettingsAutoLockTime", KSettingsAutoLockTime); RDEBUG("cRresult", cRresult); RDEBUG("lockTime", lockTime); - if(lockTime == 65535*60) // Special setting "lock at same time as keyguard" at CpDeviceLockPluginView::GetAutoLockIndex which uses this magic number - lockTime = keyguardTime-2; // lock 2 seconds before before, to avoid keyguard->devicelock sequence - if (lockTime > 60 && lockTime < 24*60*60) // lock timer can't be bigger than 1 day + if (lockTime == 65535 * 60) // Special setting "lock at same time as keyguard" at CpDeviceLockPluginView::GetAutoLockIndex which uses this magic number + { + lockTime = keyguardTime - 2; // lock 2 seconds before keyguard, to avoid keyguard->devicelock sequence + if(lockTime<=2) + lockTime=2; + RDEBUG("new lockTime", lockTime); + } + if (lockTime >= 2 && lockTime < 24 * 60 * 60) // lock timer can't be bigger than 1 day { + RDEBUG("setInactivityPeriod lockTime", lockTime); serviceDevicelock->setInactivityPeriod(lockTime); } else { - serviceDevicelock->setInactivityPeriod(12 * 31 * 24 * 60 * 60); // 0x1ea6e00 + RDEBUG("setInactivityPeriod infinite", lockTime); + serviceDevicelock->setInactivityPeriod(12 * 31 * 24 * 60 * 60); // 0x1ea6e00 = 1 year } + delete repository; + RDEBUG("99", 0x99); + } - delete repository; - } +// Some external says to quit. It should not happen, but it helps to validate memory leaks void Autolock::quit() { RDEBUG("0", 0); qApp->quit(); } +// Inform P&S listeners thatthe screensaver is created/hidden/dismissed . In particular, HbDeviceDialogs needs this to display other pending notes. +int Autolock::setDeviceDialogStatus(int aStatus) + { + RDEBUG("aStatus", aStatus); + RDEBUG("prev iDeviceDialogStatus", iDeviceDialogStatus); + TInt lPSStatus; + TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsScreenSaverStatus, lPSStatus); + RDEBUG("err", err); + RDEBUG("lPSStatus", lPSStatus); + if(aStatus>=EDeviceDialogLastValue) + { + RDEBUG("EDeviceDialogLastValue exceeded by aStatus", aStatus); + } + else + { + err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsScreenSaverStatus, aStatus); + iDeviceDialogStatus = aStatus; + RDEBUG("err", err); + } + return aStatus; + } +// Adjust the lights. It uses P&S, honoured by SysAp +int Autolock::TurnLights(int aMode, int aReason, int aCaller) + { + RDEBUG("aMode", aMode); + RDEBUG("aReason", aReason); + RDEBUG("aCaller", aCaller); + TInt err = 0; + if(aMode!=ESecurityUIsLightsLockOffRequest && aMode!=ELockAppDisableKeyguard) + { + RDEBUG("KLightsSSForcedLightsOn", KLightsSSForcedLightsOn); + err = RProperty::Set(KPSUidCoreApplicationUIs, KLightsSSForcedLightsOn, 30); + } + else + { + RDEBUG("skip KLightsSSForcedLightsOn because aMode", aMode); + } + RDEBUG("err", err); + err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLights, aMode); + RDEBUG("KSecurityUIsLights err", err); + return err; + } + +// When locked, ask for the code. Returns KErrNone or KErrCancel. In other words: this keeps asking until correct code. int Autolock::AskValidSecCode(int aReason) { RDEBUG("aReason", aReason); @@ -349,19 +430,16 @@ return KErrNone; #endif - TInt err(KErrGeneral); + Q_UNUSED(err); TBool validCode(EFalse); TInt thisTry(0); RTelServer iTelServer; - err = RProperty::Set(KPSUidSecurityUIs, - KSecurityUIsLights, ESecurityUIsLightsQueryOnRequest); - RDEBUG("KSecurityUIsLights err", err); + TurnLights(ESecurityUIsLightsQueryOnRequest, aReason, 0x10); RMmCustomAPI iCustomPhone; - while ((err = iTelServer.Connect()) != KErrNone && (thisTry++) - <= KTriesToConnectServer) + while ((err = iTelServer.Connect()) != KErrNone && (thisTry++) <= KTriesToConnectServer) { User::After( KTimeBeforeRetryingServerConnection); } @@ -382,18 +460,18 @@ if (aReason == ELockAppDisableDevicelock) { RDEBUG("calling AskSecCodeInAutoLockL", 0); - QT_TRAP_THROWING( validCode = handler->AskSecCodeInAutoLockL() ); // this returns true/false + iLockCodeQueryInDisplay = ETrue; + QT_TRAP_THROWING(validCode = handler->AskSecCodeInAutoLockL()); // this returns true/false + iLockCodeQueryInDisplay = EFalse; // TODO should this also do iPhone.SetLockSetting(status, lockType, lockChange); ??? } else if (aReason == ELockAppEnableDevicelock) { // check whether code is really needed - RMobilePhone::TMobilePhoneLock lockType = - RMobilePhone::ELockPhoneDevice; + RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice; RMobilePhone::TMobilePhoneLockInfoV1 lockInfo; RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo); - RMobilePhone::TMobilePhoneLockSetting lockChange( - RMobilePhone::ELockSetDisabled); + RMobilePhone::TMobilePhoneLockSetting lockChange(RMobilePhone::ELockSetDisabled); TRequestStatus status = KRequestPending; TInt ret = KErrNone; RDEBUG("GetLockInfo", 0); @@ -403,7 +481,7 @@ ret = status.Int(); RDEBUG("WaitForRequest ret", ret); #ifdef __WINS__ - if(ret==KErrTimedOut) + if (ret == KErrTimedOut) { ret = KErrNone; lockInfo.iSetting = RMobilePhone::ELockSetDisabled; // ask password only if there's no timeout. @@ -430,11 +508,11 @@ #else RDEBUG("! OLD_METHOD", 0); CWait *iWait = NULL; - QT_TRAP_THROWING( iWait = CWait::NewL() ); + QT_TRAP_THROWING(iWait = CWait::NewL()); iWait->SetRequestType(EMobilePhoneSetLockSetting); iPhone.SetLockSetting(iWait->iStatus, lockType, lockChange); // ask for PassPhraseRequiredL RDEBUG("WaitForRequestL", 0); - QT_TRAP_THROWING( ret = iWait->WaitForRequestL() ); + QT_TRAP_THROWING(ret = iWait->WaitForRequestL()); RDEBUG("WaitForRequestL ret", ret); if (iWait) { @@ -451,8 +529,8 @@ RDEBUG("WaitForRequestL ret", ret); #ifdef __WINS__ - if(ret==KErrTimedOut) - ret = KErrNone; + if (ret == KErrTimedOut) + ret = KErrNone; #endif if (ret == KErrNone) validCode = 1; @@ -460,145 +538,184 @@ validCode = 0; } else - { - RDEBUG("RMobilePhone::ELockSetEnabled", RMobilePhone::ELockSetEnabled); - RDEBUG("lockInfo.iSetting = RMobilePhone::ELockSetEnabled", RMobilePhone::ELockSetEnabled); + { + RDEBUG("RMobilePhone::ELockSetEnabled", RMobilePhone::ELockSetEnabled); + RDEBUG("lockInfo.iSetting = RMobilePhone::ELockSetEnabled", RMobilePhone::ELockSetEnabled); validCode = 0x20; - } + } } else { RDEBUG("Error: ret", ret); validCode = 0x21; - } + } /* Alternative way to ask for password RMobilePhone::TMobilePhoneSecurityEvent iEvent; TInt result = KErrNone; iEvent = RMobilePhone::EPhonePasswordRequired; RDEBUG( "calling HandleEventL", 0 ); - handler->HandleEventL(iEvent, result); // this is supposed to wait + handler->HandleEventL(iEvent, result); // this is supposed to wait validCode = false; if(result) validCode = true; RDEBUG( "result", result ); */ } - // TODO this doesn't wait on WINS , so how do I get the Acceptation? RDEBUG("validCode", validCode); - if (validCode>0) + if (validCode > 0) return KErrNone; - // no valid code -> switch off the lights - err = RProperty::Set(KPSUidSecurityUIs, - KSecurityUIsLights, ESecurityUIsLightsLockOffRequest); - RDEBUG("KSecurityUIsLights err", err); + // no valid code -> switch off the lights + TurnLights(ESecurityUIsLightsLockOffRequest, aReason, 0x12); return KErrCancel; } +// The API client might inform that it got our answer. Nothing to do. void Autolock::handleAnswerDelivered() { RDEBUG("0", 0); // quit(); } - +// This was used when Autolock-debug had a label to display the request. Not in use any more void Autolock::setLabelNumber(QString label, QString number) { RDEBUG("0", 0); } +// Used on debug environment for printing the Request in understandable format void Autolock::DebugRequest(int aReason) { switch (aReason) { case ELockAppEnableKeyguard: - RDEBUG("ELockAppEnableKeyguard", aReason); + RDEBUG("ELockAppEnableKeyguard", aReason) + ; break; case ELockAppDisableKeyguard: - RDEBUG("ELockAppDisableKeyguard", aReason); + RDEBUG("ELockAppDisableKeyguard", aReason) + ; break; case ELockAppEnableDevicelock: - RDEBUG("ELockAppEnableDevicelock", aReason); + RDEBUG("ELockAppEnableDevicelock", aReason) + ; break; case ELockAppDisableDevicelock: - RDEBUG("ELockAppDisableDevicelock", aReason); + RDEBUG("ELockAppDisableDevicelock", aReason) + ; break; case ELockAppOfferKeyguard: - RDEBUG("ELockAppOfferKeyguard", aReason); + RDEBUG("ELockAppOfferKeyguard", aReason) + ; break; case ELockAppOfferDevicelock: - RDEBUG("ELockAppOfferDevicelock", aReason); + RDEBUG("ELockAppOfferDevicelock", aReason) + ; break; case ELockAppShowKeysLockedNote: - RDEBUG("ELockAppShowKeysLockedNote", aReason); + RDEBUG("ELockAppShowKeysLockedNote", aReason) + ; break; default: - RDEBUG("default", aReason); + RDEBUG("default", aReason) + ; break; } } +// Used on debug environment for printing the Status in understandable format void Autolock::DebugStatus(int aReason) { switch (aReason) { case ELockNotActive: - RDEBUG("ELockNotActive", aReason); + RDEBUG("ELockNotActive", aReason) + ; break; case EKeyguardActive: - RDEBUG("EKeyguardActive", aReason); + RDEBUG("EKeyguardActive", aReason) + ; break; case EDevicelockActive: - RDEBUG("EDevicelockActive", aReason); + RDEBUG("EDevicelockActive", aReason) + ; break; default: - RDEBUG("default", aReason); + RDEBUG("default", aReason) + ; break; } } +// Used on debug environment for printing the Error in understandable format void Autolock::DebugError(int aReason) { switch (aReason) { case KErrNone: - RDEBUG("KErrNone", aReason); + RDEBUG("KErrNone", aReason) + ; break; - case KErrPermissionDenied: // caller doesn't have enough capabilities - RDEBUG("KErrPermissionDenied", aReason); + case KErrPermissionDenied: // caller doesn't have enough capabilities + RDEBUG("KErrPermissionDenied", aReason) + ; break; - case KErrAlreadyExists: // this particular lock is already enabled - RDEBUG("KErrAlreadyExists", aReason); + case KErrAlreadyExists: // this particular lock is already enabled + RDEBUG("KErrAlreadyExists", aReason) + ; break; - case KErrInUse: // the dialog is already shown - RDEBUG("KErrInUse", aReason); + case KErrInUse: // the dialog is already shown + RDEBUG("KErrInUse", aReason) + ; + break; + case KErrLocked: // never happens + RDEBUG("KErrLocked", aReason) + ; break; default: - RDEBUG("default", aReason); + RDEBUG("default", aReason) + ; break; } } - +// Check whether the future status is valid. +// Typical reasons for failure include: not correct status for this operation, lack of capabilities. +// Note that other things are handled in specific places: Active call, grip open, query on top int Autolock::CheckIfLegal(int aReason) { RDEBUG("aReason", aReason); - // check whether a dialog is already displayed. This is to prevent timeout-lock and timeout-keyguard for activated on top of a PIN query, in particular at boot-up (TODO Starter) + // check whether a dialog is already displayed. This is to prevent timeout-lock and timeout-keyguard activated on top of a PIN query, in particular at boot-up (TODO check for Starter) TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized); - TInt err = RProperty::Get(KPSUidSecurityUIs, - KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); + TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); RDEBUG("err", err); RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery); + + TInt startupValue(EStartupUiPhaseUninitialized); + err = RProperty::Get(KPSUidStartup, KPSStartupUiPhase, startupValue); + RDEBUG("err", err); + RDEBUG("startupValue", startupValue); + + TInt simStatusValue(0); + err = RProperty::Get(KPSUidStartup, KPSSimStatus, simStatusValue); + RDEBUG("err", err); + RDEBUG("simStatusValue", simStatusValue); + if(startupValueSet(KSettingsAutolockStatus, 0); // the settings remains. Only ISA changes, as well as the P&S + // cRresult = repositoryDevicelock->Set(KSettingsAutolockStatus, 0); // the settings remains. Only ISA changes, as well as the P&S cRresult = repositoryKeyguard->Set(KSysApKeyguardActive, 0); RDEBUG("cRresult", cRresult); } @@ -764,30 +888,36 @@ { if (aReason == EKeyguardActive) { - err = RProperty::Set(KPSUidAvkonDomain, KAknKeyguardStatus, - EKeyguardLocked); - RDEBUG("KAknKeyguardStatus err", err); - err = RProperty::Set(KPSUidCoreApplicationUIs, - KCoreAppUIsAutolockStatus, EAutolockOff); - RDEBUG("KCoreAppUIsAutolockStatus err", err); - err = RProperty::Set(KPSUidSecurityUIs, - KSecurityUIsLights, ESecurityUIsLightsLockOffRequest); // same for keyguard and devicelock - RDEBUG("KSecurityUIsLights err", err); + err = RProperty::Set(KPSUidAvkonDomain, KAknKeyguardStatus, EKeyguardLocked); + RDEBUG("KAknKeyguardStatus err", err); + if(autolockState!=EAutolockOff) + { + err = RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOff); + RDEBUG("KCoreAppUIsAutolockStatus err", err); + } + else + { + RDEBUG("not set KCoreAppUIsAutolockStatus because already ", EAutolockOff); + } + TurnLights(ESecurityUIsLightsLockOffRequest, aReason, 0x16); // same for keyguard and devicelock // cRresult = repositoryDevicelock->Set(KSettingsAutolockStatus, 0); cRresult = repositoryKeyguard->Set(KSysApKeyguardActive, 1); RDEBUG("cRresult", cRresult); } else if (aReason >= EDevicelockActive) { - err = RProperty::Set(KPSUidAvkonDomain, KAknKeyguardStatus, - EKeyguardAutolockEmulation); // Other candidates might be: EKeyguardLocked and EKeyguardNotActive - RDEBUG("KAknKeyguardStatus err", err); - err = RProperty::Set(KPSUidCoreApplicationUIs, - KCoreAppUIsAutolockStatus, EManualLocked); - RDEBUG("KCoreAppUIsAutolockStatus err", err); - err = RProperty::Set(KPSUidSecurityUIs, - KSecurityUIsLights, ESecurityUIsLightsLockOffRequest); - RDEBUG(" KSecurityUIsLights err", err); + err = RProperty::Set(KPSUidAvkonDomain, KAknKeyguardStatus, EKeyguardLocked); // previously EKeyguardAutolockEmulation, but then Telephone doesn't understand that it's keyguarded. Other candidates might be: EKeyguardLocked and EKeyguardNotActive + RDEBUG("KAknKeyguardStatus err", err); + if(autolockState!=EManualLocked) + { + err = RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EManualLocked); + RDEBUG("KCoreAppUIsAutolockStatus err", err); + } + else + { + RDEBUG("not set KCoreAppUIsAutolockStatus because already ", EManualLocked); + } + TurnLights(ESecurityUIsLightsQueryOnRequest, aReason, 0x18); // cRresult = repositoryDevicelock->Set(KSettingsAutolockStatus, 1); cRresult = repositoryKeyguard->Set(KSysApKeyguardActive, 0); // keyguard disabled, so that user can type and DeviceF can be captured RDEBUG("cRresult", cRresult); @@ -802,11 +932,16 @@ RDEBUG("setting iLockStatus", iLockStatus); return KErrNone; } -/********************/ +// Shows a note. This is used from the API to inform about actions. The side-switch-key and the automatic lock will not show notes. int Autolock::showNoteIfRequested(int aReason) { RDEBUG("aReason", aReason); - + // The notes are displayed. This is useful only for the API withNote, and ELockAppShowKeysLockedNote + // However, it has some inconvenients: + // - the screensaver already displays/hides + // - the notes are shown behing the icon because they have lower priorities + // - they are annoying + // TODO translate if (aReason == ELockNotActive) { if (iShowKeyguardNote == 1) @@ -819,6 +954,7 @@ if (iShowKeyguardNote == 1) { HbDeviceMessageBox::information("Keyguard activated"); + // this already waits a bit because the lock-icon takes some time to display. So the note is visible before the lock-icon. } } else if (aReason >= EDevicelockActive) // this doesn't happen, but we are prepared nevertheless @@ -830,7 +966,9 @@ } return KErrNone; } -/***********************/ +// Does the logic and actions for changing status. +// This is the main function of this program. +// On every status, the process is the same: continue with next step only if previous one is successful. int Autolock::TryChangeStatus(int aReason) { RDEBUG("aReason", aReason); @@ -838,10 +976,13 @@ int errorInProcess = KErrNone; DebugRequest(ret); - TInt err = RProperty::Set(KPSUidSecurityUIs, - KSecurityUIsDismissDialog, - ESecurityUIsDismissDialogOn); - RDEBUG("err", err); + TInt err = KErrNone; + Q_UNUSED(err); + // this will NOT cancel any previous dialog, i.e. PIN query, or any previous code-request. + // not sure about the screensaver, but nevertheless will be cancelled when the status is changed. + RDEBUG("Not setting KSecurityUIsDismissDialog ESecurityUIsDismissDialogOn", ESecurityUIsDismissDialogOn); + //// err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogOn); + RDEBUG("err", err); switch (ret) { case ELockAppEnableKeyguard: // 1 @@ -850,11 +991,20 @@ DebugError(errorInProcess); if (errorInProcess == KErrNone) { - setLabelIcon( EKeyguardActive); + showNoteIfRequested( EKeyguardActive); + setLabelIcon(EKeyguardActive); updateIndicator(EKeyguardActive); publishStatus(EKeyguardActive); - showNoteIfRequested(EKeyguardActive); + setLockDialog(aReason, EDeviceDialogCreated); } + // Telephone might want to re-enable only-keyguard after the call ends. Allow it. This means re-showing the screensaver, not more. + // Note: this is already done in CallStateChanged, so it's useless. Therefore it expects KErrLocked, which never happens + if (errorInProcess == KErrLocked && iTempDisableOnlyKeyguardBecauseIncomingCall==1) + { + RDEBUG("allowing telephone to re-enable keyguard . Call setLockDialog EDeviceDialogScreenSaverReDisplay", EDeviceDialogScreenSaverReDisplay); + setLockDialog(aReason, EDeviceDialogScreenSaverReDisplay); + iTempDisableOnlyKeyguardBecauseIncomingCall=0; + } } break; case ELockAppDisableKeyguard: // 2 @@ -863,12 +1013,30 @@ DebugError(errorInProcess); if (errorInProcess == KErrNone) { - setLabelIcon( ELockNotActive); + showNoteIfRequested( ELockNotActive); + setLabelIcon(ELockNotActive); updateIndicator(ELockNotActive); publishStatus(ELockNotActive); - showNoteIfRequested(ELockNotActive); + setLockDialog(aReason, EDeviceDialogDestroyed); } } + RDEBUG("errorInProcess", errorInProcess); + // Telephone might want to disable only-keyguard during a call. Allow it. This means hiding the screensaver, not more. + // Note: this is already done in CallStateChanged, so it's useless. Therefore it expects KErrLocked, which never happens + if(errorInProcess==KErrLocked) + { + TInt aCallStatus=-1; + TInt err = RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, aCallStatus); + RDEBUG("err", err); + RDEBUG("aCallStatus", aCallStatus); + if (aCallStatus != EPSCTsyCallStateUninitialized && aCallStatus != EPSCTsyCallStateNone) + { + RDEBUG("allowing telephone to disable keyguard . Call setLockDialog EDeviceDialogScreenSaverHidden", EDeviceDialogScreenSaverHidden); + setLockDialog(aReason, EDeviceDialogScreenSaverHidden); + iTempDisableOnlyKeyguardBecauseIncomingCall=1; + errorInProcess=KErrNone; + } + } break; case ELockAppEnableDevicelock: // 3 { @@ -885,7 +1053,7 @@ updateIndicator( EDevicelockActive); publishStatus(EDevicelockActive); setLabelIcon(EDevicelockActive); - setLockDialog(aReason, 1); + setLockDialog(aReason, EDeviceDialogCreated); } // aParam1 is aReason : EDevicelockManual, EDevicelockRemote // this never shows a note @@ -903,30 +1071,54 @@ } if (errorInProcess == KErrNone) { - setLockDialog(aReason, 0); // hide temporarilly because HbDeviceMessageBox doesn't get in top of the Lock-icon. Thus, dismiss it. - RDEBUG("calling HbDeviceMessageBox::question", 0); - bool value = HbDeviceMessageBox::question("Disable Lock?"); // this doesn't block other events, so after return everything might be messed up. + RDEBUG("skip setLockDialog", 0); + // No need to disable screensaver. Notes now can get on top. Also, this avoids the transition Screensaver->unlockQuery, which produces flicker on HomeScreen. + setLockDialog(aReason, EDeviceDialogScreenSaverHidden); // Hide temporarilly because HbDeviceMessageBox doesn't get in top of the Lock-icon. Thus, dismiss it. + // do I need to enable touch? it seems to work without it + // in any case, lights are needed + TurnLights(ESecurityUIsLightsQueryOnRequest, aReason, 0x20); + bool value = true; + // not sure whether this question is really needed. The UI doesn't say anything, so I remove it for now. + RDEBUG("not calling HbDeviceMessageBox::question", 0); + // value = HbDeviceMessageBox::question("Disable Lock?"); // this doesn't block other events, so after return everything might be messed up. RDEBUG("value", value); if (!value) errorInProcess = KErrCancel; } if (errorInProcess == KErrNone) { - setLockDialog(aReason, 0); // hide temporarilly because AskValidSecCode doesn't get in top of the Lock-icon. Thus, dismiss it. + RDEBUG("skip setLockDialog", 0); + // No need to disable screensaver. Notes now can get on top. Also, this avoids the transition Screensaver->unlockQuery, which produces flicker on HomeScreen. + setLockDialog(aReason, EDeviceDialogScreenSaverHidden); // hide temporarilly because AskValidSecCode doesn't get in top of the Lock-icon. Thus, dismiss it. RDEBUG("calling AskValidSecCode", 0); errorInProcess = AskValidSecCode(ELockAppDisableDevicelock); RDEBUG("errorInProcess", errorInProcess); } if (errorInProcess == KErrNone) { + // code is correct. Time to destroy the lock-icon setLabelIcon( ELockNotActive); updateIndicator(ELockNotActive); + setLockDialog(aReason, EDeviceDialogDestroyed); publishStatus(ELockNotActive); } - if (errorInProcess != KErrNone) - { // re-lock. For example, if password is wrong - if( iLockStatus >=EDevicelockActive) // this skips the case "unlocking although it wan't locked" - setLockDialog(aReason, 1); + else // errorInProcess != KErrNone + { // re-lock. For example, if password is cancelled. Remember that this applies also for the case KErrPermissionDenied + TInt aCallStatus=-1; + TInt skipScreenSaver=0; + TInt err = RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, aCallStatus); + RDEBUG("err", err); + RDEBUG("aCallStatus", aCallStatus); + if (aCallStatus != EPSCTsyCallStateUninitialized && aCallStatus != EPSCTsyCallStateNone) + { + // if there's an active call and the query is cancelled, screensaver should not show. + skipScreenSaver=1; // if it's skipped, it will be set at CallStateChanged + RDEBUG("new skipScreenSaver", skipScreenSaver); + } + RDEBUG("skipScreenSaver", skipScreenSaver); + if (iLockStatus >= EDevicelockActive) // this skips the case "unlocking although it wasn't locked" + if(!skipScreenSaver) + setLockDialog(ELockAppEnableDevicelock, EDeviceDialogScreenSaverReDisplay); } // this never shows a note } @@ -937,14 +1129,20 @@ DebugError(errorInProcess); if (errorInProcess == KErrNone) { - bool value = HbDeviceMessageBox::question("Enable Keyguard?"); // this doesn't block other events, so after return everything might be messed up. - // TODO what about a nice icon? + // no need to dismiss screensaver, because it's not active + // what about any PIN-query, i.e. from settings ? In this case, the query will show after the PIN query is finished. somehow this is good because PIN is more important + bool value = HbDeviceMessageBox::question("Enable Keyguard?"); // this doesn't block other events, so after return everything might be messed up i.e. the time-out might have triggered. + // what about a nice icon? RDEBUG("value", value); if (!value) errorInProcess = KErrCancel; } if (errorInProcess == KErrNone) { + errorInProcess = CheckIfLegal(ret); // confirm that it's still possible to do it. For example, if API did a lock + } + if (errorInProcess == KErrNone) + { errorInProcess = TryChangeStatus(ELockAppEnableKeyguard); } // this never shows a note @@ -956,9 +1154,11 @@ DebugError(errorInProcess); if (errorInProcess == KErrNone) { - setLockDialog(aReason, 0); // hide temporarilly because AskValidSecCode doesn't get in top of the Lock-icon. Thus, dismiss it. - errorInProcess = AskValidSecCode(ELockAppEnableDevicelock); - } + RDEBUG("skip setLockDialog", 0); + // No need to disable screensaver. Notes now can get on top. Also, this avoids the transition Screensaver->unlockQuery, which produces flicker on HomeScreen. + setLockDialog(aReason, EDeviceDialogScreenSaverHidden); // hide temporarilly because AskValidSecCode doesn't get in top of the Lock-icon. Thus, dismiss it. + errorInProcess = AskValidSecCode(ELockAppEnableDevicelock); + } if (errorInProcess == KErrNone) { RDEBUG("ELockAppOfferDevicelock calling ELockAppEnableDevicelock", ELockAppEnableDevicelock); @@ -967,75 +1167,150 @@ // this never shows a note. Perhaps ELockAppEnableDevicelock does. } break; - case ELockAppShowKeysLockedNote: // 7 + case ELockAppShowKeysLockedNote: // 7 { - errorInProcess = CheckIfLegal(ret); // it will not be legal if the keyguard is not enabled and the devicelock is not enabled. + errorInProcess = CheckIfLegal(ret); // it will not be legal if the keyguard is not enabled and the devicelock is not enabled. DebugError(errorInProcess); if (errorInProcess == KErrNone) { iShowKeyguardNote = 1; // this is not sent as parameter, so we need to fake it: ON - showNoteIfRequested( EKeyguardActive); - } + showNoteIfRequested( EKeyguardActive); + } } break; default: + { RDEBUG("default", ret); errorInProcess = KErrNotSupported; + } break; } + RDEBUG("errorInProcess", errorInProcess); return errorInProcess; } -/**************************/ -int Autolock::setLockDialog(int aReason, int status) +// Shows or hides the Screensaver/LockIcon +int Autolock::setLockDialog(int aReason, int target) { RDEBUG("aReason", aReason); - RDEBUG("status", status); - RDEBUG("iDeviceDialogCreated", iDeviceDialogCreated); + RDEBUG("target", target); + RDEBUG("iDeviceDialogStatus", iDeviceDialogStatus); TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized); - TInt err = RProperty::Get(KPSUidSecurityUIs, - KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); + TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); RDEBUG("err", err); RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery); - if (status == 0) // hide + RWindowGroup& groupWin = CEikonEnv::Static()->RootWin(); + + if (target == EDeviceDialogDestroyed || target == EDeviceDialogScreenSaverHidden) // hide { + RDEBUG("ReleaseContext", R_AVKON_DEFAULT_SKEY_LIST); + static_cast(CEikonEnv::Static()->EikAppUi())->KeySounds()->ReleaseContext(); + RDEBUG("PopContext", 0x90); + static_cast(CEikonEnv::Static()->EikAppUi())->KeySounds()->PopContext(); + RDEBUG("ReleaseContext done", 0x92); + + // aReason is not important here, but let's check nevertheless + if (aReason != ELockAppDisableKeyguard && aReason != ELockAppDisableDevicelock && aReason != ELockAppOfferDevicelock) + { + RDEBUG("!!!!****!!!!! error. target=0 but aReason", aReason); + } // secUiOriginatedQuery should be ESecurityUIsSystemLockOriginated . If not, this is not correctly setting it - if (iDeviceDialogCreated > 0) + if (iDeviceDialogStatus >= EDeviceDialogCreated) { - iDeviceDialogCreated = 0; - iDeviceDialog->cancel(); - err = iDeviceDialog->error(); - RDEBUG("err", err); - TInt err = RProperty::Set(KPSUidSecurityUIs, - KSecurityUIsSecUIOriginatedQuery, - ESecurityUIsSecUIOriginatedUninitialized); - RDEBUG("err", err); + if(mScreensaverModeTimer) + { + RDEBUG("mScreensaverModeTimer->stop()", 0); + mScreensaverModeTimer->stop(); + } + if(target == EDeviceDialogDestroyed) + { + disconnect(iDeviceDialog, SIGNAL(dataReceived(QVariantMap)), this, SLOT(handleMessageFromScreensaver(QVariantMap))); + disconnect(iDeviceDialog, SIGNAL(deviceDialogClosed()), this, SLOT(handleScreensaverClosed())); + RDEBUG("signal disconnected", err); + // TODO this used to crash for EDeviceDialogScreenSaver. Not anymore. + err = iDeviceDialog->cancel(); + RDEBUG("cancel (bool: 1= wellCancelled) err", err); + err = iDeviceDialog->error(); + RDEBUG("err", err); + RDEBUG("calling iDeviceDialog->waitForClosed()", 0); + err = iDeviceDialog->waitForClosed(); + RDEBUG("cancel (bool: 1= well waitForClosed) err", err); + err = iDeviceDialog->error(); + RDEBUG("err", err); + handleScreensaverClosed(); + RDEBUG("deleting iDeviceDialog", 0); + delete iDeviceDialog; + RDEBUG("deleted iDeviceDialog", 1); + iDeviceDialog = NULL; + } + else if(target == EDeviceDialogScreenSaverHidden) + { + RDEBUG("calling switchScreensaverMode", ESnsrViewTypeDisabled); + switchScreensaverMode( ESnsrViewTypeDisabled); + } + + TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSecUIOriginatedUninitialized); + RDEBUG("reset KSecurityUIsSecUIOriginatedQuery. err", err); + + // Lights will be on by SysAp when screen is un-keyguarded + // TurnLights(ESecurityUIsLightsQueryOnRequest, aReason, 0x22); // let's bring light into HomeScreen + // Cancel power key and application key capturing + groupWin.CancelCaptureKey(mPowerKeyCaptureHandle); + groupWin.CancelCaptureKey(mApplicationKeyCaptureHandle); + groupWin.CancelCaptureLongKey(mApplicationLongKeyCaptureHandle); + RDEBUG("done CancelCaptureKey", 1); + if (mEKeyYesCaptureHandle) + { + RDEBUG("mEKeyYesCaptureHandle", mEKeyYesCaptureHandle); + groupWin.CancelCaptureKey(mEKeyYesCaptureHandle); + mEKeyYesCaptureHandle = NULL; + } + if (mEKeyNoCaptureHandle) + { + RDEBUG("mEKeyNoCaptureHandle", mEKeyNoCaptureHandle); + groupWin.CancelCaptureKey(mEKeyNoCaptureHandle); + mEKeyNoCaptureHandle = NULL; + } + setDeviceDialogStatus( target ); } } - else if (status == 1) // show + else if (target == EDeviceDialogCreated || target == EDeviceDialogScreenSaverReDisplay) // show { + RDEBUG("PushContextL", R_AVKON_DEFAULT_SKEY_LIST); + static_cast(CEikonEnv::Static()->EikAppUi())->KeySounds()->PushContextL(R_AVKON_SILENT_SKEY_LIST); + RDEBUG("BringToForeground", 0x90); + static_cast(CEikonEnv::Static()->EikAppUi())->KeySounds()->BringToForeground(); + RDEBUG("LockContext", 0x91); + static_cast(CEikonEnv::Static()->EikAppUi())->KeySounds()->LockContext(); + RDEBUG("PushContextL Done", 0x92); + // secUiOriginatedQuery should be ESecurityUIsSecUIOriginatedUninitialized . If not, the validation is not correctly filtering it QVariantMap params; - TBool err; -#define ESecUiTypeDeviceLock 0x00100000 -#define ESecUiTypeKeyguard 0x00200000 + TBool err=EFalse; - if (aReason == EKeyguardActive) + if (aReason == ELockAppEnableKeyguard) params.insert("type", ESecUiTypeKeyguard); - else if (aReason >= EDevicelockActive) + else if (aReason == ELockAppEnableDevicelock) params.insert("type", ESecUiTypeDeviceLock); else { - RDEBUG("error. status=1 but aReason", aReason); + RDEBUG("!!!!****!!!!! error. target=1 but aReason", aReason); } // no need for title. Icon should be explicit enough // params.insert("title", "Locked"); - if (iDeviceDialogCreated <= 0) + if (iDeviceDialogStatus < EDeviceDialogCreated) { + if (iDeviceDialog != NULL) + { + RDEBUG("!!!!!!*********!!!!!!!! error: iDeviceDialog != NULL", 0); + } RDEBUG("creating iDeviceDialog", 0); iDeviceDialog = new HbDeviceDialog(HbDeviceDialog::NoFlags, this); - iDeviceDialogCreated = 1; + // in theory this is needed only for screensaver, not for LockIcon. But it doesn't harm + connect(iDeviceDialog, SIGNAL(dataReceived(QVariantMap)), SLOT(handleMessageFromScreensaver(QVariantMap)), Qt::QueuedConnection); // Qt::QueuedConnection needed to avoid deadlock at waitForClosed + connect(iDeviceDialog, SIGNAL(deviceDialogClosed()), SLOT(handleScreensaverClosed())); + setDeviceDialogStatus(EDeviceDialogCreated); } else { @@ -1043,42 +1318,91 @@ // confirm that dialog is present err = iDeviceDialog->error(); RDEBUG("err", err); - iDeviceDialogCreated = 2; + setDeviceDialogStatus( EDeviceDialogRaised ); } - const QString KSecQueryUiDeviceDialog("com.nokia.secuinotificationdialog/1.0"); + const QString KScreensaverDeviceDialog("com.nokia.screensaver.snsrdevicedialogplugin/1.0"); RDEBUG("pre show", aReason); - err = iDeviceDialog->show(KSecQueryUiDeviceDialog, params); // and continue processing - RDEBUG("post show. err", err); + TInt skipScreenSaver=0; + bool launchSuccesful = EFalse; + + TInt aCallStatus=-1; + err = RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, aCallStatus); + RDEBUG("aCallStatus", aCallStatus); + // never create screensaver if active call. + if (aCallStatus != EPSCTsyCallStateUninitialized && aCallStatus != EPSCTsyCallStateNone && iLockStatus >= EDevicelockActive ) + { + skipScreenSaver=1; + RDEBUG("new skipScreenSaver", skipScreenSaver); + } + RDEBUG("skipScreenSaver", skipScreenSaver); + if(!skipScreenSaver) + { + if(iDeviceDialogStatus == EDeviceDialogCreated) + { + launchSuccesful = iDeviceDialog->show(KScreensaverDeviceDialog, params); // and continue processing + RDEBUG("post show. bool launchSuccesful", launchSuccesful); + } + else if(iDeviceDialogStatus == EDeviceDialogScreenSaverHidden || iDeviceDialogStatus == EDeviceDialogRaised) + { + RDEBUG("calling switchScreensaverMode ESnsrViewTypeActive", ESnsrViewTypeActive); + switchScreensaverMode( ESnsrViewTypeActive); + launchSuccesful = ETrue; + } + } + RDEBUG("bool launchSuccesful", launchSuccesful); + err = iDeviceDialog->error(); + RDEBUG("iDeviceDialog->error", err); + if (launchSuccesful) // TODO && !error ??? + { + setDeviceDialogStatus( EDeviceDialogScreenSaver ); + // TODO this is needed if creating dialog for first time? switchScreensaverToActiveMode(); // this is needed in case the dialog was existing. + // Start standy mode timer. The initial state may already be the standby + // mode but setting screensaver again to standby doesn't hurt. + mScreensaverModeTimer->start(); + } + else if (!skipScreenSaver)// some err. Usually 3 (component not existing) + { + // screensaver has failed. Probably because it's not installed. Then, try the standard lock-icon + setDeviceDialogStatus( EDeviceDialogLockIcon ); + const QString KSecQueryUiDeviceDialog("com.nokia.secuinotificationdialog/1.0"); + err = iDeviceDialog->show(KSecQueryUiDeviceDialog, params); // and continue processing + RDEBUG("post show. err", err); + } err = iDeviceDialog->error(); RDEBUG("err", err); // This won't be needed when screensaver is in place, as the dialogs will be different, and therefore both can be present // Somehow this should be handled by Orbit, but unfortunatelly they don't allow the same dialog twice - err = RProperty::Set(KPSUidSecurityUIs, - KSecurityUIsSecUIOriginatedQuery, - ESecurityUIsSecUIOriginatedUninitialized); // TODO this should be ESecurityUIsSystemLockOriginated ? + err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSecUIOriginatedUninitialized); // this could also be ESecurityUIsSystemLockOriginated RDEBUG("err", err); - + // Capture power and application keys while screen saver is open. Also works for LockIcon + mPowerKeyCaptureHandle = groupWin.CaptureKey(EKeyDevice2, 0, 0); + mApplicationKeyCaptureHandle = groupWin.CaptureKey(EKeyApplication0, 0, 0); + mApplicationLongKeyCaptureHandle = groupWin.CaptureLongKey(EKeyApplication0, EKeyApplication0, 0, 0, 0, ELongCaptureShortEventImmediately | ELongCaptureRepeatEvents); + mEKeyYesCaptureHandle = groupWin.CaptureKey(EKeyYes, 0, 0); + mEKeyNoCaptureHandle = groupWin.CaptureKey(EKeyNo, 0, 0); + RDEBUG("keys captured", err); } else { - RDEBUG("unknown status", status); + RDEBUG("unknown target", target); return KErrNotSupported; } return KErrNone; } +// Updates the icon. This is not used anymore void Autolock::setLabelIcon(int aReason) { RDEBUG("aReason", aReason); if (aReason == ELockNotActive) { - setLockDialog(aReason, 0); // TODO isn't this done already at TryChangeStatus ??? + // setLockDialog(aReason, 0); // This is done already at TryChangeStatus lower(); hide(); } else if (aReason == EKeyguardActive) { - setLockDialog(aReason, 1); + // setLockDialog(aReason, 1); // This is done already at TryChangeStatus // this shows the Autolock Application. not needed } else if (aReason == EDevicelockActive) @@ -1089,7 +1413,7 @@ RDEBUG("error: aReason", aReason); } } - +// Update idicator in HomeScreen. This is a small key icon in the top-left int Autolock::updateIndicator(int aReason) { RDEBUG("aReason", aReason); @@ -1101,135 +1425,347 @@ HbIndicator indicator; bool success; if (aReason == ELockNotActive) - success = indicator.deactivate( - "com.nokia.hb.indicator.autolock.autolock_8/1.0"); // maybe it's already deactivated. Not a problem + success = indicator.deactivate("com.nokia.hb.indicator.autolock.autolock_8/1.0"); // maybe it's already deactivated. Not a problem else if (aReason == EKeyguardActive) - success = indicator.activate( - "com.nokia.hb.indicator.autolock.autolock_8/1.0"); + success = indicator.activate("com.nokia.hb.indicator.autolock.autolock_8/1.0"); else if (aReason == EDevicelockActive) - success = indicator.activate( - "com.nokia.hb.indicator.autolock.autolock_8/1.0"); // same. We have just 1 indicator + success = indicator.activate("com.nokia.hb.indicator.autolock.autolock_8/1.0"); // same. We have just 1 indicator else success = 0; RDEBUG("success", success); return success; } - +// activity while keyguarded. void Autolock::activeKeyguard() { - // activity while keyguarded. Nothing to do RDEBUG("0", 0); + // Nothing to do + RDEBUG("99", 0x99); } +// inactivity. Keyguard should be activated void Autolock::notActiveKeyguard() { - // inactivity. Keyguard should be activated RDEBUG("0", 0); int ret = KErrNone; DebugStatus( iLockStatus); if (iLockStatus == ELockNotActive) // not possible if it's keyguarded, or locked { - ret = TryChangeStatus(ELockAppEnableKeyguard); + TInt callState = EPSCTsyCallStateNone; + int err = RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState); + RDEBUG("err", err); + RDEBUG("callState", callState); + // if there's an active call, don't auto-keyguard (manual is still possible) + if (callState <= EPSCTsyCallStateNone) + { + ret = TryChangeStatus(ELockAppEnableKeyguard); + RDEBUG("ret", ret); + } + else + { + RDEBUG("not ELockAppEnableKeyguard because callState", callState); + } + } + else + { + // restart screensaver. The scenario is: keyguard->screensaver->CriticalNote->lightsOn . Therefore we need lightsOff + // this is done when keyguard can't be enabled because it's already enabled + // Note that this happens only once, so it's fine to show the screensaver in full light. + if (ret == KErrAlreadyExists) // this could also be iLockStatus == EKeyguardActive + switchScreensaverMode( ESnsrViewTypeInitial); + } + RDEBUG("ret", ret); + } +// Some activity detected while the deviceLock is enabled +void Autolock::activeDevicelock() + { + RDEBUG("0", 0); + // nothing to do + RDEBUG("99", 0x99); + } + +// inactivity. Devicelock should be activated +void Autolock::notActiveDevicelock() + { + RDEBUG("0", 0); + int ret = KErrNone; + Q_UNUSED(ret); + DebugStatus( iLockStatus); + if (iLockStatus == ELockNotActive || iLockStatus == EKeyguardActive) // not possible if it's locked + { + // this is independent of the call status + ret = TryChangeStatus(ELockAppEnableDevicelock); } RDEBUG("ret", ret); } -/* Some activity detected while the deviceLock is enabled */ -void Autolock::activeDevicelock() +// Update the screensaver. Show, hide, or sleep +void Autolock::switchScreensaverMode(int mode) { - // nothing to do + RDEBUG("mode", mode); + if (iDeviceDialog) + { + // maybe this can be used to tell the dialog to dismiss itself? + RDEBUG("got iDeviceDialog. iDeviceDialogStatus", iDeviceDialogStatus); + QVariantMap params; + // this is for LockIcon. Doesn't harm screensaver + // need to send again so that the existing dialog still knows what is its type + if (iLockStatus == EKeyguardActive) + params.insert("type", ESecUiTypeKeyguard); + else if (iLockStatus >= EDevicelockActive) + params.insert("type", ESecUiTypeDeviceLock); + + // this is for screensaver. Doesn't harm LockIcon + params.insert(KSnsrViewTypeKey, mode); + iDeviceDialog->update(params); + + if (mScreensaverModeTimer) + { + if (mode == ESnsrViewTypeStandby || mode == ESnsrViewTypeDisabled) + { + RDEBUG("stop mScreensaverModeTimer", 0); + mScreensaverModeTimer->stop(); + } + else + { + RDEBUG("start mScreensaverModeTimer", 0); + mScreensaverModeTimer->start(); + } + } + } + RDEBUG("99", 0x99); + } + +void Autolock::switchScreensaverToPowerSaveMode() + { RDEBUG("0", 0); + // This crashes IVE3. TODO : restore when it works again. + //switchScreensaverMode( ESnsrViewTypeStandby); + RDEBUG("99", 0x99); } -void Autolock::notActiveDevicelock() +void Autolock::handleMessageFromScreensaver(const QVariantMap &data) { - // inactivity. Devicelock should be activated RDEBUG("0", 0); - int ret = KErrNone; - DebugStatus( iLockStatus); - if (iLockStatus == ELockNotActive || iLockStatus == EKeyguardActive) // not possible if it's locked + RDEBUG("iLockStatus", iLockStatus); + QVariantMap::const_iterator it = data.find(KSnsrCmdUnlock); + if (it != data.end() && iLockStatus != ELockNotActive) + { + RDEBUG("calling handleLockSwitch", 0); + handleLockSwitch(); + } + + it = data.find(KSnsrCmdSwitchLights); + if (it != data.end()) + { + int lightStatus = it.value().toInt(); + RDEBUG("switching screen lights . lightStatus", lightStatus); + int err = RProperty::Set(KPSUidCoreApplicationUIs, KLightsSSForcedLightsOn, lightStatus); + RDEBUG("err", err); + } + + it = data.find(KSnsrCmdSwitchLowPower); + if (it != data.end()) { - ret = TryChangeStatus(ELockAppEnableDevicelock); + QVariantList lowPowerLimits = it.value().toList(); + if (lowPowerLimits.count() == 2) + { + // switch on screen power save mode when start and end lines are given + int startRow = lowPowerLimits.at(0).toInt(); + int endRow = lowPowerLimits.at(1).toInt(); + // TODO: The pixel buffer passed to CPowerSaveDisplayMode is supposed to + // contain the pixels shown in the active area of the screen. Currently, we + // pass a buffer filled with 0s, and this works fine on the reference + // hardware. However, according to display driver people, this doesn't + // work if the display component of the device doesn't have internal memory + // which may be the case in some of our target devices. + + // handled now directly by screensaver + /* + TUint16 *ptr = const_cast (mScreensaverPowerSavePixelBuffer->Ptr()); + RDEBUG("switching screen power save on, number of visible rows", endRow-startRow); + int err = mScreensaverPowerSave->Set(startRow, endRow, ptr); + RDEBUG("err", err); + */ + } + else + { + // any other case is interpreted as an order to switch off the power save and + // return to the normal mode + RDEBUG("switching screen power save off 0", 0); + // handled now directly by screensaver + // int err = mScreensaverPowerSave->Exit(); + // RDEBUG("err", err); + } } - RDEBUG("ret", ret); + RDEBUG("99", 0x99); + } + +void Autolock::handleScreensaverClosed() + { + RDEBUG("0", 0); + int err(0); + // Screensaver (usually) cannot send anymore any commands when + // it's being closed. Thus, we need to ensure here that screen has lights and + // full-power mode once screensaver is closed. + // handled now directly by screensaver + /* + if (mScreensaverPowerSave) + { + RDEBUG("switching screen power save off", 0); + err = mScreensaverPowerSave->Exit(); + RDEBUG("error=", err); + } + */ + RDEBUG("switching screen lights on", 1); + // Not needed because SysAp turns on the lights when keyguard is disabled + // err = RProperty::Set(KPSUidCoreApplicationUIs, KLightsSSForcedLightsOn, 30); + RDEBUG("err", err); } // some key is pressed +// TODO perhaps need a way to stop switch-key while asking unlock-code? +// Not clear what to do here. dismiss query? bool Autolock::event(QEvent *ev) { if (ev) { int isSwitchKey = 0; - // on device, this doesn't seem to get the EKeyDeviceF key: only 1ffffff - if (ev->type() == QEvent::KeyPress) + if (ev->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast (ev); RDEBUG("KeyPress", keyEvent->key()); RDEBUG("KeyPress nativeScanCode", keyEvent->nativeScanCode()); RDEBUG("EStdKeyDeviceF", EStdKeyDeviceF); + RDEBUG("EKeyDeviceF", EKeyDeviceF); RDEBUG("keyEvent->isAutoRepeat()", keyEvent->isAutoRepeat()); - if( !keyEvent->isAutoRepeat() ) - { - if ((keyEvent->key() & 0xFF) == (EKeyInsert & 0xFF)) - { - RDEBUG("EKeyInsert", EKeyInsert); - // only reacts on release, not on press - isSwitchKey = 1; - } - if ((keyEvent->key() & 0xFF) == (EKeyDeviceF & 0xFF)) - { - RDEBUG("EKeyDeviceF", EKeyDeviceF); - } - if (keyEvent->key() == 0x1ffffff) - { - RDEBUG("0x1ffffff", 0x1ffffff); // som unknown key is received. Nothing to do - } - if (keyEvent->nativeScanCode() == EStdKeyDeviceF) - { - RDEBUG("got EStdKeyDeviceF", EStdKeyDeviceF); - isSwitchKey = 1; - } - } - else if (ev->type() == QEvent::KeyRelease) - { - QKeyEvent *keyEvent = static_cast (ev); - RDEBUG("KeyRelease", keyEvent->key()); - RDEBUG("KeyRelease native", keyEvent->nativeScanCode()); - if (keyEvent->nativeScanCode() == EStdKeyDeviceF && !keyEvent->isAutoRepeat()) - { - RDEBUG("released EStdKeyDeviceF", 1); - // isSwitchKey=1; this should happen is pressed was not processed (hint: if it is/was in background) - } - } - } + // note that the key was EKeyApplication0 and EKeyDevice2 + // yes=0xc4 app=0xb4 no=0xa6 + if (keyEvent->nativeScanCode() == EStdKeyApplication0 || keyEvent->nativeScanCode() == EStdKeyDevice2 || keyEvent->nativeScanCode() == EStdKeyYes + || keyEvent->nativeScanCode() == EStdKeyNo) + { + // switch to active screensaver if application key or power key pressed while screensaver active + // This key can be repeated, so that the screensaver remains as long as key is pushed + // TODO what happens when holding Power key ? + switchScreensaverMode( ESnsrViewTypeActive); + TurnLights(ESecurityUIsLightsQueryOnRequest, 0x22 /*aReason*/, 0x24); + } + else if (!keyEvent->isAutoRepeat()) + { + if (keyEvent->key() == EKeyInsert) + { + // on WINS, this is handled with the "Ins" key in the numeric keypad + RDEBUG("EKeyInsert", EKeyInsert); + // only reacts on release, not on press + isSwitchKey = 1; + } + else if (keyEvent->key() == EKeyDeviceF) + { + // this never seem to happen. Nevertheless we are not doing anything + RDEBUG("EKeyDeviceF", EKeyDeviceF); + } + else if (keyEvent->nativeScanCode() == EStdKeyDeviceF) + { + RDEBUG("got EStdKeyDeviceF", EStdKeyDeviceF); + isSwitchKey = 1; + } + else if (keyEvent->nativeScanCode() == EKeyBell) // this might be sent by others, i.e. PCFW + { + RDEBUG("got EKeyBell", EKeyBell); + isSwitchKey = 1; + } + else if (keyEvent->key() == 0x1ffffff) + { + RDEBUG("0x1ffffff", 0x1ffffff); // some unknown key is received. Nothing to do + } + } + } + else if (ev->type() == QEvent::KeyRelease) + { + QKeyEvent *keyEvent = static_cast (ev); + RDEBUG("KeyRelease", keyEvent->key()); + RDEBUG("KeyRelease native", keyEvent->nativeScanCode()); + if (keyEvent->nativeScanCode() == EStdKeyDeviceF && !keyEvent->isAutoRepeat()) + { + RDEBUG("released EStdKeyDeviceF", 1); + // isSwitchKey=1; this should happen is pressed was not processed (hint: if it is/was in background) + } + } RDEBUG("isSwitchKey", isSwitchKey); if (isSwitchKey) { - int ret = KErrNone; - DebugStatus( iLockStatus); - if (iLockStatus == ELockNotActive) - { - iShowKeyguardNote = 1; // note on enable keyguard - ret = TryChangeStatus(ELockAppEnableKeyguard); // this should not ask confirmation - } - else if (iLockStatus == EKeyguardActive) - { - iShowKeyguardNote = 1; // note on disable keyguard - ret = TryChangeStatus(ELockAppDisableKeyguard); - } - else if (iLockStatus == EDevicelockActive) - { - ret = TryChangeStatus(ELockAppDisableDevicelock); - } - else - { - RDEBUG("unknown iLockStatus", iLockStatus); - } - RDEBUG("ret", ret); + handleLockSwitch(); + RDEBUG("0", 0); } // isSwitchKey } // ev // Process if not done before. For example, redraw or quit - return QWidget::event(ev); + TBool widgetEventSuccesful = QWidget::event(ev); + RDEBUG("99", 0x99); + return widgetEventSuccesful; + } +// The side-switch-key is pressed. Un-keyguard if keyguarded ; AskCode if locked. +int Autolock::handleLockSwitch() + { + RDEBUG("0", 0); + int ret = KErrNone; + RDEBUG("iProcessingEvent", iProcessingEvent); + RDEBUG("iLockStatus", iLockStatus); + // iProcessingEvent is used to avoid concurrent processing, i.e. 2 side-switch presses; because it needs time to create (and dismiss) the dialog + // However this disallows keyguard during unlock-quey. + if(iProcessingEvent < 1) + { + iProcessingEvent = 1; + Q_UNUSED(ret); + DebugStatus( iLockStatus); + if (iLockStatus == ELockNotActive) + { + iShowKeyguardNote = 0; // no note on enable keyguard + callerHasECapabilityWriteDeviceData = 1; + // TODO ELockAppEnableDevicelock + CRepository *repository = 0; + int deviceLock = 0; + QT_TRAP_THROWING(repository = CRepository::NewL(KCRUidSecuritySettings)); + repository->Get(KSettingsAutoLockTime, deviceLock); + delete repository; + if (65535 == deviceLock) { + // Setting says "When keys& screen locked". Therefore device is also locked when screen is manually locked. + // TODO what about the API for screen lock? + ret = TryChangeStatus(ELockAppEnableDevicelock); // this should not ask confirmation + } else { + ret = TryChangeStatus(ELockAppEnableKeyguard); // this should not ask confirmation + } + + } + else if (iLockStatus == EKeyguardActive) + { + iShowKeyguardNote = 0; // no note on disable keyguard + callerHasECapabilityWriteDeviceData = 1; + ret = TryChangeStatus(ELockAppDisableKeyguard); + } + else if (iLockStatus == EDevicelockActive) + { + callerHasECapabilityWriteDeviceData = 1; + ret = TryChangeStatus(ELockAppDisableDevicelock); + } + else + { + RDEBUG("unknown iLockStatus", iLockStatus); + } + iProcessingEvent = 0; + } + else + { + // user presses side-switch while another is in process, most probably a unlock-query. Thus, re-switch on the lights + iProcessingEvent++; // just to know how many processes we missed + if(iProcessingEvent>=10) + iProcessingEvent=0; // if user really insists, then try again + if (iLockStatus == EDevicelockActive) + { + TurnLights(ESecurityUIsLightsQueryOnRequest, ELockAppEnableDevicelock, 0x26); + } + } + RDEBUG("ret", ret); + return ret; } bool Autolock::eventFilter(QObject *o, QEvent *ev) @@ -1242,88 +1778,157 @@ void Autolock::subscriberKSettingsAutolockStatusChanged() { RDEBUG("0", 0); - QVariant v = subscriberKSettingsAutolockStatus->value( - "/KCRUidSecuritySettings/KSettingsAutolockStatus"); + QVariant v = subscriberKSettingsAutolockStatus->value("/KCRUidSecuritySettings/KSettingsAutolockStatus"); adjustInactivityTimers( KSettingsAutolockStatus); } void Autolock::subscriberKSettingsAutoLockTimeChanged() { RDEBUG("0", 0); - QVariant v = subscriberKSettingsAutoLockTime->value( - "/KCRUidSecuritySettings/KSettingsAutoLockTime"); + QVariant v = subscriberKSettingsAutoLockTime->value("/KCRUidSecuritySettings/KSettingsAutoLockTime"); adjustInactivityTimers( KSettingsAutoLockTime); } void Autolock::subscriberKSettingsAutomaticKeyguardTimeChanged() { RDEBUG("0", 0); - QVariant v = subscriberKSettingsAutomaticKeyguardTime->value( - "/KCRUidSecuritySettings/KSettingsAutomaticKeyguardTime"); + QVariant v = subscriberKSettingsAutomaticKeyguardTime->value("/KCRUidSecuritySettings/KSettingsAutomaticKeyguardTime"); adjustInactivityTimers( KSettingsAutoLockTime); } void Autolock::subscriberKDisplayLightsTimeoutChanged() { RDEBUG("0", 0); - QVariant v = subscriberKDisplayLightsTimeout->value( - "/KCRUidLightSettings/KDisplayLightsTimeout"); + QVariant v = subscriberKDisplayLightsTimeout->value("/KCRUidLightSettings/KDisplayLightsTimeout"); // nothing to do } void Autolock::subscriberKProEngActiveProfileChanged() { RDEBUG("0", 0); - QVariant v = subscriberKProEngActiveProfile->value( - "/KCRUidProfileEngine/KProEngActiveProfile"); + QVariant v = subscriberKProEngActiveProfile->value("/KCRUidProfileEngine/KProEngActiveProfile"); // nothing to do } // some environment changed void Autolock::subscriberKAknKeyguardStatusChanged() { RDEBUG("Error only Autolock should be able to change it", 0); - } + } void Autolock::subscriberKCoreAppUIsAutolockStatusChanged() { RDEBUG("Error only Autolock should be able to change it", 0); - } + } void Autolock::subscriberKHWRMGripStatusChanged() { - TInt ret; + TInt ret = KErrNone; + Q_UNUSED(ret); RDEBUG("0", 0); TInt aGripStatus; - TInt err = RProperty::Get(KPSUidHWRM, KHWRMGripStatus, aGripStatus ); + TInt err = RProperty::Get(KPSUidHWRM, KHWRMGripStatus, aGripStatus); RDEBUG("err", err); RDEBUG("value", aGripStatus); - if( aGripStatus == EPSHWRMGripOpen ) - { - if (iLockStatus == EKeyguardActive) - { - iShowKeyguardNote = 1; // note on disable keyguard - ret = TryChangeStatus(ELockAppDisableKeyguard); - } - else if (iLockStatus == EDevicelockActive) - { - ret = TryChangeStatus(ELockAppDisableDevicelock); - } - } - else if( aGripStatus == EPSHWRMGripClosed ) - { - if (iLockStatus == ELockNotActive) - { - iShowKeyguardNote = 1; // note on enable keyguard - ret = TryChangeStatus(ELockAppEnableKeyguard); - } - } + if (aGripStatus == EPSHWRMGripOpen) + { + if (iLockStatus == EKeyguardActive) + { + iShowKeyguardNote = 0; // no note on disable keyguard + callerHasECapabilityWriteDeviceData = 1; + ret = TryChangeStatus(ELockAppDisableKeyguard); + } + else if (iLockStatus == EDevicelockActive) + { + callerHasECapabilityWriteDeviceData = 1; + ret = TryChangeStatus(ELockAppDisableDevicelock); + } + } + else if (aGripStatus == EPSHWRMGripClosed) + { + if (iLockStatus == ELockNotActive) + { + iShowKeyguardNote = 0; // no note on enable keyguard + callerHasECapabilityWriteDeviceData = 1; + ret = TryChangeStatus(ELockAppEnableKeyguard); + } + } + RDEBUG("ret", ret); + } +/**************/ +void Autolock::subscriberKCTsyCallStateChanged() + { + RDEBUG("0", 0); + TInt aCallStatus; + TInt err = RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, aCallStatus); + RDEBUG("err", err); + RDEBUG("aCallStatus", aCallStatus); + RWindowGroup& groupWin = CEikonEnv::Static()->RootWin(); + RDEBUG("iLockStatus", iLockStatus); + if (aCallStatus == EPSCTsyCallStateUninitialized || aCallStatus == EPSCTsyCallStateNone) + { + // Telephone might want to re-enable only-keyguard after the call ends. Allow it. This means re-showing the screensaver, not more. + RDEBUG("call is inactive", aCallStatus); + if(iLockStatus == EDevicelockActive) + setLockDialog(ELockAppEnableKeyguard, 1); + + if (iLockStatus == EKeyguardActive || iLockStatus == EDevicelockActive) + { + if (!mEKeyYesCaptureHandle) + mEKeyYesCaptureHandle = groupWin.CaptureKey(EKeyYes, 0, 0); + if (!mEKeyNoCaptureHandle) + mEKeyNoCaptureHandle = groupWin.CaptureKey(EKeyNo, 0, 0); + } + } + else + { + RDEBUG("call is active", aCallStatus); + + RDEBUG("allowing telephone to disable keyguard . Call setLockDialog 0", 0); + if(iLockStatus == EDevicelockActive) + setLockDialog(ELockAppDisableKeyguard, 0); + + // Telephone should be on top, but nevertheless we give End/Send to them + // This should be done only if locked, but it doesn't harm + if (mEKeyYesCaptureHandle) + { + RDEBUG("mEKeyYesCaptureHandle", mEKeyYesCaptureHandle); + groupWin.CancelCaptureKey(mEKeyYesCaptureHandle); + mEKeyYesCaptureHandle = NULL; + } + if (mEKeyNoCaptureHandle) + { + RDEBUG("mEKeyNoCaptureHandle", mEKeyNoCaptureHandle); + groupWin.CancelCaptureKey(mEKeyNoCaptureHandle); + mEKeyNoCaptureHandle = NULL; + } + // it seems that Telephone doesn't turn-on the lights when an incoming call on deviceLock. It's done here. + TurnLights(ESecurityUIsLightsQueryOnRequest, ELockAppDisableKeyguard, 0x28); + } + RDEBUG("99", 0x99); + } +// SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged() +// A way for Autolock to dismiss any possible PIN dialog +// ---------------------------------------------------------------------------- +// +void Autolock::subscriberKSecurityUIsDismissDialogChanged() + { + RDEBUG("0", 0); + TInt aDismissDialog = ESecurityUIsDismissDialogUninitialized; + TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog); + RDEBUG("err", err); + RDEBUG("aDismissDialog", aDismissDialog); } +void Autolock::subscriberKSecurityUIsTestCodeChanged() + { + RDEBUG("0", 0); + TInt aTestCode = -1; + TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsTestCode, aTestCode); + RDEBUG("err", err); + RDEBUG("aTestCode", aTestCode); + } // ----------AutolockService--------------- AutolockService::AutolockService(Autolock* parent) : - XQServiceProvider(QLatin1String( - "com.nokia.services.Autolock.Autolock"), parent), - mAutolock(parent), mAsyncReqId(-1), mAsyncAnswer(false) + XQServiceProvider(QLatin1String("com.nokia.services.Autolock.Autolock"), parent), mAutolock(parent), mAsyncReqId(-1), mAsyncAnswer(false) { RDEBUG("0", 0); publishAll(); - connect(this, SIGNAL(returnValueDelivered()), parent, SLOT( - handleAnswerDelivered())); + connect(this, SIGNAL(returnValueDelivered()), parent, SLOT(handleAnswerDelivered())); } AutolockService::~AutolockService() @@ -1340,8 +1945,7 @@ } // got API request from lockaccessextension -int AutolockService::service(const QString& number, - const QString& aParam1, const QString& aParam2) +int AutolockService::service(const QString& number, const QString& aParam1, const QString& aParam2) { RDEBUG("0", 0); TInt err = KErrNone; @@ -1375,22 +1979,32 @@ myTime.HomeTime(); TInt myTimeHigh = 0; TInt myTimeLow = 0; - err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeHigh, myTimeHigh ); + err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeHigh, myTimeHigh); RDEBUG("err", err); RDEBUG("myTimeHigh", myTimeHigh); - err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeLow, myTimeLow ); + err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeLow, myTimeLow); RDEBUG("err", err); RDEBUG("myTimeLow", myTimeLow); - + myTimeHigh = I64HIGH( myTime.Int64() ); myTimeLow = I64LOW( myTime.Int64() ); RDEBUG("myTimeHigh", myTimeHigh); RDEBUG("myTimeLow", myTimeLow); - err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeHigh, myTimeHigh ); - err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeLow, myTimeLow ); + err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeHigh, myTimeHigh); + err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeLow, myTimeLow); ret = mAutolock->TryChangeStatus(ret); RDEBUG("ret", ret); + + TInt myInitiatorUID = 0; + err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorUID, myInitiatorUID); + RDEBUG("ret", ret); + RDEBUG("myInitiatorUID", myInitiatorUID); + myInitiatorUID = info.clientSecureId(); + err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorUID, myInitiatorUID); + RDEBUG("ret", ret); + RDEBUG("myInitiatorUID", myInitiatorUID); + return ret; } @@ -1399,7 +2013,7 @@ RDEBUG("0", 0); // Just quit service application if client ends mAsyncAnswer = false; - RDEBUG("0", 0); + RDEBUG("99", 0x99); // mAutolock->quit(); } diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/Autolock/src/Autolock.h --- a/securitydialogs/Autolock/src/Autolock.h Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/Autolock/src/Autolock.h Thu Oct 14 13:56:11 2010 +0300 @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -65,8 +64,24 @@ EDevicelockTimer }; +enum TDeviceDialogCreated + { + EDeviceDialogUninitialized = -1, + EDeviceDialogDestroyed = 0, + EDeviceDialogCreated = 1, + EDeviceDialogRaised = 2, + EDeviceDialogScreenSaverHidden = 0x10, + EDeviceDialogScreenSaverReDisplay = 0x11, + EDeviceDialogScreenSaver = 0x12, + EDeviceDialogLockIcon= 0x20, + EDeviceDialogLastValue + }; + +class QTimer; class AutolockService; +// handled now directly but screensaver +// class CPowerSaveDisplayMode; class Autolock : public QWidget { @@ -84,11 +99,13 @@ void DebugStatus(int value); void adjustInactivityTimers(int aReason); int updateIndicator(int aReason); + int TurnLights(int aMode, int aReason, int aCaller); int AskValidSecCode(int aReason); int publishStatus(int aReason); int TryChangeStatus(int aReason); int setLockDialog(int aReason, int status); int showNoteIfRequested(int aReason); + int setDeviceDialogStatus(int aStatus); bool event(QEvent *event); bool eventFilter(QObject *, QEvent *); @@ -109,12 +126,21 @@ void subscriberKAknKeyguardStatusChanged(); void subscriberKCoreAppUIsAutolockStatusChanged(); void subscriberKHWRMGripStatusChanged(); + void subscriberKCTsyCallStateChanged(); + void subscriberKSecurityUIsDismissDialogChanged(); + void subscriberKSecurityUIsTestCodeChanged(); private slots: void activeKeyguard(); void notActiveKeyguard(); void activeDevicelock(); void notActiveDevicelock(); + void switchScreensaverMode( int mode ); + void switchScreensaverToPowerSaveMode(); + void handleMessageFromScreensaver( const QVariantMap &data ); + void handleScreensaverClosed(); +private: + int handleLockSwitch(); private: AutolockService* mService; @@ -128,6 +154,9 @@ QValueSpaceSubscriber *subscriberKAknKeyguardStatus; QValueSpaceSubscriber *subscriberKCoreAppUIsAutolockStatus; QValueSpaceSubscriber *subscriberKHWRMGripStatus; + QValueSpaceSubscriber *subscriberKCTsyCallState; + QValueSpaceSubscriber *subscriberKSecurityUIsDismissDialog; + QValueSpaceSubscriber *subscriberKSecurityUIsTestCode; AutolockUserActivityService* serviceKeyguard; AutolockUserActivityService* serviceDevicelock; @@ -135,9 +164,23 @@ int iLockStatus; int iLockStatusPrev; CSecQueryUi *iSecQueryUi; - int iSecQueryUiCreated; + int iSecQueryUiCreated; // not used HbDeviceDialog *iDeviceDialog; - int iDeviceDialogCreated; + int iDeviceDialogStatus; + TInt32 mPowerKeyCaptureHandle; + TInt32 mApplicationKeyCaptureHandle; + TInt32 mApplicationLongKeyCaptureHandle; + TInt32 mEKeyDeviceFCaptureHandle; + TInt32 mEKeyBellCaptureHandle; + TInt32 mEKeyYesCaptureHandle; + TInt32 mEKeyNoCaptureHandle; + TBool iLockCodeQueryInDisplay; + QTimer *mScreensaverModeTimer; + // these two are handled now directly by screensaver + // CPowerSaveDisplayMode *mScreensaverPowerSave; + // HBufC16 *mScreensaverPowerSavePixelBuffer; + TInt32 iProcessingEvent; + int iTempDisableOnlyKeyguardBecauseIncomingCall; }; class AutolockService : public XQServiceProvider diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/Autolock/src/main.cpp --- a/securitydialogs/Autolock/src/main.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/Autolock/src/main.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -24,25 +24,62 @@ #include #include "Autolock.h" +#include "../PubSub/securityuisprivatepskeys.h" #include #include +#include +#include int main(int argc, char **argv) { // qInstallMsgHandler(XQSERVICEMESSAGEHANDLER); // XQSERVICE_DEBUG_PRINT(" ================== xxxx Autolock::main"); qDebug() << "================== xxxx QApplication Autolock::main"; + + + // Need to check whether process is already running. This happens if it's started from Stater, and + // before fully initialized, it's started by API through QtHighway + TSecurityPolicy readPolicy(ECapabilityReadDeviceData); + TSecurityPolicy writePolicy(ECapabilityWriteDeviceData); + int ret = RProperty::Define(KPSUidSecurityUIs, + KSecurityUIsLockInitiatorUID, RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), + writePolicy); + qDebug() << "KSecurityUIsLockInitiatorUID ret=" << ret; + int myInitiatorUID = 0; + int err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorUID, myInitiatorUID); + qDebug() << "KSecurityUIsLockInitiatorUID err=" << err; + qDebug() << "KSecurityUIsLockInitiatorUID myInitiatorUID=" << myInitiatorUID; + err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorUID, 0); + + // it takes about 3 seconds to start it, on device QApplication a( argc, argv ); + // hide server from TaskSwitcher + CEikonEnv * env = CEikonEnv::Static(); + if(env) { + env->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront); + + CApaWindowGroupName *wgName = CApaWindowGroupName::NewLC(env->WsSession()); + wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc. + wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down + // wgName->SetCaptionL(KRunningAppServerName); + wgName->SetWindowGroupName(env->RootWin()); + CleanupStack::PopAndDestroy(wgName); + } + Autolock *cl = new Autolock(); - // qDebug() << " ================== xxxx cl->show"; + // qDebug() << " Autolock::main cl->show"; // cl->show(); - // qDebug() << " ================== xxxx cl->hide"; + // qDebug() << " Autolock::main cl->hide"; cl->hide(); - // qDebug() << " ================== xxxx cl->lower"; + // qDebug() << " Autolock::main cl->lower"; cl->lower(); + qDebug() << " Autolock::main cl->lower"; + err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorUID, 1); int rv = a.exec(); + qDebug() << " Autolock::main cl->exec"; delete cl; + qDebug() << " Autolock::main cl->delete"; return rv; } diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp --- a/securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -716,6 +716,17 @@ isConditionSatisfied = ETrue; } + // call TARM so that it verifies that configuration is in sync. This might internally accept the (default) lock code, but doesn't dismiss the query. + RDEBUG("isConditionSatisfied", isConditionSatisfied); + RSCPClient scpClientConfiguration; + User::LeaveIfError( scpClientConfiguration.Connect() ); + CleanupClosePushL( scpClientConfiguration ); + RDEBUG("call CheckConfiguration KSCPComplete", KSCPComplete); + TInt finalConfStatus = scpClientConfiguration.CheckConfiguration( KSCPComplete ); + RDEBUG("finalConfStatus", finalConfStatus); + RDEBUG("isConditionSatisfied", isConditionSatisfied); + CleanupStack::PopAndDestroy(); // scpClientConfiguration + // Security code at bootup: No "cancel" softkey; Emergency calls enabled. RMobilePhone::TMobilePhoneSecurityCode secCodeTypeToAsk = RMobilePhone::ESecurityCodePhonePassword; RDEBUG("isConditionSatisfied", isConditionSatisfied); diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp --- a/securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -538,6 +538,7 @@ * Series 60 Customer / ETel * Series 60 ETel API *****************************************************/ + askChangeSimSecurityL: RDEBUG("0", 0); RMobilePhone::TMobilePhoneLockInfoV1 lockInfo; RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo); @@ -577,6 +578,19 @@ } RDEBUG("lockChangeSetting", lockChangeSetting); + RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk); + CWait* newWait = NULL; + newWait = CWait::NewL(); + RDEBUG("newWait SetLockSetting", 0); + iPhone.SetLockSetting(newWait->iStatus, lockType, lockChangeSetting); // this invokes the handler + RDEBUG("newWait WaitForRequestL", + 0); + status = newWait->WaitForRequestL(); + RDEBUG("newWait WaitForRequestL status", + status); + delete newWait; + +/* iWait->SetRequestType(EMobilePhoneSetLockSetting); RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk); RDEBUG("SetLockSetting", 0); @@ -584,6 +598,7 @@ RDEBUG("WaitForRequestL", 0); status = iWait->WaitForRequestL(); RDEBUG("WaitForRequestL status", status); +*/ #ifdef __WINS__ if (status == KErrNotSupported || status == KErrTimedOut) status = KErrNone; @@ -598,17 +613,22 @@ break; } case KErrGsm0707IncorrectPassword: + { + // code was entered erroneously + RDEBUG("KErrGsm0707IncorrectPassword", KErrGsm0707IncorrectPassword); + goto askChangeSimSecurityL; + } case KErrAccessDenied: { // code was entered erroneously RDEBUG("KErrAccessDenied", KErrAccessDenied); - return ChangeSimSecurityL(); + goto askChangeSimSecurityL; } case KErrGsmSSPasswordAttemptsViolation: case KErrLocked: { RDEBUG("KErrLocked", KErrLocked); - return ChangeSimSecurityL(); + goto askChangeSimSecurityL; } case KErrAbort: { @@ -619,7 +639,7 @@ { RDEBUG("default", status); ShowErrorNoteL(status); - return ChangeSimSecurityL(); + goto askChangeSimSecurityL; } } @@ -2576,19 +2596,13 @@ RDEBUG("maxPeriod", maxPeriod); if (FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw)) { - TBool allow = ETrue; - if ((aPeriod == 0) && (maxPeriod > 0)) { RDEBUG("The period is not allowed by TARM", aPeriod); RDEBUG( "maxPeriod", maxPeriod ); - allow = EFalse; ShowResultNoteL(R_SECUI_TEXT_AUTOLOCK_MUST_BE_ACTIVE, CAknNoteDialog::EErrorTone); - } - if (!allow) - { - return ChangeAutoLockPeriodParamsL(aPeriod, aOldPassword, aFlags, aCaption, aShowError); // ask again - } + return R_SECUI_TEXT_AUTOLOCK_MUST_BE_ACTIVE; // don't ask again. Settings will roll-back + } } if (aPeriod == 0) diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/secuidialognotifier/inc/secuidialogstrace.h --- a/securitydialogs/secuidialognotifier/inc/secuidialogstrace.h Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/secuidialognotifier/inc/secuidialogstrace.h Thu Oct 14 13:56:11 2010 +0300 @@ -20,31 +20,11 @@ #include // RDebug - -// TODO: replace with OST tracing #ifdef _DEBUG -#define TRACE( a, ARGS... ) { RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); DebugPrint( _L( a ), ##ARGS ) ; }; + #define RDEBUG( x, y ) RDebug::Printf( "%s %s (%u) %s=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, x, y ); #else -#define TRACE( a, ARGS... ) + #define RDEBUG( x, y ) #endif - -// --------------------------------------------------------------------------- -// DebugPrint() -// --------------------------------------------------------------------------- -// -#ifdef _DEBUG -const TInt KMaxPrintSize = 256; -inline void DebugPrint( TRefByValue aFmt, ... ) - { - VA_LIST list; - VA_START( list, aFmt ); - TBuf buf; - buf.AppendFormatList( aFmt, list ); - RDebug::Print( buf ); - } -#endif - - #endif // SECUIDIALOGSTRACE_H diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/secuidialognotifier/src/secuidialognotifier.cpp --- a/securitydialogs/secuidialognotifier/src/secuidialognotifier.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/secuidialognotifier/src/secuidialognotifier.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -28,7 +28,7 @@ // CSecuiDialogNotifier::~CSecuiDialogNotifier() { - TRACE( "CSecuiDialogNotifier::~CSecuiDialogNotifier" ); + RDEBUG("0", 0); Cancel(); } @@ -38,7 +38,7 @@ // CSecuiDialogNotifier* CSecuiDialogNotifier::NewL() { - TRACE( "CSecuiDialogNotifier::NewL, 1 =%d", 1 ); + RDEBUG("0", 0); CSecuiDialogNotifier* self = new( ELeave ) CSecuiDialogNotifier; CleanupStack::PushL( self ); self->ConstructL(); @@ -52,7 +52,7 @@ // void CSecuiDialogNotifier::Release() { - TRACE( "CSecuiDialogNotifier::Release" ); + RDEBUG("0", 0); delete this; } @@ -62,7 +62,7 @@ // CSecuiDialogNotifier::TNotifierInfo CSecuiDialogNotifier::RegisterL() { - TRACE( "CSecuiDialogNotifier::RegisterL, 1 =%d", 1 ); + RDEBUG("0", 0); return Info(); } @@ -72,7 +72,7 @@ // CSecuiDialogNotifier::TNotifierInfo CSecuiDialogNotifier::Info() const { - TRACE( "CSecuiDialogNotifier::Info, 1 =%d", 1 ); + RDEBUG("0", 0); TNotifierInfo info; static const TUid KUidSecuiDialogNotifier = { 0x10005988 }; @@ -90,26 +90,26 @@ void CSecuiDialogNotifier::StartL( const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage ) { - TRACE( "CSecuiDialogNotifier::StartL, begin" ); + RDEBUG("0", 0); TRAPD( err, DoStartL( aBuffer, aReplySlot, aMessage ) ); - TRACE( "CSecuiDialogNotifier::StartL, DoStartL err=%d", err ); + RDEBUG("err", err); if( err ) { if( iSecuiDialogs && !iIsSecuiDialogsDeleted ) { - TRACE( "CSecuiDialogNotifier::StartL, deleting iSecuiDialogs" ); + RDEBUG("0", 0); delete iSecuiDialogs; iSecuiDialogs = NULL; } if( !aMessage.IsNull() ) { - TRACE( "CSecuiDialogNotifier::StartL, completing message" ); + RDEBUG("0", 0); aMessage.Complete( err ); } } - TRACE( "CSecuiDialogNotifier::StartL, end" ); + RDEBUG("0x99", 0x99); } // --------------------------------------------------------------------------- @@ -127,10 +127,10 @@ // void CSecuiDialogNotifier::Cancel() { - TRACE( "CSecuiDialogNotifier::Cancel" ); + RDEBUG("0", 0); if( iSecuiDialogs && !iIsSecuiDialogsDeleted ) { - TRACE( "CSecuiDialogNotifier::Cancel, deleting iSecuiDialogs" ); + RDEBUG("0", 0); delete iSecuiDialogs; iSecuiDialogs = NULL; } @@ -151,7 +151,7 @@ // CSecuiDialogNotifier::CSecuiDialogNotifier() { - TRACE( "CSecuiDialogNotifier::CSecuiDialogNotifier" ); + RDEBUG("0", 0); } // --------------------------------------------------------------------------- @@ -169,7 +169,7 @@ void CSecuiDialogNotifier::DoStartL( const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage ) { - TRACE( "CSecuiDialogNotifier::DoStartL, 1 =%d", 1 ); + RDEBUG("0", 0); iSecuiDialogs = CSecuiDialogs::NewL( iIsSecuiDialogsDeleted ); iSecuiDialogs->StartLD( aBuffer, aReplySlot, aMessage ); diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/secuidialognotifier/src/secuidialognotifiersrv.cpp --- a/securitydialogs/secuidialognotifier/src/secuidialognotifiersrv.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/secuidialognotifier/src/secuidialognotifiersrv.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -44,13 +44,13 @@ // TInt RSecuiDialogNotifierSrv::Connect() { - TRACE( "RSecuiDialogNotifierSrv::Connect" ); + RDEBUG("0", 0); const TInt KMaxCreateSessionAttepmts = 2; TInt retry = KMaxCreateSessionAttepmts; FOREVER { TInt err = CreateSession( KSecuiDialogNotifierServerName, Version() ); - TRACE( "RSecuiDialogNotifierSrv::Connect, create session err=%d", err ); + RDEBUG("err", err); if( err != KErrNotFound && err != KErrServerTerminated ) { return err; @@ -89,7 +89,7 @@ const TDesC8& aInputBuffer, TDes8& aOutputBuffer, TRequestStatus& aStatus ) { - TRACE( "RSecuiDialogNotifierSrv::SecuiDialogOperation" ); + RDEBUG("0", 0); iArgs = TIpcArgs( &aInputBuffer, &aOutputBuffer ); SendReceive( aOperation, iArgs, aStatus ); } @@ -100,7 +100,7 @@ // void RSecuiDialogNotifierSrv::CancelOperation() { - TRACE( "RSecuiDialogNotifierSrv::CancelOperation" ); + RDEBUG("0", 0); SendReceive( KSecuiDialogCancelOperation ); } @@ -110,12 +110,12 @@ // TInt RSecuiDialogNotifierSrv::StartServer() { - TRACE( "RSecuiDialogNotifierSrv::StartServer, begin" ); + RDEBUG("0", 0); RProcess server; TInt err = server.Create( KSecuiDialogNotifierServerName, KNullDesC ); if( err ) { - TRACE( "RSecuiDialogNotifierSrv::StartServer, create failed, err=%d", err ); + RDEBUG("err", err); return err; } @@ -130,7 +130,7 @@ server.Kill( KErrNone ); } - TRACE( "RSecuiDialogNotifierSrv::StartServer, waiting rendezvous" ); + RDEBUG("WaitForRequest", 0); User::WaitForRequest( status ); if( server.ExitType() == EExitPanic ) { @@ -142,7 +142,7 @@ } server.Close(); - TRACE( "RSecuiDialogNotifierSrv::StartServer, end err=%d", err ); + RDEBUG("err", err); return err; } diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/secuidialognotifier/src/secuidialogs.cpp --- a/securitydialogs/secuidialognotifier/src/secuidialogs.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/secuidialognotifier/src/secuidialogs.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -37,7 +37,7 @@ // CSecuiDialogs::~CSecuiDialogs() { - TRACE( "CSecuiDialogs::~CSecuiDialogs, begin" ); + RDEBUG("0", 0); Cancel(); iServer.Close(); delete iInputBuffer; @@ -45,7 +45,7 @@ delete iOutputBuffer; iOutputBuffer = NULL; iIsDeleted = ETrue; - TRACE( "CSecuiDialogs::~CSecuiDialogs, end" ); + RDEBUG("0x99", 0x99); } // --------------------------------------------------------------------------- @@ -55,32 +55,32 @@ void CSecuiDialogs::StartLD( const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage ) { - TRACE( "CSecuiDialogs::StartLD, begin" ); + RDEBUG("0", 0); User::LeaveIfError( iServer.Connect() ); const TInt* ptr = reinterpret_cast< const TInt* >( aBuffer.Ptr() ); iOperation = static_cast< TSecurityDialogOperation >( *ptr & KSecurityDialogOperationMask ); iReplySlot = aReplySlot; - TRACE( "CSecuiDialogs::StartLD, iReplySlot 0x%08x", iReplySlot ); + RDEBUG("iReplySlot", iReplySlot); - TRACE( "CSecuiDialogs::StartLD, message 0x%08x", iMessagePtr.Handle() ); + RDEBUG("iMessagePtr.Handle()", iMessagePtr.Handle()); iMessagePtr = aMessage; - TRACE( "CSecuiDialogs::StartLD, iOperation=%d", iOperation ); + RDEBUG("iOperation", iOperation); TSecurityNotificationPckg pckg; pckg.Copy( aBuffer ); - TRACE( "CSecuiDialogs::StartLD, Copy=%d", 1 ); + RDEBUG("0", 0); TInt iStartup = pckg().iStartup; - TRACE( "CSecuiDialogs::StartLD, iStartup=%d", iStartup ); + RDEBUG("iStartup", iStartup); TInt iEvent = pckg().iEvent; - TRACE( "CSecuiDialogs::StartLD, iEvent=%d", iEvent ); + RDEBUG("iEvent", iEvent); TInt lOperation = 0x0000; if(iStartup) lOperation = 0x1000; lOperation += iEvent; iOperation = static_cast< TSecurityDialogOperation >( lOperation ); - TRACE( "CSecuiDialogs::StartLD, new iOperation=%d", iOperation ); + RDEBUG("new iOperation", iOperation); __ASSERT_DEBUG( iOutputBuffer == NULL, User::Invariant() ); TInt outputBufLen = 0; @@ -91,7 +91,7 @@ } else { - TRACE( "CSecuiDialogs::StartLD, not allowed iOperation =%d", iOperation ); + RDEBUG("not allowed iOperation", iOperation); User::Leave( KErrNotSupported ); } @@ -100,17 +100,17 @@ if( iOutputBuffer ) { - TRACE( "CSecuiDialogs::StartLD, iOutputPtr.Set outputBufLen=%d", outputBufLen ); + RDEBUG("outputBufLen", outputBufLen); iOutputPtr.Set( static_cast< TUint8* >( iOutputBuffer ), outputBufLen, outputBufLen ); iServer.SecuiDialogOperation( iOperation, *iInputBuffer, iOutputPtr, iStatus ); } else { - TRACE( "CSecuiDialogs::StartLD, Leave KErrNotSupported=%d", KErrNotSupported ); + RDEBUG("KErrNotSupported", KErrNotSupported); User::Leave( KErrNotSupported ); } SetActive(); - TRACE( "CSecuiDialogs::StartLD, end" ); + RDEBUG("0x99", 0x99); } // --------------------------------------------------------------------------- @@ -119,26 +119,26 @@ // void CSecuiDialogs::RunL() { - TRACE( "CSecuiDialogs::RunL, iStatus.Int()=%d", iStatus.Int() ); + RDEBUG("0", 0); TInt error = iStatus.Int(); + RDEBUG("error", error); User::LeaveIfError( error ); __ASSERT_DEBUG( iOutputPtr.Ptr(), User::Invariant() ); - TRACE( "CSecuiDialogs::RunL, calling iMessagePtr.WriteL" ); - TRACE( "CSecuiDialogs::RunL, iReplySlot 0x%08x", iReplySlot ); + RDEBUG("iReplySlot", iReplySlot); TInt maxx = iMessagePtr.GetDesMaxLength(iReplySlot); - TRACE( "CSecuiDialogs::RunL, maxx 0x%08x", maxx ); + RDEBUG("maxx", maxx); TInt curr = iMessagePtr.GetDesLength(iReplySlot); - TRACE( "CSecuiDialogs::RunL, curr 2 0x%08x", curr ); + RDEBUG("curr", curr); // no need to copy. Besides, it seems to crash because it's too long // iMessagePtr.WriteL( iReplySlot, iOutputPtr ); - TRACE( "CSecuiDialogs::RunL, called iMessagePtr.WriteL" ); + RDEBUG("not called WriteL", 0); - TRACE( "CSecuiDialogs::RunL, completing message 0x%08x", iMessagePtr.Handle() ); + RDEBUG("completing iMessagePtr.Handle()", iMessagePtr.Handle()); iMessagePtr.Complete( error ); - TRACE( "CSecuiDialogs::RunL, deleting this" ); + RDEBUG("0", 0); delete this; - TRACE( "CSecuiDialogs::RunL, end" ); + RDEBUG("0x99", 0x99); } // --------------------------------------------------------------------------- @@ -147,14 +147,14 @@ // void CSecuiDialogs::DoCancel() { - TRACE( "CSecuiDialogs::DoCancel, begin" ); + RDEBUG("0", 0); iServer.CancelOperation(); if( !iMessagePtr.IsNull() ) { - TRACE( "CSecuiDialogs::DoCancel, completing message 0x%08x", iMessagePtr.Handle() ); + RDEBUG("completing iMessagePtr.Handle()", iMessagePtr.Handle()); iMessagePtr.Complete( KErrCancel ); } - TRACE( "CSecuiDialogs::DoCancel(), end" ); + RDEBUG("0x99", 0x99); } // --------------------------------------------------------------------------- @@ -163,17 +163,17 @@ // TInt CSecuiDialogs::RunError( TInt aError ) { - TRACE( "CSecuiDialogs::RunError, aError=%d", aError ); + RDEBUG("aError", aError); if( !iMessagePtr.IsNull() ) { - TRACE( "CSecuiDialogs::RunError, completing message 0x%08x", iMessagePtr.Handle() ); + RDEBUG("completing iMessagePtr.Handle()", iMessagePtr.Handle()); iMessagePtr.Complete( aError ); } - TRACE( "CSecuiDialogs::RunError, deleting this" ); + RDEBUG("0", 0); delete this; - TRACE( "CSecuiDialogs::RunError, end" ); + RDEBUG("0x99", 0x99); return KErrNone; } @@ -184,7 +184,7 @@ CSecuiDialogs::CSecuiDialogs( TBool& aIsDeleted ) : CActive( CActive::EPriorityLow ), iIsDeleted( aIsDeleted ), iOutputPtr( NULL, 0, 0 ) { - TRACE( "CSecuiDialogs::CSecuiDialogs" ); + RDEBUG("0", 0); CActiveScheduler::Add( this ); iIsDeleted = EFalse; } diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/secuidialognotifiersrv/group/secuidialognotifiersrv.mmp --- a/securitydialogs/secuidialognotifiersrv/group/secuidialognotifiersrv.mmp Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/secuidialognotifiersrv/group/secuidialognotifiersrv.mmp Thu Oct 14 13:56:11 2010 +0300 @@ -31,20 +31,10 @@ SOURCE secuidialognotifierserver.cpp SOURCE secuidialognotifiersession.cpp SOURCE secuidialogoperation.cpp -// SOURCE secuidialogoperserverauthfail.cpp SOURCE secuidialogoperbasicpinquery.cpp -SOURCE untrustedcertquery.cpp LIBRARY euser.lib // Base classes LIBRARY efsrv.lib // RFs -LIBRARY ctframework.lib // CServerAuthenticationFailureInput -LIBRARY x509.lib // CX509Certificate -LIBRARY x500.lib // CX500DistinguishedName -LIBRARY crypto.lib // CSignedObject -LIBRARY certstore.lib // CUnifiedCertStore -LIBRARY DevTokenClient.lib // CTrustSitesStore -LIBRARY HbCore.lib // CHbDeviceDialogSymbian -LIBRARY HbWidgets.lib // CHbDeviceMessageBoxSymbian LIBRARY secui.lib // CSecQueryUi LIBRARY etelmm.lib LIBRARY etel.lib diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/secuidialognotifiersrv/inc/secuidialogstrace.h --- a/securitydialogs/secuidialognotifiersrv/inc/secuidialogstrace.h Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/secuidialognotifiersrv/inc/secuidialogstrace.h Thu Oct 14 13:56:11 2010 +0300 @@ -20,31 +20,11 @@ #include // RDebug - -// TODO: replace with OST tracing #ifdef _DEBUG -#define TRACE( a, ARGS... ) { RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); DebugPrint( _L( a ), ##ARGS ) ; }; + #define RDEBUG( x, y ) RDebug::Printf( "%s %s (%u) %s=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, x, y ); #else -#define TRACE( a, ARGS... ) + #define RDEBUG( x, y ) #endif - -// --------------------------------------------------------------------------- -// DebugPrint() -// --------------------------------------------------------------------------- -// -#ifdef _DEBUG -const TInt KMaxPrintSize = 256; -inline void DebugPrint( TRefByValue aFmt, ... ) - { - VA_LIST list; - VA_START( list, aFmt ); - TBuf buf; - buf.AppendFormatList( aFmt, list ); - RDebug::Print( buf ); - } -#endif - - #endif // SECUIDIALOGSTRACE_H diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/secuidialognotifiersrv/inc/untrustedcertquery.h --- a/securitydialogs/secuidialognotifiersrv/inc/untrustedcertquery.h Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Displays untrusted certificate dialog -* -*/ - -#ifndef C_UNTRUSTEDCERTQUERY_H -#define C_UNTRUSTEDCERTQUERY_H - -#include // CActive -#include // MHbDeviceDialogObserver -#include // TValidationError - -class CHbDeviceDialogSymbian; -class CHbSymbianVariantMap; - - -/** -* Displays untrusted certificate query. -* Untrusted certificate query dialog is displayed for secure connection -* (SSL/TLS) server authentication failure errors. CCTUntrustedCertQuery -* class uses UntrustedCertificateDialog device dialog to show the query. -*/ -NONSHARABLE_CLASS( CUntrustedCertQuery ) : public CActive, public MHbDeviceDialogObserver - { - public: // constructors and destructor - static CUntrustedCertQuery* NewL( TValidationError aValidationError, - const TDesC8& aCertificate, const TDesC& aServerName, - TBool aCanHandlePermanentAccept ); - ~CUntrustedCertQuery(); - - public: // new functions - enum TResponse { - EQueryRejected, - EQueryAccepted, - EQueryAcceptedPermanently - }; - void ShowQueryAndWaitForResponseL( TResponse& aResponse ); - - protected: // from CActive - void DoCancel(); - void RunL(); - - private: // from MHbDeviceDialogObserver - void DataReceived( CHbSymbianVariantMap& aData ); - void DeviceDialogClosed( TInt aCompletionCode ); - - private: // new functions - CUntrustedCertQuery( TValidationError aValidationError, - const TDesC8& aCertificate, const TDesC& aServerName, - TBool aCanHandlePermanentAccept ); - void ConstructL(); - - private: // data - TValidationError iValidationError; - const TDesC8& iCertificate; - const TDesC& iServerName; - TBool iCanHandlePermanentAccept; - CActiveSchedulerWait *iWait; - TInt iWaitCompletionCode; - CHbDeviceDialogSymbian* iDeviceDialog; - CHbSymbianVariantMap* iVariantMap; - TResponse iResponse; - }; - -#endif // C_UNTRUSTEDCERTQUERY_H - diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/secuidialognotifiersrv/src/secuidialognotifierserver.cpp --- a/securitydialogs/secuidialognotifiersrv/src/secuidialognotifierserver.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/secuidialognotifiersrv/src/secuidialognotifierserver.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -69,7 +69,7 @@ // CSecuiDialogNotifierServer::~CSecuiDialogNotifierServer() { - TRACE( "CSecuiDialogNotifierServer::~CSecuiDialogNotifierServer" ); + RDEBUG("0", 0); } // --------------------------------------------------------------------------- @@ -78,7 +78,7 @@ // void CSecuiDialogNotifierServer::AddSession() { - TRACE( "CSecuiDialogNotifierServer::AddSession" ); + RDEBUG("iSessionCount", iSessionCount); ++iSessionCount; } @@ -88,11 +88,11 @@ // void CSecuiDialogNotifierServer::RemoveSession() { - TRACE( "CSecuiDialogNotifierServer::RemoveSession" ); + RDEBUG("iSessionCount", iSessionCount); --iSessionCount; if( iSessionCount == 0 ) { - TRACE( "CSecuiDialogNotifierServer::RemoveSession, shutting down" ); + RDEBUG("CActiveScheduler::Stop 0", 0); CActiveScheduler::Stop(); } } @@ -104,13 +104,13 @@ CSession2* CSecuiDialogNotifierServer::NewSessionL( const TVersion &aVersion, const RMessage2& /*aMessage*/ ) const { - TRACE( "CSecuiDialogNotifierServer::NewSessionL" ); + RDEBUG("0", 0); TVersion version( KSecuiDialogNotifierServerMajorVersionNumber, KSecuiDialogNotifierServerMinorVersionNumber, KSecuiDialogNotifierServerBuildVersionNumber ); if( !User::QueryVersionSupported( version, aVersion ) ) { - TRACE( "CSecuiDialogNotifierServer::NewSessionL, version not supported" ); + RDEBUG("KErrNotSupported", KErrNotSupported); User::Leave( KErrNotSupported ); } @@ -124,7 +124,7 @@ CSecuiDialogNotifierServer::CSecuiDialogNotifierServer() : CPolicyServer( CActive::EPriorityStandard, KSecuiDialogNotifierServerPolicy ) { - TRACE( "CSecuiDialogNotifierServer::CSecuiDialogNotifierServer" ); + RDEBUG("0", 0); } // --------------------------------------------------------------------------- diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/secuidialognotifiersrv/src/secuidialognotifierservermain.cpp --- a/securitydialogs/secuidialognotifiersrv/src/secuidialognotifierservermain.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/secuidialognotifiersrv/src/secuidialognotifierservermain.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -26,22 +26,23 @@ // LOCAL_C void MainL() { - TRACE( "SecuiDialogNotifierServer: MainL" ); + RDEBUG("0", 0); CActiveScheduler* scheduler = new( ELeave ) CActiveScheduler; CleanupStack::PushL( scheduler ); CActiveScheduler::Install( scheduler ); CSecuiDialogNotifierServer* server = CSecuiDialogNotifierServer::NewLC(); User::LeaveIfError( User::RenameThread( KSecuiDialogNotifierServerName ) ); - TRACE( "SecuiDialogNotifierServer: MainL, rendezvous" ); + RDEBUG("Rendezvous 0", 0); RProcess::Rendezvous( KErrNone ); - TRACE( "SecuiDialogNotifierServer: MainL, activescheduler start" ); + RDEBUG("CActiveScheduler 0", 0); CActiveScheduler::Start(); - TRACE( "SecuiDialogNotifierServer: MainL, cleanup" ); + RDEBUG("PopAndDestroy 0", 0); CleanupStack::PopAndDestroy( server ); CleanupStack::PopAndDestroy( scheduler ); + RDEBUG("0x99", 0x99); } // --------------------------------------------------------------------------- diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/secuidialognotifiersrv/src/secuidialognotifiersession.cpp --- a/securitydialogs/secuidialognotifiersrv/src/secuidialognotifiersession.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/secuidialognotifiersrv/src/secuidialognotifiersession.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -18,10 +18,8 @@ #include "secuidialognotifiersession.h" // CSecuiDialogNotifierSession #include "secuidialognotifierserver.h" // CSecuiDialogNotifierServer #include "secuidialognotifierservername.h" // KSecuiDialogsCancelOperation -// #include "secuidialogoperserverauthfail.h" // CServerAuthFailOperation #include "secuidialogoperbasicpinquery.h" // CBasicPinQueryOperation #include "secuidialogstrace.h" // TRACE macro -#include // TSecurityDialogOperation #include const TInt KInputParam = 0; @@ -36,7 +34,7 @@ // CSecuiDialogNotifierSession* CSecuiDialogNotifierSession::NewL() { - TRACE( "CBasicPinQueryOperation::RunL, 1 =%d", 1 ); + RDEBUG("0", 0); CSecuiDialogNotifierSession* self = new( ELeave ) CSecuiDialogNotifierSession; CleanupStack::PushL( self ); self->ConstructL(); @@ -50,13 +48,13 @@ // CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession() { - TRACE( "CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession, begin" ); + RDEBUG("0", 0); Server().RemoveSession(); delete iOperationHandler; iOperationHandler = NULL; delete iInputBuffer; iInputBuffer = NULL; - TRACE( "CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession, end" ); + RDEBUG("0x99", 0x99); } // --------------------------------------------------------------------------- @@ -65,7 +63,7 @@ // void CSecuiDialogNotifierSession::CreateL() { - TRACE( "CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession" ); + RDEBUG("0", 0); Server().AddSession(); } @@ -75,13 +73,12 @@ // void CSecuiDialogNotifierSession::ServiceL( const RMessage2& aMessage ) { - TRACE( "CSecuiDialogNotifierSession::ServiceL, message 0x%08x", aMessage.Handle() ); + RDEBUG("aMessage.Handle()", aMessage.Handle()); TRAPD( error, DispatchMessageL( aMessage ) ); - TRACE( "CSecuiDialogNotifierSession::ServiceL, dispatched, error %d", error ); + RDEBUG("error", error); if( error && !aMessage.IsNull() ) { - TRACE( "CSecuiDialogNotifierSession::ServiceL, completing msg 0x%08x", - aMessage.Handle() ); + RDEBUG("Complete aMessage.Handle()", aMessage.Handle()); aMessage.Complete( error ); } } @@ -92,10 +89,10 @@ // void CSecuiDialogNotifierSession::OperationComplete() { - TRACE( "CSecuiDialogNotifierSession::OperationComplete, begin" ); + RDEBUG("0", 0); delete iOperationHandler; iOperationHandler = NULL; - TRACE( "CSecuiDialogNotifierSession::OperationComplete, end" ); + RDEBUG("0x99", 0x99); } // --------------------------------------------------------------------------- @@ -104,7 +101,7 @@ // CSecuiDialogNotifierSession::CSecuiDialogNotifierSession() { - TRACE( "CSecuiDialogNotifierSession::CSecuiDialogNotifierSession" ); + RDEBUG("0", 0); } // --------------------------------------------------------------------------- @@ -113,7 +110,7 @@ // void CSecuiDialogNotifierSession::ConstructL() { - TRACE( "CSecuiDialogNotifierSession::ConstructL" ); + RDEBUG("0", 0); } // --------------------------------------------------------------------------- @@ -132,42 +129,39 @@ // void CSecuiDialogNotifierSession::DispatchMessageL( const RMessage2& aMessage ) { - TRACE( "CSecuiDialogNotifierSession::DispatchMessageL, begin" ); + RDEBUG("0", 0); if( !IsOperationCancelled( aMessage ) ) { TInt lOperation = aMessage.Function(); - TSecurityDialogOperation operation = - static_cast< TSecurityDialogOperation >( lOperation ); - TRACE( "CSecuiDialogNotifierSession::DispatchMessageL, operation=%d", operation ); // from AskSecCodeInAutoLockL if(lOperation==0x100+6 /*RMobilePhone::EPhonePasswordRequired*/) { - TRACE( "CSecuiDialogNotifierSession::DispatchMessageL, query from AskSecCodeInAutoLockL . No need to start Autolock.exe =%d", 0 ); + RDEBUG("query from AskSecCodeInAutoLockL . No need to start Autolock.exe", 0); } else { CKeyguardAccessApi* iKeyguardAccess = CKeyguardAccessApi::NewL( ); - TRACE( "CBasicPinQueryOperation::RunL, 1 =%d", 1 ); + RDEBUG("0", 0); TInt err = iKeyguardAccess->ShowKeysLockedNote( ); - TRACE( "CBasicPinQueryOperation::RunL, err =%d", err ); + RDEBUG("err", err); delete iKeyguardAccess; } - TRACE( "CBasicPinQueryOperation::RunL, lOperation =%d", lOperation ); + RDEBUG("lOperation", lOperation); if( lOperation >= 0x1000 ) // flag for iStartup lOperation -= 0x1000; - TRACE( "CBasicPinQueryOperation::RunL, new lOperation =%d", lOperation ); + RDEBUG("new lOperation", lOperation); if( lOperation < 0x200 ) { BasicPinOperationL( aMessage ); } else { - TRACE( "CBasicPinQueryOperation::RunL, lOperation =%d", lOperation ); + RDEBUG("KErrNotSupported", KErrNotSupported); User::Leave( KErrNotSupported ); } } - TRACE( "CSecuiDialogNotifierSession::DispatchMessageL, end" ); + RDEBUG("0x99", 0x99); } // --------------------------------------------------------------------------- @@ -181,11 +175,10 @@ { if( iOperationHandler ) { - TRACE( "CSecuiDialogNotifierSession::CheckIfOperationCancelledL, cancelling" ); + RDEBUG("0", 0); iOperationHandler->CancelOperation(); } - TRACE( "CSecuiDialogNotifierSession::CheckIfOperationCancelledL, completing msg 0x%08x", - aMessage.Handle() ); + RDEBUG("completing aMessage.Handle()", aMessage.Handle()); aMessage.Complete( KErrNone ); isCancelled = ETrue; } @@ -199,7 +192,7 @@ void CSecuiDialogNotifierSession::GetInputBufferL( const RMessage2& aMessage ) { TInt inputLength = aMessage.GetDesLength( KInputParam ); - TRACE( "CSecuiDialogNotifierSession::GetInputBufferL, inputLength=%d", inputLength ); + RDEBUG("inputLength", inputLength); __ASSERT_ALWAYS( inputLength > 0, User::Leave( KErrCorrupt ) ); if( iInputBuffer ) { @@ -209,23 +202,16 @@ iInputBuffer = HBufC8::NewL( inputLength ); TPtr8 inputBufferPtr( iInputBuffer->Des() ); aMessage.ReadL( KInputParam, inputBufferPtr ); - TRACE( "CSecuiDialogNotifierSession::GetInputBufferL, read complete" ); + RDEBUG("0x99", 0x99); } // --------------------------------------------------------------------------- // CSecuiDialogNotifierSession::ServerAuthenticationFailureL() // --------------------------------------------------------------------------- // -void CSecuiDialogNotifierSession::ServerAuthenticationFailureL( const RMessage2& aMessage ) +void CSecuiDialogNotifierSession::ServerAuthenticationFailureL( const RMessage2& /* aMessage */ ) { - TRACE( "CSecuiDialogNotifierSession::ServerAuthenticationFailureL, begin" ); - GetInputBufferL( aMessage ); - - ASSERT( iOperationHandler == NULL ); - // iOperationHandler = CServerAuthFailOperation::NewL( *this, aMessage, KOutputParam ); - // iOperationHandler->StartL( *iInputBuffer ); - - TRACE( "CSecuiDialogNotifierSession::ServerAuthenticationFailureL, end" ); + RDEBUG("not used 0x99", 0x99); } // --------------------------------------------------------------------------- @@ -234,13 +220,13 @@ // void CSecuiDialogNotifierSession::BasicPinOperationL( const RMessage2& aMessage ) { - TRACE( "CSecuiDialogNotifierSession::BasicPinOperationL, begin" ); + RDEBUG("0", 0); GetInputBufferL( aMessage ); ASSERT( iOperationHandler == NULL ); iOperationHandler = CBasicPinQueryOperation::NewL( *this, aMessage, KOutputParam ); iOperationHandler->StartL( *iInputBuffer ); - TRACE( "CSecuiDialogNotifierSession::BasicPinOperationL, end" ); + RDEBUG("0x99", 0x99); } diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/secuidialognotifiersrv/src/secuidialogoperation.cpp --- a/securitydialogs/secuidialognotifiersrv/src/secuidialogoperation.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/secuidialognotifiersrv/src/secuidialogoperation.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -32,8 +32,7 @@ TInt aReplySlot ) : CActive( CActive::EPriorityStandard ), iObserver( aObserver ), iMessage( aMessage ), iReplySlot( aReplySlot ) { - TRACE( "CSecuiDialogOperation::CSecuiDialogOperation, iMessage 0x%08x", - iMessage.Handle() ); + RDEBUG("aMessage.Handle()", aMessage.Handle()); CActiveScheduler::Add( this ); } @@ -43,9 +42,9 @@ // CSecuiDialogOperation::~CSecuiDialogOperation() { - TRACE( "CSecuiDialogOperation::~CSecuiDialogOperation, begin" ); + RDEBUG("0", 0); Cancel(); - TRACE( "CSecuiDialogOperation::~CSecuiDialogOperation, end" ); + RDEBUG("0x99", 0x99); } // --------------------------------------------------------------------------- @@ -54,13 +53,13 @@ // TInt CSecuiDialogOperation::RunError( TInt aError ) { - TRACE( "CSecuiDialogOperation::RunError, aError=%d", aError ); + RDEBUG("aError", aError); if( !iMessage.IsNull() ) { - TRACE( "CSecuiDialogOperation::RunError, completing message 0x%08x", - iMessage.Handle() ); + RDEBUG("completing message iMessage.Handle()", iMessage.Handle()); iMessage.Complete( aError ); } + RDEBUG("0x99", 0x99); return KErrNone; } @@ -68,13 +67,8 @@ // CSecuiDialogOperation::ShowWarningNoteL() // --------------------------------------------------------------------------- // -void CSecuiDialogOperation::ShowWarningNoteL( const TDesC& aMessage ) +void CSecuiDialogOperation::ShowWarningNoteL( const TDesC& /* aMessage */ ) { - CHbDeviceMessageBoxSymbian *note = - CHbDeviceMessageBoxSymbian::NewL( CHbDeviceMessageBoxSymbian::EWarning ); - CleanupStack::PushL( note ); - note->SetTextL( aMessage ); - (void)note->ExecL(); // waits for response or timeout - CleanupStack::PopAndDestroy( note ); + RDEBUG("not used 0", 0); } diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/secuidialognotifiersrv/src/secuidialogoperbasicpinquery.cpp --- a/securitydialogs/secuidialognotifiersrv/src/secuidialogoperbasicpinquery.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/securitydialogs/secuidialognotifiersrv/src/secuidialogoperbasicpinquery.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -1,28 +1,26 @@ /* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Basic PIN query operation in secui dialog -* -*/ + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Basic PIN query operation in secui dialog + * + */ #include "secuidialogoperbasicpinquery.h" // CBasicPinQueryOperation #include "secuidialogoperationobserver.h" // MSecuiDialogOperationObserver #include // HbTextResolverSymbian #include "secuidialogstrace.h" // TRACE macro - // TODO: fix this #include "../../../securitydialogs/SecUi/Inc/SecQueryUi.h" // CSecQueryUi - #include #include #include @@ -31,21 +29,11 @@ #include #include -const TInt KPhoneIndex( 0 ); -const TInt KTriesToConnectServer( 2 ); -const TInt KTimeBeforeRetryingServerConnection( 50000 ); - -_LIT( KMmTsyModuleName, "PhoneTsy"); +const TInt KPhoneIndex(0); +const TInt KTriesToConnectServer(2); +const TInt KTimeBeforeRetryingServerConnection(50000); -// Descriptors for different password queries -_LIT( KBasicPinQueryKeyStorePassphrase, "Key store passphrase" ); -_LIT( KBasicPinQueryNewKeyStorePassphrase, "New key store passphrase" ); -_LIT( KBasicPinQueryImportedKeyFilePassphrase, "Passphrase of the imported key file" ); -_LIT( KBasicPinQueryExportedKeyFilePassphrase, "Passphrase of the exported key file" ); -_LIT( KBasicPinQueryPKCS12, "PKCS12"); - - - +_LIT( KMmTsyModuleName, "PhoneTsy"); // ======== MEMBER FUNCTIONS ======== @@ -53,13 +41,11 @@ // CBasicPinQueryOperation::NewL() // --------------------------------------------------------------------------- // -CBasicPinQueryOperation* CBasicPinQueryOperation::NewL( - MSecuiDialogOperationObserver& aObserver, const RMessage2& aMessage, - TInt aReplySlot ) +CBasicPinQueryOperation* CBasicPinQueryOperation::NewL(MSecuiDialogOperationObserver& aObserver, const RMessage2& aMessage, TInt aReplySlot) { - TRACE( "CBasicPinQueryOperation::NewL, aMessage 0x%08x", aMessage.Handle() ); - TRACE( "CBasicPinQueryOperation::NewL, aMessage.Function = 0x%08x", aMessage.Function() ); - return new( ELeave ) CBasicPinQueryOperation( aObserver, aMessage, aReplySlot ); + RDEBUG("aMessage.Handle()", aMessage.Handle()); + RDEBUG("aMessage.Function()", aMessage.Function()); + return new (ELeave) CBasicPinQueryOperation(aObserver, aMessage, aReplySlot); } // --------------------------------------------------------------------------- @@ -68,24 +54,24 @@ // CBasicPinQueryOperation::~CBasicPinQueryOperation() { - TRACE( "CBasicPinQueryOperation::~CBasicPinQueryOperation" ); + RDEBUG("0", 0); Cancel(); - iPinInput = NULL; // not owned + iPinInput = NULL; // not owned } // --------------------------------------------------------------------------- // CBasicPinQueryOperation::StartL() // --------------------------------------------------------------------------- // -void CBasicPinQueryOperation::StartL( const TDesC8& aBuffer ) +void CBasicPinQueryOperation::StartL(const TDesC8& aBuffer) { - TRACE( "CBasicPinQueryOperation::StartL" ); - iPinInput = reinterpret_cast< const TPINInput* >( aBuffer.Ptr() ); - ASSERT( iPinInput != NULL ); + RDEBUG("0", 0); + iPinInput = reinterpret_cast (aBuffer.Ptr()); + ASSERT(iPinInput != NULL); iStatus = KRequestPending; TRequestStatus* status = &iStatus; - User::RequestComplete( status, KErrNone ); + User::RequestComplete(status, KErrNone); SetActive(); } @@ -95,7 +81,7 @@ // void CBasicPinQueryOperation::CancelOperation() { - TRACE( "CBasicPinQueryOperation::CancelOperation" ); + RDEBUG("0", 0); // nothing to do } @@ -105,193 +91,129 @@ // void CBasicPinQueryOperation::RunL() { - TRACE( "CBasicPinQueryOperation::RunL, iStatus.Int()=%d", iStatus.Int() ); - User::LeaveIfError( iStatus.Int() ); + RDEBUG("iStatus.Int()", iStatus.Int()); + User::LeaveIfError(iStatus.Int()); - TBool isRetry = ( iPinInput->iOperation & EPINValueIncorrect ); - if( isRetry ) + TBool isRetry = (iPinInput->iOperation & EPINValueIncorrect); + if (isRetry) { // Show "Invalid PIN code" error note, as previous attempt was failed. // TODO: localized UI string needed - _LIT( KInvalidPinCode, "Invalid PIN code" ); - ShowWarningNoteL( KInvalidPinCode ); - } -TRACE( "CBasicPinQueryOperation::RunL, iPinInput->iOperation=%d", iPinInput->iOperation ); - - HBufC* caption = NULL; - if( iPinInput->iPIN.iPINLabel == KBasicPinQueryKeyStorePassphrase ) - { - TRACE( "CBasicPinQueryOperation::RunL, KBasicPinQueryKeyStorePassphrase =%d", 1 ); - - // TODO: localized UI string needed - _LIT( KText, "Keystore password:" ); - caption = KText().AllocLC(); + _LIT(KInvalidPinCode, "Invalid PIN code"); + ShowWarningNoteL( KInvalidPinCode); } - else if( iPinInput->iPIN.iPINLabel == KBasicPinQueryNewKeyStorePassphrase ) - { - TRACE( "CBasicPinQueryOperation::RunL, KBasicPinQueryNewKeyStorePassphrase =%d", 1 ); - - // "Keystore password must be created for using private keys." - // SecUi creates two input fields when caption contains two labels - // separated with a vertical bar. SecUi verifies that user types the - // same passphrase in both fields. - // TODO: localized UI strings needed - _LIT( KText, "Create keystore password:|Verify:" ); - caption = KText().AllocLC(); - } - else if( iPinInput->iPIN.iPINLabel == KBasicPinQueryImportedKeyFilePassphrase ) - { - TRACE( "CBasicPinQueryOperation::RunL, KBasicPinQueryImportedKeyFilePassphrase =%d", 1 ); + RDEBUG("iPinInput->iOperation", iPinInput->iOperation); - // "Enter code for imported key:" - // TODO: localized UI strings needed - _LIT( KText, "Enter code for imported key:|Verify:" ); - caption = KText().AllocLC(); - } - else if( iPinInput->iPIN.iPINLabel == KBasicPinQueryExportedKeyFilePassphrase ) - { - TRACE( "CBasicPinQueryOperation::RunL, KBasicPinQueryExportedKeyFilePassphrase =%d", 1 ); - - // "Enter new code for exported key:" - // TODO: localized UI strings needed - _LIT( KText, "Enter new code for exported key:|Verify:" ); - caption = KText().AllocLC(); - } - else if( iPinInput->iPIN.iPINLabel == KBasicPinQueryPKCS12 ) - { - TRACE( "CBasicPinQueryOperation::RunL, KBasicPinQueryPKCS12 =%d", 1 ); - - // "Password for %U:", PKCS#12 password query prompt - // TODO: localized UI string needed - _LIT( KText, "Password for PKCS#12 file:" ); - caption = KText().AllocLC(); - } - else - { - TRACE( "CBasicPinQueryOperation::RunL, else =%d", 1 ); - - // "Enter code for %0U in %1U" - // Data query for PIN request in keystore where %0U is the PIN's name %1U is the keystore's name. - // TODO: EEnterPinNR - _LIT( KText, "86" ); - caption = KText().AllocLC(); - } iPinValue.Copy(_L("0")); - TRACE( "CBasicPinQueryOperation::RunL, 1 =%d", 1 ); + RDEBUG("0", 0); TInt resultVerif = KErrNone; - TRACE( "CBasicPinQueryOperation::RunL, 1 =%d", 1 ); + RDEBUG("0", 0); + + { + RMobilePhone iPhone; + + TInt err(KErrGeneral); + RDEBUG("ESecurityQueryActive", ESecurityQueryActive); + err = RProperty::Set(KPSUidStartup, KStartupSecurityCodeQueryStatus, ESecurityQueryActive); + RDEBUG("err", err); + TInt thisTry(0); + RTelServer iTelServer; + RMmCustomAPI iCustomPhone; + while ((err = iTelServer.Connect()) != KErrNone && (thisTry++) <= KTriesToConnectServer) { - RMobilePhone iPhone; + User::After( KTimeBeforeRetryingServerConnection); + } + err = iTelServer.LoadPhoneModule(KMmTsyModuleName); + RTelServer::TPhoneInfo PhoneInfo; + err = iTelServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended); + err = iTelServer.GetPhoneInfo(KPhoneIndex, PhoneInfo); + err = iPhone.Open(iTelServer, PhoneInfo.iName); + err = iCustomPhone.Open(iPhone); + RDEBUG("err", err); + CSecurityHandler* handler = new (ELeave) CSecurityHandler(iPhone); + CleanupStack::PushL(handler); + // TSecUi::InitializeLibL(); + RDEBUG("0", 0); + RMobilePhone::TMobilePhoneSecurityEvent iEvent; + TInt lEvent = iPinInput->iOperation; + RDEBUG("lEvent", lEvent); + if (lEvent >= 0x1000) // flag for iStartUp + { + lEvent -= 0x1000; + } + iEvent = static_cast (lEvent); + RDEBUG("iEvent", iEvent); + RDEBUG("iStartUp", iStartUp); + TRAPD(resultHandler, handler->HandleEventL(iEvent, iStartUp, resultVerif)); + RDEBUG("resultHandler", resultHandler); + RDEBUG("resultVerif", resultVerif); - TInt err( KErrGeneral); - TRACE( "CBasicPinQueryOperation::RunL, ESecurityQueryActive =%d", ESecurityQueryActive ); - err = RProperty::Set(KPSUidStartup, KStartupSecurityCodeQueryStatus, ESecurityQueryActive); - TRACE( "CBasicPinQueryOperation::RunL, err =%d", err ); - - TInt thisTry( 0); - RTelServer iTelServer; - RMmCustomAPI iCustomPhone; - while ( ( err = iTelServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) - { - User::After( KTimeBeforeRetryingServerConnection ); - } - err = iTelServer.LoadPhoneModule( KMmTsyModuleName ); - RTelServer::TPhoneInfo PhoneInfo; - err = iTelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) ; - err = iTelServer.GetPhoneInfo( KPhoneIndex, PhoneInfo ) ; - err = iPhone.Open( iTelServer, PhoneInfo.iName ) ; - err = iCustomPhone.Open( iPhone ) ; - TRACE( "CBasicPinQueryOperation::RunL, err =%d", err ); - CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone); - CleanupStack::PushL(handler); - // TSecUi::InitializeLibL(); - TRACE( "CBasicPinQueryOperation::RunL, TMobilePhoneSecurityEvent 1 =%d", 1 ); - RMobilePhone::TMobilePhoneSecurityEvent iEvent; - TInt lEvent = iPinInput->iOperation; - TRACE( "CBasicPinQueryOperation::RunL, lEvent =%d", lEvent ); - if( lEvent >= 0x1000 ) // flag for iStartUp - { - lEvent-=0x1000; - } - iEvent = static_cast(lEvent); - TRACE( "CBasicPinQueryOperation::RunL, iEvent =%d", iEvent ); - TRACE( "CBasicPinQueryOperation::RunL, TBool iStartUp =%d", iStartUp ); - TRAPD( resultHandler, handler->HandleEventL( iEvent, iStartUp, resultVerif ) ); - TRACE( "CBasicPinQueryOperation::RunL, resultHandler =%d", resultHandler ); - TRACE( "CBasicPinQueryOperation::RunL, resultVerif =%d", resultVerif ); - - // if something went wrong cancel the code request - if (resultHandler) - { - if(resultVerif==KErrNone) // if the process failed, then the result shoud also indicate the failure (unless it does it already) - resultVerif = resultHandler; - TRACE( "CBasicPinQueryOperation::RunL, iEvent =%d", iEvent ); - TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma )); - TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin )); - switch (iEvent) - { - case RMobilePhone::EUniversalPinRequired: - if(wcdmaSupported || upinSupported) - { - iPhone.AbortSecurityCode(RMobilePhone::ESecurityUniversalPin); - } - break; - case RMobilePhone::EUniversalPukRequired: - if(wcdmaSupported || upinSupported) - { - iPhone.AbortSecurityCode(RMobilePhone::ESecurityUniversalPuk); - } - break; - case RMobilePhone::EPin1Required: - iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin1); - break; - case RMobilePhone::EPuk1Required: - iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk1); - break; - case RMobilePhone::EPin2Required: - iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin2); - break; - case RMobilePhone::EPuk2Required: - iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk2); - break; - case RMobilePhone::EPhonePasswordRequired: - iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePhonePassword); - break; - default: - TRACE( "CBasicPinQueryOperation::RunL, default iEvent =%d", iEvent ); - break; - } - } - - // uninitialize security ui - TRACE( "CBasicPinQueryOperation::RunL, PopAndDestroy(handler) =%d", 0 ); - CleanupStack::PopAndDestroy(handler); // handler - TRACE( "CBasicPinQueryOperation::RunL, UnInitializeLib =%d", 1 ); - TSecUi::UnInitializeLib(); - TRACE( "CBasicPinQueryOperation::RunL, ESecurityQueryNotActive =%d", ESecurityQueryNotActive ); - err = RProperty::Set(KPSUidStartup, KStartupSecurityCodeQueryStatus, ESecurityQueryNotActive); - TRACE( "CBasicPinQueryOperation::RunL, err =%d", err ); - //close ETel connection - if (iTelServer.Handle()) - { - TRACE( "CBasicPinQueryOperation::RunL, iPhone.Close =%d", 0 ); - iPhone.Close(); - iTelServer.UnloadPhoneModule(KMmTsyModuleName); - iTelServer.Close(); - TRACE( "CBasicPinQueryOperation::RunL, iTelServer.Close =%d", 1 ); - } + // if something went wrong cancel the code request + if (resultHandler) + { + if (resultVerif == KErrNone) // if the process failed, then the result shoud also indicate the failure (unless it does it already) + resultVerif = resultHandler; + RDEBUG("iEvent", iEvent); + TBool wcdmaSupported(FeatureManager::FeatureSupported(KFeatureIdProtocolWcdma)); + TBool upinSupported(FeatureManager::FeatureSupported(KFeatureIdUpin)); + switch (iEvent) + { + case RMobilePhone::EUniversalPinRequired: + if (wcdmaSupported || upinSupported) + { + iPhone.AbortSecurityCode(RMobilePhone::ESecurityUniversalPin); + } + break; + case RMobilePhone::EUniversalPukRequired: + if (wcdmaSupported || upinSupported) + { + iPhone.AbortSecurityCode(RMobilePhone::ESecurityUniversalPuk); + } + break; + case RMobilePhone::EPin1Required: + iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin1); + break; + case RMobilePhone::EPuk1Required: + iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk1); + break; + case RMobilePhone::EPin2Required: + iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin2); + break; + case RMobilePhone::EPuk2Required: + iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk2); + break; + case RMobilePhone::EPhonePasswordRequired: + iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePhonePassword); + break; + default: + RDEBUG("default iEvent", iEvent); + break; + } } - - ReturnResultL( resultVerif ); + // uninitialize security ui + RDEBUG("PopAndDestroy 0", 0); + CleanupStack::PopAndDestroy(handler); // handler + RDEBUG("UnInitializeLib 0", 0); + TSecUi::UnInitializeLib(); + RDEBUG("ESecurityQueryNotActive", ESecurityQueryNotActive); + err = RProperty::Set(KPSUidStartup, KStartupSecurityCodeQueryStatus, ESecurityQueryNotActive); + RDEBUG("err", err); + //close ETel connection + if (iTelServer.Handle()) + { + RDEBUG("iPhone.Close()", 0); + iPhone.Close(); + iTelServer.UnloadPhoneModule(KMmTsyModuleName); + iTelServer.Close(); + RDEBUG("0", 0); + } + } - if( caption ) - { - CleanupStack::PopAndDestroy( caption ); - caption = NULL; - } + ReturnResultL(resultVerif); + } // --------------------------------------------------------------------------- @@ -300,40 +222,39 @@ // void CBasicPinQueryOperation::DoCancel() { - TRACE( "CBasicPinQueryOperation::DoCancel" ); + RDEBUG("0", 0); } // --------------------------------------------------------------------------- // CBasicPinQueryOperation::CBasicPinQueryOperation() // --------------------------------------------------------------------------- // -CBasicPinQueryOperation::CBasicPinQueryOperation( - MSecuiDialogOperationObserver& aObserver, const RMessage2& aMessage, - TInt aReplySlot ) : CSecuiDialogOperation( aObserver, aMessage, aReplySlot ) +CBasicPinQueryOperation::CBasicPinQueryOperation(MSecuiDialogOperationObserver& aObserver, const RMessage2& aMessage, TInt aReplySlot) : + CSecuiDialogOperation(aObserver, aMessage, aReplySlot) { - TRACE( "CBasicPinQueryOperation::CBasicPinQueryOperation, aMessage 0x%08x", aMessage.Handle() ); - TRACE( "CBasicPinQueryOperation::CBasicPinQueryOperation, aMessage.Function = 0x%08x", aMessage.Function() ); - iStartUp=EFalse; - if(aMessage.Function()>=0x1000) - iStartUp=ETrue; + RDEBUG("aMessage.Handle()", aMessage.Handle()); + RDEBUG("aMessage.Function()", aMessage.Function()); + iStartUp = EFalse; + if (aMessage.Function() >= 0x1000) + iStartUp = ETrue; } // --------------------------------------------------------------------------- // CBasicPinQueryOperation::ReturnResultL() // --------------------------------------------------------------------------- // -void CBasicPinQueryOperation::ReturnResultL( TInt aErrorCode ) +void CBasicPinQueryOperation::ReturnResultL(TInt aErrorCode) { - TRACE( "CBasicPinQueryOperation::ReturnResultL, begin, aErrorCode=%d", aErrorCode ); - if( aErrorCode <= KErrNone ) // TODO should skip WriteL is error? + RDEBUG("aErrorCode", aErrorCode); + if (aErrorCode <= KErrNone) // TODO should skip WriteL is error? { - TPINValueBuf output( iPinValue ); - iMessage.WriteL( iReplySlot, output ); + TPINValueBuf output(iPinValue); + iMessage.WriteL(iReplySlot, output); } - TRACE( "CBasicPinQueryOperation::ReturnResultL, completing msg 0x%08x", iMessage.Handle() ); - iMessage.Complete( aErrorCode ); - TRACE( "CBasicPinQueryOperation::ReturnResultL, informing observer" ); + RDEBUG("Complete iMessage.Handle()", iMessage.Handle()); + iMessage.Complete(aErrorCode); + RDEBUG("informing observer 0", 0); iObserver.OperationComplete(); - TRACE( "CBasicPinQueryOperation::ReturnResultL, end" ); + RDEBUG("0x99", 0x99); } diff -r 3255e7d5bd67 -r 989397f9511c securitydialogs/secuidialognotifiersrv/src/untrustedcertquery.cpp --- a/securitydialogs/secuidialognotifiersrv/src/untrustedcertquery.cpp Thu Oct 07 14:07:34 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,250 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Displays untrusted certificate dialog -* -*/ - -#include "untrustedcertquery.h" // CUntrustedCertQuery -#include // CHbSymbianVariantMap -#include "secuidialogstrace.h" // TRACE macro - -// Note that the dialog type string, the parameters name strings, and the return code -// name string and values must match to those defined in Qt-side untrusted certificate -// dialog (in untrustedcertificatedefinitions.h file). - -// Device dialog type for untrusted certificate dialog -_LIT( KUntrustedCertificateDialog, "com.nokia.untrustedcert/1.0" ); - -// Variant map parameter names for untrusted certificate dialog -_LIT( KUntrustedCertEncodedCertificate, "cert" ); // bytearray, mandatory -_LIT( KUntrustedCertServerName, "host" ); // string, mandatory -_LIT( KUntrustedCertValidationError, "err" ); // int (TValidationError), mandatory -_LIT( KUntrustedCertTrustedSiteStoreFail, "tss" ); // any, prevents permanent acceptance - -// Dialog return code name and values -_LIT( KUntrustedCertDialogResult, "result" ); // int -const TInt KUntrustedCertDialogRejected = 0; -const TInt KUntrustedCertDialogAccepted = 1; -const TInt KUntrustedCertDialogAcceptedPermanently = 2; - - -// ======== MEMBER FUNCTIONS ======== - -// --------------------------------------------------------------------------- -// CUntrustedCertQuery::NewL() -// --------------------------------------------------------------------------- -// -CUntrustedCertQuery* CUntrustedCertQuery::NewL( - TValidationError aValidationError, const TDesC8& aCertificate, - const TDesC& aServerName, TBool aCanHandlePermanentAccept ) - { - TRACE( "CUntrustedCertQuery::NewL" ); - CUntrustedCertQuery* self = new ( ELeave ) CUntrustedCertQuery( - aValidationError, aCertificate, aServerName, - aCanHandlePermanentAccept ); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } - -// --------------------------------------------------------------------------- -// CUntrustedCertQuery::~CUntrustedCertQuery() -// --------------------------------------------------------------------------- -// -CUntrustedCertQuery::~CUntrustedCertQuery() - { - TRACE( "CUntrustedCertQuery::~CUntrustedCertQuery, begin" ); - Cancel(); - delete iWait; - iWait = NULL; - delete iDeviceDialog; - iDeviceDialog = NULL; - delete iVariantMap; - iVariantMap = NULL; - TRACE( "CUntrustedCertQuery::~CUntrustedCertQuery, end" ); - } - -// --------------------------------------------------------------------------- -// CUntrustedCertQuery::ShowQueryAndWaitForResponseL() -// --------------------------------------------------------------------------- -// -void CUntrustedCertQuery::ShowQueryAndWaitForResponseL( TResponse& aResponse ) - { - TRACE( "CUntrustedCertQuery::ShowQueryAndWaitForResponseL, begin" ); - if( !iDeviceDialog ) - { - iDeviceDialog = CHbDeviceDialogSymbian::NewL(); - } - if( !iVariantMap ) - { - iVariantMap = CHbSymbianVariantMap::NewL(); - } - - CHbSymbianVariant *variant = NULL; - variant = CHbSymbianVariant::NewL( &iCertificate, CHbSymbianVariant::EBinary ); - User::LeaveIfError( iVariantMap->Add( KUntrustedCertEncodedCertificate, variant ) ); - variant = CHbSymbianVariant::NewL( &iValidationError, CHbSymbianVariant::EInt ); - User::LeaveIfError( iVariantMap->Add( KUntrustedCertValidationError, variant ) ); - variant = CHbSymbianVariant::NewL( &iServerName, CHbSymbianVariant::EDes ); - User::LeaveIfError( iVariantMap->Add( KUntrustedCertServerName, variant ) ); - if( !iCanHandlePermanentAccept ) - { - variant = CHbSymbianVariant::NewL( &iCanHandlePermanentAccept, CHbSymbianVariant::EBool ); - User::LeaveIfError( iVariantMap->Add( KUntrustedCertTrustedSiteStoreFail, variant ) ); - } - - User::LeaveIfError( iDeviceDialog->Show( KUntrustedCertificateDialog, *iVariantMap, this ) ); - iStatus = KRequestPending; - SetActive(); - - TRACE( "CUntrustedCertQuery::ShowQueryAndWaitForResponseL, iWait start" ); - iWait->Start(); - TRACE( "CUntrustedCertQuery::ShowQueryAndWaitForResponseL, iWaitCompletionCode=%d", - iWaitCompletionCode ); - User::LeaveIfError( iWaitCompletionCode ); - TRACE( "CUntrustedCertQuery::ShowQueryAndWaitForResponseL, iResponse=%d", iResponse ); - aResponse = iResponse; - } - -// --------------------------------------------------------------------------- -// CUntrustedCertQuery::DoCancel() -// --------------------------------------------------------------------------- -// -void CUntrustedCertQuery::DoCancel() - { - TRACE( "CUntrustedCertQuery::DoCancel, begin" ); - if( iDeviceDialog ) - { - TRACE( "CUntrustedCertQuery::DoCancel, cancelling device dialog" ); - iDeviceDialog->Cancel(); - } - - // Have to complete the request here, because cancelled device dialog does not - // call DeviceDialogClosed() that normally completes it. The request needs to - // be completed since CActive::Cancel() waits until the request is completed. - TRACE( "CUntrustedCertQuery::DoCancel, completing self with KErrCancel" ); - TRequestStatus* status( &iStatus ); - User::RequestComplete( status, KErrCancel ); - - // Normally the above request complete would trigger running RunL(). Now RunL() - // is not run since the active object is already cancelled. Hence, have to stop - // the waiting here so that iWait->Start() returns. - iWaitCompletionCode = KErrCancel; - if( iWait && iWait->IsStarted() ) - { - TRACE( "CUntrustedCertQuery::DoCancel, stopping iWait" ); - iWait->AsyncStop(); - } - TRACE( "CUntrustedCertQuery::DoCancel, end" ); - } - -// --------------------------------------------------------------------------- -// CUntrustedCertQuery::RunL() -// --------------------------------------------------------------------------- -// -void CUntrustedCertQuery::RunL() - { - TRACE( "CUntrustedCertQuery::RunL, iStatus.Int()=%d", iStatus.Int() ); - iWaitCompletionCode = iStatus.Int(); - if( iWait && iWait->IsStarted() ) - { - TRACE( "CUntrustedCertQuery::RunL, stopping iWait" ); - iWait->AsyncStop(); - } - } - -// --------------------------------------------------------------------------- -// CUntrustedCertQuery::DataReceived() -// --------------------------------------------------------------------------- -// -void CUntrustedCertQuery::DataReceived( CHbSymbianVariantMap& aData ) - { - TRACE( "CUntrustedCertQuery::DataReceived" ); - const CHbSymbianVariant* variant = aData.Get( KUntrustedCertDialogResult ); - if( variant ) - { - TInt* value = variant->Value(); - if( value ) - { - switch( *value ) - { - case KUntrustedCertDialogRejected: - TRACE( "CUntrustedCertQuery::DataReceived, rejected" ); - iResponse = EQueryRejected; - break; - case KUntrustedCertDialogAccepted: - TRACE( "CUntrustedCertQuery::DataReceived, accepted" ); - iResponse = EQueryAccepted; - break; - case KUntrustedCertDialogAcceptedPermanently: - TRACE( "CUntrustedCertQuery::DataReceived, accepted permanently" ); - iResponse = EQueryAcceptedPermanently; - break; - default: - __ASSERT_DEBUG( EFalse, User::Invariant() ); - break; - } - } - else - { - __ASSERT_DEBUG( EFalse, User::Invariant() ); - } - } - else - { - __ASSERT_DEBUG( EFalse, User::Invariant() ); - } - } - -// --------------------------------------------------------------------------- -// CUntrustedCertQuery::DeviceDialogClosed() -// --------------------------------------------------------------------------- -// -void CUntrustedCertQuery::DeviceDialogClosed( TInt aCompletionCode ) - { - TRACE( "CUntrustedCertQuery::DeviceDialogClosed, aCompletionCode=%d", aCompletionCode ); - if( IsActive() ) - { - TRACE( "CUntrustedCertQuery::DeviceDialogClosed, request complete" ); - TRequestStatus* status( &iStatus ); - User::RequestComplete( status, aCompletionCode ); - } - } - -// --------------------------------------------------------------------------- -// CUntrustedCertQuery::CUntrustedCertQuery() -// --------------------------------------------------------------------------- -// -CUntrustedCertQuery::CUntrustedCertQuery( - TValidationError aValidationError, const TDesC8& aCertificate, - const TDesC& aServerName, TBool aCanHandlePermanentAccept ) : - CActive( CActive::EPriorityStandard ), iValidationError( aValidationError ), - iCertificate( aCertificate ), iServerName( aServerName ), - iCanHandlePermanentAccept( aCanHandlePermanentAccept ), - iResponse( EQueryRejected ) - { - CActiveScheduler::Add( this ); - } - -// --------------------------------------------------------------------------- -// CUntrustedCertQuery::ConstructL() -// --------------------------------------------------------------------------- -// -void CUntrustedCertQuery::ConstructL() - { - TRACE( "CUntrustedCertQuery::ConstructL" ); - iWait = new( ELeave ) CActiveSchedulerWait; - } - diff -r 3255e7d5bd67 -r 989397f9511c wim/WimPlugin/src/WimCertStore.cpp --- a/wim/WimPlugin/src/WimCertStore.cpp Thu Oct 07 14:07:34 2010 +0300 +++ b/wim/WimPlugin/src/WimCertStore.cpp Thu Oct 14 13:56:11 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -1870,7 +1870,6 @@ iKeyInfos.Close(); delete iUnifiedKeyStore; iUnifiedKeyStore = NULL; - iCertsList->Reset(); } }