Add ChatDialog
diff --git a/src/chatdialog.h b/src/chatdialog.h
index ba6c6c8..77feea1 100644
--- a/src/chatdialog.h
+++ b/src/chatdialog.h
@@ -1,145 +1,51 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
+ *                     Yingdi Yu
  *
- * GNU v3.0 license, See the LICENSE file for more information
+ * BSD license, See the LICENSE file for more information
  *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ * Author: Yingdi Yu <yingdi@cs.ucla.edu>
  */
 
 #ifndef CHATDIALOG_H
 #define CHATDIALOG_H
 
-#ifndef Q_MOC_RUN
-#include <boost/function.hpp>
-#include <boost/thread/recursive_mutex.hpp>
+#include <QDialog>
 
-#include <vector>
-#include "digesttreescene.h"
-#include "ui_chatdialog.h"
-#include "chatbuf.pb.h"
-#include <ccnx/sync-app-socket.h>
-#include <sync-logic.h>
-#include <sync-seq-no.h>
+#ifndef Q_MOC_RUN
+#include <ndn.cxx/data.h>
 #endif
 
-#include <QSystemTrayIcon>
-#include <QMainWindow>
-#include <QQueue>
+namespace Ui {
+class ChatDialog;
+}
 
-#define ORGANIZATION "irl.cs.ucla.edu"
-#define APPLICATION "ChronoChat"
-#define MAX_HISTORY_ENTRY   20
-
-class QAction;
-class QMenu;
-class QStringListModel;
-class QTextTable;
-
-class ChatDialog : public QDialog, private Ui::ChatDialog
+class ChatDialog : public QDialog
 {
-	Q_OBJECT
+  Q_OBJECT
 
 public:
-  ChatDialog(QWidget *parent = 0);
+  explicit ChatDialog(const ndn::Name& chatroomPrefix,
+                      const ndn::Name& localPrefix,
+                      QWidget *parent = 0);
   ~ChatDialog();
-  void setVisible(bool visible);
-  void appendMessage(const SyncDemo::ChatMessage msg, bool isHistory = false);
-  void processTreeUpdateWrapper(const std::vector<Sync::MissingDataInfo>, Sync::SyncAppSocket *);
-  void processDataWrapper(std::string, const char *buf, size_t len);
-  void processDataNoShowWrapper(std::string, const char *buf, size_t len);
-  void processDataHistoryWrapper(std::string, const char *buf, size_t len);
-  void processRemoveWrapper(std::string);
-  void respondHistoryRequest(std::string interest);
 
-protected:
-  void closeEvent(QCloseEvent *e);
-  void changeEvent(QEvent *e);
+  const ndn::Name&
+  getChatroomPrefix() const
+  { return m_chatroomPrefix; }
 
-public slots:
-  void processTreeUpdate(const std::vector<Sync::MissingDataInfo>);
-  void processData(QString name, const char *buf, size_t len, bool show, bool isHistory);
-  void processRemove(QString);
+  const ndn::Name&
+  getLocalPrefix() const
+  { return m_localPrefix; }
+
+  void
+  sendInvitation();
 
 private:
-  void fetchHistory(std::string name);
-  QString getRandomString();
-  void formChatMessage(const QString &text, SyncDemo::ChatMessage &msg);
-  void formControlMessage(SyncDemo::ChatMessage &msg, SyncDemo::ChatMessage::ChatMessageType type);
-  void sendMsg(SyncDemo::ChatMessage &msg);
-  bool readSettings();
-  void writeSettings();
-  void updateLabels();
-  void resizeEvent(QResizeEvent *);
-  void showEvent(QShowEvent *);
-  void fitView();
-  void testDraw();
-  void createTrayIcon();
-  void createActions();
-  QString formatTime(time_t);
-  void printTimeInCell(QTextTable *, time_t);
-  void disableTreeDisplay();
-  bool getLocalPrefix();
-  void initializeSync();
-
-private slots:
-  void returnPressed();
-  void buttonPressed();
-  void treeButtonPressed();
-  void checkSetting();
-  void settingUpdated(QString, QString, QString);
-  void sendHello();
-  void sendJoin();
-  void sendLeave();
-  void replot();
-  void updateRosterList(QStringList);
-  void enableTreeDisplay();
-  void updateLocalPrefix();
-  void reap();
-  void summonReaper();
-
-  // icon related
-  void iconActivated(QSystemTrayIcon::ActivationReason reason);
-  void showMessage(QString, QString);
-  void messageClicked();
-
-signals:
-  void dataReceived(QString name, const char *buf, size_t len, bool show, bool isHistory);
-  void treeUpdated(const std::vector<Sync::MissingDataInfo>);
-  void removeReceived(QString prefix);
-
-private:
-  User m_user; 
-  Sync::SyncAppSocket *m_sock;
-  uint32_t m_session;
-  DigestTreeScene *m_scene;
-  boost::recursive_mutex m_msgMutex;
-  boost::recursive_mutex m_sceneMutex;
-  time_t m_lastMsgTime;
-  int m_randomizedInterval;
-  QTimer *m_timer;
-  QStringListModel *m_rosterModel;
-  bool m_minimaniho;
-
-  QQueue<SyncDemo::ChatMessage> m_history;
-  bool m_historyInitialized;
-  bool m_joined;
-
-  QList<QString> m_zombieList;
-  int m_zombieIndex;
-
-  // icon related
-  QAction *minimizeAction;
-  QAction *maximizeAction;
-  QAction *restoreAction;
-  QAction *settingsAction;
-  QAction *updateLocalPrefixAction;
-  QAction *quitAction;
-  QSystemTrayIcon *trayIcon;
-  // QMenu *menuBar;
-  QMenu *trayIconMenu;
+  Ui::ChatDialog *ui;
+  ndn::Name m_chatroomPrefix;
+  ndn::Name m_localPrefix;
 };
-#endif
+
+#endif // ChatDIALOG_H