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