35 // CSecuiDialogs::~CSecuiDialogs() |
35 // CSecuiDialogs::~CSecuiDialogs() |
36 // --------------------------------------------------------------------------- |
36 // --------------------------------------------------------------------------- |
37 // |
37 // |
38 CSecuiDialogs::~CSecuiDialogs() |
38 CSecuiDialogs::~CSecuiDialogs() |
39 { |
39 { |
40 TRACE( "CSecuiDialogs::~CSecuiDialogs, begin" ); |
40 RDEBUG("0", 0); |
41 Cancel(); |
41 Cancel(); |
42 iServer.Close(); |
42 iServer.Close(); |
43 delete iInputBuffer; |
43 delete iInputBuffer; |
44 iInputBuffer = NULL; |
44 iInputBuffer = NULL; |
45 delete iOutputBuffer; |
45 delete iOutputBuffer; |
46 iOutputBuffer = NULL; |
46 iOutputBuffer = NULL; |
47 iIsDeleted = ETrue; |
47 iIsDeleted = ETrue; |
48 TRACE( "CSecuiDialogs::~CSecuiDialogs, end" ); |
48 RDEBUG("0x99", 0x99); |
49 } |
49 } |
50 |
50 |
51 // --------------------------------------------------------------------------- |
51 // --------------------------------------------------------------------------- |
52 // CSecuiDialogs::StartLD() |
52 // CSecuiDialogs::StartLD() |
53 // --------------------------------------------------------------------------- |
53 // --------------------------------------------------------------------------- |
54 // |
54 // |
55 void CSecuiDialogs::StartLD( const TDesC8& aBuffer, TInt aReplySlot, |
55 void CSecuiDialogs::StartLD( const TDesC8& aBuffer, TInt aReplySlot, |
56 const RMessagePtr2& aMessage ) |
56 const RMessagePtr2& aMessage ) |
57 { |
57 { |
58 TRACE( "CSecuiDialogs::StartLD, begin" ); |
58 RDEBUG("0", 0); |
59 User::LeaveIfError( iServer.Connect() ); |
59 User::LeaveIfError( iServer.Connect() ); |
60 |
60 |
61 const TInt* ptr = reinterpret_cast< const TInt* >( aBuffer.Ptr() ); |
61 const TInt* ptr = reinterpret_cast< const TInt* >( aBuffer.Ptr() ); |
62 iOperation = static_cast< TSecurityDialogOperation >( *ptr & KSecurityDialogOperationMask ); |
62 iOperation = static_cast< TSecurityDialogOperation >( *ptr & KSecurityDialogOperationMask ); |
63 iReplySlot = aReplySlot; |
63 iReplySlot = aReplySlot; |
64 TRACE( "CSecuiDialogs::StartLD, iReplySlot 0x%08x", iReplySlot ); |
64 RDEBUG("iReplySlot", iReplySlot); |
65 |
65 |
66 TRACE( "CSecuiDialogs::StartLD, message 0x%08x", iMessagePtr.Handle() ); |
66 RDEBUG("iMessagePtr.Handle()", iMessagePtr.Handle()); |
67 iMessagePtr = aMessage; |
67 iMessagePtr = aMessage; |
68 |
68 |
69 TRACE( "CSecuiDialogs::StartLD, iOperation=%d", iOperation ); |
69 RDEBUG("iOperation", iOperation); |
70 |
70 |
71 TSecurityNotificationPckg pckg; |
71 TSecurityNotificationPckg pckg; |
72 pckg.Copy( aBuffer ); |
72 pckg.Copy( aBuffer ); |
73 TRACE( "CSecuiDialogs::StartLD, Copy=%d", 1 ); |
73 RDEBUG("0", 0); |
74 TInt iStartup = pckg().iStartup; |
74 TInt iStartup = pckg().iStartup; |
75 TRACE( "CSecuiDialogs::StartLD, iStartup=%d", iStartup ); |
75 RDEBUG("iStartup", iStartup); |
76 TInt iEvent = pckg().iEvent; |
76 TInt iEvent = pckg().iEvent; |
77 TRACE( "CSecuiDialogs::StartLD, iEvent=%d", iEvent ); |
77 RDEBUG("iEvent", iEvent); |
78 TInt lOperation = 0x0000; |
78 TInt lOperation = 0x0000; |
79 if(iStartup) |
79 if(iStartup) |
80 lOperation = 0x1000; |
80 lOperation = 0x1000; |
81 lOperation += iEvent; |
81 lOperation += iEvent; |
82 iOperation = static_cast< TSecurityDialogOperation >( lOperation ); |
82 iOperation = static_cast< TSecurityDialogOperation >( lOperation ); |
83 TRACE( "CSecuiDialogs::StartLD, new iOperation=%d", iOperation ); |
83 RDEBUG("new iOperation", iOperation); |
84 |
84 |
85 __ASSERT_DEBUG( iOutputBuffer == NULL, User::Invariant() ); |
85 __ASSERT_DEBUG( iOutputBuffer == NULL, User::Invariant() ); |
86 TInt outputBufLen = 0; |
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 |
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 { |
88 { |
89 iOutputBuffer = new( ELeave ) TPINValueBuf; |
89 iOutputBuffer = new( ELeave ) TPINValueBuf; |
90 outputBufLen = sizeof( TPINValueBuf ); |
90 outputBufLen = sizeof( TPINValueBuf ); |
91 } |
91 } |
92 else |
92 else |
93 { |
93 { |
94 TRACE( "CSecuiDialogs::StartLD, not allowed iOperation =%d", iOperation ); |
94 RDEBUG("not allowed iOperation", iOperation); |
95 User::Leave( KErrNotSupported ); |
95 User::Leave( KErrNotSupported ); |
96 } |
96 } |
97 |
97 |
98 __ASSERT_DEBUG( iInputBuffer == NULL, User::Invariant() ); |
98 __ASSERT_DEBUG( iInputBuffer == NULL, User::Invariant() ); |
99 iInputBuffer = aBuffer.AllocL(); |
99 iInputBuffer = aBuffer.AllocL(); |
100 |
100 |
101 if( iOutputBuffer ) |
101 if( iOutputBuffer ) |
102 { |
102 { |
103 TRACE( "CSecuiDialogs::StartLD, iOutputPtr.Set outputBufLen=%d", outputBufLen ); |
103 RDEBUG("outputBufLen", outputBufLen); |
104 iOutputPtr.Set( static_cast< TUint8* >( iOutputBuffer ), outputBufLen, outputBufLen ); |
104 iOutputPtr.Set( static_cast< TUint8* >( iOutputBuffer ), outputBufLen, outputBufLen ); |
105 iServer.SecuiDialogOperation( iOperation, *iInputBuffer, iOutputPtr, iStatus ); |
105 iServer.SecuiDialogOperation( iOperation, *iInputBuffer, iOutputPtr, iStatus ); |
106 } |
106 } |
107 else |
107 else |
108 { |
108 { |
109 TRACE( "CSecuiDialogs::StartLD, Leave KErrNotSupported=%d", KErrNotSupported ); |
109 RDEBUG("KErrNotSupported", KErrNotSupported); |
110 User::Leave( KErrNotSupported ); |
110 User::Leave( KErrNotSupported ); |
111 } |
111 } |
112 SetActive(); |
112 SetActive(); |
113 TRACE( "CSecuiDialogs::StartLD, end" ); |
113 RDEBUG("0x99", 0x99); |
114 } |
114 } |
115 |
115 |
116 // --------------------------------------------------------------------------- |
116 // --------------------------------------------------------------------------- |
117 // CSecuiDialogs::RunL() |
117 // CSecuiDialogs::RunL() |
118 // --------------------------------------------------------------------------- |
118 // --------------------------------------------------------------------------- |
119 // |
119 // |
120 void CSecuiDialogs::RunL() |
120 void CSecuiDialogs::RunL() |
121 { |
121 { |
122 TRACE( "CSecuiDialogs::RunL, iStatus.Int()=%d", iStatus.Int() ); |
122 RDEBUG("0", 0); |
123 TInt error = iStatus.Int(); |
123 TInt error = iStatus.Int(); |
|
124 RDEBUG("error", error); |
124 User::LeaveIfError( error ); |
125 User::LeaveIfError( error ); |
125 __ASSERT_DEBUG( iOutputPtr.Ptr(), User::Invariant() ); |
126 __ASSERT_DEBUG( iOutputPtr.Ptr(), User::Invariant() ); |
126 TRACE( "CSecuiDialogs::RunL, calling iMessagePtr.WriteL" ); |
127 RDEBUG("iReplySlot", iReplySlot); |
127 TRACE( "CSecuiDialogs::RunL, iReplySlot 0x%08x", iReplySlot ); |
|
128 TInt maxx = iMessagePtr.GetDesMaxLength(iReplySlot); |
128 TInt maxx = iMessagePtr.GetDesMaxLength(iReplySlot); |
129 TRACE( "CSecuiDialogs::RunL, maxx 0x%08x", maxx ); |
129 RDEBUG("maxx", maxx); |
130 TInt curr = iMessagePtr.GetDesLength(iReplySlot); |
130 TInt curr = iMessagePtr.GetDesLength(iReplySlot); |
131 TRACE( "CSecuiDialogs::RunL, curr 2 0x%08x", curr ); |
131 RDEBUG("curr", curr); |
132 // no need to copy. Besides, it seems to crash because it's too long |
132 // no need to copy. Besides, it seems to crash because it's too long |
133 // iMessagePtr.WriteL( iReplySlot, iOutputPtr ); |
133 // iMessagePtr.WriteL( iReplySlot, iOutputPtr ); |
134 TRACE( "CSecuiDialogs::RunL, called iMessagePtr.WriteL" ); |
134 RDEBUG("not called WriteL", 0); |
135 |
135 |
136 TRACE( "CSecuiDialogs::RunL, completing message 0x%08x", iMessagePtr.Handle() ); |
136 RDEBUG("completing iMessagePtr.Handle()", iMessagePtr.Handle()); |
137 iMessagePtr.Complete( error ); |
137 iMessagePtr.Complete( error ); |
138 |
138 |
139 TRACE( "CSecuiDialogs::RunL, deleting this" ); |
139 RDEBUG("0", 0); |
140 delete this; |
140 delete this; |
141 TRACE( "CSecuiDialogs::RunL, end" ); |
141 RDEBUG("0x99", 0x99); |
142 } |
142 } |
143 |
143 |
144 // --------------------------------------------------------------------------- |
144 // --------------------------------------------------------------------------- |
145 // CSecuiDialogs::DoCancel() |
145 // CSecuiDialogs::DoCancel() |
146 // --------------------------------------------------------------------------- |
146 // --------------------------------------------------------------------------- |
147 // |
147 // |
148 void CSecuiDialogs::DoCancel() |
148 void CSecuiDialogs::DoCancel() |
149 { |
149 { |
150 TRACE( "CSecuiDialogs::DoCancel, begin" ); |
150 RDEBUG("0", 0); |
151 iServer.CancelOperation(); |
151 iServer.CancelOperation(); |
152 if( !iMessagePtr.IsNull() ) |
152 if( !iMessagePtr.IsNull() ) |
153 { |
153 { |
154 TRACE( "CSecuiDialogs::DoCancel, completing message 0x%08x", iMessagePtr.Handle() ); |
154 RDEBUG("completing iMessagePtr.Handle()", iMessagePtr.Handle()); |
155 iMessagePtr.Complete( KErrCancel ); |
155 iMessagePtr.Complete( KErrCancel ); |
156 } |
156 } |
157 TRACE( "CSecuiDialogs::DoCancel(), end" ); |
157 RDEBUG("0x99", 0x99); |
158 } |
158 } |
159 |
159 |
160 // --------------------------------------------------------------------------- |
160 // --------------------------------------------------------------------------- |
161 // CSecuiDialogs::RunError() |
161 // CSecuiDialogs::RunError() |
162 // --------------------------------------------------------------------------- |
162 // --------------------------------------------------------------------------- |
163 // |
163 // |
164 TInt CSecuiDialogs::RunError( TInt aError ) |
164 TInt CSecuiDialogs::RunError( TInt aError ) |
165 { |
165 { |
166 TRACE( "CSecuiDialogs::RunError, aError=%d", aError ); |
166 RDEBUG("aError", aError); |
167 if( !iMessagePtr.IsNull() ) |
167 if( !iMessagePtr.IsNull() ) |
168 { |
168 { |
169 TRACE( "CSecuiDialogs::RunError, completing message 0x%08x", iMessagePtr.Handle() ); |
169 RDEBUG("completing iMessagePtr.Handle()", iMessagePtr.Handle()); |
170 iMessagePtr.Complete( aError ); |
170 iMessagePtr.Complete( aError ); |
171 } |
171 } |
172 |
172 |
173 TRACE( "CSecuiDialogs::RunError, deleting this" ); |
173 RDEBUG("0", 0); |
174 delete this; |
174 delete this; |
175 |
175 |
176 TRACE( "CSecuiDialogs::RunError, end" ); |
176 RDEBUG("0x99", 0x99); |
177 return KErrNone; |
177 return KErrNone; |
178 } |
178 } |
179 |
179 |
180 // --------------------------------------------------------------------------- |
180 // --------------------------------------------------------------------------- |
181 // CSecuiDialogs::CSecuiDialogs() |
181 // CSecuiDialogs::CSecuiDialogs() |
182 // --------------------------------------------------------------------------- |
182 // --------------------------------------------------------------------------- |
183 // |
183 // |
184 CSecuiDialogs::CSecuiDialogs( TBool& aIsDeleted ) : CActive( CActive::EPriorityLow ), |
184 CSecuiDialogs::CSecuiDialogs( TBool& aIsDeleted ) : CActive( CActive::EPriorityLow ), |
185 iIsDeleted( aIsDeleted ), iOutputPtr( NULL, 0, 0 ) |
185 iIsDeleted( aIsDeleted ), iOutputPtr( NULL, 0, 0 ) |
186 { |
186 { |
187 TRACE( "CSecuiDialogs::CSecuiDialogs" ); |
187 RDEBUG("0", 0); |
188 CActiveScheduler::Add( this ); |
188 CActiveScheduler::Add( this ); |
189 iIsDeleted = EFalse; |
189 iIsDeleted = EFalse; |
190 } |
190 } |
191 |
191 |