namespaces yai

This commit is contained in:
Patrick von Reth 2011-11-09 23:13:46 +01:00
parent 2d6066b5db
commit cf13a539fd
26 changed files with 110 additions and 49 deletions

View File

@ -26,6 +26,10 @@ endif(KDE4_FOUND)
find_package( CryptoPP )
find_package( Boost COMPONENTS system thread)
if(Boost_USE_STATIC_RUNTIME)
add_definitions(-DBOOST_THREAD_USE_LIB )
endif(Boost_USE_STATIC_RUNTIME)
set(PLUGIN_INSTALL_PATH LIBRARY DESTINATION bin/snoreplugins)
add_subdirectory(data)

View File

@ -15,6 +15,7 @@
****************************************************************************************/
#include "application.h"
namespace Snore{
Application::Application (const QString &name, const SnoreIcon &icon) :
@ -98,6 +99,7 @@ bool Alert::isActive() const
return _active;
}
}
#include "application.moc"

View File

@ -20,6 +20,8 @@
#include "notification/icon.h"
#include <QHash>
namespace Snore{
typedef QHash<QString,class Application*> ApplicationsList ;
typedef QHash<QString,class Alert*> AlertList;
@ -66,4 +68,6 @@ private:
};
}
#endif // APPLICATION_H

View File

@ -18,6 +18,7 @@
#include "snoreserver.h"
#include <QTimer>
namespace Snore{
SnorePlugin::SnorePlugin ( QString name,SnoreServer *snore ) :
_name ( name ),
@ -91,4 +92,5 @@ Notification_Frontend::~Notification_Frontend()
{
}
}
#include "interface.moc"

View File

@ -19,6 +19,7 @@
#include "snore_exports.h"
#include "notification/notification.h"
namespace Snore{
class SNORE_EXPORT SnorePlugin:public QObject
{
@ -46,13 +47,16 @@ private:
};
Q_DECLARE_INTERFACE ( SnorePlugin,
}
Q_DECLARE_INTERFACE ( Snore::SnorePlugin,
"org.Snore.SnorePlugin/1.0" )
namespace Snore{
class SNORE_EXPORT Notification_Backend:public SnorePlugin
{
Q_OBJECT
Q_INTERFACES(SnorePlugin)
Q_INTERFACES(Snore::SnorePlugin)
public:
Notification_Backend ( QString name,class SnoreServer *snore=0 );
virtual ~Notification_Backend();
@ -74,7 +78,7 @@ public slots:
class SNORE_EXPORT Notification_Frontend:public SnorePlugin
{
Q_OBJECT
Q_INTERFACES(SnorePlugin)
Q_INTERFACES(Snore::SnorePlugin)
public:
Notification_Frontend ( QString name,class SnoreServer *snore=0 );
virtual ~Notification_Frontend();
@ -87,10 +91,12 @@ public slots:
Q_DECLARE_INTERFACE ( Notification_Frontend,
}
Q_DECLARE_INTERFACE ( Snore::Notification_Frontend,
"org.Snore.NotificationFrontend/1.0" )
Q_DECLARE_INTERFACE ( Notification_Backend,
Q_DECLARE_INTERFACE ( Snore::Notification_Backend,
"org.Snore.NotificationBackend/1.0" )
#endif//INTERFACE_H

View File

@ -22,6 +22,7 @@
#include <QHash>
#include <QFile>
#include <QDebug>
namespace Snore{
class SnoreIcon::SnoreIconData
{
@ -130,4 +131,5 @@ bool SnoreIcon::isEmpty() const{
return d->_hash.isEmpty() && d->_img.isNull() && d->_localFileName.isEmpty();
}
}
#include "icon.moc"

View File

@ -21,6 +21,7 @@
#include <QImage>
#include <QSharedPointer>
namespace Snore{
class SNORE_EXPORT SnoreIcon
@ -51,7 +52,7 @@ private:
};
}
#endif // NOTIFICATION_ICON_H

View File

@ -23,19 +23,26 @@
#include <Qt>
#include <QTextDocumentFragment>
#include <QTextDocument>
namespace Snore{
static int metaid = qRegisterMetaType<Notification>();
static int count = 0;
class Notification::NotificationData
{
public:
NotificationData ( uint id=0 ):
_id ( id ),
_timeout ( 10 ),
_source ( NULL ),
_closeReason(NotificationEnums::CloseReasons::NONE),
_priority(NotificationEnums::Prioritys::NORMAL)
{}
{
qDebug()<<"ActiveNotifications"<<++count;
}
NotificationData ( const QString &application,const QString &alert,const QString &title,const QString &text,const SnoreIcon &icon,int timeout,uint id,NotificationEnums::Prioritys::prioritys priority ):
_id ( id ),
@ -48,11 +55,14 @@ public:
_icon ( icon ),
_priority(priority),
_closeReason(NotificationEnums::CloseReasons::NONE)
{}
{
qDebug()<<"ActiveNotifications"<<++count;
}
~NotificationData(){
//delete _actionInvoked;
qDebug()<<"ActiveNotifications"<<--count;
}
uint _id;
@ -235,5 +245,6 @@ QDataStream & operator<< ( QDataStream &stream, const Notification::Action &a)
stream<<a.id<<a.id;
return stream;
}
}

View File

@ -22,6 +22,7 @@
#include <QVariant>
#include <QSharedPointer>
namespace Snore{
namespace NotificationEnums{
@ -102,9 +103,10 @@ private:
QSharedPointer<NotificationData> d;
};
Q_DECLARE_METATYPE(Notification)
}
QDataStream & operator<< ( QDataStream & stream, const Notification & noti );
QDataStream & operator<< ( QDataStream & stream, const Notification::Action & action);
Q_DECLARE_METATYPE(Snore::Notification)
QDataStream & operator<< ( QDataStream & stream, const Snore::Notification & noti );
QDataStream & operator<< ( QDataStream & stream, const Snore::Notification::Action & action);
#endif // NOTIFICATION_H

View File

@ -25,6 +25,7 @@
#include <QDir>
#include <QSystemTrayIcon>
namespace Snore{
QString const SnoreServer::version(){
return "0.15";
@ -180,5 +181,6 @@ const QString &SnoreServer::primaryNotificationBackend(){
return _notificationBackend->name();
}
}
#include "snoreserver.moc"

View File

@ -23,6 +23,10 @@
#include <QStringList>
class QSystemTrayIcon;
namespace Snore{
class SNORE_EXPORT SnoreServer:public QObject
{
Q_OBJECT
@ -31,7 +35,7 @@ public:
static const QString snoreTMP();
public:
SnoreServer ( class QSystemTrayIcon *trayIcon=0 );
SnoreServer (QSystemTrayIcon *trayIcon=0 );
void publicatePlugin ( const QString &fileName );
void publicatePlugin ( SnorePlugin *plugin );
@ -72,5 +76,6 @@ signals:
};
}
#endif // SNORESERVER_H

View File

@ -5,6 +5,8 @@
#include <QTimer>
#include <QTime>
#include <QDebug>
using namespace Snore;
TrayIconNotifer::TrayIconNotifer ( SnoreServer *snore, QSystemTrayIcon *icon ) :
Notification_Backend ( "SystemTray",snore ),
@ -79,4 +81,5 @@ void TrayIconNotifer::actionInvoked(){
}
#include "trayiconnotifer.moc"

View File

@ -6,23 +6,23 @@
#include <QTime>
class TrayIconNotifer:public Notification_Backend
class TrayIconNotifer:public Snore::Notification_Backend
{
Q_OBJECT
Q_INTERFACES(Notification_Backend)
Q_INTERFACES(Snore::Notification_Backend)
public:
TrayIconNotifer ( class SnoreServer *snore=0,class QSystemTrayIcon *icon=0 );
TrayIconNotifer ( class Snore::SnoreServer *snore=0,class QSystemTrayIcon *icon=0 );
bool isPrimaryNotificationBackend();
public slots:
void registerApplication ( Application *application );
void unregisterApplication ( class Application *application );
uint notify ( Notification notification );
void closeNotification ( Notification notification );
void registerApplication ( Snore::Application *application );
void unregisterApplication ( Snore::Application *application );
uint notify ( Snore::Notification notification );
void closeNotification ( Snore::Notification notification );
private:
class QSystemTrayIcon *_trayIcon;
QList<Notification > _notificationQue;
QList<Snore::Notification > _notificationQue;
QTime _lastNotify;
uint _id;
uint _displayed;

View File

@ -27,6 +27,7 @@
#ifdef HAVE_KDE
#include <KIcon>
#endif
using namespace Snore;
Q_EXPORT_PLUGIN2(freedesktop_frontend,FreedesktopNotification_Frontend)

View File

@ -19,15 +19,15 @@
#include "core/interface.h"
#include <QtDBus>
class FreedesktopNotification_Frontend:public Notification_Frontend{
class FreedesktopNotification_Frontend:public Snore::Notification_Frontend{
Q_OBJECT
Q_INTERFACES(Notification_Frontend)
Q_INTERFACES(Snore::Notification_Frontend)
public:
FreedesktopNotification_Frontend(class SnoreServer *snore=0);
FreedesktopNotification_Frontend(class Snore::SnoreServer *snore=0);
~FreedesktopNotification_Frontend();
void actionInvoked(Notification notification);
void notificationClosed(Notification notification);
void actionInvoked(Snore::Notification notification);
void notificationClosed(Snore::Notification notification);
uint Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int timeout);
void CloseNotification( uint id );

View File

@ -20,7 +20,6 @@
#include <QtGlobal>
static int imageHintID = qDBusRegisterMetaType<FreedesktopImageHint>();

View File

@ -10,6 +10,12 @@ if( WITH_GROWL_BACKEND )
automoc4_add_library(growl_backend MODULE ${GROWL__SRC} )
target_link_libraries(growl_backend snorecore ${QT_QTCORE_LIBRARY} ${CRYPTOPP_LIBRARIES} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})
if(MINGW)
#fiexes a multiple defenition error with static boost
SET_TARGET_PROPERTIES(growl_backend PROPERTIES LINK_FLAGS -Wl,--allow-multiple-definition)
endif(MINGW)
if(WIN32)
target_link_libraries(growl_backend wsock32 ws2_32)
endif(WIN32)

View File

@ -22,7 +22,7 @@
#include <QtCore>
using namespace Snore;
Q_EXPORT_PLUGIN2(growl_backend,Growl_Backend)

View File

@ -20,15 +20,15 @@
#include <string>
class Growl_Backend:public Notification_Backend
class Growl_Backend:public Snore::Notification_Backend
{
Q_OBJECT
Q_INTERFACES(Notification_Backend)
Q_INTERFACES(Snore::Notification_Backend)
public:
Growl_Backend(class SnoreServer *snore=0);
Growl_Backend(class Snore::SnoreServer *snore=0);
~Growl_Backend();
bool isPrimaryNotificationBackend(){return true;}
static void gntpCallback(const int &id,const std::string &reason,const std::string &data);
static void gntpCallback(const int &id,const std::string &reason,const std::string &data);
private:
//a static instance for the static callback methode
static Growl_Backend *instance;
@ -36,10 +36,10 @@ private:
QHash<QString,class gntp*> _applications;
public slots:
void registerApplication(Application *application);
void unregisterApplication(class Application *application);
uint notify(Notification notification);
void closeNotification(Notification notification);
void registerApplication(Snore::Application *application);
void unregisterApplication(Snore::Application *application);
uint notify(Snore::Notification notification);
void closeNotification(Snore::Notification notification);
};

View File

@ -645,7 +645,7 @@ LPSTR SnarlInterface::WideToUTF8(LPCWSTR szWideStr)
if (szWideStr == NULL)
return NULL;
int nSize = WideCharToMultiByte(CP_UTF8, 0, szWideStr, -1, NULL, 0, NULL, NULL);
int nSize = WideCharToMultiByte(CP_UTF8, 0, szWideStr, -1, NULL,0, NULL, NULL);
LPSTR szUTF8 = new char[nSize];
WideCharToMultiByte(CP_UTF8, 0, szWideStr, -1, szUTF8, nSize, NULL, NULL);

View File

@ -30,6 +30,7 @@
#define SNORENOTIFIER_MESSAGE_ID WM_USER + 238
using namespace Snore;
using namespace Snarl::V42;
Q_EXPORT_PLUGIN2(snarl_backend,Snarl_Backend)

View File

@ -23,13 +23,13 @@
class SnarlWidget;
class Snarl_Backend:public Notification_Backend
class Snarl_Backend:public Snore::Notification_Backend
{
Q_OBJECT
Q_INTERFACES(Notification_Backend)
Q_INTERFACES(Snore::Notification_Backend)
friend class SnarlWidget;
public:
Snarl_Backend(class SnoreServer *snore=0);
Snarl_Backend(class Snore::SnoreServer *snore=0);
~Snarl_Backend();
bool isPrimaryNotificationBackend();
@ -40,10 +40,10 @@ private:
bool _away;
public slots:
void registerApplication(Application *application);
void unregisterApplication(class Application *application);
uint notify(Notification notification);
void closeNotification(Notification notification);
void registerApplication(Snore::Application *application);
void unregisterApplication(Snore::Application *application);
uint notify(Snore::Notification notification);
void closeNotification(Snore::Notification notification);
};

View File

@ -28,13 +28,13 @@
#include <iostream>
using namespace Snore;
SnoreNotify::SnoreNotify():
_settings("TheOneRing","SnoreNotify")
{
_trayIcon = new TrayIcon();
_snore = new SnoreServer(_trayIcon->trayIcon());
_snore = new Snore::SnoreServer(_trayIcon->trayIcon());
QDir pluginsDir ( qApp->applicationDirPath() +"/snoreplugins" );
foreach ( QString fileName, pluginsDir.entryList ( QDir::Files ) )

View File

@ -19,6 +19,10 @@
#include <QtCore>
namespace Snore{
class SnoreServer;
}
class SnoreNotify:public QObject
{
Q_OBJECT
@ -30,7 +34,7 @@ public:
private:
class TrayIcon *_trayIcon;
class SnoreServer *_snore;
Snore::SnoreServer *_snore;
class QSettings _settings;
private slots:

View File

@ -21,6 +21,8 @@
#include <QMenu>
#include <QAction>
using namespace Snore;
TrayIcon::TrayIcon()
{
_trayIcon = new QSystemTrayIcon(QIcon(":/root/snore.png"));

View File

@ -19,12 +19,16 @@
#include <QtCore>
namespace Snore{
class SnoreServer;
}
class TrayIcon:public QObject
{
Q_OBJECT
public:
TrayIcon();
void initConextMenu(class SnoreServer *snore);
void initConextMenu(Snore::SnoreServer *snore);
void hide();
class QSystemTrayIcon* trayIcon();
@ -32,7 +36,7 @@ private:
class QSystemTrayIcon *_trayIcon;
class QMenu *_trayMenu;
class QList<class QAction*> _backendActions;
class SnoreServer *_snore;
class Snore::SnoreServer *_snore;
public slots: