blob: df3de48e43407018e905f850566f3620638c7863 [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 Zhu36c6b782012-06-04 17:11:04 -070022 void processTreeUpdate(const std::vector<Sync::MissingDataInfo> &, Sync::SyncAppSocket *);
23 void processData(std::string, const char *buf, size_t len);
24 void processRemove(const std::string);
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -070025
Zhenkai Zhue8b9e8e2012-06-04 21:55:14 -070026public slots:
27 void appendMessage(const SyncDemo::ChatMessage msg);
28
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -070029private:
30 void formChatMessage(const QString &text, SyncDemo::ChatMessage &msg);
Zhenkai Zhu36c6b782012-06-04 17:11:04 -070031 bool readSettings();
Zhenkai Zhu3472e3f2012-06-02 00:44:42 -070032 void writeSettings();
33 void updateLabels();
Zhenkai Zhue5660932012-06-04 15:25:20 -070034 void resizeEvent(QResizeEvent *);
35 void showEvent(QShowEvent *);
36 void fitView();
Zhenkai Zhu88380c12012-06-04 21:23:34 -070037 void testDraw();
Zhenkai Zhuc71da772012-05-30 21:25:23 -070038
39private slots:
40 void returnPressed();
Zhenkai Zhu275ba3a2012-06-01 23:10:43 -070041 void buttonPressed();
Zhenkai Zhu3472e3f2012-06-02 00:44:42 -070042 void settingUpdated(QString, QString, QString);
Zhenkai Zhuc71da772012-05-30 21:25:23 -070043
Zhenkai Zhue8b9e8e2012-06-04 21:55:14 -070044signals:
45 void msgReceived(const SyncDemo::ChatMessage msg);
46
Zhenkai Zhuc71da772012-05-30 21:25:23 -070047private:
Zhenkai Zhu56a88592012-06-04 09:42:53 -070048 User m_user;
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -070049 Sync::SyncAppSocket *m_sock;
Zhenkai Zhu36c6b782012-06-04 17:11:04 -070050 uint32_t m_session;
51 DigestTreeScene *m_scene;
Zhenkai Zhufd52ab72012-05-29 17:34:35 -070052};
53#endif