securitydialogs/Autolock/src/Autolock.h
changeset 26 aad866c37519
child 37 7bad16cccaca
child 63 989397f9511c
equal deleted inserted replaced
22:6b63ca65093a 26:aad866c37519
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
       
     8 * 
       
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not, 
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
       
    19 *
       
    20 */
       
    21 
       
    22 #ifndef AUTOLOCK_H
       
    23 #define AUTOLOCK_H
       
    24 
       
    25 #ifdef _DEBUG
       
    26 		#define RDEBUG( x, y ) RDebug::Printf( "%s %s (%u) %s=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, x, y );
       
    27 #else
       
    28     #define RDEBUG( x, y )
       
    29 #endif
       
    30 
       
    31 #include <QWidget>
       
    32 #include <QEvent>
       
    33 #include <QModelIndex>
       
    34 #include <QMap>
       
    35 #include <QStringList>
       
    36 #include <xqserviceprovider.h>
       
    37 #include <xqsharablefile.h>
       
    38 #include <QToolButton>
       
    39 #include <qmobilityglobal.h>
       
    40 
       
    41 #include "autolockuseractivityservice.h"
       
    42 #include "../../SecUi/Inc/SecQueryUi.h"
       
    43 
       
    44 QTM_BEGIN_NAMESPACE
       
    45     class QValueSpacePublisher;
       
    46     class QValueSpaceSubscriber;
       
    47 QTM_END_NAMESPACE
       
    48 QTM_USE_NAMESPACE
       
    49 
       
    50 #include <hbwidget.h>
       
    51 #include <qapplication.h>
       
    52 #include <hbdevicedialog.h>
       
    53 
       
    54 enum TLockStatus
       
    55 	{
       
    56 	ELockNotActive = 0,
       
    57 	EKeyguardActive,
       
    58 	EDevicelockActive
       
    59 	};
       
    60 
       
    61 enum TDevicelockReason
       
    62 	{
       
    63 	EDevicelockManual = 1,
       
    64 	EDevicelockRemote,
       
    65 	EDevicelockTimer
       
    66 	};
       
    67 
       
    68 
       
    69 class AutolockService;
       
    70 
       
    71 class Autolock : public QWidget
       
    72 {
       
    73     Q_OBJECT
       
    74 
       
    75 public:
       
    76     Autolock( QWidget *parent = 0, Qt::WFlags f = 0 );
       
    77     ~Autolock();
       
    78 
       
    79     void setLabelNumber(QString label,QString number);
       
    80     void setLabelIcon(int value);
       
    81     int CheckIfLegal(int value);
       
    82     void DebugRequest(int value);
       
    83     void DebugError(int value);
       
    84     void DebugStatus(int value);
       
    85     void adjustInactivityTimers(int aReason);
       
    86     int updateIndicator(int aReason);
       
    87     int AskValidSecCode(int aReason);
       
    88     int publishStatus(int aReason);
       
    89     int TryChangeStatus(int aReason);
       
    90     int setLockDialog(int aReason, int status);
       
    91     int showNoteIfRequested(int aReason);
       
    92 
       
    93     bool event(QEvent *event);    
       
    94     bool eventFilter(QObject *, QEvent *);
       
    95 
       
    96 		int callerHasECapabilityWriteDeviceData;
       
    97 		int iShowKeyguardNote;
       
    98     int mParam1;
       
    99     int mParam2;
       
   100 
       
   101 public slots:    
       
   102     void quit();
       
   103     void handleAnswerDelivered();
       
   104     void subscriberKSettingsAutolockStatusChanged();
       
   105     void subscriberKSettingsAutoLockTimeChanged();
       
   106     void subscriberKSettingsAutomaticKeyguardTimeChanged();
       
   107     void subscriberKDisplayLightsTimeoutChanged();
       
   108     void subscriberKProEngActiveProfileChanged();
       
   109     void subscriberKAknKeyguardStatusChanged();
       
   110     void subscriberKCoreAppUIsAutolockStatusChanged();
       
   111     void subscriberKHWRMGripStatusChanged();
       
   112 
       
   113 private slots:
       
   114     void activeKeyguard();
       
   115     void notActiveKeyguard();
       
   116     void activeDevicelock();
       
   117     void notActiveDevicelock();
       
   118 
       
   119 private:
       
   120     AutolockService* mService;
       
   121     // int mKeyCode;
       
   122     // int mKeyCaptureHandle;
       
   123     QValueSpaceSubscriber *subscriberKSettingsAutolockStatus;
       
   124     QValueSpaceSubscriber *subscriberKSettingsAutoLockTime;
       
   125     QValueSpaceSubscriber *subscriberKSettingsAutomaticKeyguardTime;
       
   126     QValueSpaceSubscriber *subscriberKDisplayLightsTimeout;
       
   127     QValueSpaceSubscriber *subscriberKProEngActiveProfile;
       
   128     QValueSpaceSubscriber *subscriberKAknKeyguardStatus;
       
   129     QValueSpaceSubscriber *subscriberKCoreAppUIsAutolockStatus;
       
   130     QValueSpaceSubscriber *subscriberKHWRMGripStatus;
       
   131 
       
   132 		AutolockUserActivityService* serviceKeyguard;
       
   133 		AutolockUserActivityService* serviceDevicelock;
       
   134 		
       
   135 		int iLockStatus;
       
   136 		int iLockStatusPrev;
       
   137 		CSecQueryUi *iSecQueryUi;
       
   138 		int iSecQueryUiCreated;
       
   139 		HbDeviceDialog *iDeviceDialog;
       
   140 		int iDeviceDialogCreated;
       
   141 };
       
   142 
       
   143 class AutolockService : public XQServiceProvider
       
   144 {
       
   145     Q_OBJECT
       
   146 public:
       
   147     AutolockService( Autolock *parent = 0 );
       
   148     ~AutolockService();
       
   149     
       
   150     void complete(QString number);
       
   151     bool asyncAnswer() {return mAsyncAnswer;}
       
   152 public slots:
       
   153     int service(const QString& number, const QString& aParam1, const QString& aParam2 );
       
   154 
       
   155 private slots:
       
   156    void handleClientDisconnect();
       
   157 
       
   158 private:
       
   159     Autolock* mAutolock;
       
   160     QString mNumber;
       
   161     bool mAsyncAnswer;
       
   162     int mAsyncReqId;
       
   163 };
       
   164 
       
   165 class  CWait : public CActive
       
   166     {
       
   167      public:
       
   168        /**
       
   169         * Creates instance of the CWait class.
       
   170         *
       
   171 		* @return Returns the instance just created.
       
   172         */
       
   173 		static CWait* NewL();
       
   174 		/**
       
   175         * Destructor.
       
   176         */
       
   177         ~CWait();
       
   178     public:
       
   179         /**
       
   180 		* Starts waiting for aReqStatus. 
       
   181 		*/
       
   182 		TInt WaitForRequestL();
       
   183     public:
       
   184         /**
       
   185         * Sets active request type. 
       
   186         */
       
   187         void SetRequestType(TInt aRequestType);
       
   188         /**
       
   189         * Gets active request type. 
       
   190         */
       
   191         TInt GetRequestType();
       
   192 	private:
       
   193 		/**
       
   194 		* C++ default constructor.
       
   195 		*/
       
   196 		CWait();
       
   197 		/**
       
   198 		* Symbian OS constructor.
       
   199 		*/
       
   200 		void ConstructL();
       
   201 	private: // from CActive
       
   202         /** @see CActive::RunL() */
       
   203 		void RunL();
       
   204 		/** @see CActive::DoCancel() */
       
   205         void DoCancel();
       
   206 		RTimer iTimer;
       
   207 		CActiveSchedulerWait iWait;
       
   208 		// Used if there is a need to cancel an active request;
       
   209         // namely in situations where destructor is called when Wait
       
   210         // is active.
       
   211         TInt iRequestType;
       
   212 	};
       
   213 
       
   214 
       
   215 #endif // AUTOLOCK_H