Commit 7fa4ad1f authored by Jan Möbius's avatar Jan Möbius
Browse files

Added Version information for plugins

Check updates on server in ini files

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@2938 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 440b1803
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
// it under the terms of the GNU Lesser General Public License as published by // it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// OpenFlipper is distributed in the hope that it will be useful, // OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details. // GNU Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public License // You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>. // along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
// //
...@@ -35,57 +35,57 @@ ...@@ -35,57 +35,57 @@
// //
// C++ Interface: BasePlugin // C++ Interface: BasePlugin
// //
// Description: // Description:
// //
// //
// Author: Jan Moebius <jan_moebius@web.de>, (C) 2007 // Author: Jan Moebius <jan_moebius@web.de>, (C) 2007
// //
#ifndef BASEINTERFACE_HH #ifndef BASEINTERFACE_HH
#define BASEINTERFACE_HH #define BASEINTERFACE_HH
#include <QtGui> #include <QtGui>
#include <QMenuBar> #include <QMenuBar>
#include <ACG/QtWidgets/QtExaminerViewer.hh> #include <ACG/QtWidgets/QtExaminerViewer.hh>
#include <OpenFlipper/common/Types.hh> #include <OpenFlipper/common/Types.hh>
/** \brief Interface class from which all plugins have to be created. /** \brief Interface class from which all plugins have to be created.
* *
* You have to implement at least name and description for your plugin. * You have to implement at least name and description for your plugin.
* All other functions and signals are optional. If you want to implement or use * All other functions and signals are optional. If you want to implement or use
* them just add them to your plugin header. * them just add them to your plugin header.
*/ */
class BaseInterface { class BaseInterface {
signals : signals :
/** \brief Update current view in Main Application /** \brief Update current view in Main Application
* *
* Emit this Signal if the examiner widget in the Main Application should update the current view. * Emit this Signal if the examiner widget in the Main Application should update the current view.
* This should be done for example if you changed a scenegraph node or a mesh and have * This should be done for example if you changed a scenegraph node or a mesh and have
* to redraw it. * to redraw it.
*/ */
virtual void update_view() {}; virtual void update_view() {};
/** \brief The object list has been changed by this plugin /** \brief The object list has been changed by this plugin
* *
* Emit this Signal, if the object list has changed (e.g. Source or Target changed).\n * Emit this Signal, if the object list has changed (e.g. Source or Target changed).\n
* If you changed the element itself (geometry, topology,..) You should also emit this signal.\n * If you changed the element itself (geometry, topology,..) You should also emit this signal.\n
* Dont emit this Signal in BaseInterface::slotObjectUpdated() as this causes an endless Loop!! * Dont emit this Signal in BaseInterface::slotObjectUpdated() as this causes an endless Loop!!
* Give the id of the new object as parameter or -1 if you deleted an object. * Give the id of the new object as parameter or -1 if you deleted an object.
*/ */
virtual void updated_objects(int) {}; virtual void updated_objects(int) {};
/** \brief The active object has been switched by this plugin /** \brief The active object has been switched by this plugin
* *
* This Signal is used to tell the other plugins that the active object has been changed.\n * This Signal is used to tell the other plugins that the active object has been changed.\n
* You should only do this if you are writing a plugin that manages the objects(e.g. DatacontrolPlugin).\n * You should only do this if you are writing a plugin that manages the objects(e.g. DatacontrolPlugin).\n
*/ */
virtual void activeObjectChanged() {}; virtual void activeObjectChanged() {};
private slots : private slots :
/** \brief An object has been updated by an other plugin /** \brief An object has been updated by an other plugin
* *
* This slot is called by the Main aplication if the number or status of existing objects changed or if * This slot is called by the Main aplication if the number or status of existing objects changed or if
* an existing object has been changed. This could mean, that objects are added or deleted * an existing object has been changed. This could mean, that objects are added or deleted
* or that for an existing object with the given id has been modified. * or that for an existing object with the given id has been modified.
* If you store local information about one of these Objects, you should check if its still valid!\n * If you store local information about one of these Objects, you should check if its still valid!\n
...@@ -93,66 +93,75 @@ class BaseInterface { ...@@ -93,66 +93,75 @@ class BaseInterface {
* @param _identifier Identifier of the updated/new object or -1 if one is deleted * @param _identifier Identifier of the updated/new object or -1 if one is deleted
*/ */
virtual void slotObjectUpdated( int _identifier ) {}; virtual void slotObjectUpdated( int _identifier ) {};
/** \brief Called if the whole scene is cleared /** \brief Called if the whole scene is cleared
* *
*/ */
virtual void slotAllCleared( ) {}; virtual void slotAllCleared( ) {};
/** \brief The active object has changed /** \brief The active object has changed
* *
* This slot is called by the Main aplication if the currently active object has changed.\n * This slot is called by the Main aplication if the currently active object has changed.\n
* This means that the selection of target objects has changed. * This means that the selection of target objects has changed.
*/ */
virtual void slotActiveObjectChanged() {}; virtual void slotActiveObjectChanged() {};
/** \brief Initialize Plugin /** \brief Initialize Plugin
* *
* This slot is called if the plugin is loaded and has to be initialized. All initialization stuff * This slot is called if the plugin is loaded and has to be initialized. All initialization stuff
* in this slot has to stay inside the plugin, no external singals are allowed here. * in this slot has to stay inside the plugin, no external singals are allowed here.
* Dont create any objects via pluginfunctions here. Use the pluginsInitialized() slot for external * Dont create any objects via pluginfunctions here. Use the pluginsInitialized() slot for external
* Initialization. After execution of this slot your plugin should be fully functional. * Initialization. After execution of this slot your plugin should be fully functional.
* Only gui elements may be uninitialized and should be created in pluginsInitialized(). * Only gui elements may be uninitialized and should be created in pluginsInitialized().
*/ */
virtual void initializePlugin() {}; virtual void initializePlugin() {};
/** \brief Initialize Plugin step 2 /** \brief Initialize Plugin step 2
* *
* This slot is called if all plugins are loaded and the core is ready. Here you can create objects, * This slot is called if all plugins are loaded and the core is ready. Here you can create objects,
* set Textures and everything which will involve signals to the core. * set Textures and everything which will involve signals to the core.
*/ */
virtual void pluginsInitialized() {}; virtual void pluginsInitialized() {};
/** This function is called when the application exits or when your plugin is about to be unloaded. /** This function is called when the application exits or when your plugin is about to be unloaded.
* Here you can clean up your plugin, delete local variables... * Here you can clean up your plugin, delete local variables...
*/ */
virtual void exit(){}; virtual void exit(){};
/** Using this function you can inform the core that your plugin can run without creating a widget. /** Using this function you can inform the core that your plugin can run without creating a widget.
* If your plugin does not implement this function, it will not be loaded in scripting mode. * If your plugin does not implement this function, it will not be loaded in scripting mode.
* You dont have to do anything in this function. * You dont have to do anything in this function.
*/ */
virtual void noguiSupported( ) {} ; virtual void noguiSupported( ) {} ;
public : public slots:
/** \brief Return a version string for your plugin
*
* This function will be used to determin the current version of your plugin.
* Should have the form x.x.x ( you do not need to give that many subversions )
*/
virtual QString version() { return QString("-1"); };
public :
/// Destructor /// Destructor
virtual ~BaseInterface() {}; virtual ~BaseInterface() {};
/** \brief Return a Name for the plugin /** \brief Return a Name for the plugin
* *
* This Function has to return the name of the plugin. * This Function has to return the name of the plugin.
*/ */
virtual QString name() = 0; virtual QString name() = 0;
/** \brief Return a description of what the plugin is doing /** \brief Return a description of what the plugin is doing
* *
* This function has to return a basic description of the plugin * This function has to return a basic description of the plugin
*/ */
virtual QString description() = 0; virtual QString description() = 0;
}; };
Q_DECLARE_INTERFACE(BaseInterface,"OpenFlipper.BaseInterface/0.3") Q_DECLARE_INTERFACE(BaseInterface,"OpenFlipper.BaseInterface/0.3")
#endif // BASEINTERFACE_HH #endif // BASEINTERFACE_HH
...@@ -27,6 +27,9 @@ struct PluginInfo{ ...@@ -27,6 +27,9 @@ struct PluginInfo{
/// Description of the plugin ( requested from the plugin on load) /// Description of the plugin ( requested from the plugin on load)
QString description; QString description;
/// Version of the plugin
QString version;
/// Path to the plugin ( set on load ) /// Path to the plugin ( set on load )
QString path; QString path;
......
...@@ -384,6 +384,11 @@ void Core::loadPlugin(QString filename, bool silent){ ...@@ -384,6 +384,11 @@ void Core::loadPlugin(QString filename, bool silent){
info.path = filename; info.path = filename;
info.widget = 0; info.widget = 0;
if ( checkSlot(plugin,"version()") )
info.version = basePlugin->version();
else
info.version = QString::number(-1);
if ( OpenFlipper::Options::nogui() ) { if ( OpenFlipper::Options::nogui() ) {
if ( ! checkSlot( plugin , "noguiSupported()" ) ) { if ( ! checkSlot( plugin , "noguiSupported()" ) ) {
...@@ -403,7 +408,7 @@ void Core::loadPlugin(QString filename, bool silent){ ...@@ -403,7 +408,7 @@ void Core::loadPlugin(QString filename, bool silent){
if ( checkSlot(plugin,"slotAllCleared()") ) if ( checkSlot(plugin,"slotAllCleared()") )
connect(this,SIGNAL(allCleared()),plugin,SLOT(slotAllCleared())); connect(this,SIGNAL(allCleared()),plugin,SLOT(slotAllCleared()));
if ( checkSignal(plugin,"activeObjectChanged()") ) if ( checkSignal(plugin,"activeObjectChanged()") )
connect(plugin,SIGNAL(activeObjectChanged()),this,SLOT(slotActiveObjectChanged() )); connect(plugin,SIGNAL(activeObjectChanged()),this,SLOT(slotActiveObjectChanged() ));
...@@ -582,7 +587,7 @@ void Core::loadPlugin(QString filename, bool silent){ ...@@ -582,7 +587,7 @@ void Core::loadPlugin(QString filename, bool silent){
// if ( checkSlot( plugin , "slotKeyEvent(QKeyEvent*)" ) ) // if ( checkSlot( plugin , "slotKeyEvent(QKeyEvent*)" ) )
// connect(coreWidget_,SIGNAL(PluginKeyEvent(QKeyEvent* )), plugin,SLOT(slotKeyEvent(QKeyEvent*))); // connect(coreWidget_,SIGNAL(PluginKeyEvent(QKeyEvent* )), plugin,SLOT(slotKeyEvent(QKeyEvent*)));
// //
// if ( checkSlot( plugin , "slotKeyReleaseEvent(QKeyEvent*)" ) ) // if ( checkSlot( plugin , "slotKeyReleaseEvent(QKeyEvent*)" ) )
// connect(coreWidget_,SIGNAL(PluginKeyReleaseEvent(QKeyEvent* )), plugin,SLOT(slotKeyReleaseEvent(QKeyEvent*))); // connect(coreWidget_,SIGNAL(PluginKeyReleaseEvent(QKeyEvent* )), plugin,SLOT(slotKeyReleaseEvent(QKeyEvent*)));
} }
......
...@@ -351,25 +351,63 @@ void OptionsWidget::compareVersions() { ...@@ -351,25 +351,63 @@ void OptionsWidget::compareVersions() {
QString updatedComponents = "Updates found for "; QString updatedComponents = "Updates found for ";
if ( OpenFlipper::Options::isWindows() ) {
QString coreVersion;
if ( ini.get_entry(coreVersion, "Core" , "VersionWindows" )) { QString systemString = "";
if ( isNewer( OpenFlipper::Options::coreVersion(), coreVersion ) ) { if ( true || OpenFlipper::Options::isWindows() ) {
std::cerr << "Newer Version found for Core!" << std::endl; systemString = "VersionWindows";
std::cerr << "Latest Version is " << coreVersion.toStdString() << std::endl; } else if (OpenFlipper::Options::isLinux()) {
std::cerr << "Current Version is " << OpenFlipper::Options::coreVersion().toStdString() << std::endl; systemString = "VersionLinux";
return;
} else {
std::cerr << "Unsupported platform for update" << std::endl;
return;
}
QString coreVersion;
if ( ini.get_entry(coreVersion, "Core" , systemString )) {
if ( isNewer( OpenFlipper::Options::coreVersion(), coreVersion ) ) {
std::cerr << "Newer Version found for Core!" << std::endl;
std::cerr << "Latest Version is " << coreVersion.toStdString() << std::endl;
std::cerr << "Current Version is " << OpenFlipper::Options::coreVersion().toStdString() << std::endl;
newerVersionsAvailable = true;
updatedComponents += "Core " + OpenFlipper::Options::coreVersion() + " -> " + coreVersion ;
}
}
for ( uint i = 0 ; i < plugins_.size(); ++i ) {
QString latestVersion;
if ( ini.get_entry(latestVersion, plugins_[i].name , systemString )) {
if ( isNewer( plugins_[i].version, latestVersion ) ) {
std::cerr << "Newer Version found for " << plugins_[i].name.toStdString() << std::endl;
std::cerr << "Latest Version is " << latestVersion.toStdString() << std::endl;
std::cerr << "Current Version is " << plugins_[i].version.toStdString() << std::endl;
newerVersionsAvailable = true; newerVersionsAvailable = true;
updatedComponents += "Core " + OpenFlipper::Options::coreVersion() + " -> " + coreVersion; updatedComponents += plugins_[i].name + " " + plugins_[i].version + " -> " + latestVersion;
} }
} }
// else {
//
// std::cerr << "No Version information on server for " << plugins_[i].name.toStdString()
// << ". Local Version is ";
} else { // if ( plugins_[i].version == "-1" )
std::cerr << "Updates for linux not implemented yet" << std::endl; // std::cerr << "UNKNOWN (no info provided by plugin" << std::endl;
// else
// std::cerr << plugins_[i].version.toStdString() << std::endl;
// }
} }
if ( newerVersionsAvailable ) { if ( newerVersionsAvailable ) {
statusLabel->setText(updatedComponents); statusLabel->setText(updatedComponents);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment