Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
3ed45189
提交
3ed45189
authored
4月 06, 2010
作者:
Joao Mesquita
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use more SharedPointers to make our lives easier.
上级
b9d5c62b
全部展开
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
138 行增加
和
81 行删除
+138
-81
call.cpp
fscomm/call.cpp
+21
-2
call.h
fscomm/call.h
+2
-2
channel.cpp
fscomm/channel.cpp
+2
-0
channel.h
fscomm/channel.h
+10
-2
fshost.cpp
fscomm/fshost.cpp
+72
-50
fshost.h
fscomm/fshost.h
+21
-20
mainwindow.cpp
fscomm/mainwindow.cpp
+10
-5
没有找到文件。
fscomm/call.cpp
浏览文件 @
3ed45189
...
...
@@ -32,7 +32,9 @@
#include <fshost.h>
Call
::
Call
()
{}
{
_answeredEpoch
=
0
;
}
switch_status_t
Call
::
toggleRecord
(
bool
startRecord
)
{
...
...
@@ -70,6 +72,23 @@ void Call::sendDTMF(QString digit)
QTime
Call
::
getCurrentStateTime
()
{
int
now
=
QDateTime
::
fromTime_t
(
_answered_epoch
).
secsTo
(
QDateTime
::
currentDateTime
());
qulonglong
time
=
0
;
if
(
_state
==
FSCOMM_CALL_STATE_ANSWERED
)
{
time
=
_answeredEpoch
;
}
else
if
(
_state
==
FSCOMM_CALL_STATE_RINGING
)
{
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
();
}
else
_otherLegChannel
.
data
()
->
getProgressEpoch
()
==
0
?
time
=
_otherLegChannel
.
data
()
->
getProgressMediaEpoch
()
:
time
=
_otherLegChannel
.
data
()
->
getProgressEpoch
();
}
int
now
=
QDateTime
::
fromTime_t
(
time
).
secsTo
(
QDateTime
::
currentDateTime
());
return
QTime
::
fromString
(
QString
::
number
(
now
),
"s"
);
}
fscomm/call.h
浏览文件 @
3ed45189
...
...
@@ -72,7 +72,7 @@ public:
bool
isActive
()
{
return
_isActive
==
true
;
}
switch_status_t
toggleRecord
(
bool
);
void
sendDTMF
(
QString
digit
);
void
setAnsweredEpoch
(
qulonglong
time
)
{
_answered
_e
poch
=
time
/
1000000
;
}
void
setAnsweredEpoch
(
qulonglong
time
)
{
_answered
E
poch
=
time
/
1000000
;
}
QTime
getCurrentStateTime
();
private
:
...
...
@@ -85,7 +85,7 @@ private:
bool
_isActive
;
QString
_recording_filename
;
fscomm_call_state_t
_state
;
qulonglong
_answered
_e
poch
;
qulonglong
_answered
E
poch
;
};
Q_DECLARE_METATYPE
(
Call
)
...
...
fscomm/channel.cpp
浏览文件 @
3ed45189
...
...
@@ -3,4 +3,6 @@
Channel
::
Channel
(
QString
uuid
)
:
_uuid
(
uuid
)
{
_progressEpoch
=
0
;
_progressMediaEpoch
=
0
;
}
fscomm/channel.h
浏览文件 @
3ed45189
...
...
@@ -16,14 +16,22 @@ public:
void
setDestinatinonNumber
(
QString
destinationNumber
)
{
_destinationNumber
=
destinationNumber
;
}
QString
getDestinationNumber
()
{
return
_destinationNumber
;
}
int
getPaCallId
()
{
return
_pa_call_id
;
}
int
getPaCallId
()
{
return
_paCallId
;
}
void
setPaCallId
(
int
paCallId
)
{
_paCallId
=
paCallId
;}
void
setProgressEpoch
(
qulonglong
time
)
{
_progressEpoch
=
time
/
1000000
;
}
qulonglong
getProgressEpoch
()
{
return
_progressEpoch
;
}
void
setProgressMediaEpoch
(
qulonglong
time
)
{
_progressMediaEpoch
=
time
/
1000000
;
}
qulonglong
getProgressMediaEpoch
()
{
return
_progressMediaEpoch
;
}
private
:
QString
_uuid
;
QString
_cidName
;
QString
_cidNumber
;
QString
_destinationNumber
;
int
_pa_call_id
;
int
_paCallId
;
qulonglong
_progressEpoch
;
qulonglong
_progressMediaEpoch
;
};
Q_DECLARE_METATYPE
(
Channel
)
...
...
fscomm/fshost.cpp
浏览文件 @
3ed45189
差异被折叠。
点击展开。
fscomm/fshost.h
浏览文件 @
3ed45189
...
...
@@ -44,7 +44,7 @@ Q_OBJECT
public
:
explicit
FSHost
(
QObject
*
parent
=
0
);
switch_status_t
sendCmd
(
const
char
*
cmd
,
const
char
*
args
,
QString
*
res
);
void
generalEventHandler
(
switch_event_t
*
event
);
void
generalEventHandler
(
QSharedPointer
<
switch_event_t
>
event
);
QSharedPointer
<
Call
>
getCallByUUID
(
QString
uuid
)
{
return
_active_calls
.
value
(
uuid
);
}
QSharedPointer
<
Call
>
getCurrentActiveCall
();
QList
<
QSharedPointer
<
Account
>
>
getAccounts
()
{
return
_accounts
.
values
();
}
...
...
@@ -84,28 +84,29 @@ private slots:
private
:
/* Helper methods */
void
createFolders
();
void
printEventHeaders
(
switch_event_t
*
event
);
void
printEventHeaders
(
QSharedPointer
<
switch_event_t
>
event
);
/*FSM State handlers*/
/** Channel Related*/
void
eventChannelCreate
(
switch_event_t
*
event
,
QString
uuid
);
void
eventChannelAnswer
(
switch_event_t
*
event
,
QString
uuid
);
void
eventChannelState
(
switch_event_t
*
event
,
QString
uuid
);
void
eventChannelExecute
(
switch_event_t
*
event
,
QString
uuid
);
void
eventChannelExecuteComplete
(
switch_event_t
*
event
,
QString
uuid
);
void
eventChannelOutgoing
(
switch_event_t
*
event
,
QString
uuid
);
void
eventChannelOriginate
(
switch_event_t
*
event
,
QString
uuid
);
void
eventChannelProgressMedia
(
switch_event_t
*
event
,
QString
uuid
);
void
eventChannelBridge
(
switch_event_t
*
event
,
QString
uuid
);
void
eventChannelHangup
(
switch_event_t
*
event
,
QString
uuid
);
void
eventChannelUnbridge
(
switch_event_t
*
event
,
QString
uuid
);
void
eventChannelHangupComplete
(
switch_event_t
*
event
,
QString
uuid
);
void
eventChannelDestroy
(
switch_event_t
*
event
,
QString
uuid
);
void
eventChannelCreate
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventChannelAnswer
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventChannelState
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventChannelExecute
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventChannelExecuteComplete
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventChannelOutgoing
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventChannelOriginate
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventChannelProgress
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventChannelProgressMedia
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventChannelBridge
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventChannelHangup
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventChannelUnbridge
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventChannelHangupComplete
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventChannelDestroy
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
/** Others*/
void
eventCodec
(
switch_event_t
*
event
,
QString
uuid
);
void
eventCallUpdate
(
switch_event_t
*
event
,
QString
uuid
);
void
eventRecvInfo
(
switch_event_t
*
event
,
QString
uuid
);
void
eventCodec
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventCallUpdate
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
void
eventRecvInfo
(
QSharedPointer
<
switch_event_t
>
event
,
QString
uuid
);
/* Structures to keep track of things */
QHash
<
QString
,
QSharedPointer
<
Call
>
>
_active_calls
;
...
...
@@ -125,9 +126,9 @@ static void eventHandlerCallback(switch_event_t *event)
{
switch_event_t
*
clone
=
NULL
;
if
(
switch_event_dup
(
&
clone
,
event
)
==
SWITCH_STATUS_SUCCESS
)
{
g_FSHost
.
generalEventHandler
(
clone
);
QSharedPointer
<
switch_event_t
>
e
(
clone
);
g_FSHost
.
generalEventHandler
(
e
);
}
switch_safe_free
(
clone
);
}
#endif // FSHOST_H
fscomm/mainwindow.cpp
浏览文件 @
3ed45189
...
...
@@ -133,7 +133,7 @@ void MainWindow::updateCallTimers()
QSharedPointer
<
Call
>
call
=
g_FSHost
.
getCallByUUID
(
item
->
data
(
Qt
::
UserRole
).
toString
());
QTime
time
=
call
.
data
()
->
getCurrentStateTime
();
item
->
setText
(
time
.
toString
(
"hh:mm:ss"
));
item
->
setTextAlignment
(
Qt
::
AlignRight
);
item
->
setTextAlignment
(
Qt
::
AlignRight
|
Qt
::
AlignVCenter
);
}
}
...
...
@@ -267,7 +267,6 @@ void MainWindow::makeCall()
switch_core_set_variable
(
"fscomm_caller_id_name"
,
cidName
.
toAscii
().
data
());
switch_core_set_variable
(
"fscomm_caller_id_num"
,
cidNum
.
toAscii
().
data
());
qDebug
()
<<
"Name:"
<<
cidName
<<
"Num:"
<<
cidNum
;
}
if
(
ok
&&
!
dialstring
.
isEmpty
())
...
...
@@ -396,12 +395,18 @@ void MainWindow::ringing(QSharedPointer<Call> call)
if
(
item
->
data
(
Qt
::
UserRole
).
toString
()
==
call
.
data
()
->
getUuid
())
{
item
->
setText
(
tr
(
"Ringing"
));
if
(
call
.
data
()
->
getDirection
()
==
FSCOMM_CALL_DIRECTION_INBOUND
)
ui
->
textEdit
->
setText
(
QString
(
"Call from %1 (%2)"
).
arg
(
call
.
data
()
->
getCidName
(),
call
.
data
()
->
getCidNumber
()));
else
ui
->
textEdit
->
setText
(
QString
(
"Call to %1 is ringing."
).
arg
(
call
.
data
()
->
getDestinationNumber
()));
return
;
}
}
if
(
call
.
data
()
->
getDirection
()
==
FSCOMM_CALL_DIRECTION_INBOUND
)
ui
->
textEdit
->
setText
(
QString
(
"Call from %1 (%2)"
).
arg
(
call
.
data
()
->
getCidName
(),
call
.
data
()
->
getCidNumber
()));
else
ui
->
textEdit
->
setText
(
QString
(
"Call to %1 is ringing."
).
arg
(
call
.
data
()
->
getDestinationNumber
()));
ui
->
tableCalls
->
setRowCount
(
ui
->
tableCalls
->
rowCount
()
+
1
);
QTableWidgetItem
*
item0
=
new
QTableWidgetItem
(
QString
(
"%1 (%2)"
).
arg
(
call
.
data
()
->
getCidName
(),
call
.
data
()
->
getCidNumber
()));
...
...
@@ -521,7 +526,7 @@ void MainWindow::hungup(QSharedPointer<Call> call)
}
else
{
ui
->
textEdit
->
setText
(
tr
(
"Call with %1 hungup."
).
arg
(
call
.
data
()
->
get
Cid
Number
()));
ui
->
textEdit
->
setText
(
tr
(
"Call with %1 hungup."
).
arg
(
call
.
data
()
->
get
Destination
Number
()));
}
/* TODO: Will cause problems if 2 calls are received at the same time */
ui
->
recoredCallBtn
->
setEnabled
(
false
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论