Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -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 | #include "contact-item.h" |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 12 | |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 13 | #include "logging.h" |
| 14 | |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 15 | using namespace std; |
| 16 | using namespace ndn; |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 17 | |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 18 | INIT_LOGGER("ContactItem"); |
| 19 | |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 20 | namespace chronos{ |
| 21 | |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 22 | ContactItem::ContactItem(const EndorseCertificate& selfEndorseCertificate, |
Yingdi Yu | 71c0187 | 2013-11-03 16:22:05 -0800 | [diff] [blame] | 23 | bool isIntroducer, |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 24 | const string& alias) |
| 25 | : m_selfEndorseCertificate(selfEndorseCertificate) |
Yingdi Yu | 71c0187 | 2013-11-03 16:22:05 -0800 | [diff] [blame] | 26 | , m_isIntroducer(isIntroducer) |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 27 | { |
| 28 | Name endorsedkeyName = selfEndorseCertificate.getPublicKeyName(); |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 29 | |
| 30 | m_namespace = endorsedkeyName.getSubName(0, endorsedkeyName.size() - 1); |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 31 | |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 32 | |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 33 | m_name = selfEndorseCertificate.getProfile().get("name"); |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 34 | m_alias = alias.empty() ? m_name : alias; |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 35 | m_institution = selfEndorseCertificate.getProfile().get("institution"); |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Yingdi Yu | ec5e72a | 2013-11-03 15:05:26 -0800 | [diff] [blame] | 38 | ContactItem::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 Yu | 71c0187 | 2013-11-03 16:22:05 -0800 | [diff] [blame] | 44 | , m_isIntroducer(contactItem.m_isIntroducer) |
| 45 | , m_trustScope(contactItem.m_trustScope) |
Yingdi Yu | ec5e72a | 2013-11-03 15:05:26 -0800 | [diff] [blame] | 46 | {} |
| 47 | |
Yingdi Yu | 71c0187 | 2013-11-03 16:22:05 -0800 | [diff] [blame] | 48 | } |