[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [publictransport] applet: Remove deprecated network state checks in applet
From:       Friedrich_Karl_Tilman_Pülz <fpuelz () gmx ! de>
Date:       2012-11-30 20:36:57
Message-ID: 20121130203657.783DBA60D2 () git ! kde ! org
[Download RAW message or body]

Git commit f68c863f33c0589a25e517b874f1c1a93fd1225a by Friedrich Karl Tilman Pülz.
Committed on 27/11/2012 at 18:01.
Pushed by fkpulz into branch 'master'.

Remove deprecated network state checks in applet

The applet was using the "network" data engine to check
the network status, this did not work very well. And since
network error messages are now forwarded from the engine,
no network state checks need to be done in the applet.
Furthermore the applet cannot know if the provider plugin
needs a network connection at all (eg. GTFS does not).

Remove old error messages in the applet, just use the error
message from the data engine.

M  +2    -80   applet/publictransport.cpp
M  +0    -11   applet/publictransport.h
M  +0    -34   applet/publictransport_p.h

http://commits.kde.org/publictransport/f68c863f33c0589a25e517b874f1c1a93fd1225a

diff --git a/applet/publictransport.cpp b/applet/publictransport.cpp
index ef8b523..676ab17 100644
--- a/applet/publictransport.cpp
+++ b/applet/publictransport.cpp
@@ -91,9 +91,6 @@ void PublicTransportApplet::init()
         }
     }
 
-    // Check for network connectivity
-    checkNetworkStatus();
-
     // Set popup icon
     if ( isIconified() ) {
         updatePopupIcon();
@@ -115,51 +112,6 @@ void PublicTransportApplet::themeChanged()
     d->applyTheme();
 }
 
-bool PublicTransportApplet::checkNetworkStatus()
-{
-    QString status = queryNetworkStatus();
-    if ( status == QLatin1String("unavailable") ) {
-        emit networkConnectionLost();
-        return false;
-    } else if ( status == QLatin1String("configuring") ) {
-        emit networkIsConfiguring();
-        return false;
-    } else if ( status == QLatin1String("activated") /*&& m_currentMessage == MessageError TODO*/ ) {
-        emit networkIsActivated();
-        return false;
-    } else {
-        kDebug() << "Unknown network status or no error message was shown" << status;
-        return true;
-    }
-}
-
-QString PublicTransportApplet::queryNetworkStatus()
-{
-    const QStringList interfaces = dataEngine( "network" )->sources();
-    if ( interfaces.isEmpty() ) {
-        return "unknown";
-    }
-
-    // Check if there is an activated interface or at least one that's
-    // currently being configured
-    QString status = "unavailable";
-    foreach( const QString &iface, interfaces ) {
-        QString sStatus = dataEngine( "network" )->query( iface )["ConnectionStatus"].toString();
-        if ( sStatus.isEmpty() ) {
-            return "unknown";
-        }
-
-        if ( sStatus == QLatin1String("Activated") ) {
-            status = "activated";
-            break;
-        } else if ( sStatus == QLatin1String("Configuring") ) {
-            status = "configuring";
-        }
-    }
-
-    return status;
-}
-
 void PublicTransportApplet::setSettings( const QString& serviceProviderID, const QString& stopName )
 {
     Q_D( const PublicTransportApplet );
@@ -189,16 +141,6 @@ void PublicTransportApplet::setSettings( const StopSettingsList& stops,
     setSettings( settings );
 }
 
-void PublicTransportApplet::noItemsTextClicked()
-{
-    Q_D( const PublicTransportApplet );
-
-    // Update the timetable if an error message inside the tree view has been clicked
-    if ( !d->isStateActive("networkActivated") ) {
-        updateDataSource();
-    }
-}
-
 void PublicTransportApplet::setupActions()
 {
     Q_D( PublicTransportApplet );
@@ -623,28 +565,8 @@ void PublicTransportApplet::handleDataError( const QString& /*sourceName*/,
             setAssociatedApplicationUrlForDepartures();
         }
 
-        QString error = data["errorMessage"].toString();
-        if ( error.isEmpty() ) {
-            if ( d->isStateActive("networkActivated") ) {
-                if ( d->settings.departureArrivalListType() == DepartureList ) {
-                    setConfigurationRequired( true, i18nc("@info", "Error parsing "
-                            "departure information or currently no departures") );
-                } else {
-                    setConfigurationRequired( true, i18nc("@info", "Error parsing "
-                            "arrival information or currently no arrivals") );
-                }
-            }
-        } else if ( checkNetworkStatus() ) {
-            if ( d->currentProviderData["type"] == QLatin1String("GTFS") ) {
-                d->timetable->setNoItemsText( i18nc("@info/plain",
-                        "There was an error:<nl/><message>%1</message><nl/><nl/>"
-                        "The GTFS feed database may need to be updated. Please wait.", error) );
-            } else {
-                d->timetable->setNoItemsText( i18nc("@info/plain",
-                        "There was an error:<nl/><message>%1</message><nl/><nl/>"
-                        "The server may be temporarily unavailable.", error) );
-            }
-        }
+        d->timetable->setNoItemsText( i18nc("@info/plain",
+                "There was an error:<nl/><message>%1</message>", data["errorMessage"].toString()) );
     }
 }
 
diff --git a/applet/publictransport.h b/applet/publictransport.h
index 4726eed..9a9604b 100644
--- a/applet/publictransport.h
+++ b/applet/publictransport.h
@@ -240,8 +240,6 @@ protected slots:
     void requestStopAction( StopAction::Type stopAction,
                             const QString &stopName, const QString &stopNameShortened );
 
-    void noItemsTextClicked();
-
     /**
      * @brief Show the departure list.
      *
@@ -623,15 +621,6 @@ protected:
     /** @brief Remove an autogenerated alarm from this departure/arrival if any. */
     void removeAlarmForDeparture( int row );
 
-    QString queryNetworkStatus();
-
-    /**
-     * @brief Show an error message when no interface is activated.
-     *
-     * @return True, if no message is shown. False, otherwise.
-     **/
-    bool checkNetworkStatus();
-
 private:
     PublicTransportAppletPrivate* const d_ptr;
     Q_DECLARE_PRIVATE( PublicTransportApplet )
diff --git a/applet/publictransport_p.h b/applet/publictransport_p.h
index 020f95a..c917b03 100644
--- a/applet/publictransport_p.h
+++ b/applet/publictransport_p.h
@@ -312,13 +312,11 @@ public: // Inline functions, mostly used only once (therefore inline) or very sh
         QState *viewStateGroup = new QState( mainStateGroup );
         QState *departureDataStateGroup = new QState( mainStateGroup );
         QState *journeyDataStateGroup = new QState( mainStateGroup );
-        QState *networkStateGroup = new QState( mainStateGroup );
         states.insert( "mainStateGroup", mainStateGroup );
         states.insert( "providerStateGroup", providerStateGroup );
         states.insert( "viewStateGroup", viewStateGroup );
         states.insert( "departureDataStateGroup", departureDataStateGroup );
         states.insert( "journeyDataStateGroup", journeyDataStateGroup );
-        states.insert( "networkStateGroup", networkStateGroup );
 
         // Create View states
         QState *actionButtonsState = new QState( viewStateGroup );
@@ -373,25 +371,6 @@ public: // Inline functions, mostly used only once (therefore inline) or very sh
         states.insert( "journeyDataValid", journeyDataValidState );
         states.insert( "journeyDataInvalid", journeyDataInvalidState );
 
-        // Create network states
-        QState *networkStatusUnknownState = new QState( networkStateGroup );
-        QState *networkConfiguringState = new QState( networkStateGroup );
-        QState *networkActivatedState = new QState( networkStateGroup );
-        QState *networkNotActivatedState = new QState( networkStateGroup );
-        networkStateGroup->setInitialState( networkStatusUnknownState );
-        states.insert( "networkStatusUnknown", networkStatusUnknownState );
-        states.insert( "networkConfiguring", networkConfiguringState );
-        states.insert( "networkActivated", networkActivatedState );
-        states.insert( "networkNotActivated", networkNotActivatedState );
-
-        // Set text to be displayed if no data is present when the network state changes
-        networkConfiguringState->assignProperty( timetable, "noItemsText",
-                i18nc("@info", "Network gets configured. Please wait...") );
-        networkNotActivatedState->assignProperty( timetable, "noItemsText",
-                i18nc("@info", "No network connection") );
-        networkActivatedState->assignProperty( timetable, "noItemsText",
-                                               i18nc("@info", "Network connection established") );
-
         // "Search Journeys..." action transitions to the journey search view (state "journeySearch").
         // If journeys aren't supported by the current service provider, a message gets displayed
         // and the target state is "journeysUnsupportedView". The target states of these transitions
@@ -479,19 +458,6 @@ public: // Inline functions, mostly used only once (therefore inline) or very sh
         journeyDataInvalidState->addTransition(
             q, SIGNAL(requestedNewJourneyData()), journeyDataWaitingState );
 
-        networkConfiguringState->addTransition(
-            q, SIGNAL(networkConnectionLost()), networkNotActivatedState );
-        networkActivatedState->addTransition(
-            q, SIGNAL(networkConnectionLost()), networkNotActivatedState );
-        networkActivatedState->addTransition(
-            q, SIGNAL(networkIsConfiguring()), networkConfiguringState );
-        networkNotActivatedState->addTransition(
-            q, SIGNAL(networkIsConfiguring()), networkConfiguringState );
-        networkConfiguringState->addTransition(
-            q, SIGNAL(networkIsActivated()), networkActivatedState );
-        networkNotActivatedState->addTransition(
-            q, SIGNAL(networkIsActivated()), networkActivatedState );
-
         q->connect( actionButtonsState, SIGNAL(entered()),
                     q, SLOT(showActionButtons()) );
         q->connect( actionButtonsState, SIGNAL(exited()),

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic