30 #include <usbpersonalityids.h> |
30 #include <usbpersonalityids.h> |
31 |
31 |
32 #include <QMetaEnum> |
32 #include <QMetaEnum> |
33 #include <QString> |
33 #include <QString> |
34 #include <QVariant> |
34 #include <QVariant> |
|
35 #include <QTimer> |
35 #include <qsymbianevent.h> |
36 #include <qsymbianevent.h> |
36 |
37 |
37 #endif // Q_OS_SYMBIAN |
38 #endif // Q_OS_SYMBIAN |
38 |
39 |
39 #include "cxutils.h" |
40 #include "cxutils.h" |
40 #include "cxuieventlog.h" |
41 #include "cxuieventlog.h" |
41 #include "cxuiapplication.h" |
42 #include "cxuiapplication.h" |
42 #include "cxesettings.h" |
43 #include "cxesettings.h" |
43 #include "cxuiapplicationframeworkmonitorprivate.h" |
44 #include "cxuiapplicationframeworkmonitorprivate.h" |
44 |
45 |
|
46 namespace{ |
|
47 const int CXUI_USB_MODE_CHECK_TIMER_DELAY = 1000; // 1 second |
|
48 } |
45 |
49 |
46 #ifdef Q_OS_SYMBIAN |
50 #ifdef Q_OS_SYMBIAN |
47 namespace |
51 namespace |
48 { |
52 { |
49 inline QString convertTDesC2QString(const TDesC& aDescriptor) |
53 inline QString convertTDesC2QString(const TDesC& aDescriptor) |
108 mWindowGroupId(mWindowGroup.Identifier()), |
112 mWindowGroupId(mWindowGroup.Identifier()), |
109 mWindowGroupName(), |
113 mWindowGroupName(), |
110 mKeyLockState(EKeyguardNotActive), |
114 mKeyLockState(EKeyguardNotActive), |
111 mBatteryStatus(EBatteryStatusUnknown), |
115 mBatteryStatus(EBatteryStatusUnknown), |
112 mUsbPersonality(0), |
116 mUsbPersonality(0), |
|
117 mUsbModeCheckTimer(this), |
113 mEventLog(NULL), |
118 mEventLog(NULL), |
114 #endif // Q_OS_SYMBIAN |
119 #endif // Q_OS_SYMBIAN |
115 mState(CxuiApplicationFrameworkMonitor::ForegroundOwned) |
120 mState(CxuiApplicationFrameworkMonitor::ForegroundOwned) |
116 { |
121 { |
117 CX_DEBUG_ENTER_FUNCTION(); |
122 CX_DEBUG_ENTER_FUNCTION(); |
118 #ifdef Q_OS_SYMBIAN |
123 #ifdef Q_OS_SYMBIAN |
119 mWindowGroup.EnableFocusChangeEvents(); |
124 mWindowGroup.EnableFocusChangeEvents(); |
120 mWindowGroupName = windowGroupName(mWsSession, mWindowGroupId); |
125 mWindowGroupName = windowGroupName(mWsSession, mWindowGroupId); |
121 mEventLog = new CxuiEventLog("CxuiApplicationFrameworkMonitorPrivate"); |
126 mEventLog = new CxuiEventLog("CxuiApplicationFrameworkMonitorPrivate"); |
122 init(); |
127 init(); |
|
128 mUsbModeCheckTimer.setSingleShot(true); |
|
129 mUsbModeCheckTimer.setInterval(CXUI_USB_MODE_CHECK_TIMER_DELAY); |
|
130 connect(&mUsbModeCheckTimer, SIGNAL(timeout()), |
|
131 this, SLOT(usbModeCheckTimerCallback())); |
123 #endif // Q_OS_SYMBIAN |
132 #endif // Q_OS_SYMBIAN |
124 CX_DEBUG_EXIT_FUNCTION(); |
133 CX_DEBUG_EXIT_FUNCTION(); |
125 } |
134 } |
126 |
135 |
127 /*! |
136 /*! |
232 mEventLog->append(EVENT_USB, QString::number(mUsbPersonality)); |
241 mEventLog->append(EVENT_USB, QString::number(mUsbPersonality)); |
233 } |
242 } |
234 |
243 |
235 // Check if mass memory mode activity changed. |
244 // Check if mass memory mode activity changed. |
236 if (wasUsbMassMemoryModeActive != isUsbMassMemoryModeActive()) { |
245 if (wasUsbMassMemoryModeActive != isUsbMassMemoryModeActive()) { |
237 emit q->usbMassMemoryModeToggled(isUsbMassMemoryModeActive()); |
246 |
238 } |
247 // If the massmemory mode switched from on to off, |
239 } |
248 // the signal is emitted immediately. |
|
249 // If the switch is from off to on, we need to use a timer |
|
250 // as a workaround because plugging in the USB charger |
|
251 // sends a mass memory mode change event. |
|
252 if (wasUsbMassMemoryModeActive) { |
|
253 emit q->usbMassMemoryModeToggled(isUsbMassMemoryModeActive()); |
|
254 } else { |
|
255 // (Re)starting the timer |
|
256 mUsbModeCheckTimer.stop(); |
|
257 mUsbModeCheckTimer.start(); |
|
258 } |
|
259 |
|
260 } |
|
261 } |
|
262 } |
|
263 |
|
264 CX_DEBUG_EXIT_FUNCTION(); |
|
265 } |
|
266 |
|
267 /*! |
|
268 * Callback function for the timer used to seperate USB charging |
|
269 * from USB mass memory mode |
|
270 */ |
|
271 void CxuiApplicationFrameworkMonitorPrivate::usbModeCheckTimerCallback() |
|
272 { |
|
273 CX_DEBUG_ENTER_FUNCTION(); |
|
274 |
|
275 // if the device is still in mass memory mode after the timer has finished, |
|
276 // the device really is in massmemory mode and not plugged into the charger |
|
277 if (isUsbMassMemoryModeActive()){ |
|
278 emit q->usbMassMemoryModeToggled(isUsbMassMemoryModeActive()); |
240 } |
279 } |
241 |
280 |
242 CX_DEBUG_EXIT_FUNCTION(); |
281 CX_DEBUG_EXIT_FUNCTION(); |
243 } |
282 } |
244 |
283 |