securitydialogs/secuidialognotifiersrv/src/secuidialognotifiersession.cpp
author hgs
Thu, 14 Oct 2010 13:56:11 +0300
changeset 63 989397f9511c
parent 59 881d92421467
child 66 67b3e3c1fc87
permissions -rw-r--r--
201039_03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59
881d92421467 201037_03
hgs
parents:
diff changeset
     1
/*
881d92421467 201037_03
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
881d92421467 201037_03
hgs
parents:
diff changeset
     3
* All rights reserved.
881d92421467 201037_03
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
881d92421467 201037_03
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
881d92421467 201037_03
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
881d92421467 201037_03
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
881d92421467 201037_03
hgs
parents:
diff changeset
     8
*
881d92421467 201037_03
hgs
parents:
diff changeset
     9
* Initial Contributors:
881d92421467 201037_03
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
881d92421467 201037_03
hgs
parents:
diff changeset
    11
*
881d92421467 201037_03
hgs
parents:
diff changeset
    12
* Contributors:
881d92421467 201037_03
hgs
parents:
diff changeset
    13
*
881d92421467 201037_03
hgs
parents:
diff changeset
    14
* Description:  Secui dialog notifier server session
881d92421467 201037_03
hgs
parents:
diff changeset
    15
*
881d92421467 201037_03
hgs
parents:
diff changeset
    16
*/
881d92421467 201037_03
hgs
parents:
diff changeset
    17
881d92421467 201037_03
hgs
parents:
diff changeset
    18
#include "secuidialognotifiersession.h"  // CSecuiDialogNotifierSession
881d92421467 201037_03
hgs
parents:
diff changeset
    19
#include "secuidialognotifierserver.h"   // CSecuiDialogNotifierServer
881d92421467 201037_03
hgs
parents:
diff changeset
    20
#include "secuidialognotifierservername.h" // KSecuiDialogsCancelOperation
881d92421467 201037_03
hgs
parents:
diff changeset
    21
#include "secuidialogoperbasicpinquery.h" // CBasicPinQueryOperation
881d92421467 201037_03
hgs
parents:
diff changeset
    22
#include "secuidialogstrace.h"           // TRACE macro
881d92421467 201037_03
hgs
parents:
diff changeset
    23
#include <keyguardaccessapi.h>
881d92421467 201037_03
hgs
parents:
diff changeset
    24
881d92421467 201037_03
hgs
parents:
diff changeset
    25
const TInt KInputParam = 0;
881d92421467 201037_03
hgs
parents:
diff changeset
    26
const TInt KOutputParam = 1;
881d92421467 201037_03
hgs
parents:
diff changeset
    27
881d92421467 201037_03
hgs
parents:
diff changeset
    28
881d92421467 201037_03
hgs
parents:
diff changeset
    29
// ======== MEMBER FUNCTIONS ========
881d92421467 201037_03
hgs
parents:
diff changeset
    30
881d92421467 201037_03
hgs
parents:
diff changeset
    31
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    32
// CSecuiDialogNotifierSession::NewL()
881d92421467 201037_03
hgs
parents:
diff changeset
    33
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    34
//
881d92421467 201037_03
hgs
parents:
diff changeset
    35
CSecuiDialogNotifierSession* CSecuiDialogNotifierSession::NewL()
881d92421467 201037_03
hgs
parents:
diff changeset
    36
    {
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
    37
		RDEBUG("0", 0);
59
881d92421467 201037_03
hgs
parents:
diff changeset
    38
    CSecuiDialogNotifierSession* self = new( ELeave ) CSecuiDialogNotifierSession;
881d92421467 201037_03
hgs
parents:
diff changeset
    39
    CleanupStack::PushL( self );
881d92421467 201037_03
hgs
parents:
diff changeset
    40
    self->ConstructL();
881d92421467 201037_03
hgs
parents:
diff changeset
    41
    CleanupStack::Pop( self );
881d92421467 201037_03
hgs
parents:
diff changeset
    42
    return self;
881d92421467 201037_03
hgs
parents:
diff changeset
    43
    }
881d92421467 201037_03
hgs
parents:
diff changeset
    44
881d92421467 201037_03
hgs
parents:
diff changeset
    45
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    46
// CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession()
881d92421467 201037_03
hgs
parents:
diff changeset
    47
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    48
//
881d92421467 201037_03
hgs
parents:
diff changeset
    49
CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession()
881d92421467 201037_03
hgs
parents:
diff changeset
    50
    {
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
    51
    RDEBUG("0", 0);
59
881d92421467 201037_03
hgs
parents:
diff changeset
    52
    Server().RemoveSession();
881d92421467 201037_03
hgs
parents:
diff changeset
    53
    delete iOperationHandler;
881d92421467 201037_03
hgs
parents:
diff changeset
    54
    iOperationHandler = NULL;
881d92421467 201037_03
hgs
parents:
diff changeset
    55
    delete iInputBuffer;
881d92421467 201037_03
hgs
parents:
diff changeset
    56
    iInputBuffer = NULL;
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
    57
    RDEBUG("0x99", 0x99);
59
881d92421467 201037_03
hgs
parents:
diff changeset
    58
    }
881d92421467 201037_03
hgs
parents:
diff changeset
    59
881d92421467 201037_03
hgs
parents:
diff changeset
    60
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    61
// CSecuiDialogNotifierSession::CreateL()
881d92421467 201037_03
hgs
parents:
diff changeset
    62
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    63
//
881d92421467 201037_03
hgs
parents:
diff changeset
    64
void CSecuiDialogNotifierSession::CreateL()
881d92421467 201037_03
hgs
parents:
diff changeset
    65
    {
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
    66
    RDEBUG("0", 0);
59
881d92421467 201037_03
hgs
parents:
diff changeset
    67
    Server().AddSession();
881d92421467 201037_03
hgs
parents:
diff changeset
    68
    }
881d92421467 201037_03
hgs
parents:
diff changeset
    69
881d92421467 201037_03
hgs
parents:
diff changeset
    70
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    71
// CSecuiDialogNotifierSession::ServiceL()
881d92421467 201037_03
hgs
parents:
diff changeset
    72
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    73
//
881d92421467 201037_03
hgs
parents:
diff changeset
    74
void CSecuiDialogNotifierSession::ServiceL( const RMessage2& aMessage )
881d92421467 201037_03
hgs
parents:
diff changeset
    75
    {
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
    76
    RDEBUG("aMessage.Handle()", aMessage.Handle());
59
881d92421467 201037_03
hgs
parents:
diff changeset
    77
    TRAPD( error, DispatchMessageL( aMessage ) );
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
    78
    RDEBUG("error", error);
59
881d92421467 201037_03
hgs
parents:
diff changeset
    79
    if( error && !aMessage.IsNull() )
881d92421467 201037_03
hgs
parents:
diff changeset
    80
        {
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
    81
        RDEBUG("Complete aMessage.Handle()", aMessage.Handle());
59
881d92421467 201037_03
hgs
parents:
diff changeset
    82
        aMessage.Complete( error );
881d92421467 201037_03
hgs
parents:
diff changeset
    83
        }
881d92421467 201037_03
hgs
parents:
diff changeset
    84
    }
881d92421467 201037_03
hgs
parents:
diff changeset
    85
881d92421467 201037_03
hgs
parents:
diff changeset
    86
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    87
// CSecuiDialogNotifierSession::OperationComplete()
881d92421467 201037_03
hgs
parents:
diff changeset
    88
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    89
//
881d92421467 201037_03
hgs
parents:
diff changeset
    90
void CSecuiDialogNotifierSession::OperationComplete()
881d92421467 201037_03
hgs
parents:
diff changeset
    91
    {
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
    92
    RDEBUG("0", 0);
59
881d92421467 201037_03
hgs
parents:
diff changeset
    93
    delete iOperationHandler;
881d92421467 201037_03
hgs
parents:
diff changeset
    94
    iOperationHandler = NULL;
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
    95
    RDEBUG("0x99", 0x99);
59
881d92421467 201037_03
hgs
parents:
diff changeset
    96
    }
881d92421467 201037_03
hgs
parents:
diff changeset
    97
881d92421467 201037_03
hgs
parents:
diff changeset
    98
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    99
// CSecuiDialogNotifierSession::CSecuiDialogNotifierSession()
881d92421467 201037_03
hgs
parents:
diff changeset
   100
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   101
//
881d92421467 201037_03
hgs
parents:
diff changeset
   102
CSecuiDialogNotifierSession::CSecuiDialogNotifierSession()
881d92421467 201037_03
hgs
parents:
diff changeset
   103
    {
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   104
    RDEBUG("0", 0);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   105
    }
881d92421467 201037_03
hgs
parents:
diff changeset
   106
881d92421467 201037_03
hgs
parents:
diff changeset
   107
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   108
// CSecuiDialogNotifierSession::ConstructL()
881d92421467 201037_03
hgs
parents:
diff changeset
   109
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   110
//
881d92421467 201037_03
hgs
parents:
diff changeset
   111
void CSecuiDialogNotifierSession::ConstructL()
881d92421467 201037_03
hgs
parents:
diff changeset
   112
    {
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   113
    RDEBUG("0", 0);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   114
    }
881d92421467 201037_03
hgs
parents:
diff changeset
   115
881d92421467 201037_03
hgs
parents:
diff changeset
   116
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   117
// CSecuiDialogNotifierSession::Server()
881d92421467 201037_03
hgs
parents:
diff changeset
   118
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   119
//
881d92421467 201037_03
hgs
parents:
diff changeset
   120
CSecuiDialogNotifierServer& CSecuiDialogNotifierSession::Server()
881d92421467 201037_03
hgs
parents:
diff changeset
   121
    {
881d92421467 201037_03
hgs
parents:
diff changeset
   122
    return *static_cast< CSecuiDialogNotifierServer* >(
881d92421467 201037_03
hgs
parents:
diff changeset
   123
            const_cast< CServer2* >( CSession2::Server() ) );
881d92421467 201037_03
hgs
parents:
diff changeset
   124
    }
881d92421467 201037_03
hgs
parents:
diff changeset
   125
881d92421467 201037_03
hgs
parents:
diff changeset
   126
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   127
// CSecuiDialogNotifierSession::DispatchMessageL()
881d92421467 201037_03
hgs
parents:
diff changeset
   128
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   129
//
881d92421467 201037_03
hgs
parents:
diff changeset
   130
void CSecuiDialogNotifierSession::DispatchMessageL( const RMessage2& aMessage )
881d92421467 201037_03
hgs
parents:
diff changeset
   131
    {
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   132
    RDEBUG("0", 0);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   133
    if( !IsOperationCancelled( aMessage ) )
881d92421467 201037_03
hgs
parents:
diff changeset
   134
        {
881d92421467 201037_03
hgs
parents:
diff changeset
   135
        TInt lOperation = aMessage.Function();
881d92421467 201037_03
hgs
parents:
diff changeset
   136
881d92421467 201037_03
hgs
parents:
diff changeset
   137
		// from AskSecCodeInAutoLockL
881d92421467 201037_03
hgs
parents:
diff changeset
   138
		if(lOperation==0x100+6 /*RMobilePhone::EPhonePasswordRequired*/)
881d92421467 201037_03
hgs
parents:
diff changeset
   139
			{
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   140
			RDEBUG("query from AskSecCodeInAutoLockL . No need to start Autolock.exe", 0);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   141
			}
881d92421467 201037_03
hgs
parents:
diff changeset
   142
		else
881d92421467 201037_03
hgs
parents:
diff changeset
   143
			{
881d92421467 201037_03
hgs
parents:
diff changeset
   144
	    CKeyguardAccessApi* iKeyguardAccess = CKeyguardAccessApi::NewL( );
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   145
	   	RDEBUG("0", 0);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   146
			TInt err = iKeyguardAccess->ShowKeysLockedNote( );
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   147
			RDEBUG("err", err);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   148
			delete iKeyguardAccess;
881d92421467 201037_03
hgs
parents:
diff changeset
   149
			}
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   150
			RDEBUG("lOperation", lOperation);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   151
				if( lOperation >= 0x1000 )	// flag for iStartup
881d92421467 201037_03
hgs
parents:
diff changeset
   152
					lOperation -= 0x1000;
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   153
			RDEBUG("new lOperation", lOperation);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   154
        if( lOperation < 0x200 )
881d92421467 201037_03
hgs
parents:
diff changeset
   155
            {
881d92421467 201037_03
hgs
parents:
diff changeset
   156
            BasicPinOperationL( aMessage );
881d92421467 201037_03
hgs
parents:
diff changeset
   157
            }
881d92421467 201037_03
hgs
parents:
diff changeset
   158
        else
881d92421467 201037_03
hgs
parents:
diff changeset
   159
	        	{
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   160
						RDEBUG("KErrNotSupported", KErrNotSupported);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   161
	          User::Leave( KErrNotSupported );
881d92421467 201037_03
hgs
parents:
diff changeset
   162
	          }
881d92421467 201037_03
hgs
parents:
diff changeset
   163
        }
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   164
    RDEBUG("0x99", 0x99);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   165
    }
881d92421467 201037_03
hgs
parents:
diff changeset
   166
881d92421467 201037_03
hgs
parents:
diff changeset
   167
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   168
// CSecuiDialogNotifierSession::IsOperationCancelled()
881d92421467 201037_03
hgs
parents:
diff changeset
   169
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   170
//
881d92421467 201037_03
hgs
parents:
diff changeset
   171
TBool CSecuiDialogNotifierSession::IsOperationCancelled( const RMessage2& aMessage )
881d92421467 201037_03
hgs
parents:
diff changeset
   172
    {
881d92421467 201037_03
hgs
parents:
diff changeset
   173
    TBool isCancelled = EFalse;
881d92421467 201037_03
hgs
parents:
diff changeset
   174
    if( aMessage.Function() == KSecuiDialogCancelOperation )
881d92421467 201037_03
hgs
parents:
diff changeset
   175
        {
881d92421467 201037_03
hgs
parents:
diff changeset
   176
        if( iOperationHandler )
881d92421467 201037_03
hgs
parents:
diff changeset
   177
            {
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   178
            RDEBUG("0", 0);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   179
            iOperationHandler->CancelOperation();
881d92421467 201037_03
hgs
parents:
diff changeset
   180
            }
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   181
        RDEBUG("completing aMessage.Handle()", aMessage.Handle());
59
881d92421467 201037_03
hgs
parents:
diff changeset
   182
        aMessage.Complete( KErrNone );
881d92421467 201037_03
hgs
parents:
diff changeset
   183
        isCancelled = ETrue;
881d92421467 201037_03
hgs
parents:
diff changeset
   184
        }
881d92421467 201037_03
hgs
parents:
diff changeset
   185
    return isCancelled;
881d92421467 201037_03
hgs
parents:
diff changeset
   186
    }
881d92421467 201037_03
hgs
parents:
diff changeset
   187
881d92421467 201037_03
hgs
parents:
diff changeset
   188
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   189
// CSecuiDialogNotifierSession::GetInputBufferL()
881d92421467 201037_03
hgs
parents:
diff changeset
   190
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   191
//
881d92421467 201037_03
hgs
parents:
diff changeset
   192
void CSecuiDialogNotifierSession::GetInputBufferL( const RMessage2& aMessage )
881d92421467 201037_03
hgs
parents:
diff changeset
   193
    {
881d92421467 201037_03
hgs
parents:
diff changeset
   194
    TInt inputLength = aMessage.GetDesLength( KInputParam );
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   195
    RDEBUG("inputLength", inputLength);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   196
    __ASSERT_ALWAYS( inputLength > 0, User::Leave( KErrCorrupt ) );
881d92421467 201037_03
hgs
parents:
diff changeset
   197
    if( iInputBuffer )
881d92421467 201037_03
hgs
parents:
diff changeset
   198
        {
881d92421467 201037_03
hgs
parents:
diff changeset
   199
        delete iInputBuffer;
881d92421467 201037_03
hgs
parents:
diff changeset
   200
        iInputBuffer = NULL;
881d92421467 201037_03
hgs
parents:
diff changeset
   201
        }
881d92421467 201037_03
hgs
parents:
diff changeset
   202
    iInputBuffer = HBufC8::NewL( inputLength );
881d92421467 201037_03
hgs
parents:
diff changeset
   203
    TPtr8 inputBufferPtr( iInputBuffer->Des() );
881d92421467 201037_03
hgs
parents:
diff changeset
   204
    aMessage.ReadL( KInputParam, inputBufferPtr );
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   205
    RDEBUG("0x99", 0x99);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   206
    }
881d92421467 201037_03
hgs
parents:
diff changeset
   207
881d92421467 201037_03
hgs
parents:
diff changeset
   208
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   209
// CSecuiDialogNotifierSession::ServerAuthenticationFailureL()
881d92421467 201037_03
hgs
parents:
diff changeset
   210
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   211
//
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   212
void CSecuiDialogNotifierSession::ServerAuthenticationFailureL( const RMessage2& /* aMessage */ )
59
881d92421467 201037_03
hgs
parents:
diff changeset
   213
    {
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   214
    RDEBUG("not used 0x99", 0x99);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   215
    }
881d92421467 201037_03
hgs
parents:
diff changeset
   216
881d92421467 201037_03
hgs
parents:
diff changeset
   217
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   218
// CSecuiDialogNotifierSession::BasicPinOperationL()
881d92421467 201037_03
hgs
parents:
diff changeset
   219
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   220
//
881d92421467 201037_03
hgs
parents:
diff changeset
   221
void CSecuiDialogNotifierSession::BasicPinOperationL( const RMessage2& aMessage )
881d92421467 201037_03
hgs
parents:
diff changeset
   222
    {
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   223
    RDEBUG("0", 0);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   224
    GetInputBufferL( aMessage );
881d92421467 201037_03
hgs
parents:
diff changeset
   225
881d92421467 201037_03
hgs
parents:
diff changeset
   226
    ASSERT( iOperationHandler == NULL );
881d92421467 201037_03
hgs
parents:
diff changeset
   227
    iOperationHandler = CBasicPinQueryOperation::NewL( *this, aMessage, KOutputParam );
881d92421467 201037_03
hgs
parents:
diff changeset
   228
    iOperationHandler->StartL( *iInputBuffer );
881d92421467 201037_03
hgs
parents:
diff changeset
   229
63
989397f9511c 201039_03
hgs
parents: 59
diff changeset
   230
    RDEBUG("0x99", 0x99);
59
881d92421467 201037_03
hgs
parents:
diff changeset
   231
    }
881d92421467 201037_03
hgs
parents:
diff changeset
   232