better notification support; dock icon;
system tray icon;
notification is given when the new message is received
and the dialog is not active window;
notification requires growl in Mac OS X
icon also changes until the window is reactivated
diff --git a/chatdialog.h b/chatdialog.h
index e5e0c34..116e20e 100644
--- a/chatdialog.h
+++ b/chatdialog.h
@@ -9,22 +9,31 @@
 #include <sync-app-socket.h>
 #include <sync-logic.h>
 #include <sync-seq-no.h>
+#include <QSystemTrayIcon>
 
 #define ORGANIZATION "IRL@UCLA"
 #define APPLICATION "SYNC-DEMO"
 
+class QAction;
+class QMenu;
+
 class ChatDialog : public QDialog,  private Ui::ChatDialog 
 {
 	Q_OBJECT
 
 public:
-	ChatDialog(QWidget *parent = 0);
+  ChatDialog(QWidget *parent = 0);
   ~ChatDialog();
+  void setVisible(bool visible);
   void processRemove(const std::string);
   void appendMessage(const SyncDemo::ChatMessage msg);
   void processTreeUpdateWrapper(const std::vector<Sync::MissingDataInfo>, Sync::SyncAppSocket *);
   void processDataWrapper(std::string, const char *buf, size_t len);
 
+protected:
+  void closeEvent(QCloseEvent *e);
+  void changeEvent(QEvent *e);
+
 public slots:
   void processTreeUpdate(const std::vector<Sync::MissingDataInfo>);
   void processData(QString name, const char *buf, size_t len);
@@ -38,6 +47,8 @@
   void showEvent(QShowEvent *);
   void fitView();
   void testDraw();
+  void createTrayIcon();
+  void createActions();
 
 private slots:
   void returnPressed();
@@ -45,6 +56,11 @@
   void checkSetting();
   void settingUpdated(QString, QString, QString);
 
+  // icon related
+  void iconActivated(QSystemTrayIcon::ActivationReason reason);
+  void showMessage(QString, QString);
+  void messageClicked();
+
 signals:
   void dataReceived(QString name, const char *buf, size_t len);
   void treeUpdated(const std::vector<Sync::MissingDataInfo>);
@@ -56,5 +72,13 @@
   DigestTreeScene *m_scene;
   boost::mutex m_msgMutex;
   boost::mutex m_sceneMutex;
+
+  // icon related
+  QAction *minimizeAction;
+  QAction *maximizeAction;
+  QAction *restoreAction;
+  QAction *quitAction;
+  QSystemTrayIcon *trayIcon;
+  QMenu *trayIconMenu;
 };
 #endif