[Amarok] 868d5d6 Add a versioning system for Context View applets.
Mark Kretschmann
kretschmann at kde.org
Thu Mar 18 12:30:05 CET 2010
commit 868d5d6fa88f43701be280e31acb7df60af68d60
Author: Mark Kretschmann <kretschmann at kde.org>
Date: Thu Mar 18 12:27:21 2010 +0100
Add a versioning system for Context View applets.
The purpose of this is the same as with our Plugins: Making sure that
deprecated applets from old Amarok installs no longer show up.
TODO: Discuss with Leo Franchi how to handle the problem with the config
loading. Currently if an applet is not loaded, a ghost of the applet appears.
TODO: Extend our bump_plugin_version.rb script to handle applet versioning.
CCMAIL: amarok-devel at kde.org
diff --git a/src/Amarok.h b/src/Amarok.h
index 6c7d7b5..6d287e3 100644
--- a/src/Amarok.h
+++ b/src/Amarok.h
@@ -46,9 +46,19 @@ namespace Amarok
const int VOLUME_SENSITIVITY = 30; // for mouse wheels
const int GUI_THREAD_ID = 0;
- /** Bump this number whenever the plugin framework gets incompatible with older versions */
+ /**
+ * Bump this number whenever the plugin framework becomes incompatible with older versions.
+ * This is normally handled by the "bump_plugin_version.rb" script before tagging.
+ */
static const int PluginFrameworkVersion = 54;
+ /**
+ * Bump this number whenever Context View applets have been removed or renamed.
+ * This is normally handled by the "bump_plugin_version.rb" script before tagging.
+ */
+ static const int AppletFrameworkVersion = 1;
+
+
extern QMutex globalDirsMutex; // defined in App.cpp
extern QPointer<KActionCollection> actionCollectionObject; // defined in App.cpp
diff --git a/src/context/Applet.h b/src/context/Applet.h
index fab3cf3..120d962 100644
--- a/src/context/Applet.h
+++ b/src/context/Applet.h
@@ -1,5 +1,6 @@
/****************************************************************************************
* Copyright (c) 2007 Leo Franchi <lfranchi at gmail.com> *
+ * Copyright (c) 2010 Mark Kretschmann <kretschmann at kde.org> *
* *
* This program is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License as published by the Free Software *
@@ -82,6 +83,12 @@ class AMAROK_EXPORT Applet : public Plasma::Applet
bool isAppletExtended();
/**
+ * Return version of the applet, which is used for sorting out deprecated applets.
+ @return version number of the applet
+ */
+ virtual int appletVersion() const = 0;
+
+ /**
* sizeHint is reimplemented here only for all the applet.
*/
virtual QSizeF sizeHint( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const;
diff --git a/src/context/applets/albums/Albums.h b/src/context/applets/albums/Albums.h
index 2fb1fdb..0d689b2 100644
--- a/src/context/applets/albums/Albums.h
+++ b/src/context/applets/albums/Albums.h
@@ -52,6 +52,8 @@ public:
void constraintsEvent( Plasma::Constraints constraints = Plasma::AllConstraints);
+ virtual int appletVersion() const { return 1; }
+
public slots:
void dataUpdated( const QString& name, const Plasma::DataEngine::Data &data );
void showConfigurationInterface();
diff --git a/src/context/applets/coverbling/CoverBlingApplet.h b/src/context/applets/coverbling/CoverBlingApplet.h
index e74b1bf..4e7f44c 100644
--- a/src/context/applets/coverbling/CoverBlingApplet.h
+++ b/src/context/applets/coverbling/CoverBlingApplet.h
@@ -54,6 +54,8 @@ class CoverBlingApplet : public Context::Applet, public EngineObserver
// inherited from EngineObserver
virtual void engineNewTrackPlaying();
+ virtual int appletVersion() const { return 1; }
+
public slots:
void slotAlbumQueryResult( QString collectionId, Meta::AlbumList albums);
void slideChanged(int islideindex);
diff --git a/src/context/applets/currenttrack/CurrentTrack.h b/src/context/applets/currenttrack/CurrentTrack.h
index 304659b..83eaeb1 100644
--- a/src/context/applets/currenttrack/CurrentTrack.h
+++ b/src/context/applets/currenttrack/CurrentTrack.h
@@ -57,6 +57,8 @@ public:
virtual void init();
virtual void paintInterface( QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect );
+ virtual int appletVersion() const { return 1; }
+
public slots:
void dataUpdated( const QString& name, const Plasma::DataEngine::Data &data );
diff --git a/src/context/applets/info/InfoApplet.h b/src/context/applets/info/InfoApplet.h
index 4be28fc..d928a6b 100644
--- a/src/context/applets/info/InfoApplet.h
+++ b/src/context/applets/info/InfoApplet.h
@@ -51,6 +51,8 @@ public:
void paintInterface( QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect );
void constraintsEvent( Plasma::Constraints constraints = Plasma::AllConstraints );
+ virtual int appletVersion() const { return 1; }
+
public slots:
void dataUpdated( const QString& name, const Plasma::DataEngine::Data &data );
diff --git a/src/context/applets/lyrics/LyricsApplet.h b/src/context/applets/lyrics/LyricsApplet.h
index 7234b03..fe7f235 100644
--- a/src/context/applets/lyrics/LyricsApplet.h
+++ b/src/context/applets/lyrics/LyricsApplet.h
@@ -50,6 +50,8 @@ public:
void paintInterface( QPainter *painter, const QStyleOptionGraphicsItem* option, const QRect& contentsRect );
+ virtual int appletVersion() const { return 1; }
+
public slots:
void connectSource( const QString& source );
void dataUpdated( const QString& name, const Plasma::DataEngine::Data& data );
diff --git a/src/context/applets/photos/PhotosApplet.h b/src/context/applets/photos/PhotosApplet.h
index 5e3931a..f149296 100644
--- a/src/context/applets/photos/PhotosApplet.h
+++ b/src/context/applets/photos/PhotosApplet.h
@@ -56,6 +56,8 @@ class PhotosApplet : public Context::Applet, public EngineObserver
virtual void engineNewTrackPlaying();
virtual void enginePlaybackEnded( qint64 finalPosition, qint64 trackLength, PlaybackEndedReason reason );
+ virtual int appletVersion() const { return 1; }
+
public slots:
void dataUpdated( const QString& name, const Plasma::DataEngine::Data& data );
void connectSource( const QString &source );
diff --git a/src/context/applets/playlistinfo/PlaylistInfo.h b/src/context/applets/playlistinfo/PlaylistInfo.h
index 79096e5..a2a2f61 100644
--- a/src/context/applets/playlistinfo/PlaylistInfo.h
+++ b/src/context/applets/playlistinfo/PlaylistInfo.h
@@ -42,6 +42,8 @@ public:
void constraintsEvent();
QSizeF contentSizeHint() const { return m_size; }
+ virtual int appletVersion() const { return 1; }
+
public slots:
void dataUpdated( const QString& name, const Plasma::DataEngine::Data &data );
void showConfigurationInterface();
diff --git a/src/context/applets/songkick/SongkickApplet.h b/src/context/applets/songkick/SongkickApplet.h
index a07ca45..0998080 100644
--- a/src/context/applets/songkick/SongkickApplet.h
+++ b/src/context/applets/songkick/SongkickApplet.h
@@ -46,6 +46,8 @@ public:
virtual QSizeF sizeHint( Qt::SizeHint which, const QSizeF & constraint) const;
+ virtual int appletVersion() const { return 1; }
+
public slots:
void connectSource( const QString& source );
void dataUpdated( const QString& name, const Plasma::DataEngine::Data& data );
diff --git a/src/context/applets/videoclip/VideoclipApplet.h b/src/context/applets/videoclip/VideoclipApplet.h
index 56b185f..fe90a96 100644
--- a/src/context/applets/videoclip/VideoclipApplet.h
+++ b/src/context/applets/videoclip/VideoclipApplet.h
@@ -83,6 +83,8 @@ class VideoclipApplet : public Context::Applet, public EngineObserver
virtual void engineStateChanged(Phonon::State, Phonon::State );
virtual void enginePlaybackEnded( qint64 finalPosition, qint64 trackLength, PlaybackEndedReason reason );
+ virtual int appletVersion() const { return 1; }
+
public slots:
void setGeom();
void dataUpdated( const QString& name, const Plasma::DataEngine::Data& data );
diff --git a/src/context/applets/wikipedia/WikipediaApplet.h b/src/context/applets/wikipedia/WikipediaApplet.h
index fd52c70..7b4a083 100644
--- a/src/context/applets/wikipedia/WikipediaApplet.h
+++ b/src/context/applets/wikipedia/WikipediaApplet.h
@@ -57,6 +57,8 @@ public:
bool hasHeightForWidth() const;
qreal heightForWidth( qreal width ) const;
+ virtual int appletVersion() const { return 1; }
+
protected:
void createConfigurationInterface(KConfigDialog *parent);
diff --git a/src/context/containments/verticallayout/VerticalToolbarContainment.cpp b/src/context/containments/verticallayout/VerticalToolbarContainment.cpp
index 4af6074..b3683f1 100644
--- a/src/context/containments/verticallayout/VerticalToolbarContainment.cpp
+++ b/src/context/containments/verticallayout/VerticalToolbarContainment.cpp
@@ -1,5 +1,6 @@
/****************************************************************************************
* Copyright (c) 2007 Leo Franchi <lfranchi at kde.org> *
+ * Copyright (c) 2010 Mark Kretschmann <kretschmann at kde.org> *
* *
* This program is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License as published by the Free Software *
@@ -16,6 +17,7 @@
#include "VerticalToolbarContainment.h"
+#include "Amarok.h"
#include "ContextView.h"
#include "Debug.h"
#include "PaletteHandler.h"
@@ -141,13 +143,21 @@ Context::VerticalToolbarContainment::addApplet( const QString& pluginName, const
{
DEBUG_BLOCK
- Plasma::Applet* applet = Plasma::Containment::addApplet( pluginName );
+ Context::Applet* applet = qobject_cast<Context::Applet*>( Plasma::Containment::addApplet( pluginName ) );
if( applet == 0 )
+ {
debug() << "FAILED ADDING APPLET TO CONTAINMENT!! NOT FOUND!!";
- else
- m_applets->addApplet( applet, loc );
+ return 0;
+ }
+
+ if( applet->appletVersion() != Amarok::AppletFrameworkVersion )
+ {
+ debug() << "Applet version mismatch. Skipping this applet.";
+ return 0;
+ }
+ m_applets->addApplet( applet, loc );
return applet;
}
More information about the Amarok-devel
mailing list