blob: 0ed7fc25f98f622b1f4725b1a273df5adfc0843c [file] [log] [blame]
Yingdi Yu847aa862013-10-09 16:35:53 -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
11#include <QApplication>
12#include <QSystemTrayIcon>
13
Yingdi Yu847aa862013-10-09 16:35:53 -070014#include "contactpanel.h"
Yingdi Yu3b318c12013-10-15 17:54:00 -070015#include "contact-storage.h"
Yingdi Yu4685b1b2013-10-18 17:05:02 -070016#include "dns-storage.h"
Yingdi Yu9236c432013-10-18 11:29:25 -070017#include "contact-manager.h"
Yingdi Yu46948282013-11-06 18:43:31 -080018#include "logging.h"
Yingdi Yu3b318c12013-10-15 17:54:00 -070019#include <ndn.cxx/security/identity/identity-manager.h>
20#include <ndn.cxx/security/identity/osx-privatekey-storage.h>
21#include <ndn.cxx/security/identity/basic-identity-storage.h>
22
Yingdi Yu46948282013-11-06 18:43:31 -080023INIT_LOGGER("MAIN");
24
Yingdi Yu3b318c12013-10-15 17:54:00 -070025using namespace ndn;
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070026
Yingdi Yu7989eb22013-10-31 17:38:22 -070027class NewApp : public QApplication
28{
29public:
30 NewApp(int & argc, char ** argv)
31 : QApplication(argc, argv)
Yingdi Yu46948282013-11-06 18:43:31 -080032 { }
Yingdi Yu7989eb22013-10-31 17:38:22 -070033
34 bool notify(QObject * receiver, QEvent * event)
35 {
36 try
37 {
38 return QApplication::notify(receiver, event);
39 }
40 catch(std::exception& e)
41 {
42 std::cerr << "Exception thrown:" << e.what() << endl;
43 return false;
44 }
45
46 }
47};
48
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070049int main(int argc, char *argv[])
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070050{
Yingdi Yu7989eb22013-10-31 17:38:22 -070051 NewApp app(argc, argv);
Zhenkai Zhu3a008fc2012-06-08 17:36:39 -070052
Yingdi Yu46948282013-11-06 18:43:31 -080053 // app.setWindowIcon(QIcon(":/demo.icns"));
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070054
Yingdi Yu72781e52013-11-06 23:00:21 -080055 Ptr<ContactStorage> contactStorage = NULL;
Yingdi Yue35bdb82013-11-07 11:32:40 -080056 Ptr<DnsStorage> dnsStorage = NULL;
Yingdi Yu72781e52013-11-06 23:00:21 -080057 try{
58 contactStorage = Ptr<ContactStorage>::Create();
Yingdi Yue35bdb82013-11-07 11:32:40 -080059 dnsStorage = Ptr<DnsStorage>::Create();
Yingdi Yu72781e52013-11-06 23:00:21 -080060 }catch(std::exception& e){
61 std::cerr << e.what() << std::endl;
62 exit(1);
63 }
Yingdi Yue35bdb82013-11-07 11:32:40 -080064
Yingdi Yu4685b1b2013-10-18 17:05:02 -070065 Ptr<ContactManager> contactManager = Ptr<ContactManager>(new ContactManager(contactStorage, dnsStorage));
Yingdi Yu72781e52013-11-06 23:00:21 -080066
Yingdi Yu4685b1b2013-10-18 17:05:02 -070067 ContactPanel contactPanel(contactManager);
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070068
Yingdi Yu847aa862013-10-09 16:35:53 -070069 contactPanel.show ();
70 contactPanel.activateWindow ();
71 contactPanel.raise ();
72
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070073 return app.exec();
74}