blob: 13201ae3187f7ff330d9da4b21e540d5f3c00598 [file] [log] [blame]
Yingdi Yu53b8a9c2013-10-14 09:36:31 -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#include "contact-item.h"
Yingdi Yu53b8a9c2013-10-14 09:36:31 -070012
Yingdi Yu79c25a22013-10-21 13:38:38 -070013#include "logging.h"
14
Yingdi Yu53b8a9c2013-10-14 09:36:31 -070015using namespace std;
16using namespace ndn;
Yingdi Yu53b8a9c2013-10-14 09:36:31 -070017
Yingdi Yu79c25a22013-10-21 13:38:38 -070018INIT_LOGGER("ContactItem");
19
Yingdi Yua1a688f2014-02-06 18:09:22 -080020namespace chronos{
21
Yingdi Yu53b8a9c2013-10-14 09:36:31 -070022ContactItem::ContactItem(const EndorseCertificate& selfEndorseCertificate,
Yingdi Yu813d4e92013-11-03 16:22:05 -080023 bool isIntroducer,
Yingdi Yu53b8a9c2013-10-14 09:36:31 -070024 const string& alias)
25 : m_selfEndorseCertificate(selfEndorseCertificate)
Yingdi Yu813d4e92013-11-03 16:22:05 -080026 , m_isIntroducer(isIntroducer)
Yingdi Yu53b8a9c2013-10-14 09:36:31 -070027{
28 Name endorsedkeyName = selfEndorseCertificate.getPublicKeyName();
Yingdi Yu53b8a9c2013-10-14 09:36:31 -070029
30 m_namespace = endorsedkeyName.getSubName(0, endorsedkeyName.size() - 1);
Yingdi Yub35b8652013-11-07 11:32:40 -080031
Yingdi Yu53b8a9c2013-10-14 09:36:31 -070032
Yingdi Yua1a688f2014-02-06 18:09:22 -080033 m_name = selfEndorseCertificate.getProfile().get("name");
Yingdi Yub35b8652013-11-07 11:32:40 -080034 m_alias = alias.empty() ? m_name : alias;
Yingdi Yua1a688f2014-02-06 18:09:22 -080035 m_institution = selfEndorseCertificate.getProfile().get("institution");
Yingdi Yu53b8a9c2013-10-14 09:36:31 -070036}
37
Yingdi Yua50c3252013-11-03 15:05:26 -080038ContactItem::ContactItem(const ContactItem& contactItem)
39 : m_selfEndorseCertificate(contactItem.m_selfEndorseCertificate)
40 , m_namespace(contactItem.m_namespace)
41 , m_alias(contactItem.m_alias)
42 , m_name(contactItem.m_name)
43 , m_institution(contactItem.m_institution)
Yingdi Yu813d4e92013-11-03 16:22:05 -080044 , m_isIntroducer(contactItem.m_isIntroducer)
45 , m_trustScope(contactItem.m_trustScope)
Yingdi Yua50c3252013-11-03 15:05:26 -080046{}
47
Yingdi Yu813d4e92013-11-03 16:22:05 -080048}