sa_sensor_tap_qt.cpp

Go to the documentation of this file.
00001 #include "sa_sensor_tap_qt.hpp"
00002 #include "sa_sensor_tap_api.h"
00003 
00004 #include "er_errors.h"
00005 #include "ld_logging.h"
00006 #include "sa_sensor_list_log_db.h"
00007 
00008 // http://doc.qt.nokia.com/qtmobility-1.1.0/qtapsensor.html
00009 
00010 Sensor_tap::Sensor_tap(ac_AppContext* aAppContext,
00011            bool aDouble, const char* aName) :
00012   iAppContext(aAppContext), iDouble(aDouble), iName(aName)
00013 {
00014   // Whether we are interested in single or double taps.
00015   setProperty("returnDoubleTapEvents", aDouble);
00016 
00017   // Signals cannot be "overridden" directly like methods, but we can
00018   // connect to slots locally.
00019   connect(this, SIGNAL(activeChanged()), this, SLOT(handleActiveChanged()));
00020   connect(this, SIGNAL(busyChanged()), this, SLOT(handleBusyChanged()));
00021   connect(this, SIGNAL(readingChanged()), this, SLOT(handleReadingChanged()));
00022   connect(this, SIGNAL(sensorError(int)), this, SLOT(handleSensorError(int)));
00023 
00024   if (!isBusy())
00025     start();
00026 }
00027 
00028 /*
00029 Sensor_tap::~Sensor_tap()
00030 {
00031 }
00032 */
00033 
00034 void Sensor_tap::handleActiveChanged()
00035 {
00036   const char* status = (isActive() ? "activated" : "disactivated");
00037   log_db_log_status(GetLogDb(), NULL, 
00038         "STATUS: %s sensor %s", Name(), status);
00039 }
00040 
00041 void Sensor_tap::handleBusyChanged()
00042 {
00043   const char* status = (isBusy() ? "busy" : "available");
00044   log_db_log_status(GetLogDb(), NULL, 
00045         "STATUS: %s sensor hardware %s", Name(), status);
00046   if (!isActive() && !isBusy())
00047     start();
00048 }
00049 
00050 void Sensor_tap::handleReadingChanged()
00051 {
00052   QTapReading* data(reading()); // not owned
00053   if (data) {
00054     int dir = data->tapDirection();
00055     int isDbl = data->isDoubleTap();
00056     guilogf("%s: dir=%d (%s)", Name(),
00057       dir, isDbl ? "double" : "single");
00058     log_db_log_tap(GetLogDb(), dir, isDbl, NULL);
00059   }
00060 }
00061 
00062 void Sensor_tap::handleSensorError(int errCode)
00063 {
00064   log_db_log_status(GetLogDb(), NULL, 
00065         "ERROR: error in %s sensor: %d", 
00066         Name(), errCode);
00067 }
00068 
00069 Sensor_tap* new_Sensor_tap(ac_AppContext* aAppContext,
00070          bool aDouble, const char* aName)
00071 {
00072   return q_check_ptr(new Sensor_tap(aAppContext, aDouble, aName));
00073 }
00074 
00075 void delete_Sensor_tap(Sensor_tap* obj)
00076 {
00077   delete obj;
00078 }
00079 
00080 /**
00081 
00082 Copyright 2010 Helsinki Institute for Information Technology (HIIT)
00083 and the authors. All rights reserved.
00084 
00085 Authors: Tero Hasu <tero.hasu@hut.fi>
00086 
00087 Permission is hereby granted, free of charge, to any person
00088 obtaining a copy of this software and associated documentation files
00089 (the "Software"), to deal in the Software without restriction,
00090 including without limitation the rights to use, copy, modify, merge,
00091 publish, distribute, sublicense, and/or sell copies of the Software,
00092 and to permit persons to whom the Software is furnished to do so,
00093 subject to the following conditions:
00094 
00095 The above copyright notice and this permission notice shall be
00096 included in all copies or substantial portions of the Software.
00097 
00098 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00099 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00100 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00101 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
00102 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
00103 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00104 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
00105 SOFTWARE.
00106 
00107  **/

ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:56 2011 by Doxygen 1.6.1