aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2022-01-05 18:58:45 +0000
committerSaturneric <[email protected]>2022-01-05 18:58:45 +0000
commitd7650e385128e22678ec8876cecfe69ccf32749c (patch)
tree522ffe76de9c4788d7799a828e28607293219880 /src
parent<feature>(ui, project): load root certs. (diff)
downloadGpgFrontend-d7650e385128e22678ec8876cecfe69ccf32749c.tar.gz
GpgFrontend-d7650e385128e22678ec8876cecfe69ccf32749c.zip
<feature>(ui, resources): add imap folder support.
1. add some icons on imap folders. 2. add abstraction to imap folders.
Diffstat (limited to 'src')
-rw-r--r--src/ui/smtp/IMAPFolder.cpp92
-rw-r--r--src/ui/smtp/IMAPFolder.h50
-rw-r--r--src/ui/smtp/ReceiveMailDialog.h18
3 files changed, 159 insertions, 1 deletions
diff --git a/src/ui/smtp/IMAPFolder.cpp b/src/ui/smtp/IMAPFolder.cpp
new file mode 100644
index 00000000..446b1bea
--- /dev/null
+++ b/src/ui/smtp/IMAPFolder.cpp
@@ -0,0 +1,92 @@
+/**
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar 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 General Public License
+ * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from gpg4usb-team.
+ * Their source code version also complies with GNU General Public License.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#include "IMAPFolder.h"
+
+#include <utility>
+#include <vmime/vmime.hpp>
+
+GpgFrontend::UI::IMAPFolder::IMAPFolder(
+ std::shared_ptr<vmime::net::folder> folder)
+ : folder_(std::move(folder)),
+ tree_node_(new QTreeWidgetItem(static_cast<QTreeWidget *>(nullptr),
+ {"server"})) {
+ const std::string folder_name = folder_->getName().getBuffer();
+ LOG(INFO) << "folder" << folder_name;
+
+ const vmime::net::folderAttributes attr = folder_->getAttributes();
+ std::ostringstream attrStr;
+
+ tree_node_->setIcon(0, QIcon(":folder.png"));
+ if (attr.getSpecialUse() == vmime::net::folderAttributes::SPECIALUSE_ALL) {
+ LOG(INFO) << "use:All";
+ } else if (attr.getSpecialUse() ==
+ vmime::net::folderAttributes::SPECIALUSE_ARCHIVE) {
+ tree_node_->setIcon(0, QIcon(":archive.png"));
+ } else if (attr.getSpecialUse() ==
+ vmime::net::folderAttributes::SPECIALUSE_DRAFTS) {
+ tree_node_->setIcon(0, QIcon(":drafts.png"));
+ } else if (attr.getSpecialUse() ==
+ vmime::net::folderAttributes::SPECIALUSE_FLAGGED) {
+ tree_node_->setIcon(0, QIcon(":flag.png"));
+ } else if (attr.getSpecialUse() ==
+ vmime::net::folderAttributes::SPECIALUSE_JUNK) {
+ tree_node_->setIcon(0, QIcon(":junk.png"));
+ } else if (attr.getSpecialUse() ==
+ vmime::net::folderAttributes::SPECIALUSE_SENT) {
+ tree_node_->setIcon(0, QIcon(":sent.png"));
+ } else if (attr.getSpecialUse() ==
+ vmime::net::folderAttributes::SPECIALUSE_TRASH) {
+ tree_node_->setIcon(0, QIcon(":trash.png"));
+ } else if (attr.getSpecialUse() ==
+ vmime::net::folderAttributes::SPECIALUSE_IMPORTANT) {
+ tree_node_->setIcon(0, QIcon(":importance.png"));
+ }
+
+ if (attr.getFlags() & vmime::net::folderAttributes::FLAG_HAS_CHILDREN) {
+ LOG(INFO) << " flag:HasChildren";
+ }
+ if (attr.getFlags() & vmime::net::folderAttributes::FLAG_NO_OPEN) {
+ LOG(INFO) << " flag:NoOpen";
+ // tree_node_->setDisabled(true);
+ }
+
+ if (!folder_name.empty())
+ tree_node_->setText(0, folder_name.c_str());
+ else
+ tree_node_->setIcon(0, QIcon(":server.png"));
+
+}
+
+void GpgFrontend::UI::IMAPFolder::SetParentFolder(IMAPFolder *parent_folder) {
+ parent_folder->GetTreeWidgetItem()->addChild(tree_node_);
+}
+
+QTreeWidgetItem *GpgFrontend::UI::IMAPFolder::GetTreeWidgetItem() {
+ return tree_node_;
+}
+
+vmime::net::folder *GpgFrontend::UI::IMAPFolder::GetVmimeFolder() {
+ return folder_.get();
+}
diff --git a/src/ui/smtp/IMAPFolder.h b/src/ui/smtp/IMAPFolder.h
new file mode 100644
index 00000000..255f3d71
--- /dev/null
+++ b/src/ui/smtp/IMAPFolder.h
@@ -0,0 +1,50 @@
+/**
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar 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 General Public License
+ * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from gpg4usb-team.
+ * Their source code version also complies with GNU General Public License.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ */
+#ifndef GPGFRONTEND_IMAPFOLDER_H
+#define GPGFRONTEND_IMAPFOLDER_H
+
+#include "GpgFrontendUI.h"
+
+namespace vmime::net {
+class folder;
+};
+
+namespace GpgFrontend::UI {
+class IMAPFolder {
+ public:
+ explicit IMAPFolder(std::shared_ptr<vmime::net::folder> folder);
+
+ void SetParentFolder(IMAPFolder* parent_node);
+
+ QTreeWidgetItem* GetTreeWidgetItem();
+
+ vmime::net::folder* GetVmimeFolder();
+
+ private:
+ std::shared_ptr<vmime::net::folder> folder_;
+ QTreeWidgetItem* tree_node_;
+};
+} // namespace GpgFrontend::UI
+
+#endif // GPGFRONTEND_IMAPFOLDER_H
diff --git a/src/ui/smtp/ReceiveMailDialog.h b/src/ui/smtp/ReceiveMailDialog.h
index 5aa2c52e..7199cd2a 100644
--- a/src/ui/smtp/ReceiveMailDialog.h
+++ b/src/ui/smtp/ReceiveMailDialog.h
@@ -29,15 +29,31 @@
class Ui_ReceiveMailDialog;
+namespace vmime::net {
+class folder;
+};
+
namespace GpgFrontend::UI {
+class IMAPFolder;
+
class ReceiveMailDialog : public QDialog {
Q_OBJECT
public:
- ReceiveMailDialog(QWidget *parent);
+ ReceiveMailDialog(QWidget* parent);
+
+ private slots:
+ void slotRefreshData();
private:
std::shared_ptr<Ui_ReceiveMailDialog> ui;
+
+ std::string get_folder_path(const std::shared_ptr<vmime::net::folder>& f);
+
+ void list_sub_folders(IMAPFolder* parent_folder,
+ const std::shared_ptr<vmime::net::folder>&);
+
+ std::vector<std::shared_ptr<IMAPFolder>> folders;
};
} // namespace GpgFrontend::UI