Added qmafw-gst-subtitles-renderer-0.0.55 for Meego Harmattan 1.2
[mafwsubrenderer] / qmafw-gst-subtitles-renderer / src / MafwGstRendererNetworkMonitor.cpp
diff --git a/qmafw-gst-subtitles-renderer/src/MafwGstRendererNetworkMonitor.cpp b/qmafw-gst-subtitles-renderer/src/MafwGstRendererNetworkMonitor.cpp
new file mode 100644 (file)
index 0000000..504676d
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * This file is part of QMAFW
+ *
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). All rights
+ * reserved.
+ *
+ * Contact: Visa Smolander <visa.smolander@nokia.com>
+ *
+ * This software, including documentation, is protected by copyright controlled
+ * by Nokia Corporation. All rights are reserved. Copying, including
+ * reproducing, storing, adapting or translating, any or all of this material
+ * requires the prior written consent of Nokia Corporation. This material also
+ * contains confidential information which may not be disclosed to others
+ * without the prior written consent of Nokia.
+ *
+ */
+
+#include "MafwGstRendererNetworkMonitor.h"
+#include "MafwGstRendererHaltState.h"
+
+#include <QDebug>
+#include <QtNetwork/QNetworkConfigurationManager>
+
+/********************************************************************
+ * MafwGstRendererNetworkMonitor::MafwGstRendererNetworkMonitor
+ ********************************************************************/
+MafwGstRendererNetworkMonitor::MafwGstRendererNetworkMonitor()
+    :
+    m_networkManager(new QNetworkConfigurationManager(this))
+{
+    connect(m_networkManager, SIGNAL(configurationChanged(QNetworkConfiguration)),
+            this, SLOT(handleConfigurationChange(QNetworkConfiguration)));
+}
+
+/********************************************************************
+ * MafwGstRendererNetworkMonitor::MafwGstRendererNetworkMonitor
+ ********************************************************************/
+MafwGstRendererNetworkMonitor::~MafwGstRendererNetworkMonitor()
+{
+
+}
+
+/********************************************************************
+ * MafwGstRendererNetworkMonitor::handleConfigurationChange
+ ********************************************************************/
+void MafwGstRendererNetworkMonitor::handleConfigurationChange(const QNetworkConfiguration &config)
+{
+    qDebug() << __PRETTY_FUNCTION__ << "Configs status: " << config.name() << config.state();
+
+    QNetworkConfiguration::StateFlags flags = config.state();
+    if( flags.testFlag(QNetworkConfiguration::Active) )
+    {
+        Q_EMIT networkChangeFinished();
+        m_currentConfiguration = config;
+    }
+    else if( !m_currentConfiguration.isValid() || config == m_currentConfiguration )
+    {
+        Q_EMIT prepareNetworkChange();
+    }
+}