ServiceCallback Service::checkoutCallback(ui64 cbid) { cleanCallback(); auto founder = _cbs.find(cbid); if (founder == _cbs.end()) { return nullptr; } auto cb = std::move(founder->second.second); _cbs.erase(founder); return cb; }
STSTest::STSTest( QWidget *parent) : QMainWindow(parent), sts(new XQSystemToneService()) { qDebug() << QString("[sts] STSTest::STSTest 1"); QWidget *window = new QWidget(this); qDebug() << QString("[sts] STSTest::STSTest 2"); QVBoxLayout* layout = new QVBoxLayout(this); callbackCleanTimer.setSingleShot(true); connect(&callbackCleanTimer, SIGNAL(timeout()), this, SLOT(cleanCallback())); QPushButton *quitButton = new QPushButton("QUIT", this); connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); QPushButton *playToneButton = new QPushButton("Play Tone", this); connect(playToneButton, SIGNAL(clicked()), this, SLOT(playTone())); QPushButton *playAlarmButton = new QPushButton("Play Alarm", this); connect(playAlarmButton, SIGNAL(clicked()), this, SLOT(playAlarm())); QPushButton *playAlarmAsToneButton = new QPushButton("Play Alarm as Tone", this); connect(playAlarmAsToneButton, SIGNAL(clicked()), this, SLOT(playAlarmAsTone())); QPushButton *stopAlarmButton = new QPushButton("Stop Alarm", this); connect(stopAlarmButton, SIGNAL(clicked()), this, SLOT(stopAlarm())); connect(sts, SIGNAL(toneStarted()), this, SLOT(startCallback())); connect(sts, SIGNAL(alarmStarted(unsigned int)), this, SLOT(startCallback(unsigned int))); connect(sts, SIGNAL(alarmFinished(unsigned int)), this, SLOT(stopCallback(unsigned int))); qDebug() << QString("[sts] STSTest::STSTest 3"); box = new QComboBox(this); spinBox = new QSpinBox(this); layout->setMargin(10); layout->setSpacing(0); qDebug() << QString("[sts] STSTest::STSTest 4"); QList<QPair<int, QString> > tonesList; // alarms tonesList.append(QPair<int,QString>(XQSystemToneService::CalendarAlarmTone, "[A] Calendar Alarm")); tonesList.append(QPair<int,QString>(XQSystemToneService::ClockAlarmTone, "[A] Clock Alarm")); tonesList.append(QPair<int,QString>(XQSystemToneService::ToDoAlarmTone, "[A] ToDo Alarm")); tonesList.append(QPair<int,QString>(XQSystemToneService::IncomingCallTone, "[A] Incoming Call")); tonesList.append(QPair<int,QString>(XQSystemToneService::IncomingCallLine2Tone, "[A] Incomming Call Line 2")); tonesList.append(QPair<int,QString>(XQSystemToneService::IncomingDataCallTone, "[A] Incomming Data Call")); // tones tonesList.append(QPair<int,QString>(XQSystemToneService::BurstModeTone, "[T] Burst Mode")); tonesList.append(QPair<int,QString>(XQSystemToneService::CaptureTone, "[T] Capture")); tonesList.append(QPair<int,QString>(XQSystemToneService::CallRecordingTone, "[T] Call Recording")); tonesList.append(QPair<int,QString>(XQSystemToneService::RecordingStartTone, "[T] Recording Start")); tonesList.append(QPair<int,QString>(XQSystemToneService::SelfTimerTone, "[T] Self Timer")); tonesList.append(QPair<int,QString>(XQSystemToneService::ConfirmationBeepTone, "[T] Confirmation Beep")); tonesList.append(QPair<int,QString>(XQSystemToneService::DefaultBeepTone, "[T] Default Beep")); tonesList.append(QPair<int,QString>(XQSystemToneService::ErrorBeepTone, "[T] Error Beep")); tonesList.append(QPair<int,QString>(XQSystemToneService::InformationBeepTone, "[T] Information Beep")); tonesList.append(QPair<int,QString>(XQSystemToneService::WarningBeepTone, "[T] Warning Beep")); tonesList.append(QPair<int,QString>(XQSystemToneService::IntegratedHandsFreeActivatedTone, "[T] Integrated Hands Free Act.")); tonesList.append(QPair<int,QString>(XQSystemToneService::TouchScreenTone, "[T] Touch Screen")); tonesList.append(QPair<int,QString>(XQSystemToneService::ChatAlertTone, "[T] Chat Alert")); tonesList.append(QPair<int,QString>(XQSystemToneService::EmailAlertTone, "[T] Email Alert")); tonesList.append(QPair<int,QString>(XQSystemToneService::MmsAlertTone, "[T] MMS Alert")); tonesList.append(QPair<int,QString>(XQSystemToneService::SmsAlertTone, "[T] SMS Alert")); tonesList.append(QPair<int,QString>(XQSystemToneService::DeliveryReportTone, "[T] Delivery Report")); tonesList.append(QPair<int,QString>(XQSystemToneService::MessageSendFailureTone, "[T] Message Send Failure")); tonesList.append(QPair<int,QString>(XQSystemToneService::BatteryLowTone, "[T] Battery Low")); tonesList.append(QPair<int,QString>(XQSystemToneService::BatteryRechargedTone, "[T] Battery Recharge")); tonesList.append(QPair<int,QString>(XQSystemToneService::PowerOnTone, "[T] Power On")); tonesList.append(QPair<int,QString>(XQSystemToneService::PowerOffTone, "[T] Power Off")); tonesList.append(QPair<int,QString>(XQSystemToneService::WakeUpTone, "[T] Wake Up")); tonesList.append(QPair<int,QString>(XQSystemToneService::WrongChargerTone, "[T] Wrong Charger")); tonesList.append(QPair<int,QString>(XQSystemToneService::AutomaticRedialCompleteTone, "[T] Automatic Redial Compl.")); tonesList.append(QPair<int,QString>(XQSystemToneService::VoiceStartTone, "[T] Voice Start")); tonesList.append(QPair<int,QString>(XQSystemToneService::VoiceErrorTone, "[T] Voice Error")); tonesList.append(QPair<int,QString>(XQSystemToneService::VoiceAbortTone, "[T] Voice Abort")); qDebug() << QString("[sts] STSTest::STSTest 5"); QListIterator<QPair<int, QString> > iter(tonesList); while (iter.hasNext()) { QPair<int, QString> item = iter.next(); box->addItem(item.second, item.first); } layout->addStretch(4); layout->addWidget(box); qDebug() << QString("[sts] STSTest::STSTest 6"); layout->addStretch(1); layout->addWidget(playToneButton); layout->addStretch(1); layout->addWidget(playAlarmButton); layout->addStretch(1); layout->addWidget(playAlarmAsToneButton); layout->addStretch(1); currCtxLabel = new QLabel("Last context: ?", this); layout->addWidget(currCtxLabel); layout->addStretch(2); layout->addWidget(stopAlarmButton); layout->addStretch(1); layout->addWidget(new QLabel("Context:", this)); layout->addWidget(spinBox); layout->addStretch(1); callbackLabel = new QLabel("SIGNALS: ---", this); layout->addWidget(callbackLabel); layout->addStretch(4); layout->addWidget(quitButton); window->setLayout(layout); setCentralWidget(window); window->show();; }