diff -Nru libmessaging-menu-qt-12.10.2+201405191933/CMakeLists.txt libmessaging-menu-qt-12.10.2+201405201933/CMakeLists.txt --- libmessaging-menu-qt-12.10.2+201405191933/CMakeLists.txt 2014-05-19 19:33:25.000000000 +0000 +++ libmessaging-menu-qt-12.10.2+201405201933/CMakeLists.txt 2014-05-20 19:33:11.000000000 +0000 @@ -58,8 +58,8 @@ ${CMAKE_SOURCE_DIR}/src ) -configure_file(libmessaging-menu-qt.pc.in ${CMAKE_BINARY_DIR}/libmessaging-menu-qt.pc @ONLY) -install(FILES ${CMAKE_BINARY_DIR}/libmessaging-menu-qt.pc +configure_file(libmessaging-menu-qt.pc.in ${CMAKE_BINARY_DIR}/lib${LIBMESSAGINGMENUQT}.pc @ONLY) +install(FILES ${CMAKE_BINARY_DIR}/lib${LIBMESSAGINGMENUQT}.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig) @@ -83,7 +83,7 @@ RUNTIME DESTINATION bin ) install(FILES ${HEADERS} - DESTINATION include/${LIBMESSAGINGMENUQT}/ + DESTINATION include/${LIBMESSAGINGMENUQT} COMPONENT ${LIBMESSAGINGMENUQT} ) #add_subdirectory(examples) diff -Nru libmessaging-menu-qt-12.10.2+201405191933/debian/bzr-builder.manifest libmessaging-menu-qt-12.10.2+201405201933/debian/bzr-builder.manifest --- libmessaging-menu-qt-12.10.2+201405191933/debian/bzr-builder.manifest 2014-05-19 19:33:25.000000000 +0000 +++ libmessaging-menu-qt-12.10.2+201405201933/debian/bzr-builder.manifest 2014-05-20 19:33:11.000000000 +0000 @@ -1,2 +1,2 @@ -# bzr-builder format 0.3 deb-version {debupstream}+201405191933-7 -lp:messaging-menu-qt revid:torkvema@gmail.com-20140519192003-zosfowmv1mbqyf1a +# bzr-builder format 0.3 deb-version {debupstream}+201405201933-10 +lp:messaging-menu-qt revid:torkvema@gmail.com-20140520140043-38enaj1xqacvmqfa diff -Nru libmessaging-menu-qt-12.10.2+201405191933/debian/changelog libmessaging-menu-qt-12.10.2+201405201933/debian/changelog --- libmessaging-menu-qt-12.10.2+201405191933/debian/changelog 2014-05-19 19:33:25.000000000 +0000 +++ libmessaging-menu-qt-12.10.2+201405201933/debian/changelog 2014-05-20 19:33:11.000000000 +0000 @@ -1,8 +1,8 @@ -libmessaging-menu-qt (12.10.2+201405191933-7~ubuntu12.10.1) quantal; urgency=low +libmessaging-menu-qt (12.10.2+201405201933-10~ubuntu12.10.1) quantal; urgency=low * Auto build. - -- Vsevolod Velichko Mon, 19 May 2014 19:33:25 +0000 + -- Vsevolod Velichko Tue, 20 May 2014 19:33:11 +0000 libmessaging-menu-qt (12.10.2-1) unstable; urgency=low diff -Nru libmessaging-menu-qt-12.10.2+201405191933/libmessaging-menu-qt.pc.in libmessaging-menu-qt-12.10.2+201405201933/libmessaging-menu-qt.pc.in --- libmessaging-menu-qt-12.10.2+201405191933/libmessaging-menu-qt.pc.in 2014-05-19 19:33:25.000000000 +0000 +++ libmessaging-menu-qt-12.10.2+201405201933/libmessaging-menu-qt.pc.in 2014-05-20 19:33:11.000000000 +0000 @@ -1,10 +1,10 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=@CMAKE_INSTALL_PREFIX@ libdir=@CMAKE_INSTALL_PREFIX@/lib -includedir=@CMAKE_INSTALL_PREFIX@/include/messaging-menu-qt +includedir=@CMAKE_INSTALL_PREFIX@/include/@LIBMESSAGINGMENUQT@ -Name: libmessaging-menu-qt +Name: lib@LIBMESSAGINGMENUQT@ Description: Qt binding library to operate with Ubuntu Messaging Menu Version: @libmessaging-menu-qt_VERSION@ -Libs: -L${libdir} -lmessaging-menu-qt +Libs: -L${libdir} -l@LIBMESSAGINGMENUQT@ Cflags: -I${includedir} diff -Nru libmessaging-menu-qt-12.10.2+201405191933/src/messaging-menu.cpp libmessaging-menu-qt-12.10.2+201405201933/src/messaging-menu.cpp --- libmessaging-menu-qt-12.10.2+201405191933/src/messaging-menu.cpp 2014-05-19 19:33:25.000000000 +0000 +++ libmessaging-menu-qt-12.10.2+201405201933/src/messaging-menu.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,420 +0,0 @@ -/**************************************************************************** - * messaging-menu.cpp - * Copyright © 2012, Vsevolod Velichko . - * Licence: GPLv3 or later - * - **************************************************************************** - * * - * This library 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 Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - ****************************************************************************/ - -#define QT_NO_KEYWORDS // Otherwise it'll break GTK -#include "messaging-menu.hpp" -#include -#include -#include - -class GIconPtr -{ - private: - GIcon *icon; - public: - GIconPtr() - : icon(NULL) - { - } - GIconPtr(const QIcon &_icon = QIcon()) - : icon(NULL) - { - if (!_icon.isNull() && !_icon.name().isEmpty() ) { - QByteArray d = _icon.name().toUtf8(); - icon = g_icon_new_for_string (d.data(), NULL); - } - } - GIcon* operator*() - { - return icon; - } - ~GIconPtr() - { - if(icon) - g_object_unref (icon); - } -}; - -using namespace MessagingMenu; -namespace MessagingMenu -{ - typedef enum - { - SourceTime, - SourceCount, - SourceString - } SourceType; - - class Application::SourcePrivate - { - public: - const QString id; - const QByteArray idNative; - QString label; - QIcon icon; - QPair count; - QPair time; - QPair str; - bool attention; - Application *application; - SourceType type; - bool persistent; - qint32 position; - public: - SourcePrivate() = delete; - SourcePrivate (const QString &_id, const QString &_label, const QIcon &_icon, Application *_application) - : id (_id) - , idNative (id.toUtf8() ) - , label (_label) - , icon (_icon) - , count (false, 0U) - , time (false, 0L) - , str (false, QString() ) - , attention (false) - , application (_application) - , type(SourceTime) - , persistent(false) - , position(0) - {} - - MessagingMenuApp *getApp() const; - - void sendCount() { - if (count.first) { - messaging_menu_app_set_source_count (getApp(), idNative.data(), count.second); - } - } - - void sendTime() { - if (time.first) { - messaging_menu_app_set_source_time (getApp(), idNative.data(), time.second); - } - } - - void sendString() { - if (!str.first) { - return; - } - QByteArray d = str.second.toUtf8(); - messaging_menu_app_set_source_string (getApp(), idNative.data(), d.data() ); - } - - void sendLabel() { - QByteArray d = label.toUtf8(); - messaging_menu_app_set_source_label (getApp(), idNative.data(), d.data() ); - } - - void sendIcon() { - GIconPtr i(icon); - messaging_menu_app_set_source_icon (getApp(), idNative.data(), *i); - } - - void sendAttention() { - if (attention) { - messaging_menu_app_draw_attention (getApp(), idNative.data() ); - } else { - messaging_menu_app_remove_attention (getApp(), idNative.data() ); - } - } - }; - - class ApplicationPrivate - { - public: - MessagingMenuApp *app; - QHash > sources; - ApplicationPrivate() - : app(NULL) - , sources() - { - } - static void emitStatusChanged(MessagingMenuApp *, MessagingMenuStatus st, gpointer user_data) - { - Status status = static_cast(static_cast(st)); - Application *a = reinterpret_cast(user_data); - Q_EMIT a->statusChanged(status); - } - - static void emitSourceActivated(MessagingMenuApp *, const gchar *id, gpointer user_data) - { - Application *a = reinterpret_cast(user_data); - QString qId = QString::fromUtf8(id); - auto it = a->d_ptr->sources.find(qId); - if (it == a->d_ptr->sources.end()) - return; - QSharedPointer sourcePtr = *it; - Application::Source& source = *sourcePtr; - qint32 position = source.getPosition(); - if (source.isPersistent()) - { - a->d_ptr->sendCreatedSource(source, position); - } - else - { - a->d_ptr->sources.remove (source.getIdNative().data() ); - a->d_ptr->shiftPositions(position, -1); - } - Q_EMIT a->sourceActivated(source); - } - - void shiftPositions(qint32 position, qint32 shift = 1) - { - if (position >= 0) - for (auto it = sources.begin(); it != sources.end(); ++it) - if ((*it)->getPosition() >= position) - (*it)->setPosition((*it)->getPosition() + shift); - } - - Application::Source &createSource (Application *parent, const QString &id, const QString &label, const QIcon &icon, bool persistent, qint32 position) - { - shiftPositions(position); - Application::Source &source = *sources.insert (id, QSharedPointer (new Application::Source (parent, id, label, icon) ) ).value(); - source.setPersistent(persistent); - if (position >= 0) { - source.setPosition(position); - } else { - source.setPosition(sources.size() - 1); - } - return source; - } - - inline void sendCreatedSource(Application::Source &source, qint32 position) - { - GIconPtr i(source.getIcon()); - QByteArray d = source.getLabel().toUtf8(); - if(position >= 0) - { - switch(source.d_ptr->type) { - case SourceTime: - messaging_menu_app_insert_source_with_time (app, position, source.getIdNative().data(), *i, d.data(), source.d_ptr->time.second ); - break; - case SourceCount: - messaging_menu_app_insert_source_with_count (app, position, source.getIdNative().data(), *i, d.data(), source.d_ptr->count.second ); - break; - case SourceString: - QByteArray str = source.d_ptr->str.second.toUtf8(); - messaging_menu_app_insert_source_with_string (app, position, source.getIdNative().data(), *i, d.data(), str.data() ); - break; - } - } else { - switch(source.d_ptr->type) { - case SourceTime: - messaging_menu_app_append_source_with_time (app, source.getIdNative().data(), *i, d.data(), source.d_ptr->time.second ); - break; - case SourceCount: - messaging_menu_app_append_source_with_count (app, source.getIdNative().data(), *i, d.data(), source.d_ptr->count.second ); - break; - case SourceString: - QByteArray str = source.d_ptr->str.second.toUtf8(); - messaging_menu_app_append_source_with_string (app, source.getIdNative().data(), *i, d.data(), str.data() ); - break; - } - } - source.sendAll(); - } - - }; - - MessagingMenuApp *Application::SourcePrivate::getApp() const - { - return application->d_ptr->app; - } -} - -Application::Source::Source (Application *application, const QString &id, const QString &label, const QIcon &icon) - : d_ptr (new SourcePrivate (id, label, icon, application) ) -{ -} - -bool Application::Source::hasCount () const -{ - return d_ptr->count.first; -} -bool Application::Source::hasTime() const -{ - return d_ptr->time.first; -} -bool Application::Source::hasStr() const -{ - return d_ptr->str.first; -} -quint32 Application::Source::getCount() const -{ - return d_ptr->count.second; -} -QDateTime Application::Source::getTime() const -{ - return QDateTime::fromMSecsSinceEpoch(d_ptr->time.second / 1000); -} -const QString &Application::Source::getString() const -{ - return d_ptr->str.second; -} -const QString &Application::Source::getLabel() const -{ - return d_ptr->label; -} -const QIcon &Application::Source::getIcon() const -{ - return d_ptr->icon; -} -const QByteArray &Application::Source::getIdNative() const -{ - return d_ptr->idNative; -} - -void Application::Source::setCount (quint32 count) -{ - d_ptr->count.first = true; - d_ptr->time.first = false; - d_ptr->str.first = false; - d_ptr->count.second = count; - d_ptr->sendCount(); -} - -void Application::Source::setTime (const QDateTime &time) -{ - d_ptr->time.first = true; - d_ptr->str.first = false; - d_ptr->count.first = false; - d_ptr->time.second = time.toMSecsSinceEpoch() * 1000; - d_ptr->sendTime(); -} - -void Application::Source::setString (const QString &str) -{ - d_ptr->str.first = true; - d_ptr->time.first = false; - d_ptr->count.first = false; - d_ptr->str.second = str; - d_ptr->sendString(); -} - -void Application::Source::setLabel (const QString &label) -{ - d_ptr->label = label; - d_ptr->sendLabel(); -} - -void Application::Source::setIcon (const QIcon &icon) -{ - d_ptr->icon = icon; - d_ptr->sendIcon(); -} - -void Application::Source::sendAll () -{ - d_ptr->sendCount(); - d_ptr->sendTime(); - d_ptr->sendString(); - d_ptr->sendAttention(); -} - -void Application::Source::setAttention(bool draw) -{ - d_ptr->attention = draw; - d_ptr->sendAttention(); -} - -void Application::Source::setPosition(qint32 position) -{ - d_ptr->position = position; -} - -qint32 Application::Source::getPosition() const -{ - return d_ptr->position; -} - -bool Application::Source::isPersistent() const -{ - return d_ptr->persistent; -} - -void Application::Source::setPersistent(bool persistent) -{ - d_ptr->persistent = persistent; -} - -Application::Application (const QString &desktopId, QObject *parent) - : QObject (parent) - , d_ptr (new ApplicationPrivate) -{ - g_type_init(); - QByteArray d = desktopId.toUtf8(); - d_ptr->app = messaging_menu_app_new (d.data() ); - g_signal_connect(d_ptr->app, "activate-source", G_CALLBACK(ApplicationPrivate::emitSourceActivated), this); - g_signal_connect(d_ptr->app, "status-changed", G_CALLBACK(ApplicationPrivate::emitStatusChanged), this); -} - -Application::~Application() -{ - delete d_ptr; -} - -void Application::registerApp() -{ - messaging_menu_app_register (d_ptr->app); -} - -void Application::unregisterApp() -{ - messaging_menu_app_unregister (d_ptr->app); -} - -void Application::setStatus (Status status) -{ - messaging_menu_app_set_status (d_ptr->app, static_cast (static_cast (status) ) ); -} - -Application::Source &Application::createSourceTime (const QString &id, const QString &label, const QIcon &icon, const QDateTime &time, bool persistent, qint32 position) -{ - Source &source = d_ptr->createSource(this, id, label, icon, persistent, position); - source.d_ptr->time.first = true; - source.d_ptr->time.second = time.toMSecsSinceEpoch() * 1000; - source.d_ptr->type = SourceTime; - d_ptr->sendCreatedSource(source, position); - return source; -} -Application::Source &Application::createSourceCount (const QString &id, const QString &label, const QIcon &icon, quint32 count, bool persistent, qint32 position) -{ - Source &source = d_ptr->createSource(this, id, label, icon, persistent, position); - source.d_ptr->count.first = true; - source.d_ptr->count.second = count; - source.d_ptr->type = SourceCount; - d_ptr->sendCreatedSource(source, position); - return source; -} -Application::Source &Application::createSourceString (const QString &id, const QString &label, const QIcon &icon, const QString &str, bool persistent, qint32 position) -{ - Source &source = d_ptr->createSource(this, id, label, icon, persistent, position); - source.d_ptr->str.first = true; - source.d_ptr->str.second = str; - source.d_ptr->type = SourceString; - d_ptr->sendCreatedSource(source, position); - return source; -} - -void Application::removeSource (Source &source) -{ - messaging_menu_app_remove_source (d_ptr->app, source.getIdNative().data() ); - qint32 position = source.getPosition(); - d_ptr->sources.remove (source.getIdNative().data() ); - d_ptr->shiftPositions(position, -1); -} - -bool Application::hasSource (const Source &source) -{ - return messaging_menu_app_has_source (d_ptr->app, source.getIdNative().data() ); -} diff -Nru libmessaging-menu-qt-12.10.2+201405191933/src/messaging-menu.hpp libmessaging-menu-qt-12.10.2+201405201933/src/messaging-menu.hpp --- libmessaging-menu-qt-12.10.2+201405191933/src/messaging-menu.hpp 2014-05-19 19:33:25.000000000 +0000 +++ libmessaging-menu-qt-12.10.2+201405201933/src/messaging-menu.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -/**************************************************************************** - * messaging-menu.hpp - * Copyright © 2012, Vsevolod Velichko . - * Licence: GPLv3 or later - * - **************************************************************************** - * * - * This library 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 Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - ****************************************************************************/ - -#ifndef MESSAGING_MENU_30GOW558 -#define MESSAGING_MENU_30GOW558 - -#include -#include -#include -#include -#include -#include -namespace MessagingMenu -{ - typedef enum - { - Available, - Away, - Busy, - Invisible, - Offline - } Status; - - class ApplicationPrivate; - class Application : public QObject - { - Q_OBJECT - Q_DECLARE_PRIVATE(MessagingMenu::Application) - private: - ApplicationPrivate* d_ptr; - public: - class SourcePrivate; - class Source - { - Q_DECLARE_PRIVATE(MessagingMenu::Application::Source) - friend class Application; - friend class ApplicationPrivate; - private: - Source() = delete; - Source(const Source&) = delete; - Source& operator=(const Source&) = delete; - Source(Application *application, const QString &id, const QString &label, const QIcon &icon = QIcon()); - public: - bool hasCount() const; - bool hasTime() const; - bool hasStr() const; - - quint32 getCount() const; - QDateTime getTime() const; - const QString& getString() const; - const QString& getLabel() const; - const QIcon& getIcon() const; - - void setCount(quint32 count); - void setTime(const QDateTime &time); - void setString(const QString &str); - void setLabel(const QString &label); - void setIcon(const QIcon &icon); - void setAttention(bool draw = true); - bool isPersistent() const; - void setPersistent(bool persistent = true); - private: - void sendAll(); - void setPosition(qint32 position); - qint32 getPosition () const; - const QByteArray& getIdNative() const; - private: - SourcePrivate *d_ptr; - }; - - Application(const QString &desktopId, QObject *parent = NULL); - virtual ~Application(); - - Source& createSourceTime(const QString &id, const QString &label, const QIcon &icon = QIcon(), const QDateTime &time = QDateTime::currentDateTime(), bool persistent = false, qint32 position = -1); - Source& createSourceCount(const QString &id, const QString &label, const QIcon &icon = QIcon(), quint32 count = 0, bool persistent = false, qint32 position = -1); - Source& createSourceString(const QString &id, const QString &label, const QIcon &icon = QIcon(), const QString& str = QString(), bool persistent = false, qint32 position = -1); - void registerApp(); - void unregisterApp(); - void setStatus(Status status); - void removeSource(Source& source); - bool hasSource(const Source& source); - Q_SIGNALS: - void sourceActivated(MessagingMenu::Application::Source&); - void statusChanged(MessagingMenu::Status); - }; -} - -#endif /* end of include guard: MESSAGING_MENU_30GOW558 */ - diff -Nru libmessaging-menu-qt-12.10.2+201405191933/src/messaging-menu-qt.cpp libmessaging-menu-qt-12.10.2+201405201933/src/messaging-menu-qt.cpp --- libmessaging-menu-qt-12.10.2+201405191933/src/messaging-menu-qt.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libmessaging-menu-qt-12.10.2+201405201933/src/messaging-menu-qt.cpp 2014-05-20 19:33:11.000000000 +0000 @@ -0,0 +1,420 @@ +/**************************************************************************** + * messaging-menu.cpp + * Copyright © 2012, Vsevolod Velichko . + * Licence: GPLv3 or later + * + **************************************************************************** + * * + * This library 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 Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + ****************************************************************************/ + +#define QT_NO_KEYWORDS // Otherwise it'll break GTK +#include "messaging-menu-qt.hpp" +#include +#include +#include + +class GIconPtr +{ + private: + GIcon *icon; + public: + GIconPtr() + : icon(NULL) + { + } + GIconPtr(const QIcon &_icon = QIcon()) + : icon(NULL) + { + if (!_icon.isNull() && !_icon.name().isEmpty() ) { + QByteArray d = _icon.name().toUtf8(); + icon = g_icon_new_for_string (d.data(), NULL); + } + } + GIcon* operator*() + { + return icon; + } + ~GIconPtr() + { + if(icon) + g_object_unref (icon); + } +}; + +using namespace MessagingMenu; +namespace MessagingMenu +{ + typedef enum + { + SourceTime, + SourceCount, + SourceString + } SourceType; + + class Application::SourcePrivate + { + public: + const QString id; + const QByteArray idNative; + QString label; + QIcon icon; + QPair count; + QPair time; + QPair str; + bool attention; + Application *application; + SourceType type; + bool persistent; + qint32 position; + public: + SourcePrivate() = delete; + SourcePrivate (const QString &_id, const QString &_label, const QIcon &_icon, Application *_application) + : id (_id) + , idNative (id.toUtf8() ) + , label (_label) + , icon (_icon) + , count (false, 0U) + , time (false, 0L) + , str (false, QString() ) + , attention (false) + , application (_application) + , type(SourceTime) + , persistent(false) + , position(0) + {} + + MessagingMenuApp *getApp() const; + + void sendCount() { + if (count.first) { + messaging_menu_app_set_source_count (getApp(), idNative.data(), count.second); + } + } + + void sendTime() { + if (time.first) { + messaging_menu_app_set_source_time (getApp(), idNative.data(), time.second); + } + } + + void sendString() { + if (!str.first) { + return; + } + QByteArray d = str.second.toUtf8(); + messaging_menu_app_set_source_string (getApp(), idNative.data(), d.data() ); + } + + void sendLabel() { + QByteArray d = label.toUtf8(); + messaging_menu_app_set_source_label (getApp(), idNative.data(), d.data() ); + } + + void sendIcon() { + GIconPtr i(icon); + messaging_menu_app_set_source_icon (getApp(), idNative.data(), *i); + } + + void sendAttention() { + if (attention) { + messaging_menu_app_draw_attention (getApp(), idNative.data() ); + } else { + messaging_menu_app_remove_attention (getApp(), idNative.data() ); + } + } + }; + + class ApplicationPrivate + { + public: + MessagingMenuApp *app; + QHash > sources; + ApplicationPrivate() + : app(NULL) + , sources() + { + } + static void emitStatusChanged(MessagingMenuApp *, MessagingMenuStatus st, gpointer user_data) + { + Status status = static_cast(static_cast(st)); + Application *a = reinterpret_cast(user_data); + Q_EMIT a->statusChanged(status); + } + + static void emitSourceActivated(MessagingMenuApp *, const gchar *id, gpointer user_data) + { + Application *a = reinterpret_cast(user_data); + QString qId = QString::fromUtf8(id); + auto it = a->d_ptr->sources.find(qId); + if (it == a->d_ptr->sources.end()) + return; + QSharedPointer sourcePtr = *it; + Application::Source& source = *sourcePtr; + qint32 position = source.getPosition(); + if (source.isPersistent()) + { + a->d_ptr->sendCreatedSource(source, position); + } + else + { + a->d_ptr->sources.remove (source.getIdNative().data() ); + a->d_ptr->shiftPositions(position, -1); + } + Q_EMIT a->sourceActivated(source); + } + + void shiftPositions(qint32 position, qint32 shift = 1) + { + if (position >= 0) + for (auto it = sources.begin(); it != sources.end(); ++it) + if ((*it)->getPosition() >= position) + (*it)->setPosition((*it)->getPosition() + shift); + } + + Application::Source &createSource (Application *parent, const QString &id, const QString &label, const QIcon &icon, bool persistent, qint32 position) + { + shiftPositions(position); + Application::Source &source = *sources.insert (id, QSharedPointer (new Application::Source (parent, id, label, icon) ) ).value(); + source.setPersistent(persistent); + if (position >= 0) { + source.setPosition(position); + } else { + source.setPosition(sources.size() - 1); + } + return source; + } + + inline void sendCreatedSource(Application::Source &source, qint32 position) + { + GIconPtr i(source.getIcon()); + QByteArray d = source.getLabel().toUtf8(); + if(position >= 0) + { + switch(source.d_ptr->type) { + case SourceTime: + messaging_menu_app_insert_source_with_time (app, position, source.getIdNative().data(), *i, d.data(), source.d_ptr->time.second ); + break; + case SourceCount: + messaging_menu_app_insert_source_with_count (app, position, source.getIdNative().data(), *i, d.data(), source.d_ptr->count.second ); + break; + case SourceString: + QByteArray str = source.d_ptr->str.second.toUtf8(); + messaging_menu_app_insert_source_with_string (app, position, source.getIdNative().data(), *i, d.data(), str.data() ); + break; + } + } else { + switch(source.d_ptr->type) { + case SourceTime: + messaging_menu_app_append_source_with_time (app, source.getIdNative().data(), *i, d.data(), source.d_ptr->time.second ); + break; + case SourceCount: + messaging_menu_app_append_source_with_count (app, source.getIdNative().data(), *i, d.data(), source.d_ptr->count.second ); + break; + case SourceString: + QByteArray str = source.d_ptr->str.second.toUtf8(); + messaging_menu_app_append_source_with_string (app, source.getIdNative().data(), *i, d.data(), str.data() ); + break; + } + } + source.sendAll(); + } + + }; + + MessagingMenuApp *Application::SourcePrivate::getApp() const + { + return application->d_ptr->app; + } +} + +Application::Source::Source (Application *application, const QString &id, const QString &label, const QIcon &icon) + : d_ptr (new SourcePrivate (id, label, icon, application) ) +{ +} + +bool Application::Source::hasCount () const +{ + return d_ptr->count.first; +} +bool Application::Source::hasTime() const +{ + return d_ptr->time.first; +} +bool Application::Source::hasStr() const +{ + return d_ptr->str.first; +} +quint32 Application::Source::getCount() const +{ + return d_ptr->count.second; +} +QDateTime Application::Source::getTime() const +{ + return QDateTime::fromMSecsSinceEpoch(d_ptr->time.second / 1000); +} +const QString &Application::Source::getString() const +{ + return d_ptr->str.second; +} +const QString &Application::Source::getLabel() const +{ + return d_ptr->label; +} +const QIcon &Application::Source::getIcon() const +{ + return d_ptr->icon; +} +const QByteArray &Application::Source::getIdNative() const +{ + return d_ptr->idNative; +} + +void Application::Source::setCount (quint32 count) +{ + d_ptr->count.first = true; + d_ptr->time.first = false; + d_ptr->str.first = false; + d_ptr->count.second = count; + d_ptr->sendCount(); +} + +void Application::Source::setTime (const QDateTime &time) +{ + d_ptr->time.first = true; + d_ptr->str.first = false; + d_ptr->count.first = false; + d_ptr->time.second = time.toMSecsSinceEpoch() * 1000; + d_ptr->sendTime(); +} + +void Application::Source::setString (const QString &str) +{ + d_ptr->str.first = true; + d_ptr->time.first = false; + d_ptr->count.first = false; + d_ptr->str.second = str; + d_ptr->sendString(); +} + +void Application::Source::setLabel (const QString &label) +{ + d_ptr->label = label; + d_ptr->sendLabel(); +} + +void Application::Source::setIcon (const QIcon &icon) +{ + d_ptr->icon = icon; + d_ptr->sendIcon(); +} + +void Application::Source::sendAll () +{ + d_ptr->sendCount(); + d_ptr->sendTime(); + d_ptr->sendString(); + d_ptr->sendAttention(); +} + +void Application::Source::setAttention(bool draw) +{ + d_ptr->attention = draw; + d_ptr->sendAttention(); +} + +void Application::Source::setPosition(qint32 position) +{ + d_ptr->position = position; +} + +qint32 Application::Source::getPosition() const +{ + return d_ptr->position; +} + +bool Application::Source::isPersistent() const +{ + return d_ptr->persistent; +} + +void Application::Source::setPersistent(bool persistent) +{ + d_ptr->persistent = persistent; +} + +Application::Application (const QString &desktopId, QObject *parent) + : QObject (parent) + , d_ptr (new ApplicationPrivate) +{ + g_type_init(); + QByteArray d = desktopId.toUtf8(); + d_ptr->app = messaging_menu_app_new (d.data() ); + g_signal_connect(d_ptr->app, "activate-source", G_CALLBACK(ApplicationPrivate::emitSourceActivated), this); + g_signal_connect(d_ptr->app, "status-changed", G_CALLBACK(ApplicationPrivate::emitStatusChanged), this); +} + +Application::~Application() +{ + delete d_ptr; +} + +void Application::registerApp() +{ + messaging_menu_app_register (d_ptr->app); +} + +void Application::unregisterApp() +{ + messaging_menu_app_unregister (d_ptr->app); +} + +void Application::setStatus (Status status) +{ + messaging_menu_app_set_status (d_ptr->app, static_cast (static_cast (status) ) ); +} + +Application::Source &Application::createSourceTime (const QString &id, const QString &label, const QIcon &icon, const QDateTime &time, bool persistent, qint32 position) +{ + Source &source = d_ptr->createSource(this, id, label, icon, persistent, position); + source.d_ptr->time.first = true; + source.d_ptr->time.second = time.toMSecsSinceEpoch() * 1000; + source.d_ptr->type = SourceTime; + d_ptr->sendCreatedSource(source, position); + return source; +} +Application::Source &Application::createSourceCount (const QString &id, const QString &label, const QIcon &icon, quint32 count, bool persistent, qint32 position) +{ + Source &source = d_ptr->createSource(this, id, label, icon, persistent, position); + source.d_ptr->count.first = true; + source.d_ptr->count.second = count; + source.d_ptr->type = SourceCount; + d_ptr->sendCreatedSource(source, position); + return source; +} +Application::Source &Application::createSourceString (const QString &id, const QString &label, const QIcon &icon, const QString &str, bool persistent, qint32 position) +{ + Source &source = d_ptr->createSource(this, id, label, icon, persistent, position); + source.d_ptr->str.first = true; + source.d_ptr->str.second = str; + source.d_ptr->type = SourceString; + d_ptr->sendCreatedSource(source, position); + return source; +} + +void Application::removeSource (Source &source) +{ + messaging_menu_app_remove_source (d_ptr->app, source.getIdNative().data() ); + qint32 position = source.getPosition(); + d_ptr->sources.remove (source.getIdNative().data() ); + d_ptr->shiftPositions(position, -1); +} + +bool Application::hasSource (const Source &source) +{ + return messaging_menu_app_has_source (d_ptr->app, source.getIdNative().data() ); +} diff -Nru libmessaging-menu-qt-12.10.2+201405191933/src/messaging-menu-qt.hpp libmessaging-menu-qt-12.10.2+201405201933/src/messaging-menu-qt.hpp --- libmessaging-menu-qt-12.10.2+201405191933/src/messaging-menu-qt.hpp 1970-01-01 00:00:00.000000000 +0000 +++ libmessaging-menu-qt-12.10.2+201405201933/src/messaging-menu-qt.hpp 2014-05-20 19:33:11.000000000 +0000 @@ -0,0 +1,100 @@ +/**************************************************************************** + * messaging-menu.hpp + * Copyright © 2012, Vsevolod Velichko . + * Licence: GPLv3 or later + * + **************************************************************************** + * * + * This library 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 Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + ****************************************************************************/ + +#ifndef MESSAGING_MENU_30GOW558 +#define MESSAGING_MENU_30GOW558 + +#include +#include +#include +#include +#include +#include +namespace MessagingMenu +{ + typedef enum + { + Available, + Away, + Busy, + Invisible, + Offline + } Status; + + class ApplicationPrivate; + class Application : public QObject + { + Q_OBJECT + Q_DECLARE_PRIVATE(MessagingMenu::Application) + private: + ApplicationPrivate* d_ptr; + public: + class SourcePrivate; + class Source + { + Q_DECLARE_PRIVATE(MessagingMenu::Application::Source) + friend class Application; + friend class ApplicationPrivate; + private: + Source() = delete; + Source(const Source&) = delete; + Source& operator=(const Source&) = delete; + Source(Application *application, const QString &id, const QString &label, const QIcon &icon = QIcon()); + public: + bool hasCount() const; + bool hasTime() const; + bool hasStr() const; + + quint32 getCount() const; + QDateTime getTime() const; + const QString& getString() const; + const QString& getLabel() const; + const QIcon& getIcon() const; + + void setCount(quint32 count); + void setTime(const QDateTime &time); + void setString(const QString &str); + void setLabel(const QString &label); + void setIcon(const QIcon &icon); + void setAttention(bool draw = true); + bool isPersistent() const; + void setPersistent(bool persistent = true); + private: + void sendAll(); + void setPosition(qint32 position); + qint32 getPosition () const; + const QByteArray& getIdNative() const; + private: + SourcePrivate *d_ptr; + }; + + Application(const QString &desktopId, QObject *parent = NULL); + virtual ~Application(); + + Source& createSourceTime(const QString &id, const QString &label, const QIcon &icon = QIcon(), const QDateTime &time = QDateTime::currentDateTime(), bool persistent = false, qint32 position = -1); + Source& createSourceCount(const QString &id, const QString &label, const QIcon &icon = QIcon(), quint32 count = 0, bool persistent = false, qint32 position = -1); + Source& createSourceString(const QString &id, const QString &label, const QIcon &icon = QIcon(), const QString& str = QString(), bool persistent = false, qint32 position = -1); + void registerApp(); + void unregisterApp(); + void setStatus(Status status); + void removeSource(Source& source); + bool hasSource(const Source& source); + Q_SIGNALS: + void sourceActivated(MessagingMenu::Application::Source&); + void statusChanged(MessagingMenu::Status); + }; +} + +#endif /* end of include guard: MESSAGING_MENU_30GOW558 */ +