projects
/
dcpomatic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fa8bdd1
)
Tweak naming of KDM emails and attachments.
author
Carl Hetherington
<cth@carlh.net>
Wed, 7 Oct 2015 22:31:07 +0000
(23:31 +0100)
committer
Carl Hetherington
<cth@carlh.net>
Fri, 9 Oct 2015 12:45:00 +0000
(13:45 +0100)
src/lib/cinema_kdms.cc
patch
|
blob
|
history
src/lib/cinema_kdms.h
patch
|
blob
|
history
src/lib/emailer.cc
patch
|
blob
|
history
src/lib/emailer.h
patch
|
blob
|
history
src/lib/screen_kdm.cc
patch
|
blob
|
history
src/lib/screen_kdm.h
patch
|
blob
|
history
src/tools/dcpomatic_kdm.cc
patch
|
blob
|
history
diff --git
a/src/lib/cinema_kdms.cc
b/src/lib/cinema_kdms.cc
index 9b839a3545f4f8597f6bb2c1b65bf0ecf8133ef7..9584a3f236200a22bbabd576221de1784d9bdcce 100644
(file)
--- a/
src/lib/cinema_kdms.cc
+++ b/
src/lib/cinema_kdms.cc
@@
-35,11
+35,8
@@
using std::cout;
using std::string;
using boost::shared_ptr;
using std::string;
using boost::shared_ptr;
-/** @param filename_first_part First part of name of KDM files inside the zip file
- * (perhaps the name of the film).
- */
void
void
-CinemaKDMs::make_zip_file (string fil
ename_first_part
, boost::filesystem::path zip_file) const
+CinemaKDMs::make_zip_file (string fil
m_name
, boost::filesystem::path zip_file) const
{
int error;
struct zip* zip = zip_open (zip_file.string().c_str(), ZIP_CREATE | ZIP_EXCL, &error);
{
int error;
struct zip* zip = zip_open (zip_file.string().c_str(), ZIP_CREATE | ZIP_EXCL, &error);
@@
-61,7
+58,7
@@
CinemaKDMs::make_zip_file (string filename_first_part, boost::filesystem::path z
throw StringError ("could not create ZIP source");
}
throw StringError ("could not create ZIP source");
}
- if (zip_add (zip, i.filename(fil
ename_first_part
).c_str(), source) == -1) {
+ if (zip_add (zip, i.filename(fil
m_name
).c_str(), source) == -1) {
throw StringError ("failed to add KDM to ZIP archive");
}
}
throw StringError ("failed to add KDM to ZIP archive");
}
}
@@
-107,18
+104,18
@@
CinemaKDMs::collect (list<ScreenKDM> screen_kdms)
}
void
}
void
-CinemaKDMs::write_zip_files (string fil
ename_first_part
, list<CinemaKDMs> cinema_kdms, boost::filesystem::path directory)
+CinemaKDMs::write_zip_files (string fil
m_name
, list<CinemaKDMs> cinema_kdms, boost::filesystem::path directory)
{
BOOST_FOREACH (CinemaKDMs const & i, cinema_kdms) {
boost::filesystem::path path = directory;
path /= tidy_for_filename (i.cinema->name) + ".zip";
{
BOOST_FOREACH (CinemaKDMs const & i, cinema_kdms) {
boost::filesystem::path path = directory;
path /= tidy_for_filename (i.cinema->name) + ".zip";
- i.make_zip_file (fil
ename_first_part
, path);
+ i.make_zip_file (fil
m_name
, path);
}
}
/* XXX: should probably get from/to from the KDMs themselves */
void
}
}
/* XXX: should probably get from/to from the KDMs themselves */
void
-CinemaKDMs::email (string fil
ename_first_part
, string cpl_name, list<CinemaKDMs> cinema_kdms, dcp::LocalTime from, dcp::LocalTime to, shared_ptr<Job> job)
+CinemaKDMs::email (string fil
m_name
, string cpl_name, list<CinemaKDMs> cinema_kdms, dcp::LocalTime from, dcp::LocalTime to, shared_ptr<Job> job)
{
Config* config = Config::instance ();
{
Config* config = Config::instance ();
@@
-126,9
+123,7
@@
CinemaKDMs::email (string filename_first_part, string cpl_name, list<CinemaKDMs>
boost::filesystem::path zip_file = boost::filesystem::temp_directory_path ();
zip_file /= boost::filesystem::unique_path().string() + ".zip";
boost::filesystem::path zip_file = boost::filesystem::temp_directory_path ();
zip_file /= boost::filesystem::unique_path().string() + ".zip";
- i.make_zip_file (filename_first_part, zip_file);
-
- /* Send email */
+ i.make_zip_file (film_name, zip_file);
string subject = config->kdm_subject();
SafeStringStream start;
string subject = config->kdm_subject();
SafeStringStream start;
@@
-161,7
+156,8
@@
CinemaKDMs::email (string filename_first_part, string cpl_name, list<CinemaKDMs>
email.add_bcc (config->kdm_bcc ());
}
email.add_bcc (config->kdm_bcc ());
}
- email.add_attachment (zip_file, "application/zip");
+ string const name = tidy_for_filename(i.cinema->name) + "_" + tidy_for_filename(film_name) + ".zip";
+ email.add_attachment (zip_file, name, "application/zip");
email.send (job);
}
}
email.send (job);
}
}
diff --git
a/src/lib/cinema_kdms.h
b/src/lib/cinema_kdms.h
index ecff32ff42c521c24817ea5fcb1d1501c1896d3e..49f29cc42b05562927d001461b303b2899d37eac 100644
(file)
--- a/
src/lib/cinema_kdms.h
+++ b/
src/lib/cinema_kdms.h
@@
-25,12
+25,12
@@
class Job;
class CinemaKDMs
{
public:
class CinemaKDMs
{
public:
- void make_zip_file (std::string
name_first_part
, boost::filesystem::path zip_file) const;
+ void make_zip_file (std::string
film_name
, boost::filesystem::path zip_file) const;
static std::list<CinemaKDMs> collect (std::list<ScreenKDM> kdms);
static std::list<CinemaKDMs> collect (std::list<ScreenKDM> kdms);
- static void write_zip_files (std::string fil
ename_first_part
, std::list<CinemaKDMs> cinema_kdms, boost::filesystem::path directory);
+ static void write_zip_files (std::string fil
m_name
, std::list<CinemaKDMs> cinema_kdms, boost::filesystem::path directory);
static void email (
static void email (
- std::string fil
ename_first_part
,
+ std::string fil
m_name
,
std::string cpl_name,
std::list<CinemaKDMs> cinema_kdms,
dcp::LocalTime from,
std::string cpl_name,
std::list<CinemaKDMs> cinema_kdms,
dcp::LocalTime from,
diff --git
a/src/lib/emailer.cc
b/src/lib/emailer.cc
index 0febb56ab6601ff3eec9350708ca0cbc291cce24..0193f36051c216724eeeaeb0cda6f9d443ad38da 100644
(file)
--- a/
src/lib/emailer.cc
+++ b/
src/lib/emailer.cc
@@
-61,9
+61,13
@@
Emailer::add_bcc (string bcc)
}
void
}
void
-Emailer::add_attachment (boost::filesystem::path
attachment
, string mime_type)
+Emailer::add_attachment (boost::filesystem::path
file, string name
, string mime_type)
{
{
- _attachments.push_back (make_pair (attachment, mime_type));
+ Attachment a;
+ a.file = file;
+ a.name = name;
+ a.mime_type = mime_type;
+ _attachments.push_back (a);
}
static size_t
}
static size_t
@@
-129,18
+133,18
@@
Emailer::send (shared_ptr<Job> job)
email << _body;
email << _body;
-
for (list<pair<boost::filesystem::path, string> >::const_iterator i = _attachments.begin(); i != _attachments.end(); ++i
) {
+
BOOST_FOREACH (Attachment i, _attachments
) {
email << "\r\n\r\n--" << boundary << "\r\n"
email << "\r\n\r\n--" << boundary << "\r\n"
- << "Content-Type: " << i
->second << "; name=" << i->first.leaf()
<< "\r\n"
+ << "Content-Type: " << i
.mime_type << "; name=" << i.name
<< "\r\n"
<< "Content-Transfer-Encoding: Base64\r\n"
<< "Content-Transfer-Encoding: Base64\r\n"
- << "Content-Disposition: attachment; filename=" << i
->first.leaf()
<< "\r\n\r\n";
+ << "Content-Disposition: attachment; filename=" << i
.name
<< "\r\n\r\n";
BIO* b64 = BIO_new (BIO_f_base64());
BIO* bio = BIO_new (BIO_s_mem());
bio = BIO_push (b64, bio);
BIO* b64 = BIO_new (BIO_f_base64());
BIO* bio = BIO_new (BIO_s_mem());
bio = BIO_push (b64, bio);
- Data data (i
->first
);
+ Data data (i
.file
);
BIO_write (bio, data.data().get(), data.size());
(void) BIO_flush (bio);
BIO_write (bio, data.data().get(), data.size());
(void) BIO_flush (bio);
diff --git
a/src/lib/emailer.h
b/src/lib/emailer.h
index 4b4d1f6f77d4013905d2609decbb2bd9ef430c57..9e6fca5b05f1665a8b34271991fa430e66d8ec21 100644
(file)
--- a/
src/lib/emailer.h
+++ b/
src/lib/emailer.h
@@
-27,7
+27,7
@@
public:
void add_cc (std::string cc);
void add_bcc (std::string bcc);
void add_cc (std::string cc);
void add_bcc (std::string bcc);
- void add_attachment (boost::filesystem::path
attachment, std::string
);
+ void add_attachment (boost::filesystem::path
file, std::string name, std::string mime_type
);
void send (boost::shared_ptr<Job> job);
void send (boost::shared_ptr<Job> job);
@@
-44,7
+44,14
@@
private:
std::string _body;
std::list<std::string> _cc;
std::list<std::string> _bcc;
std::string _body;
std::list<std::string> _cc;
std::list<std::string> _bcc;
- std::list<std::pair<boost::filesystem::path, std::string> > _attachments;
+
+ struct Attachment {
+ boost::filesystem::path file;
+ std::string name;
+ std::string mime_type;
+ };
+
+ std::list<Attachment> _attachments;
std::string _email;
size_t _offset;
boost::scoped_array<char> _notes_buffer;
std::string _email;
size_t _offset;
boost::scoped_array<char> _notes_buffer;
diff --git
a/src/lib/screen_kdm.cc
b/src/lib/screen_kdm.cc
index 60a81399d3c79c0714e393230bbf0137ec07d845..bbe539801dbdb400ab0e15e57c79ac2d4c2dc5d0 100644
(file)
--- a/
src/lib/screen_kdm.cc
+++ b/
src/lib/screen_kdm.cc
@@
-33,19
+33,18
@@
operator== (ScreenKDM const & a, ScreenKDM const & b)
return a.screen == b.screen && a.kdm == b.kdm;
}
return a.screen == b.screen && a.kdm == b.kdm;
}
-/** @param first_part first part of the filename (perhaps the name of the film) */
string
string
-ScreenKDM::filename (string fi
rst_part
) const
+ScreenKDM::filename (string fi
lm_name
) const
{
{
- return tidy_for_filename (fi
rst_part
) + "_" + tidy_for_filename (screen->cinema->name) + "_" + tidy_for_filename (screen->name) + ".kdm.xml";
+ return tidy_for_filename (fi
lm_name
) + "_" + tidy_for_filename (screen->cinema->name) + "_" + tidy_for_filename (screen->name) + ".kdm.xml";
}
void
}
void
-ScreenKDM::write_files (string
name_first_part
, list<ScreenKDM> screen_kdms, boost::filesystem::path directory)
+ScreenKDM::write_files (string
film_name
, list<ScreenKDM> screen_kdms, boost::filesystem::path directory)
{
/* Write KDMs to the specified directory */
BOOST_FOREACH (ScreenKDM const & i, screen_kdms) {
{
/* Write KDMs to the specified directory */
BOOST_FOREACH (ScreenKDM const & i, screen_kdms) {
- boost::filesystem::path out = directory / i.filename(
name_first_part
);
+ boost::filesystem::path out = directory / i.filename(
film_name
);
i.kdm.as_xml (out);
}
}
i.kdm.as_xml (out);
}
}
diff --git
a/src/lib/screen_kdm.h
b/src/lib/screen_kdm.h
index e2a16d3b726cc4501082909c5c71e044d0939743..6230ea091b3b7dfbeb3dbb6454e869d50eda5399 100644
(file)
--- a/
src/lib/screen_kdm.h
+++ b/
src/lib/screen_kdm.h
@@
-34,9
+34,9
@@
public:
, kdm (k)
{}
, kdm (k)
{}
- std::string filename (std::string fi
rst_part
) const;
+ std::string filename (std::string fi
lm_name
) const;
- static void write_files (std::string
name_first_part
, std::list<ScreenKDM> screen_kdms, boost::filesystem::path directory);
+ static void write_files (std::string
film_name
, std::list<ScreenKDM> screen_kdms, boost::filesystem::path directory);
boost::shared_ptr<Screen> screen;
dcp::EncryptedKDM kdm;
boost::shared_ptr<Screen> screen;
dcp::EncryptedKDM kdm;
diff --git
a/src/tools/dcpomatic_kdm.cc
b/src/tools/dcpomatic_kdm.cc
index bc58be914a93ae1c13ad243748a9f9f1b9004908..351c61750a37de9dbcf28ee978710abf9215d9e9 100644
(file)
--- a/
src/tools/dcpomatic_kdm.cc
+++ b/
src/tools/dcpomatic_kdm.cc
@@
-50,6
+50,7
@@
using std::exception;
using std::list;
using std::exception;
using std::list;
+using std::string;
using boost::shared_ptr;
using boost::bind;
using boost::shared_ptr;
using boost::bind;
@@
-273,8
+274,12
@@
private:
wxString::Format (s, int(screen_kdms.size()), std_to_wx(_output->directory().string()).data())
);
} else {
wxString::Format (s, int(screen_kdms.size()), std_to_wx(_output->directory().string()).data())
);
} else {
+ string film_name = decrypted.annotation_text ();
+ if (film_name.empty ()) {
+ film_name = decrypted.content_title_text ();
+ }
shared_ptr<Job> job (new SendKDMEmailJob (
shared_ptr<Job> job (new SendKDMEmailJob (
-
decrypted.annotation_text()
,
+
film_name
,
decrypted.content_title_text(),
_timing->from(), _timing->until(),
CinemaKDMs::collect (screen_kdms)
decrypted.content_title_text(),
_timing->from(), _timing->until(),
CinemaKDMs::collect (screen_kdms)