Permalink
Browse files

十分简单的插件系统和通告插件

  • Loading branch information...
zhanlangsir committed Feb 5, 2013
1 parent 42ce234 commit d63b90a097622b8c598a0b2b3bda2ac3e7e31af2
Showing with 1,778 additions and 69 deletions.
  1. +4 −0 CMakeLists.txt
  2. +1 −0 config.h.in
  3. +18 −0 src/CMakeLists.txt
  4. +1 −1 src/chatwidget/qqchatdlg.cpp
  5. +4 −3 src/core/qqmsg.h
  6. +4 −0 src/core/talkable.h
  7. +14 −0 src/interfaces/inotifier.h
  8. +34 −0 src/interfaces/iplugin.h
  9. +3 −2 src/mainwindow.cpp
  10. +4 −0 src/mainwindow.h
  11. 0 src/msghandle/sess_handle.cpp
  12. +0 −10 src/msghandle/sess_handle.h
  13. +19 −0 src/notification_manager/notification_manager.cpp
  14. +53 −0 src/notification_manager/notification_manager.h
  15. +0 −3 src/notify/statuschanged_notifier.cpp
  16. +0 −39 src/notify/statuschanged_notifier.h
  17. +108 −0 src/pluginmanager/plugin_managedlg.cpp
  18. +40 −0 src/pluginmanager/plugin_managedlg.h
  19. +206 −0 src/pluginmanager/plugin_manager.cpp
  20. +63 −0 src/pluginmanager/plugin_manager.h
  21. +1 −0 src/plugins/CMakeLists.txt
  22. +33 −0 src/plugins/notifier/CMakeLists.txt
  23. +345 −0 src/plugins/notifier/animatedtextbrowser.cpp
  24. +54 −0 src/plugins/notifier/animatedtextbrowser.h
  25. 0 src/plugins/notifier/notifier.cpp
  26. 0 src/plugins/notifier/notifier.h
  27. +61 −0 src/plugins/notifier/notifier_plugin.cpp
  28. +30 −0 src/plugins/notifier/notifier_plugin.h
  29. +33 −0 src/plugins/notifier/notifytextbrowser.cpp
  30. +24 −0 src/plugins/notifier/notifytextbrowser.h
  31. +194 −0 src/plugins/notifier/notifywidget.cpp
  32. +63 −0 src/plugins/notifier/notifywidget.h
  33. +164 −0 src/plugins/notifier/notifywidget.ui
  34. +6 −0 src/qqglobal.h
  35. +8 −0 src/qtqq.cpp
  36. +2 −0 src/qtqq.h
  37. +14 −11 src/ui/mainwindow.ui
  38. +170 −0 src/ui/pluginmanagedlg.ui
  39. 0 src/{msghandle → utils}/htmltomsgparser.h
View
@@ -30,17 +30,21 @@ if ( CMAKE_BUILD_TYPE MATCHES "Debug" )
set(DEBUG_MODE 1)
set(prefix ${PROJECT_SOURCE_DIR})
set(pkgdatadir ${prefix}/data)
+ set(PLUGIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/lib/plugins)
else ()
set(prefix ${CMAKE_INSTALL_PREFIX})
set(pkgdatadir ${prefix}/share/${package})
+ set(PLUGIN_DIR ${libdir}/plugins)
endif ()
+
set(bindir ${prefix}/bin)
set(libdir ${prefix}/lib)
set(includedir ${prefix}/include)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib)
+set(PLUGIN_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH}/plugins)
configure_file(${PROJECT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h)
View
@@ -7,6 +7,7 @@
#define PACKAGE "@package@"
#define DATA_DIR "@prefix@/share"
#define PKG_DATA_DIR "@pkgdatadir@"
+#define PLUGIN_DIR "@PLUGIN_DIR@"
#define VERSION "@version@"
#endif /* __CONFIG_H__ */
View
@@ -49,6 +49,13 @@ set(CORE_HEADERS
#msgprocessor
msgprocessor/msg_processor.h
+ #notification manager
+ notification_manager/notification_manager.h
+
+ #plugin manager
+ pluginmanager/plugin_manager.h
+ pluginmanager/plugin_managedlg.h
+
#qq_protocol
protocol/qq_protocol.h
protocol/pollthread.h
@@ -93,6 +100,7 @@ set(CORE_HEADERS
#utils
utils/contact_status.h
utils/icon_decorator.h
+ utils/htmltomsgparser.h
#trayicon
trayicon/systemtray.h
@@ -147,6 +155,13 @@ set(CORE_SOURCES
#msgprocessor
msgprocessor/msg_processor.cpp
+ #notification manager
+ notification_manager/notification_manager.cpp
+
+ #plugin manager
+ pluginmanager/plugin_manager.cpp
+ pluginmanager/plugin_managedlg.cpp
+
#qq_protocol
protocol/qq_protocol.cpp
protocol/pollthread.cpp
@@ -239,6 +254,7 @@ set(UI_FILES
ui/qqfacepanel.ui
ui/sesschatdlg.ui
ui/tabwindow.ui
+ ui/pluginmanagedlg.ui
)
QT4_WRAP_UI(UI_FILES_HEADERS ${UI_FILES})
@@ -279,6 +295,8 @@ option(UPDATE_TRANSLATIONS "Update source translation files" OFF)
# QT4_ADD_TRANSLATION(QM_FILES ${TRANSLATIONS_FILES})
#endif (UPDATE_TRANSLATIONS)
+add_subdirectory(plugins EXCLUDE_FROM_ALL)
+
add_executable(qtqq
${CORE_SOURCES} ${CORE_HEADERS_MOC}
${UI_SOURCES} ${UI_HEADERS_MOC}
@@ -18,7 +18,7 @@
#include "core/qqitem.h"
#include "core/curr_login_account.h"
#include "protocol/qq_protocol.h"
-#include "msghandle/htmltomsgparser.h"
+#include "utils/htmltomsgparser.h"
#include "skinengine/qqskinengine.h"
#include "soundplayer/soundplayer.h"
#include "event_handle/event_handle.h"
View
@@ -96,6 +96,7 @@ class QQChatMsg : public QQMsg
{
msg_str.append(msg.content());
}
+ return msg_str;
}
QString msg_id_;
@@ -122,7 +123,7 @@ class QQSessChatMsg : public QQChatMsg
}
virtual QString talkTo() const
- { return from_uin_; }
+ { return gid_; }
virtual QString sendUin() const
{ return from_uin_; }
@@ -140,9 +141,9 @@ class QQGroupChatMsg : public QQChatMsg
{
}
- QString talkTo() const
+ virtual QString talkTo() const
{ return from_uin_; }
- QString sendUin() const
+ virtual QString sendUin() const
{ return send_uin_; }
QString gCode() const {return group_code_; }
View
@@ -69,6 +69,10 @@ class Talkable : public QObject
{
return name_;
}
+ virtual QString markname() const
+ {
+ return name_;
+ }
TalkableType type() const
{
View
@@ -0,0 +1,14 @@
+#ifndef INOTIFIER_H
+#define INOTIFIER_H
+
+#include <QtPlugin>
+
+class INotifier
+{
+public:
+ virtual void notify() = 0;
+}
+
+Q_DECLARE_INTERFACE(IPlugin, "Qtqq.INotifier/1.0")
+
+#endif //INOTIFIER_H
View
@@ -0,0 +1,34 @@
+#ifndef IPLUGIN_H
+#define IPLUGIN_H
+
+#include <QUuid>
+#include <QUrl>
+#include <QtPlugin>
+#include <QWidget>
+
+struct PluginInfo
+{
+ QString name;
+ QString version;
+ QString author;
+ QString email;
+ QUrl home_page;
+ QString description;
+};
+
+class IPlugin
+{
+public:
+ virtual QUuid uuid() const = 0;
+
+ virtual void pluginInfo(PluginInfo *plugin_info) = 0;
+
+ virtual QWidget *configWidget(QWidget *parent) = 0;
+
+ virtual void load() = 0;
+ virtual void unload() = 0;
+};
+
+Q_DECLARE_INTERFACE(IPlugin, "Qtqq.IPlugin/1.0")
+
+#endif //IPLUGIN_H
View
@@ -25,6 +25,7 @@
#include "core/types.h"
#include "event_handle/event_handle.h"
#include "msgprocessor/msg_processor.h"
+#include "pluginmanager/plugin_managedlg.h"
#include "protocol/event_center.h"
#include "protocol/qq_protocol.h"
#include "requestwidget/requestmsg_processor.h"
@@ -63,7 +64,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->cb_status, SIGNAL(currentIndexChanged(int)), this, SLOT(changeMyStatus(int)));
- connect(ui->pb_mainmenu, SIGNAL(clicked()), this, SLOT(openMainMenu()));
+ //connect(ui->mainmenu_btn, SIGNAL(clicked()), this, SLOT(openMainMenu()));
connect(Protocol::EventCenter::instance(), SIGNAL(eventTrigger(Protocol::Event *)), EventHandle::instance(), SLOT(onEventTrigger(Protocol::Event *)));
if (QFile::exists(QQGlobal::configDir() + "/qqgroupdb"))
@@ -76,10 +77,10 @@ MainWindow::MainWindow(QWidget *parent) :
act_mute_ = new QAction(tr("Mute"), main_menu_);
act_mute_->setCheckable(true);
act_mute_->setChecked(setting.value("mute").toBool());
-
connect(act_mute_, SIGNAL(toggled(bool)), this, SLOT(setMute(bool)));
main_menu_->addAction(act_mute_);
+ ui->mainmenu_btn->setMenu(main_menu_);
if (!open_chat_dlg_sc_)
{
View
@@ -23,6 +23,7 @@ class QQChatDlg;
class QQLoginCore;
class RecentModel;
class RosterModel;
+class PluginManageDlg;
class MainWindow : public QWidget
{
@@ -40,6 +41,9 @@ class MainWindow : public QWidget
void updateLoginUser() const;
void clean();
+ QMenu *mainMenu() const
+ { return main_menu_; }
+
protected:
virtual void closeEvent(QCloseEvent *);
No changes.
@@ -1,10 +0,0 @@
-#ifndef SESS_HANDLE_H
-#define SESS_HANDLE_H
-
-class SessHandle : public MsgHandle
-{
-public slots:
- void slotNewSessMsg();
-};
-
-#endif //SESS_HANDLE_H
@@ -0,0 +1,19 @@
+#include "notification_manager.h"
+
+#include "chatwidget/chatdlg_manager.h"
+#include "msgprocessor/msg_processor.h"
+
+NotificationManager *NotificationManager::instance_ = NULL;
+
+NotificationManager::NotificationManager()
+{
+ connect(MsgProcessor::instance(), SIGNAL(newChatMsg(ShareQQMsgPtr)), this, SLOT(onNewChatMsg(ShareQQMsgPtr)));
+}
+
+void NotificationManager::onNewChatMsg(ShareQQMsgPtr msg)
+{
+ if ( !ChatDlgManager::instance()->isOpening(msg->talkTo()) )
+ {
+ emit newChatMsg(msg);
+ }
+}
@@ -0,0 +1,53 @@
+#ifndef NOTIFICATION_MANAGER_H
+#define NOTIFICATION_MANAGER_H
+
+#include <QObject>
+//#include <QVariant>
+
+#include "core/qqmsg.h"
+
+/* enum NotificationType */
+/* { */
+/* NFT_Chat, */
+/* NFT_GroupChat, */
+/* NFT_SessChat, */
+/* NFT_StatusChanged */
+/* }; */
+
+/* struct Notification */
+/* { */
+/* NotificationType type; */
+/* QString title; */
+/* QString content; */
+/* */
+/* QPixmap icon; */
+/* QVariant data; */
+/* }; */
+
+class NotificationManager : public QObject
+{
+ Q_OBJECT
+signals:
+ void newChatMsg(ShareQQMsgPtr msg);
+
+public:
+ static NotificationManager *instance()
+ {
+ if ( !instance_ )
+ instance_ = new NotificationManager();
+
+ return instance_;
+ }
+
+private slots:
+ void onNewChatMsg(ShareQQMsgPtr msg);
+
+private:
+ NotificationManager();
+ NotificationManager(const NotificationManager &);
+ NotificationManager &operator=(const NotificationManager &);
+
+ static NotificationManager *instance_;
+};
+
+#endif //NOTIFICATION_MANAGER_H
@@ -1,3 +0,0 @@
-#include "statuschanged_notifier.h"
-
-StatusChangedNotifier *StatusChangedNotifier::instance_ = NULL;
@@ -1,39 +0,0 @@
-#ifndef STATUS_CHANGED_NOTIFIER_H
-#define STATUS_CHANGED_NOTIFIER_H
-
-#include <QObject>
-
-#include "utils/contact_status.h"
-
-class StatusChangedNotifier : public QObject
-{
- Q_OBJECT
-signals:
- void statusChanged(QString id, ContactStatus status, ContactClientType type)
-
-public:
- static StatusChangedNotifier *instance()
- {
- if ( !instance_ )
- instance_ = new StatusChangedNotifier();
-
- return instance_;
- }
-
-public slots:
- void slotNewStatusMsg(ShareQQMsgPtr msg)
- {
- }
-
-private:
- StatusChangedNotifier(QObject *parent = NULL) :
- QObject(parent)
- {
- }
- StatusChangedNotifier(const StatusChangedNotifier &);
- StatusChangedNotifier &operator=(const StatusChangedNotifier &);
-
- static StatusChangedNotifier *instance_;
-};
-
-#endif //STATUS_CHANGED_NOTIFIER_H
Oops, something went wrong.

0 comments on commit d63b90a

Please sign in to comment.