/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2013, Regents of the University of California
 *                     Yingdi Yu
 *
 * BSD license, See the LICENSE file for more information
 *
 * Author: Yingdi Yu <yingdi@cs.ucla.edu>
 */

#ifndef LINKNDN_CONTACT_STORAGE_H
#define LINKNDN_CONTACT_STORAGE_H

#include <sqlite3.h>
#include "trusted-contact.h"
#include "contact-item.h"
#include "profile-data.h"
#include <ndn.cxx/security/identity/identity-manager.h>
#include <ndn.cxx/fields/signature-sha256-with-rsa.h>

class ContactStorage
{
public:
  ContactStorage(ndn::Ptr<ndn::security::IdentityManager> identityManager);
  
  ~ContactStorage() {}

  void
  setSelfProfileIdentity(const ndn::Name& identity);

  void
  setSelfProfileEntry(const std::string& profileType, const ndn::Blob& profileValue);

  ndn::Ptr<Profile>
  getSelfProfile();

  void
  addTrustedContact(const TrustedContact& trustedContact);
  
  void
  addNormalContact(const ContactItem& contactItem);

  std::vector<ndn::Ptr<TrustedContact> >
  getAllTrustedContacts() const;

  std::vector<ndn::Ptr<ContactItem> >
  getAllNormalContacts() const;

  void
  updateProfileData() const;

private:
  bool
  doesSelfEntryExist(const std::string& profileType);

  inline bool
  doesTrustedContactExist(const ndn::Name& name)
  { return doesContactExist(name, false); }

  inline bool
  doesNormalContactExist(const ndn::Name& name)
  { return doesContactExist(name, true); }

  bool
  doesContactExist(const ndn::Name& name, bool normal);

  ndn::Ptr<Profile>
  getSelfProfile() const;

  ndn::Ptr<ProfileData>
  getSignedSelfProfileData(const ndn::Name& identity,
                           const Profile& profile) const;
  
private:
  ndn::Ptr<ndn::security::IdentityManager> m_identityManager;
  sqlite3 *m_db;
};

#endif
