blob: e5e0c34a1fe47186f785ab5b3ce6f368aba0f674 [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>
Zhenkai Zhu44b43752012-06-05 21:18:37 -07004#include <boost/thread/mutex.hpp>
Zhenkai Zhub45e38a2012-06-01 15:44:36 -07005#include <vector>
6#include "digesttreescene.h"
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -07007#include "ui_chatdialog.h"
Zhenkai Zhu5a8d5aa2012-05-30 21:25:23 -07008#include "chatbuf.pb.h"
Zhenkai Zhu90ee76c2012-06-01 16:00:25 -07009#include <sync-app-socket.h>
Zhenkai Zhu85845d22012-06-01 23:10:43 -070010#include <sync-logic.h>
11#include <sync-seq-no.h>
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070012
Zhenkai Zhu7e9b06d2012-06-02 00:44:42 -070013#define ORGANIZATION "IRL@UCLA"
14#define APPLICATION "SYNC-DEMO"
15
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070016class ChatDialog : public QDialog, private Ui::ChatDialog
17{
18 Q_OBJECT
19
20public:
21 ChatDialog(QWidget *parent = 0);
Zhenkai Zhu82a62752012-06-04 17:11:04 -070022 ~ChatDialog();
Zhenkai Zhu82a62752012-06-04 17:11:04 -070023 void processRemove(const std::string);
Zhenkai Zhu64f9ede2012-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 Zhub45e38a2012-06-01 15:44:36 -070027
Zhenkai Zhu10ccb5a2012-06-04 21:55:14 -070028public slots:
Zhenkai Zhu64f9ede2012-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 Zhu10ccb5a2012-06-04 21:55:14 -070031
Zhenkai Zhub45e38a2012-06-01 15:44:36 -070032private:
33 void formChatMessage(const QString &text, SyncDemo::ChatMessage &msg);
Zhenkai Zhu82a62752012-06-04 17:11:04 -070034 bool readSettings();
Zhenkai Zhu7e9b06d2012-06-02 00:44:42 -070035 void writeSettings();
36 void updateLabels();
Zhenkai Zhud13acd02012-06-04 15:25:20 -070037 void resizeEvent(QResizeEvent *);
38 void showEvent(QShowEvent *);
39 void fitView();
Zhenkai Zhu21d75f92012-06-04 21:23:34 -070040 void testDraw();
Zhenkai Zhu5a8d5aa2012-05-30 21:25:23 -070041
42private slots:
43 void returnPressed();
Zhenkai Zhu85845d22012-06-01 23:10:43 -070044 void buttonPressed();
Zhenkai Zhue837f792012-06-05 20:47:54 -070045 void checkSetting();
Zhenkai Zhu7e9b06d2012-06-02 00:44:42 -070046 void settingUpdated(QString, QString, QString);
Zhenkai Zhu5a8d5aa2012-05-30 21:25:23 -070047
Zhenkai Zhu10ccb5a2012-06-04 21:55:14 -070048signals:
Zhenkai Zhu64f9ede2012-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 Zhu10ccb5a2012-06-04 21:55:14 -070051
Zhenkai Zhu5a8d5aa2012-05-30 21:25:23 -070052private:
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -070053 User m_user;
Zhenkai Zhub45e38a2012-06-01 15:44:36 -070054 Sync::SyncAppSocket *m_sock;
Zhenkai Zhu82a62752012-06-04 17:11:04 -070055 uint32_t m_session;
56 DigestTreeScene *m_scene;
Zhenkai Zhu44b43752012-06-05 21:18:37 -070057 boost::mutex m_msgMutex;
58 boost::mutex m_sceneMutex;
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070059};
60#endif