bool Client::processServerRequest(const BP::Packet &packet){ setStatus(Client::NotActive); last_server_serial = packet.global_serial; BP::CommandType command = packet.getCommandType(); QJsonValue msg = packet.getMessageBody(); BP::Countdown countdown; countdown.current = 0; bool use_default = !msg.isArray(); if(!use_default){ QJsonArray arr = msg.toArray(); if(arr.size() <= 1 || !countdown.tryParse(arr.first())){ use_default = true; } } if(use_default){ countdown.type = BP::Countdown::UseDefault; countdown.max = ServerInfo.getCommandTimeout(command, BP::ClientInstance); } setCountdown(countdown); Callback callback = interactions[command]; if(!callback){ return false; } (this->*callback)(msg); return true; }
PhoneManager::PhoneManager(QObject *parent, MainWindow *pMainWindow) : QObject(parent) { m_ncidClient = NULL; m_connected = false; m_settings = new QSettings; loadConfiguration(); m_callReported = false; m_pButtonMonitorThread = new ButtonMonitorThread(this); connect(m_pButtonMonitorThread, SIGNAL(buttonChange(int,bool)), this, SLOT(onButtonChange(int,bool))); connect(this, SIGNAL(setOutputState(int,bool)), m_pButtonMonitorThread, SLOT(setOutputState(int,bool))); m_iConsecutiveDecrement = 0; m_bDndActive = false; m_dndEndTime = QDateTime::fromTime_t( 0 ); m_clockTimer.setInterval(1000); connect(&m_clockTimer, SIGNAL(timeout()), this, SLOT(onClockTick())); m_clockTimer.start(); m_btnIncrementTimer.setInterval(REPEAT_INTERVAL); m_btnDecrementTimer.setInterval(REPEAT_INTERVAL); connect(&m_btnIncrementTimer, SIGNAL(timeout()), this, SLOT(onIncrementDnd())); connect(&m_btnDecrementTimer, SIGNAL(timeout()), this, SLOT(onDecrementDnd())); m_pDisplayManager = new DisplayManager(this); connect(this, SIGNAL(dndStatus(bool)), m_pDisplayManager, SLOT(setDndStatus(bool))); connect(this, SIGNAL(dndEndTime(QDateTime)), m_pDisplayManager, SLOT(setDndEndTime(QDateTime))); connect( m_pDisplayManager, SIGNAL(ringEnabledChanged(bool)), pMainWindow, SLOT(setRinger(bool)) ); connect( m_pDisplayManager, SIGNAL(untilChanged(QString)), pMainWindow, SLOT(setUntil(QString)) ); connect( m_pDisplayManager, SIGNAL(countdownChanged(QString)), pMainWindow, SLOT(setCountdown(QString)) ); connect( this, SIGNAL(lastCallChanged(QString, QString, QString)), pMainWindow, SLOT(setLastCall(QString, QString, QString)) ); m_pButtonMonitorThread->start(); disableDnd(); connectToNcidServer(); }
bool VCClock::loadXML(const QDomElement* root) { Q_ASSERT(root != NULL); if (root->tagName() != KXMLQLCVCClock) { qWarning() << Q_FUNC_INFO << "Clock node not found"; return false; } if (root->hasAttribute(KXMLQLCVCClockType)) { setClockType(stringToType(root->attribute(KXMLQLCVCClockType))); if (clockType() == Countdown) { int h = 0, m = 0, s = 0; if (root->hasAttribute(KXMLQLCVCClockHours)) h = root->attribute(KXMLQLCVCClockHours).toInt(); if (root->hasAttribute(KXMLQLCVCClockMinutes)) m = root->attribute(KXMLQLCVCClockMinutes).toInt(); if (root->hasAttribute(KXMLQLCVCClockSeconds)) s = root->attribute(KXMLQLCVCClockSeconds).toInt(); setCountdown(h, m ,s); } } /* Widget commons */ loadXMLCommon(root); /* Children */ QDomNode node = root->firstChild(); while (node.isNull() == false) { QDomElement tag = node.toElement(); if (tag.tagName() == KXMLQLCWindowState) { int x = 0, y = 0, w = 0, h = 0; bool visible = false; loadXMLWindowState(&tag, &x, &y, &w, &h, &visible); setGeometry(x, y, w, h); } else if (tag.tagName() == KXMLQLCVCWidgetAppearance) { loadXMLAppearance(&tag); } else if (tag.tagName() == KXMLQLCVCClockSchedule) { VCClockSchedule sch; if (sch.loadXML(&tag) == true) addSchedule(sch); } else { qWarning() << Q_FUNC_INFO << "Unknown clock tag:" << tag.tagName(); } node = node.nextSibling(); } return true; }