blob: 483bc615876047c5a06cdcdba72b4e1d821939be [file] [log] [blame]
Yingdi Yu348f5ea2014-03-01 14:47:25 -08001/* -*- 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
11#include <QApplication>
12#include <QMessageBox>
13#include <QDir>
14#include <QTimer>
Yingdi Yu0b0a7362014-08-05 16:31:30 -070015#include "controller.hpp"
Mengjin Yan391d7242014-08-28 20:51:55 -070016//#include "chatroom-discovery.h"
Yingdi Yu348f5ea2014-03-01 14:47:25 -080017
18#ifndef Q_MOC_RUN
19#include <boost/filesystem.hpp>
20#include <boost/lexical_cast.hpp>
Yingdi Yufa0b6a02014-04-30 14:26:42 -070021#include <ndn-cxx/util/random.hpp>
Yingdi Yu0b0a7362014-08-05 16:31:30 -070022#include "cryptopp.hpp"
Yingdi Yu348f5ea2014-03-01 14:47:25 -080023#include "config.pb.h"
24#include "endorse-info.pb.h"
25#include "logging.h"
26#endif
27
Yingdi Yu0b0a7362014-08-05 16:31:30 -070028// INIT_LOGGER("chronos.Controller");
Yingdi Yu348f5ea2014-03-01 14:47:25 -080029
30Q_DECLARE_METATYPE(ndn::Name)
31Q_DECLARE_METATYPE(ndn::IdentityCertificate)
Yingdi Yu0b0a7362014-08-05 16:31:30 -070032Q_DECLARE_METATYPE(Chronos::EndorseInfo)
Yingdi Yu233a9722014-03-07 15:47:09 -080033Q_DECLARE_METATYPE(ndn::Interest)
34Q_DECLARE_METATYPE(size_t)
Mengjin Yan391d7242014-08-28 20:51:55 -070035Q_DECLARE_METATYPE(chronos::ChatroomInfo)
Yingdi Yu348f5ea2014-03-01 14:47:25 -080036
37namespace chronos {
38
Yingdi Yu0b0a7362014-08-05 16:31:30 -070039using std::string;
40
41using ndn::Face;
42using ndn::IdentityCertificate;
43using ndn::OnInterestValidated;
44using ndn::OnInterestValidationFailed;
Yingdi Yu17032f82014-03-25 15:48:23 -070045
Yingdi Yu348f5ea2014-03-01 14:47:25 -080046static const uint8_t ROUTING_PREFIX_SEPARATOR[2] = {0xF0, 0x2E};
47
48// constructor & destructor
49Controller::Controller(shared_ptr<Face> face,
Yingdi Yufa0b6a02014-04-30 14:26:42 -070050 QWidget* parent)
Yingdi Yu348f5ea2014-03-01 14:47:25 -080051 : QDialog(parent)
52 , m_face(face)
53 , m_invitationListenerId(0)
54 , m_contactManager(m_face)
Mengjin Yan391d7242014-08-28 20:51:55 -070055 , m_discoveryLogic(m_face,
56 bind(&Controller::updateDiscoveryList, this, _1, _2))
Yingdi Yu348f5ea2014-03-01 14:47:25 -080057 , m_settingDialog(new SettingDialog)
58 , m_startChatDialog(new StartChatDialog)
59 , m_profileEditor(new ProfileEditor)
60 , m_invitationDialog(new InvitationDialog)
61 , m_contactPanel(new ContactPanel)
62 , m_browseContactDialog(new BrowseContactDialog)
63 , m_addContactPanel(new AddContactPanel)
Mengjin Yan391d7242014-08-28 20:51:55 -070064 , m_chatroomDiscoveryDialog(new ChatroomDiscoveryDialog)
Yingdi Yu348f5ea2014-03-01 14:47:25 -080065{
66 qRegisterMetaType<ndn::Name>("ndn.Name");
67 qRegisterMetaType<ndn::IdentityCertificate>("ndn.IdentityCertificate");
Yingdi Yu0b0a7362014-08-05 16:31:30 -070068 qRegisterMetaType<Chronos::EndorseInfo>("Chronos.EndorseInfo");
Yingdi Yu233a9722014-03-07 15:47:09 -080069 qRegisterMetaType<ndn::Interest>("ndn.Interest");
70 qRegisterMetaType<size_t>("size_t");
Mengjin Yan391d7242014-08-28 20:51:55 -070071 qRegisterMetaType<chronos::ChatroomInfo>("chronos.Chatroom");
Yingdi Yu348f5ea2014-03-01 14:47:25 -080072
73 connect(this, SIGNAL(localPrefixUpdated(const QString&)),
74 this, SLOT(onLocalPrefixUpdated(const QString&)));
Yingdi Yu233a9722014-03-07 15:47:09 -080075 connect(this, SIGNAL(invitationInterest(const ndn::Name&, const ndn::Interest&, size_t)),
76 this, SLOT(onInvitationInterest(const ndn::Name&, const ndn::Interest&, size_t)));
Yingdi Yu348f5ea2014-03-01 14:47:25 -080077
78 // Connection to ContactManager
79 connect(this, SIGNAL(identityUpdated(const QString&)),
80 &m_contactManager, SLOT(onIdentityUpdated(const QString&)));
81 connect(&m_contactManager, SIGNAL(warning(const QString&)),
82 this, SLOT(onWarning(const QString&)));
83 connect(this, SIGNAL(refreshBrowseContact()),
84 &m_contactManager, SLOT(onRefreshBrowseContact()));
85 connect(&m_contactManager, SIGNAL(contactInfoFetchFailed(const QString&)),
86 this, SLOT(onWarning(const QString&)));
87 connect(&m_contactManager, SIGNAL(contactIdListReady(const QStringList&)),
88 this, SLOT(onContactIdListReady(const QStringList&)));
89
90 // Connection to SettingDialog
91 connect(this, SIGNAL(identityUpdated(const QString&)),
92 m_settingDialog, SLOT(onIdentityUpdated(const QString&)));
93 connect(m_settingDialog, SIGNAL(identityUpdated(const QString&)),
94 this, SLOT(onIdentityUpdated(const QString&)));
95 connect(m_settingDialog, SIGNAL(nickUpdated(const QString&)),
96 this, SLOT(onNickUpdated(const QString&)));
97
98 // Connection to ProfileEditor
99 connect(this, SIGNAL(closeDBModule()),
100 m_profileEditor, SLOT(onCloseDBModule()));
101 connect(this, SIGNAL(identityUpdated(const QString&)),
102 m_profileEditor, SLOT(onIdentityUpdated(const QString&)));
103 connect(m_profileEditor, SIGNAL(updateProfile()),
104 &m_contactManager, SLOT(onUpdateProfile()));
105
106 // Connection to StartChatDialog
107 connect(m_startChatDialog, SIGNAL(startChatroom(const QString&, bool)),
108 this, SLOT(onStartChatroom(const QString&, bool)));
109
110 // Connection to InvitationDialog
111 connect(m_invitationDialog, SIGNAL(invitationResponded(const ndn::Name&, bool)),
112 this, SLOT(onInvitationResponded(const ndn::Name&, bool)));
113
114 // Connection to AddContactPanel
115 connect(m_addContactPanel, SIGNAL(fetchInfo(const QString&)),
116 &m_contactManager, SLOT(onFetchContactInfo(const QString&)));
117 connect(m_addContactPanel, SIGNAL(addContact(const QString&)),
118 &m_contactManager, SLOT(onAddFetchedContact(const QString&)));
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700119 connect(&m_contactManager, SIGNAL(contactEndorseInfoReady(const Chronos::EndorseInfo&)),
120 m_addContactPanel, SLOT(onContactEndorseInfoReady(const Chronos::EndorseInfo&)));
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800121
122
123 // Connection to BrowseContactDialog
124 connect(m_browseContactDialog, SIGNAL(directAddClicked()),
125 this, SLOT(onDirectAdd()));
126 connect(m_browseContactDialog, SIGNAL(fetchIdCert(const QString&)),
127 &m_contactManager, SLOT(onFetchIdCert(const QString&)));
128 connect(m_browseContactDialog, SIGNAL(addContact(const QString&)),
129 &m_contactManager, SLOT(onAddFetchedContactIdCert(const QString&)));
130 connect(&m_contactManager, SIGNAL(idCertNameListReady(const QStringList&)),
131 m_browseContactDialog, SLOT(onIdCertNameListReady(const QStringList&)));
132 connect(&m_contactManager, SIGNAL(nameListReady(const QStringList&)),
133 m_browseContactDialog, SLOT(onNameListReady(const QStringList&)));
134 connect(&m_contactManager, SIGNAL(idCertReady(const ndn::IdentityCertificate&)),
135 m_browseContactDialog, SLOT(onIdCertReady(const ndn::IdentityCertificate&)));
136
137 // Connection to ContactPanel
138 connect(m_contactPanel, SIGNAL(waitForContactList()),
139 &m_contactManager, SLOT(onWaitForContactList()));
140 connect(m_contactPanel, SIGNAL(waitForContactInfo(const QString&)),
141 &m_contactManager, SLOT(onWaitForContactInfo(const QString&)));
142 connect(m_contactPanel, SIGNAL(removeContact(const QString&)),
143 &m_contactManager, SLOT(onRemoveContact(const QString&)));
144 connect(m_contactPanel, SIGNAL(updateAlias(const QString&, const QString&)),
145 &m_contactManager, SLOT(onUpdateAlias(const QString&, const QString&)));
146 connect(m_contactPanel, SIGNAL(updateIsIntroducer(const QString&, bool)),
147 &m_contactManager, SLOT(onUpdateIsIntroducer(const QString&, bool)));
148 connect(m_contactPanel, SIGNAL(updateEndorseCertificate(const QString&)),
149 &m_contactManager, SLOT(onUpdateEndorseCertificate(const QString&)));
150 connect(m_contactPanel, SIGNAL(warning(const QString&)),
151 this, SLOT(onWarning(const QString&)));
152 connect(this, SIGNAL(closeDBModule()),
153 m_contactPanel, SLOT(onCloseDBModule()));
154 connect(this, SIGNAL(identityUpdated(const QString&)),
155 m_contactPanel, SLOT(onIdentityUpdated(const QString&)));
156 connect(&m_contactManager, SIGNAL(contactAliasListReady(const QStringList&)),
157 m_contactPanel, SLOT(onContactAliasListReady(const QStringList&)));
158 connect(&m_contactManager, SIGNAL(contactIdListReady(const QStringList&)),
159 m_contactPanel, SLOT(onContactIdListReady(const QStringList&)));
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700160 connect(&m_contactManager, SIGNAL(contactInfoReady(const QString&, const QString&,
161 const QString&, bool)),
162 m_contactPanel, SLOT(onContactInfoReady(const QString&, const QString&,
163 const QString&, bool)));
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800164
Mengjin Yan391d7242014-08-28 20:51:55 -0700165 // Connection to DiscoveryDialog
166 connect(this,
167 SIGNAL(discoverChatroomChanged(const chronos::ChatroomInfo&, bool)),
168 m_chatroomDiscoveryDialog,
169 SLOT(onDiscoverChatroomChanged(const chronos::ChatroomInfo&, bool)));
170 connect(m_chatroomDiscoveryDialog, SIGNAL(startChatroom(const QString&, bool)),
171 this, SLOT(onStartChatroom(const QString&, bool)));
172
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800173 initialize();
174
Yingdi Yu233a9722014-03-07 15:47:09 -0800175 createTrayIcon();
176
177 onUpdateLocalPrefixAction();
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800178}
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700179
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800180Controller::~Controller()
181{
182 saveConf();
183}
184
185// public methods
186
187
188// private methods
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700189string
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800190Controller::getDBName()
191{
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700192 string dbName("chronos-");
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800193
194 std::stringstream ss;
195 {
196 using namespace CryptoPP;
197
198 SHA256 hash;
199 StringSource(m_identity.wireEncode().wire(), m_identity.wireEncode().size(), true,
200 new HashFilter(hash, new HexEncoder(new FileSink(ss), false)));
201 }
202 dbName.append(ss.str()).append(".db");
203
204 return dbName;
205}
206
207void
208Controller::openDB()
209{
210 m_db = QSqlDatabase::addDatabase("QSQLITE");
211 QString path = (QDir::home().path());
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700212 path.append(QDir::separator())
213 .append(".chronos")
214 .append(QDir::separator())
215 .append(getDBName().c_str());
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800216 m_db.setDatabaseName(path);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800217
Yingdi Yu42125862014-08-07 17:04:28 -0700218 m_db.open();
219
220 // bool ok = m_db.open();
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700221 // _LOG_DEBUG("DB opened: " << std::boolalpha << ok );
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800222}
223
224void
225Controller::initialize()
226{
227 loadConf();
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700228
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800229 m_keyChain.createIdentity(m_identity);
230
231 openDB();
232
233 emit identityUpdated(QString(m_identity.toUri().c_str()));
234
235 setInvitationListener();
Mengjin Yan391d7242014-08-28 20:51:55 -0700236
237 m_discoveryLogic.sendDiscoveryInterest();
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800238}
239
240void
241Controller::setInvitationListener()
242{
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700243 if (m_invitationListenerId != 0)
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800244 m_face->unsetInterestFilter(m_invitationListenerId);
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700245
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800246 Name invitationPrefix;
247 Name routingPrefix = getInvitationRoutingPrefix();
248 size_t offset = 0;
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700249 if (!routingPrefix.isPrefixOf(m_identity)) {
250 invitationPrefix.append(routingPrefix).append(ROUTING_PREFIX_SEPARATOR, 2);
251 offset = routingPrefix.size() + 1;
252 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800253 invitationPrefix.append(m_identity).append("CHRONOCHAT-INVITATION");
254
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700255 m_invitationListenerId = m_face->setInterestFilter(invitationPrefix,
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700256 bind(&Controller::onInvitationInterestWrapper,
257 this, _1, _2, offset),
258 bind(&Controller::onInvitationRegisterFailed,
259 this, _1, _2));
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800260}
261
262void
263Controller::loadConf()
264{
265 namespace fs = boost::filesystem;
266
267 fs::path chronosDir = fs::path(getenv("HOME")) / ".chronos";
268 fs::create_directories (chronosDir);
269
270 std::ifstream is((chronosDir / "config").c_str ());
271 ChronoChat::Conf conf;
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700272 if (conf.ParseFromIstream(&is)) {
273 m_identity.clear();
274 m_identity.append(conf.identity());
275 if (conf.has_nick())
276 m_nick = conf.nick();
277 else
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800278 m_nick = m_identity.get(-1).toUri();
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700279 }
280 else {
281 m_identity.clear();
282 // TODO: change below to system default;
283 m_identity.append("chronochat-tmp-identity")
284 .append(getRandomString());
285
286 m_nick = m_identity.get(-1).toUri();
287 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800288}
289
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700290void
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800291Controller::saveConf()
292{
293 namespace fs = boost::filesystem;
294
295 fs::path chronosDir = fs::path(getenv("HOME")) / ".chronos";
296 fs::create_directories (chronosDir);
297
298 std::ofstream os((chronosDir / "config").c_str ());
299 ChronoChat::Conf conf;
300 conf.set_identity(m_identity.toUri());
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700301 if (!m_nick.empty())
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800302 conf.set_nick(m_nick);
303 conf.SerializeToOstream(&os);
304
305 os.close();
306}
307
308void
309Controller::createActions()
310{
311 m_startChatroom = new QAction(tr("Start new chat"), this);
312 connect(m_startChatroom, SIGNAL(triggered()), this, SLOT(onStartChatAction()));
313
Mengjin Yan391d7242014-08-28 20:51:55 -0700314 m_discoveryAction = new QAction(tr("Ongoing Chatrooms"), this);
315 connect(m_discoveryAction, SIGNAL(triggered()), this, SLOT(onDiscoveryAction()));
316
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800317 m_settingsAction = new QAction(tr("Settings"), this);
318 connect(m_settingsAction, SIGNAL(triggered()), this, SLOT(onSettingsAction()));
319
320 m_editProfileAction = new QAction(tr("Edit profile"), this);
321 connect(m_editProfileAction, SIGNAL(triggered()), this, SLOT(onProfileEditorAction()));
322
323 m_contactListAction = new QAction(tr("Contact List"), this);
324 connect(m_contactListAction, SIGNAL(triggered()), this, SLOT(onContactListAction()));
325
326 m_addContactAction = new QAction(tr("Add contact"), this);
327 connect(m_addContactAction, SIGNAL(triggered()), this, SLOT(onAddContactAction()));
328
329 m_updateLocalPrefixAction = new QAction(tr("Update local prefix"), this);
330 connect(m_updateLocalPrefixAction, SIGNAL(triggered()), this, SLOT(onUpdateLocalPrefixAction()));
331
332 m_minimizeAction = new QAction(tr("Mi&nimize"), this);
333 connect(m_minimizeAction, SIGNAL(triggered()), this, SLOT(onMinimizeAction()));
334
335 m_quitAction = new QAction(tr("Quit"), this);
336 connect(m_quitAction, SIGNAL(triggered()), this, SLOT(onQuitAction()));
Mengjin Yan391d7242014-08-28 20:51:55 -0700337
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800338}
339
340void
341Controller::createTrayIcon()
342{
343 createActions();
344
345 m_trayIconMenu = new QMenu(this);
346 m_trayIconMenu->addAction(m_startChatroom);
Mengjin Yan391d7242014-08-28 20:51:55 -0700347 m_trayIconMenu->addAction(m_discoveryAction);
348
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800349 m_trayIconMenu->addSeparator();
350 m_trayIconMenu->addAction(m_settingsAction);
351 m_trayIconMenu->addAction(m_editProfileAction);
352 m_trayIconMenu->addSeparator();
353 m_trayIconMenu->addAction(m_contactListAction);
354 m_trayIconMenu->addAction(m_addContactAction);
355 m_trayIconMenu->addSeparator();
356 m_trayIconMenu->addAction(m_updateLocalPrefixAction);
357 m_trayIconMenu->addSeparator();
358 m_trayIconMenu->addAction(m_minimizeAction);
359 m_closeMenu = m_trayIconMenu->addMenu("Close chatroom");
360 m_closeMenu->setEnabled(false);
361 m_trayIconMenu->addSeparator();
362 m_trayIconMenu->addAction(m_quitAction);
363
364 m_trayIcon = new QSystemTrayIcon(this);
365 m_trayIcon->setContextMenu(m_trayIconMenu);
366
367 m_trayIcon->setIcon(QIcon(":/images/icon_small.png"));
368 m_trayIcon->setToolTip("ChronoChat System Tray Icon");
369 m_trayIcon->setVisible(true);
370}
371
372void
373Controller::updateMenu()
374{
375 QMenu* menu = new QMenu(this);
376 QMenu* closeMenu = 0;
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700377
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800378 menu->addAction(m_startChatroom);
Mengjin Yan391d7242014-08-28 20:51:55 -0700379 menu->addAction(m_discoveryAction);
380
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800381 menu->addSeparator();
382 menu->addAction(m_settingsAction);
383 menu->addAction(m_editProfileAction);
384 menu->addSeparator();
Yingdi Yu233a9722014-03-07 15:47:09 -0800385 menu->addAction(m_contactListAction);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800386 menu->addAction(m_addContactAction);
387 menu->addSeparator();
388 {
389 ChatActionList::const_iterator it = m_chatActionList.begin();
390 ChatActionList::const_iterator end = m_chatActionList.end();
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700391 if (it != end) {
392 for (; it != end; it++)
393 menu->addAction(it->second);
394 menu->addSeparator();
395 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800396 }
397 menu->addAction(m_updateLocalPrefixAction);
398 menu->addSeparator();
399 menu->addAction(m_minimizeAction);
400 closeMenu = menu->addMenu("Close chatroom");
401 {
402 ChatActionList::const_iterator it = m_closeActionList.begin();
403 ChatActionList::const_iterator end = m_closeActionList.end();
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700404 if (it == end)
405 closeMenu->setEnabled(false);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800406 else
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700407 for (; it != end; it++)
408 closeMenu->addAction(it->second);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800409 }
410 menu->addSeparator();
411 menu->addAction(m_quitAction);
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700412
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800413 m_trayIcon->setContextMenu(menu);
414 delete m_trayIconMenu;
415 m_trayIconMenu = menu;
416 m_closeMenu = closeMenu;
417}
418
419void
420Controller::onLocalPrefix(const Interest& interest, Data& data)
421{
422 QString localPrefixStr = QString::fromUtf8
423 (reinterpret_cast<const char*>(data.getContent().value()), data.getContent().value_size())
424 .trimmed();
425
426 Name localPrefix(localPrefixStr.toStdString());
Mengjin Yan391d7242014-08-28 20:51:55 -0700427 if (m_localPrefix.empty() || m_localPrefix != localPrefix) {
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800428 emit localPrefixUpdated(localPrefixStr);
Mengjin Yan391d7242014-08-28 20:51:55 -0700429 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800430}
431
432void
433Controller::onLocalPrefixTimeout(const Interest& interest)
434{
435 QString localPrefixStr("/private/local");
436
437 Name localPrefix(localPrefixStr.toStdString());
Mengjin Yan391d7242014-08-28 20:51:55 -0700438 if (m_localPrefix.empty() || m_localPrefix != localPrefix) {
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800439 emit localPrefixUpdated(localPrefixStr);
Mengjin Yan391d7242014-08-28 20:51:55 -0700440 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800441}
442
443void
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700444Controller::onInvitationInterestWrapper(const Name& prefix,
445 const Interest& interest,
446 size_t routingPrefixOffset)
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800447{
Yingdi Yu233a9722014-03-07 15:47:09 -0800448 emit invitationInterest(prefix, interest, routingPrefixOffset);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800449}
450
451void
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700452Controller::onInvitationRegisterFailed(const Name& prefix, const string& failInfo)
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800453{
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700454 // _LOG_DEBUG("Controller::onInvitationRegisterFailed: " << failInfo);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800455}
456
457void
458Controller::onInvitationValidated(const shared_ptr<const Interest>& interest)
459{
460 Invitation invitation(interest->getName());
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700461 // Should be obtained via a method of ContactManager.
462 string alias = invitation.getInviterCertificate().getPublicKeyName().getPrefix(-1).toUri();
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800463
464 m_invitationDialog->setInvitation(alias, invitation.getChatroom(), interest->getName());
465 m_invitationDialog->show();
466}
467
468void
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700469Controller::onInvitationValidationFailed(const shared_ptr<const Interest>& interest,
470 string failureInfo)
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800471{
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700472 // _LOG_DEBUG("Invitation: " << interest->getName() <<
473 // " cannot not be validated due to: " << failureInfo);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800474}
475
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700476string
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800477Controller::getRandomString()
478{
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700479 uint32_t r = ndn::random::generateWord32();
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800480 std::stringstream ss;
481 {
482 using namespace CryptoPP;
483 StringSource(reinterpret_cast<uint8_t*>(&r), 4, true,
484 new HexEncoder(new FileSink(ss), false));
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700485
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800486 }
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700487 // for (int i = 0; i < 8; i++)
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800488 // {
489 // uint32_t t = r & mask;
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700490 // if (t < 10)
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800491 // ss << static_cast<char>(t + 0x30);
492 // else
493 // ss << static_cast<char>(t + 0x57);
494 // r = r >> 4;
495 // }
496
497 return ss.str();
498}
499
500ndn::Name
501Controller::getInvitationRoutingPrefix()
502{
503 return Name("/ndn/broadcast");
504}
505
506void
507Controller::addChatDialog(const QString& chatroomName, ChatDialog* chatDialog)
508{
509 m_chatDialogList[chatroomName.toStdString()] = chatDialog;
Mengjin Yan391d7242014-08-28 20:51:55 -0700510 m_discoveryLogic.addLocalChatroom(*chatDialog->getChatroomInfo());
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800511 connect(chatDialog, SIGNAL(closeChatDialog(const QString&)),
512 this, SLOT(onRemoveChatDialog(const QString&)));
513 connect(chatDialog, SIGNAL(showChatMessage(const QString&, const QString&, const QString&)),
514 this, SLOT(onShowChatMessage(const QString&, const QString&, const QString&)));
Yingdi Yu233a9722014-03-07 15:47:09 -0800515 connect(chatDialog, SIGNAL(resetIcon()),
516 this, SLOT(onResetIcon()));
Mengjin Yan391d7242014-08-28 20:51:55 -0700517 connect(chatDialog, SIGNAL(rosterChanged(const chronos::ChatroomInfo&)),
518 this, SLOT(onRosterChanged(const chronos::ChatroomInfo&)));
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800519 connect(this, SIGNAL(localPrefixUpdated(const QString&)),
520 chatDialog, SLOT(onLocalPrefixUpdated(const QString&)));
521
522 QAction* chatAction = new QAction(chatroomName, this);
523 m_chatActionList[chatroomName.toStdString()] = chatAction;
Mengjin Yan391d7242014-08-28 20:51:55 -0700524 connect(chatAction, SIGNAL(triggered()),
525 chatDialog, SLOT(raise()));//ymj
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800526
527 QAction* closeAction = new QAction(chatroomName, this);
528 m_closeActionList[chatroomName.toStdString()] = closeAction;
529 connect(closeAction, SIGNAL(triggered()), chatDialog, SLOT(onClose()));
530
531 updateMenu();
532}
533
Mengjin Yan391d7242014-08-28 20:51:55 -0700534void
535Controller::updateDiscoveryList(const ChatroomInfo& info, bool isAdd)
536{
537 emit discoverChatroomChanged(info, isAdd);
538}
539
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800540void
541Controller::onIdentityUpdated(const QString& identity)
542{
543 Name identityName(identity.toStdString());
544
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700545 while (!m_chatDialogList.empty()) {
546 ChatDialogList::const_iterator it = m_chatDialogList.begin();
547 onRemoveChatDialog(QString::fromStdString(it->first));
548 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800549
550 m_identity = identityName;
551 m_keyChain.createIdentity(m_identity);
Yingdi Yu233a9722014-03-07 15:47:09 -0800552 setInvitationListener();
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800553
554 emit closeDBModule();
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700555
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800556 QTimer::singleShot(500, this, SLOT(onIdentityUpdatedContinued()));
557
558}
559
560void
561Controller::onIdentityUpdatedContinued()
562{
563 QString connection = m_db.connectionName();
564 // _LOG_DEBUG("connection name: " << connection.toStdString());
565 QSqlDatabase::removeDatabase(connection);
566 m_db.close();
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700567
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800568 openDB();
569
570 emit identityUpdated(QString(m_identity.toUri().c_str()));
571}
572
573void
574Controller::onContactIdListReady(const QStringList& list)
575{
576 ContactList contactList;
577
578 m_contactManager.getContactList(contactList);
579 m_validator.cleanTrustAnchor();
580
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700581 for (ContactList::const_iterator it = contactList.begin(); it != contactList.end(); it++)
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800582 m_validator.addTrustAnchor((*it)->getPublicKeyName(), (*it)->getPublicKey());
583
584}
585
586void
587Controller::onNickUpdated(const QString& nick)
588{
589 m_nick = nick.toStdString();
590}
591
592void
593Controller::onLocalPrefixUpdated(const QString& localPrefix)
594{
595 m_localPrefix = Name(localPrefix.toStdString());
596}
597
598void
599Controller::onStartChatAction()
600{
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700601 string chatroom = "chatroom-" + getRandomString();
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800602
603 m_startChatDialog->setChatroom(chatroom);
604 m_startChatDialog->show();
605 m_startChatDialog->raise();
606}
607
608void
Mengjin Yan391d7242014-08-28 20:51:55 -0700609Controller::onDiscoveryAction()
610{
611 m_discoveryLogic.sendDiscoveryInterest();
612
613 m_chatroomDiscoveryDialog->updateChatroomList();
614 m_chatroomDiscoveryDialog->show();
615 m_chatroomDiscoveryDialog->raise();
616}
617
618
619void
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800620Controller::onSettingsAction()
621{
622 m_settingDialog->setNick(QString(m_nick.c_str()));
623 m_settingDialog->show();
624 m_settingDialog->raise();
625}
626
627void
628Controller::onProfileEditorAction()
629{
630 m_profileEditor->show();
631 m_profileEditor->raise();
632}
633
634void
635Controller::onAddContactAction()
636{
637 emit refreshBrowseContact();
638 m_browseContactDialog->show();
639 m_browseContactDialog->raise();
640}
641
642void
643Controller::onContactListAction()
644{
645 m_contactPanel->show();
646 m_contactPanel->raise();
647}
648
649void
650Controller::onDirectAdd()
651{
652 m_addContactPanel->show();
653 m_addContactPanel->raise();
654}
655
656void
657Controller::onUpdateLocalPrefixAction()
658{
659 // Name interestName();
660 Interest interest("/local/ndn/prefix");
Yingdi Yua7876722014-03-25 14:46:55 -0700661 interest.setInterestLifetime(time::milliseconds(1000));
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800662 interest.setMustBeFresh(true);
663
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700664 m_face->expressInterest(interest,
665 bind(&Controller::onLocalPrefix, this, _1, _2),
666 bind(&Controller::onLocalPrefixTimeout, this, _1));
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800667}
668
669void
670Controller::onMinimizeAction()
671{
672 m_settingDialog->hide();
673 m_startChatDialog->hide();
674 m_profileEditor->hide();
675 m_invitationDialog->hide();
676 m_addContactPanel->hide();
677
678 ChatDialogList::iterator it = m_chatDialogList.begin();
679 ChatDialogList::iterator end = m_chatDialogList.end();
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700680 for (; it != end; it++)
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800681 it->second->hide();
682}
683
684void
685Controller::onQuitAction()
686{
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700687 while (!m_chatDialogList.empty()) {
688 ChatDialogList::const_iterator it = m_chatDialogList.begin();
689 onRemoveChatDialog(QString::fromStdString(it->first));
690 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800691
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700692 if (m_invitationListenerId != 0)
Yingdi Yu233a9722014-03-07 15:47:09 -0800693 m_face->unsetInterestFilter(m_invitationListenerId);
694
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800695 delete m_settingDialog;
696 delete m_startChatDialog;
697 delete m_profileEditor;
698 delete m_invitationDialog;
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700699 delete m_browseContactDialog;
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800700 delete m_addContactPanel;
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700701
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700702 m_face->getIoService().stop();
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800703
704 QApplication::quit();
705}
706
707void
708Controller::onStartChatroom(const QString& chatroomName, bool secured)
709{
710 Name chatroomPrefix;
711 chatroomPrefix.append("ndn")
712 .append("broadcast")
713 .append("ChronoChat")
714 .append(chatroomName.toStdString());
715
716 // check if the chatroom exists
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700717 if (m_chatDialogList.find(chatroomName.toStdString()) != m_chatDialogList.end()) {
718 QMessageBox::information(this, tr("ChronoChat"),
719 tr("You are creating an existing chatroom."
720 "You can check it in the context memu."));
721 return;
722 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800723
Mengjin Yan391d7242014-08-28 20:51:55 -0700724 // TODO: We should create a chatroom specific key/cert
725 //(which should be created in the first half of this method
726 //, but let's use the default one for now.
727 // std::cout << "start chat room localprefix: " << m_localPrefix.toUri() << std::endl;
728 shared_ptr<IdentityCertificate> idCert
729 = m_keyChain.getCertificate(m_keyChain.getDefaultCertificateNameForIdentity(m_identity));
730 ChatDialog* chatDialog
731 = new ChatDialog(&m_contactManager, m_face, *idCert, chatroomPrefix
732 , m_localPrefix, m_nick, secured);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800733
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700734 addChatDialog(chatroomName, chatDialog);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800735 chatDialog->show();
736}
737
738void
Mengjin Yan391d7242014-08-28 20:51:55 -0700739Controller::onInvitationResponded(const ndn::Name& invitationName, bool accepted)
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800740{
Yingdi Yu6c3c5962014-09-09 16:52:38 -0700741 shared_ptr<Data> response = make_shared<Data>();
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800742 shared_ptr<IdentityCertificate> chatroomCert;
743
744 // generate reply;
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700745 if (accepted) {
746 Name responseName = invitationName;
747 responseName.append(m_localPrefix.wireEncode());
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800748
Yingdi Yu6c3c5962014-09-09 16:52:38 -0700749 response->setName(responseName);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800750
Mengjin Yan391d7242014-08-28 20:51:55 -0700751 // We should create a particular certificate for this chatroom,
752 //but let's use default one for now.
753 chatroomCert
754 = m_keyChain.getCertificate(m_keyChain.getDefaultCertificateNameForIdentity(m_identity));
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800755
Yingdi Yu6c3c5962014-09-09 16:52:38 -0700756 response->setContent(chatroomCert->wireEncode());
757 response->setFreshnessPeriod(time::milliseconds(1000));
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700758 }
759 else {
Yingdi Yu6c3c5962014-09-09 16:52:38 -0700760 response->setName(invitationName);
761 response->setFreshnessPeriod(time::milliseconds(1000));
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700762 }
763
Yingdi Yu6c3c5962014-09-09 16:52:38 -0700764 m_keyChain.signByIdentity(*response, m_identity);
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700765
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800766 // Check if we need a wrapper
767 Name invitationRoutingPrefix = getInvitationRoutingPrefix();
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700768 if (invitationRoutingPrefix.isPrefixOf(m_identity))
Yingdi Yu6c3c5962014-09-09 16:52:38 -0700769 m_face->put(*response);
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700770 else {
771 Name wrappedName;
772 wrappedName.append(invitationRoutingPrefix)
773 .append(ROUTING_PREFIX_SEPARATOR, 2)
Yingdi Yu6c3c5962014-09-09 16:52:38 -0700774 .append(response->getName());
Yingdi Yu233a9722014-03-07 15:47:09 -0800775
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700776 // _LOG_DEBUG("onInvitationResponded: prepare reply " << wrappedName);
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700777
Yingdi Yu6c3c5962014-09-09 16:52:38 -0700778 shared_ptr<Data> wrappedData = make_shared<Data>(wrappedName);
779 wrappedData->setContent(response->wireEncode());
780 wrappedData->setFreshnessPeriod(time::milliseconds(1000));
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800781
Yingdi Yu6c3c5962014-09-09 16:52:38 -0700782 m_keyChain.signByIdentity(*wrappedData, m_identity);
783 m_face->put(*wrappedData);
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700784 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800785
786 // create chatroom
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700787 if (accepted) {
788 Invitation invitation(invitationName);
789 Name chatroomPrefix;
790 chatroomPrefix.append("ndn")
791 .append("broadcast")
792 .append("ChronoChat")
793 .append(invitation.getChatroom());
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800794
Mengjin Yan391d7242014-08-28 20:51:55 -0700795 //We should create a chatroom specific key/cert
796 //(which should be created in the first half of this method,
797 //but let's use the default one for now.
798 shared_ptr<IdentityCertificate> idCert
799 = m_keyChain.getCertificate(m_keyChain.getDefaultCertificateNameForIdentity(m_identity));
800 ChatDialog* chatDialog
801 = new ChatDialog(&m_contactManager, m_face, *idCert,
802 chatroomPrefix, m_localPrefix, m_nick, true);
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700803 chatDialog->addSyncAnchor(invitation);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800804
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700805 addChatDialog(QString::fromStdString(invitation.getChatroom()), chatDialog);
806 chatDialog->show();
807 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800808}
809
810void
811Controller::onShowChatMessage(const QString& chatroomName, const QString& from, const QString& data)
812{
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700813 m_trayIcon->showMessage(QString("Chatroom %1 has a new message").arg(chatroomName),
814 QString("<%1>: %2").arg(from).arg(data),
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800815 QSystemTrayIcon::Information, 20000);
816 m_trayIcon->setIcon(QIcon(":/images/note.png"));
817}
818
819void
Yingdi Yu233a9722014-03-07 15:47:09 -0800820Controller::onResetIcon()
821{
822 m_trayIcon->setIcon(QIcon(":/images/icon_small.png"));
823}
824
825void
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800826Controller::onRemoveChatDialog(const QString& chatroomName)
827{
828 ChatDialogList::iterator it = m_chatDialogList.find(chatroomName.toStdString());
829
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700830 if (it != m_chatDialogList.end()) {
831 ChatDialog* deletedChat = it->second;
832 if (deletedChat)
833 delete deletedChat;
834 m_chatDialogList.erase(it);
Mengjin Yan391d7242014-08-28 20:51:55 -0700835 m_discoveryLogic.removeLocalChatroom(Name::Component(chatroomName.toStdString()));
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800836
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700837 QAction* chatAction = m_chatActionList[chatroomName.toStdString()];
838 QAction* closeAction = m_closeActionList[chatroomName.toStdString()];
839 if (chatAction)
840 delete chatAction;
841 if (closeAction)
842 delete closeAction;
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700843
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700844 m_chatActionList.erase(chatroomName.toStdString());
845 m_closeActionList.erase(chatroomName.toStdString());
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700846
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700847 updateMenu();
848 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800849}
850
851void
852Controller::onWarning(const QString& msg)
853{
854 QMessageBox::information(this, tr("ChronoChat"), msg);
855}
856
857void
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700858Controller::onError(const QString& msg)
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800859{
860 QMessageBox::critical(this, tr("ChronoChat"), msg, QMessageBox::Ok);
861 exit(1);
862}
863
Yingdi Yu233a9722014-03-07 15:47:09 -0800864void
Mengjin Yan391d7242014-08-28 20:51:55 -0700865Controller::onInvitationInterest(const ndn::Name& prefix,
866 const ndn::Interest& interest,
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700867 size_t routingPrefixOffset)
Yingdi Yu233a9722014-03-07 15:47:09 -0800868{
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700869 // _LOG_DEBUG("onInvitationInterest: " << interest.getName());
870 shared_ptr<Interest> invitationInterest =
871 make_shared<Interest>(boost::cref(interest.getName().getSubName(routingPrefixOffset)));
Yingdi Yu233a9722014-03-07 15:47:09 -0800872
873 // check if the chatroom already exists;
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700874 try {
Yingdi Yu233a9722014-03-07 15:47:09 -0800875 Invitation invitation(invitationInterest->getName());
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700876 if (m_chatDialogList.find(invitation.getChatroom()) != m_chatDialogList.end())
Yingdi Yu233a9722014-03-07 15:47:09 -0800877 return;
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700878 }
879 catch (Invitation::Error& e) {
880 // Cannot parse the invitation;
881 return;
882 }
Yingdi Yu233a9722014-03-07 15:47:09 -0800883
884 OnInterestValidated onValidated = bind(&Controller::onInvitationValidated, this, _1);
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700885 OnInterestValidationFailed onValidationFailed = bind(&Controller::onInvitationValidationFailed,
886 this, _1, _2);
Yingdi Yu233a9722014-03-07 15:47:09 -0800887 m_validator.validate(*invitationInterest, onValidated, onValidationFailed);
888}
889
Mengjin Yan391d7242014-08-28 20:51:55 -0700890void
891Controller::onRosterChanged(const chronos::ChatroomInfo& info)
892{
893 m_discoveryLogic.addLocalChatroom(info);
894}
895
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800896} // namespace chronos
897
898#if WAF
899#include "controller.moc"
Yingdi Yu42125862014-08-07 17:04:28 -0700900// #include "controller.cpp.moc"
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800901#endif