Add mimesis library.
This commit is contained in:
parent
a695a4f0ff
commit
7c43ef6c8a
9 changed files with 1549 additions and 5 deletions
|
@ -32,7 +32,6 @@ Fixed/changed:
|
||||||
▪ Purging of messages wasn't purgin important messages if chosen, now fixed.
|
▪ Purging of messages wasn't purgin important messages if chosen, now fixed.
|
||||||
▪ Fixed errors in internal SQL code when displaying empty message list.
|
▪ Fixed errors in internal SQL code when displaying empty message list.
|
||||||
|
|
||||||
|
|
||||||
3.6.3
|
3.6.3
|
||||||
—————
|
—————
|
||||||
|
|
||||||
|
|
1271
src/librssguard/3rd-party/mimesis/mimesis.cpp
vendored
Executable file
1271
src/librssguard/3rd-party/mimesis/mimesis.cpp
vendored
Executable file
File diff suppressed because it is too large
Load diff
181
src/librssguard/3rd-party/mimesis/mimesis.hpp
vendored
Executable file
181
src/librssguard/3rd-party/mimesis/mimesis.hpp
vendored
Executable file
|
@ -0,0 +1,181 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/* Mimesis -- a library for parsing and creating RFC2822 messages
|
||||||
|
Copyright © 2017 Guus Sliepen <guus@lightbts.info>
|
||||||
|
|
||||||
|
Mimesis is free software; you can redistribute it and/or modify it under the
|
||||||
|
terms of the GNU Lesser General Public License as published by the Free
|
||||||
|
Software Foundation, either version 3 of the License, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <functional>
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Mimesis {
|
||||||
|
|
||||||
|
std::string base64_encode(std::string_view in);
|
||||||
|
std::string base64_decode(std::string_view in);
|
||||||
|
|
||||||
|
class Part {
|
||||||
|
std::vector<std::pair<std::string, std::string>> headers;
|
||||||
|
std::string preamble;
|
||||||
|
std::string body;
|
||||||
|
std::string epilogue;
|
||||||
|
std::vector<Part> parts;
|
||||||
|
std::string boundary;
|
||||||
|
bool multipart;
|
||||||
|
bool crlf;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool message;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Part();
|
||||||
|
friend bool operator==(const Part& lhs, const Part& rhs);
|
||||||
|
friend bool operator!=(const Part& lhs, const Part& rhs);
|
||||||
|
|
||||||
|
// Loading and saving a whole MIME message
|
||||||
|
std::string load(std::istream& in, const std::string& parent_boundary = {});
|
||||||
|
void load(const std::string& filename);
|
||||||
|
void save(std::ostream& out) const;
|
||||||
|
void save(const std::string& filename) const;
|
||||||
|
void from_string(const std::string& data);
|
||||||
|
std::string to_string() const;
|
||||||
|
|
||||||
|
// Low-level access
|
||||||
|
std::string get_body() const;
|
||||||
|
std::string get_preamble() const;
|
||||||
|
std::string get_epilogue() const;
|
||||||
|
std::string get_boundary() const;
|
||||||
|
std::vector<Part>& get_parts();
|
||||||
|
const std::vector<Part>& get_parts() const;
|
||||||
|
std::vector<std::pair<std::string, std::string>>& get_headers();
|
||||||
|
const std::vector<std::pair<std::string, std::string>>& get_headers() const;
|
||||||
|
|
||||||
|
bool is_multipart() const;
|
||||||
|
bool is_multipart(const std::string& subtype) const;
|
||||||
|
bool is_singlepart() const;
|
||||||
|
bool is_singlepart(const std::string& type) const;
|
||||||
|
|
||||||
|
void set_body(const std::string& body);
|
||||||
|
void set_preamble(const std::string& preamble);
|
||||||
|
void set_epilogue(const std::string& epilogue);
|
||||||
|
void set_boundary(const std::string& boundary);
|
||||||
|
void set_parts(const std::vector<Part>& parts);
|
||||||
|
void set_headers(const std::vector<std::pair<std::string, std::string>>& headers);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
void clear_body();
|
||||||
|
|
||||||
|
// Header manipulation
|
||||||
|
std::string get_header(const std::string& field) const;
|
||||||
|
void set_header(const std::string& field, const std::string& value);
|
||||||
|
std::string& operator[](const std::string& field);
|
||||||
|
const std::string& operator[](const std::string& field) const;
|
||||||
|
|
||||||
|
void append_header(const std::string& field, const std::string& value);
|
||||||
|
void prepend_header(const std::string& field, const std::string& value);
|
||||||
|
void erase_header(const std::string& field);
|
||||||
|
void clear_headers();
|
||||||
|
|
||||||
|
// Specialized header functions
|
||||||
|
std::string get_multipart_type() const;
|
||||||
|
std::string get_header_value(const std::string& field) const;
|
||||||
|
std::string get_header_parameter(const std::string& field, const std::string& parameter) const;
|
||||||
|
|
||||||
|
void set_header_value(const std::string& field, const std::string& value);
|
||||||
|
void set_header_parameter(const std::string& field, const std::string& paramter, const std::string& value);
|
||||||
|
|
||||||
|
void add_received(const std::string& domain, const std::chrono::system_clock::time_point& date = std::chrono::system_clock::now());
|
||||||
|
void generate_msgid(const std::string& domain);
|
||||||
|
void set_date(const std::chrono::system_clock::time_point& date = std::chrono::system_clock::now());
|
||||||
|
|
||||||
|
// Part manipulation
|
||||||
|
Part& append_part(const Part& part = {});
|
||||||
|
Part& prepend_part(const Part& part = {});
|
||||||
|
|
||||||
|
void clear_parts();
|
||||||
|
void make_multipart(const std::string& type, const std::string& boundary = {});
|
||||||
|
bool flatten();
|
||||||
|
|
||||||
|
std::string get_mime_type() const;
|
||||||
|
void set_mime_type(const std::string& type);
|
||||||
|
bool is_mime_type(const std::string& type) const;
|
||||||
|
bool has_mime_type() const;
|
||||||
|
|
||||||
|
// Body and attachments
|
||||||
|
Part& set_alternative(const std::string& subtype, const std::string& text);
|
||||||
|
|
||||||
|
void set_plain(const std::string& text);
|
||||||
|
void set_html(const std::string& text);
|
||||||
|
|
||||||
|
const Part* get_first_matching_part(std::function<bool(const Part&)> predicate) const;
|
||||||
|
|
||||||
|
Part* get_first_matching_part(std::function<bool(const Part&)> predicate);
|
||||||
|
const Part* get_first_matching_part(const std::string& type) const;
|
||||||
|
|
||||||
|
Part* get_first_matching_part(const std::string& type);
|
||||||
|
std::string get_first_matching_body(const std::string& type) const;
|
||||||
|
std::string get_text() const;
|
||||||
|
std::string get_plain() const;
|
||||||
|
std::string get_html() const;
|
||||||
|
|
||||||
|
Part& attach(const Part& attachment);
|
||||||
|
Part& attach(const std::string& data, const std::string& mime_type, const std::string& filename = {});
|
||||||
|
Part& attach(std::istream& in, const std::string& mime_type, const std::string& filename = {});
|
||||||
|
|
||||||
|
std::vector<const Part*> get_attachments() const;
|
||||||
|
|
||||||
|
void clear_alternative(const std::string& subtype);
|
||||||
|
void clear_text();
|
||||||
|
void clear_plain();
|
||||||
|
void clear_html();
|
||||||
|
void clear_attachments();
|
||||||
|
|
||||||
|
void simplify();
|
||||||
|
|
||||||
|
bool has_text() const;
|
||||||
|
bool has_plain() const;
|
||||||
|
bool has_html() const;
|
||||||
|
bool has_attachments() const;
|
||||||
|
bool is_attachment() const;
|
||||||
|
bool is_inline() const;
|
||||||
|
|
||||||
|
// Format manipulation
|
||||||
|
void set_crlf(bool value = true);
|
||||||
|
};
|
||||||
|
|
||||||
|
class Message : public Part {
|
||||||
|
public:
|
||||||
|
Message();
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator==(const Part& lhs, const Part& rhs);
|
||||||
|
bool operator!=(const Part& lhs, const Part& rhs);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, const Mimesis::Part& part) {
|
||||||
|
part.save(out);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::istream& operator>>(std::istream& in, Mimesis::Part& part) {
|
||||||
|
part.load(in);
|
||||||
|
return in;
|
||||||
|
}
|
61
src/librssguard/3rd-party/mimesis/quoted-printable.cpp
vendored
Executable file
61
src/librssguard/3rd-party/mimesis/quoted-printable.cpp
vendored
Executable file
|
@ -0,0 +1,61 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
/* Mimesis -- a library for parsing and creating RFC2822 messages
|
||||||
|
Copyright © 2017 Guus Sliepen <guus@lightbts.info>
|
||||||
|
|
||||||
|
Mimesis is free software; you can redistribute it and/or modify it under the
|
||||||
|
terms of the GNU Lesser General Public License as published by the Free
|
||||||
|
Software Foundation, either version 3 of the License, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "quoted-printable.hpp"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
string quoted_printable_decode(string_view in) {
|
||||||
|
string out;
|
||||||
|
|
||||||
|
out.reserve(in.size());
|
||||||
|
|
||||||
|
int decode = 0;
|
||||||
|
uint8_t val = 0;
|
||||||
|
|
||||||
|
for (auto&& c: in) {
|
||||||
|
if (decode) {
|
||||||
|
if (c >= '0' && c <= '9') {
|
||||||
|
val <<= 4;
|
||||||
|
val |= c - '0';
|
||||||
|
decode--;
|
||||||
|
}
|
||||||
|
else if (c >= 'A' && c <= 'F') {
|
||||||
|
val <<= 4;
|
||||||
|
val |= 10 + (c - 'A');
|
||||||
|
decode--;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
decode = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decode == 0)
|
||||||
|
out.push_back(static_cast<char>(val));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (c == '=')
|
||||||
|
decode = 2;
|
||||||
|
else
|
||||||
|
out.push_back(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
25
src/librssguard/3rd-party/mimesis/quoted-printable.hpp
vendored
Executable file
25
src/librssguard/3rd-party/mimesis/quoted-printable.hpp
vendored
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/* Mimesis -- a library for parsing and creating RFC2822 messages
|
||||||
|
Copyright © 2017 Guus Sliepen <guus@lightbts.info>
|
||||||
|
|
||||||
|
Mimesis is free software; you can redistribute it and/or modify it under the
|
||||||
|
terms of the GNU Lesser General Public License as published by the Free
|
||||||
|
Software Foundation, either version 3 of the License, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
std::string quoted_printable_decode(std::string_view in);
|
|
@ -92,7 +92,7 @@
|
||||||
<locale language="English" country="UnitedStates"/>
|
<locale language="English" country="UnitedStates"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="m_tabInfo">
|
<widget class="QWidget" name="m_tabInfo">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -167,7 +167,7 @@ p, li { white-space: pre-wrap; }
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
<string>GNU GPL License (applies to RSS Guard source code)</string>
|
<string>GNU GPL License (applies to RSS Guard and mimesis source code)</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="toolTip">
|
<attribute name="toolTip">
|
||||||
<string>GNU GPL License</string>
|
<string>GNU GPL License</string>
|
||||||
|
|
|
@ -413,6 +413,10 @@ else {
|
||||||
gui/newspaperpreviewer.ui
|
gui/newspaperpreviewer.ui
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Add mimesis.
|
||||||
|
SOURCES += $$files(3rd-party/mimesis/*.cpp, false)
|
||||||
|
HEADERS += $$files(3rd-party/mimesis/*.hpp, false)
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/. \
|
INCLUDEPATH += $$PWD/. \
|
||||||
$$PWD/gui \
|
$$PWD/gui \
|
||||||
$$PWD/gui/dialogs \
|
$$PWD/gui/dialogs \
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "services/gmail/gui/formaddeditemail.h"
|
#include "services/gmail/gui/formaddeditemail.h"
|
||||||
|
|
||||||
|
#include "gui/guiutilities.h"
|
||||||
#include "miscellaneous/application.h"
|
#include "miscellaneous/application.h"
|
||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
#include "services/gmail/gmailserviceroot.h"
|
#include "services/gmail/gmailserviceroot.h"
|
||||||
|
@ -10,6 +11,8 @@
|
||||||
FormAddEditEmail::FormAddEditEmail(GmailServiceRoot* root, QWidget* parent) : QDialog(parent), m_root(root) {
|
FormAddEditEmail::FormAddEditEmail(GmailServiceRoot* root, QWidget* parent) : QDialog(parent), m_root(root) {
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
|
GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("mail-message-new")));
|
||||||
|
|
||||||
m_ui.m_layoutAdder->setMargin(0);
|
m_ui.m_layoutAdder->setMargin(0);
|
||||||
m_ui.m_layoutAdder->setContentsMargins(0, 0, 0, 0);
|
m_ui.m_layoutAdder->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
|
|
@ -228,11 +228,11 @@ void GmailNetworkFactory::markMessagesStarred(RootItem::Importance importance, c
|
||||||
QJsonArray param_add, param_remove;
|
QJsonArray param_add, param_remove;
|
||||||
|
|
||||||
if (importance == RootItem::Importance::Important) {
|
if (importance == RootItem::Importance::Important) {
|
||||||
// We add label UNREAD.
|
// We add label STARRED.
|
||||||
param_add.append(GMAIL_SYSTEM_LABEL_STARRED);
|
param_add.append(GMAIL_SYSTEM_LABEL_STARRED);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// We remove label UNREAD.
|
// We remove label STARRED.
|
||||||
param_remove.append(GMAIL_SYSTEM_LABEL_STARRED);
|
param_remove.append(GMAIL_SYSTEM_LABEL_STARRED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue