blob: 312ebb0b0b5bdb4a68c8f11fd18f94a90d424f82 [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 processRemove(const std::string);
Zhenkai Zhub285a412012-06-05 11:32:00 -070023 void appendMessage(const SyncDemo::ChatMessage msg);
24 void processTreeUpdateWrapper(const std::vector<Sync::MissingDataInfo>, Sync::SyncAppSocket *);
25 void processDataWrapper(std::string, const char *buf, size_t len);
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -070026
Zhenkai Zhue8b9e8e2012-06-04 21:55:14 -070027public slots:
Zhenkai Zhub285a412012-06-05 11:32:00 -070028 void processTreeUpdate(const std::vector<Sync::MissingDataInfo>);
29 void processData(QString name, const char *buf, size_t len);
Zhenkai Zhue8b9e8e2012-06-04 21:55:14 -070030
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -070031private:
32 void formChatMessage(const QString &text, SyncDemo::ChatMessage &msg);
Zhenkai Zhu36c6b782012-06-04 17:11:04 -070033 bool readSettings();
Zhenkai Zhu3472e3f2012-06-02 00:44:42 -070034 void writeSettings();
35 void updateLabels();
Zhenkai Zhue5660932012-06-04 15:25:20 -070036 void resizeEvent(QResizeEvent *);
37 void showEvent(QShowEvent *);
38 void fitView();
Zhenkai Zhu88380c12012-06-04 21:23:34 -070039 void testDraw();
Zhenkai Zhuc71da772012-05-30 21:25:23 -070040
41private slots:
42 void returnPressed();
Zhenkai Zhu275ba3a2012-06-01 23:10:43 -070043 void buttonPressed();
Zhenkai Zhub7834702012-06-05 20:47:54 -070044 void checkSetting();
Zhenkai Zhu3472e3f2012-06-02 00:44:42 -070045 void settingUpdated(QString, QString, QString);
Zhenkai Zhuc71da772012-05-30 21:25:23 -070046
Zhenkai Zhue8b9e8e2012-06-04 21:55:14 -070047signals:
Zhenkai Zhub285a412012-06-05 11:32:00 -070048 void dataReceived(QString name, const char *buf, size_t len);
49 void treeUpdated(const std::vector<Sync::MissingDataInfo>);
Zhenkai Zhue8b9e8e2012-06-04 21:55:14 -070050
Zhenkai Zhuc71da772012-05-30 21:25:23 -070051private:
Zhenkai Zhu56a88592012-06-04 09:42:53 -070052 User m_user;
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -070053 Sync::SyncAppSocket *m_sock;
Zhenkai Zhu36c6b782012-06-04 17:11:04 -070054 uint32_t m_session;
55 DigestTreeScene *m_scene;
Zhenkai Zhufd52ab72012-05-29 17:34:35 -070056};
57#endif