blob: ea95873f95b04c3103d552fdecfbe12d899ec2e8 [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>
4#include <vector>
5#include "digesttreescene.h"
Zhenkai Zhufd52ab72012-05-29 17:34:35 -07006#include "ui_chatdialog.h"
Zhenkai Zhuc71da772012-05-30 21:25:23 -07007#include "chatbuf.pb.h"
Zhenkai Zhuea026982012-06-01 16:00:25 -07008#include <sync-app-socket.h>
Zhenkai Zhu275ba3a2012-06-01 23:10:43 -07009#include <sync-logic.h>
10#include <sync-seq-no.h>
Zhenkai Zhufd52ab72012-05-29 17:34:35 -070011
Zhenkai Zhu3472e3f2012-06-02 00:44:42 -070012#define ORGANIZATION "IRL@UCLA"
13#define APPLICATION "SYNC-DEMO"
14
Zhenkai Zhufd52ab72012-05-29 17:34:35 -070015class ChatDialog : public QDialog, private Ui::ChatDialog
16{
17 Q_OBJECT
18
19public:
20 ChatDialog(QWidget *parent = 0);
Zhenkai Zhu36c6b782012-06-04 17:11:04 -070021 ~ChatDialog();
Zhenkai Zhu2c55b382012-05-31 13:27:24 -070022 void appendMessage(const SyncDemo::ChatMessage &msg);
Zhenkai Zhu36c6b782012-06-04 17:11:04 -070023 void processTreeUpdate(const std::vector<Sync::MissingDataInfo> &, Sync::SyncAppSocket *);
24 void processData(std::string, const char *buf, size_t len);
25 void processRemove(const std::string);
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -070026
27private:
28 void formChatMessage(const QString &text, SyncDemo::ChatMessage &msg);
Zhenkai Zhu36c6b782012-06-04 17:11:04 -070029 bool readSettings();
Zhenkai Zhu3472e3f2012-06-02 00:44:42 -070030 void writeSettings();
31 void updateLabels();
Zhenkai Zhue5660932012-06-04 15:25:20 -070032 void resizeEvent(QResizeEvent *);
33 void showEvent(QShowEvent *);
34 void fitView();
Zhenkai Zhu88380c12012-06-04 21:23:34 -070035 void testDraw();
Zhenkai Zhuc71da772012-05-30 21:25:23 -070036
37private slots:
38 void returnPressed();
Zhenkai Zhu275ba3a2012-06-01 23:10:43 -070039 void buttonPressed();
Zhenkai Zhu3472e3f2012-06-02 00:44:42 -070040 void settingUpdated(QString, QString, QString);
Zhenkai Zhuc71da772012-05-30 21:25:23 -070041
42private:
Zhenkai Zhu56a88592012-06-04 09:42:53 -070043 User m_user;
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -070044 Sync::SyncAppSocket *m_sock;
Zhenkai Zhu36c6b782012-06-04 17:11:04 -070045 uint32_t m_session;
46 DigestTreeScene *m_scene;
Zhenkai Zhufd52ab72012-05-29 17:34:35 -070047};
48#endif