blob: 0ed7fc25f98f622b1f4725b1a273df5adfc0843c [file] [log] [blame]
Yingdi Yu614db142013-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>
Yingdi Yudef90612013-10-09 22:34:42 -070012#include <QSystemTrayIcon>
Yingdi Yu614db142013-10-09 16:35:53 -070013
Yingdi Yu9e0dc292013-10-10 11:39:45 -070014#include "contactpanel.h"
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070015#include "contact-storage.h"
Yingdi Yuaa8d7692013-10-18 17:05:02 -070016#include "dns-storage.h"
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070017#include "contact-manager.h"
Yingdi Yu42372442013-11-06 18:43:31 -080018#include "logging.h"
Yingdi Yu0a6b6c52013-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 Yu42372442013-11-06 18:43:31 -080023INIT_LOGGER("MAIN");
24
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070025using namespace ndn;
Yingdi Yu614db142013-10-09 16:35:53 -070026
Yingdi Yu42f66462013-10-31 17:38:22 -070027class NewApp : public QApplication
28{
29public:
30 NewApp(int & argc, char ** argv)
31 : QApplication(argc, argv)
Yingdi Yu42372442013-11-06 18:43:31 -080032 { }
Yingdi Yu42f66462013-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
Yingdi Yu614db142013-10-09 16:35:53 -070049int main(int argc, char *argv[])
50{
Yingdi Yu42f66462013-10-31 17:38:22 -070051 NewApp app(argc, argv);
Yingdi Yu614db142013-10-09 16:35:53 -070052
Yingdi Yu42372442013-11-06 18:43:31 -080053 // app.setWindowIcon(QIcon(":/demo.icns"));
Yingdi Yudef90612013-10-09 22:34:42 -070054
Yingdi Yu6a5b9f62013-11-06 23:00:21 -080055 Ptr<ContactStorage> contactStorage = NULL;
Yingdi Yub35b8652013-11-07 11:32:40 -080056 Ptr<DnsStorage> dnsStorage = NULL;
Yingdi Yu6a5b9f62013-11-06 23:00:21 -080057 try{
58 contactStorage = Ptr<ContactStorage>::Create();
Yingdi Yub35b8652013-11-07 11:32:40 -080059 dnsStorage = Ptr<DnsStorage>::Create();
Yingdi Yu6a5b9f62013-11-06 23:00:21 -080060 }catch(std::exception& e){
61 std::cerr << e.what() << std::endl;
62 exit(1);
63 }
Yingdi Yub35b8652013-11-07 11:32:40 -080064
Yingdi Yuaa8d7692013-10-18 17:05:02 -070065 Ptr<ContactManager> contactManager = Ptr<ContactManager>(new ContactManager(contactStorage, dnsStorage));
Yingdi Yu6a5b9f62013-11-06 23:00:21 -080066
Yingdi Yuaa8d7692013-10-18 17:05:02 -070067 ContactPanel contactPanel(contactManager);
Yingdi Yu614db142013-10-09 16:35:53 -070068
Yingdi Yu9e0dc292013-10-10 11:39:45 -070069 contactPanel.show ();
70 contactPanel.activateWindow ();
71 contactPanel.raise ();
Yingdi Yu614db142013-10-09 16:35:53 -070072
73 return app.exec();
74}