All Classes Namespaces Files Functions Variables Groups
Mails.idl
Go to the documentation of this file.
1 /**
2  * @file Mails.idl
3  * @brief Work with mails.
4  *
5  * @author Martin Hosna
6  *
7  * @copyright Copyright © 2017 Kerio Technologies s.r.o.
8  */
9 
10 /**
11  * @defgroup FOLDERS Accessing message folders
12  * @{
13  */
14 #import <Structures.idl>
15 #import <Certificates.idl>
16 
17 module kerio {
18 module jsonapi {
19 module webmail {
20 module mails {
21 
22 struct Email {
23  string name;
24  string address;
25  string contactId; ///< [WRITE-ONCE]
26 };
27 
28 typedef sequence<Email> EmailList;
29 
30 
31 struct Attachment {
32  string id; ///< origin ID of attachment or ID from upload response
33  string url; ///< [READ-ONLY] Relative URL from root of web. Eg.: /webmail/api/download/attachment/ba5767a9-7a70-4c90-a6bf-dc8dd62e259c/14/0-1-0-1/picture.jpg
34  string name; ///< [WRITE-ONCE] Filename. Can be empty if attachment is inline.
35  string contentType; ///< [WRITE-ONCE]
36  string contentId; ///< [WRITE-ONCE] Inline attachment parameter. URI is used in format cid:contentId in HTML parts.
37  long size; ///< [READ-ONLY]
38 };
39 
40 /** array of mail attachment */
41 typedef sequence<Attachment> AttachmentList;
42 
43 enum DisplayableContentType {
44  ctTextPlain,
45  ctTextHtml
46 };
47 
49  kerio::web::KId id; ///< [READ-ONLY] local identification, 0 = root mime part, 0-0 = sub-mime part, 0.1 = sub-mime part second item...
50  DisplayableContentType contentType;
51  string content; ///< UTF-8 encoded
52 };
53 
54 typedef sequence<DisplayableMimePart> DisplayableMimePartList;
55 
56 enum MimeHeaderType {
57  mhMessageID, ///< [READ-ONLY]
58  mhInReplayTo, ///< The contents of this field identify previous correspondence which this message answers. It contents an original 'Message-ID' value. rfc0822
59  mhResentMessageID ///< The contents of this field identify a forwarded message. It contains an original 'Message-ID' value. rfc0822
60 };
61 
62 struct MimeHeader {
63  MimeHeaderType type;
64  string value;
65 };
66 
67 typedef sequence<MimeHeader> MimeHeaderList;
68 
69 struct SignInfo {
70  boolean isSigned;
71  boolean isValid;
73 
75 };
76 
77 enum DecryptResult {
78  DecryptSuccesful,
79  DecryptNoKey,
80  DecryptError
81 };
82 
83 struct EncryptInfo {
84  boolean isEncrypted;
85  DecryptResult result;
87 };
88 
89 /** Constants for composing kerio::web::SearchQuery */
90 module searchFields {
91  const string QUICKSEARCH = "QUICKSEARCH"; ///< [SEARCHABLE] query=( ((subject LIKE $1) OR (from LIKE $1)) AND ((subject LIKE $2) OR (from LIKE $2)) ... OR (body == $0) ); $0 - whole phrase, $x - tokens of phrase
92  const string QUICKSEARCHSENT = "QUICKSEARCHSENT"; ///< [SEARCHABLE] query=( ((subject LIKE $1) OR (to LIKE $1)) AND ((subject LIKE $2) OR (to LIKE $2)) ... OR (body == $0) ); $0 - whole phrase, $x - tokens of phrase
93  const string FULLTEXT = "FULLTEXT"; ///< [SEARCHABLE] Just this field must be alone in search query with comparator 'Like'.
94  const string messageId = "messageId"; ///< [SEARCHABLE]
95  const string body = "body"; ///< [SEARCHABLE]
96  const string subject = "subject"; ///< [SEARCHABLE][SORTABLE]
97  const string from = "from"; ///< [SEARCHABLE][SORTABLE]
98  const string to = "to"; ///< [SEARCHABLE][SORTABLE]
99  const string cc = "cc"; ///< [SEARCHABLE][SORTABLE]
100  const string hasAttachment = "hasAttachment"; ///< [SEARCHABLE][SORTABLE]
101  const string priority = "priority"; ///< [SEARCHABLE][SORTABLE]
102  const string sendDate = "sendDate"; ///< [SEARCHABLE][SORTABLE]
103  const string receiveDate = "receiveDate"; ///< [SORTABLE]
104  const string size = "size"; ///< [SORTABLE]
105  const string modifiedDate = "modifiedDate"; ///< [SORTABLE]
106  const string isFlagged = "isFlagged"; ///< [SORTABLE]
107  const string isSeen = "isSeen"; ///< [SORTABLE]
108 };
109 
110 struct Mail {
111  kerio::web::KId id; ///< [READ-ONLY] global identification
112  kerio::web::KId folderId; ///< global identification
113  Watermark watermark;
114  Email from; ///< contents of the From header
115  Email sender; ///< contents of the Sender header. Use it for delegation. It shoudn't be the same as From header.
116  EmailList to; ///< contents of To header
117  EmailList cc; ///< contents of Cc header
118  EmailList bcc; ///< contents of BCc header
119  UtcDateTime sendDate; ///< contents of Date header (to be displayed in Sent Items). Not set for drafts.
120  UtcDateTime receiveDate; ///< mail delivery time. Not set for drafts.
121  UtcDateTime modifiedDate;
122  EmailList replyTo; ///< contents of Reply-To header
123  Email notificationTo; ///< contents of Disposition-Notification-To header
124 
125  string subject; ///< contents of Subject header
126  PriorityType priority; ///< mail priority (contents of X-Priority header). Defaults to normal priority.
127  long size; ///< mail size in bytes
128 
129  // flags ---------------------------------
130  boolean isSeen;
131  boolean isAnswered;
132  boolean isFlagged;
133  boolean isForwarded;
134  boolean isJunk;
135  boolean isMDNSent; ///< rfc3503; When saving an unfinished message to any folder client MUST set $MDNSent keyword to prevent another client from sending MDN for the message.
136  boolean showExternal; ///< It means the user confirm to show external sources (eg. images). It's false by default.
137  boolean requestDSN; ///< It is true if should be requested DSN even for successful delivered message. DSN for failure is default.
138  boolean hasAttachment; ///< [read-only]
139  boolean isDraft; ///< [read-only]
140  boolean isReadOnly; ///< [read-only]
141  // ---------------------------------------
142 
143  // SMIME ---------------------------------
144  SignInfo signInfo; ///< [read-only]
145  EncryptInfo encryptInfo; ///< [read-only]
146  // ---------------------------------------
147 
148  DisplayableMimePartList displayableParts;
149  AttachmentList attachments;
150  MimeHeaderList headers;
151 
152  boolean send; ///< [WRITE-ONLY] Send mail, beware it invalidate ID of this mail
153  boolean sign; ///< [WRITE-ONLY] Appends a signature as attachment
154  boolean encrypt; ///< [WRITE-ONLY] Encypts the email. Certificates of each recipient must be known.
155 };
156 
157 typedef sequence<Mail> MailList;
158 
159 
160 /**
161  * Mail store manager class
162  */
163 interface Mails {
164 
165  /**
166  * Get a list of e-mails.
167  *
168  * @param list - all found e-mails
169  * @param totalItems - number of mails found if there is no limit
170  * @param folderIds - list of global identifiers of folders to be listed.
171  * @param query - query attributes and limits
172  */
173  void get(out MailList list, out long totalItems, in kerio::web::KIdList folderIds, in kerio::web::SearchQuery query);
174 
175  /**
176  * Get a list of e-mails.
177  *
178  * @param list - all found e-mails
179  * @param totalItems - number of mails found if there is no limit
180  * @param folderIds - list of global identifiers of folders to be listed
181  * @param query - query attributes and limits. Mind that offset is not used
182  * @param id - global identifier of requested email
183  */
184  void getPageWithId(out MailList list, out long start, out long totalItems, in kerio::web::KIdList folderIds, in kerio::web::SearchQuery query, in kerio::web::KId id);
185 
186  /**
187  * Get one particular email. All members of struct Mail are filed in response.
188  *
189  * @param errors - list of email that failed to obtain
190  * @param result - found emails
191  * @param ids - global identifiers of requested emails
192  */
193  void getById(out kerio::web::ErrorList errors, out MailList result, in kerio::web::KIdList ids);
194 
195  /**
196  * Save e-mail to folder Templates or send and save to folder Sent Items
197  *
198  * @param errors - error message list
199  * @param result - list of ID of crated mails.
200  * @param mails - new mails.
201  *
202  * Errors:
203  * ErrorCodePartialSuccess - Failed to create mail but mail was successfully sent.
204  * ErrorCodeQuotaReached - Failed to create mail. Items quota or disk size quota was reached.
205  * ErrorCodeSendingFailed - Failed to send email and failed to create mail.
206  */
207  void create(out kerio::web::ErrorList errors, out CreateResultList result, in MailList mails);
208 
209  /**
210  * Remove a list of mails.
211  *
212  * @param errors - list of mails that failed to remove
213  * @param ids - list of global identifiers of mails to be removed
214  */
215  void remove(out kerio::web::ErrorList errors, in kerio::web::KIdList ids);
216 
217  /**
218  * Set existing e-mail in folder Templates or send and save to folder Sent
219  *
220  * @param errors - error message list
221  * @param mails - modifications of mails.
222  *
223  * Errors:
224  * ErrorCodePartialSuccess - Failed to move mail after update.
225  * ErrorCodeSendingFailed - Failed to send email and failed to update mail.
226  */
227  void set(out kerio::web::ErrorList errors, out SetResultList result, in MailList mails);
228 
229  /**
230  * Set all e-mail in folder as seen.
231  *
232  * @param folderId - target folder
233  */
234  void setAllSeen(in kerio::web::KId folderId);
235 
236  /**
237  * Copy existing e-mails to folder
238  *
239  * @param errors - error message list
240  * @param ids - list of global identifiers of mails to be copied
241  * @param folder - target folder
242  */
243  void copy(out kerio::web::ErrorList errors, out CreateResultList result, in kerio::web::KIdList ids, in kerio::web::KId folder);
244 
245  /**
246  * Move existing e-mails to folder
247  *
248  * @param errors - error message list
249  * @param ids - list of global identifiers of e-mails to be moved
250  * @param folder - target folder
251  */
252  void move(out kerio::web::ErrorList errors, out CreateResultList result, in kerio::web::KIdList ids, in kerio::web::KId folder);
253 
254  /**
255  * Export attachments from mail and pack them into zip.
256  *
257  * @param fileDownload - description of output file
258  * @param attachmentIds - list of global identifiers of attachments. All attachments must be from the same e-mail.
259  */
260  void exportAttachments(out kerio::web::Download fileDownload, in kerio::web::KIdList attachmentIds);
261 };
262 
263 }; }; }; }; // end of namespace
264 
265 /**
266  * @}
267  */