| /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| /* |
| * Copyright (c) 2013, Regents of the University of California |
| * Yingdi Yu |
| * |
| * BSD license, See the LICENSE file for more information |
| * |
| * Author: Yingdi Yu <yingdi@cs.ucla.edu> |
| */ |
| |
| #ifndef LINKNDN_CONTACT_MANAGER_H |
| #define LINKNDN_CONTACT_MANAGER_H |
| |
| #include <QObject> |
| |
| #ifndef Q_MOC_RUN |
| #include "contact-storage.h" |
| #include "dns-storage.h" |
| #include "endorse-certificate.h" |
| #include "profile.h" |
| #include <ndn-cpp-dev/face.hpp> |
| #include <ndn-cpp-dev/security/key-chain.hpp> |
| #include <ndn-cpp-dev/security/verifier.hpp> |
| #endif |
| |
| typedef ndn::func_lib::function<void()> TimeoutNotify; |
| |
| class ContactManager : public QObject |
| { |
| Q_OBJECT |
| |
| public: |
| ContactManager(ndn::ptr_lib::shared_ptr<ndn::KeyChain> keyChain, |
| ndn::ptr_lib::shared_ptr<ndn::Face> m_face, |
| QObject* parent = 0); |
| |
| ~ContactManager(); |
| |
| void |
| fetchSelfEndorseCertificate(const ndn::Name& identity); |
| |
| void |
| fetchKey(const ndn::Name& identity); |
| |
| void |
| fetchCollectEndorse(const ndn::Name& identity); |
| |
| void |
| fetchIdCertificate(const ndn::Name& certName); |
| |
| void |
| updateProfileData(const ndn::Name& identity); |
| |
| void |
| updateEndorseCertificate(const ndn::Name& identity, const ndn::Name& signerIdentity); |
| |
| void |
| getContactItemList(std::vector<ndn::ptr_lib::shared_ptr<ContactItem> >& contacts); |
| |
| ndn::ptr_lib::shared_ptr<ContactStorage> |
| getContactStorage() |
| { return m_contactStorage; } |
| |
| ndn::ptr_lib::shared_ptr<ContactItem> |
| getContact(const ndn::Name& contactNamespace); |
| |
| ndn::ptr_lib::shared_ptr<DnsStorage> |
| getDnsStorage() |
| { return m_dnsStorage; } |
| |
| ndn::Name |
| getDefaultIdentity() |
| { return m_keyChain->getDefaultIdentity(); } |
| |
| void |
| publishEndorsedDataInDns(const ndn::Name& identity); |
| |
| void |
| setDefaultIdentity(const ndn::Name& identity) |
| { m_defaultIdentity = identity; } |
| |
| void |
| addContact(const ndn::IdentityCertificate& idCert, const Profile& profile); |
| |
| void |
| removeContact(const ndn::Name& contactNameSpace); |
| |
| // ndn::ptr_lib::shared_ptr<ndn::KeyChain> |
| // getKeyChain() |
| // { return m_keyChain; } |
| |
| private: |
| void |
| initializeSecurity(); |
| |
| ndn::ptr_lib::shared_ptr<EndorseCertificate> |
| getSignedSelfEndorseCertificate(const ndn::Name& identity, const Profile& profile); |
| |
| ndn::ptr_lib::shared_ptr<EndorseCertificate> |
| generateEndorseCertificate(const ndn::Name& identity, const ndn::Name& signerIdentity); |
| |
| void |
| publishSelfEndorseCertificateInDNS(const EndorseCertificate& selfEndorseCertificate); |
| |
| void |
| publishEndorseCertificateInDNS(const EndorseCertificate& endorseCertificate, const ndn::Name& signerIdentity); |
| |
| void |
| sendInterest(const ndn::Interest& interest, |
| const ndn::OnVerified& onVerified, |
| const ndn::OnVerifyFailed& onVerifyFailed, |
| const TimeoutNotify& timeoutNotify, |
| int retry = 1); |
| |
| void |
| onTargetData(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, |
| const ndn::ptr_lib::shared_ptr<ndn::Data>& data, |
| const ndn::OnVerified& onVerified, |
| const ndn::OnVerifyFailed& onVerifyFailed); |
| |
| void |
| onTargetTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, |
| int retry, |
| const ndn::OnVerified& onVerified, |
| const ndn::OnVerifyFailed& onVerifyFailed, |
| const TimeoutNotify& timeoutNotify); |
| |
| |
| void |
| onDnsSelfEndorseCertificateTimeoutNotify(const ndn::Name& identity); |
| |
| void |
| onDnsSelfEndorseCertificateVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& selfEndorseCertificate, const ndn::Name& identity); |
| |
| void |
| onDnsSelfEndorseCertificateVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& selfEndorseCertificate, const ndn::Name& identity); |
| |
| |
| void |
| onDnsCollectEndorseVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, const ndn::Name& identity); |
| |
| void |
| onDnsCollectEndorseVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, const ndn::Name& identity); |
| |
| void |
| onDnsCollectEndorseTimeoutNotify(const ndn::Name& identity); |
| |
| |
| void |
| onKeyVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, const ndn::Name& identity); |
| |
| void |
| onKeyVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, const ndn::Name& identity); |
| |
| void |
| onKeyTimeoutNotify(const ndn::Name& identity); |
| |
| |
| void |
| onIdCertificateVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, const ndn::Name& identity); |
| |
| void |
| onIdCertificateVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, const ndn::Name& identity); |
| |
| void |
| onIdCertificateTimeoutNotify(const ndn::Name& identity); |
| |
| |
| signals: |
| void |
| noNdnConnection(const QString& msg); |
| |
| void |
| contactFetched(const EndorseCertificate& endorseCertificate); |
| |
| void |
| contactFetchFailed(const ndn::Name& identity); |
| |
| void |
| contactKeyFetched(const EndorseCertificate& endorseCertificate); |
| |
| void |
| contactKeyFetchFailed(const ndn::Name& identity); |
| |
| void |
| contactCertificateFetched(const ndn::IdentityCertificate& identityCertificate); |
| |
| void |
| contactCertificateFetchFailed(const ndn::Name& identity); |
| |
| void |
| collectEndorseFetched(const ndn::Data& data); |
| |
| void |
| collectEndorseFetchFailed(const ndn::Name& identity); |
| |
| void |
| warning(QString msg); |
| |
| void |
| contactRemoved(const ndn::Name& identity); |
| |
| void |
| contactAdded(const ndn::Name& identity); |
| |
| private slots: |
| |
| |
| private: |
| |
| ndn::ptr_lib::shared_ptr<ContactStorage> m_contactStorage; |
| ndn::ptr_lib::shared_ptr<DnsStorage> m_dnsStorage; |
| ndn::ptr_lib::shared_ptr<ndn::Verifier> m_verifier; |
| ndn::ptr_lib::shared_ptr<ndn::KeyChain> m_keyChain; |
| ndn::ptr_lib::shared_ptr<ndn::Face> m_face; |
| ndn::Name m_defaultIdentity; |
| }; |
| |
| #endif |