Home | History | Annotate | Download | only in WebCoreSupport
      1 /*
      2  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
      3  *
      4  * This library is free software; you can redistribute it and/or
      5  * modify it under the terms of the GNU Library General Public
      6  * License as published by the Free Software Foundation; either
      7  * version 2 of the License, or (at your option) any later version.
      8  *
      9  * This library is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12  * Library General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU Library General Public License
     15  * along with this library; see the file COPYING.LIB.  If not, write to
     16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     17  * Boston, MA 02110-1301, USA.
     18  *
     19  */
     20 #include "config.h"
     21 #include "DeviceMotionClientQt.h"
     22 
     23 #include "DeviceMotionController.h"
     24 #include "DeviceMotionProviderQt.h"
     25 
     26 #include "qwebpage.h"
     27 
     28 namespace WebCore {
     29 
     30 DeviceMotionClientQt::DeviceMotionClientQt(QWebPage* page)
     31     : m_page(page)
     32     , m_controller(0)
     33     , m_provider(new DeviceMotionProviderQt())
     34 {
     35 
     36     connect(m_provider, SIGNAL(deviceMotionChanged()), SLOT(changeDeviceMotion()));
     37 }
     38 
     39 DeviceMotionClientQt::~DeviceMotionClientQt()
     40 {
     41     disconnect();
     42     delete m_provider;
     43 }
     44 
     45 void DeviceMotionClientQt::setController(DeviceMotionController* controller)
     46 {
     47     m_controller = controller;
     48 }
     49 
     50 void DeviceMotionClientQt::startUpdating()
     51 {
     52     m_provider->start();
     53 }
     54 
     55 void DeviceMotionClientQt::stopUpdating()
     56 {
     57     m_provider->stop();
     58 }
     59 
     60 DeviceMotionData* DeviceMotionClientQt::currentDeviceMotion() const
     61 {
     62     return m_provider->currentDeviceMotion();
     63 }
     64 
     65 void DeviceMotionClientQt::deviceMotionControllerDestroyed()
     66 {
     67     delete this;
     68 }
     69 
     70 void DeviceMotionClientQt::changeDeviceMotion()
     71 {
     72     if (!m_controller)
     73         return;
     74 
     75     m_controller->didChangeDeviceMotion(currentDeviceMotion());
     76 }
     77 
     78 } // namespace WebCore
     79 
     80 #include "moc_DeviceMotionClientQt.cpp"
     81