Index: trunk/BNC/src/GPSS/gpssDecoder.cpp
===================================================================
--- trunk/BNC/src/GPSS/gpssDecoder.cpp	(revision 5064)
+++ trunk/BNC/src/GPSS/gpssDecoder.cpp	(revision 5066)
@@ -51,5 +51,5 @@
 gpssDecoder::gpssDecoder() : GPSDecoder() {
   connect(this, SIGNAL(newGPSEph(gpsephemeris*)), 
-          (bncApp*) qApp, SLOT(slotNewGPSEph(gpsephemeris*)));
+          PGM_CORE, SLOT(slotNewGPSEph(gpsephemeris*)));
 }
 
Index: trunk/BNC/src/GPSS/hassDecoder.cpp
===================================================================
--- trunk/BNC/src/GPSS/hassDecoder.cpp	(revision 5064)
+++ trunk/BNC/src/GPSS/hassDecoder.cpp	(revision 5066)
@@ -47,5 +47,5 @@
 
   connect(this, SIGNAL(newCorrLine(QString, QString, long)), 
-          (bncApp*) qApp, SLOT(slotNewCorrLine(QString, QString, long)));
+          PGM_CORE, SLOT(slotNewCorrLine(QString, QString, long)));
 }
 
Index: trunk/BNC/src/RTCM3/RTCM3Decoder.cpp
===================================================================
--- trunk/BNC/src/RTCM3/RTCM3Decoder.cpp	(revision 5064)
+++ trunk/BNC/src/RTCM3/RTCM3Decoder.cpp	(revision 5066)
@@ -75,9 +75,9 @@
 
   connect(this, SIGNAL(newGPSEph(gpsephemeris*)), 
-          (bncApp*) qApp, SLOT(slotNewGPSEph(gpsephemeris*)));
+          PGM_CORE, SLOT(slotNewGPSEph(gpsephemeris*)));
   connect(this, SIGNAL(newGlonassEph(glonassephemeris*)), 
-          (bncApp*) qApp, SLOT(slotNewGlonassEph(glonassephemeris*)));
+          PGM_CORE, SLOT(slotNewGlonassEph(glonassephemeris*)));
   connect(this, SIGNAL(newGalileoEph(galileoephemeris*)), 
-          (bncApp*) qApp, SLOT(slotNewGalileoEph(galileoephemeris*)));
+          PGM_CORE, SLOT(slotNewGalileoEph(galileoephemeris*)));
 
   // Mode can be either observations or corrections
@@ -149,6 +149,5 @@
   // Get Glonass Slot Numbers from Global Array
   // ------------------------------------------
-  bncApp* app = (bncApp*) qApp;
-  app->getGlonassSlotNums(parser.GLOFreq);
+  PGM_CORE->getGlonassSlotNums(parser.GLOFreq);
 
   // Remaining part decodes the Observations
@@ -378,5 +377,5 @@
 
   if (decoded) {
-    app->storeGlonassSlotNums(parser.GLOFreq);
+    PGM_CORE->storeGlonassSlotNums(parser.GLOFreq);
     return success;
   }
Index: trunk/BNC/src/RTCM3/RTCM3coDecoder.cpp
===================================================================
--- trunk/BNC/src/RTCM3/RTCM3coDecoder.cpp	(revision 5064)
+++ trunk/BNC/src/RTCM3/RTCM3coDecoder.cpp	(revision 5066)
@@ -73,8 +73,8 @@
 
   connect(this, SIGNAL(newCorrLine(QString, QString, long)), 
-          (bncApp*) qApp, SLOT(slotNewCorrLine(QString, QString, long)));
+          PGM_CORE, SLOT(slotNewCorrLine(QString, QString, long)));
 
   connect(this, SIGNAL(newMessage(QByteArray,bool)), 
-          (bncApp*) qApp, SLOT(slotMessage(const QByteArray,bool)));
+          PGM_CORE, SLOT(slotMessage(const QByteArray,bool)));
 
   memset(&_co, 0, sizeof(_co));
Index: trunk/BNC/src/RTCM3/ephemeris.cpp
===================================================================
--- trunk/BNC/src/RTCM3/ephemeris.cpp	(revision 5064)
+++ trunk/BNC/src/RTCM3/ephemeris.cpp	(revision 5066)
@@ -416,5 +416,5 @@
     }
 
-    if (timeChanged && ((bncApp*) qApp)->mode() == bncApp::batchPostProcessing) {
+    if (timeChanged && PGM_CORE->mode() == t_pgmCore::batchPostProcessing) {
       bncTime newHTime(ww, (double) tow);
       cout << "GLONASS " << ee->almanac_number <<  " Time Changed at " 
Index: trunk/BNC/src/RTRover/bncrtrover.cpp
===================================================================
--- trunk/BNC/src/RTRover/bncrtrover.cpp	(revision 5064)
+++ trunk/BNC/src/RTRover/bncrtrover.cpp	(revision 5066)
@@ -93,14 +93,14 @@
   // Connect to BNC Signals
   // ----------------------
-  connect(((bncApp*)qApp), SIGNAL(newCorrections(QList<QString>)),
+  connect(PGM_CORE, SIGNAL(newCorrections(QList<QString>)),
           this, SLOT(slotNewCorrections(QList<QString>)));
 
-  connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
+  connect(PGM_CORE, SIGNAL(newEphGPS(gpsephemeris)),
           this, SLOT(slotNewEphGPS(gpsephemeris)));
 
-  connect(((bncApp*)qApp), SIGNAL(newEphGlonass(glonassephemeris)),
+  connect(PGM_CORE, SIGNAL(newEphGlonass(glonassephemeris)),
           this, SLOT(slotNewEphGlonass(glonassephemeris)));
 
-  connect(((bncApp*)qApp), SIGNAL(newEphGalileo(galileoephemeris)),
+  connect(PGM_CORE, SIGNAL(newEphGalileo(galileoephemeris)),
           this, SLOT(slotNewEphGalileo(galileoephemeris)));
  
Index: trunk/BNC/src/bncapp.cpp
===================================================================
--- trunk/BNC/src/bncapp.cpp	(revision 5064)
+++ trunk/BNC/src/bncapp.cpp	(revision 5066)
@@ -27,5 +27,5 @@
  * -------------------------------------------------------------------------
  *
- * Class:      bncApp
+ * Class:      t_pgmCore
  *
  * Purpose:    This class implements the main application
@@ -58,7 +58,5 @@
 // Constructor
 ////////////////////////////////////////////////////////////////////////////
-bncApp::bncApp(int& argc, char* argv[], bool GUIenabled) : 
-  QApplication(argc, argv, GUIenabled) {
-
+t_pgmCore::t_pgmCore(int& argc, char* argv[], bool GUIenabled) {
   _GUIenabled  = GUIenabled;
   _logFileFlag = 0;
@@ -127,5 +125,5 @@
 // Destructor
 ////////////////////////////////////////////////////////////////////////////
-bncApp::~bncApp() {
+t_pgmCore::~t_pgmCore() {
   delete _logStream;
   delete _logFile;
@@ -163,5 +161,5 @@
 // Write a Program Message
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::slotMessage(QByteArray msg, bool showOnScreen) {
+void t_pgmCore::slotMessage(QByteArray msg, bool showOnScreen) {
 
   QMutexLocker locker(&_mutexMessage);
@@ -173,5 +171,5 @@
 // Write a Program Message (private, no lock)
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::messagePrivate(const QByteArray& msg) {
+void t_pgmCore::messagePrivate(const QByteArray& msg) {
 
   // First time resolve the log file name
@@ -215,5 +213,5 @@
 // New GPS Ephemeris 
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::slotNewGPSEph(gpsephemeris* gpseph) {
+void t_pgmCore::slotNewGPSEph(gpsephemeris* gpseph) {
 
   QMutexLocker locker(&_mutex);
@@ -246,5 +244,5 @@
 // New Glonass Ephemeris
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::slotNewGlonassEph(glonassephemeris* glonasseph) {
+void t_pgmCore::slotNewGlonassEph(glonassephemeris* glonasseph) {
 
   QMutexLocker locker(&_mutex);
@@ -292,5 +290,5 @@
 // New Galileo Ephemeris
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::slotNewGalileoEph(galileoephemeris* galileoeph) {
+void t_pgmCore::slotNewGalileoEph(galileoephemeris* galileoeph) {
 
   QMutexLocker locker(&_mutex);
@@ -327,5 +325,5 @@
 // Print Header of the output File(s)
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::printEphHeader() {
+void t_pgmCore::printEphHeader() {
 
   bncSettings settings;
@@ -499,5 +497,5 @@
 // Print One GPS Ephemeris
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::printGPSEph(gpsephemeris* ep, bool printFile) {
+void t_pgmCore::printGPSEph(gpsephemeris* ep, bool printFile) {
 
   t_ephGPS eph;
@@ -512,5 +510,5 @@
 // Print One Glonass Ephemeris
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::printGlonassEph(glonassephemeris* ep, bool printFile) {
+void t_pgmCore::printGlonassEph(glonassephemeris* ep, bool printFile) {
 
   t_ephGlo eph;
@@ -526,5 +524,5 @@
 // Print One Galileo Ephemeris
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::printGalileoEph(galileoephemeris* ep, bool printFile) {
+void t_pgmCore::printGalileoEph(galileoephemeris* ep, bool printFile) {
 
   t_ephGal eph;
@@ -539,5 +537,5 @@
 // Output
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::printOutput(bool printFile, QTextStream* stream,
+void t_pgmCore::printOutput(bool printFile, QTextStream* stream,
                          const QString& strV2, const QString& strV3) {
 
@@ -576,5 +574,5 @@
 // Set Port Number
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::setPort(int port) {
+void t_pgmCore::setPort(int port) {
   _port = port;
   if (_port != 0) {
@@ -582,5 +580,5 @@
     _server = new QTcpServer;
     if ( !_server->listen(QHostAddress::Any, _port) ) {
-      slotMessage("bncApp: Cannot listen on ephemeris port", true);
+      slotMessage("t_pgmCore: Cannot listen on ephemeris port", true);
     }
     connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
@@ -592,5 +590,5 @@
 // Set Port Number
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::setPortCorr(int port) {
+void t_pgmCore::setPortCorr(int port) {
   _portCorr = port;
   if (_portCorr != 0) {
@@ -598,5 +596,5 @@
     _serverCorr = new QTcpServer;
     if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) {
-      slotMessage("bncApp: Cannot listen on correction port", true);
+      slotMessage("t_pgmCore: Cannot listen on correction port", true);
     }
     connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr()));
@@ -608,5 +606,5 @@
 // New Connection
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::slotNewConnection() {
+void t_pgmCore::slotNewConnection() {
   _sockets->push_back( _server->nextPendingConnection() );
 }
@@ -614,5 +612,5 @@
 // New Connection
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::slotNewConnectionCorr() {
+void t_pgmCore::slotNewConnectionCorr() {
   _socketsCorr->push_back( _serverCorr->nextPendingConnection() );
 }
@@ -620,13 +618,13 @@
 // 
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::slotQuit() {
-  cout << "bncApp::slotQuit" << endl;
+void t_pgmCore::slotQuit() {
+  cout << "t_pgmCore::slotQuit" << endl;
   delete _caster;
-  quit();
+  qApp->quit();
 }
 
 // 
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::slotNewCorrLine(QString line, QString staID, long coTime) {
+void t_pgmCore::slotNewCorrLine(QString line, QString staID, long coTime) {
 
   QMutexLocker locker(&_mutex);
@@ -680,5 +678,5 @@
 // Dump Complete Correction Epochs
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::dumpCorrs(long minTime, long maxTime) {
+void t_pgmCore::dumpCorrs(long minTime, long maxTime) {
   for (long sec = minTime; sec <= maxTime; sec++) {
     QList<QString> allCorrs = _corrs->values(sec);
@@ -690,5 +688,5 @@
 // Dump all corrections
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::dumpCorrs() {
+void t_pgmCore::dumpCorrs() {
   QList<QString> allCorrs;
   QMutableMapIterator<long, QString> it(*_corrs);
@@ -702,5 +700,5 @@
 // Dump List of Corrections 
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::dumpCorrs(const QList<QString>& allCorrs) {
+void t_pgmCore::dumpCorrs(const QList<QString>& allCorrs) {
   emit newCorrections(allCorrs);
   if (_socketsCorr) {
@@ -729,10 +727,10 @@
 // 
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::setConfFileName(const QString& confFileName) {
+void t_pgmCore::setConfFileName(const QString& confFileName) {
   if (confFileName.isEmpty()) {
     _confFileName = QDir::homePath() + QDir::separator() 
                   + ".config" + QDir::separator()
-                  + organizationName() + QDir::separator()
-                  + applicationName() + ".bnc";
+                  + qApp->organizationName() + QDir::separator()
+                  + qApp->applicationName() + ".bnc";
   }
   else {
@@ -743,5 +741,5 @@
 // Raw Output
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::writeRawData(const QByteArray& data, const QByteArray& staID,
+void t_pgmCore::writeRawData(const QByteArray& data, const QByteArray& staID,
                           const QByteArray& format) {
 
@@ -763,5 +761,5 @@
 // Get Glonass Slot Numbers from Global Array
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::getGlonassSlotNums(int GLOFreq[]) {
+void t_pgmCore::getGlonassSlotNums(int GLOFreq[]) {
 
   QMutexLocker locker(&_mutex);
@@ -776,5 +774,5 @@
 // Store Glonass Slot Numbers to Global Array
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::storeGlonassSlotNums(const int GLOFreq[]) {
+void t_pgmCore::storeGlonassSlotNums(const int GLOFreq[]) {
 
   QMutexLocker locker(&_mutex);
@@ -789,5 +787,5 @@
 // 
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::initCombination() {
+void t_pgmCore::initCombination() {
 #ifdef USE_COMBINATION
   _bncComb = new bncComb();
@@ -801,5 +799,5 @@
 // 
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::stopCombination() {
+void t_pgmCore::stopCombination() {
 #ifdef USE_COMBINATION
   delete _bncComb;
@@ -808,20 +806,7 @@
 }
 
-// Handling Events (virtual)
-////////////////////////////////////////////////////////////////////////////
-bool bncApp::event(QEvent* ev) {
-
-  if (ev->type() == QEvent::FileOpen) {  // currently happens on Mac only
-    QString fileName = static_cast<QFileOpenEvent*>(ev)->file();
-    setConfFileName(fileName);
-    return true;
-  }
-    
-  return QApplication::event(ev);
-}
-
 // Check Ephemeris Consistency
 ////////////////////////////////////////////////////////////////////////////
-void bncApp::checkEphemeris(gpsephemeris* oldEph, gpsephemeris* newEph) {
+void t_pgmCore::checkEphemeris(gpsephemeris* oldEph, gpsephemeris* newEph) {
   if (oldEph->clock_bias      != newEph->clock_bias      ||
       oldEph->clock_drift     != newEph->clock_drift     ||
Index: trunk/BNC/src/bncapp.h
===================================================================
--- trunk/BNC/src/bncapp.h	(revision 5064)
+++ trunk/BNC/src/bncapp.h	(revision 5066)
@@ -36,5 +36,5 @@
 class bncTableItem;
 
-class bncApp : public QApplication {
+class t_pgmCore : public QObject {
   Q_OBJECT
 
@@ -44,6 +44,6 @@
   public:
     enum e_mode {interactive, nonInteractive, batchPostProcessing};
-    bncApp(int& argc, char* argv[], bool GUIenabled);
-    virtual ~bncApp();  
+    t_pgmCore(int& argc, char* argv[], bool GUIenabled);
+    virtual ~t_pgmCore();  
     e_mode mode() const {return _mode;}
     void   setMode(e_mode mode) {_mode = mode;}
@@ -65,6 +65,4 @@
     void setMainWindow(QWidget* mainWindow){_mainWindow = mainWindow;}
     bool GUIenabled() const {return _GUIenabled;}
-  protected:
-    virtual bool event(QEvent* ev);
 
   public slots:
@@ -143,3 +141,6 @@
     QMap<int, bncTableItem*> _uploadTableItems;
 };
+
+extern t_pgmCore* PGM_CORE;
+
 #endif
Index: trunk/BNC/src/bnccaster.cpp
===================================================================
--- trunk/BNC/src/bnccaster.cpp	(revision 5064)
+++ trunk/BNC/src/bnccaster.cpp	(revision 5066)
@@ -65,5 +65,5 @@
 
   connect(this, SIGNAL(newMessage(QByteArray,bool)), 
-          (bncApp*) qApp, SLOT(slotMessage(const QByteArray,bool)));
+          PGM_CORE, SLOT(slotMessage(const QByteArray,bool)));
 
   if ( !outFileName.isEmpty() ) {
@@ -483,5 +483,5 @@
   emit mountPointsRead(_threads);
   emit( newMessage(QString("Configuration read: "
-                           + ((bncApp*) qApp)->confFileName()
+                           + PGM_CORE->confFileName()
                            + ", %1 stream(s)")
                             .arg(_threads.count()).toAscii(), true) );
Index: trunk/BNC/src/bncephuser.cpp
===================================================================
--- trunk/BNC/src/bncephuser.cpp	(revision 5064)
+++ trunk/BNC/src/bncephuser.cpp	(revision 5066)
@@ -51,11 +51,11 @@
 
   if (connectSlots) {
-    connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
+    connect(PGM_CORE, SIGNAL(newEphGPS(gpsephemeris)),
             this, SLOT(slotNewEphGPS(gpsephemeris)), Qt::DirectConnection);
     
-    connect(((bncApp*)qApp), SIGNAL(newEphGlonass(glonassephemeris)),
+    connect(PGM_CORE, SIGNAL(newEphGlonass(glonassephemeris)),
             this, SLOT(slotNewEphGlonass(glonassephemeris)), Qt::DirectConnection);
     
-    connect(((bncApp*)qApp), SIGNAL(newEphGalileo(galileoephemeris)),
+    connect(PGM_CORE, SIGNAL(newEphGalileo(galileoephemeris)),
             this, SLOT(slotNewEphGalileo(galileoephemeris)), Qt::DirectConnection);
   }
Index: trunk/BNC/src/bncgetthread.cpp
===================================================================
--- trunk/BNC/src/bncgetthread.cpp	(revision 5064)
+++ trunk/BNC/src/bncgetthread.cpp	(revision 5066)
@@ -121,8 +121,6 @@
   setTerminationEnabled(true);
 
-  bncApp* app = (bncApp*) qApp;
-
   connect(this, SIGNAL(newMessage(QByteArray,bool)), 
-          app, SLOT(slotMessage(const QByteArray,bool)));
+          PGM_CORE, SLOT(slotMessage(const QByteArray,bool)));
 
   _isToBeDeleted = false;
@@ -333,6 +331,5 @@
       settings.value("pppMount").toString() == _staID) {
     _PPPclient = new bncPPPclient(_staID);
-    bncApp* app = (bncApp*) qApp;
-    app->_bncPPPclient = _PPPclient;
+    PGM_CORE->_bncPPPclient = _PPPclient;
     qRegisterMetaType<bncTime>("bncTime");
     connect(_PPPclient, SIGNAL(newPosition(bncTime, double, double, double)), 
@@ -443,5 +440,5 @@
         if (data.isEmpty()) {
           cout << "no more data" << endl;
-          ((bncApp*) qApp)->stopCombination();
+          PGM_CORE->stopCombination();
           QThread::exit(0);
           delete this;
@@ -468,6 +465,5 @@
       // -----------
       if (_rawOutput) {
-        bncApp* app = (bncApp*) qApp;
-        app->writeRawData(data, _staID, _format); 
+        PGM_CORE->writeRawData(data, _staID, _format); 
       }
 
Index: trunk/BNC/src/bncmain.cpp
===================================================================
--- trunk/BNC/src/bncmain.cpp	(revision 5064)
+++ trunk/BNC/src/bncmain.cpp	(revision 5066)
@@ -45,4 +45,5 @@
 #include <iostream>
 
+#include "app.h"
 #include "bncapp.h"
 #include "bncwindow.h"
@@ -116,10 +117,10 @@
 
   bool GUIenabled = interactive || displaySet;
-  bncApp app(argc, argv, GUIenabled);
+  t_app app(argc, argv, GUIenabled);
 
   app.setApplicationName("BNC");
   app.setOrganizationName("BKG");
   app.setOrganizationDomain("www.bkg.bund.de");
-  app.setConfFileName( confFileName );
+  PGM_CORE->setConfFileName( confFileName );
 
   bncSettings settings;
@@ -137,5 +138,5 @@
   if (interactive) {
 
-    app.setMode(bncApp::interactive);
+    PGM_CORE->setMode(t_pgmCore::interactive);
 
     QString fontString = settings.value("font").toString();
@@ -150,5 +151,5 @@
 
     bncWindow* bncWin = new bncWindow();
-    app.setMainWindow(bncWin);
+    PGM_CORE->setMainWindow(bncWin);
     bncWin->show();
   }
@@ -159,5 +160,5 @@
   // -------------------
   else if (settings.value("pppSPP").toString() == "Post-Processing") {
-    app.setMode(bncApp::batchPostProcessing);
+    PGM_CORE->setMode(t_pgmCore::batchPostProcessing);
     t_postProcessing* postProcessing = new t_postProcessing(0);
     postProcessing->start();
@@ -167,5 +168,5 @@
   // -------------------------
   else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
-    app.setMode(bncApp::batchPostProcessing);
+    PGM_CORE->setMode(t_pgmCore::batchPostProcessing);
     t_reqcEdit* reqcEdit = new t_reqcEdit(0);
     reqcEdit->start();
@@ -175,5 +176,5 @@
   // ----------------------------
   else if (settings.value("reqcAction").toString() == "Analyze") {
-    app.setMode(bncApp::batchPostProcessing);
+    PGM_CORE->setMode(t_pgmCore::batchPostProcessing);
     t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
     reqcAnalyze->start();
@@ -193,17 +194,17 @@
                                       settings.value("outPort").toInt());
     
-    app.setCaster(caster);
-    app.setPort(settings.value("outEphPort").toInt());
-    app.setPortCorr(settings.value("corrPort").toInt());
-    app.initCombination();
-    
-    app.connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
-    
-    ((bncApp*)qApp)->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
+    PGM_CORE->setCaster(caster);
+    PGM_CORE->setPort(settings.value("outEphPort").toInt());
+    PGM_CORE->setPortCorr(settings.value("corrPort").toInt());
+    PGM_CORE->initCombination();
+    
+    PGM_CORE->connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
+    
+    PGM_CORE->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
     
     // Normal case - data from Internet
     // --------------------------------
     if ( rawFileName.isEmpty() ) {
-      app.setMode(bncApp::nonInteractive);
+      PGM_CORE->setMode(t_pgmCore::nonInteractive);
       caster->readMountPoints();
       if (caster->numStations() == 0) {
@@ -215,5 +216,5 @@
     // -----------------------------
     else {
-      app.setMode(bncApp::batchPostProcessing);
+      PGM_CORE->setMode(t_pgmCore::batchPostProcessing);
       bncRawFile*   rawFile   = new bncRawFile(rawFileName, "", 
                                                bncRawFile::input);
Index: trunk/BNC/src/bncnetquery.h
===================================================================
--- trunk/BNC/src/bncnetquery.h	(revision 5064)
+++ trunk/BNC/src/bncnetquery.h	(revision 5066)
@@ -13,6 +13,6 @@
 
   bncNetQuery() {
-    connect(this,           SIGNAL(newMessage(QByteArray,bool)), 
-            (bncApp*) qApp, SLOT(slotMessage(const QByteArray,bool)));
+    connect(this,     SIGNAL(newMessage(QByteArray,bool)), 
+            PGM_CORE, SLOT(slotMessage(const QByteArray,bool)));
   }
   virtual ~bncNetQuery() {}
Index: trunk/BNC/src/bncnetqueryv2.cpp
===================================================================
--- trunk/BNC/src/bncnetqueryv2.cpp	(revision 5064)
+++ trunk/BNC/src/bncnetqueryv2.cpp	(revision 5066)
@@ -42,5 +42,5 @@
 
   if (_secure && !QSslSocket::supportsSsl()) {
-    ((bncApp*)qApp)->slotMessage("No SSL support, install OpenSSL run-time libraries", true);
+    PGM_CORE->slotMessage("No SSL support, install OpenSSL run-time libraries", true);
     stop();
   }
@@ -219,5 +219,5 @@
   }
 
-  ((bncApp*)qApp)->slotMessage(msg.toAscii(), true);
+  PGM_CORE->slotMessage(msg.toAscii(), true);
 
   if (_ignoreSslErrors) {
Index: trunk/BNC/src/bncpppclient.cpp
===================================================================
--- trunk/BNC/src/bncpppclient.cpp	(revision 5064)
+++ trunk/BNC/src/bncpppclient.cpp	(revision 5066)
@@ -72,7 +72,7 @@
   if (connectSlots) {
     connect(this, SIGNAL(newMessage(QByteArray,bool)), 
-            ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
-
-    connect(((bncApp*)qApp), SIGNAL(newCorrections(QList<QString>)),
+            PGM_CORE, SLOT(slotMessage(const QByteArray,bool)));
+
+    connect(PGM_CORE, SIGNAL(newCorrections(QList<QString>)),
             this, SLOT(slotNewCorrections(QList<QString>)));
   }
Index: trunk/BNC/src/bncrawfile.cpp
===================================================================
--- trunk/BNC/src/bncrawfile.cpp	(revision 5064)
+++ trunk/BNC/src/bncrawfile.cpp	(revision 5066)
@@ -136,7 +136,6 @@
       QStringList lst  = line.split(' ');
       
-      bncApp* app = (bncApp*) qApp;
-      delete app->_currentDateAndTimeGPS;
-      app->_currentDateAndTimeGPS = 
+      delete PGM_CORE->_currentDateAndTimeGPS;
+      PGM_CORE->_currentDateAndTimeGPS = 
         new QDateTime(QDateTime::fromString(lst.value(0), Qt::ISODate));
       
Index: trunk/BNC/src/bncsettings.cpp
===================================================================
--- trunk/BNC/src/bncsettings.cpp	(revision 5064)
+++ trunk/BNC/src/bncsettings.cpp	(revision 5066)
@@ -27,14 +27,7 @@
   QMutexLocker locker(&_mutex);
 
-#ifdef GNSSCENTER_PLUGIN
-  _bncApp = 0;
-  return;
-#else
-  _bncApp = static_cast<bncApp*>(qApp);
-#endif
-
   // First fill the options
   // ---------------------- 
-  if (_bncApp->_settings.size() == 0) {
+  if (PGM_CORE->_settings.size() == 0) {
     reRead();
   }
@@ -50,7 +43,7 @@
 void bncSettings::reRead() {
 
-  _bncApp->_settings.clear();
-
-  QSettings settings(_bncApp->confFileName(), QSettings::IniFormat);
+  PGM_CORE->_settings.clear();
+
+  QSettings settings(PGM_CORE->confFileName(), QSettings::IniFormat);
 
   // Read from File
@@ -60,5 +53,5 @@
     while (it.hasNext()) {
       QString key = it.next();
-      _bncApp->_settings[key] = settings.value(key);
+      PGM_CORE->_settings[key] = settings.value(key);
     }
   }
@@ -225,6 +218,6 @@
   QMutexLocker locker(&_mutex);
 
-  if (_bncApp && _bncApp->_settings.contains(key)) {
-    return _bncApp->_settings[key];
+  if (PGM_CORE->_settings.contains(key)) {
+    return PGM_CORE->_settings[key];
   }
   else {
@@ -243,5 +236,5 @@
 ////////////////////////////////////////////////////////////////////////////
 void bncSettings::setValue_p(const QString &key, const QVariant& value) {
-  _bncApp->_settings[key] = value;
+  PGM_CORE->_settings[key] = value;
 }
 
@@ -250,5 +243,5 @@
 void bncSettings::remove(const QString& key ) {
   QMutexLocker locker(&_mutex);
-  _bncApp->_settings.remove(key);
+  PGM_CORE->_settings.remove(key);
 }
 
@@ -257,7 +250,7 @@
 void bncSettings::sync() {
   QMutexLocker locker(&_mutex);
-  QSettings settings(_bncApp->confFileName(), QSettings::IniFormat);
+  QSettings settings(PGM_CORE->confFileName(), QSettings::IniFormat);
   settings.clear();
-  QMapIterator<QString, QVariant> it(_bncApp->_settings);
+  QMapIterator<QString, QVariant> it(PGM_CORE->_settings);
   while (it.hasNext()) {
     it.next();
Index: trunk/BNC/src/bncsettings.h
===================================================================
--- trunk/BNC/src/bncsettings.h	(revision 5064)
+++ trunk/BNC/src/bncsettings.h	(revision 5066)
@@ -3,6 +3,4 @@
 
 #include <QMutex>
-
-class bncApp;
 
 class bncSettings {
@@ -18,5 +16,4 @@
  private:
   void setValue_p(const QString &key, const QVariant& value);
-  bncApp*       _bncApp;
   static QMutex _mutex;
 };
Index: trunk/BNC/src/bncutils.cpp
===================================================================
--- trunk/BNC/src/bncutils.cpp	(revision 5064)
+++ trunk/BNC/src/bncutils.cpp	(revision 5066)
@@ -91,6 +91,6 @@
   QDateTime currDateTimeGPS;
 
-  if ( ((bncApp*) qApp)->_currentDateAndTimeGPS ) {
-    currDateTimeGPS = *(((bncApp*) qApp)->_currentDateAndTimeGPS);
+  if ( PGM_CORE->_currentDateAndTimeGPS ) {
+    currDateTimeGPS = *(PGM_CORE->_currentDateAndTimeGPS);
   }
   else {
@@ -116,6 +116,6 @@
 ////////////////////////////////////////////////////////////////////////////
 QDateTime currentDateAndTimeGPS() {
-  if ( ((bncApp*) qApp)->_currentDateAndTimeGPS ) {
-    return *(((bncApp*) qApp)->_currentDateAndTimeGPS);
+  if ( PGM_CORE->_currentDateAndTimeGPS ) {
+    return *(PGM_CORE->_currentDateAndTimeGPS);
   }
   else {
Index: trunk/BNC/src/bncwindow.cpp
===================================================================
--- trunk/BNC/src/bncwindow.cpp	(revision 5064)
+++ trunk/BNC/src/bncwindow.cpp	(revision 5066)
@@ -101,6 +101,6 @@
   setWindowTitle(tr("BKG Ntrip Client (BNC) Version " BNCVERSION));
 
-  connect((bncApp*)qApp, SIGNAL(newMessage(QByteArray,bool)), 
-           this, SLOT(slotWindowMessage(QByteArray,bool)));
+  connect(PGM_CORE, SIGNAL(newMessage(QByteArray,bool)), 
+          this, SLOT(slotWindowMessage(QByteArray,bool)));
 
   // Create Actions
@@ -1921,5 +1921,5 @@
 ////////////////////////////////////////////////////////////////////////////
 void bncWindow::slotGetThreadsFinished() {
-  ((bncApp*)qApp)->slotMessage("All Get Threads Terminated", true);
+  PGM_CORE->slotMessage("All Get Threads Terminated", true);
   delete _caster;    _caster    = 0;
   delete _casterEph; _casterEph = 0;
@@ -1957,7 +1957,7 @@
                           _outPortLineEdit->text().toInt());
 
-  ((bncApp*)qApp)->setPort(_outEphPortLineEdit->text().toInt());
-  ((bncApp*)qApp)->setPortCorr(_corrPortLineEdit->text().toInt());
-  ((bncApp*)qApp)->initCombination();
+  PGM_CORE->setPort(_outEphPortLineEdit->text().toInt());
+  PGM_CORE->setPortCorr(_corrPortLineEdit->text().toInt());
+  PGM_CORE->initCombination();
 
   connect(_caster, SIGNAL(getThreadsFinished()), 
@@ -1967,27 +1967,27 @@
            this, SLOT(slotMountPointsRead(QList<bncGetThread*>)));
 
-  ((bncApp*)qApp)->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
+  PGM_CORE->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
 
   bncSettings settings;
 
   QDir rnxdir(settings.value("rnxPath").toString());
-  if (!rnxdir.exists()) ((bncApp*)qApp)->slotMessage("Cannot find RINEX Observations directory", true);
+  if (!rnxdir.exists()) PGM_CORE->slotMessage("Cannot find RINEX Observations directory", true);
 
   QString rnx_file = settings.value("rnxScript").toString();
   if ( !rnx_file.isEmpty() ) {
     QFile rnxfile(settings.value("rnxScript").toString());
-    if (!rnxfile.exists()) ((bncApp*)qApp)->slotMessage("Cannot find RINEX Observations script", true);
+    if (!rnxfile.exists()) PGM_CORE->slotMessage("Cannot find RINEX Observations script", true);
   }
 
   QDir ephdir(settings.value("ephPath").toString());
-  if (!ephdir.exists()) ((bncApp*)qApp)->slotMessage("Cannot find RINEX Ephemeris directory", true);
+  if (!ephdir.exists()) PGM_CORE->slotMessage("Cannot find RINEX Ephemeris directory", true);
 
   QDir corrdir(settings.value("corrPath").toString());
-  if (!corrdir.exists()) ((bncApp*)qApp)->slotMessage("Cannot find Broadcast Corrections directory", true);
+  if (!corrdir.exists()) PGM_CORE->slotMessage("Cannot find Broadcast Corrections directory", true);
 
   QString advise_file = settings.value("adviseScript").toString();
   if ( !advise_file.isEmpty() ) {
     QFile advisefile(settings.value("adviseScript").toString());
-    if (!advisefile.exists()) ((bncApp*)qApp)->slotMessage("Cannot find Outages script", true);
+    if (!advisefile.exists()) PGM_CORE->slotMessage("Cannot find Outages script", true);
   }
 
@@ -1995,5 +1995,5 @@
   if ( !ant_file.isEmpty() ) {
     QFile anxfile(settings.value("pppAntex").toString());
-    if (!anxfile.exists()) ((bncApp*)qApp)->slotMessage("Cannot find IGS ANTEX file", true);
+    if (!anxfile.exists()) PGM_CORE->slotMessage("Cannot find IGS ANTEX file", true);
   }
 
@@ -2012,5 +2012,5 @@
                                    QMessageBox::NoButton);
   if (iRet == QMessageBox::Yes) {
-    ((bncApp*)qApp)->stopCombination();
+    PGM_CORE->stopCombination();
     delete _caster;    _caster    = 0;
     delete _casterEph; _casterEph = 0;
@@ -2584,5 +2584,5 @@
       bncIt->setFlags(bncIt->flags() & ~Qt::ItemIsEditable);
       _uploadTable->setItem(iRow, iCol, bncIt);
-      ((bncApp*)qApp)->_uploadTableItems[iRow] = bncIt;
+      PGM_CORE->_uploadTableItems[iRow] = bncIt;
     }
     else {
@@ -2595,5 +2595,5 @@
 ////////////////////////////////////////////////////////////////////////////
 void bncWindow::slotDelUploadRow() {
-  ((bncApp*)qApp)->_uploadTableItems.clear();
+  PGM_CORE->_uploadTableItems.clear();
   int nRows = _uploadTable->rowCount();
   bool flg[nRows];
@@ -2612,5 +2612,5 @@
   }
   for (int iRow = 0; iRow < _uploadTable->rowCount(); iRow++) {
-    ((bncApp*)qApp)->_uploadTableItems[iRow] = 
+    PGM_CORE->_uploadTableItems[iRow] = 
                                 (bncTableItem*) _uploadTable->item(iRow, 11);
   }
@@ -2668,5 +2668,5 @@
         bncIt->setFlags(bncIt->flags() & ~Qt::ItemIsEditable);
         _uploadTable->setItem(iRow, iCol, bncIt);
-        ((bncApp*)qApp)->_uploadTableItems[iRow] = bncIt;
+        PGM_CORE->_uploadTableItems[iRow] = bncIt;
       }
       else {
Index: trunk/BNC/src/combination/bnccomb.cpp
===================================================================
--- trunk/BNC/src/combination/bnccomb.cpp	(revision 5064)
+++ trunk/BNC/src/combination/bnccomb.cpp	(revision 5066)
@@ -163,5 +163,5 @@
 
   connect(this, SIGNAL(newMessage(QByteArray,bool)), 
-          ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
+          PGM_CORE, SLOT(slotMessage(const QByteArray,bool)));
 
   // Combination Method
@@ -750,7 +750,6 @@
   // Optionally send new Corrections to PPP
   // --------------------------------------
-  bncApp* app = (bncApp*) qApp;
-  if (app->_bncPPPclient) {
-    app->_bncPPPclient->slotNewCorrections(corrLines);
+  if (PGM_CORE->_bncPPPclient) {
+    PGM_CORE->_bncPPPclient->slotNewCorrections(corrLines);
   }
 }
Index: trunk/BNC/src/latencychecker.cpp
===================================================================
--- trunk/BNC/src/latencychecker.cpp	(revision 5064)
+++ trunk/BNC/src/latencychecker.cpp	(revision 5066)
@@ -60,7 +60,6 @@
   _staID = staID;
 
-  bncApp* app = (bncApp*) qApp;
   connect(this, SIGNAL(newMessage(QByteArray,bool)), 
-          app, SLOT(slotMessage(const QByteArray,bool)));
+          PGM_CORE, SLOT(slotMessage(const QByteArray,bool)));
 
   bncSettings settings;
Index: trunk/BNC/src/rinex/bncpostprocess.cpp
===================================================================
--- trunk/BNC/src/rinex/bncpostprocess.cpp	(revision 5064)
+++ trunk/BNC/src/rinex/bncpostprocess.cpp	(revision 5066)
@@ -98,5 +98,5 @@
   }
   else {
-    ((bncApp*) qApp)->slotMessage(msg, false);
+    PGM_CORE->slotMessage(msg, false);
   }
 }
@@ -222,7 +222,6 @@
   }
 
-  bncApp* app = (bncApp*) qApp;
-  if ( app->mode() != bncApp::interactive) {
-    app->exit(0);
+  if (PGM_CORE->mode() != t_pgmCore::interactive) {
+    qApp->exit(0);
   }
   else {
Index: trunk/BNC/src/rinex/reqcanalyze.cpp
===================================================================
--- trunk/BNC/src/rinex/reqcanalyze.cpp	(revision 5064)
+++ trunk/BNC/src/rinex/reqcanalyze.cpp	(revision 5066)
@@ -101,7 +101,6 @@
   delete _log;     _log     = 0;
   delete _logFile; _logFile = 0;
-  bncApp* app = (bncApp*) qApp;
-  if ( app->mode() != bncApp::interactive) {
-    app->exit(0);
+  if (PGM_CORE->mode() != t_pgmCore::interactive) {
+    qApp->exit(0);
   }
 }
@@ -117,6 +116,5 @@
                                    double maxValue) {
 
-  bncApp* app = dynamic_cast<bncApp*>(qApp);
-  if (app->GUIenabled()) {
+  if (PGM_CORE->GUIenabled()) {
 
     if (maxValue == 0.0) {
@@ -144,5 +142,5 @@
     if (data1) {
       t_polarPlot* plot1 = new t_polarPlot(QwtText(title1), scaleInterval,
-                                          app->mainWindow());
+                                          PGM_CORE->mainWindow());
       plot1->addCurve(data1);
       plots << plot1;
@@ -150,5 +148,5 @@
     if (data2) {
       t_polarPlot* plot2 = new t_polarPlot(QwtText(title2), scaleInterval,
-                                           app->mainWindow());
+                                           PGM_CORE->mainWindow());
       plot2->addCurve(data2);
       plots << plot2;
@@ -298,5 +296,5 @@
   // Show the plots
   // --------------
-  if (dynamic_cast<bncApp*>(qApp)->GUIenabled()) {
+  if (PGM_CORE->GUIenabled()) {
     QFileInfo  fileInfo(obsFile->fileName());
     QByteArray title = fileInfo.fileName().toAscii();
@@ -653,5 +651,5 @@
                                      const QByteArray& title) {
 
-  if (dynamic_cast<bncApp*>(qApp)->GUIenabled()) {
+  if (PGM_CORE->GUIenabled()) {
     t_availPlot* plotA = new t_availPlot(0, &_availDataMap);
     plotA->setTitle(title);
Index: trunk/BNC/src/rinex/reqcedit.cpp
===================================================================
--- trunk/BNC/src/rinex/reqcedit.cpp	(revision 5064)
+++ trunk/BNC/src/rinex/reqcedit.cpp	(revision 5066)
@@ -103,6 +103,4 @@
   // ---------------
   if (_log) {
-    bncApp* app = (bncApp*) qApp;
-
     *_log << QByteArray(78, '-') << endl;
     *_log << "Concatenation of RINEX Observation and/or Navigation Files\n";
@@ -110,7 +108,7 @@
 
     *_log << QByteArray("Program").leftJustified(15) << ": "
-          << app->pgmName() << endl;
+          << PGM_CORE->pgmName() << endl;
     *_log << QByteArray("Run by").leftJustified(15) << ": "
-          << app->userName() << endl;
+          << PGM_CORE->userName() << endl;
     *_log << QByteArray("Date").leftJustified(15) << ": "
           << QDateTime::currentDateTime().toUTC().toString("yyyy-MM-dd hh:mm:ss") << endl;
@@ -148,7 +146,6 @@
   // Exit (thread)
   // -------------
-  bncApp* app = (bncApp*) qApp;
-  if ( app->mode() != bncApp::interactive) {
-    app->exit(0);
+  if (PGM_CORE->mode() != t_pgmCore::interactive) {
+    qApp->exit(0);
   }
   else {
Index: trunk/BNC/src/rinex/rnxnavfile.cpp
===================================================================
--- trunk/BNC/src/rinex/rnxnavfile.cpp	(revision 5064)
+++ trunk/BNC/src/rinex/rnxnavfile.cpp	(revision 5066)
@@ -241,7 +241,5 @@
 void t_rnxNavFile::writeHeader(const QMap<QString, QString>* txtMap) {
 
-  bncApp* app = (bncApp*) qApp;
-
-  QString     runBy = app->userName();
+  QString     runBy = PGM_CORE->userName();
   QStringList comments;
 
@@ -277,5 +275,5 @@
                                             : "yyyyMMdd hhmmss UTC";
   *_stream << QString("%1%2%3")
-    .arg(app->pgmName(), -20)
+    .arg(PGM_CORE->pgmName(), -20)
     .arg(runBy.trimmed().left(20), -20)
     .arg(QDateTime::currentDateTime().toUTC().toString(fmtDate), -20)
Index: trunk/BNC/src/rinex/rnxobsfile.cpp
===================================================================
--- trunk/BNC/src/rinex/rnxobsfile.cpp	(revision 5064)
+++ trunk/BNC/src/rinex/rnxobsfile.cpp	(revision 5066)
@@ -212,8 +212,6 @@
                            const QMap<QString, QString>* txtMap) const {
 
-  bncApp* app = (bncApp*) qApp;
-
   QStringList newComments;
-  QString     runBy = app->userName();
+  QString     runBy = PGM_CORE->userName();
 
   if (txtMap) {
@@ -238,5 +236,5 @@
                                                   : "yyyyMMdd hhmmss UTC";
   *stream << QString("%1%2%3")
-    .arg(app->pgmName(), -20)
+    .arg(PGM_CORE->pgmName(), -20)
     .arg(runBy.trimmed().left(20), -20)
     .arg(QDateTime::currentDateTime().toUTC().toString(fmtDate), -20)
Index: trunk/BNC/src/src.pro
===================================================================
--- trunk/BNC/src/src.pro	(revision 5064)
+++ trunk/BNC/src/src.pro	(revision 5066)
@@ -57,4 +57,5 @@
           bncephuser.h bncoutf.h bncclockrinex.h bncsp3.h             \
           bncbytescounter.h bncsslconfig.h reqcdlg.h                  \
+          app.h                                                       \
           upload/bncrtnetdecoder.h upload/bncuploadcaster.h           \
           upload/bncrtnetuploadcaster.h upload/bnccustomtrafo.h       \
@@ -86,4 +87,5 @@
           bncephuser.cpp bncoutf.cpp bncclockrinex.cpp bncsp3.cpp     \
           bncbytescounter.cpp bncsslconfig.cpp reqcdlg.cpp            \
+          app.cpp                                                     \
           upload/bncrtnetdecoder.cpp upload/bncuploadcaster.cpp       \
           upload/bncrtnetuploadcaster.cpp upload/bnccustomtrafo.cpp   \
Index: trunk/BNC/src/upload/bncuploadcaster.cpp
===================================================================
--- trunk/BNC/src/upload/bncuploadcaster.cpp	(revision 5064)
+++ trunk/BNC/src/upload/bncuploadcaster.cpp	(revision 5066)
@@ -45,11 +45,10 @@
   _isToBeDeleted = false;
 
-  bncApp* app = (bncApp*) qApp;
   connect(this, SIGNAL(newMessage(QByteArray,bool)), 
-          app, SLOT(slotMessage(const QByteArray,bool)));
+          PGM_CORE, SLOT(slotMessage(const QByteArray,bool)));
 
-  if (app->_uploadTableItems.find(_iRow) != app->_uploadTableItems.end()){
+  if (PGM_CORE->_uploadTableItems.find(_iRow) != PGM_CORE->_uploadTableItems.end()){
     connect(this, SIGNAL(newBytes(QByteArray,double)), 
-            app->_uploadTableItems.value(iRow), 
+            PGM_CORE->_uploadTableItems.value(iRow), 
             SLOT(slotNewBytes(const QByteArray,double)));
   }
