blob: f7967ed8589c81aafcec2d356609a9f9cff5da25 [file] [log] [blame]
Yingdi Yufa4ce792014-02-06 18:09:22 -08001/* -*- 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
Yingdi Yueb692ac2015-02-10 18:46:18 -080011#ifndef CHRONOCHAT_INVITATION_HPP
12#define CHRONOCHAT_INVITATION_HPP
Yingdi Yufa4ce792014-02-06 18:09:22 -080013
14
Yingdi Yu0b0a7362014-08-05 16:31:30 -070015#include "common.hpp"
16
Yingdi Yufa0b6a02014-04-30 14:26:42 -070017#include <ndn-cxx/security/identity-certificate.hpp>
Yingdi Yufa4ce792014-02-06 18:09:22 -080018
Yingdi Yueb692ac2015-02-10 18:46:18 -080019namespace chronochat {
Yingdi Yufa4ce792014-02-06 18:09:22 -080020
21class Invitation
22{
Yingdi Yu0b0a7362014-08-05 16:31:30 -070023public:
Yingdi Yu348f5ea2014-03-01 14:47:25 -080024 /*
25 * /[invitee_namespace]
26 * /CHRONOCHAT-INVITATION
27 * /<chatroom_name>
28 * /<inviter_routing_prefix>
29 * /<inviter_cert>
30 * /<timestamp>
31 * /<keylocator>
32 * /<signature>
33 */
Yingdi Yufa4ce792014-02-06 18:09:22 -080034 static const size_t NAME_SIZE_MIN;
Yingdi Yufa4ce792014-02-06 18:09:22 -080035 static const ssize_t SIGNATURE;
36 static const ssize_t KEY_LOCATOR;
37 static const ssize_t TIMESTAMP;
Yingdi Yu348f5ea2014-03-01 14:47:25 -080038 static const ssize_t INVITER_CERT;
Yingdi Yufa4ce792014-02-06 18:09:22 -080039 static const ssize_t INVITER_PREFIX;
40 static const ssize_t CHATROOM;
Yingdi Yu348f5ea2014-03-01 14:47:25 -080041 static const ssize_t CHRONOCHAT_INVITATION;
Yingdi Yufa4ce792014-02-06 18:09:22 -080042
Yingdi Yu0b0a7362014-08-05 16:31:30 -070043 class Error : public std::runtime_error
44 {
45 public:
46 Error(const std::string& what)
47 : std::runtime_error(what)
48 {
49 }
50 };
Yingdi Yufa4ce792014-02-06 18:09:22 -080051
Yingdi Yu0b0a7362014-08-05 16:31:30 -070052 Invitation()
53 {
54 }
Yingdi Yufa4ce792014-02-06 18:09:22 -080055
Yingdi Yu0b0a7362014-08-05 16:31:30 -070056 Invitation(const Name& interestName);
Yingdi Yufa4ce792014-02-06 18:09:22 -080057
Yingdi Yu0b0a7362014-08-05 16:31:30 -070058 Invitation(const Name& inviteeNameSpace,
Yingdi Yu348f5ea2014-03-01 14:47:25 -080059 const std::string& chatroom,
Yingdi Yu0b0a7362014-08-05 16:31:30 -070060 const Name& inviterRoutingPrefix,
Yingdi Yu348f5ea2014-03-01 14:47:25 -080061 const ndn::IdentityCertificate& inviterCertificate);
Yingdi Yufa4ce792014-02-06 18:09:22 -080062
63 Invitation(const Invitation& invitation);
64
65 virtual
Yingdi Yu0b0a7362014-08-05 16:31:30 -070066 ~Invitation()
67 {
68 }
Yingdi Yufa4ce792014-02-06 18:09:22 -080069
Yingdi Yu0b0a7362014-08-05 16:31:30 -070070 const Name&
Yingdi Yufa4ce792014-02-06 18:09:22 -080071 getInviteeNameSpace() const
Yingdi Yu0b0a7362014-08-05 16:31:30 -070072 {
73 return m_inviteeNameSpace;
74 }
Yingdi Yufa4ce792014-02-06 18:09:22 -080075
Yingdi Yu348f5ea2014-03-01 14:47:25 -080076 const std::string&
Yingdi Yufa4ce792014-02-06 18:09:22 -080077 getChatroom() const
Yingdi Yu0b0a7362014-08-05 16:31:30 -070078 {
79 return m_chatroom;
80 }
Yingdi Yufa4ce792014-02-06 18:09:22 -080081
Yingdi Yu0b0a7362014-08-05 16:31:30 -070082 const Name&
Yingdi Yufa4ce792014-02-06 18:09:22 -080083 getInviterRoutingPrefix() const
Yingdi Yu0b0a7362014-08-05 16:31:30 -070084 {
85 return m_inviterRoutingPrefix;
86 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -080087
88 const ndn::IdentityCertificate&
89 getInviterCertificate() const
Yingdi Yu0b0a7362014-08-05 16:31:30 -070090 {
91 return m_inviterCertificate;
92 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -080093
94 const uint64_t
95 getTimestamp() const
Yingdi Yu0b0a7362014-08-05 16:31:30 -070096 {
97 return m_timestamp;
98 }
Yingdi Yufa0b6a02014-04-30 14:26:42 -070099
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700100 const Name&
Yingdi Yufa4ce792014-02-06 18:09:22 -0800101 getUnsignedInterestName() const
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700102 {
103 return m_interestName;
104 }
Yingdi Yufa4ce792014-02-06 18:09:22 -0800105
106private:
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700107 Name m_interestName;
Yingdi Yufa4ce792014-02-06 18:09:22 -0800108
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700109 Name m_inviteeNameSpace;
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800110 std::string m_chatroom;
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700111 Name m_inviterRoutingPrefix;
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800112 ndn::IdentityCertificate m_inviterCertificate;
113 uint64_t m_timestamp;
Yingdi Yufa4ce792014-02-06 18:09:22 -0800114};
115
Yingdi Yueb692ac2015-02-10 18:46:18 -0800116} // namespace chronochat
Yingdi Yufa4ce792014-02-06 18:09:22 -0800117
Yingdi Yueb692ac2015-02-10 18:46:18 -0800118#endif // CHRONOCHAT_INVITATION_HPP