diff --git a/fscomm/call.cpp b/fscomm/call.cpp index a13f01712e..80dc316fb3 100644 --- a/fscomm/call.cpp +++ b/fscomm/call.cpp @@ -36,6 +36,27 @@ Call::Call() _answeredEpoch = 0; } +switch_status_t Call::toggleHold(bool holdPressed) +{ + if (_state != FSCOMM_CALL_STATE_ANSWERED) return SWITCH_STATUS_FALSE; + switch_stream_handle_t stream = { 0 }; + SWITCH_STANDARD_STREAM(stream); + QString holdStr; + if (holdPressed) + { + holdStr = _channel.data()->getUuid(); + } + else + { + holdStr = "off " + _channel.data()->getUuid(); + } + + switch_status_t st = switch_api_execute("uuid_hold", holdStr.toAscii().data(), NULL, &stream); + switch_safe_free(stream.data); + return st; + +} + switch_status_t Call::toggleRecord(bool startRecord) { QDir conf_dir = QDir::home(); @@ -82,8 +103,7 @@ QTime Call::getCurrentStateTime() { if (_direction == FSCOMM_CALL_DIRECTION_INBOUND) { - /* TODO: DOESNT WORK - How do I get what time it started to ring? */ - _channel.data()->getProgressEpoch() == 0 ? time = _channel.data()->getProgressMediaEpoch() : time = _channel.data()->getProgressEpoch(); + time = _channel.data()->getCreatedEpoch(); } else _otherLegChannel.data()->getProgressEpoch() == 0 ? time = _otherLegChannel.data()->getProgressMediaEpoch() : time = _otherLegChannel.data()->getProgressEpoch(); diff --git a/fscomm/call.h b/fscomm/call.h index 891bb17f54..81f712a679 100644 --- a/fscomm/call.h +++ b/fscomm/call.h @@ -50,8 +50,8 @@ class Call { public: Call(); /* Needs rework */ - QString getCidName(void) { return _channel.data()->getCidName(); } - QString getCidNumber(void) { return _channel.data()->getCidNumber(); } + QString getCidName(void) { return (_direction == FSCOMM_CALL_DIRECTION_INBOUND) ? _otherLegChannel.data()->getCidName() : _channel.data()->getCidName(); } + QString getCidNumber(void) { return (_direction == FSCOMM_CALL_DIRECTION_INBOUND) ? _otherLegChannel.data()->getCidNumber() : _channel.data()->getCidNumber(); } QString getDestinationNumber(void) { return _otherLegChannel.data()->getDestinationNumber(); } void setChannel(QSharedPointer channel) { _channel = channel; } @@ -66,11 +66,12 @@ public: fscomm_call_direction_t getDirection() { return _direction; } fscomm_call_state_t getState() { return _state; } void setState(fscomm_call_state_t state) { _state = state; } - void setCause(QString cause) { _cause = cause; } - QString getCause() { return _cause; } + void setCause(QString cause) { _cause = cause; qDebug()<listDetails->clear(); int r = ui->listEvents->currentRow(); + if (r == -1) return; QString uuid = ui->listUUID->currentItem()->text(); QList > tmpListEvents = _events.value(uuid); QSharedPointer e = tmpListEvents.at(r); diff --git a/fscomm/fshost.cpp b/fscomm/fshost.cpp index fda22b59d6..b37452d01d 100644 --- a/fscomm/fshost.cpp +++ b/fscomm/fshost.cpp @@ -394,13 +394,13 @@ void FSHost::eventChannelOutgoing(QSharedPointerevent, QString u else { Call *callPtr = new Call(); - callPtr->setCallDirection(FSCOMM_CALL_DIRECTION_INBOUND); - callPtr->setChannel(_channels.value(switch_event_get_header_nil(event.data(), "Other-Leg-Unique-ID"))); - callPtr->setOtherLegChannel(_channels.value(uuid)); + callPtr->setChannel(_channels.value(uuid)); + callPtr->setOtherLegChannel(_channels.value(switch_event_get_header_nil(event.data(), "Other-Leg-Unique-ID"))); QSharedPointer call(callPtr); - _active_calls.insert(switch_event_get_header_nil(event.data(), "Other-Leg-Unique-ID"), call); + _active_calls.insert(uuid, call); call.data()->setState(FSCOMM_CALL_STATE_RINGING); + _channels.value(uuid).data()->setCreatedEpoch(QString(switch_event_get_header_nil(event.data(), "Caller-Channel-Created-Time")).toULongLong()); emit ringing(call); } } @@ -426,16 +426,23 @@ void FSHost::eventChannelBridge(QSharedPointerevent, QString uui if (time.toULongLong() > 0) _channels.value(uuid).data()->setProgressMediaEpoch(time.toULongLong()); } void FSHost::eventChannelHangup(QSharedPointerevent, QString uuid) -{ - if (_active_calls.contains(uuid)) - { - emit hungup(_active_calls.take(uuid)); - } -} +{} void FSHost::eventChannelUnbridge(QSharedPointerevent, QString uuid) {} void FSHost::eventChannelHangupComplete(QSharedPointerevent, QString uuid) -{} +{ + if (_active_calls.contains(uuid)) + { + if (_active_calls.value(uuid).data()->getState() != FSCOMM_CALL_STATE_ANSWERED) + { + _active_calls.value(uuid).data()->setState(FSCOMM_CALL_STATE_FAILED); + _active_calls.value(uuid).data()->setCause(switch_event_get_header_nil(event.data(), "variable_originate_disposition")); + emit callFailed(_active_calls.value(uuid)); + return; + } + emit hungup(_active_calls.take(uuid)); + } +} void FSHost::eventChannelDestroy(QSharedPointerevent, QString uuid) { _channels.take(uuid); diff --git a/fscomm/mainwindow.cpp b/fscomm/mainwindow.cpp index 6a99a4bb50..b4720f5034 100644 --- a/fscomm/mainwindow.cpp +++ b/fscomm/mainwindow.cpp @@ -100,6 +100,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->answerBtn, SIGNAL(clicked()), this, SLOT(paAnswer())); connect(ui->hangupBtn, SIGNAL(clicked()), this, SLOT(paHangup())); connect(ui->recoredCallBtn, SIGNAL(toggled(bool)), SLOT(recordCall(bool))); + connect(ui->btnHold, SIGNAL(toggled(bool)), this, SLOT(holdCall(bool))); connect(ui->tableCalls, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(callTableDoubleClick(QTableWidgetItem*))); connect(ui->action_Preferences, SIGNAL(triggered()), this, SLOT(prefTriggered())); connect(ui->action_Exit, SIGNAL(triggered()), this, SLOT(close())); @@ -363,16 +364,35 @@ void MainWindow::paHangup() ui->hangupBtn->setEnabled(false); } +void MainWindow::holdCall(bool pressed) +{ + + QSharedPointer call = g_FSHost.getCurrentActiveCall(); + + if (call.isNull()) + { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not hold call because there is not current active call!.\n"); + return; + } + + if (call.data()->toggleHold(pressed) != SWITCH_STATUS_SUCCESS) + { + QMessageBox::warning(this,tr("Hold call"), + tr("

Could not get active call to hold/unhold." + "

Please report this bug."), + QMessageBox::Ok); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not hold/unhold call [%s].\n", call.data()->getUuid().toAscii().data()); + return; + } + +} + void MainWindow::recordCall(bool pressed) { QSharedPointer call = g_FSHost.getCurrentActiveCall(); if (call.isNull()) { - QMessageBox::warning(this,tr("Record call"), - tr("

FSComm reports that there are no active calls to be recorded." - "

Please report this bug."), - QMessageBox::Ok); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not record call because there is not current active call!.\n"); return; } @@ -472,6 +492,9 @@ void MainWindow::answered(QSharedPointer call) } ui->recoredCallBtn->setEnabled(true); ui->recoredCallBtn->setChecked(false); + ui->btnHold->setEnabled(true); + ui->btnHold->setChecked(false); + ui->btnTransfer->setEnabled(true); ui->dtmf0Btn->setEnabled(true); ui->dtmf1Btn->setEnabled(true); ui->dtmf2Btn->setEnabled(true); @@ -504,13 +527,26 @@ void MainWindow::callFailed(QSharedPointer call) break; } } - ui->textEdit->setText(tr("Call with %1 (%2) failed with reason %3.").arg(call.data()->getCidName(), - call.data()->getCidNumber(), - call.data()->getCause())); + if (call.data()->getDirection() == FSCOMM_CALL_DIRECTION_INBOUND) + { + ui->textEdit->setText(tr("Call from %1 (%2) failed with reason %3.").arg(call.data()->getCidName(), + call.data()->getCidNumber(), + call.data()->getCause())); + } + else + { + ui->textEdit->setText(tr("Call to %1 failed with reason %3.").arg(call.data()->getCidName(), + call.data()->getCidNumber(), + call.data()->getCause())); + } + call.data()->setActive(false); /* TODO: Will cause problems if 2 calls are received at the same time */ ui->recoredCallBtn->setEnabled(false); ui->recoredCallBtn->setChecked(false); + ui->btnHold->setEnabled(false); + ui->btnHold->setChecked(false); + ui->btnTransfer->setEnabled(false); ui->answerBtn->setEnabled(false); ui->hangupBtn->setEnabled(false); ui->dtmf0Btn->setEnabled(false); @@ -558,6 +594,9 @@ void MainWindow::hungup(QSharedPointer call) /* TODO: Will cause problems if 2 calls are received at the same time */ ui->recoredCallBtn->setEnabled(false); ui->recoredCallBtn->setChecked(false); + ui->btnHold->setEnabled(false); + ui->btnHold->setChecked(false); + ui->btnTransfer->setEnabled(false); ui->answerBtn->setEnabled(false); ui->hangupBtn->setEnabled(false); ui->dtmf0Btn->setEnabled(false); diff --git a/fscomm/mainwindow.h b/fscomm/mainwindow.h index 46031b3723..e7348c13d6 100644 --- a/fscomm/mainwindow.h +++ b/fscomm/mainwindow.h @@ -76,6 +76,7 @@ private slots: void hungup(QSharedPointer); void callFailed(QSharedPointer); void recordCall(bool); + void holdCall(bool); void setDefaultAccount(); void accountAdd(QSharedPointer); void accountDel(QSharedPointer); diff --git a/fscomm/mainwindow.ui b/fscomm/mainwindow.ui index 9950b7d088..3987094abf 100644 --- a/fscomm/mainwindow.ui +++ b/fscomm/mainwindow.ui @@ -14,28 +14,250 @@ FSComm - A FreeSWITCH Communicator - + - + - - - false - - - true - - + + + + + false + + + true + + + + + + + + + false + + + New Call + + + + + + + false + + + Hold + + + true + + + false + + + + + + + + + + + false + + + Answer + + + + + + + false + + + Hangup + + + + + + + + + + + false + + + 1 + + + + + + + false + + + 2 + + + + + + + false + + + 3 + + + + + + + false + + + 4 + + + + + + + false + + + 5 + + + + + + + false + + + 6 + + + + + + + false + + + 7 + + + + + + + false + + + 8 + + + + + + + false + + + 9 + + + + + + + false + + + * + + + + + + + false + + + 0 + + + + + + + false + + + # + + + + + + + false + + + A + + + + + + + false + + + B + + + + + + + false + + + D + + + + + + + false + + + C + + + + + + - + - + false - New Call + Transfer @@ -47,200 +269,6 @@ Record - - true - - - false - - - - - - - - - - - false - - - Answer - - - - - - - false - - - Hangup - - - - - - - - - - - false - - - 1 - - - - - - - false - - - 2 - - - - - - - false - - - 3 - - - - - - - false - - - 4 - - - - - - - false - - - 5 - - - - - - - false - - - 6 - - - - - - - false - - - 7 - - - - - - - false - - - 8 - - - - - - - false - - - 9 - - - - - - - false - - - * - - - - - - - false - - - 0 - - - - - - - false - - - # - - - - - - - false - - - A - - - - - - - false - - - B - - - - - - - false - - - D - - - - - - - false - - - C -