Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 1 | /* -*- 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 Yu | def9061 | 2013-10-09 22:34:42 -0700 | [diff] [blame] | 12 | #include <QSystemTrayIcon> |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 13 | |
Yingdi Yu | 9e0dc29 | 2013-10-10 11:39:45 -0700 | [diff] [blame] | 14 | #include "contactpanel.h" |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 15 | #include "contact-storage.h" |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 16 | #include "dns-storage.h" |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 17 | #include "contact-manager.h" |
Yingdi Yu | 4237244 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 18 | #include "logging.h" |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 19 | #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 Yu | 4237244 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 23 | INIT_LOGGER("MAIN"); |
| 24 | |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 25 | using namespace ndn; |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 26 | |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 27 | class NewApp : public QApplication |
| 28 | { |
| 29 | public: |
| 30 | NewApp(int & argc, char ** argv) |
| 31 | : QApplication(argc, argv) |
Yingdi Yu | 4237244 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 32 | { } |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 33 | |
| 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 Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 49 | int main(int argc, char *argv[]) |
| 50 | { |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 51 | NewApp app(argc, argv); |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 52 | |
Yingdi Yu | 4237244 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 53 | // app.setWindowIcon(QIcon(":/demo.icns")); |
Yingdi Yu | def9061 | 2013-10-09 22:34:42 -0700 | [diff] [blame] | 54 | |
Yingdi Yu | 6a5b9f6 | 2013-11-06 23:00:21 -0800 | [diff] [blame] | 55 | Ptr<ContactStorage> contactStorage = NULL; |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 56 | Ptr<DnsStorage> dnsStorage = NULL; |
Yingdi Yu | 6a5b9f6 | 2013-11-06 23:00:21 -0800 | [diff] [blame] | 57 | try{ |
| 58 | contactStorage = Ptr<ContactStorage>::Create(); |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 59 | dnsStorage = Ptr<DnsStorage>::Create(); |
Yingdi Yu | 6a5b9f6 | 2013-11-06 23:00:21 -0800 | [diff] [blame] | 60 | }catch(std::exception& e){ |
| 61 | std::cerr << e.what() << std::endl; |
| 62 | exit(1); |
| 63 | } |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 64 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 65 | Ptr<ContactManager> contactManager = Ptr<ContactManager>(new ContactManager(contactStorage, dnsStorage)); |
Yingdi Yu | 6a5b9f6 | 2013-11-06 23:00:21 -0800 | [diff] [blame] | 66 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 67 | ContactPanel contactPanel(contactManager); |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 68 | |
Yingdi Yu | 9e0dc29 | 2013-10-10 11:39:45 -0700 | [diff] [blame] | 69 | contactPanel.show (); |
| 70 | contactPanel.activateWindow (); |
| 71 | contactPanel.raise (); |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 72 | |
| 73 | return app.exec(); |
| 74 | } |