]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Add more information to splash screen and warn users when very important modules...
authorJoão Mesquita <jmesquita@freeswitch.org>
Tue, 30 Mar 2010 02:09:08 +0000 (02:09 +0000)
committerJoão Mesquita <jmesquita@freeswitch.org>
Tue, 30 Mar 2010 02:09:08 +0000 (02:09 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@17135 d0543943-73ff-0310-b7d9-9358b9ac24b2

fscomm/fshost.cpp
fscomm/fshost.h
fscomm/main.cpp
fscomm/mainwindow.cpp

index 564fa843bde1215e6e98bd832217a593c80f92e0..c5f5056c0d6cf656d1240eda368c6a71bb7fbab7 100644 (file)
@@ -45,6 +45,13 @@ FSHost::FSHost(QObject *parent) :
     qRegisterMetaType<QSharedPointer<Call> >("QSharedPointer<Call>");
     qRegisterMetaType<QSharedPointer<Account> >("QSharedPointer<Account>");
 
+    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<Account> acc)
 {
     QString res;
index e6b9a41bb6e75a05cfeb6a554a7a0b63f1f93427..f20cd036d2df15ff75130ba6813ef2af21c9881a 100644 (file)
@@ -30,6 +30,7 @@
 #define FSHOST_H
 
 #include <QThread>
+#include <QColor>
 #include <QHash>
 #include <QSharedPointer>
 #include <switch.h>
@@ -50,12 +51,15 @@ public:
     QSharedPointer<Account> getCurrentDefaultAccount();
     QSharedPointer<Account> getAccountByName(QString accStr);
     void accountReloadCmd(QSharedPointer<Account> 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<Call>);
     void answered(QSharedPointer<Call>);
@@ -69,6 +73,7 @@ signals:
 private slots:
     /* We need to wait for the gateway deletion before reloading it */
     void accountReloadSlot(QSharedPointer<Account>);
+    void minimalModuleLoaded(QString, QString, QString);
 
 private:
     switch_status_t processBlegEvent(switch_event_t *, QString);
@@ -79,6 +84,7 @@ private:
     QHash<QString, QSharedPointer<Account> > _accounts;
     QHash<QString, QString> _bleg_uuids;
     QList<QString> _reloading_Accounts;
+    QList<QString> _loadedModules;
 };
 
 extern FSHost g_FSHost;
index 9f8c461c7e6382fcec9e9d2781f36a732c671c16..147314b66fab164592792ce809811de8ed2e8bf4 100644 (file)
@@ -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;    
index 95f8e3343d8596772ef2ca407687b37f83d49d91..c9d42022b4fc5024f37493b942834defa082f2b3 100644 (file)
@@ -90,7 +90,7 @@ MainWindow::MainWindow(QWidget *parent) :
     connect(&g_FSHost, SIGNAL(accountStateChange(QSharedPointer<Account>)), this, SLOT(accountStateChanged(QSharedPointer<Account>)));
     connect(&g_FSHost, SIGNAL(newAccount(QSharedPointer<Account>)), this, SLOT(accountAdd(QSharedPointer<Account>)));
     connect(&g_FSHost, SIGNAL(delAccount(QSharedPointer<Account>)), this, SLOT(accountDel(QSharedPointer<Account>)));
-    /*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<Account> 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()