Commit 80b0bd7c authored by Jan Möbius's avatar Jan Möbius

Updated license manager

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10389 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c9ccf55a
...@@ -160,6 +160,9 @@ bool Core::checkSignal(QObject* _plugin , const char* _signalSignature) { ...@@ -160,6 +160,9 @@ bool Core::checkSignal(QObject* _plugin , const char* _signalSignature) {
*/ */
void Core::loadPlugins() void Core::loadPlugins()
{ {
QString licenseTexts = "";
//try to load plugins from new location //try to load plugins from new location
QDir tempDir = QDir(OpenFlipper::Options::pluginDir()); QDir tempDir = QDir(OpenFlipper::Options::pluginDir());
...@@ -258,7 +261,9 @@ void Core::loadPlugins() ...@@ -258,7 +261,9 @@ void Core::loadPlugins()
loaderThreads[i]->wait(); loaderThreads[i]->wait();
if ( loaderThreads[i]->getInstance() != 0 ) { if ( loaderThreads[i]->getInstance() != 0 ) {
loadPlugin(loaderThreads[i]->filename(),true,loaderThreads[i]->getInstance()); QString pluginLicenseText = "";
loadPlugin(loaderThreads[i]->filename(),true,pluginLicenseText, loaderThreads[i]->getInstance());
licenseTexts += pluginLicenseText;
} else { } else {
emit log(LOGERR,tr("Unable to load Plugin :\t %1").arg( loaderThreads[i]->filename() ) ); emit log(LOGERR,tr("Unable to load Plugin :\t %1").arg( loaderThreads[i]->filename() ) );
emit log(LOGERR,tr("Error was : ") + loaderThreads[i]->getError() ); emit log(LOGERR,tr("Error was : ") + loaderThreads[i]->getError() );
...@@ -270,6 +275,15 @@ void Core::loadPlugins() ...@@ -270,6 +275,15 @@ void Core::loadPlugins()
splashMessage_ = ""; splashMessage_ = "";
if ( licenseTexts != "" ) {
if ( OpenFlipper::Options::gui() )
QMessageBox::warning ( 0, tr("Plugin License check failed"), licenseTexts );
else {
std::cerr << "Plugin License check failed" << std::endl;
std::cerr << licenseTexts.toStdString() << std::endl;
}
}
emit pluginsInitialized(); emit pluginsInitialized();
emit log(LOGOUT,tr("Loaded %n Plugin(s)","",plugins.size()) ); emit log(LOGOUT,tr("Loaded %n Plugin(s)","",plugins.size()) );
...@@ -344,7 +358,17 @@ void Core::slotLoadPlugin(){ ...@@ -344,7 +358,17 @@ void Core::slotLoadPlugin(){
} }
} }
loadPlugin(filename,false); QString licenseText = "";
loadPlugin(filename,false,licenseText);
if ( licenseText != "" ) {
if ( OpenFlipper::Options::gui() )
QMessageBox::warning ( 0, tr("Plugin License check failed"), licenseText );
else {
std::cerr << "Plugin License check failed" << std::endl;
std::cerr << licenseText.toStdString() << std::endl;
}
}
} }
/** @brief slot for showing loaded Plugins /** @brief slot for showing loaded Plugins
...@@ -404,9 +428,12 @@ void Core::unloadPlugin(QString name){ ...@@ -404,9 +428,12 @@ void Core::unloadPlugin(QString name){
/** @brief Load a Plugin with given filename /** @brief Load a Plugin with given filename
* @param filename complete path + filename of the plugin * @param filename complete path + filename of the plugin
* @param silent if 'true': user isn't asked what to do if a plugin is already loaded * @param silent if 'true': user isn't asked what to do if a plugin is already loaded
* @param _licenseErrors String will be epty when no license issues occured, otherwise it contains the required information for obtaining a license
* @param _plugin You can provide a preloaded plugin here. If this is 0 the filename will be used to load the plugin. * @param _plugin You can provide a preloaded plugin here. If this is 0 the filename will be used to load the plugin.
*/ */
void Core::loadPlugin(QString filename, bool silent, QObject* _plugin){ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QObject* _plugin){
_licenseErrors = "";
// Only load .dll under windows // Only load .dll under windows
if ( OpenFlipper::Options::isWindows() ) { if ( OpenFlipper::Options::isWindows() ) {
...@@ -502,13 +529,15 @@ void Core::loadPlugin(QString filename, bool silent, QObject* _plugin){ ...@@ -502,13 +529,15 @@ void Core::loadPlugin(QString filename, bool silent, QObject* _plugin){
emit log(LOGINFO,tr("Plugin uses security interface. Trying to authenticate against plugin ...")); emit log(LOGINFO,tr("Plugin uses security interface. Trying to authenticate against plugin ..."));
bool success = false; bool success = false;
QMetaObject::invokeMethod(plugin,"authenticate", Q_RETURN_ARG( bool , success ) ) ; QMetaObject::invokeMethod(plugin,"authenticate", Q_RETURN_ARG( bool , success ) , Q_ARG(QString&, _licenseErrors)) ;
if ( success ) if ( success )
emit log(LOGINFO,tr("... ok. Loading plugin ")); emit log(LOGINFO,tr("... ok. Loading plugin "));
else { else {
emit log(LOGERR,tr("... failed. Plugin access denied.")); emit log(LOGERR,tr("... failed. Plugin access denied."));
emit log(LOGOUT,"================================================================================"); emit log(LOGOUT,"================================================================================");
// Abort here, as the plugin will not do anything else until correct authentication.
return; return;
} }
} }
......
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