39 #include <aknlayoutscalable_avkon.cdl.h> |
39 #include <aknlayoutscalable_avkon.cdl.h> |
40 #include <touchfeedback.h> |
40 #include <touchfeedback.h> |
41 |
41 |
42 #include <AknTasHook.h> // for testability hooks |
42 #include <AknTasHook.h> // for testability hooks |
43 #include "AknHeadingPaneTouchObserver.h" |
43 #include "AknHeadingPaneTouchObserver.h" |
44 |
44 #include "akntrace.h" |
45 |
45 |
46 // CONSTANTS |
46 // CONSTANTS |
47 const TInt KMaxLinks = 64; |
47 const TInt KMaxLinks = 64; |
48 |
48 |
49 const TInt KLinkStartTagLength = 22; |
49 const TInt KLinkStartTagLength = 22; |
50 const TInt KLinkEndTagLength = 23; |
50 const TInt KLinkEndTagLength = 23; |
51 const TInt KBoldStartTagLength = 22; |
51 const TInt KBoldStartTagLength = 22; |
52 const TInt KBoldEndTagLength = 23; |
52 const TInt KBoldEndTagLength = 23; |
53 |
53 |
|
54 NONSHARABLE_CLASS(CAknAsynCallbackRunner) : public CActive |
|
55 { |
|
56 public: |
|
57 CAknAsynCallbackRunner( CAknMessageQueryDialogExtension* aMsgQueryExtension ); |
|
58 ~CAknAsynCallbackRunner(); |
|
59 |
|
60 public: |
|
61 // new functions |
|
62 void AsyncCallbackRunL( TInt aCurLink ); |
|
63 |
|
64 // from CActive |
|
65 void DoCancel(); |
|
66 void RunL(); |
|
67 |
|
68 private: |
|
69 CAknMessageQueryDialogExtension* iMsgQueryExtension; |
|
70 TInt iCurLink; |
|
71 }; |
54 |
72 |
55 class CAknMessageQueryDialogExtension : public CBase, public CAknExtendedInputCapabilities::MAknEventObserver, |
73 class CAknMessageQueryDialogExtension : public CBase, public CAknExtendedInputCapabilities::MAknEventObserver, |
56 public MAknHeadingPaneTouchObserver |
74 public MAknHeadingPaneTouchObserver |
57 { |
75 { |
58 public: |
76 public: |
59 CAknMessageQueryDialogExtension( CAknMessageQueryDialog* aParent ) : iParent(aParent), |
77 CAknMessageQueryDialogExtension( CAknMessageQueryDialog* aParent ) : iParent(aParent), |
60 iControlRegisted( EFalse ) {} |
78 iControlRegisted( EFalse ) {} |
61 ~CAknMessageQueryDialogExtension() |
79 ~CAknMessageQueryDialogExtension() |
62 { |
80 { |
|
81 delete iAsyncCallbackRunner; |
63 TInt count = iFormatTextArray.Count(); |
82 TInt count = iFormatTextArray.Count(); |
64 for ( TInt i = 0; i < count; i++ ) |
83 for ( TInt i = 0; i < count; i++ ) |
65 { |
84 { |
66 delete iFormatTextArray[i]; |
85 delete iFormatTextArray[i]; |
67 } |
86 } |
68 iCallBackArray.Close(); |
87 iCallBackArray.Close(); |
69 iFormatTextLocationArray.Close(); |
88 iFormatTextLocationArray.Close(); |
70 iFormatTextArray.Close(); |
89 iFormatTextArray.Close(); |
71 iFormatTypeArray.Close(); |
90 iFormatTypeArray.Close(); |
72 |
|
73 if ( iDestroyedPtr ) |
|
74 { |
|
75 // Mark the object as destroyed. |
|
76 *iDestroyedPtr = ETrue; |
|
77 iDestroyedPtr = NULL; |
|
78 } |
|
79 } |
91 } |
80 |
92 |
81 /** From CAknExtendedInputCapabilities::MAknEventObserver |
93 /** From CAknExtendedInputCapabilities::MAknEventObserver |
82 */ |
94 */ |
83 void HandleInputCapabilitiesEventL( TInt aEvent, TAny* aParams ) |
95 void HandleInputCapabilitiesEventL( TInt aEvent, TAny* aParams ) |
112 TInt iLinkCount; // values between 0 and KMaxLinks-1 |
133 TInt iLinkCount; // values between 0 and KMaxLinks-1 |
113 TBool iMarkedLinks; |
134 TBool iMarkedLinks; |
114 TInt iButtonGroupPreviouslyChanged; |
135 TInt iButtonGroupPreviouslyChanged; |
115 CAknMessageQueryDialog* iParent; |
136 CAknMessageQueryDialog* iParent; |
116 TBool iControlRegisted; |
137 TBool iControlRegisted; |
117 CAknMessageQueryControl* iCtrl; |
138 CAknMessageQueryControl* iCtrl; |
118 |
139 |
119 /** |
|
120 * @c iDestroyedPtr is used for the object destruction check. |
|
121 * If it has non-null value, the destruction check is turned on, and |
|
122 * the value points to a local boolean variable that keeps the destroyed state. |
|
123 */ |
|
124 TBool* iDestroyedPtr; |
|
125 TBool iIsInEditor; |
140 TBool iIsInEditor; |
|
141 |
|
142 CAknAsynCallbackRunner* iAsyncCallbackRunner; |
126 }; |
143 }; |
|
144 |
|
145 CAknAsynCallbackRunner::CAknAsynCallbackRunner( |
|
146 CAknMessageQueryDialogExtension* aMsgQueryExtension ) : |
|
147 CActive( EPriorityStandard ), iMsgQueryExtension( aMsgQueryExtension ) |
|
148 { |
|
149 CActiveScheduler::Add( this ); |
|
150 } |
|
151 |
|
152 CAknAsynCallbackRunner::~CAknAsynCallbackRunner() |
|
153 { |
|
154 Cancel(); |
|
155 } |
|
156 |
|
157 void CAknAsynCallbackRunner::AsyncCallbackRunL( TInt aCurLink ) |
|
158 { |
|
159 iCurLink = aCurLink; |
|
160 if ( !IsActive() ) |
|
161 { |
|
162 iStatus = KRequestPending; |
|
163 TRequestStatus* status = &iStatus; |
|
164 User::RequestComplete( status, KErrNone ); |
|
165 SetActive(); |
|
166 } |
|
167 } |
|
168 |
|
169 void CAknAsynCallbackRunner::DoCancel() |
|
170 { |
|
171 } |
|
172 |
|
173 void CAknAsynCallbackRunner::RunL() |
|
174 { |
|
175 if ( iMsgQueryExtension && iCurLink >= 0 && |
|
176 iCurLink < iMsgQueryExtension->iCallBackArray.Count() ) |
|
177 { |
|
178 iMsgQueryExtension->iCallBackArray[iCurLink].CallBack(); |
|
179 } |
|
180 } |
127 |
181 |
128 |
182 |
129 EXPORT_C CAknMessageQueryDialog* CAknMessageQueryDialog::NewL( TDesC& aMessage, const TTone& aTone ) |
183 EXPORT_C CAknMessageQueryDialog* CAknMessageQueryDialog::NewL( TDesC& aMessage, const TTone& aTone ) |
130 { |
184 { |
|
185 _AKNTRACE_FUNC_ENTER; |
131 CAknMessageQueryDialog* self = new ( ELeave ) CAknMessageQueryDialog( aTone ); |
186 CAknMessageQueryDialog* self = new ( ELeave ) CAknMessageQueryDialog( aTone ); |
132 CleanupStack::PushL( self ); |
187 CleanupStack::PushL( self ); |
133 self->SetMessageTextL( aMessage ); |
188 self->SetMessageTextL( aMessage ); |
134 CleanupStack::Pop(); //self |
189 CleanupStack::Pop(); //self |
135 AKNTASHOOK_ADDL( self, "CAknMessageQueryDialog" ); |
190 AKNTASHOOK_ADDL( self, "CAknMessageQueryDialog" ); |
|
191 _AKNTRACE_FUNC_EXIT; |
136 return self; |
192 return self; |
137 } |
193 } |
138 |
194 |
139 //@deprecated |
195 //@deprecated |
140 EXPORT_C CAknMessageQueryDialog::CAknMessageQueryDialog() : CAknQueryDialog( ENoTone ) |
196 EXPORT_C CAknMessageQueryDialog::CAknMessageQueryDialog() : CAknQueryDialog( ENoTone ) |
146 #endif |
202 #endif |
147 } |
203 } |
148 |
204 |
149 EXPORT_C CAknMessageQueryDialog::CAknMessageQueryDialog( const TTone aTone ) : CAknQueryDialog( aTone ) |
205 EXPORT_C CAknMessageQueryDialog::CAknMessageQueryDialog( const TTone aTone ) : CAknQueryDialog( aTone ) |
150 { |
206 { |
|
207 _AKNTRACE_FUNC_ENTER; |
151 #ifndef RD_NO_DIALOG_BORDERS |
208 #ifndef RD_NO_DIALOG_BORDERS |
152 iBorder = AknBorderId::EAknBorderNotePopup; |
209 iBorder = AknBorderId::EAknBorderNotePopup; |
153 #else |
210 #else |
154 iBorder = TGulBorder::ENone; |
211 iBorder = TGulBorder::ENone; |
155 #endif |
212 #endif |
|
213 _AKNTRACE_FUNC_EXIT; |
156 } |
214 } |
157 |
215 |
158 //@deprecated |
216 //@deprecated |
159 EXPORT_C CAknMessageQueryDialog::CAknMessageQueryDialog( TDesC* aMessage, TDesC* aHeader ) |
217 EXPORT_C CAknMessageQueryDialog::CAknMessageQueryDialog( TDesC* aMessage, TDesC* aHeader ) |
160 : CAknQueryDialog( ENoTone ), iMessage( aMessage ), iHeader( aHeader ) |
218 : CAknQueryDialog( ENoTone ), iMessage( aMessage ), iHeader( aHeader ) |
199 #endif |
257 #endif |
200 } |
258 } |
201 |
259 |
202 EXPORT_C CAknMessageQueryDialog::~CAknMessageQueryDialog() |
260 EXPORT_C CAknMessageQueryDialog::~CAknMessageQueryDialog() |
203 { |
261 { |
|
262 _AKNTRACE( "[%s][%s] Enter", "CAknMessageQueryDialog", "~CAknMessageQueryDialog" ); |
204 AKNTASHOOK_REMOVE(); |
263 AKNTASHOOK_REMOVE(); |
205 delete iMessage; |
264 delete iMessage; |
206 delete iHeader; |
265 delete iHeader; |
207 delete iHeaderImage; |
266 delete iHeaderImage; |
208 RegisterPointerEventObserver( EFalse ); |
267 RegisterPointerEventObserver( EFalse ); |
209 delete iMsgQueryExtension; |
268 delete iMsgQueryExtension; |
|
269 _AKNTRACE( "[%s][%s] Exit", "CAknMessageQueryDialog", "~CAknMessageQueryDialog" ); |
210 } |
270 } |
211 |
271 |
212 EXPORT_C void CAknMessageQueryDialog::SetMessageTextL( const TDesC& aMessage ) |
272 EXPORT_C void CAknMessageQueryDialog::SetMessageTextL( const TDesC& aMessage ) |
213 { |
273 { |
214 delete iMessage; |
274 delete iMessage; |
240 iMsgQueryExtension->iFormatTextArray[lastIndex] = aLinkText.AllocL(); |
300 iMsgQueryExtension->iFormatTextArray[lastIndex] = aLinkText.AllocL(); |
241 } |
301 } |
242 else |
302 else |
243 { |
303 { |
244 // SetLinkTextL creates new callback in the callback array for the new link |
304 // SetLinkTextL creates new callback in the callback array for the new link |
245 iMsgQueryExtension->iFormatTextArray.Append( aLinkText.AllocL() ); |
305 HBufC* linkText = aLinkText.AllocL(); |
246 iMsgQueryExtension->iFormatTypeArray.Append( EMsgQueryLink ); |
306 CleanupStack::PushL( linkText ); |
|
307 iMsgQueryExtension->iFormatTextArray.AppendL( linkText ); |
|
308 CleanupStack::Pop( linkText ); |
|
309 iMsgQueryExtension->iFormatTypeArray.AppendL( EMsgQueryLink ); |
247 |
310 |
248 // If the other method SetLink has been already called |
311 // If the other method SetLink has been already called |
249 // the new link is finished by adding the link count |
312 // the new link is finished by adding the link count |
250 if ( iMsgQueryExtension->iCallBackArray.Count() > iMsgQueryExtension->iLinkCount ) |
313 if ( iMsgQueryExtension->iCallBackArray.Count() > iMsgQueryExtension->iLinkCount ) |
251 { |
314 { |
284 if ( iMsgQueryExtension->iMarkedLinks ) |
347 if ( iMsgQueryExtension->iMarkedLinks ) |
285 { |
348 { |
286 if ( iMsgQueryExtension->iCallBackArray.Count() < iMsgQueryExtension->iLinkCount ) |
349 if ( iMsgQueryExtension->iCallBackArray.Count() < iMsgQueryExtension->iLinkCount ) |
287 { |
350 { |
288 // SetLink creates new callback in the callback array for the new link |
351 // SetLink creates new callback in the callback array for the new link |
289 iMsgQueryExtension->iCallBackArray.Append( aCallBack ); |
352 if ( KErrNone != iMsgQueryExtension->iCallBackArray.Append( aCallBack ) ) |
|
353 { |
|
354 return; |
|
355 } |
290 } |
356 } |
291 } |
357 } |
292 else if ( iMsgQueryExtension->iLinkCount < KMaxLinks ) |
358 else if ( iMsgQueryExtension->iLinkCount < KMaxLinks ) |
293 { |
359 { |
294 if ( iMsgQueryExtension->iCallBackArray.Count() > iMsgQueryExtension->iLinkCount ) |
360 if ( iMsgQueryExtension->iCallBackArray.Count() > iMsgQueryExtension->iLinkCount ) |
297 iMsgQueryExtension->iCallBackArray[iMsgQueryExtension->iCallBackArray.Count()-1] = aCallBack; |
363 iMsgQueryExtension->iCallBackArray[iMsgQueryExtension->iCallBackArray.Count()-1] = aCallBack; |
298 } |
364 } |
299 else |
365 else |
300 { |
366 { |
301 // SetLink creates new callback in the callback array for the new link |
367 // SetLink creates new callback in the callback array for the new link |
302 iMsgQueryExtension->iCallBackArray.Append( aCallBack ); |
368 if ( KErrNone != iMsgQueryExtension->iCallBackArray.Append( aCallBack ) ) |
|
369 { |
|
370 return; |
|
371 } |
303 |
372 |
304 // If the other method SetLinkText has been already called |
373 // If the other method SetLinkText has been already called |
305 // the new link is finished by adding the link count |
374 // the new link is finished by adding the link count |
306 |
375 |
307 if ( LinksInArray() > iMsgQueryExtension->iLinkCount ) |
376 if ( LinksInArray() > iMsgQueryExtension->iLinkCount ) |
984 * the link execution. |
1055 * the link execution. |
985 */ |
1056 */ |
986 |
1057 |
987 TBool CAknMessageQueryDialog::ExecuteLinkL() |
1058 TBool CAknMessageQueryDialog::ExecuteLinkL() |
988 { |
1059 { |
989 CAknMessageQueryControl* control = STATIC_CAST( CAknMessageQueryControl*, Control( EAknMessageQueryContentId ) ); |
1060 _AKNTRACE_FUNC_ENTER; |
|
1061 CAknMessageQueryControl* control = STATIC_CAST( CAknMessageQueryControl*, Control( EAknMessageQueryContentId ) ); |
990 if( !control ) |
1062 if( !control ) |
991 { |
1063 { |
|
1064 _AKNTRACE_FUNC_EXIT; |
992 return EFalse; |
1065 return EFalse; |
993 } |
1066 } |
994 if( !control->LinkHighLighted() ) |
1067 if( !control->LinkHighLighted() ) |
995 { |
1068 { |
|
1069 _AKNTRACE_FUNC_EXIT; |
996 return EFalse; |
1070 return EFalse; |
997 } |
1071 } |
998 TInt curLink = control->CurrentLink(); |
1072 TInt curLink = control->CurrentLink(); |
999 /** |
1073 TRAP_IGNORE( iMsgQueryExtension->ExecuteLinkCallbackL( curLink ) ); |
1000 * The local @c destroyed variable keeps track of the object destroyed state. |
1074 control->DehighlightLink(); |
1001 */ |
1075 _AKNTRACE_FUNC_EXIT; |
1002 TBool destroyed = EFalse; |
|
1003 iMsgQueryExtension->iDestroyedPtr = &destroyed; |
|
1004 TRAPD( err, iMsgQueryExtension->iCallBackArray[curLink].CallBack() ); |
|
1005 if ( !destroyed ) |
|
1006 { |
|
1007 iMsgQueryExtension->iDestroyedPtr = NULL; |
|
1008 } |
|
1009 User::LeaveIfError( err ); |
|
1010 if ( !destroyed ) |
|
1011 { |
|
1012 control->DehighlightLink(); |
|
1013 } |
|
1014 return ETrue; |
1076 return ETrue; |
1015 } |
1077 } |
1016 |
1078 |
1017 // End of File |
1079 // End of File |