blob: 465a1cc11a574dfe2c331bde6ecaa1722f6b7ee3 [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 Yu79c25a22013-10-21 13:38:38 -070020#include "profile.h"
Yingdi Yu590fa5d2013-10-18 18:35:09 -070021#include <ndn.cxx/wrapper/wrapper.h>
Yingdi Yuaa8d7692013-10-18 17:05:02 -070022#endif
23
24
25class ContactManager : public QObject
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070026{
Yingdi Yuaa8d7692013-10-18 17:05:02 -070027 Q_OBJECT
28
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070029public:
Yingdi Yuaa8d7692013-10-18 17:05:02 -070030 ContactManager(ndn::Ptr<ContactStorage> contactStorage,
Yingdi Yu590fa5d2013-10-18 18:35:09 -070031 ndn::Ptr<DnsStorage> dnsStorage,
32 QObject* parent = 0);
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070033
34 ~ContactManager();
35
Yingdi Yuaa8d7692013-10-18 17:05:02 -070036 void
37 fetchSelfEndorseCertificate(const ndn::Name& identity);
38
39 void
40 updateProfileData(const ndn::Name& identity);
41
Yingdi Yu79c25a22013-10-21 13:38:38 -070042 std::vector<ndn::Ptr<ContactItem> >
43 getContactItemList();
44
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070045 inline ndn::Ptr<ContactStorage>
46 getContactStorage()
47 { return m_contactStorage; }
48
Yingdi Yud40226b2013-10-23 14:05:12 -070049 ndn::Ptr<ContactItem>
50 getContact(const ndn::Name& contactNamespace);
51
Yingdi Yuaa8d7692013-10-18 17:05:02 -070052 inline ndn::Ptr<DnsStorage>
53 getDnsStorage()
54 { return m_dnsStorage; }
55
56 inline ndn::Name
57 getDefaultIdentity()
58 { return m_keychain->getDefaultIdentity(); }
59
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070060 inline ndn::Ptr<ndn::Wrapper>
61 getWrapper()
62 { return m_wrapper; }
63
64private:
Yingdi Yuaa8d7692013-10-18 17:05:02 -070065 void
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070066 setKeychain();
Yingdi Yuaa8d7692013-10-18 17:05:02 -070067
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
83signals:
84 void
Yingdi Yu79c25a22013-10-21 13:38:38 -070085 contactFetched(const EndorseCertificate& endorseCertificate);
Yingdi Yuaa8d7692013-10-18 17:05:02 -070086
87 void
88 contactFetchFailed(const ndn::Name& identity);
89
90private slots:
91
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070092
93private:
94 ndn::Ptr<ContactStorage> m_contactStorage;
Yingdi Yuaa8d7692013-10-18 17:05:02 -070095 ndn::Ptr<DnsStorage> m_dnsStorage;
96 ndn::Ptr<ndn::security::Keychain> m_keychain;
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070097 ndn::Ptr<ndn::Wrapper> m_wrapper;
98};
99
100#endif