blob: 312ebb0b0b5bdb4a68c8f11fd18f94a90d424f82 [file] [log] [blame]
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -07001#ifndef CHATDIALOG_H
2#define CHATDIALOG_H
Zhenkai Zhub45e38a2012-06-01 15:44:36 -07003#include <boost/function.hpp>
4#include <vector>
5#include "digesttreescene.h"
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -07006#include "ui_chatdialog.h"
Zhenkai Zhu5a8d5aa2012-05-30 21:25:23 -07007#include "chatbuf.pb.h"
Zhenkai Zhu90ee76c2012-06-01 16:00:25 -07008#include <sync-app-socket.h>
Zhenkai Zhu85845d22012-06-01 23:10:43 -07009#include <sync-logic.h>
10#include <sync-seq-no.h>
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070011
Zhenkai Zhu7e9b06d2012-06-02 00:44:42 -070012#define ORGANIZATION "IRL@UCLA"
13#define APPLICATION "SYNC-DEMO"
14
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070015class ChatDialog : public QDialog, private Ui::ChatDialog
16{
17 Q_OBJECT
18
19public:
20 ChatDialog(QWidget *parent = 0);
Zhenkai Zhu82a62752012-06-04 17:11:04 -070021 ~ChatDialog();
Zhenkai Zhu82a62752012-06-04 17:11:04 -070022 void processRemove(const std::string);
Zhenkai Zhu64f9ede2012-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 Zhub45e38a2012-06-01 15:44:36 -070026
Zhenkai Zhu10ccb5a2012-06-04 21:55:14 -070027public slots:
Zhenkai Zhu64f9ede2012-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 Zhu10ccb5a2012-06-04 21:55:14 -070030
Zhenkai Zhub45e38a2012-06-01 15:44:36 -070031private:
32 void formChatMessage(const QString &text, SyncDemo::ChatMessage &msg);
Zhenkai Zhu82a62752012-06-04 17:11:04 -070033 bool readSettings();
Zhenkai Zhu7e9b06d2012-06-02 00:44:42 -070034 void writeSettings();
35 void updateLabels();
Zhenkai Zhud13acd02012-06-04 15:25:20 -070036 void resizeEvent(QResizeEvent *);
37 void showEvent(QShowEvent *);
38 void fitView();
Zhenkai Zhu21d75f92012-06-04 21:23:34 -070039 void testDraw();
Zhenkai Zhu5a8d5aa2012-05-30 21:25:23 -070040
41private slots:
42 void returnPressed();
Zhenkai Zhu85845d22012-06-01 23:10:43 -070043 void buttonPressed();
Zhenkai Zhue837f792012-06-05 20:47:54 -070044 void checkSetting();
Zhenkai Zhu7e9b06d2012-06-02 00:44:42 -070045 void settingUpdated(QString, QString, QString);
Zhenkai Zhu5a8d5aa2012-05-30 21:25:23 -070046
Zhenkai Zhu10ccb5a2012-06-04 21:55:14 -070047signals:
Zhenkai Zhu64f9ede2012-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 Zhu10ccb5a2012-06-04 21:55:14 -070050
Zhenkai Zhu5a8d5aa2012-05-30 21:25:23 -070051private:
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -070052 User m_user;
Zhenkai Zhub45e38a2012-06-01 15:44:36 -070053 Sync::SyncAppSocket *m_sock;
Zhenkai Zhu82a62752012-06-04 17:11:04 -070054 uint32_t m_session;
55 DigestTreeScene *m_scene;
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070056};
57#endif