blob: e5e0c34a1fe47186f785ab5b3ce6f368aba0f674 [file] [log] [blame]
Zhenkai Zhufd52ab72012-05-29 17:34:35 -07001#ifndef CHATDIALOG_H
2#define CHATDIALOG_H
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -07003#include <boost/function.hpp>
Zhenkai Zhuf26e0462012-06-05 21:18:37 -07004#include <boost/thread/mutex.hpp>
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -07005#include <vector>
6#include "digesttreescene.h"
Zhenkai Zhufd52ab72012-05-29 17:34:35 -07007#include "ui_chatdialog.h"
Zhenkai Zhuc71da772012-05-30 21:25:23 -07008#include "chatbuf.pb.h"
Zhenkai Zhuea026982012-06-01 16:00:25 -07009#include <sync-app-socket.h>
Zhenkai Zhu275ba3a2012-06-01 23:10:43 -070010#include <sync-logic.h>
11#include <sync-seq-no.h>
Zhenkai Zhufd52ab72012-05-29 17:34:35 -070012
Zhenkai Zhu3472e3f2012-06-02 00:44:42 -070013#define ORGANIZATION "IRL@UCLA"
14#define APPLICATION "SYNC-DEMO"
15
Zhenkai Zhufd52ab72012-05-29 17:34:35 -070016class ChatDialog : public QDialog, private Ui::ChatDialog
17{
18 Q_OBJECT
19
20public:
21 ChatDialog(QWidget *parent = 0);
Zhenkai Zhu36c6b782012-06-04 17:11:04 -070022 ~ChatDialog();
Zhenkai Zhu36c6b782012-06-04 17:11:04 -070023 void processRemove(const std::string);
Zhenkai Zhub285a412012-06-05 11:32:00 -070024 void appendMessage(const SyncDemo::ChatMessage msg);
25 void processTreeUpdateWrapper(const std::vector<Sync::MissingDataInfo>, Sync::SyncAppSocket *);
26 void processDataWrapper(std::string, const char *buf, size_t len);
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -070027
Zhenkai Zhue8b9e8e2012-06-04 21:55:14 -070028public slots:
Zhenkai Zhub285a412012-06-05 11:32:00 -070029 void processTreeUpdate(const std::vector<Sync::MissingDataInfo>);
30 void processData(QString name, const char *buf, size_t len);
Zhenkai Zhue8b9e8e2012-06-04 21:55:14 -070031
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -070032private:
33 void formChatMessage(const QString &text, SyncDemo::ChatMessage &msg);
Zhenkai Zhu36c6b782012-06-04 17:11:04 -070034 bool readSettings();
Zhenkai Zhu3472e3f2012-06-02 00:44:42 -070035 void writeSettings();
36 void updateLabels();
Zhenkai Zhue5660932012-06-04 15:25:20 -070037 void resizeEvent(QResizeEvent *);
38 void showEvent(QShowEvent *);
39 void fitView();
Zhenkai Zhu88380c12012-06-04 21:23:34 -070040 void testDraw();
Zhenkai Zhuc71da772012-05-30 21:25:23 -070041
42private slots:
43 void returnPressed();
Zhenkai Zhu275ba3a2012-06-01 23:10:43 -070044 void buttonPressed();
Zhenkai Zhub7834702012-06-05 20:47:54 -070045 void checkSetting();
Zhenkai Zhu3472e3f2012-06-02 00:44:42 -070046 void settingUpdated(QString, QString, QString);
Zhenkai Zhuc71da772012-05-30 21:25:23 -070047
Zhenkai Zhue8b9e8e2012-06-04 21:55:14 -070048signals:
Zhenkai Zhub285a412012-06-05 11:32:00 -070049 void dataReceived(QString name, const char *buf, size_t len);
50 void treeUpdated(const std::vector<Sync::MissingDataInfo>);
Zhenkai Zhue8b9e8e2012-06-04 21:55:14 -070051
Zhenkai Zhuc71da772012-05-30 21:25:23 -070052private:
Zhenkai Zhu56a88592012-06-04 09:42:53 -070053 User m_user;
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -070054 Sync::SyncAppSocket *m_sock;
Zhenkai Zhu36c6b782012-06-04 17:11:04 -070055 uint32_t m_session;
56 DigestTreeScene *m_scene;
Zhenkai Zhuf26e0462012-06-05 21:18:37 -070057 boost::mutex m_msgMutex;
58 boost::mutex m_sceneMutex;
Zhenkai Zhufd52ab72012-05-29 17:34:35 -070059};
60#endif