Revision
17135
Author
jmesquita
Date
2010-03-29 21:09:08 -0500 (Mon, 29 Mar 2010)

Log Message

Add more information to splash screen and warn users when very important modules are not loaded.

Modified Paths

Diff

Modified: freeswitch/trunk/fscomm/fshost.cpp (17134 => 17135)


--- freeswitch/trunk/fscomm/fshost.cpp	2010-03-29 23:02:47 UTC (rev 17134)
+++ freeswitch/trunk/fscomm/fshost.cpp	2010-03-30 02:09:08 UTC (rev 17135)
@@ -45,8 +45,15 @@
     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()
 {
     /* Create directory structure for softphone with default configs */
@@ -117,14 +124,14 @@
     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 @@
         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 @@
     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 @@
             }
             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;

Modified: freeswitch/trunk/fscomm/fshost.h (17134 => 17135)


--- freeswitch/trunk/fscomm/fshost.h	2010-03-29 23:02:47 UTC (rev 17134)
+++ freeswitch/trunk/fscomm/fshost.h	2010-03-30 02:09:08 UTC (rev 17135)
@@ -30,6 +30,7 @@
 #define FSHOST_H
 
 #include <QThread>
+#include <QColor>
 #include <QHash>
 #include <QSharedPointer>
 #include <switch.h>
@@ -50,12 +51,15 @@
     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 @@
 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 @@
     QHash<QString, QSharedPointer<Account> > _accounts;
     QHash<QString, QString> _bleg_uuids;
     QList<QString> _reloading_Accounts;
+    QList<QString> _loadedModules;
 };
 
 extern FSHost g_FSHost;

Modified: freeswitch/trunk/fscomm/main.cpp (17134 => 17135)


--- freeswitch/trunk/fscomm/main.cpp	2010-03-29 23:02:47 UTC (rev 17134)
+++ freeswitch/trunk/fscomm/main.cpp	2010-03-30 02:09:08 UTC (rev 17135)
@@ -41,8 +41,10 @@
     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;    
     QObject::connect(&g_FSHost, SIGNAL(ready()), &w, SLOT(show()));

Modified: freeswitch/trunk/fscomm/mainwindow.cpp (17134 => 17135)


--- freeswitch/trunk/fscomm/mainwindow.cpp	2010-03-29 23:02:47 UTC (rev 17134)
+++ freeswitch/trunk/fscomm/mainwindow.cpp	2010-03-30 02:09:08 UTC (rev 17135)
@@ -90,7 +90,7 @@
     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::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 @@
     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()