/* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application * * The Initial Developer of the Original Code is * Anthony Minessale II * Portions created by the Initial Developer are Copyright (C) * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Joao Mesquita * */ #ifndef FSHOST_H #define FSHOST_H #include #include #include #include #include #include "call.h" #include "channel.h" #include "account.h" #include "fscomm.h" static void eventHandlerCallback(switch_event_t *); static switch_status_t loggerHandler(const switch_log_node_t *, switch_log_level_t); class FSHost : public QThread { Q_OBJECT public: explicit FSHost(QObject *parent = 0); switch_status_t sendCmd(const char *cmd, const char *args, QString *res); void generalEventHandler(QSharedPointerevent); void generalLoggerHandler(QSharedPointernode, switch_log_level_t level); void printEventHeaders(QSharedPointerevent); QSharedPointer getCallByUUID(QString uuid) { return _active_calls.value(uuid); } QSharedPointer getCurrentActiveCall(); QList > getAccounts() { return _accounts.values(); } QSharedPointer getAccountByUUID(QString uuid); QSharedPointer getCurrentDefaultAccount(); QSharedPointer getAccountByName(QString accStr); void accountReloadCmd(QSharedPointer acc); QBool isModuleLoaded(QString); protected: void run(void); signals: /* Status signals */ void coreLoadingError(QString); void loadingModules(QString, int, QColor); void loadedModule(QString, QString); void ready(void); /* Logging signals */ void eventLog(QSharedPointer, switch_log_level_t); void newEvent(QSharedPointer); /* Call signals */ void ringing(QSharedPointer); void answered(QSharedPointer); void newOutgoingCall(QSharedPointer); void callFailed(QSharedPointer); void hungup(QSharedPointer); /* Account signals */ void accountStateChange(QSharedPointer); void newAccount(QSharedPointer); void delAccount(QSharedPointer); private slots: /* We need to wait for the gateway deletion before reloading it */ void accountReloadSlot(QSharedPointer); void minimalModuleLoaded(QString, QString); private: /* Helper methods */ void createFolders(); /*FSM State handlers*/ /** Channel Related*/ void eventChannelCreate(QSharedPointer event, QString uuid); void eventChannelAnswer(QSharedPointer event, QString uuid); void eventChannelState(QSharedPointerevent, QString uuid); void eventChannelExecute(QSharedPointerevent, QString uuid); void eventChannelExecuteComplete(QSharedPointerevent, QString uuid); void eventChannelOutgoing(QSharedPointerevent, QString uuid); void eventChannelOriginate(QSharedPointerevent, QString uuid); void eventChannelProgress(QSharedPointerevent, QString uuid); void eventChannelProgressMedia(QSharedPointerevent, QString uuid); void eventChannelBridge(QSharedPointerevent, QString uuid); void eventChannelHangup(QSharedPointerevent, QString uuid); void eventChannelUnbridge(QSharedPointerevent, QString uuid); void eventChannelHangupComplete(QSharedPointerevent, QString uuid); void eventChannelDestroy(QSharedPointerevent, QString uuid); /** Others*/ void eventCodec(QSharedPointerevent, QString uuid); void eventCallUpdate(QSharedPointerevent, QString uuid); void eventRecvInfo(QSharedPointerevent, QString uuid); /* Structures to keep track of things */ QHash > _active_calls; QHash > _accounts; QHash > _channels; QList _reloading_Accounts; QList _loadedModules; }; extern FSHost *g_FSHost; #endif // FSHOST_H