blob: 1cde4bc401fb3fb01702e4e81ea9bc52a87f1980 [file] [log] [blame]
Yingdi Yu0b82a4e2013-10-18 11:29:25 -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#ifndef LINKNDN_CONTACT_MANAGER_H
12#define LINKNDN_CONTACT_MANAGER_H
13
Yingdi Yuaa8d7692013-10-18 17:05:02 -070014#include <QObject>
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070015
Yingdi Yuaa8d7692013-10-18 17:05:02 -070016#ifndef Q_MOC_RUN
17#include "contact-storage.h"
18#include "dns-storage.h"
19#include "endorse-certificate.h"
20#include "ndn.cxx/wrapper/wrapper.h"
21#endif
22
23
24class ContactManager : public QObject
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070025{
Yingdi Yuaa8d7692013-10-18 17:05:02 -070026 Q_OBJECT
27
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070028public:
Yingdi Yuaa8d7692013-10-18 17:05:02 -070029 ContactManager(ndn::Ptr<ContactStorage> contactStorage,
30 ndn::Ptr<DnsStorage> dnsStorage);
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070031
32 ~ContactManager();
33
Yingdi Yuaa8d7692013-10-18 17:05:02 -070034 void
35 fetchSelfEndorseCertificate(const ndn::Name& identity);
36
37 void
38 updateProfileData(const ndn::Name& identity);
39
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070040 inline ndn::Ptr<ContactStorage>
41 getContactStorage()
42 { return m_contactStorage; }
43
Yingdi Yuaa8d7692013-10-18 17:05:02 -070044 inline ndn::Ptr<DnsStorage>
45 getDnsStorage()
46 { return m_dnsStorage; }
47
48 inline ndn::Name
49 getDefaultIdentity()
50 { return m_keychain->getDefaultIdentity(); }
51
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070052 inline ndn::Ptr<ndn::Wrapper>
53 getWrapper()
54 { return m_wrapper; }
55
56private:
Yingdi Yuaa8d7692013-10-18 17:05:02 -070057 void
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070058 setKeychain();
Yingdi Yuaa8d7692013-10-18 17:05:02 -070059
60 ndn::Ptr<EndorseCertificate>
61 getSignedSelfEndorseCertificate(const ndn::Name& identity, const Profile& profile);
62
63 void
64 publishSelfEndorseCertificateInDNS(ndn::Ptr<EndorseCertificate> selfEndorseCertificate);
65
66 void
67 onDnsSelfEndorseCertificateVerified(ndn::Ptr<ndn::Data> selfEndorseCertificate, const ndn::Name& identity);
68
69 void
70 onDnsSelfEndorseCertificateUnverified(ndn::Ptr<ndn::Data> selfEndorseCertificate, const ndn::Name& identity);
71
72 void
73 onDnsSelfEndorseCertificateTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest, const ndn::Name& identity, int retry);
74
75signals:
76 void
77 contactFetched(ndn::Ptr<EndorseCertificate> selfEndorseCertificate);
78
79 void
80 contactFetchFailed(const ndn::Name& identity);
81
82private slots:
83
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070084
85private:
86 ndn::Ptr<ContactStorage> m_contactStorage;
Yingdi Yuaa8d7692013-10-18 17:05:02 -070087 ndn::Ptr<DnsStorage> m_dnsStorage;
88 ndn::Ptr<ndn::security::Keychain> m_keychain;
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070089 ndn::Ptr<ndn::Wrapper> m_wrapper;
90};
91
92#endif