react-native-email-imap-smtp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EmailImapSmtp.podspec +29 -0
- package/LICENSE +20 -0
- package/README.md +121 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +117 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +11 -0
- package/android/src/main/java/com/margelo/nitro/emailimapsmtp/EmailImapSmtp.kt +1533 -0
- package/android/src/main/java/com/margelo/nitro/emailimapsmtp/EmailImapSmtpPackage.kt +22 -0
- package/ios/EmailImapSmtp.swift +5 -0
- package/lib/module/EmailImapSmtp.nitro.js +4 -0
- package/lib/module/EmailImapSmtp.nitro.js.map +1 -0
- package/lib/module/NativeEmailImapSmtp.js +14 -0
- package/lib/module/NativeEmailImapSmtp.js.map +1 -0
- package/lib/module/index.js +64 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/native.js +227 -0
- package/lib/module/native.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/web.js +107 -0
- package/lib/module/web.js.map +1 -0
- package/lib/module/windows.js +156 -0
- package/lib/module/windows.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/EmailImapSmtp.nitro.d.ts +268 -0
- package/lib/typescript/src/EmailImapSmtp.nitro.d.ts.map +1 -0
- package/lib/typescript/src/NativeEmailImapSmtp.d.ts +36 -0
- package/lib/typescript/src/NativeEmailImapSmtp.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +33 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/native.d.ts +32 -0
- package/lib/typescript/src/native.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +261 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/web.d.ts +32 -0
- package/lib/typescript/src/web.d.ts.map +1 -0
- package/lib/typescript/src/windows.d.ts +32 -0
- package/lib/typescript/src/windows.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/c++/JAppendResult.hpp +65 -0
- package/nitrogen/generated/android/c++/JAttachmentInfo.hpp +96 -0
- package/nitrogen/generated/android/c++/JConnectionConfig.hpp +94 -0
- package/nitrogen/generated/android/c++/JConnectionResult.hpp +73 -0
- package/nitrogen/generated/android/c++/JDeleteResult.hpp +87 -0
- package/nitrogen/generated/android/c++/JEmailAddress.hpp +61 -0
- package/nitrogen/generated/android/c++/JEmailBody.hpp +84 -0
- package/nitrogen/generated/android/c++/JEmailMessage.hpp +273 -0
- package/nitrogen/generated/android/c++/JFetchEmailsOptions.hpp +110 -0
- package/nitrogen/generated/android/c++/JFolderInfo.hpp +126 -0
- package/nitrogen/generated/android/c++/JFunc_void_IdleNotification.hpp +79 -0
- package/nitrogen/generated/android/c++/JHybridEmailImapSmtpSpec.cpp +697 -0
- package/nitrogen/generated/android/c++/JHybridEmailImapSmtpSpec.hpp +92 -0
- package/nitrogen/generated/android/c++/JIdleNotification.hpp +78 -0
- package/nitrogen/generated/android/c++/JImapServerInfo.hpp +84 -0
- package/nitrogen/generated/android/c++/JMailboxInfo.hpp +134 -0
- package/nitrogen/generated/android/c++/JMailboxListItem.hpp +92 -0
- package/nitrogen/generated/android/c++/JQuotaInfo.hpp +78 -0
- package/nitrogen/generated/android/c++/JSearchCriteria.hpp +187 -0
- package/nitrogen/generated/android/c++/JSearchHeader.hpp +61 -0
- package/nitrogen/generated/android/c++/JSendMailOptions.hpp +229 -0
- package/nitrogen/generated/android/c++/JSendMailResult.hpp +88 -0
- package/nitrogen/generated/android/c++/JSmtpAttachment.hpp +80 -0
- package/nitrogen/generated/android/c++/JSmtpConnectionConfig.hpp +98 -0
- package/nitrogen/generated/android/c++/JSmtpServerInfo.hpp +102 -0
- package/nitrogen/generated/android/c++/JVariant_ImapServerInfo_SmtpServerInfo.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_ImapServerInfo_SmtpServerInfo.hpp +73 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_AttachmentInfo.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_AttachmentInfo.hpp +75 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_EmailMessage.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_EmailMessage.hpp +83 -0
- package/nitrogen/generated/android/emailimapsmtp+autolinking.cmake +84 -0
- package/nitrogen/generated/android/emailimapsmtp+autolinking.gradle +27 -0
- package/nitrogen/generated/android/emailimapsmtpOnLoad.cpp +56 -0
- package/nitrogen/generated/android/emailimapsmtpOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/AppendResult.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/AttachmentInfo.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/ConnectionConfig.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/ConnectionResult.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/DeleteResult.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/EmailAddress.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/EmailBody.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/EmailMessage.kt +156 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/FetchEmailsOptions.kt +116 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/FolderInfo.kt +91 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/Func_void_IdleNotification.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/HybridEmailImapSmtpSpec.kt +178 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/IdleNotification.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/ImapServerInfo.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/MailboxInfo.kt +101 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/MailboxListItem.kt +71 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/QuotaInfo.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SearchCriteria.kt +196 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SearchHeader.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SendMailOptions.kt +126 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SendMailResult.kt +86 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SmtpAttachment.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SmtpConnectionConfig.kt +101 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SmtpServerInfo.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/Variant_ImapServerInfo_SmtpServerInfo.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/Variant_NullType_AttachmentInfo.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/Variant_NullType_EmailMessage.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/emailimapsmtpOnLoad.kt +35 -0
- package/nitrogen/generated/ios/EmailImapSmtp+autolinking.rb +62 -0
- package/nitrogen/generated/ios/EmailImapSmtp-Swift-Cxx-Bridge.cpp +161 -0
- package/nitrogen/generated/ios/EmailImapSmtp-Swift-Cxx-Bridge.hpp +1132 -0
- package/nitrogen/generated/ios/EmailImapSmtp-Swift-Cxx-Umbrella.hpp +118 -0
- package/nitrogen/generated/ios/EmailImapSmtpAutolinking.mm +33 -0
- package/nitrogen/generated/ios/EmailImapSmtpAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridEmailImapSmtpSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridEmailImapSmtpSpecSwift.hpp +390 -0
- package/nitrogen/generated/ios/swift/AppendResult.swift +39 -0
- package/nitrogen/generated/ios/swift/AttachmentInfo.swift +113 -0
- package/nitrogen/generated/ios/swift/ConnectionConfig.swift +87 -0
- package/nitrogen/generated/ios/swift/ConnectionResult.swift +84 -0
- package/nitrogen/generated/ios/swift/DeleteResult.swift +64 -0
- package/nitrogen/generated/ios/swift/EmailAddress.swift +34 -0
- package/nitrogen/generated/ios/swift/EmailBody.swift +45 -0
- package/nitrogen/generated/ios/swift/EmailMessage.swift +184 -0
- package/nitrogen/generated/ios/swift/FetchEmailsOptions.swift +198 -0
- package/nitrogen/generated/ios/swift/FolderInfo.swift +81 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_AppendResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_ConnectionResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_DeleteResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_IdleNotification.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_MailboxInfo.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_QuotaInfo.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_SendMailResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__AttachmentInfo_.swift +58 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__EmailMessage_.swift +58 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_AttachmentInfo_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_EmailMessage_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_FolderInfo_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_MailboxListItem_.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridEmailImapSmtpSpec.swift +84 -0
- package/nitrogen/generated/ios/swift/HybridEmailImapSmtpSpec_cxx.swift +759 -0
- package/nitrogen/generated/ios/swift/IdleNotification.swift +93 -0
- package/nitrogen/generated/ios/swift/ImapServerInfo.swift +45 -0
- package/nitrogen/generated/ios/swift/MailboxInfo.swift +91 -0
- package/nitrogen/generated/ios/swift/MailboxListItem.swift +55 -0
- package/nitrogen/generated/ios/swift/QuotaInfo.swift +80 -0
- package/nitrogen/generated/ios/swift/SearchCriteria.swift +485 -0
- package/nitrogen/generated/ios/swift/SearchHeader.swift +34 -0
- package/nitrogen/generated/ios/swift/SendMailOptions.swift +310 -0
- package/nitrogen/generated/ios/swift/SendMailResult.swift +155 -0
- package/nitrogen/generated/ios/swift/SmtpAttachment.swift +80 -0
- package/nitrogen/generated/ios/swift/SmtpConnectionConfig.swift +105 -0
- package/nitrogen/generated/ios/swift/SmtpServerInfo.swift +51 -0
- package/nitrogen/generated/ios/swift/Variant_ImapServerInfo_SmtpServerInfo.swift +30 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_AttachmentInfo.swift +30 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_EmailMessage.swift +30 -0
- package/nitrogen/generated/shared/c++/AppendResult.hpp +91 -0
- package/nitrogen/generated/shared/c++/AttachmentInfo.hpp +121 -0
- package/nitrogen/generated/shared/c++/ConnectionConfig.hpp +120 -0
- package/nitrogen/generated/shared/c++/ConnectionResult.hpp +98 -0
- package/nitrogen/generated/shared/c++/DeleteResult.hpp +93 -0
- package/nitrogen/generated/shared/c++/EmailAddress.hpp +87 -0
- package/nitrogen/generated/shared/c++/EmailBody.hpp +92 -0
- package/nitrogen/generated/shared/c++/EmailMessage.hpp +177 -0
- package/nitrogen/generated/shared/c++/FetchEmailsOptions.hpp +136 -0
- package/nitrogen/generated/shared/c++/FolderInfo.hpp +116 -0
- package/nitrogen/generated/shared/c++/HybridEmailImapSmtpSpec.cpp +50 -0
- package/nitrogen/generated/shared/c++/HybridEmailImapSmtpSpec.hpp +145 -0
- package/nitrogen/generated/shared/c++/IdleNotification.hpp +104 -0
- package/nitrogen/generated/shared/c++/ImapServerInfo.hpp +92 -0
- package/nitrogen/generated/shared/c++/MailboxInfo.hpp +124 -0
- package/nitrogen/generated/shared/c++/MailboxListItem.hpp +100 -0
- package/nitrogen/generated/shared/c++/QuotaInfo.hpp +104 -0
- package/nitrogen/generated/shared/c++/SearchCriteria.hpp +203 -0
- package/nitrogen/generated/shared/c++/SearchHeader.hpp +87 -0
- package/nitrogen/generated/shared/c++/SendMailOptions.hpp +151 -0
- package/nitrogen/generated/shared/c++/SendMailResult.hpp +113 -0
- package/nitrogen/generated/shared/c++/SmtpAttachment.hpp +105 -0
- package/nitrogen/generated/shared/c++/SmtpConnectionConfig.hpp +124 -0
- package/nitrogen/generated/shared/c++/SmtpServerInfo.hpp +92 -0
- package/package.json +196 -0
- package/react-native.config.js +27 -0
- package/src/EmailImapSmtp.nitro.ts +333 -0
- package/src/NativeEmailImapSmtp.ts +100 -0
- package/src/index.tsx +166 -0
- package/src/native.ts +305 -0
- package/src/types.ts +328 -0
- package/src/web.ts +196 -0
- package/src/windows.ts +304 -0
- package/windows/EmailImapSmtp.cpp +735 -0
- package/windows/EmailImapSmtp.h +137 -0
- package/windows/EmailImapSmtpModule.cpp +10 -0
- package/windows/EmailImapSmtpModule.h +139 -0
- package/windows/EmailImapSmtpPackage.cpp +15 -0
- package/windows/EmailImapSmtpPackage.h +13 -0
- package/windows/ImapProtocol.cpp +1382 -0
- package/windows/ImapProtocol.h +97 -0
- package/windows/ProtocolDefs.h +300 -0
- package/windows/SmtpProtocol.cpp +334 -0
- package/windows/SmtpProtocol.h +36 -0
- package/windows/TlsSocket.cpp +818 -0
- package/windows/TlsSocket.h +87 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// ImapProtocol.h — 纯 IMAP 协议实现,无 Nitro/JSI 依赖
|
|
3
|
+
// ============================================================
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <vector>
|
|
9
|
+
#include <unordered_map>
|
|
10
|
+
#include <functional>
|
|
11
|
+
#include <memory>
|
|
12
|
+
#include <mutex>
|
|
13
|
+
#include <set>
|
|
14
|
+
#include <regex>
|
|
15
|
+
#include <sstream>
|
|
16
|
+
#include <cctype>
|
|
17
|
+
#include <algorithm>
|
|
18
|
+
|
|
19
|
+
#include "ProtocolDefs.h"
|
|
20
|
+
#include "TlsSocket.h"
|
|
21
|
+
|
|
22
|
+
namespace emailimap {
|
|
23
|
+
|
|
24
|
+
struct ImapState {
|
|
25
|
+
bool connected = false;
|
|
26
|
+
bool selected = false;
|
|
27
|
+
std::string selectedMailbox;
|
|
28
|
+
std::string tagPrefix = "A";
|
|
29
|
+
int tagCounter = 0;
|
|
30
|
+
ConnectionConfig config;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
class ImapClient {
|
|
34
|
+
public:
|
|
35
|
+
ImapClient();
|
|
36
|
+
~ImapClient();
|
|
37
|
+
|
|
38
|
+
bool connect(const ConnectionConfig& config, std::string& error);
|
|
39
|
+
void disconnect();
|
|
40
|
+
bool isConnected() const;
|
|
41
|
+
|
|
42
|
+
std::vector<MailboxListItem> listMailboxes(std::string& error);
|
|
43
|
+
MailboxInfo selectMailbox(const std::string& mailbox, bool readOnly, std::string& error);
|
|
44
|
+
MailboxInfo refreshMailbox(std::string& error);
|
|
45
|
+
std::vector<FolderInfo> fetchFolders(std::string& error);
|
|
46
|
+
bool createFolder(const std::string& folderName, std::string& error);
|
|
47
|
+
bool deleteFolder(const std::string& folderName, std::string& error);
|
|
48
|
+
bool renameFolder(const std::string& oldName, const std::string& newName, std::string& error);
|
|
49
|
+
bool subscribeFolder(const std::string& folderName, std::string& error);
|
|
50
|
+
bool unsubscribeFolder(const std::string& folderName, std::string& error);
|
|
51
|
+
std::vector<EmailMessage> fetchEmails(const FetchEmailsOptions& options, std::string& error);
|
|
52
|
+
EmailMessage* fetchEmailByUID(double uid, std::string& error);
|
|
53
|
+
std::vector<EmailMessage> searchEmails(const SearchCriteria& criteria, std::string& error);
|
|
54
|
+
bool markAsRead(const std::vector<double>& uids, bool silent, std::string& error);
|
|
55
|
+
bool markAsFlagged(const std::vector<double>& uids, bool flagged, std::string& error);
|
|
56
|
+
bool moveEmails(const std::vector<double>& uids, const std::string& destinationMailbox, std::string& error);
|
|
57
|
+
bool copyEmails(const std::vector<double>& uids, const std::string& destinationMailbox, std::string& error);
|
|
58
|
+
DeleteResult deleteEmails(const std::vector<double>& uids, std::string& error);
|
|
59
|
+
bool expunge(std::string& error);
|
|
60
|
+
AttachmentInfo* fetchAttachment(double uid, const std::string& partId, std::string& error);
|
|
61
|
+
std::vector<AttachmentInfo> fetchAllAttachments(double uid, std::string& error);
|
|
62
|
+
bool idle(const std::function<void(const IdleNotification&)>& callback, std::string& error);
|
|
63
|
+
bool stopIdle(std::string& error);
|
|
64
|
+
QuotaInfo getQuota(const std::optional<std::string>& root, std::string& error);
|
|
65
|
+
AppendResult appendMessage(const std::string& mailbox,
|
|
66
|
+
const std::vector<uint8_t>& rawMimeData,
|
|
67
|
+
const std::optional<std::vector<std::string>>& flags,
|
|
68
|
+
std::string& error);
|
|
69
|
+
|
|
70
|
+
public:
|
|
71
|
+
// 桥接层 keep-alive 需要发送 NOOP;独立测试也可直接调用
|
|
72
|
+
bool sendCommand(const std::string& command, std::string& response, std::string& error);
|
|
73
|
+
bool sendRaw(const std::string& data);
|
|
74
|
+
int socketError() const { return m_socket ? m_socket->getLastError() : 0; }
|
|
75
|
+
|
|
76
|
+
private:
|
|
77
|
+
std::unique_ptr<TlsSocket> m_socket;
|
|
78
|
+
ImapState m_state;
|
|
79
|
+
|
|
80
|
+
std::string nextTag();
|
|
81
|
+
bool sendCommandMulti(const std::string& command, std::vector<std::string>& responses, std::string& error);
|
|
82
|
+
std::string receiveLine();
|
|
83
|
+
std::string receiveUntil(const std::string& delimiter);
|
|
84
|
+
bool waitForTaggedResponse(const std::string& tag, std::string& response, std::string& error);
|
|
85
|
+
bool waitForTaggedResponses(const std::string& tag, std::vector<std::string>& responses, std::string& error);
|
|
86
|
+
|
|
87
|
+
EmailMessage parseMessage(const std::string& rawHeaders, const std::string& rawBody, double uid, double seqNum);
|
|
88
|
+
void parseMimeParts(const std::string& contentType, const std::string& body,
|
|
89
|
+
std::string& textBody, std::string& htmlBody,
|
|
90
|
+
std::vector<AttachmentInfo>& attachments);
|
|
91
|
+
std::string decodeMimeHeader(const std::string& header);
|
|
92
|
+
std::string decodeQuotedPrintable(const std::string& text);
|
|
93
|
+
|
|
94
|
+
std::string m_responseBuffer;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
} // namespace emailimap
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// ProtocolDefs.h — 纯 C++ 数据类型定义
|
|
3
|
+
// 从 nitrogen/generated/shared/c++/*.hpp 提取 struct 定义,
|
|
4
|
+
// 去掉所有 NitroModules 头文件和 JSIConverter 特化,
|
|
5
|
+
// 使协议层可脱离 JSI/Nitro 独立编译。
|
|
6
|
+
//
|
|
7
|
+
// ⚠️ ArrayBuffer → std::vector<uint8_t> 替换
|
|
8
|
+
// ============================================================
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <string>
|
|
13
|
+
#include <vector>
|
|
14
|
+
#include <optional>
|
|
15
|
+
#include <variant>
|
|
16
|
+
#include <cstdint>
|
|
17
|
+
#include <functional>
|
|
18
|
+
#include <memory>
|
|
19
|
+
#include <unordered_map>
|
|
20
|
+
|
|
21
|
+
namespace emailimap {
|
|
22
|
+
|
|
23
|
+
// ═══════════════════════════════════════════════════════════
|
|
24
|
+
// Connection
|
|
25
|
+
// ═══════════════════════════════════════════════════════════
|
|
26
|
+
|
|
27
|
+
struct ConnectionConfig {
|
|
28
|
+
std::string host;
|
|
29
|
+
double port;
|
|
30
|
+
std::string username;
|
|
31
|
+
std::string password;
|
|
32
|
+
bool tls;
|
|
33
|
+
std::string authType;
|
|
34
|
+
std::optional<std::string> accessToken;
|
|
35
|
+
double timeout;
|
|
36
|
+
bool checkCertificate;
|
|
37
|
+
bool debug;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
struct SmtpConnectionConfig {
|
|
41
|
+
std::string host;
|
|
42
|
+
double port;
|
|
43
|
+
std::string username;
|
|
44
|
+
std::string password;
|
|
45
|
+
bool tls;
|
|
46
|
+
std::string authType;
|
|
47
|
+
std::optional<std::string> accessToken;
|
|
48
|
+
double timeout;
|
|
49
|
+
bool checkCertificate;
|
|
50
|
+
std::optional<std::string> helloName;
|
|
51
|
+
bool debug;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
struct ImapServerInfo {
|
|
55
|
+
std::string serverName;
|
|
56
|
+
std::vector<std::string> capabilities;
|
|
57
|
+
bool isCompressed;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
struct SmtpServerInfo {
|
|
61
|
+
std::string serverName;
|
|
62
|
+
std::vector<std::string> capabilities;
|
|
63
|
+
std::vector<std::string> supportedAuthMethods;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
struct ConnectionResult {
|
|
67
|
+
bool success;
|
|
68
|
+
std::optional<std::variant<ImapServerInfo, SmtpServerInfo>> serverInfo;
|
|
69
|
+
std::optional<std::string> error;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// ═══════════════════════════════════════════════════════════
|
|
73
|
+
// Mailbox / Folder
|
|
74
|
+
// ═══════════════════════════════════════════════════════════
|
|
75
|
+
|
|
76
|
+
struct MailboxListItem {
|
|
77
|
+
std::string name;
|
|
78
|
+
std::string path;
|
|
79
|
+
std::string delimiter;
|
|
80
|
+
std::vector<std::string> flags;
|
|
81
|
+
bool subscribed;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
struct FolderInfo {
|
|
85
|
+
std::string name;
|
|
86
|
+
std::string path;
|
|
87
|
+
std::string delimiter;
|
|
88
|
+
std::string parent;
|
|
89
|
+
std::vector<std::string> children;
|
|
90
|
+
std::vector<std::string> flags;
|
|
91
|
+
bool subscribed;
|
|
92
|
+
double messageCount;
|
|
93
|
+
double unseenCount;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
struct MailboxInfo {
|
|
97
|
+
std::string name;
|
|
98
|
+
std::string path;
|
|
99
|
+
double uidNext = 0;
|
|
100
|
+
double uidValidity = 0;
|
|
101
|
+
double messageCount = 0;
|
|
102
|
+
double recentCount = 0;
|
|
103
|
+
double unseenCount = 0;
|
|
104
|
+
double firstUnseenUid = 0;
|
|
105
|
+
double highestModSeq = 0;
|
|
106
|
+
std::vector<std::string> flags;
|
|
107
|
+
std::vector<std::string> permanentFlags;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// ═══════════════════════════════════════════════════════════
|
|
111
|
+
// Email
|
|
112
|
+
// ═══════════════════════════════════════════════════════════
|
|
113
|
+
|
|
114
|
+
struct EmailAddress {
|
|
115
|
+
std::string name;
|
|
116
|
+
std::string email;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
struct EmailBody {
|
|
120
|
+
std::string text;
|
|
121
|
+
std::string html;
|
|
122
|
+
std::vector<std::string> embeddedAttachments;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// ⚠️ ArrayBuffer → std::vector<uint8_t>
|
|
126
|
+
struct AttachmentInfo {
|
|
127
|
+
std::string filename;
|
|
128
|
+
std::string mimeType;
|
|
129
|
+
std::string partId;
|
|
130
|
+
double size = 0;
|
|
131
|
+
std::vector<uint8_t> data; // 原: shared_ptr<ArrayBuffer>
|
|
132
|
+
std::optional<std::string> contentId;
|
|
133
|
+
bool isInline = false;
|
|
134
|
+
std::optional<std::string> charset;
|
|
135
|
+
std::string contentDisposition;
|
|
136
|
+
std::optional<std::string> localPath;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
struct EmailMessage {
|
|
140
|
+
double uid = 0;
|
|
141
|
+
double sequenceNumber = 0;
|
|
142
|
+
std::string subject;
|
|
143
|
+
EmailAddress from;
|
|
144
|
+
std::vector<EmailAddress> to;
|
|
145
|
+
std::vector<EmailAddress> cc;
|
|
146
|
+
std::vector<EmailAddress> bcc;
|
|
147
|
+
std::vector<EmailAddress> replyTo;
|
|
148
|
+
std::string date;
|
|
149
|
+
std::string receivedDate;
|
|
150
|
+
std::string messageId;
|
|
151
|
+
std::string inReplyTo;
|
|
152
|
+
std::string references;
|
|
153
|
+
EmailBody body;
|
|
154
|
+
std::vector<AttachmentInfo> attachments;
|
|
155
|
+
std::vector<std::string> flags;
|
|
156
|
+
std::string mimeType;
|
|
157
|
+
std::string charset;
|
|
158
|
+
std::string priority;
|
|
159
|
+
bool isEncrypted = false;
|
|
160
|
+
std::unordered_map<std::string, std::string> headers;
|
|
161
|
+
double size = 0;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// ═══════════════════════════════════════════════════════════
|
|
165
|
+
// Fetch / Search Options
|
|
166
|
+
// ═══════════════════════════════════════════════════════════
|
|
167
|
+
|
|
168
|
+
struct FetchEmailsOptions {
|
|
169
|
+
std::optional<std::string> mailbox;
|
|
170
|
+
std::optional<double> from;
|
|
171
|
+
std::optional<double> to;
|
|
172
|
+
std::optional<std::string> rangeType;
|
|
173
|
+
std::optional<double> page;
|
|
174
|
+
std::optional<double> pageSize;
|
|
175
|
+
std::optional<std::string> since;
|
|
176
|
+
std::optional<std::string> before;
|
|
177
|
+
bool fetchBody = false;
|
|
178
|
+
bool fetchAttachments = false;
|
|
179
|
+
bool fetchFlags = false;
|
|
180
|
+
bool fetchHeaders = true;
|
|
181
|
+
bool fetchFullContent = false;
|
|
182
|
+
double maxBodySize = 1048576;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
struct SearchHeader {
|
|
186
|
+
std::string key;
|
|
187
|
+
std::string value;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
struct SearchCriteria {
|
|
191
|
+
std::optional<std::string> text;
|
|
192
|
+
std::optional<std::string> subject;
|
|
193
|
+
std::optional<std::string> from;
|
|
194
|
+
std::optional<std::string> to;
|
|
195
|
+
std::optional<std::string> body;
|
|
196
|
+
std::optional<std::string> since;
|
|
197
|
+
std::optional<std::string> before;
|
|
198
|
+
std::optional<std::string> on;
|
|
199
|
+
std::optional<std::string> sentSince;
|
|
200
|
+
std::optional<std::string> sentBefore;
|
|
201
|
+
std::optional<bool> flagged;
|
|
202
|
+
std::optional<bool> seen;
|
|
203
|
+
std::optional<bool> answered;
|
|
204
|
+
std::optional<bool> draft;
|
|
205
|
+
std::optional<bool> deleted;
|
|
206
|
+
std::optional<bool> junk;
|
|
207
|
+
std::optional<bool> hasAttachment;
|
|
208
|
+
std::optional<std::vector<double>> uids;
|
|
209
|
+
std::optional<SearchHeader> header;
|
|
210
|
+
std::optional<double> larger;
|
|
211
|
+
std::optional<double> smaller;
|
|
212
|
+
std::optional<std::string> mailbox;
|
|
213
|
+
std::optional<std::string> sortOrder;
|
|
214
|
+
std::optional<double> limit;
|
|
215
|
+
bool fetchBody = false;
|
|
216
|
+
bool fetchAttachments = false;
|
|
217
|
+
bool fetchFlags = false;
|
|
218
|
+
bool fetchHeaders = true;
|
|
219
|
+
bool fetchFullContent = false;
|
|
220
|
+
double maxBodySize = 1048576;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// ═══════════════════════════════════════════════════════════
|
|
224
|
+
// Batch / Quota / Append / Idle
|
|
225
|
+
// ═══════════════════════════════════════════════════════════
|
|
226
|
+
|
|
227
|
+
struct DeleteResult {
|
|
228
|
+
std::vector<double> success;
|
|
229
|
+
std::vector<double> failed;
|
|
230
|
+
std::optional<std::string> error;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
struct IdleNotification {
|
|
234
|
+
std::string type;
|
|
235
|
+
std::string mailbox;
|
|
236
|
+
std::optional<double> uid;
|
|
237
|
+
std::optional<std::string> flag;
|
|
238
|
+
std::optional<double> messageCount;
|
|
239
|
+
double timestamp = 0;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
struct QuotaInfo {
|
|
243
|
+
double storageUsed = 0;
|
|
244
|
+
double storageLimit = -1;
|
|
245
|
+
std::string storageUnit;
|
|
246
|
+
std::optional<double> messagesUsed;
|
|
247
|
+
std::optional<double> messagesLimit;
|
|
248
|
+
std::string root;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
struct AppendResult {
|
|
252
|
+
double uid = -1;
|
|
253
|
+
double uidValidity = 0;
|
|
254
|
+
std::string date;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// ═══════════════════════════════════════════════════════════
|
|
258
|
+
// SMTP
|
|
259
|
+
// ═══════════════════════════════════════════════════════════
|
|
260
|
+
|
|
261
|
+
struct SmtpAttachment {
|
|
262
|
+
std::string filename;
|
|
263
|
+
std::string mimeType;
|
|
264
|
+
std::vector<uint8_t> data; // 原: shared_ptr<ArrayBuffer>
|
|
265
|
+
std::optional<std::string> contentId;
|
|
266
|
+
bool isInline = false;
|
|
267
|
+
std::optional<std::string> disposition;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
struct SendMailOptions {
|
|
271
|
+
EmailAddress from;
|
|
272
|
+
std::vector<EmailAddress> to;
|
|
273
|
+
std::optional<std::vector<EmailAddress>> cc;
|
|
274
|
+
std::optional<std::vector<EmailAddress>> bcc;
|
|
275
|
+
std::optional<std::vector<EmailAddress>> replyTo;
|
|
276
|
+
std::string subject;
|
|
277
|
+
std::optional<std::string> textBody;
|
|
278
|
+
std::optional<std::string> htmlBody;
|
|
279
|
+
std::optional<std::vector<SmtpAttachment>> attachments;
|
|
280
|
+
std::optional<std::string> priority;
|
|
281
|
+
std::optional<std::unordered_map<std::string, std::string>> headers;
|
|
282
|
+
std::optional<std::string> inReplyTo;
|
|
283
|
+
std::optional<std::string> references;
|
|
284
|
+
std::optional<EmailAddress> readReceiptTo;
|
|
285
|
+
std::optional<std::string> charset;
|
|
286
|
+
std::optional<std::string> encoding;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
struct SendMailResult {
|
|
290
|
+
bool success = false;
|
|
291
|
+
std::optional<std::string> messageId;
|
|
292
|
+
std::optional<std::string> date;
|
|
293
|
+
std::optional<double> serverResponseCode;
|
|
294
|
+
std::optional<std::vector<uint8_t>> rawMimeData;
|
|
295
|
+
std::optional<std::string> queueId;
|
|
296
|
+
std::optional<std::string> error;
|
|
297
|
+
std::optional<bool> retryable;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
} // namespace emailimap
|