blob: 9803a6a95eaed30a0d30106594145f8b72849fbc [file] [log] [blame]
Yingdi Yu9e0dc292013-10-10 11:39:45 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013, Regents of the University of California
4 * Yingdi Yu
5 *
6 * BSD license, See the LICENSE file for more information
7 *
8 * Author: Yingdi Yu <yingdi@cs.ucla.edu>
9 */
10
Yingdi Yudef90612013-10-09 22:34:42 -070011#ifndef CONTACTPANEL_H
12#define CONTACTPANEL_H
13
14#include <QDialog>
Yingdi Yu01a942b2013-10-10 15:00:58 -070015#include <QStringListModel>
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070016#include <QtSql/QSqlDatabase>
Yingdi Yu79c25a22013-10-21 13:38:38 -070017#include <QMenu>
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070018
19#include "profileeditor.h"
Yingdi Yud59b5932013-10-16 13:16:49 -070020#include "addcontactpanel.h"
Yingdi Yu79c25a22013-10-21 13:38:38 -070021#include "setaliasdialog.h"
Yingdi Yu100267f2013-10-21 15:01:40 -070022#include "startchatdialog.h"
Yingdi Yu53eb8a72013-10-23 11:50:51 -070023#include "invitationdialog.h"
24#include "settingdialog.h"
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070025
26#ifndef Q_MOC_RUN
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070027#include "contact-manager.h"
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070028#endif
Yingdi Yudef90612013-10-09 22:34:42 -070029
Yingdi Yu53eb8a72013-10-23 11:50:51 -070030
Yingdi Yudef90612013-10-09 22:34:42 -070031namespace Ui {
32class ContactPanel;
33}
34
35class ContactPanel : public QDialog
36{
37 Q_OBJECT
38
39public:
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070040 explicit ContactPanel(ndn::Ptr<ContactManager> contactManager, QWidget *parent = 0);
Yingdi Yu53eb8a72013-10-23 11:50:51 -070041
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070042 ~ContactPanel();
Yingdi Yudef90612013-10-09 22:34:42 -070043
Yingdi Yu53eb8a72013-10-23 11:50:51 -070044private:
45 void
46 openDB();
47
48 void
49 setKeychain();
50
51 void
52 setLocalPrefix();
53
54 void
55 onLocalPrefixVerified(ndn::Ptr<ndn::Data> data);
56
57 void
58 onLocalPrefixTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest);
59
60 void
61 onUnverified(ndn::Ptr<ndn::Data> data);
62
63 void
64 onTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest);
65
66 void
67 setInvitationListener();
68
69 void
70 onInvitation(ndn::Ptr<ndn::Interest> interest);
71
72 void
73 onInvitationCertVerified(ndn::Ptr<ndn::Data> data,
74 const ndn::Name& interestName,
75 int inviterIndex);
76
77 std::string
78 getRandomString();
79
80 void
81 popChatInvitation(const ndn::Name& interestName,
82 int inviterIndex,
83 const ndn::Name& inviterNameSpace,
84 ndn::Ptr<ndn::security::IdentityCertificate> certificate);
85
Yingdi Yu01a942b2013-10-10 15:00:58 -070086private slots:
87 void
88 updateSelection(const QItemSelection &selected,
89 const QItemSelection &deselected);
90
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070091 void
Yingdi Yu53eb8a72013-10-23 11:50:51 -070092 updateDefaultIdentity(const QString& identity);
93
94 void
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070095 openProfileEditor();
96
Yingdi Yud59b5932013-10-16 13:16:49 -070097 void
98 openAddContactPanel();
99
Yingdi Yu79c25a22013-10-21 13:38:38 -0700100 void
101 openSetAliasDialog();
Yingdi Yu100267f2013-10-21 15:01:40 -0700102
103 void
104 openStartChatDialog();
Yingdi Yu79c25a22013-10-21 13:38:38 -0700105
106 void
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700107 openSettingDialog();
108
109 void
Yingdi Yu79c25a22013-10-21 13:38:38 -0700110 refreshContactList();
111
112 void
113 showContextMenu(const QPoint& pos);
114
Yingdi Yu100267f2013-10-21 15:01:40 -0700115 void
116 startChatroom(const QString& chatroom, const QString& invitee, bool isIntroducer);
117
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700118 void
119 startChatroom2(const QString& chatroom, const QString& inviter);
120
121 void
122 acceptInvitation(const ndn::Name& interestName,
123 const ndn::security::IdentityCertificate& identityCertificate,
124 QString inviter,
125 QString chatroom);
126
127 void
128 rejectInvitation(const ndn::Name& interestName);
129
Yingdi Yudef90612013-10-09 22:34:42 -0700130private:
Yingdi Yu0a6b6c52013-10-15 17:54:00 -0700131 Ui::ContactPanel *ui;
Yingdi Yu0b82a4e2013-10-18 11:29:25 -0700132 ndn::Ptr<ContactManager> m_contactManager;
Yingdi Yu0a6b6c52013-10-15 17:54:00 -0700133 QStringListModel* m_contactListModel;
134 ProfileEditor* m_profileEditor;
Yingdi Yud59b5932013-10-16 13:16:49 -0700135 AddContactPanel* m_addContactPanel;
Yingdi Yu79c25a22013-10-21 13:38:38 -0700136 SetAliasDialog* m_setAliasDialog;
Yingdi Yu100267f2013-10-21 15:01:40 -0700137 StartChatDialog* m_startChatDialog;
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700138 InvitationDialog* m_invitationDialog;
139 SettingDialog* m_settingDialog;
Yingdi Yu79c25a22013-10-21 13:38:38 -0700140 QAction* m_menuInvite;
141 QAction* m_menuAlias;
Yingdi Yu79c25a22013-10-21 13:38:38 -0700142 std::vector<ndn::Ptr<ContactItem> > m_contactList;
143
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700144 ndn::Ptr<ndn::security::Keychain> m_keychain;
145 ndn::Ptr<ndn::Wrapper> m_handler;
146
147 ndn::Name m_defaultIdentity;
148 ndn::Name m_localPrefix;
149
Yingdi Yu100267f2013-10-21 15:01:40 -0700150 std::string m_currentSelectedContactAlias;
151 std::string m_currentSelectedContactNamespace;
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700152
153
Yingdi Yudef90612013-10-09 22:34:42 -0700154};
155
156#endif // CONTACTPANEL_H