59
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: CSecuiDialogs active object
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "secuidialogs.h" // CSecuiDialogs
|
|
19 |
#include "secuidialogstrace.h" // TRACE macro
|
|
20 |
|
|
21 |
#include <securitynotification.h>
|
|
22 |
|
|
23 |
// ======== MEMBER FUNCTIONS ========
|
|
24 |
|
|
25 |
// ---------------------------------------------------------------------------
|
|
26 |
// CSecuiDialogs::NewL()
|
|
27 |
// ---------------------------------------------------------------------------
|
|
28 |
//
|
|
29 |
CSecuiDialogs* CSecuiDialogs::NewL( TBool& aIsDeleted )
|
|
30 |
{
|
|
31 |
return new( ELeave ) CSecuiDialogs( aIsDeleted );
|
|
32 |
}
|
|
33 |
|
|
34 |
// ---------------------------------------------------------------------------
|
|
35 |
// CSecuiDialogs::~CSecuiDialogs()
|
|
36 |
// ---------------------------------------------------------------------------
|
|
37 |
//
|
|
38 |
CSecuiDialogs::~CSecuiDialogs()
|
|
39 |
{
|
|
40 |
TRACE( "CSecuiDialogs::~CSecuiDialogs, begin" );
|
|
41 |
Cancel();
|
|
42 |
iServer.Close();
|
|
43 |
delete iInputBuffer;
|
|
44 |
iInputBuffer = NULL;
|
|
45 |
delete iOutputBuffer;
|
|
46 |
iOutputBuffer = NULL;
|
|
47 |
iIsDeleted = ETrue;
|
|
48 |
TRACE( "CSecuiDialogs::~CSecuiDialogs, end" );
|
|
49 |
}
|
|
50 |
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
// CSecuiDialogs::StartLD()
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
void CSecuiDialogs::StartLD( const TDesC8& aBuffer, TInt aReplySlot,
|
|
56 |
const RMessagePtr2& aMessage )
|
|
57 |
{
|
|
58 |
TRACE( "CSecuiDialogs::StartLD, begin" );
|
|
59 |
User::LeaveIfError( iServer.Connect() );
|
|
60 |
|
|
61 |
const TInt* ptr = reinterpret_cast< const TInt* >( aBuffer.Ptr() );
|
|
62 |
iOperation = static_cast< TSecurityDialogOperation >( *ptr & KSecurityDialogOperationMask );
|
|
63 |
iReplySlot = aReplySlot;
|
|
64 |
TRACE( "CSecuiDialogs::StartLD, iReplySlot 0x%08x", iReplySlot );
|
|
65 |
|
|
66 |
TRACE( "CSecuiDialogs::StartLD, message 0x%08x", iMessagePtr.Handle() );
|
|
67 |
iMessagePtr = aMessage;
|
|
68 |
|
|
69 |
TRACE( "CSecuiDialogs::StartLD, iOperation=%d", iOperation );
|
|
70 |
|
|
71 |
TSecurityNotificationPckg pckg;
|
|
72 |
pckg.Copy( aBuffer );
|
|
73 |
TRACE( "CSecuiDialogs::StartLD, Copy=%d", 1 );
|
|
74 |
TInt iStartup = pckg().iStartup;
|
|
75 |
TRACE( "CSecuiDialogs::StartLD, iStartup=%d", iStartup );
|
|
76 |
TInt iEvent = pckg().iEvent;
|
|
77 |
TRACE( "CSecuiDialogs::StartLD, iEvent=%d", iEvent );
|
|
78 |
TInt lOperation = 0x0000;
|
|
79 |
if(iStartup)
|
|
80 |
lOperation = 0x1000;
|
|
81 |
lOperation += iEvent;
|
|
82 |
iOperation = static_cast< TSecurityDialogOperation >( lOperation );
|
|
83 |
TRACE( "CSecuiDialogs::StartLD, new iOperation=%d", iOperation );
|
|
84 |
|
|
85 |
__ASSERT_DEBUG( iOutputBuffer == NULL, User::Invariant() );
|
|
86 |
TInt outputBufLen = 0;
|
|
87 |
if( iEvent < 0x100 || iEvent == 0x106 /* from Autolock*/) // a simple test to prevent unknown codes. Nevertheless they will also be stopped later in case that no dialog can answer the request
|
|
88 |
{
|
|
89 |
iOutputBuffer = new( ELeave ) TPINValueBuf;
|
|
90 |
outputBufLen = sizeof( TPINValueBuf );
|
|
91 |
}
|
|
92 |
else
|
|
93 |
{
|
|
94 |
TRACE( "CSecuiDialogs::StartLD, not allowed iOperation =%d", iOperation );
|
|
95 |
User::Leave( KErrNotSupported );
|
|
96 |
}
|
|
97 |
|
|
98 |
__ASSERT_DEBUG( iInputBuffer == NULL, User::Invariant() );
|
|
99 |
iInputBuffer = aBuffer.AllocL();
|
|
100 |
|
|
101 |
if( iOutputBuffer )
|
|
102 |
{
|
|
103 |
TRACE( "CSecuiDialogs::StartLD, iOutputPtr.Set outputBufLen=%d", outputBufLen );
|
|
104 |
iOutputPtr.Set( static_cast< TUint8* >( iOutputBuffer ), outputBufLen, outputBufLen );
|
|
105 |
iServer.SecuiDialogOperation( iOperation, *iInputBuffer, iOutputPtr, iStatus );
|
|
106 |
}
|
|
107 |
else
|
|
108 |
{
|
|
109 |
TRACE( "CSecuiDialogs::StartLD, Leave KErrNotSupported=%d", KErrNotSupported );
|
|
110 |
User::Leave( KErrNotSupported );
|
|
111 |
}
|
|
112 |
SetActive();
|
|
113 |
TRACE( "CSecuiDialogs::StartLD, end" );
|
|
114 |
}
|
|
115 |
|
|
116 |
// ---------------------------------------------------------------------------
|
|
117 |
// CSecuiDialogs::RunL()
|
|
118 |
// ---------------------------------------------------------------------------
|
|
119 |
//
|
|
120 |
void CSecuiDialogs::RunL()
|
|
121 |
{
|
|
122 |
TRACE( "CSecuiDialogs::RunL, iStatus.Int()=%d", iStatus.Int() );
|
|
123 |
TInt error = iStatus.Int();
|
|
124 |
User::LeaveIfError( error );
|
|
125 |
__ASSERT_DEBUG( iOutputPtr.Ptr(), User::Invariant() );
|
|
126 |
TRACE( "CSecuiDialogs::RunL, calling iMessagePtr.WriteL" );
|
|
127 |
TRACE( "CSecuiDialogs::RunL, iReplySlot 0x%08x", iReplySlot );
|
|
128 |
TInt maxx = iMessagePtr.GetDesMaxLength(iReplySlot);
|
|
129 |
TRACE( "CSecuiDialogs::RunL, maxx 0x%08x", maxx );
|
|
130 |
TInt curr = iMessagePtr.GetDesLength(iReplySlot);
|
|
131 |
TRACE( "CSecuiDialogs::RunL, curr 2 0x%08x", curr );
|
|
132 |
// no need to copy. Besides, it seems to crash because it's too long
|
|
133 |
// iMessagePtr.WriteL( iReplySlot, iOutputPtr );
|
|
134 |
TRACE( "CSecuiDialogs::RunL, called iMessagePtr.WriteL" );
|
|
135 |
|
|
136 |
TRACE( "CSecuiDialogs::RunL, completing message 0x%08x", iMessagePtr.Handle() );
|
|
137 |
iMessagePtr.Complete( error );
|
|
138 |
|
|
139 |
TRACE( "CSecuiDialogs::RunL, deleting this" );
|
|
140 |
delete this;
|
|
141 |
TRACE( "CSecuiDialogs::RunL, end" );
|
|
142 |
}
|
|
143 |
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
// CSecuiDialogs::DoCancel()
|
|
146 |
// ---------------------------------------------------------------------------
|
|
147 |
//
|
|
148 |
void CSecuiDialogs::DoCancel()
|
|
149 |
{
|
|
150 |
TRACE( "CSecuiDialogs::DoCancel, begin" );
|
|
151 |
iServer.CancelOperation();
|
|
152 |
if( !iMessagePtr.IsNull() )
|
|
153 |
{
|
|
154 |
TRACE( "CSecuiDialogs::DoCancel, completing message 0x%08x", iMessagePtr.Handle() );
|
|
155 |
iMessagePtr.Complete( KErrCancel );
|
|
156 |
}
|
|
157 |
TRACE( "CSecuiDialogs::DoCancel(), end" );
|
|
158 |
}
|
|
159 |
|
|
160 |
// ---------------------------------------------------------------------------
|
|
161 |
// CSecuiDialogs::RunError()
|
|
162 |
// ---------------------------------------------------------------------------
|
|
163 |
//
|
|
164 |
TInt CSecuiDialogs::RunError( TInt aError )
|
|
165 |
{
|
|
166 |
TRACE( "CSecuiDialogs::RunError, aError=%d", aError );
|
|
167 |
if( !iMessagePtr.IsNull() )
|
|
168 |
{
|
|
169 |
TRACE( "CSecuiDialogs::RunError, completing message 0x%08x", iMessagePtr.Handle() );
|
|
170 |
iMessagePtr.Complete( aError );
|
|
171 |
}
|
|
172 |
|
|
173 |
TRACE( "CSecuiDialogs::RunError, deleting this" );
|
|
174 |
delete this;
|
|
175 |
|
|
176 |
TRACE( "CSecuiDialogs::RunError, end" );
|
|
177 |
return KErrNone;
|
|
178 |
}
|
|
179 |
|
|
180 |
// ---------------------------------------------------------------------------
|
|
181 |
// CSecuiDialogs::CSecuiDialogs()
|
|
182 |
// ---------------------------------------------------------------------------
|
|
183 |
//
|
|
184 |
CSecuiDialogs::CSecuiDialogs( TBool& aIsDeleted ) : CActive( CActive::EPriorityLow ),
|
|
185 |
iIsDeleted( aIsDeleted ), iOutputPtr( NULL, 0, 0 )
|
|
186 |
{
|
|
187 |
TRACE( "CSecuiDialogs::CSecuiDialogs" );
|
|
188 |
CActiveScheduler::Add( this );
|
|
189 |
iIsDeleted = EFalse;
|
|
190 |
}
|
|
191 |
|