/* -*- 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_MANAGER_H
#define LINKNDN_CONTACT_MANAGER_H

#include <QObject>

#ifndef Q_MOC_RUN
#include "contact-storage.h"
#include "dns-storage.h"
#include "endorse-certificate.h"
#include "profile.h"
#include <ndn.cxx/wrapper/wrapper.h>
#endif


class ContactManager : public QObject
{
  Q_OBJECT

public:
  ContactManager(ndn::Ptr<ContactStorage> contactStorage,
                 ndn::Ptr<DnsStorage> dnsStorage,
                 QObject* parent = 0);

  ~ContactManager();

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

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

  std::vector<ndn::Ptr<ContactItem> >
  getContactItemList();

  inline ndn::Ptr<ContactStorage>
  getContactStorage()
  { return m_contactStorage; }

  inline ndn::Ptr<DnsStorage>
  getDnsStorage()
  { return m_dnsStorage; }

  inline ndn::Name
  getDefaultIdentity()
  { return m_keychain->getDefaultIdentity(); }

  inline ndn::Ptr<ndn::Wrapper>
  getWrapper()
  { return m_wrapper; }

private:
  void
  setKeychain();

  ndn::Ptr<EndorseCertificate>
  getSignedSelfEndorseCertificate(const ndn::Name& identity, const Profile& profile);

  void
  publishSelfEndorseCertificateInDNS(ndn::Ptr<EndorseCertificate> selfEndorseCertificate);

  void 
  onDnsSelfEndorseCertificateVerified(ndn::Ptr<ndn::Data> selfEndorseCertificate, const ndn::Name& identity);

  void
  onDnsSelfEndorseCertificateUnverified(ndn::Ptr<ndn::Data> selfEndorseCertificate, const ndn::Name& identity);

  void
  onDnsSelfEndorseCertificateTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest, const ndn::Name& identity, int retry);

signals:
  void 
  contactFetched(const EndorseCertificate& endorseCertificate);
  
  void
  contactFetchFailed(const ndn::Name& identity);

private slots:
  
  
private:
  ndn::Ptr<ContactStorage> m_contactStorage;
  ndn::Ptr<DnsStorage> m_dnsStorage;
  ndn::Ptr<ndn::security::Keychain> m_keychain;
  ndn::Ptr<ndn::Wrapper> m_wrapper;
};

#endif
