mirror of
https://github.com/status-im/snorenotify.git
synced 2025-01-10 16:45:56 +00:00
reduced member count
This commit is contained in:
parent
6e4f0b3659
commit
428456570d
@ -26,8 +26,9 @@
|
||||
#include <QPluginLoader>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <QMetaEnum>
|
||||
|
||||
namespace Snore{
|
||||
using namespace Snore;
|
||||
|
||||
SnorePlugin::SnorePlugin ( const QString &name ) :
|
||||
m_name ( name ),
|
||||
@ -79,4 +80,32 @@ bool SnorePlugin::deinitialize()
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QDebug operator <<(QDebug debug, const Snore::SnorePlugin::PluginTypes &flags)
|
||||
{
|
||||
QMetaEnum e = SnorePlugin::staticMetaObject.enumerator(SnorePlugin::staticMetaObject.indexOfEnumerator("PluginType"));
|
||||
debug.nospace() << "PluginTypes(";
|
||||
bool needSeparator = false;
|
||||
int key;
|
||||
for (uint i = 0; i < e.keyCount(); ++i)
|
||||
{
|
||||
key = e.value(i);
|
||||
if (flags.testFlag((SnorePlugin::PluginType)key))
|
||||
{
|
||||
if (needSeparator)
|
||||
{
|
||||
debug.nospace() << '|';
|
||||
}
|
||||
else
|
||||
{
|
||||
needSeparator = true;
|
||||
}
|
||||
|
||||
debug.nospace() << e.valueToKey(key);
|
||||
|
||||
}
|
||||
}
|
||||
debug << ')';
|
||||
return debug.space();
|
||||
|
||||
}
|
||||
|
@ -71,6 +71,8 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Snore::SnorePlugin::PluginTypes)
|
||||
Q_DECLARE_INTERFACE ( Snore::SnorePlugin,
|
||||
"org.Snore.SnorePlugin/1.0" )
|
||||
|
||||
SNORE_EXPORT QDebug operator<< ( QDebug, const Snore::SnorePlugin::PluginTypes &);
|
||||
|
||||
//compatability defines to reduce the number of ifdefs to make fiat compile with qt4 and qt5
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
# if defined(Q_EXPORT_PLUGIN)
|
||||
|
@ -64,7 +64,7 @@ void SnoreCore::loadPlugins( SnorePlugin::PluginTypes types )
|
||||
case SnorePlugin::BACKEND:
|
||||
{
|
||||
snoreDebug( SNORE_DEBUG ) << info->name() << "is a Notification_Backend";
|
||||
d->m_notificationBackends.append( info->name());
|
||||
d->m_plugins.insert(SnorePlugin::BACKEND, info->name());
|
||||
break;
|
||||
}
|
||||
case SnorePlugin::SECONDARY_BACKEND:
|
||||
@ -73,7 +73,7 @@ void SnoreCore::loadPlugins( SnorePlugin::PluginTypes types )
|
||||
info->unload();
|
||||
break;
|
||||
}
|
||||
d->m_secondaryNotificationBackends.append(info->name());
|
||||
d->m_plugins.insert(SnorePlugin::SECONDARY_BACKEND, info->name());
|
||||
break;
|
||||
}
|
||||
case SnorePlugin::FRONTEND:
|
||||
@ -83,7 +83,7 @@ void SnoreCore::loadPlugins( SnorePlugin::PluginTypes types )
|
||||
info->unload();
|
||||
break;
|
||||
}
|
||||
d->m_Frontends.append(info->name());
|
||||
d->m_plugins.insert(SnorePlugin::FRONTEND, info->name());
|
||||
break;
|
||||
}
|
||||
case SnorePlugin::PLUGIN:
|
||||
@ -93,7 +93,7 @@ void SnoreCore::loadPlugins( SnorePlugin::PluginTypes types )
|
||||
info->unload();
|
||||
break;
|
||||
}
|
||||
d->m_plugins.append(info->name());
|
||||
d->m_plugins.insert(SnorePlugin::PLUGIN, info->name());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -106,7 +106,7 @@ void SnoreCore::loadPlugins( SnorePlugin::PluginTypes types )
|
||||
snoreDebug( SNORE_DEBUG )<<"dont load "<<info->file()<<info->type();
|
||||
}
|
||||
}
|
||||
snoreDebug( SNORE_INFO ) << "Loaded Plugins:" << d->m_notificationBackends << d->m_Frontends << d->m_secondaryNotificationBackends << d->m_plugins;
|
||||
snoreDebug( SNORE_INFO ) << "Loaded Plugins:" << d->m_plugins;
|
||||
}
|
||||
|
||||
void SnoreCore::broadcastNotification ( Notification notification )
|
||||
@ -145,22 +145,22 @@ const QHash<QString, Application> &SnoreCore::aplications() const
|
||||
}
|
||||
|
||||
|
||||
const QStringList &SnoreCore::notificationBackends() const
|
||||
const QStringList SnoreCore::notificationBackends() const
|
||||
{
|
||||
Q_D(const SnoreCore);
|
||||
return d->m_notificationBackends;
|
||||
return d->m_plugins.values(SnorePlugin::BACKEND);
|
||||
}
|
||||
|
||||
const QStringList &SnoreCore::notificationFrontends() const
|
||||
const QStringList SnoreCore::notificationFrontends() const
|
||||
{
|
||||
Q_D(const SnoreCore);
|
||||
return d->m_Frontends;
|
||||
return d->m_plugins.values(SnorePlugin::FRONTEND);
|
||||
}
|
||||
|
||||
const QStringList &SnoreCore::secondaryNotificationBackends() const
|
||||
const QStringList SnoreCore::secondaryNotificationBackends() const
|
||||
{
|
||||
Q_D(const SnoreCore);
|
||||
return d->m_secondaryNotificationBackends;
|
||||
return d->m_plugins.values(SnorePlugin::SECONDARY_BACKEND);
|
||||
}
|
||||
|
||||
bool SnoreCore::setPrimaryNotificationBackend ( const QString &backend )
|
||||
|
@ -106,19 +106,19 @@ public:
|
||||
*
|
||||
* @return a list of all known notification backends
|
||||
*/
|
||||
const QStringList ¬ificationBackends() const;
|
||||
const QStringList notificationBackends() const;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return a list of all known notification frontends
|
||||
*/
|
||||
const QStringList ¬ificationFrontends() const;
|
||||
const QStringList notificationFrontends() const;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return a list of all known notification secondary backends
|
||||
*/
|
||||
const QStringList &secondaryNotificationBackends() const;
|
||||
const QStringList secondaryNotificationBackends() const;
|
||||
|
||||
/**
|
||||
* Sets the primary backend.
|
||||
|
@ -80,7 +80,7 @@ void SnoreCorePrivate::notificationActionInvoked(Notification notification) cons
|
||||
bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
|
||||
{
|
||||
Q_Q(SnoreCore);
|
||||
if( m_notificationBackends.contains(backend))
|
||||
if( m_plugins.contains(SnorePlugin::BACKEND, backend))
|
||||
{
|
||||
return q->setPrimaryNotificationBackend(backend);
|
||||
}
|
||||
|
@ -65,11 +65,7 @@ private:
|
||||
|
||||
QHash<QString,Application> m_applications;
|
||||
|
||||
|
||||
QStringList m_notificationBackends;
|
||||
QStringList m_Frontends;
|
||||
QStringList m_secondaryNotificationBackends;
|
||||
QStringList m_plugins;
|
||||
QMultiHash<SnorePlugin::PluginTypes, QString> m_plugins;
|
||||
|
||||
QPointer<SnoreBackend> m_notificationBackend;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user