include: Wrap uses of u_* types in ws2tcpip.h with WS() macro.
[wine] / include / imnxport.idl
1 /*
2  * Copyright 2006 Robert Shearman for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 import "imnact.idl";
20
21 interface IInternetTransport;
22 interface ISMTPTransport;
23 interface IPOP3Transport;
24 interface IIMAPTransport;
25
26 /* CLSIDs */
27
28 cpp_quote("DEFINE_GUID(CLSID_IInternetMessageUrl, 0xca30cc91, 0xb1b3, 0x11d0, 0x85, 0xd0, 0x00, 0xc0, 0x4f, 0xd8, 0x5a, 0xb4);")
29 cpp_quote("DEFINE_GUID(CLSID_ISMTPTransport, 0xfd853ce6, 0x7f86, 0x11d0, 0x82, 0x52, 0x00, 0xc0, 0x4f, 0xd8, 0x5a, 0xb4);")
30 cpp_quote("DEFINE_GUID(CLSID_IPOP3Transport, 0xfd853ce7, 0x7f86, 0x11d0, 0x82, 0x52, 0x00, 0xc0, 0x4f, 0xd8, 0x5a, 0xb4);")
31 cpp_quote("DEFINE_GUID(CLSID_INNTPTransport, 0xfd853ce8, 0x7f86, 0x11d0, 0x82, 0x52, 0x00, 0xc0, 0x4f, 0xd8, 0x5a, 0xb4);")
32 cpp_quote("DEFINE_GUID(CLSID_IRASTransport, 0xfd853ce9, 0x7f86, 0x11d0, 0x82, 0x52, 0x00, 0xc0, 0x4f, 0xd8, 0x5a, 0xb4);")
33 cpp_quote("DEFINE_GUID(CLSID_IRangeList, 0xfd853cea, 0x7f86, 0x11d0, 0x82, 0x52, 0x00, 0xc0, 0x4f, 0xd8, 0x5a, 0xb4);")
34 cpp_quote("DEFINE_GUID(CLSID_IIMAPTransport, 0xfd853ceb, 0x7f86, 0x11d0, 0x82, 0x52, 0x00, 0xc0, 0x4f, 0xd8, 0x5a, 0xb4);")
35 cpp_quote("DEFINE_GUID(CLSID_IHTTPMailTransport, 0x5a580c11, 0xe5eb, 0x11d1, 0xa8, 0x6e, 0x00, 0x00, 0xf8, 0x08, 0x4f, 0x96);")
36 cpp_quote("DEFINE_GUID(CLSID_IPropFindRequest, 0xbb847b8a, 0x054a, 0x11d2, 0xa8, 0x94, 0x00, 0x00, 0xf8, 0x08, 0x4f, 0x96);")
37 cpp_quote("DEFINE_GUID(CLSID_IPropPatchRequest, 0xea678830, 0x235d, 0x11d2, 0xa8, 0xb6, 0x00, 0x00, 0xf8, 0x08, 0x4f, 0x96);")
38
39 /* Error Codes */
40
41 cpp_quote("#ifndef HR_E")
42 cpp_quote("#define HR_E(n) MAKE_SCODE(SEVERITY_ERROR, FACILITY_INTERNET, n)")
43 cpp_quote("#endif")
44 cpp_quote("#ifndef HR_S")
45 cpp_quote("#define HR_S(n) MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_INTERNET, n)")
46 cpp_quote("#endif")
47
48 /* General Error Codes */
49 cpp_quote("#define IXP_E_LOAD_SICILY_FAILED     HR_E(0xCC00)")
50 cpp_quote("#define IXP_E_INVALID_CERT_CN        HR_E(0xCC01)")
51 cpp_quote("#define IXP_E_INVALID_CERT_DATE      HR_E(0xCC02)")
52 cpp_quote("#define IXP_E_ALREADY_CONNECTED      HR_E(0xCC03)")
53 cpp_quote("#define IXP_E_CONN                   HR_E(0xCC04)")
54 cpp_quote("#define IXP_E_NOT_CONNECTED          HR_E(0xCC05)")
55 cpp_quote("#define IXP_E_CONN_SEND              HR_E(0xCC06)")
56 cpp_quote("#define IXP_E_WOULD_BLOCK            HR_E(0xCC07)")
57 cpp_quote("#define IXP_E_INVALID_STATE          HR_E(0xCC08)")
58 cpp_quote("#define IXP_E_CONN_RECV              HR_E(0xCC09)")
59 cpp_quote("#define IXP_E_INCOMPLETE             HR_E(0xCC0A)")
60 cpp_quote("#define IXP_E_BUSY                   HR_E(0xCC0B)")
61 cpp_quote("#define IXP_E_NOT_INIT               HR_E(0xCC0C)")
62 cpp_quote("#define IXP_E_CANT_FIND_HOST         HR_E(0xCC0D)")
63 cpp_quote("#define IXP_E_FAILED_TO_CONNECT      HR_E(0xCC0E)")
64 cpp_quote("#define IXP_E_CONNECTION_DROPPED     HR_E(0xCC0F)")
65 cpp_quote("#define IXP_E_INVALID_ADDRESS        HR_E(0xCC10)")
66 cpp_quote("#define IXP_E_INVALID_ADDRESS_LIST   HR_E(0xCC11)")
67 cpp_quote("#define IXP_E_SOCKET_READ_ERROR      HR_E(0xCC12)")
68 cpp_quote("#define IXP_E_SOCKET_WRITE_ERROR     HR_E(0xCC13)")
69 cpp_quote("#define IXP_E_SCOKET_INIT_ERROR      HR_E(0xCC14)")
70 cpp_quote("#define IXP_E_SOCKET_CONNECT_ERROR   HR_E(0xCC15)")
71 cpp_quote("#define IXP_E_INVALID_ACCOUNT        HR_E(0xCC16)")
72 cpp_quote("#define IXP_E_USER_CANCEL            HR_E(0xCC17)")
73 cpp_quote("#define IXP_E_SICILY_LOGON_FAILED    HR_E(0xCC18)")
74 cpp_quote("#define IXP_E_TIMEOUT                HR_E(0xCC19)")
75 cpp_quote("#define IXP_E_SECURE_CONNECT_FAILED  HR_E(0xCC1A)")
76
77 /* SMTP Failure Statuses */
78 cpp_quote("#define IXP_E_SMTP_RESPONSE_ERROR            HR_E(0xCC60)")
79 cpp_quote("#define IXP_E_SMTP_UNKNOWN_RESPONSE_CODE     HR_E(0xCC61)")
80 cpp_quote("#define IXP_E_SMTP_500_SYNTAX_ERROR          HR_E(0xCC62)")
81 cpp_quote("#define IXP_E_SMTP_501_PARAM_SYNTAX          HR_E(0xCC63)")
82 cpp_quote("#define IXP_E_SMTP_502_COMMAND_NOTIMPL       HR_E(0xCC64)")
83 cpp_quote("#define IXP_E_SMTP_503_COMMAND_SEQ           HR_E(0xCC65)")
84 cpp_quote("#define IXP_E_SMTP_504_COMMAND_PARAM_NOTIMPL HR_E(0xCC66)")
85 cpp_quote("#define IXP_E_SMTP_421_NOT_AVAILABLE         HR_E(0xCC67)")
86 cpp_quote("#define IXP_E_SMTP_450_MAILBOX_BUSY          HR_E(0xCC68)")
87 cpp_quote("#define IXP_E_SMTP_550_MAILBOX_NOT_FOUND     HR_E(0xCC69)")
88 cpp_quote("#define IXP_E_SMTP_451_ERROR_PROCESSING      HR_E(0xCC6A)")
89 cpp_quote("#define IXP_E_SMTP_551_USER_NOT_LOCAL        HR_E(0xCC6B)")
90 cpp_quote("#define IXP_E_SMTP_452_NO_SYSTEM_STORAGE     HR_E(0xCC6C)")
91 cpp_quote("#define IXP_E_SMTP_552_STORAGE_OVERFLOW      HR_E(0xCC6D)")
92 cpp_quote("#define IXP_E_SMTP_553_MAILBOX_NAME_SYNTAX   HR_E(0xCC6E)")
93 cpp_quote("#define IXP_E_SMTP_554_TRANSACT_FAILED       HR_E(0xCC6F)")
94
95 /* SMTP Success Statuses */
96 cpp_quote("#define IXP_E_SMTP_211_SYSTEM_STATUS         HR_S(0xCC70)")
97 cpp_quote("#define IXP_E_SMTP_214_HELP_MESSAGE          HR_S(0xCC71)")
98 cpp_quote("#define IXP_E_SMTP_220_READY                 HR_S(0xCC72)")
99 cpp_quote("#define IXP_E_SMTP_221_CLOSING               HR_S(0xCC73)")
100 cpp_quote("#define IXP_E_SMTP_250_MAIL_ACTION_OKAY      HR_S(0xCC74)")
101 cpp_quote("#define IXP_E_SMTP_251_FORWARDING_MAIL       HR_S(0xCC75)")
102 cpp_quote("#define IXP_E_SMTP_354_START_MAIL_INPUT      HR_S(0xCC76)")
103 cpp_quote("#define IXP_E_SMTP_CONTINUE                  HR_S(0xCC77)")
104 cpp_quote("#define IXP_E_SMTP_334_AUTH_READY_RESPONSE   HR_S(0xCC78)")
105 cpp_quote("#define IXP_E_SMTP_245_AUTH_SUCCESS          HR_S(0xCC79)")
106
107 /* More SMTP Failure Statuses */
108 cpp_quote("#define IXP_E_SMTP_REJECTED_SENDER           HR_E(0xCC78)")
109 cpp_quote("#define IXP_E_SMTP_REJECTED_RECIPIENTS       HR_E(0xCC79)")
110 cpp_quote("#define IXP_E_SMTP_NO_SENDER                 HR_E(0xCC7A)")
111 cpp_quote("#define IXP_E_SMTP_NO_RECIPIENTS             HR_E(0xCC7B)")
112 cpp_quote("#define IXP_E_SMTP_530_STARTTLS_REQUIRED     HR_E(0xCC7C)")
113 cpp_quote("#define IXP_E_SMTP_NO_STARTTLS_SUPPORT       HR_E(0xCC7D)")
114 cpp_quote("#define IXP_E_SMTP_NO_DSN_SUPPORT            HR_E(0xCC7E)")
115 cpp_quote("#define IXP_E_SMTP_454_STARTTLS_FAILED       HR_E(0xCC7F)")
116
117 const SHORT CCHMAX_DOMAIN = 256;
118 const SHORT CCHMAX_PHONE_NUMBER = 128;
119
120 const DWORD DEFAULT_IMAP_PORT = 143;
121 const DWORD DEFAULT_POP3_PORT = 110;
122 const DWORD DEFAULT_SMTP_PORT = 25;
123 const DWORD DEFAULT_NNTP_PORT = 119;
124
125 typedef enum tagINETADDRTYPE
126 {
127     ADDR_TO,
128     ADDR_FROM,
129     ADDR_DSN_NEVER = 16,
130     ADDR_DSN_SUCCESS = 32,
131     ADDR_DSN_FAILURE = 64,
132     ADDR_DSN_DELAY = 128
133 } INETADDRTYPE;
134
135 const DWORD ADDR_TOFROM_MASK = 0x1;
136 const DWORD ADDR_DSN_MASK = 0xf0;
137
138 typedef enum tagDSNRET
139 {
140     DSNRET_DEFAULT,
141     DSNRET_HDRS,
142     DSNRET_FULL,
143 } DSNRET;
144
145 typedef struct tagINETADDR
146 {
147     INETADDRTYPE addrtype;
148     CHAR szEmail[CCHMAX_EMAIL_ADDRESS];
149 } INETADDR, *LPINETADDR;
150
151 typedef struct tagINETADDRLIST
152 {
153     ULONG cAddress;
154     LPINETADDR prgAddress;
155 } INETADDRLIST, *LPINETADDRLIST;
156
157 typedef enum tagRASCONNTYPE
158 {
159     RAS_CONNECT_LAN,
160     RAS_CONNECT_MANUAL,
161     RAS_CONNECT_RAS
162 } RASCONNTYPE;
163
164 typedef enum tagHTTPMAILPROPTYPE
165 {
166     HTTPMAIL_PROP_INVALID,
167     HTTPMAIL_PROP_ADBAR,
168     HTTPMAIL_PROP_CONTACTS,
169     HTTPMAIL_PROP_INBOX,
170     HTTPMAIL_PROP_OUTBOX,
171     HTTPMAIL_PROP_SENDMSG,
172     HTTPMAIL_PROP_SENTITEMS,
173     HTTPMAIL_PROP_DELETEDITEMS,
174     HTTPMAIL_PROP_DRAFTS,
175     HTTPMAIL_PROP_MSGFOLDERROOT,
176     HTTPMAIL_PROP_SIG,
177     HTTPMAIL_PROP_LAST
178 } HTTPMAILPROPTYPE;
179
180 typedef enum tagHTTPMAILSPECIALFOLDER
181 {
182     HTTPMAIL_SF_NONE,
183     HTTPMAIL_SF_UNRECOGNIZED,
184     HTTPMAIL_SF_INBOX,
185     HTTPMAIL_SF_DELETEDITEMS,
186     HTTPMAIL_SF_DRAFTS,
187     HTTPMAIL_SF_OUTBOX,
188     HTTPMAIL_SF_SENTITEMS,
189     HTTPMAIL_SF_CONTACTS,
190     HTTPMAIL_SF_CALENDAR,
191     HTTPMAIL_SF_MSNPROMO,
192     HTTPMAIL_SF_LAST
193 } HTTPMAILSPECIALFOLDER;
194
195 typedef enum tagHTTPMAILCONTACTTYPE
196 {
197     HTTPMAIL_CT_CONTACT,
198     HTTPMAIL_CT_GROUP,
199     HTTPMAIL_CT_LAST
200 } HTTPMAILCONTACTTYPE;
201
202 const DWORD DAVNAMESPACE_UNKNOWN = 0xFFFFFFFF;
203 const DWORD DAVNAMESPACE_DAV = 0;
204 const DWORD DAVNAMESPACE_HOTMAIL = 1;
205 const DWORD DAVNAMESPACE_HTTPMAIL = 2;
206 const DWORD DAVNAMESPACE_MAIL = 3;
207 const DWORD DAVNAMESPACE_CONTACTS = 4;
208
209 cpp_quote("#define ISF_SMTP_USEIPFORHELO        0x01")
210 cpp_quote("#define ISF_ALWAYSPROMPTFORPASSWORD  0x02")
211 /* for SMTP - send EHLO and use STARTTLS if available: */
212 cpp_quote("#define ISF_SSLONSAMEPORT            0x04")
213 cpp_quote("#define ISF_QUERYDSNSUPPORT          0x08")
214 /* for SMTP - send EHLO and use AUTH if available: */
215 cpp_quote("#define ISF_QUERYAUTHSUPPORT         0x10")
216
217 typedef struct INETSERVER
218 {
219     CHAR szAccount[CCHMAX_ACCOUNT_NAME];
220     CHAR szUserName[CCHMAX_USERNAME];
221     CHAR szPassword[CCHMAX_PASSWORD];
222     CHAR szServerName[CCHMAX_SERVER_NAME];
223     CHAR szConnectoid[CCHMAX_CONNECTOID];
224     RASCONNTYPE rasconntype;
225     DWORD dwPort;
226     BOOL fSSL;
227     BOOL fTrySicily;
228     DWORD dwTimeout;
229     DWORD dwFlags;
230 } INETSERVER, *LPINETSERVER;
231
232 typedef enum tagIXPTYPE
233 {
234     IXP_NNTP,
235     IXP_SMTP,
236     IXP_POP3,
237     IXP_IMAP,
238     IXP_RAS,
239     IXP_HTTPMail
240 } IXPTYPE;
241
242 typedef enum tagIXPSTATUS
243 {
244     IXP_FINDINGHOST,
245     IXP_CONNECTING,
246     IXP_SECURING,
247     IXP_CONNECTED,
248     IXP_AUTHORIZING,
249     IXP_AUTHRETRY,
250     IXP_AUTHORIZED,
251     IXP_DISCONNECTING,
252     IXP_DISCONNECTED,
253     IXP_LAST
254 } IXPSTATUS;
255
256 const DWORD DEPTH_INFINITY = 0xFFFFFFFE;
257
258 typedef DWORD MEMBERINFOFLAGS;
259
260 const MEMBERINFOFLAGS HTTP_MEMBERINFO_COMMONPROPS = 0x0;
261 const MEMBERINFOFLAGS HTTP_MEMBERINFO_FOLDERPROPS = 0x1;
262 const MEMBERINFOFLAGS HTTP_MEMBERINFO_MESSAGEPROPS = 0x2;
263 const MEMBERINFOFLAGS HTTP_MEMBERINFO_ALLPROPS = HTTP_MEMBERINFO_FOLDERPROPS | HTTP_MEMBERINFO_MESSAGEPROPS;
264
265 typedef DWORD IMAP_MSGFLAGS;
266
267 const IMAP_MSGFLAGS IMAP_MSG_NOFLAGS = 0x00;
268 const IMAP_MSGFLAGS IMAP_MSG_ANSWERED = 0x01;
269 const IMAP_MSGFLAGS IMAP_MSG_FLAGGED = 0x02;
270 const IMAP_MSGFLAGS IMAP_MSG_DELETED = 0x04;
271 const IMAP_MSGFLAGS IMAP_MSG_SEEN = 0x08;
272 const IMAP_MSGFLAGS IMAP_MSG_DRAFT = 0x10;
273 const IMAP_MSGFLAGS IMAP_MSG_ALLFLAGS = 0x1f;
274
275 [
276     object,
277     uuid(CA30F3FF-C9AC-11D1-9A3A-00C04FA309D4),
278     local
279 ]
280 interface ITransportCallbackService : IUnknown
281 {
282     HRESULT GetParentWindow(
283         [in]    DWORD dwReserved,
284         [out]   HWND *phwndParent);
285
286     HRESULT GetAccount(
287         [out]   LPDWORD pdwServerType,
288         [out]   IImnAccount **ppAccount);
289 }
290
291 [
292     object,
293     uuid(0DF2C7E1-3435-11D0-81D0-00C04FD85AB4),
294     local
295 ]
296 interface ITransportCallback : IUnknown
297 {
298     typedef struct tagIXPRESULT
299     {
300         HRESULT hrResult;
301         LPSTR pszResponse;
302         UINT uiServerError;
303         HRESULT hrServerError;
304         DWORD dwSocketError;
305         LPSTR pszProblem;
306     } IXPRESULT, *LPIXPRESULT;
307
308     typedef enum tagCMDTYPE
309     {
310         CMD_SEND,
311         CMD_RESP
312     } CMDTYPE;
313
314     HRESULT OnTimeout(
315         [in,out]    DWORD *pdwTimeout,
316         [in]        IInternetTransport *pTransport);
317
318     HRESULT OnLogonPrompt(
319         [in,out]    LPINETSERVER pInetServer,
320         [in]        IInternetTransport *pTransport);
321
322     INT OnPrompt(
323         [in]    HRESULT hrError,
324         [in]    LPCSTR pszText,
325         [in]    LPCSTR pszCaption,
326         [in]    UINT uType,
327         [in]    IInternetTransport *pTransport);
328
329     HRESULT OnStatus(
330         [in]    IXPSTATUS ixpstatus,
331         [in]    IInternetTransport *pTransport);
332
333     HRESULT OnError(
334         [in]    IXPSTATUS ixpstatus,
335         [in]    LPIXPRESULT pResult,
336         [in]    IInternetTransport *pTransport);
337
338     HRESULT OnCommand(
339         [in]    CMDTYPE cmdtype,
340         [in]    LPSTR pszLine,
341         [in]    HRESULT hrResponse,
342         [in]    IInternetTransport *pTransport);
343 }
344
345 [
346     object,
347     uuid(1F636C01-364E-11D0-81D3-00C04FD85AB4),
348     local
349 ]
350 interface IInternetTransport : IUnknown
351 {
352     const boolean iitAUTHENTICATE = TRUE;
353     const boolean iitDONT_AUTHENTICATe = FALSE;
354     const boolean iitENABLE_ONCOMMAND = TRUE;
355     const boolean iitDISABLE_ONCOMMAND = FALSE;
356
357     typedef enum tagIXPISSTATE
358     {
359         IXP_IS_CONNECTED,
360         IXP_IS_BUSY,
361         IXP_IS_READY,
362         IXP_IS_AUTHENTICATED
363     } IXPISSTATE;
364
365     HRESULT GetServerInfo(
366         [in,out]    LPINETSERVER pInetServer);
367
368     IXPTYPE GetIXPType();
369
370     HRESULT IsState(
371         [in]    IXPISSTATE isstate);
372
373     HRESULT InetServerFromAccount(
374         [in]        IImnAccount *pAccount,
375         [in,out]    LPINETSERVER pInetServer);
376
377     HRESULT Connect(
378         [in]    LPINETSERVER pInetServer,
379         [in]    boolean fAuthenticate,
380         [in]    boolean fCommandLogging);
381
382     HRESULT HandsOffCallback();
383
384     HRESULT Disconnect();
385
386     HRESULT DropConnection();
387
388     HRESULT GetStatus(
389         [out]   IXPSTATUS *pCurrentStatus);
390 }
391
392 [
393     object,
394     uuid(1F636C02-364E-11D0-81D3-00C04FD85AB4),
395     local
396 ]
397 interface ISMTPCallback : ITransportCallback
398 {
399     typedef enum tagSMTPCOMMAND
400     {
401         SMTP_NONE,
402         SMTP_BANNER,
403         SMTP_CONNECTED,
404         SMTP_SEND_MESSAGE,
405         SMTP_AUTH,
406         SMTP_EHLO,
407         SMTP_HELO,
408         SMTP_MAIL,
409         SMTP_RCPT,
410         SMTP_RSET,
411         SMTP_QUIT,
412         SMTP_DATA,
413         SMTP_DOT,
414         SMTP_SEND_STREAM,
415         SMTP_CUSTOM
416     } SMTPCOMMAND;
417
418     typedef struct tagSMTPSTREAM
419     {
420         DWORD cbIncrement;
421         DWORD cbCurrent;
422         DWORD cbTotal;
423     } SMTPSTREAM, *LPSMTPSTREAM;
424
425     typedef struct tagSMTPRESPONSE
426     {
427         SMTPCOMMAND command;
428         BOOL fDone;
429         IXPRESULT rIxpResult;
430         ISMTPTransport *pTransport;
431
432         [switch_type(SMTPCOMMAND), switch_is(command)]
433         union
434         {
435         [case(SMTP_SEND_STREAM)]    SMTPSTREAM rStreamInfo;
436         [default];
437         } DUMMYUNIONNAME;
438     } SMTPRESPONSE, *LPSMTPRESPONSE;
439
440     HRESULT OnResponse(
441         [in] LPSMTPRESPONSE pResponse);
442 }
443
444 [
445     object,
446     uuid(0DF2C7E2-3435-11D0-81D0-00C04FD85AB4),
447     local
448 ]
449 interface ISMTPTransport : IInternetTransport
450 {
451     typedef struct tagSMTPMESSAGE
452     {
453         ULONG cbSize;
454         LPSTREAM pstmMsg;
455         INETADDRLIST rAddressList;
456     } SMTPMESSAGE, *LPSMTPMESSAGE;
457
458     HRESULT InitNew(
459         [in]    LPSTR pszLogFilePath,
460         [in]    ISMTPCallback *pCallback);
461
462 cpp_quote("#ifdef WINE_NO_UNICODE_MACROS")
463 cpp_quote("#undef SendMessage")
464 cpp_quote("#endif")
465
466     HRESULT SendMessage(
467         [in]    LPSMTPMESSAGE pMessage);
468
469     HRESULT CommandMAIL(
470         [in]    LPSTR pszEmailFrom);
471
472     HRESULT CommandRCPT(
473         [in]    LPSTR pszEmailTo);
474
475     HRESULT CommandEHLO();
476
477     HRESULT CommandHELO();
478
479     HRESULT CommandAUTH(
480         [in]    LPSTR pszAuthType);
481
482     HRESULT CommandQUIT();
483
484     HRESULT CommandRSET();
485
486     HRESULT CommandDATA();
487
488     HRESULT CommandDOT();
489
490     HRESULT SendDataStream(
491         [in]    IStream *pStream,
492         [in]    ULONG cbSize);
493 }
494
495 [
496     object,
497     uuid(0DF2C7EC-3435-11D0-81D0-00C04FD85AB4),
498     local
499 ]
500 interface ISMTPTransport2 : ISMTPTransport
501 {
502     typedef struct tagSMTPMESSAGE2
503     {
504         SMTPMESSAGE smtpMsg;
505         LPSTR pszDSNENVID;
506         DSNRET dsnRet;
507         DWORD dwReserved;
508         DWORD dwReserved2;
509     } SMTPMESSAGE2, *LPSMTPMESSAGE2;
510
511     HRESULT SetWindow();
512
513     HRESULT ResetWindow();
514
515     HRESULT SendMessage2(
516         [in]    LPSMTPMESSAGE2 pMessage);
517
518     HRESULT CommandRCPT2(
519         [in]    LPSTR pszEmailTo,
520         [in]    INETADDRTYPE atDSN);
521 }
522
523 /* FIXME: IDAVNamespaceArbiter, IPropPatchRequest, IPropFindRequest, IPropFindMultiResponse, IPropFindResponse, IHTTPMailCallback, IHTTPMailTransport */
524
525 [
526     object,
527     uuid(0DF2C7E3-3435-11D0-81D0-00C04FD85AB4),
528     local
529 ]
530 interface IPOP3Callback : ITransportCallback
531 {
532     typedef enum tagPOP3COMMAND
533     {
534         POP3_NONE,
535         POP3_BANNER,
536         POP3_CONNECTED,
537         POP3_USER,
538         POP3_PASS,
539         POP3_AUTH,
540         POP3_UIDL,
541         POP3_STAT,
542         POP3_LIST,
543         POP3_DELE,
544         POP3_RETR,
545         POP3_TOP,
546         POP3_NOOP,
547         POP3_QUIT,
548         POP3_RSET,
549         POP3_CUSTOM
550     } POP3COMMAND;
551
552     typedef struct tagPOP3RETR
553     {
554         BOOL fHeader;
555         BOOL fBody;
556         DWORD dwPopId;
557         DWORD cbSoFar;
558         LPSTR pszLines;
559         ULONG cbLines;
560     } POP3RETR, *LPPOP3RETR;
561
562     typedef struct tagPOP3TOP
563     {
564         BOOL fHeader;
565         BOOL fBody;
566         DWORD dwPopId;
567         DWORD cPreviewLines;
568         DWORD cbSoFar;
569         LPSTR pszLines;
570         ULONG cbLines;
571     } POP3TOP, *LPPOP3TOP;
572
573     typedef struct tagPOP3LIST
574     {
575         DWORD dwPopId;
576         DWORD cbSize;
577     } POP3LIST, *LPPOP3LIST;
578
579     typedef struct tagPOP3UIDL
580     {
581         DWORD dwPopId;
582         LPSTR pszUidl;
583     } POP3UIDL, *LPPOP3UIDL;
584
585     typedef struct tagPOP3STAT
586     {
587         DWORD cMessages;
588         DWORD cbMessages;
589     } POP3STAT, *LPPOP3STAT;
590
591     typedef struct tagPOP3RESPONSE
592     {
593         POP3COMMAND command;
594         BOOL fDone;
595         IXPRESULT rIxpResult;
596         IPOP3Transport *pTransport;
597         BOOL fValidInfo;
598         [switch_type(POP3COMMAND), switch_is(command)]
599         union
600         {
601         [case(POP3_UIDL)] POP3UIDL rUidlInfo;
602         [case(POP3_STAT)] POP3STAT rStatInfo;
603         [case(POP3_LIST)] POP3LIST rListInfo;
604         [case(POP3_DELE)] DWORD dwPopId;
605         [case(POP3_RETR)] POP3RETR rRetrInfo;
606         [case(POP3_TOP)]  POP3TOP rTopInfo;
607         [default];
608         } DUMMYUNIONNAME;
609     } POP3RESPONSE, *LPPOP3RESPONSE;
610
611     HRESULT OnResponse(
612         [in]    LPPOP3RESPONSE pResponse);
613 }
614
615 [
616     object,
617     uuid(0DF2C7E4-3435-11D0-81D0-00C04FD85AB4),
618     local
619 ]
620 interface IPOP3Transport : IInternetTransport
621 {
622     typedef enum tagPOP3CMDTYPE
623     {
624         POP3CMD_GET_POPID,
625         POP3CMD_GET_MARKED,
626         POP3CMD_GET_ALL
627     } POP3CMDTYPE;
628
629     typedef enum tagPOP3MARKTYPE
630     {
631         POP3_MARK_FOR_TOP = 0x01,
632         POP3_MARK_FOR_RETR = 0x02,
633         POP3_MARK_FOR_DELE = 0x04,
634         POP3_MARK_FOR_UIDL = 0x08,
635         POP3_MARK_FOR_LIST = 0x10
636     } POP3MARKTYPE;
637
638     HRESULT InitNew(
639         [in]    LPSTR pszLogFilePath,
640         [in]    IPOP3Callback *pCallback);
641
642     HRESULT MarkItem(
643         [in]    POP3MARKTYPE marktype,
644         [in]    DWORD dwPopId,
645         [in]    boolean fMarked);
646
647     HRESULT CommandAUTH(
648         [in]    LPSTR pszAuthType);
649
650     HRESULT CommandUSER(
651         [in]    LPSTR pszUserName);
652
653     HRESULT CommandPASS(
654         [in]    LPSTR pszPassword);
655
656     HRESULT CommandLIST(
657         [in]    POP3CMDTYPE cmdtype,
658         [in]    DWORD dwPopId);
659
660     HRESULT CommandTOP(
661         [in]    POP3CMDTYPE cmdtype,
662         [in]    DWORD dwPopId,
663         [in]    DWORD cPreviewLines);
664
665     HRESULT CommandQUIT();
666
667     HRESULT CommandSTAT();
668
669     HRESULT CommandNOOP();
670
671     HRESULT CommandRSET();
672
673     HRESULT CommandUIDL(
674         [in]    POP3CMDTYPE cmdtype,
675         [in]    DWORD dwPopId);
676
677     HRESULT CommandDELE(
678         [in]    POP3CMDTYPE cmdtype,
679         [in]    DWORD dwPopId);
680
681     HRESULT CommandRETR(
682         [in]    POP3CMDTYPE cmdtype,
683         [in]    DWORD dwPopId);
684 }
685
686 /* FIXME: INNTPCallback, INNTPTransport */
687
688 [
689     object,
690     uuid(8C438160-4EF6-11d0-874F-00AA00530EE9),
691     local,
692 ]
693 interface IRangeList : IUnknown
694 {
695     const ULONG RL_RANGE_ERROR = ((ULONG)-1);
696     const ULONG RL_LAST_MESSAGE = ((ULONG)-1);
697
698     HRESULT Clear();
699
700     HRESULT IsInRange(
701         [in]    const ULONG value);
702
703     HRESULT Min(
704         [out]   ULONG *pulMin);
705
706     HRESULT Max(
707         [out]   ULONG *pulMax);
708
709     HRESULT Save(
710         [out]   byte **ppbDestination,
711         [out]   ULONG *pulSizeOfDestination);
712
713     HRESULT Load(
714         [in, size_is(ulSizeOfSource)]   byte *pbSource,
715         [in]    const ULONG ulSizeOfSource);
716
717     HRESULT AddRange(
718         [in]    const ULONG low,
719         [in]    const ULONG high);
720
721     HRESULT AddSingleValue(
722         [in]    const ULONG value);
723
724     HRESULT AddRangeList(
725         [in]    const IRangeList *prl);
726
727     HRESULT DeleteRange(
728         [in]    const ULONG low,
729         [in]    const ULONG high);
730
731     HRESULT DeleteSingleValue(
732         [in]    const ULONG value);
733
734     HRESULT DeleteRangeList(
735         [in]    const IRangeList *prl);
736
737     HRESULT MinOfRange(
738         [in]    const ULONG value,
739         [out]   ULONG *pulMinOfRange);
740
741     HRESULT MaxOfRange(
742         [in]    const ULONG value,
743         [out]   ULONG *pulMaxOfRange);
744
745     HRESULT RangeToIMAPString(
746         [out]   LPSTR *ppszDestination,
747         [out]   LPDWORD pdwLengthOfDestination);
748
749     HRESULT Next(
750         [in]    const ULONG current,
751         [out]   ULONG *pulNext);
752
753     HRESULT Prev(
754         [in]    const ULONG current,
755         [out]   ULONG *pulPrev);
756
757     HRESULT Cardinality(
758         [out]   ULONG *pulCardinality);
759
760     HRESULT CardinalityFrom(
761         [in]    const ULONG ulStartPoint,
762         [out]   ULONG *pulCardinalityFrom);
763 }
764
765 [
766     object,
767     uuid(E9E9D8A3-4EDD-11d0-874F-00AA00530EE9),
768     local
769 ]
770 interface IIMAPCallback : ITransportCallback
771 {
772     typedef DWORD IMAP_MBOXFLAGS;
773     const IMAP_MBOXFLAGS IMAP_MBOX_NOFLAGS = 0x0;
774     const IMAP_MBOXFLAGS IMAP_MBOX_MARKED = 0x1;
775     const IMAP_MBOXFLAGS IMAP_MBOX_NOINFERIORS = 0x2;
776     const IMAP_MBOXFLAGS IMAP_MBOX_NOSELECT = 0x4;
777     const IMAP_MBOXFLAGS IMAP_MBOX_UNMARKED = 0x8;
778     const IMAP_MBOXFLAGS IMAP_MBOX_ALLFLAGS = 0xf;
779
780     typedef enum tagIMAP_RESPONSE_TYPE
781     {
782         irtERROR_NOTIFICATION,
783         irtCOMMAND_COMPLETION,
784         irtSERVER_ALERT,
785         irtPARSE_ERROR,
786         irtMAILBOX_UPDATE,
787         irtDELETED_MSG,
788         irtFETCH_BODY,
789         irtUPDATE_MSG,
790         irtAPPLICABLE_FLAGS,
791         irtPERMANENT_FLAGS,
792         irtUIDVALIDITY,
793         irtREADWRITE_STATUS,
794         irtTRYCREATE,
795         irtSEARCH,
796         irtMAILBOX_LISTING,
797         irtMAILBOX_STATUS,
798         irtAPPEND_PROGRESS,
799         irtUPDATE_MSG_EX
800     } IMAP_RESPONSE_TYPE;
801
802     typedef struct tagFETCH_BODY_PART
803     {
804         DWORD dwMsgSeqNum;
805         LPSTR pszBodyTag;
806         DWORD dwTotalBytes;
807         DWORD dwSizeOfData;
808         DWORD dwOffset;
809         BOOL fDone;
810         LPSTR pszData;
811         LPARAM lpFetchCookie1;
812         LPARAM lpFetchCookie2;
813     } FETCH_BODY_PART;
814
815     typedef struct tagFETCH_CMD_RESULTS
816     {
817         DWORD dwMsgSeqNum;
818         BOOL bMsgFlags;
819         IMAP_MSGFLAGS mfMsgFlags;
820         BOOL bRFC822Size;
821         DWORD dwRFC822Size;
822         BOOL bUID;
823         DWORD dwUID;
824         BOOL bInternalDate;
825         FILETIME ftInternalDate;
826         LPARAM lpFetchCookie1;
827         LPARAM lpFetchCookie2;
828     } FETCH_CMD_RESULTS;
829
830     typedef struct tagIMAPADDR
831     {
832         LPSTR pszName;
833         LPSTR pszADL;
834         LPSTR pszMailbox;
835         LPSTR pszHost;
836         struct tagIMAPADDR *pNext;
837     } IMAPADDR;
838
839     typedef struct tagFETCH_CMD_RESULTS_EX
840     {
841         DWORD dwMsgSeqNum;
842         BOOL bMsgFlags;
843         IMAP_MSGFLAGS mfMsgFlags;
844         BOOL bRFC822Size;
845         DWORD dwRFC822Size;
846         BOOL bUID;
847         DWORD dwUID;
848         BOOL bInternalDate;
849         FILETIME ftInternalDate;
850         LPARAM lpFetchCookie1;
851         LPARAM lpFetchCookie2;
852         BOOL bEnvelope;
853         FILETIME ftENVDate;
854         LPSTR pszENVSubject;
855         IMAPADDR *piaENVFrom;
856         IMAPADDR *piaENVSender;
857         IMAPADDR *piaENVReplyTo;
858         IMAPADDR *piaENVTo;
859         IMAPADDR *piaENVCc;
860         IMAPADDR *piaENVBcc;
861         LPSTR pszENVInReplyTo;
862         LPSTR pszENVMessageID;
863         DWORD dwReserved1;
864         DWORD dwReserved2;
865         DWORD dwReserved3;
866     } FETCH_CMD_RESULTS_EX;
867
868     typedef struct tagMBOX_MSGCOUNT
869     {
870         BOOL bGotExistsResponse;
871         DWORD dwExists;
872         BOOL bGotRecentResponse;
873         DWORD dwRecent;
874         BOOL bGotUnseenResponse;
875         DWORD dwUnseen;
876     } MBOX_MSGCOUNT;
877
878     typedef struct tagIMAP_LISTLSUB_RESPONSE
879     {
880         LPSTR pszMailboxName;
881         IMAP_MBOXFLAGS imfMboxFlags;
882         char cHierarchyChar;
883     } IMAP_LISTLSUB_RESPONSE;
884
885     typedef struct tagIMAP_STATUS_RESPONSE
886     {
887         LPSTR pszMailboxName;
888         BOOL fMessages;
889         DWORD dwMessages;
890         BOOL fRecent;
891         DWORD dwRecent;
892         BOOL fUIDNext;
893         DWORD dwUIDNext;
894         BOOL fUIDValidity;
895         DWORD dwUIDValidity;
896         BOOL fUnseen;
897         DWORD dwUnseen;
898     } IMAP_STATUS_RESPONSE;
899
900     typedef struct tagAPPEND_PROGRESS
901     {
902         DWORD dwUploaded;
903         DWORD dwTotal;
904     } APPEND_PROGRESS;
905
906     typedef [switch_type(IMAP_RESPONSE_TYPE)] union tagIMAP_RESPONSE_DATA
907     {
908         [case (irtMAILBOX_UPDATE)] MBOX_MSGCOUNT *pmcMsgCount;
909         [case (irtDELETED_MSG)] DWORD dwDeletedMsgSeqNum;
910         [case (irtFETCH_BODY)] FETCH_BODY_PART *pFetchBodyPart;
911         [case (irtUPDATE_MSG)] FETCH_CMD_RESULTS *pFetchResults;
912         [case (irtAPPLICABLE_FLAGS, irtPERMANENT_FLAGS)] IMAP_MSGFLAGS imfImapMessageFlags;
913         [case (irtUIDVALIDITY)] DWORD dwUIDValidity;
914         [case (irtREADWRITE_STATUS)] BOOL bReadWrite;
915         [case (irtSEARCH)] IRangeList *prlSearchResults;
916         [case (irtMAILBOX_LISTING)] IMAP_LISTLSUB_RESPONSE illrdMailboxListing;
917         [case (irtMAILBOX_STATUS)] IMAP_STATUS_RESPONSE *pisrStatusResponse;
918         [case (irtAPPEND_PROGRESS)] APPEND_PROGRESS *papAppendProgress;
919         [case (irtUPDATE_MSG_EX)] FETCH_CMD_RESULTS_EX *pFetchResultsEx;
920     } IMAP_RESPONSE_DATA;
921
922     typedef struct tagIMAP_RESPONSE
923     {
924         WPARAM wParam;
925         LPARAM lParam;
926         HRESULT hrResult;
927         LPSTR lpszResponseText;
928         IMAP_RESPONSE_TYPE irtResponseType;
929         [switch_is(irtResponseType)] IMAP_RESPONSE_DATA irdResponseData;
930     } IMAP_RESPONSE;
931
932     HRESULT OnResponse([in] const IMAP_RESPONSE *pirIMAPResponse);
933 }
934
935 [
936 object,
937 uuid(E9E9D8A8-4EDD-11d0-874F-00AA00530EE9),
938 local,
939 ]
940 interface IIMAPTransport : IInternetTransport
941 {
942     const DWORD IMAP_CAPABILITY_IMAP4 = 0x1;
943     const DWORD IMAP_CAPABILITY_IMAP4rev1 = 0x2;
944     const DWORD IMAP_CAPABILITY_IDLE = 0x4;
945     const DWORD IMAP_CAPABILITY_ALLFLAGS = 0x7;
946
947     HRESULT InitNew(
948         [in]    LPSTR pszLogFilePath,
949         [in]    IIMAPCallback *pCBHandler);
950
951     HRESULT NewIRangeList(
952         [out]   IRangeList **pprlNewRangeList);
953
954     HRESULT Capability(
955         [out]   DWORD *pdwCapabilityFlags);
956
957     HRESULT Select(
958         [in]    WPARAM wParam,
959         [in]    LPARAM lParam,
960         [in]    IIMAPCallback *pCBHandler,
961         [in]    LPSTR lpszMailboxName);
962
963     HRESULT Examine(
964         [in]    WPARAM wParam,
965         [in]    LPARAM lParam,
966         [in]    IIMAPCallback *pCBHandler,
967         [in]    LPSTR lpszMailboxName);
968
969     HRESULT Create(
970         [in]    WPARAM wParam,
971         [in]    LPARAM lParam,
972         [in]    IIMAPCallback *pCBHandler,
973         [in]    LPSTR lpszMailboxName);
974
975     HRESULT Delete(
976         [in]    WPARAM wParam,
977         [in]    LPARAM lParam,
978         [in]    IIMAPCallback *pCBHandler,
979         [in]    LPSTR lpszMailboxName);
980
981     HRESULT Rename(
982         [in]    WPARAM wParam,
983         [in]    LPARAM lParam,
984         [in]    IIMAPCallback *pCBHandler,
985         [in]    LPSTR lpszMailboxName,
986         [in]    LPSTR lpszNewMailboxName);
987
988     HRESULT Subscribe(
989         [in]    WPARAM wParam,
990         [in]    LPARAM lParam,
991         [in]    IIMAPCallback *pCBHandler,
992         [in]    LPSTR lpszMailboxName);
993
994     HRESULT Unsubscribe(
995         [in]    WPARAM wParam,
996         [in]    LPARAM lParam,
997         [in]    IIMAPCallback *pCBHandler,
998         [in]    LPSTR lpszMailboxName);
999
1000     HRESULT List(
1001         [in]    WPARAM wParam,
1002         [in]    LPARAM lParam,
1003         [in]    IIMAPCallback *pCBHandler,
1004         [in]    LPSTR lpszMailboxNameReference,
1005         [in]    LPSTR lpszMailboxNamePattern);
1006
1007     HRESULT Lsub(
1008         [in]    WPARAM wParam,
1009         [in]    LPARAM lParam,
1010         [in]    IIMAPCallback *pCBHandler,
1011         [in]    LPSTR lpszMailboxNameReference,
1012         [in]    LPSTR lpszMailboxNamePattern);
1013
1014     HRESULT Append(
1015         [in]    WPARAM wParam,
1016         [in]    LPARAM lParam,
1017         [in]    IIMAPCallback *pCBHandler,
1018         [in]    LPSTR lpszMailboxName,
1019         [in]    LPSTR lpszMessageFlags,
1020         [in]    FILETIME ftMessageDateTime,
1021         [in]    LPSTREAM lpstmMessageToSave);
1022
1023     HRESULT Close(
1024         [in]    WPARAM wParam,
1025         [in]    LPARAM lParam,
1026         [in]    IIMAPCallback *pCBHandler);
1027
1028     HRESULT Expunge(
1029         [in]    WPARAM wParam,
1030         [in]    LPARAM lParam,
1031         [in]    IIMAPCallback *pCBHandler);
1032
1033     HRESULT Search(
1034         [in]    WPARAM wParam,
1035         [in]    LPARAM lParam,
1036         [in]    IIMAPCallback *pCBHandler,
1037         [in]    LPSTR lpszSearchCriteria,
1038         [in]    boolean bReturnUIDs,
1039         [in]    IRangeList *pMsgRange,
1040         [in]    boolean bUIDRangeList);
1041
1042     HRESULT Fetch(
1043         [in]    WPARAM wParam,
1044         [in]    LPARAM lParam,
1045         [in]    IIMAPCallback *pCBHandler,
1046         [in]    IRangeList *pMsgRange,
1047         [in]    boolean bUIDMsgRange,
1048         [in]    LPSTR lpszFetchArgs);
1049
1050     HRESULT Store(
1051         [in]    WPARAM wParam,
1052         [in]    LPARAM lParam,
1053         [in]    IIMAPCallback *pCBHandler,
1054         [in]    IRangeList *pMsgRange,
1055         [in]    boolean bUIDRangeList,
1056         [in]    LPSTR lpszStoreArgs);
1057
1058     HRESULT Copy(
1059         [in]    WPARAM wParam,
1060         [in]    LPARAM lParam,
1061         [in]    IIMAPCallback *pCBHandler,
1062         [in]    IRangeList *pMsgRange,
1063         [in]    boolean bUIDRangeList,
1064         [in]    LPSTR lpszMailboxName);
1065
1066     HRESULT Noop(
1067         [in]    WPARAM wParam,
1068         [in]    LPARAM lParam,
1069         [in]    IIMAPCallback *pCBHandler);
1070
1071     HRESULT ResizeMsgSeqNumTable(
1072         [in]    DWORD dwSizeOfMbox);
1073
1074     HRESULT UpdateSeqNumToUID(
1075         [in]    DWORD dwMsgSeqNum,
1076         [in]    DWORD dwUID);
1077
1078     HRESULT RemoveSequenceNum(
1079         [in]    DWORD dwDeletedMsgSeqNum);
1080
1081     HRESULT MsgSeqNumToUID(
1082         [in]    DWORD dwMsgSeqNum,
1083         [out]   DWORD *pdwUID);
1084
1085     HRESULT GetMsgSeqNumToUIDArray(
1086         [out]   DWORD **ppdwMsgSeqNumToUIDArray,
1087         [out]   DWORD *pdwNumberOfElements);
1088
1089     HRESULT GetHighestMsgSeqNum(
1090         [out]   DWORD *pdwHighestMSN);
1091
1092     HRESULT ResetMsgSeqNumToUID();
1093
1094     HRESULT SetDefaultCBHandler(
1095         [in]    IIMAPCallback *pCBHandler);
1096
1097     HRESULT Status(
1098         [in]    WPARAM wParam,
1099         [in]    LPARAM lParam,
1100         [in]    IIMAPCallback *pCBHandler,
1101         [in]    LPSTR pszMailboxName,
1102         [in]    LPSTR pszStatusCmdArgs);
1103 }
1104
1105 #if 0
1106 cpp_quote("HRESULT WINAPI CreateRASTransport(IRASTransport **ppTransport);")
1107 cpp_quote("HRESULT WINAPI CreateNNTPTransport(INNTPTransport **ppTransport);")
1108 cpp_quote("HRESULT WINAPI CreateIMAPTransport2(IIMAPTransport2 **ppTransport);")
1109 #endif
1110 cpp_quote("HRESULT WINAPI CreateRangeList(IRangeList **ppRangeList);")
1111 cpp_quote("HRESULT WINAPI CreateSMTPTransport(ISMTPTransport **ppTransport);")
1112 cpp_quote("HRESULT WINAPI CreatePOP3Transport(IPOP3Transport **ppTransport);")
1113 cpp_quote("HRESULT WINAPI CreateIMAPTransport(IIMAPTransport **ppTransport);")