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