File 2_7_BRANCH.diff of Package soprano

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c3c440f..eb80bba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,7 +7,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/mod
 ##################  Soprano version  ################################
 set(CMAKE_SOPRANO_VERSION_MAJOR 2)
 set(CMAKE_SOPRANO_VERSION_MINOR 7)
-set(CMAKE_SOPRANO_VERSION_RELEASE 1)
+set(CMAKE_SOPRANO_VERSION_RELEASE 3)
 set(CMAKE_SOPRANO_VERSION_STRING "${CMAKE_SOPRANO_VERSION_MAJOR}.${CMAKE_SOPRANO_VERSION_MINOR}.${CMAKE_SOPRANO_VERSION_RELEASE}")
 
 
diff --git a/ChangeLog b/ChangeLog
index 383fbea..00eec79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2.7.3
+	* Added new signal in the Virtuoso backend which signals when the server goes down.
+
 2.7.2
 	* Reverted a change which was introduced in 2.7.1 to use a separate QDBusConnection for the 
           DBusExportModel. It made things worse.
diff --git a/backends/virtuoso/Virtuoso.dox b/backends/virtuoso/Virtuoso.dox
index c62d6f9..7bd0e73 100644
--- a/backends/virtuoso/Virtuoso.dox
+++ b/backends/virtuoso/Virtuoso.dox
@@ -60,6 +60,19 @@
  * \li Soprano::BackendOptionPassword - Set the password to connect to the Virtuoso server.
  *
  *
+ * \section soprano_backend_vituoso_additions Additional Features
+ *
+ * Models created by the Virtuoso backend emit a non-standard signal which informs the client that the Virtuoso server went down.
+ * This signal is only emitted for Virtuoso instances that were started by the backend and has the following signature:
+ *
+ * \code
+ * void virtuosoStopped(bool normalExit);
+ * \endcode
+ *
+ * The parameter \p normalExit is \p true if the instance went down as scheduled (deletion of the model) and \p false if the
+ * Virtuoso instance crashed or was killed by a third party. Typically a client would connect to the signal to properly re-create the model.
+ *
+ *
  * \section soprano_backend_vituoso_specialities Virtuoso Specialities
  *
  * Since Virtuoso is an SQL server and, thus, does store all RDF data in SQL tables it
diff --git a/backends/virtuoso/virtuosobackend.cpp b/backends/virtuoso/virtuosobackend.cpp
index c83605d..aab1881 100644
--- a/backends/virtuoso/virtuosobackend.cpp
+++ b/backends/virtuoso/virtuosobackend.cpp
@@ -1,7 +1,7 @@
 /*
  * This file is part of Soprano Project
  *
- * Copyright (C) 2008-2010 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2008-2011 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -115,8 +115,10 @@ Soprano::StorageModel* Soprano::Virtuoso::BackendPlugin::createModel( const Back
     VirtuosoModel* model = new VirtuosoModel( connectionPool, this );
     // mem mangement the ugly way
     // FIXME: improve
-    if ( controller )
+    if ( controller ) {
         controller->setParent( model );
+        connect(controller, SIGNAL(stopped(Soprano::VirtuosoController::ExitStatus)), model, SLOT(slotVirtuosoStopped(Soprano::VirtuosoController::ExitStatus)));
+    }
     return model;
 }
 
diff --git a/backends/virtuoso/virtuosocontroller.h b/backends/virtuoso/virtuosocontroller.h
index 713d5cc..0f772d4 100644
--- a/backends/virtuoso/virtuosocontroller.h
+++ b/backends/virtuoso/virtuosocontroller.h
@@ -74,7 +74,7 @@ namespace Soprano {
 
     Q_SIGNALS:
         void started();
-        void stopped( ExitStatus status );
+        void stopped( Soprano::VirtuosoController::ExitStatus status );
 
     private Q_SLOTS:
         void slotProcessFinished( int exitCode, QProcess::ExitStatus exitStatus );
diff --git a/backends/virtuoso/virtuosomodel.cpp b/backends/virtuoso/virtuosomodel.cpp
index 9b9aa5d..5b04c4e 100644
--- a/backends/virtuoso/virtuosomodel.cpp
+++ b/backends/virtuoso/virtuosomodel.cpp
@@ -1,7 +1,7 @@
 /*
  * This file is part of Soprano Project
  *
- * Copyright (C) 2008-2010 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2008-2011 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -449,4 +449,17 @@ Soprano::QueryResultIterator Soprano::VirtuosoModel::executeQuery( const QString
     return d->sparqlQuery( d->replaceFakeTypesInQuery( query ) );
 }
 
+
+void Soprano::VirtuosoModel::slotVirtuosoStopped(VirtuosoController::ExitStatus status)
+{
+    // inform clients about a non-scheduled exit of the server so they can act accordingly
+    // typically this would mean to re-create the model from the backend
+    // We do this async in case clients react by directly deleting us
+    QMetaObject::invokeMethod(this,
+                              "virtuosoStopped",
+                              Qt::QueuedConnection,
+                              Q_ARG(bool, (!(status == VirtuosoController::CrashExit ||
+                                             status == VirtuosoController::ThirdPartyExit))));
+}
+
 #include "virtuosomodel.moc"
diff --git a/backends/virtuoso/virtuosomodel.h b/backends/virtuoso/virtuosomodel.h
index ba1a344..7ad70a3 100644
--- a/backends/virtuoso/virtuosomodel.h
+++ b/backends/virtuoso/virtuosomodel.h
@@ -1,7 +1,7 @@
 /*
  * This file is part of Soprano Project
  *
- * Copyright (C) 2008-2010 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2008-2011 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -19,10 +19,11 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#ifndef _SOPRANO_IODBC_MODEL_H_
-#define _SOPRANO_IODBC_MODEL_H_
+#ifndef _SOPRANO_VIRTUOSO_MODEL_H_
+#define _SOPRANO_VIRTUOSO_MODEL_H_
 
 #include "storagemodel.h"
+#include "virtuosocontroller.h"
 
 namespace Soprano {
     namespace ODBC {
@@ -55,6 +56,14 @@ namespace Soprano {
                                                    Query::QueryLanguage language = Query::QueryLanguageSparql,
                                                    const QString& userQueryLanguage = QString() ) const;
 
+    public Q_SLOTS:
+        /// a public slot since it is connected from the backend on creation time
+        void slotVirtuosoStopped(Soprano::VirtuosoController::ExitStatus status);
+
+    Q_SIGNALS:
+        /// \param normalExit \p true if the shutdown of Virtuoso was initialized by deleting the model
+        void virtuosoStopped(bool normalExit);
+
     private:
         VirtuosoModelPrivate* const d;
 
openSUSE Build Service is sponsored by