提交 a891fe51 authored 作者: João Mesquita's avatar João Mesquita

Initial work to support multiple lines. Took away the dial for a minute. Sorry about that.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk/contrib@16111 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 71db7fd1
...@@ -25,9 +25,9 @@ LIBS = -L../../../.libs \ ...@@ -25,9 +25,9 @@ LIBS = -L../../../.libs \
SOURCES += main.cpp \ SOURCES += main.cpp \
mainwindow.cpp \ mainwindow.cpp \
fshost.cpp fshost.cpp \
#call.cpp call.cpp
HEADERS += mainwindow.h \ HEADERS += mainwindow.h \
fshost.h fshost.h \
#call.h call.h
FORMS += mainwindow.ui FORMS += mainwindow.ui
#include "call.h" #include "call.h"
Call::Call(int call_id, QString cid_name, QString cid_number) : Call::Call()
{
}
Call::Call(int call_id, QString cid_name, QString cid_number, fsphone_call_direction_t direction, QString uuid) :
_call_id(call_id), _call_id(call_id),
_cid_name(cid_name), _cid_name(cid_name),
_cid_number(cid_number) _cid_number(cid_number),
_direction(direction),
_uuid (uuid)
{ {
} }
#ifndef CALL_H #ifndef CALL_H
#define CALL_H #define CALL_H
#include <QtCore>
#include <QString> #include <QString>
#include <fshost.h> #include <fshost.h>
...@@ -12,13 +13,21 @@ typedef enum { ...@@ -12,13 +13,21 @@ typedef enum {
class Call class Call
{ {
public: public:
Call(int call_id, QString cid_name, QString cid_number); Call(void);
Call(int call_id, QString cid_name, QString cid_number, fsphone_call_direction_t direction, QString uuid);
QString getCidName(void) { return _cid_name; }
QString getCidNumber(void) { return _cid_number; }
int getCallID(void) { return _call_id; }
QString getUUID(void) { return _uuid; }
private: private:
int _call_id; int _call_id;
QString _cid_name; QString _cid_name;
QString _cid_number; QString _cid_number;
fsphone_call_direction_t _direction; fsphone_call_direction_t _direction;
QString _uuid;
}; };
Q_DECLARE_METATYPE(Call)
#endif // CALL_H #endif // CALL_H
#include <QtGui>
#include "fshost.h" #include "fshost.h"
#include "call.h"
/* Declare it globally */ /* Declare it globally */
FSHost g_FSHost; FSHost g_FSHost;
...@@ -10,6 +12,9 @@ FSHost::FSHost(QObject *parent) : ...@@ -10,6 +12,9 @@ FSHost::FSHost(QObject *parent) :
printf("Initializing globals...\n"); printf("Initializing globals...\n");
switch_core_setrlimits(); switch_core_setrlimits();
switch_core_set_globals(); switch_core_set_globals();
qRegisterMetaType<Call>("Call");
} }
void FSHost::run(void) void FSHost::run(void)
...@@ -58,7 +63,12 @@ void FSHost::generalEventHandler(switch_event_t *event) ...@@ -58,7 +63,12 @@ void FSHost::generalEventHandler(switch_event_t *event)
{ {
if (strcmp(event->subclass_name, "portaudio::ringing") == 0) if (strcmp(event->subclass_name, "portaudio::ringing") == 0)
{ {
emit ringing(switch_event_get_header_nil(event, "call_id"), switch_event_get_header_nil(event, "Caller-Caller-ID-Number"), switch_event_get_header_nil(event, "Caller-Caller-ID-Name")); Call *call = new Call(atoi(switch_event_get_header_nil(event, "call_id")),
switch_event_get_header_nil(event, "Caller-Caller-ID-Name"),
switch_event_get_header_nil(event, "Caller-Caller-ID-Number"),
FSPHONE_CALL_DIRECTION_INBOUND,
switch_event_get_header_nil(event, "Unique-ID"));
emit ringing(call);
} }
else else
{ {
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include <QThread> #include <QThread>
#include <switch.h> #include <switch.h>
class Call;
class FSHost : public QThread class FSHost : public QThread
{ {
Q_OBJECT Q_OBJECT
...@@ -17,7 +19,7 @@ protected: ...@@ -17,7 +19,7 @@ protected:
signals: signals:
void ready(void); void ready(void);
void ringing(QString uuid, QString caller_id_name, QString caller_id_name); void ringing(Call *call);
}; };
......
...@@ -8,11 +8,9 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -8,11 +8,9 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
connect(&g_FSHost, SIGNAL(ready()),this, SLOT(fshostReady())); connect(&g_FSHost, SIGNAL(ready()),this, SLOT(fshostReady()));
connect(&g_FSHost, SIGNAL(ringing(QString,QString,QString)), this, SLOT(ringing(QString,QString,QString))); connect(&g_FSHost, SIGNAL(ringing(Call *)), this, SLOT(ringing(Call *)));
connect(ui->answerBtn, SIGNAL(clicked()), this, SLOT(paAnswer())); connect(ui->answerBtn, SIGNAL(clicked()), this, SLOT(paAnswer()));
connect(ui->callBtn, SIGNAL(clicked()), this, SLOT(paCall()));
connect(ui->hangupBtn, SIGNAL(clicked()), this, SLOT(paHangup())); connect(ui->hangupBtn, SIGNAL(clicked()), this, SLOT(paHangup()));
connect(ui->paDevlistBtn, SIGNAL(clicked()), this, SLOT(paDevlist()));
g_FSHost.start(); g_FSHost.start();
} }
...@@ -28,20 +26,8 @@ MainWindow::~MainWindow() ...@@ -28,20 +26,8 @@ MainWindow::~MainWindow()
void MainWindow::fshostReady() void MainWindow::fshostReady()
{ {
ui->statusBar->showMessage("Ready", 0); ui->statusBar->showMessage("Ready", 0);
ui->paDevlistBtn->setEnabled(true);
ui->textEdit->setEnabled(true); ui->textEdit->setEnabled(true);
ui->callBtn->setEnabled(true); ui->textEdit->setText("Click on line to dial number...");
ui->textEdit->setText("Click to dial number...");
}
void MainWindow::paDevlist()
{
QString result;
if (g_FSHost.sendCmd("pa", "devlist as xml", &result) == SWITCH_STATUS_FALSE) {
ui->textEdit->setText("Error sending that command");
}
ui->textEdit->setText(result);
} }
void MainWindow::paAnswer() void MainWindow::paAnswer()
...@@ -51,11 +37,9 @@ void MainWindow::paAnswer() ...@@ -51,11 +37,9 @@ void MainWindow::paAnswer()
ui->textEdit->setText("Error sending that command"); ui->textEdit->setText("Error sending that command");
} }
ui->textEdit->setReadOnly(true);
ui->textEdit->setText("Talking..."); ui->textEdit->setText("Talking...");
ui->hangupBtn->setEnabled(true); ui->hangupBtn->setEnabled(true);
ui->answerBtn->setEnabled(false); ui->answerBtn->setEnabled(false);
ui->callBtn->setEnabled(false);
} }
void MainWindow::paCall() void MainWindow::paCall()
...@@ -81,13 +65,18 @@ void MainWindow::paHangup() ...@@ -81,13 +65,18 @@ void MainWindow::paHangup()
ui->textEdit->setText("Click to dial number..."); ui->textEdit->setText("Click to dial number...");
ui->statusBar->showMessage("Call hungup", 10); ui->statusBar->showMessage("Call hungup", 10);
ui->hangupBtn->setEnabled(false); ui->hangupBtn->setEnabled(false);
ui->textEdit->setReadOnly(false);
ui->callBtn->setEnabled(true);
} }
void MainWindow::ringing(QString uuid, QString caller_id_number, QString caller_id_name) void MainWindow::ringing(Call *call)
{ {
ui->textEdit->setText(QString("Number: %1\nName: %3").arg(caller_id_number, caller_id_name)); if (_lines.contains(call->getUUID()))
{
delete call;
}
else
{
ui->textEdit->setText(QString("Number: %1\nName: %3").arg(call->getCidNumber(), call->getCidName()));
}
ui->answerBtn->setEnabled(true); ui->answerBtn->setEnabled(true);
} }
......
...@@ -34,8 +34,10 @@ ...@@ -34,8 +34,10 @@
#define MAINWINDOW_H #define MAINWINDOW_H
#include <QMainWindow> #include <QMainWindow>
#include <QPushButton>
#include <switch.h> #include <switch.h>
#include <fshost.h> #include <fshost.h>
#include <call.h>
namespace Ui { namespace Ui {
class MainWindow; class MainWindow;
...@@ -52,14 +54,14 @@ protected: ...@@ -52,14 +54,14 @@ protected:
private slots: private slots:
void fshostReady(); void fshostReady();
void paDevlist();
void paAnswer(); void paAnswer();
void paCall(); void paCall();
void paHangup(); void paHangup();
void ringing(QString, QString, QString); void ringing(Call *);
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
QHash<QString, Call *> _lines;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>287</width> <width>287</width>
<height>471</height> <height>438</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -21,23 +21,13 @@ ...@@ -21,23 +21,13 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="readOnly"> <property name="readOnly">
<bool>false</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="callBtn"> <layout class="QGridLayout" name="gridLayout_2">
<property name="enabled"> <item row="0" column="0">
<bool>false</bool>
</property>
<property name="text">
<string>Call</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="answerBtn"> <widget class="QPushButton" name="answerBtn">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
...@@ -47,17 +37,7 @@ ...@@ -47,17 +37,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QPushButton" name="paDevlistBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>pa devlist</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="hangupBtn"> <widget class="QPushButton" name="hangupBtn">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论