blob: 882dff56653c8a21993f7fc59d27cfde45ab2254 [file] [log] [blame]
Yingdi Yuede8eaf2013-10-14 14:07:03 -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_STORAGE_H
12#define LINKNDN_CONTACT_STORAGE_H
13
14#include <sqlite3.h>
Yingdi Yuede8eaf2013-10-14 14:07:03 -070015#include "contact-item.h"
Yingdi Yu68aced92013-10-17 21:13:03 -070016#include "endorse-certificate.h"
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070017#include <ndn.cxx/security/identity/identity-manager.h>
18#include <ndn.cxx/fields/signature-sha256-with-rsa.h>
Yingdi Yuede8eaf2013-10-14 14:07:03 -070019
Yingdi Yuaa8d7692013-10-18 17:05:02 -070020
Yingdi Yuede8eaf2013-10-14 14:07:03 -070021class ContactStorage
22{
Yingdi Yuaa8d7692013-10-18 17:05:02 -070023
Yingdi Yuede8eaf2013-10-14 14:07:03 -070024public:
Yingdi Yuaa8d7692013-10-18 17:05:02 -070025 ContactStorage();
Yingdi Yuede8eaf2013-10-14 14:07:03 -070026
Yingdi Yuaa8d7692013-10-18 17:05:02 -070027 ~ContactStorage()
28 {sqlite3_close(m_db);}
Yingdi Yuede8eaf2013-10-14 14:07:03 -070029
30 void
Yingdi Yu49eea9f2013-10-17 15:07:17 -070031 setSelfProfileEntry(const ndn::Name& identity, const std::string& profileType, const ndn::Blob& profileValue);
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070032
33 ndn::Ptr<Profile>
Yingdi Yu49eea9f2013-10-17 15:07:17 -070034 getSelfProfile(const ndn::Name& identity);
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070035
36 void
Yingdi Yu813d4e92013-11-03 16:22:05 -080037 addContact(const ContactItem& contactItem);
Yingdi Yuede8eaf2013-10-14 14:07:03 -070038
Yingdi Yu79c25a22013-10-21 13:38:38 -070039 void
40 updateAlias(const ndn::Name& identity, std::string alias);
41
Yingdi Yuede8eaf2013-10-14 14:07:03 -070042 std::vector<ndn::Ptr<ContactItem> >
Yingdi Yu813d4e92013-11-03 16:22:05 -080043 getAllContacts() const;
Yingdi Yud40226b2013-10-23 14:05:12 -070044
45 ndn::Ptr<ContactItem>
Yingdi Yu813d4e92013-11-03 16:22:05 -080046 getContact(const ndn::Name& name);
Yingdi Yuaa8d7692013-10-18 17:05:02 -070047
48 ndn::Ptr<Profile>
49 getSelfProfile(const ndn::Name& identity) const;
50
51 ndn::Ptr<ndn::Blob>
52 getSelfEndorseCertificate(const ndn::Name& identity);
Yingdi Yuede8eaf2013-10-14 14:07:03 -070053
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070054 void
Yingdi Yuaa8d7692013-10-18 17:05:02 -070055 updateSelfEndorseCertificate(ndn::Ptr<EndorseCertificate> endorseCertificate, const ndn::Name& identity);
56
57 void
58 addSelfEndorseCertificate(ndn::Ptr<EndorseCertificate> endorseCertificate, const ndn::Name& identity);
Yingdi Yuc26af3c2013-10-17 17:03:46 -070059
Yingdi Yuede8eaf2013-10-14 14:07:03 -070060private:
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070061 bool
Yingdi Yu49eea9f2013-10-17 15:07:17 -070062 doesSelfEntryExist(const ndn::Name& identity, const std::string& profileType);
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070063
Yingdi Yuede8eaf2013-10-14 14:07:03 -070064 bool
Yingdi Yu813d4e92013-11-03 16:22:05 -080065 doesContactExist(const ndn::Name& name);
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070066
Yingdi Yuede8eaf2013-10-14 14:07:03 -070067private:
Yingdi Yuede8eaf2013-10-14 14:07:03 -070068 sqlite3 *m_db;
69};
70
71#endif