]> git.ipfire.org Git - thirdparty/freeswitch.git/blob - fscomm/fshost.h
[Build-System] Update libks and signalwire-c requirements to 2.0
[thirdparty/freeswitch.git] / fscomm / fshost.h
1 /*
2 * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3 * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
4 *
5 * Version: MPL 1.1
6 *
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
11 *
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
15 * License.
16 *
17 * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18 *
19 * The Initial Developer of the Original Code is
20 * Anthony Minessale II <anthm@freeswitch.org>
21 * Portions created by the Initial Developer are Copyright (C)
22 * the Initial Developer. All Rights Reserved.
23 *
24 * Contributor(s):
25 *
26 * Joao Mesquita <jmesquita@freeswitch.org>
27 *
28 */
29 #ifndef FSHOST_H
30 #define FSHOST_H
31
32 #include <QThread>
33 #include <QColor>
34 #include <QHash>
35 #include <QSharedPointer>
36 #include <switch.h>
37 #include "call.h"
38 #include "channel.h"
39 #include "account.h"
40 #include "fscomm.h"
41
42
43 static void eventHandlerCallback(switch_event_t *);
44 static switch_status_t loggerHandler(const switch_log_node_t *, switch_log_level_t);
45
46 class FSHost : public QThread
47 {
48 Q_OBJECT
49 public:
50 explicit FSHost(QObject *parent = 0);
51 switch_status_t sendCmd(const char *cmd, const char *args, QString *res);
52 void generalEventHandler(QSharedPointer<switch_event_t>event);
53 void generalLoggerHandler(QSharedPointer<switch_log_node_t>node, switch_log_level_t level);
54 void printEventHeaders(QSharedPointer<switch_event_t>event);
55 QSharedPointer<Call> getCallByUUID(QString uuid) { return _active_calls.value(uuid); }
56 QSharedPointer<Call> getCurrentActiveCall();
57 QList<QSharedPointer<Account> > getAccounts() { return _accounts.values(); }
58 QSharedPointer<Account> getAccountByUUID(QString uuid);
59 QSharedPointer<Account> getCurrentDefaultAccount();
60 QSharedPointer<Account> getAccountByName(QString accStr);
61 void accountReloadCmd(QSharedPointer<Account> acc);
62 QBool isModuleLoaded(QString);
63
64 protected:
65 void run(void);
66
67 signals:
68 /* Status signals */
69 void coreLoadingError(QString);
70 void loadingModules(QString, int, QColor);
71 void loadedModule(QString, QString);
72 void ready(void);
73
74
75 /* Logging signals */
76 void eventLog(QSharedPointer<switch_log_node_t>, switch_log_level_t);
77 void newEvent(QSharedPointer<switch_event_t>);
78
79 /* Call signals */
80 void ringing(QSharedPointer<Call>);
81 void answered(QSharedPointer<Call>);
82 void newOutgoingCall(QSharedPointer<Call>);
83 void callFailed(QSharedPointer<Call>);
84 void hungup(QSharedPointer<Call>);
85
86 /* Account signals */
87 void accountStateChange(QSharedPointer<Account>);
88 void newAccount(QSharedPointer<Account>);
89 void delAccount(QSharedPointer<Account>);
90
91 private slots:
92 /* We need to wait for the gateway deletion before reloading it */
93 void accountReloadSlot(QSharedPointer<Account>);
94 void minimalModuleLoaded(QString, QString);
95
96 private:
97 /* Helper methods */
98 void createFolders();
99
100 /*FSM State handlers*/
101 /** Channel Related*/
102 void eventChannelCreate(QSharedPointer<switch_event_t> event, QString uuid);
103 void eventChannelAnswer(QSharedPointer<switch_event_t> event, QString uuid);
104 void eventChannelState(QSharedPointer<switch_event_t>event, QString uuid);
105 void eventChannelExecute(QSharedPointer<switch_event_t>event, QString uuid);
106 void eventChannelExecuteComplete(QSharedPointer<switch_event_t>event, QString uuid);
107 void eventChannelOutgoing(QSharedPointer<switch_event_t>event, QString uuid);
108 void eventChannelOriginate(QSharedPointer<switch_event_t>event, QString uuid);
109 void eventChannelProgress(QSharedPointer<switch_event_t>event, QString uuid);
110 void eventChannelProgressMedia(QSharedPointer<switch_event_t>event, QString uuid);
111 void eventChannelBridge(QSharedPointer<switch_event_t>event, QString uuid);
112 void eventChannelHangup(QSharedPointer<switch_event_t>event, QString uuid);
113 void eventChannelUnbridge(QSharedPointer<switch_event_t>event, QString uuid);
114 void eventChannelHangupComplete(QSharedPointer<switch_event_t>event, QString uuid);
115 void eventChannelDestroy(QSharedPointer<switch_event_t>event, QString uuid);
116
117 /** Others*/
118 void eventCodec(QSharedPointer<switch_event_t>event, QString uuid);
119 void eventCallUpdate(QSharedPointer<switch_event_t>event, QString uuid);
120 void eventRecvInfo(QSharedPointer<switch_event_t>event, QString uuid);
121
122 /* Structures to keep track of things */
123 QHash<QString, QSharedPointer<Call> > _active_calls;
124 QHash<QString, QSharedPointer<Account> > _accounts;
125 QHash<QString, QSharedPointer<Channel> > _channels;
126 QList<QString> _reloading_Accounts;
127 QList<QString> _loadedModules;
128 };
129
130 extern FSHost *g_FSHost;
131
132 #endif // FSHOST_H