7 #include <Wt/WApplication.h> 10 #include <Wt/WPushButton.h> 11 #include <Wt/WContainerWidget.h> 12 #include <Wt/WStringUtil.h> 24 composer_ = this->addWidget(cpp14::make_unique<Composer>());
26 std::vector<Contact> addressBook;
27 addressBook.push_back(
Contact(U
"Koen Deforche",
28 U
"koen.deforche@gmail.com"));
29 addressBook.push_back(
Contact(U
"Koen alias1",
30 U
"koen.alias1@yahoo.com"));
31 addressBook.push_back(
Contact(U
"Koen alias2",
32 U
"koen.alias2@yahoo.com"));
33 addressBook.push_back(
Contact(U
"Koen alias3",
34 U
"koen.alias3@yahoo.com"));
35 addressBook.push_back(
Contact(U
"Bartje",
36 U
"jafar@hotmail.com"));
39 std::vector<Contact> contacts;
40 contacts.push_back(
Contact(U
"Koen Deforche", U
"koen.deforche@gmail.com"));
48 details_ = this->addWidget(cpp14::make_unique<WContainerWidget>());
50 details_->addWidget(cpp14::make_unique<WText>(tr(
"example.info")));
55 WContainerWidget *feedback = this->addWidget(cpp14::make_unique<WContainerWidget>());
56 feedback->setStyleClass(U
"feedback");
58 WContainerWidget *horiz = feedback->addWidget(cpp14::make_unique<WContainerWidget>());
59 horiz->addWidget(cpp14::make_unique<WText>(U
"<p>We could have, but did not send the following email:</p>"));
62 if (!contacts.empty())
63 horiz = feedback->addWidget(cpp14::make_unique<WContainerWidget>());
64 for (
unsigned i = 0; i < contacts.size(); ++i) {
65 horiz->addWidget(cpp14::make_unique<WText>(U
"To: \"" + contacts[i].name + U
"\" <" 66 + contacts[i].email + U
">", TextFormat::Plain));
67 horiz->addWidget(cpp14::make_unique<WBreak>());
71 if (!contacts.empty())
72 horiz = feedback->addWidget(cpp14::make_unique<WContainerWidget>());
73 for (
unsigned i = 0; i < contacts.size(); ++i) {
74 horiz->addWidget(cpp14::make_unique<WText>(U
"Cc: \"" + contacts[i].name + U
"\" <" 75 + contacts[i].email + U
">", TextFormat::Plain));
76 horiz->addWidget(cpp14::make_unique<WBreak>());
80 if (!contacts.empty())
81 horiz = feedback->addWidget(cpp14::make_unique<WContainerWidget>());
82 for (
unsigned i = 0; i < contacts.size(); ++i) {
83 horiz->addWidget(cpp14::make_unique<WText>(U
"Bcc: \"" + contacts[i].name + U
"\" <" 84 + contacts[i].email + U
">", TextFormat::Plain));
85 horiz->addWidget(cpp14::make_unique<WBreak>());
88 horiz = feedback->addWidget(cpp14::make_unique<WContainerWidget>());
89 horiz->addWidget(cpp14::make_unique<WText>(
"Subject: \"" +
composer_->
subject() +
"\"", TextFormat::Plain));
92 if (!attachments.empty())
93 horiz = feedback->addWidget(cpp14::make_unique<WContainerWidget>());
94 for (
unsigned i = 0; i < attachments.size(); ++i) {
95 horiz->addWidget(cpp14::make_unique<WText>(U
"Attachment: \"" 96 + attachments[i].fileName
97 + U
"\" (" + attachments[i].contentDescription
98 + U
")", TextFormat::Plain));
100 unlink(attachments[i].spoolFileName.c_str());
102 horiz->addWidget(cpp14::make_unique<WText>(
", was in spool file: " 103 + attachments[i].spoolFileName));
104 horiz->addWidget(cpp14::make_unique<WBreak>());
109 horiz = feedback->addWidget(cpp14::make_unique<WContainerWidget>());
110 horiz->addWidget(cpp14::make_unique<WText>(
"Message body: "));
111 horiz->addWidget(cpp14::make_unique<WBreak>());
113 if (!message.empty()) {
114 horiz->addWidget(cpp14::make_unique<WText>(message, TextFormat::Plain));
116 horiz->addWidget(cpp14::make_unique<WText>(
"<i>(empty)</i>"));
128 WContainerWidget *feedback = this->addWidget(cpp14::make_unique<WContainerWidget>());
129 feedback->setStyleClass(
"feedback");
131 WContainerWidget *horiz = feedback->addWidget(cpp14::make_unique<WContainerWidget>());
132 horiz->addWidget(cpp14::make_unique<WText>(
"<p>Wise decision! Everyone's mailbox is already full anyway.</p>"));
144 std::unique_ptr<WApplication> app
145 = cpp14::make_unique<WApplication>(env);
149 app->messageResourceBundle().use(WApplication::appRoot() +
"composer");
153 app->useStyleSheet(
"composer.css");
155 app->setTitle(
"Composer example");
157 app->root()->addWidget(cpp14::make_unique<ComposeExample>());
162 int main(
int argc,
char **argv)
std::unique_ptr< WApplication > createApplication(const WEnvironment &env)
const WString & subject() const
Get the subject.
std::vector< Contact > cc() const
Get the Cc: contacts.
std::vector< Attachment > attachments() const
Get the list of attachments.
const WString & message() const
Get the message.
Wt::Signal send
The message is ready to be sent...
void setSubject(const WString &subject)
Set subject.
ComposeExample()
create a new Composer example.
WContainerWidget * details_
void setAddressBook(const std::vector< Contact > &addressBook)
Set the address book, for autocomplete suggestions.
std::vector< Contact > bcc() const
Get the Bc: contacts.
std::vector< Contact > to() const
Get the To: contacts.
Wt::Signal discard
The message must be discarded.
void setTo(const std::vector< Contact > &to)
Set message To: contacts.
int main(int argc, char **argv)