wip: stuff.
[dcpomatic.git] / src / lib / dkdm_recipient.cc
1 /*
2     Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #include "dkdm_recipient.h"
22 #include "dcpomatic_assert.h"
23 #include <dcp/raw_convert.h>
24 #include <libxml++/libxml++.h>
25 #include <boost/foreach.hpp>
26
27 using std::string;
28 using dcp::raw_convert;
29
30 DKDMRecipient::DKDMRecipient (cxml::ConstNodePtr node)
31         : KDMRecipient (node)
32 {
33         BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Email")) {
34                 emails.push_back (i->content());
35         }
36
37         _utc_offset_hour = node->number_child<int>("UTCOffsetHour");
38         _utc_offset_minute = node->number_child<int>("UTCOffsetMinute");
39 }
40
41
42 void
43 DKDMRecipient::as_xml (xmlpp::Element* parent) const
44 {
45         KDMRecipient::as_xml (parent);
46
47         BOOST_FOREACH (string i, emails) {
48                 parent->add_child("Email")->add_child_text (i);
49         }
50
51         parent->add_child("UTCOffsetHour")->add_child_text(raw_convert<string>(_utc_offset_hour));
52         parent->add_child("UTCOffsetMinute")->add_child_text(raw_convert<string>(_utc_offset_minute));
53 }
54
55
56 void
57 DKDMRecipient::set_utc_offset_hour (int h)
58 {
59         DCPOMATIC_ASSERT (h >= -11 && h <= 12);
60         _utc_offset_hour = h;
61 }
62
63
64 void
65 DKDMRecipient::set_utc_offset_minute (int m)
66 {
67         DCPOMATIC_ASSERT (m >= 0 && m <= 59);
68         _utc_offset_minute = m;
69 }