/*! Creates a TimeControl instance with the given \a parent. */ TimeControl::TimeControl(QObject *parent) : QObject(parent), m_timer(0), timeValueSpace("/UI/DisplayTime") { m_timer = new QtopiaTimer(this); QObject::connect(m_timer, SIGNAL(timeout()), this, SLOT(doTimeTick())); doTimeTick(); QObject::connect(qApp, SIGNAL(timeChanged()), this, SLOT(doTimeTick())); QObject::connect(qApp, SIGNAL(dateFormatChanged()), this, SLOT(dateFormatChanged())); QObject::connect(qApp, SIGNAL(clockChanged(bool)), this, SLOT(clockChanged(bool))); QObject::connect(qtopiaTask<SystemSuspend>(), SIGNAL(systemSuspending()), this, SLOT(systemSuspending())); QObject::connect(qtopiaTask<SystemSuspend>(), SIGNAL(systemWaking()), this, SLOT(systemWaking())); }
bool SystemSuspendPrivate::suspendSystem() { if(!handlersValid) { handlers = qtopiaTasks<SystemSuspendHandler>(); handlersValid = true; for(int ii = 0; ii < handlers.count(); ++ii) { QObject::connect(handlers.at(ii), SIGNAL(operationCompleted()), this, SLOT(operationCompleted())); } } // Check can suspend for(int ii = handlers.count(); ii > 0; --ii) { if(!handlers.at(ii - 1)->canSuspend()) { emit systemSuspendCanceled(); return false; } } // abort suspension if we see an input event inputEvent = false; // Do suspend emit systemSuspending(); for(int ii = handlers.count(); ii > 0; --ii) { waitingOn = handlers.at(ii - 1); if(!waitingOn->suspend()) { while(waitingOn) QApplication::instance()->processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents); if (inputEvent) break; } else { waitingOn = 0; } } // Do wakeup emit systemWaking(); for(int ii = 0; ii < handlers.count(); ++ii) { waitingOn = handlers.at(ii); if(!waitingOn->wake()) { while(waitingOn) QApplication::instance()->processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents); } else { waitingOn = 0; } } // Done emit systemActive(); return true; }
/*! \internal Create a new RingControl instance with the specified \a parent. */ RingControl::RingControl(QObject *parent) : QObject(parent) { d = new RingControlPrivate; d->videoAdaptor = new QtopiaIpcAdaptor( "QPE/VideoRingtone", this ); QtopiaIpcAdaptor::connect( d->videoAdaptor, MESSAGE(videoRingtoneFailed()), this, SLOT(videoRingtoneFailed()) ); d->profileManager = new QPhoneProfileManager(this); QPhoneProfile prof = d->profileManager->activeProfile(); setVolume(prof.volume()); setMsgRingTime(prof.msgAlertDuration()); connect(DialerControl::instance(), SIGNAL(stateChanged()), this, SLOT(stateChanged())); QObject::connect(d->profileManager, SIGNAL(activeProfileChanged(QPhoneProfile)), this, SLOT(profileChanged())); QObject::connect(qtopiaTask<SystemSuspend>(), SIGNAL(systemSuspending()), this, SLOT(stopMessageAlert())); // Implement ringtone service RingtoneServiceProxy *ringtoneServiceProxy = new RingtoneServiceProxy(this); connect(ringtoneServiceProxy, SIGNAL(doStartMessageRingtone()), this, SLOT(startMessageRingtone())); connect(ringtoneServiceProxy, SIGNAL(doStopMessageRingtone()), this, SLOT(stopMessageRingtone())); connect(ringtoneServiceProxy, SIGNAL(doStartRingtone(QString)), this, SLOT(startRingtone(QString))); connect(ringtoneServiceProxy, SIGNAL(doStopRingtone(QString)), this, SLOT(stopRingtone(QString))); connect(ringtoneServiceProxy, SIGNAL(doMuteRing()), this, SLOT(muteRing())); d->curAlertType = QPhoneProfile::Off; }
bool SystemSuspendPrivate::suspendSystem() { if(!handlersValid) { handlers = qtopiaTasks<SystemSuspendHandler>(); handlersValid = true; for(int ii = 0; ii < handlers.count(); ++ii) { QObject::connect(handlers.at(ii), SIGNAL(operationCompleted()), this, SLOT(operationCompleted())); } } // Check can suspend for(int ii = handlers.count(); ii > 0; --ii) { qLog(PowerManagement) << handlers.at(ii - 1) << "checking whether canSuspend..."; if(!handlers.at(ii - 1)->canSuspend()) { qLog(PowerManagement) << " ...refused, canceling suspend"; emit systemSuspendCanceled(); return false; } } // abort suspension if we see an input event inputEvent = false; // Do suspend emit systemSuspending(); for(int ii = handlers.count(); ii > 0; --ii) { waitingOn = handlers.at(ii - 1); qLog(PowerManagement) << waitingOn << "suspending..."; if(!waitingOn->suspend()) { qLog(PowerManagement) << " ...waiting for completion..."; while(waitingOn) { QApplication::instance()->processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents); //qLog(PowerManagement) << " ...processEvents done"; } if (inputEvent) { qLog(PowerManagement) << "canceling suspend on inputevent"; break; } } else { waitingOn = 0; } } // Do wakeup emit systemWaking(); for(int ii = 0; ii < handlers.count(); ++ii) { waitingOn = handlers.at(ii); qLog(PowerManagement) << handlers.at(ii) << "waking up..."; if(!waitingOn->wake()) { qLog(PowerManagement) << " ...waiting for completion..."; while(waitingOn) QApplication::instance()->processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents); } else { waitingOn = 0; } } // Done emit systemActive(); return true; }