blob: 666cf9b19445053e916f6f7d1985579aea942a24 [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 Yuaa8d7692013-10-18 17:05:02 -070049 inline ndn::Ptr<DnsStorage>
50 getDnsStorage()
51 { return m_dnsStorage; }
52
53 inline ndn::Name
54 getDefaultIdentity()
55 { return m_keychain->getDefaultIdentity(); }
56
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070057 inline ndn::Ptr<ndn::Wrapper>
58 getWrapper()
59 { return m_wrapper; }
60
61private:
Yingdi Yuaa8d7692013-10-18 17:05:02 -070062 void
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070063 setKeychain();
Yingdi Yuaa8d7692013-10-18 17:05:02 -070064
65 ndn::Ptr<EndorseCertificate>
66 getSignedSelfEndorseCertificate(const ndn::Name& identity, const Profile& profile);
67
68 void
69 publishSelfEndorseCertificateInDNS(ndn::Ptr<EndorseCertificate> selfEndorseCertificate);
70
71 void
72 onDnsSelfEndorseCertificateVerified(ndn::Ptr<ndn::Data> selfEndorseCertificate, const ndn::Name& identity);
73
74 void
75 onDnsSelfEndorseCertificateUnverified(ndn::Ptr<ndn::Data> selfEndorseCertificate, const ndn::Name& identity);
76
77 void
78 onDnsSelfEndorseCertificateTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest, const ndn::Name& identity, int retry);
79
80signals:
81 void
Yingdi Yu79c25a22013-10-21 13:38:38 -070082 contactFetched(const EndorseCertificate& endorseCertificate);
Yingdi Yuaa8d7692013-10-18 17:05:02 -070083
84 void
85 contactFetchFailed(const ndn::Name& identity);
86
87private slots:
88
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070089
90private:
91 ndn::Ptr<ContactStorage> m_contactStorage;
Yingdi Yuaa8d7692013-10-18 17:05:02 -070092 ndn::Ptr<DnsStorage> m_dnsStorage;
93 ndn::Ptr<ndn::security::Keychain> m_keychain;
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070094 ndn::Ptr<ndn::Wrapper> m_wrapper;
95};
96
97#endif