From bc0b04d2551f701a8dafa93e10a9ef91c58cf2a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Mesquita?= Date: Tue, 30 Mar 2010 02:09:08 +0000 Subject: [PATCH] Add more information to splash screen and warn users when very important modules are not loaded. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@17135 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- fscomm/fshost.cpp | 31 ++++++++++++++++++++++++++++--- fscomm/fshost.h | 6 ++++++ fscomm/main.cpp | 4 +++- fscomm/mainwindow.cpp | 20 +++++++++++++++++--- 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/fscomm/fshost.cpp b/fscomm/fshost.cpp index 564fa843bd..c5f5056c0d 100644 --- a/fscomm/fshost.cpp +++ b/fscomm/fshost.cpp @@ -45,6 +45,13 @@ FSHost::FSHost(QObject *parent) : qRegisterMetaType >("QSharedPointer"); qRegisterMetaType >("QSharedPointer"); + connect(this, SIGNAL(loadedModule(QString,QString,QString)), this, SLOT(minimalModuleLoaded(QString,QString,QString))); + +} + +QBool FSHost::isModuleLoaded(QString modName) +{ + return _loadedModules.contains(modName); } void FSHost::createFolders() @@ -117,14 +124,14 @@ void FSHost::run(void) createFolders(); /* If you need to override configuration directories, you need to change them in the SWITCH_GLOBAL_dirs global structure */ - qDebug() << "Initializing core..." << endl; + qDebug() << "Initializing core..."; /* Initialize the core and load modules, that will startup FS completely */ if (switch_core_init(flags, console, &err) != SWITCH_STATUS_SUCCESS) { fprintf(stderr, "Failed to initialize FreeSWITCH's core: %s\n", err); emit coreLoadingError(err); } - qDebug() << "Everything OK, Entering runtime loop ..." << endl; + qDebug() << "Everything OK, Entering runtime loop ..."; if (switch_event_bind("FSHost", SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, eventHandlerCallback, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); @@ -136,12 +143,14 @@ void FSHost::run(void) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't load mod_qsettings\n"); } + emit loadingModules("Loading modules...", Qt::AlignRight|Qt::AlignBottom, Qt::blue); if (switch_core_init_and_modload(flags, console, &err) != SWITCH_STATUS_SUCCESS) { fprintf(stderr, "Failed to initialize FreeSWITCH's core: %s\n", err); emit coreLoadingError(err); } emit ready(); + /* Go into the runtime loop. If the argument is true, this basically sets runtime.running = 1 and loops while that is set * If its false, it initializes the libedit for the console, then does the same thing */ @@ -154,7 +163,7 @@ void FSHost::run(void) destroy_status = switch_core_destroy(); if (destroy_status == SWITCH_STATUS_SUCCESS) { - qDebug() << "We have properly shutdown the core." << endl; + qDebug() << "We have properly shutdown the core."; } } @@ -407,11 +416,27 @@ void FSHost::generalEventHandler(switch_event_t *event) } break; } + case SWITCH_EVENT_MODULE_LOAD: + { + QString modType = switch_event_get_header_nil(event, "type"); + QString modName = switch_event_get_header_nil(event, "name"); + QString modKey = switch_event_get_header_nil(event, "key"); + emit loadedModule(modType, modName, modKey); + break; + } default: break; } } +void FSHost::minimalModuleLoaded(QString modType, QString modName, QString modKey) +{ + if (modType == "endpoint") + { + _loadedModules.append(modKey); + } +} + void FSHost::accountReloadCmd(QSharedPointer acc) { QString res; diff --git a/fscomm/fshost.h b/fscomm/fshost.h index e6b9a41bb6..f20cd036d2 100644 --- a/fscomm/fshost.h +++ b/fscomm/fshost.h @@ -30,6 +30,7 @@ #define FSHOST_H #include +#include #include #include #include @@ -50,12 +51,15 @@ public: QSharedPointer getCurrentDefaultAccount(); QSharedPointer getAccountByName(QString accStr); void accountReloadCmd(QSharedPointer acc); + QBool isModuleLoaded(QString); protected: void run(void); signals: void coreLoadingError(QString); + void loadingModules(QString, int, QColor); + void loadedModule(QString, QString, QString); void ready(void); void ringing(QSharedPointer); void answered(QSharedPointer); @@ -69,6 +73,7 @@ signals: private slots: /* We need to wait for the gateway deletion before reloading it */ void accountReloadSlot(QSharedPointer); + void minimalModuleLoaded(QString, QString, QString); private: switch_status_t processBlegEvent(switch_event_t *, QString); @@ -79,6 +84,7 @@ private: QHash > _accounts; QHash _bleg_uuids; QList _reloading_Accounts; + QList _loadedModules; }; extern FSHost g_FSHost; diff --git a/fscomm/main.cpp b/fscomm/main.cpp index 9f8c461c7e..147314b66f 100644 --- a/fscomm/main.cpp +++ b/fscomm/main.cpp @@ -41,7 +41,9 @@ int main(int argc, char *argv[]) QPixmap image(":/images/splash.png"); QSplashScreen *splash = new QSplashScreen(image); splash->show(); - splash->showMessage("Loading, please wait...", Qt::AlignRight|Qt::AlignBottom, Qt::blue); + splash->showMessage("Loading core, please wait...", Qt::AlignRight|Qt::AlignBottom, Qt::blue); + + QObject::connect(&g_FSHost, SIGNAL(loadingModules(QString,int,QColor)), splash, SLOT(showMessage(QString,int,QColor))); QObject::connect(&g_FSHost, SIGNAL(ready()), splash, SLOT(close())); MainWindow w; diff --git a/fscomm/mainwindow.cpp b/fscomm/mainwindow.cpp index 95f8e3343d..c9d42022b4 100644 --- a/fscomm/mainwindow.cpp +++ b/fscomm/mainwindow.cpp @@ -90,7 +90,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(&g_FSHost, SIGNAL(accountStateChange(QSharedPointer)), this, SLOT(accountStateChanged(QSharedPointer))); connect(&g_FSHost, SIGNAL(newAccount(QSharedPointer)), this, SLOT(accountAdd(QSharedPointer))); connect(&g_FSHost, SIGNAL(delAccount(QSharedPointer)), this, SLOT(accountDel(QSharedPointer))); - /*connect(&g_FSHost, SIGNAL(coreLoadingError(QString)), this, SLOT(coreLoadingError(QString)));*/ + connect(&g_FSHost, SIGNAL(coreLoadingError(QString)), this, SLOT(coreLoadingError(QString))); /* Connect call commands */ connect(ui->newCallBtn, SIGNAL(clicked()), this, SLOT(makeCall())); @@ -163,8 +163,9 @@ void MainWindow::prefTriggered() void MainWindow::coreLoadingError(QString err) { - QMessageBox::warning(this, "Error Loading Core...", err, QMessageBox::Ok); - QApplication::exit(255); + QMessageBox::critical(this, tr("Core error!"), + tr("The core failed to load. Please, ask for help as the softphone will not be useable. Error code: %1").arg(err), + QMessageBox::Ok); } void MainWindow::accountAdd(QSharedPointer acc) @@ -283,6 +284,19 @@ void MainWindow::fshostReady() ui->textEdit->setText("Ready to dial and receive calls!"); sysTray->show(); sysTray->showMessage(tr("Status"), tr("FSComm has initialized!"), QSystemTrayIcon::Information, 5000); + + if (!g_FSHost.isModuleLoaded("mod_sofia")) + { + QMessageBox::warning(this, tr("SIP not available"), + tr("Sofia could not be loaded, therefore, SIP will not be available."), + QMessageBox::Ok); + } + if (!g_FSHost.isModuleLoaded("mod_portaudio")) + { + QMessageBox::warning(this, tr("Audio not available"), + tr("Portaudio could not be loaded. Please check if mod_portaudio is properly compiled."), + QMessageBox::Ok); + } } void MainWindow::paAnswer()