Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 1 | /* -*- 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 Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 15 | #include "contact-item.h" |
Yingdi Yu | 68aced9 | 2013-10-17 21:13:03 -0700 | [diff] [blame] | 16 | #include "endorse-certificate.h" |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 17 | #include <ndn.cxx/security/identity/identity-manager.h> |
| 18 | #include <ndn.cxx/fields/signature-sha256-with-rsa.h> |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 19 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 20 | |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 21 | class ContactStorage |
| 22 | { |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 23 | |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 24 | public: |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 25 | ContactStorage(); |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 26 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 27 | ~ContactStorage() |
| 28 | {sqlite3_close(m_db);} |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 29 | |
| 30 | void |
Yingdi Yu | 49eea9f | 2013-10-17 15:07:17 -0700 | [diff] [blame] | 31 | setSelfProfileEntry(const ndn::Name& identity, const std::string& profileType, const ndn::Blob& profileValue); |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 32 | |
| 33 | ndn::Ptr<Profile> |
Yingdi Yu | 49eea9f | 2013-10-17 15:07:17 -0700 | [diff] [blame] | 34 | getSelfProfile(const ndn::Name& identity); |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 35 | |
| 36 | void |
Yingdi Yu | 813d4e9 | 2013-11-03 16:22:05 -0800 | [diff] [blame^] | 37 | addContact(const ContactItem& contactItem); |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 38 | |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 39 | void |
| 40 | updateAlias(const ndn::Name& identity, std::string alias); |
| 41 | |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 42 | std::vector<ndn::Ptr<ContactItem> > |
Yingdi Yu | 813d4e9 | 2013-11-03 16:22:05 -0800 | [diff] [blame^] | 43 | getAllContacts() const; |
Yingdi Yu | d40226b | 2013-10-23 14:05:12 -0700 | [diff] [blame] | 44 | |
| 45 | ndn::Ptr<ContactItem> |
Yingdi Yu | 813d4e9 | 2013-11-03 16:22:05 -0800 | [diff] [blame^] | 46 | getContact(const ndn::Name& name); |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 47 | |
| 48 | ndn::Ptr<Profile> |
| 49 | getSelfProfile(const ndn::Name& identity) const; |
| 50 | |
| 51 | ndn::Ptr<ndn::Blob> |
| 52 | getSelfEndorseCertificate(const ndn::Name& identity); |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 53 | |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 54 | void |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 55 | updateSelfEndorseCertificate(ndn::Ptr<EndorseCertificate> endorseCertificate, const ndn::Name& identity); |
| 56 | |
| 57 | void |
| 58 | addSelfEndorseCertificate(ndn::Ptr<EndorseCertificate> endorseCertificate, const ndn::Name& identity); |
Yingdi Yu | c26af3c | 2013-10-17 17:03:46 -0700 | [diff] [blame] | 59 | |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 60 | private: |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 61 | bool |
Yingdi Yu | 49eea9f | 2013-10-17 15:07:17 -0700 | [diff] [blame] | 62 | doesSelfEntryExist(const ndn::Name& identity, const std::string& profileType); |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 63 | |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 64 | bool |
Yingdi Yu | 813d4e9 | 2013-11-03 16:22:05 -0800 | [diff] [blame^] | 65 | doesContactExist(const ndn::Name& name); |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 66 | |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 67 | private: |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 68 | sqlite3 *m_db; |
| 69 | }; |
| 70 | |
| 71 | #endif |