Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -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 | #ifndef LINKNDN_CONTACT_MANAGER_H |
| 12 | #define LINKNDN_CONTACT_MANAGER_H |
| 13 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 14 | #include <QObject> |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 15 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 16 | #ifndef Q_MOC_RUN |
| 17 | #include "contact-storage.h" |
| 18 | #include "dns-storage.h" |
| 19 | #include "endorse-certificate.h" |
Yingdi Yu | 590fa5d | 2013-10-18 18:35:09 -0700 | [diff] [blame] | 20 | #include <ndn.cxx/wrapper/wrapper.h> |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 21 | #endif |
| 22 | |
| 23 | |
| 24 | class ContactManager : public QObject |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 25 | { |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 26 | Q_OBJECT |
| 27 | |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 28 | public: |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 29 | ContactManager(ndn::Ptr<ContactStorage> contactStorage, |
Yingdi Yu | 590fa5d | 2013-10-18 18:35:09 -0700 | [diff] [blame] | 30 | ndn::Ptr<DnsStorage> dnsStorage, |
| 31 | QObject* parent = 0); |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 32 | |
| 33 | ~ContactManager(); |
| 34 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 35 | void |
| 36 | fetchSelfEndorseCertificate(const ndn::Name& identity); |
| 37 | |
| 38 | void |
| 39 | updateProfileData(const ndn::Name& identity); |
| 40 | |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 41 | inline ndn::Ptr<ContactStorage> |
| 42 | getContactStorage() |
| 43 | { return m_contactStorage; } |
| 44 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 45 | inline ndn::Ptr<DnsStorage> |
| 46 | getDnsStorage() |
| 47 | { return m_dnsStorage; } |
| 48 | |
| 49 | inline ndn::Name |
| 50 | getDefaultIdentity() |
| 51 | { return m_keychain->getDefaultIdentity(); } |
| 52 | |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 53 | inline ndn::Ptr<ndn::Wrapper> |
| 54 | getWrapper() |
| 55 | { return m_wrapper; } |
| 56 | |
| 57 | private: |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 58 | void |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 59 | setKeychain(); |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 60 | |
| 61 | ndn::Ptr<EndorseCertificate> |
| 62 | getSignedSelfEndorseCertificate(const ndn::Name& identity, const Profile& profile); |
| 63 | |
| 64 | void |
| 65 | publishSelfEndorseCertificateInDNS(ndn::Ptr<EndorseCertificate> selfEndorseCertificate); |
| 66 | |
| 67 | void |
| 68 | onDnsSelfEndorseCertificateVerified(ndn::Ptr<ndn::Data> selfEndorseCertificate, const ndn::Name& identity); |
| 69 | |
| 70 | void |
| 71 | onDnsSelfEndorseCertificateUnverified(ndn::Ptr<ndn::Data> selfEndorseCertificate, const ndn::Name& identity); |
| 72 | |
| 73 | void |
| 74 | onDnsSelfEndorseCertificateTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest, const ndn::Name& identity, int retry); |
| 75 | |
| 76 | signals: |
| 77 | void |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame^] | 78 | contactFetched(const EndorseCertificate& selfEndorseCertificate); |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 79 | |
| 80 | void |
| 81 | contactFetchFailed(const ndn::Name& identity); |
| 82 | |
| 83 | private slots: |
| 84 | |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 85 | |
| 86 | private: |
| 87 | ndn::Ptr<ContactStorage> m_contactStorage; |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 88 | ndn::Ptr<DnsStorage> m_dnsStorage; |
| 89 | ndn::Ptr<ndn::security::Keychain> m_keychain; |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 90 | ndn::Ptr<ndn::Wrapper> m_wrapper; |
| 91 | }; |
| 92 | |
| 93 | #endif |