blob: 42fd847c4298dd7c0a4ecc2c537fc631d1852705 [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"
Yingdi Yu590fa5d2013-10-18 18:35:09 -070020#include <ndn.cxx/wrapper/wrapper.h>
Yingdi Yuaa8d7692013-10-18 17:05:02 -070021#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,
Yingdi Yu590fa5d2013-10-18 18:35:09 -070030 ndn::Ptr<DnsStorage> dnsStorage,
31 QObject* parent = 0);
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070032
33 ~ContactManager();
34
Yingdi Yuaa8d7692013-10-18 17:05:02 -070035 void
36 fetchSelfEndorseCertificate(const ndn::Name& identity);
37
38 void
39 updateProfileData(const ndn::Name& identity);
40
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070041 inline ndn::Ptr<ContactStorage>
42 getContactStorage()
43 { return m_contactStorage; }
44
Yingdi Yuaa8d7692013-10-18 17:05:02 -070045 inline ndn::Ptr<DnsStorage>
46 getDnsStorage()
47 { return m_dnsStorage; }
48
49 inline ndn::Name
50 getDefaultIdentity()
51 { return m_keychain->getDefaultIdentity(); }
52
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070053 inline ndn::Ptr<ndn::Wrapper>
54 getWrapper()
55 { return m_wrapper; }
56
57private:
Yingdi Yuaa8d7692013-10-18 17:05:02 -070058 void
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070059 setKeychain();
Yingdi Yuaa8d7692013-10-18 17:05:02 -070060
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
76signals:
77 void
Yingdi Yuc29fb982013-10-20 19:43:10 -070078 contactFetched(const EndorseCertificate& selfEndorseCertificate);
Yingdi Yuaa8d7692013-10-18 17:05:02 -070079
80 void
81 contactFetchFailed(const ndn::Name& identity);
82
83private slots:
84
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070085
86private:
87 ndn::Ptr<ContactStorage> m_contactStorage;
Yingdi Yuaa8d7692013-10-18 17:05:02 -070088 ndn::Ptr<DnsStorage> m_dnsStorage;
89 ndn::Ptr<ndn::security::Keychain> m_keychain;
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070090 ndn::Ptr<ndn::Wrapper> m_wrapper;
91};
92
93#endif