_direction(direction),
_uuid (uuid)
{
+ _isActive = false;
+}
+
+switch_status_t Call::toggleRecord(bool startRecord)
+{
+ QDir conf_dir = QDir::home();
+ QString result;
+ switch_status_t status;
+
+ if (startRecord)
+ {
+ _recording_filename = QString("%1/.fscomm/recordings/%2_%3.wav").arg(
+ conf_dir.absolutePath(),
+ QDateTime::currentDateTime().toString("yyyyMMddhhmmss"),
+ _cid_number);
+ status = g_FSHost.sendCmd("uuid_record", QString("%1 start %2").arg(_uuid, _recording_filename).toAscii().data(),&result);
+ }
+ else
+ {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stopping call recording on call [%s]\n",
+ _uuid.toAscii().data());
+ status = g_FSHost.sendCmd("uuid_record", QString("%1 stop %2").arg(_uuid, _recording_filename).toAscii().data(),&result);
+ }
+
+ return status;
}
#include <QtCore>
#include <QString>
+#include <switch.h>
typedef enum {
FSCOMM_CALL_STATE_RINGING = 0,
void setState(fscomm_call_state_t state) { _state = state; }
void setCause(QString cause) { _cause = cause; }
QString getCause() { return _cause; }
+ void setActive(bool isActive) { _isActive = isActive; }
+ bool isActive() { return _isActive == true; }
+ switch_status_t toggleRecord(bool);
private:
int _call_id;
fscomm_call_direction_t _direction;
QString _uuid;
QString _buuid;
+ bool _isActive;
+ QString _recording_filename;
fscomm_call_state_t _state;
};
/* Create directory structure for softphone with default configs */
QDir conf_dir = QDir::home();
if (!conf_dir.exists(".fscomm"))
- {
- conf_dir.mkpath(".fscomm/conf/accounts");
+ conf_dir.mkpath(".fscomm");
+ if (!conf_dir.exists(".fscomm/recordings"))
+ conf_dir.mkpath(".fscomm/recordings");
+ if (!conf_dir.exists(".fscomm/sounds")) {
conf_dir.mkpath(".fscomm/sounds");
QFile::copy(":/sounds/test.wav", QString("%1/.fscomm/sounds/test.wav").arg(QDir::homePath()));
+ }
+ if(!QFile::exists(QString("%1/.fscomm/conf/freeswitch.xml").arg(conf_dir.absolutePath()))) {
+ conf_dir.mkdir(".fscomm/conf");
QFile rootXML(":/confs/freeswitch.xml");
QString dest = QString("%1/.fscomm/conf/freeswitch.xml").arg(conf_dir.absolutePath());
rootXML.copy(dest);
-
- QFile defaultAccount(":/confs/template.xml");
- dest = QString("%1/.fscomm/conf/accounts/template.xml").arg(conf_dir.absolutePath());
- defaultAccount.copy(dest);
}
/* Set all directories to the home user directory */
switch_status_t status = SWITCH_STATUS_FALSE;
switch_stream_handle_t stream = { 0 };
SWITCH_STANDARD_STREAM(stream);
+ qDebug() << "Sending command: " << cmd << args << endl;
status = switch_api_execute(cmd, args, NULL, &stream);
*res = switch_str_nil((char *) stream.data);
switch_safe_free(stream.data);
return status;
}
+QSharedPointer<Call> FSHost::getCurrentActiveCall()
+{
+ foreach(QSharedPointer<Call> call, _active_calls.values())
+ {
+ if (call.data()->isActive())
+ return call;
+ }
+ return QSharedPointer<Call>();
+}
+
void FSHost::printEventHeaders(switch_event_t *event)
{
switch_event_header_t *hp;
switch_status_t sendCmd(const char *cmd, const char *args, QString *res);
void generalEventHandler(switch_event_t *event);
QSharedPointer<Call> getCallByUUID(QString uuid) { return _active_calls.value(uuid); }
+ QSharedPointer<Call> getCurrentActiveCall();
QString getGwStateName(int id) { return fscomm_gw_state_names[id]; }
protected:
connect(ui->newCallBtn, SIGNAL(clicked()), this, SLOT(makeCall()));
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->listCalls, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(callListDoubleClick(QListWidgetItem*)));
connect(ui->action_Preferences, SIGNAL(triggered()), this, SLOT(prefTriggered()));
connect(ui->action_Exit, SIGNAL(triggered()), this, SLOT(close()));
void MainWindow::callListDoubleClick(QListWidgetItem *item)
{
+ QSharedPointer<Call> lastCall = g_FSHost.getCurrentActiveCall();
QSharedPointer<Call> call = g_FSHost.getCallByUUID(item->data(Qt::UserRole).toString());
QString switch_str = QString("switch %1").arg(call.data()->getCallID());
QString result;
return;
}
ui->hangupBtn->setEnabled(true);
+ lastCall.data()->setActive(false);
+ call.data()->setActive(true);
}
void MainWindow::makeCall()
ui->hangupBtn->setEnabled(false);
}
+void MainWindow::recordCall(bool pressed)
+{
+ QSharedPointer<Call> call = g_FSHost.getCurrentActiveCall();
+
+ if (call.isNull())
+ {
+ QMessageBox::warning(this,tr("Record call"),
+ tr("<p>FSComm reports that there are no active calls to be recorded."
+ "<p>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;
+ }
+
+ if (call.data()->toggleRecord(pressed) != SWITCH_STATUS_SUCCESS)
+ {
+ QMessageBox::warning(this,tr("Record call"),
+ tr("<p>Could not get active call to start/stop recording."
+ "<p>Please report this bug."),
+ QMessageBox::Ok);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not record call [%s].\n", call.data()->getUUID().toAscii().data());
+ return;
+ }
+}
+
void MainWindow::newOutgoingCall(QSharedPointer<Call> call)
{
ui->textEdit->setText(QString("Calling %1 (%2)").arg(call.data()->getCidName(), call.data()->getCidNumber()));
item->setData(Qt::UserRole, call.data()->getUUID());
ui->listCalls->addItem(item);
ui->hangupBtn->setEnabled(true);
+ call.data()->setActive(true);
}
void MainWindow::ringing(QSharedPointer<Call> call)
item->setData(Qt::UserRole, call.data()->getUUID());
ui->listCalls->addItem(item);
ui->answerBtn->setEnabled(true);
+ call.data()->setActive(true);
}
void MainWindow::answered(QSharedPointer<Call> call)
ui->textEdit->setText(tr("Call with %1 (%2) 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->answerBtn->setEnabled(false);
ui->hangupBtn->setEnabled(false);
break;
}
}
+ call.data()->setActive(false);
ui->textEdit->setText(tr("Call with %1 (%2) hungup.").arg(call.data()->getCidName(), call.data()->getCidNumber()));
/* TODO: Will cause problems if 2 calls are received at the same time */
ui->answerBtn->setEnabled(false);
void answered(QSharedPointer<Call>);
void hungup(QSharedPointer<Call>);
void callFailed(QSharedPointer<Call>);
+ void recordCall(bool);
private:
Ui::MainWindow *ui;
</property>
</widget>
</item>
+ <item>
+ <widget class="QPushButton" name="recoredCallBtn">
+ <property name="text">
+ <string>Record</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item>