Commit 0fe2b36b194de71bf53c4f6c6ed94d0ecea53c58

  • avatar
  • timo <timo @pu…p.(none)>
  • Sat Oct 17 11:25:21 CEST 2009
Added functions to request enabling/disabling the accelerometer.
  
4040
4141private:
4242 void orientationUpdate(const QString& orientation, const QString& stand, const QString& face);
43 void enableAccelerometer();
44 void disableAccelerometer();
4345
4446private:
4547 bool m_listenForOrientationChanges;
5959 // Update current orientation to portrait/landscape if desired
6060 if (updateCurrentOrientation)
6161 {
62 enableAccelerometer();
63
6264 // Query current device orientation to start in correct mode
63 QDBusMessage msg = QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET);
65 QDBusMessage msg = QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
66 MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET);
6467
6568 // Ignore the last three arguments of the orientation information (x, y and z axis)
6669 QDBusConnection::systemBus().callWithCallback(msg, pub, SLOT(orientationUpdate(QString, QString, QString)));
7474{
7575 MAEMO_PUBLIC(QOrientationCapability);
7676 Maemo::setIntXProperty(qobject_cast<QWidget *>(pub->parent()), PORTRAIT_MODE_SUPPORT, 0);
77
78 //request to stop accelerometer
79 if(m_listenForOrientationChanges) {
80 disableAccelerometer();
81 }
7782}
7883
7984bool QOrientationCapabilityPrivate::islisteningOrientationChanges() const
9191 MAEMO_PUBLIC(QOrientationCapability);
9292
9393 if (listening)
94 {
94 {
95 enableAccelerometer();
96
9597 QDBusConnection::systemBus().connect("", MCE_SIGNAL_PATH, MCE_SIGNAL_IF,
9698 MCE_DEVICE_ORIENTATION_SIG, pub, SLOT(orientationUpdate(QString, QString, QString)));
9799 }
101101 {
102102 QDBusConnection::systemBus().disconnect("", MCE_SIGNAL_PATH, MCE_SIGNAL_IF,
103103 MCE_DEVICE_ORIENTATION_SIG, pub, SLOT(orientationUpdate(QString,QString,QString)));
104
105 disableAccelerometer();
104106 }
105107
106108 m_listenForOrientationChanges = listening;
145145QOrientation QOrientationCapabilityPrivate::currentOrientation() const
146146{
147147 return m_currentOrientation;
148}
149
150void QOrientationCapabilityPrivate::enableAccelerometer()
151{
152 QDBusConnection::systemBus().call(QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
153 MCE_REQUEST_IF, MCE_ACCELEROMETER_ENABLE_REQ));
154}
155
156void QOrientationCapabilityPrivate::disableAccelerometer()
157{
158 QDBusConnection::systemBus().call(QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
159 MCE_REQUEST_IF, MCE_ACCELEROMETER_DISABLE_REQ));
148160}
149161
150162