Moved timeout constants to appsettings in preparatino for adding to user configuratio...
authordruid23 <usr@dru-id.co.uk>
Sun, 5 Sep 2010 14:50:03 +0000 (15:50 +0100)
committerdruid23 <usr@dru-id.co.uk>
Sun, 5 Sep 2010 14:50:03 +0000 (15:50 +0100)
modified:   src/accountdialog.cpp
modified:   src/appsettings.cpp
modified:   src/appsettings.h
modified:   src/browsemainwindow.cpp
modified:   src/playermainwindow.cpp

src/accountdialog.cpp
src/appsettings.cpp
src/appsettings.h
src/browsemainwindow.cpp
src/playermainwindow.cpp

index a5fe39e..0cb777b 100644 (file)
@@ -157,7 +157,7 @@ QListWidgetItem AccountDialog::asyncTestItem(const QListWidgetItem& item)
     else
         socket->connectToHost(host,8080);
 
-    if (socket->waitForConnected(1000))
+    if (socket->waitForConnected(AppSettings::getPingTimeout()))
         newItem.setIcon(QIcon::fromTheme("widgets_tickmark_list"));
     else
         newItem.setIcon(QIcon::fromTheme("statusarea_presence_busy_error"));
index e910978..dc2472c 100644 (file)
@@ -91,6 +91,24 @@ bool AppSettings::deleteFavourite(VlcDirectory dir) {
     sets.remove("config/accounts/" + getCurrentKey() + "/favourites/" + dir.name);
     return true;
 }
+int AppSettings::getStatusPollTimeout() {
+    return STATUS_POLL_TIMEOUT;
+}
+int AppSettings::getPingTimeout() {
+    return PING_TIMEOUT;
+}
+int AppSettings::getConnectionTimeout() {
+    return CONNECTION_TIMEOUT;
+}
+int AppSettings::getRetrieveArtTimeout() {
+    return RETRIEVE_ART_TIMEOUT;
+}
+int AppSettings::getRetryNetworkTimeout() {
+    return RETRY_NETWORK_TIMEOUT;
+}
+bool AppSettings::getShowUnknownFileTypes() {
+    return SHOW_UNKNOWN_FILETYPES;
+}
 Orientation AppSettings::setOrientation(Orientation orientation) {
     QSettings sets;
     sets.setValue("config/orientation", (int)orientation);
index 98b287b..1da0b9a 100644 (file)
 #define APPSETTINGS_H
 #include <QSettings>
 
+#ifndef STATUS_POLL_TIMEOUT
+#define STATUS_POLL_TIMEOUT 5000
+#endif
+#ifndef PING_TIMEOUT
+#define PING_TIMEOUT 1000
+#endif
+#ifndef CONNECTION_TIMEOUT
+#define CONNECTION_TIMEOUT 1000
+#endif
+#ifndef RETRIEVE_ART_TIMEOUT
+#define RETRIEVE_ART_TIMEOUT 500
+#endif
+#ifndef RETRY_NETWORK_TIMEOUT
+#define RETRY_NETWORK_TIMEOUT 20000
+#endif
+
+#ifndef SHOW_UNKNOWN_FILETYPES
+#define SHOW_UNKNOWN_FILETYPES false
+#endif
+
+
 struct VlcDirectory {
     QString name;
     QString path;
@@ -43,8 +64,12 @@ public:
     static Orientation setOrientation(Orientation orientation);
     static Orientation getOrientation();
     static bool isConnected();
-//private:
-    //static QSettings settings;
+    static int getStatusPollTimeout();
+    static int getPingTimeout();
+    static int getConnectionTimeout();
+    static int getRetrieveArtTimeout();
+    static int getRetryNetworkTimeout();
+    static bool getShowUnknownFileTypes();
 };
 
 #endif // APPSETTINGS_H
index 811e8f4..751770a 100644 (file)
@@ -390,8 +390,13 @@ void BrowseMainWindow::updateList() {
                         item = new QListWidgetItem(icon_flash, dir.name, ui->listWidget, 0);
                     }
                     else {
-                        item_good = false;
-                        //item = new QListWidgetItem(icon_unknown, dir.name, ui->listWidget, 0);
+                        if (AppSettings::getShowUnknownFileTypes()) {
+                            item_good = true;
+                            item = new QListWidgetItem(icon_unknown, dir.name, ui->listWidget, 0);
+                        }
+                        else {
+                            item_good = false;
+                        }
                     }
                 }
             }
index ff734cb..6ad1541 100644 (file)
               else {
                   socket->connectToHost(last_ip,8080);
               }
-              if (!socket->waitForConnected(1000)) {
+              if (!socket->waitForConnected(AppSettings::getConnectionTimeout())) {
                      showConfig();
                  }
               else {
 
                  mPlayListMainWindow->init();
                  mBrowserMainWindow->init();
-                 mTimer->start(5000);
+                 mTimer->start(AppSettings::getStatusPollTimeout());
                  askStatus();
               }
               delete socket;
 
           mPlayListMainWindow->init();
           mBrowserMainWindow->init();
-          mTimer->start(5000);
+          mTimer->start(AppSettings::getStatusPollTimeout());
           askStatus();
       }
       else {
 #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5)
         QMaemo5InformationBox::information(this, tr("Network unavailable!"), QMaemo5InformationBox::DefaultTimeout);
 #endif
-        QTimer::singleShot(20000, this, SLOT(showConfig()));
+        QTimer::singleShot(AppSettings::getRetryNetworkTimeout(), this, SLOT(showConfig()));
       }
   }
   void PlayerMainWindow::showAbout()
       // now would be a good time to work out if we are a new track / file or not.
       // key if we are going to look for album art later
       // for now we check length and title this will require further examination later
-      mCurrentStatus.newtrack = true;
-      if ( (0 == mCurrentStatus.length || STOP == mCurrentStatus.state) // stopped or null
-              || // same track as current playing
-           (mCurrentStatus.length == length && !mCurrentStatus.title.isNull() && 0 == QString::compare(mCurrentStatus.title, title)) ){
-        mCurrentStatus.newtrack = false;
-      }
-      mCurrentStatus.volume = volume;
-      mCurrentStatus.length = length;
-      mCurrentStatus.time = time;
-      mCurrentStatus.position = position;
-      mCurrentStatus.random = (1 == random);
-      mCurrentStatus.loop = (1 == loop);
-      mCurrentStatus.repeat = (1 == repeat);
-      mCurrentStatus.title = title;
-      mCurrentStatus.artist = artist;
-      mCurrentStatus.album = album;
-      mCurrentStatus.nowplaying = now_playing;
-      mCurrentStatus.hasart = (!art_url.isNull() && !art_url.isEmpty());
       if (!state.isNull() && !state.isEmpty()) {
           if (0 == QString::compare("playing", state, Qt::CaseInsensitive)) {
             mCurrentStatus.state = PLAYING;
       else {
           mCurrentStatus.state = UNKNOWN;
       }
+      mCurrentStatus.newtrack = true;
+      if ( (0 == mCurrentStatus.length || STOP == mCurrentStatus.state) // stopped or null
+              || // same track as current playing
+           (mCurrentStatus.length == length && !mCurrentStatus.title.isNull() && !title.isNull() && 0 == QString::compare(mCurrentStatus.title, title)) ){
+        mCurrentStatus.newtrack = false;
+      }
+      mCurrentStatus.volume = volume;
+      mCurrentStatus.length = length;
+      mCurrentStatus.time = time;
+      mCurrentStatus.position = position;
+      mCurrentStatus.random = (1 == random);
+      mCurrentStatus.loop = (1 == loop);
+      mCurrentStatus.repeat = (1 == repeat);
+      mCurrentStatus.title = title;
+      mCurrentStatus.artist = artist;
+      mCurrentStatus.album = album;
+      mCurrentStatus.nowplaying = now_playing;
+      mCurrentStatus.hasart = (!art_url.isNull() && !art_url.isEmpty());
       // What's our mute status?
       if (0 < mCurrentStatus.volume) {
           this->mVolume = mCurrentStatus.volume;
           //   rebuild display layout
           //   retrieve album art
           mHasImage = false;
-          QTimer::singleShot(500, mPlayListMainWindow, SLOT(requestPlayList()));
+          QTimer::singleShot(AppSettings::getRetrieveArtTimeout(), mPlayListMainWindow, SLOT(requestPlayList()));
       }
       // Update the buttons on the playlist window
       if (NULL != this->mPlayListMainWindow) {