15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 // INCLUDE FILES |
19 // INCLUDE FILES |
20 #include <eikenv.h> // Eikon environment |
20 #include <hb/hbwidgets/hbdevicemessageboxsymbian.h> |
21 #include <aknnotedialog.h> |
21 #include <hb/hbcore/hbtextresolversymbian.h> |
22 #include <bautils.h> // BAFL utils (for language file) |
|
23 #include <StringLoader.h> // Localisation stringloader |
|
24 #include <AknMediatorFacade.h> // for cover display support |
|
25 #include <usbuinotif.rsg> // Own resources |
|
26 #include "usbuinotifotgwarning.h" // Own class definition |
22 #include "usbuinotifotgwarning.h" // Own class definition |
27 #include "usbuinotifdebug.h" // Debugging macros |
23 #include "usbuinotifdebug.h" // Debugging macros |
28 #include "usbuinotifsecondarydisplay.h" // Dialog index for cover UI |
24 |
|
25 |
|
26 // CONSTANTS |
|
27 /** granularity for allocating warning strings */ |
|
28 const TInt KUsbOtgWarningGranularity = 1; |
|
29 |
29 // ================= MEMBER FUNCTIONS ========================================= |
30 // ================= MEMBER FUNCTIONS ========================================= |
30 |
31 |
31 // ---------------------------------------------------------------------------- |
32 // ---------------------------------------------------------------------------- |
32 // CUsbUiNotifOtgWarning::NewL |
33 // CUsbUiNotifOtgWarning::NewL |
33 // Two-phased constructor. |
34 // Two-phased constructor. |
64 { |
65 { |
65 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::destructor()")); |
66 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::destructor()")); |
66 //Make sure that the request is completed. Note that inside the destructor, |
67 //Make sure that the request is completed. Note that inside the destructor, |
67 //this virtual function call is to local CUsbUiNotifOtgWarning::Cancel, |
68 //this virtual function call is to local CUsbUiNotifOtgWarning::Cancel, |
68 //not to any possibly derived class implementation. |
69 //not to any possibly derived class implementation. |
|
70 delete iStringIds; |
69 Cancel(); |
71 Cancel(); |
70 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::destructor completed()")); |
72 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::destructor completed()")); |
71 } |
73 } |
72 |
74 |
73 void CUsbUiNotifOtgWarning::ConstructL() |
75 void CUsbUiNotifOtgWarning::ConstructL() |
74 { |
76 { |
75 CUSBUINotifierBase::ConstructL(); |
77 CUSBUINotifierBase::ConstructL(); |
76 iStringIds.AppendL( R_USB_OTG_WARNING_PARTIAL_SUPPORT); |
78 iStringIds = new (ELeave) CDesCArrayFlat(KUsbOtgWarningGranularity); |
|
79 _LIT(KPartiallySupported, "txt_usb_info_partially_supported_usb_device_connec"); |
|
80 iStringIds->AppendL( KPartiallySupported); |
77 } |
81 } |
78 |
82 |
79 // ---------------------------------------------------------------------------- |
83 // ---------------------------------------------------------------------------- |
80 // CUsbUiNotifOtgWarning::RegisterL |
84 // CUsbUiNotifOtgWarning::RegisterL |
81 // Register notifier. |
85 // Register notifier. |
100 { |
104 { |
101 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel")); |
105 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel")); |
102 if (iNote) |
106 if (iNote) |
103 { |
107 { |
104 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel - delete iNote")); |
108 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel - delete iNote")); |
|
109 iNote->Close(); |
105 delete iNote; |
110 delete iNote; |
106 iNote = NULL; |
111 iNote = NULL; |
107 } |
112 } |
108 CompleteMessage( KErrNone ); |
113 CUSBUINotifierBase::Cancel(); |
109 |
114 |
110 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel() completed")); |
115 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel() completed")); |
111 } |
116 } |
112 |
117 |
113 // ---------------------------------------------------------------------------- |
118 // ---------------------------------------------------------------------------- |
114 // CUsbUiNotifOtgWarning::GetParamsL |
119 // CUsbUiNotifOtgWarning::GetParamsL |
115 // Mandatory for USB UI Notifiers when using asynchronous launch. |
120 // Mandatory for USB UI Notifiers when using asynchronous launch. |
116 // This notifier is synchronous so this function is not used. |
121 // This notifier is synchronous so this function is not used. |
117 // ---------------------------------------------------------------------------- |
122 // ---------------------------------------------------------------------------- |
118 // |
123 // |
119 void CUsbUiNotifOtgWarning::GetParamsL(const TDesC8& aBuffer, |
124 void CUsbUiNotifOtgWarning::StartDialogL(const TDesC8& aBuffer, |
120 TInt aReplySlot, const RMessagePtr2& aMessage) |
125 TInt aReplySlot, const RMessagePtr2& aMessage) |
121 { |
126 { |
122 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL")); |
127 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::StartDialogL")); |
123 if (iNote || iReplySlot != 0 || iNeedToCompleteMessage) |
128 if (iReplySlot != 0 || iNeedToCompleteMessage) |
124 { |
129 { |
125 User::Leave( KErrInUse ); |
130 User::Leave( KErrInUse ); |
126 } |
131 } |
|
132 |
|
133 InitializeTextResolver(); |
|
134 |
|
135 iMessage = aMessage; |
|
136 iNeedToCompleteMessage = ETrue; |
|
137 iReplySlot = aReplySlot; |
127 |
138 |
128 // Get parameters |
139 // Get parameters |
129 // |
140 // |
130 TPckgC<TInt> pckg( iNoteId ); |
141 TPckgC<TInt> pckg( iNoteId ); |
131 pckg.Set( aBuffer ); |
142 pckg.Set( aBuffer ); |
132 iNoteId = pckg(); |
143 iNoteId = pckg(); |
133 |
144 FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL iNoteId: %d"), iNoteId )); |
134 FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL iNoteId: %d"), iNoteId )); |
145 if ( iNoteId < 0 || iNoteId >= iStringIds->MdcaCount()) |
135 if ( iNoteId < 0 || iNoteId >= iStringIds.Count() ) |
|
136 { |
146 { |
137 User::Leave( KErrArgument); |
147 User::Leave( KErrArgument); |
138 } |
148 } |
139 |
149 if (iNote) |
140 iMessage = aMessage; |
150 { |
141 iNeedToCompleteMessage = ETrue; |
151 delete iNote; |
142 iReplySlot = aReplySlot; |
152 iNote = NULL; |
143 |
153 } |
144 SetActive(); |
154 |
145 iStatus = KRequestPending; |
155 iNote = CHbDeviceMessageBoxSymbian::NewL( |
146 TRequestStatus* stat = &iStatus; |
156 CHbDeviceMessageBoxSymbian::EWarning, this); |
147 User::RequestComplete( stat, KErrNone ); |
157 HBufC* stringHolder = HbTextResolverSymbian::LoadLC(iStringIds->MdcaPoint(iNoteId) ); |
148 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL() completed")); |
158 iNote->SetTextL(*stringHolder); |
|
159 iNote->ShowL(); |
|
160 CleanupStack::PopAndDestroy( stringHolder ); |
|
161 |
|
162 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::StartDialogL completed")); |
149 } |
163 } |
150 |
164 |
151 // ---------------------------------------------------------------------------- |
165 // ---------------------------------------------------------------------------- |
152 // CUsbUiNotifOtgWarning::RunL |
166 // Call back function to observe device message box closing. |
153 // Mandatory for Active Objects. This notifier is synchronous |
|
154 // so this function is not used. |
|
155 // ---------------------------------------------------------------------------- |
167 // ---------------------------------------------------------------------------- |
156 // |
168 // |
157 void CUsbUiNotifOtgWarning::RunL() |
169 void CUsbUiNotifOtgWarning::MessageBoxClosed( |
|
170 const CHbDeviceMessageBoxSymbian* /*aMessageBox*/, |
|
171 CHbDeviceMessageBoxSymbian::TButtonId aButton) |
158 { |
172 { |
159 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::RunL")); |
173 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed")); |
|
174 int returnValue = KErrNone; |
|
175 |
|
176 //iQuery will be deleted in Cancel. If Cancel is not called, it will be |
|
177 //deleted next time the query is shown. |
160 |
178 |
161 // Create confirmation note |
179 if (aButton == CHbDeviceMessageBoxSymbian::EAcceptButton) |
162 // |
|
163 HBufC* str = StringLoader::LoadL( iStringIds[iNoteId] ); |
|
164 CleanupStack::PushL( str ); |
|
165 iNote = new (ELeave) CAknWarningNote( ETrue ); |
|
166 |
|
167 iNote->SetTimeout( CAknNoteDialog::ENoTimeout ); |
|
168 |
|
169 if (iCoverDisplaySupported) |
|
170 { |
180 { |
171 iNote->PublishDialogL( iNoteId, KUsbUiNotifOtgWarning ); |
181 returnValue = KErrNone; |
|
182 } |
|
183 else |
|
184 { |
|
185 returnValue = KErrCancel; |
172 } |
186 } |
173 |
187 |
174 TInt t = iNote->ExecuteLD( *str ); |
188 CompleteMessage( returnValue ); |
175 iNote = NULL; |
189 |
176 CleanupStack::PopAndDestroy( str ); |
190 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed completed")); |
177 |
|
178 CompleteMessage( KErrNone ); |
|
179 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::RunL() completed")); |
|
180 } |
191 } |
181 |
192 |
182 // End of File |
193 // End of File |