monotone

monotone Mtn Source Tree

Root/src/packet.hh

1// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
2//
3// This program is made available under the GNU GPL version 2.0 or
4// greater. See the accompanying file COPYING for details.
5//
6// This program is distributed WITHOUT ANY WARRANTY; without even the
7// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8// PURPOSE.
9
10#ifndef __PACKET_HH__
11#define __PACKET_HH__
12
13#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
14#include <botan/ui.h>
15#endif
16
17#include "vocab.hh"
18
19struct cert;
20struct keypair;
21
22// the idea here is that monotone can produce and consume "packet streams",
23// where each packet is *informative* rather than transactional. that is to
24// say, they contain no information which needs to be replied to or processed
25// in any particular manner during some communication session.
26//
27// unlike nearly every other part of this program, the packet stream
28// interface is really *stream* oriented. the idea being that, while you
29// might be able to keep any one delta or file in memory at once, asking
30// you to keep *all* the deltas or files associated with a large chunk of
31// work, in memory, is a bit much.
32//
33// packet streams are ascii text, formatted for comfortable viewing on a
34// terminal or inclusion in an email / netnews post. they can be edited with
35// vi, filtered with grep, and concatenated with cat.
36//
37// there are currently 8 types of packets, though this can grow without
38// hurting anyone's feelings. if there's a backwards compatibility problem,
39// just introduce a new packet type.
40
41struct packet_consumer
42{
43public:
44 virtual ~packet_consumer() {}
45 virtual void consume_file_data(file_id const & ident,
46 file_data const & dat) = 0;
47 virtual void consume_file_delta(file_id const & id_old,
48 file_id const & id_new,
49 file_delta const & del) = 0;
50
51 virtual void consume_revision_data(revision_id const & ident,
52 revision_data const & dat) = 0;
53 virtual void consume_revision_cert(cert const & t) = 0;
54
55
56 virtual void consume_public_key(key_name const & ident,
57 rsa_pub_key const & k) = 0;
58 virtual void consume_key_pair(key_name const & ident,
59 keypair const & kp) = 0;
60 virtual void consume_old_private_key(key_name const & ident,
61 old_arc4_rsa_priv_key const & k) = 0;
62};
63
64// this writer writes packets into a stream
65
66struct packet_writer : public packet_consumer
67{
68 std::ostream & ost;
69 explicit packet_writer(std::ostream & o);
70 virtual ~packet_writer() {}
71 virtual void consume_file_data(file_id const & ident,
72 file_data const & dat);
73 virtual void consume_file_delta(file_id const & id_old,
74 file_id const & id_new,
75 file_delta const & del);
76
77 virtual void consume_revision_data(revision_id const & ident,
78 revision_data const & dat);
79 virtual void consume_revision_cert(cert const & t);
80
81 virtual void consume_public_key(key_name const & ident,
82 rsa_pub_key const & k);
83 virtual void consume_key_pair(key_name const & ident,
84 keypair const & kp);
85 virtual void consume_old_private_key(key_name const & ident,
86 old_arc4_rsa_priv_key const & k);
87};
88
89size_t read_packets(std::istream & in, packet_consumer & cons);
90
91#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
92// A helper class implementing Botan::User_Interface - which doesn't really
93// interface with the user, but provides the necessary plumbing for Botan.
94//
95// See Botan commit 2d09d7d0cd4bd0e7155d001dd65a4f29103b158c
96typedef std::runtime_error Passphrase_Required;
97
98class Dummy_UI : public Botan::User_Interface
99{
100public:
101 virtual std::string get_passphrase(const std::string &, const std::string &,
102 Botan::User_Interface::UI_Result &) const;
103};
104#endif
105
106#endif
107
108// Local Variables:
109// mode: C++
110// fill-column: 76
111// c-file-style: "gnu"
112// indent-tabs-mode: nil
113// End:
114// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status