Statistics
| Revision:

root / libsylph / smtp.h @ 2395

History | View | Annotate | Download (2.2 kB)

1 1 hiro
/*
2 578 hiro
 * LibSylph -- E-Mail client library
3 2091 hiro
 * Copyright (C) 1999-2008 Hiroyuki Yamamoto
4 1 hiro
 *
5 578 hiro
 * This library is free software; you can redistribute it and/or
6 578 hiro
 * modify it under the terms of the GNU Lesser General Public
7 578 hiro
 * License as published by the Free Software Foundation; either
8 578 hiro
 * version 2.1 of the License, or (at your option) any later version.
9 1 hiro
 *
10 578 hiro
 * This library is distributed in the hope that it will be useful,
11 1 hiro
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 578 hiro
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 578 hiro
 * Lesser General Public License for more details.
14 1 hiro
 *
15 578 hiro
 * You should have received a copy of the GNU Lesser General Public
16 578 hiro
 * License along with this library; if not, write to the Free Software
17 578 hiro
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 1 hiro
 */
19 1 hiro
20 1 hiro
#ifndef __SMTP_H__
21 1 hiro
#define __SMTP_H__
22 1 hiro
23 1 hiro
#ifdef HAVE_CONFIG_H
24 1 hiro
#  include "config.h"
25 1 hiro
#endif
26 1 hiro
27 1 hiro
#include <glib.h>
28 793 hiro
#include <stdio.h>
29 1 hiro
30 1 hiro
#include "session.h"
31 1 hiro
32 1 hiro
typedef struct _SMTPSession        SMTPSession;
33 1 hiro
34 1 hiro
#define SMTP_SESSION(obj)        ((SMTPSession *)obj)
35 1 hiro
36 2091 hiro
#define SMTPBUFSIZE                8192
37 1 hiro
38 1 hiro
typedef enum
39 1 hiro
{
40 1 hiro
        SM_OK                        = 0,
41 1 hiro
        SM_ERROR                = 128,
42 1 hiro
        SM_UNRECOVERABLE        = 129,
43 1 hiro
        SM_AUTHFAIL                = 130
44 1 hiro
} SMTPErrorValue;
45 1 hiro
46 1 hiro
typedef enum
47 1 hiro
{
48 1 hiro
        ESMTP_8BITMIME        = 1 << 0,
49 1 hiro
        ESMTP_SIZE        = 1 << 1,
50 1 hiro
        ESMTP_ETRN        = 1 << 2
51 1 hiro
} ESMTPFlag;
52 1 hiro
53 1 hiro
typedef enum
54 1 hiro
{
55 1 hiro
        SMTPAUTH_LOGIN      = 1 << 0,
56 1 hiro
        SMTPAUTH_CRAM_MD5   = 1 << 1,
57 166 hiro
        SMTPAUTH_DIGEST_MD5 = 1 << 2,
58 166 hiro
        SMTPAUTH_PLAIN      = 1 << 3
59 1 hiro
} SMTPAuthType;
60 1 hiro
61 1 hiro
typedef enum
62 1 hiro
{
63 1 hiro
        SMTP_READY,
64 1 hiro
        SMTP_CONNECTED,
65 1 hiro
        SMTP_HELO,
66 1 hiro
        SMTP_EHLO,
67 1 hiro
        SMTP_STARTTLS,
68 1 hiro
        SMTP_FROM,
69 1 hiro
        SMTP_AUTH,
70 166 hiro
        SMTP_AUTH_PLAIN,
71 1 hiro
        SMTP_AUTH_LOGIN_USER,
72 1 hiro
        SMTP_AUTH_LOGIN_PASS,
73 1 hiro
        SMTP_AUTH_CRAM_MD5,
74 1 hiro
        SMTP_RCPT,
75 1 hiro
        SMTP_DATA,
76 1 hiro
        SMTP_SEND_DATA,
77 1 hiro
        SMTP_EOM,
78 1 hiro
        SMTP_RSET,
79 1 hiro
        SMTP_QUIT,
80 1 hiro
        SMTP_ERROR,
81 1 hiro
        SMTP_DISCONNECTED,
82 1 hiro
83 1 hiro
        N_SMTP_PHASE
84 1 hiro
} SMTPState;
85 1 hiro
86 1 hiro
struct _SMTPSession
87 1 hiro
{
88 1 hiro
        Session session;
89 1 hiro
90 1 hiro
        SMTPState state;
91 1 hiro
92 1 hiro
        gboolean tls_init_done;
93 1 hiro
94 1 hiro
        gchar *hostname;
95 1 hiro
96 1 hiro
        gchar *user;
97 1 hiro
        gchar *pass;
98 1 hiro
99 1 hiro
        gchar *from;
100 1 hiro
        GSList *to_list;
101 1 hiro
        GSList *cur_to;
102 1 hiro
103 771 hiro
        FILE *send_data_fp;
104 771 hiro
        gint send_data_len;
105 1 hiro
106 1 hiro
        SMTPAuthType avail_auth_type;
107 1 hiro
        SMTPAuthType forced_auth_type;
108 1 hiro
        SMTPAuthType auth_type;
109 1 hiro
110 1 hiro
        SMTPErrorValue error_val;
111 1 hiro
        gchar *error_msg;
112 1 hiro
};
113 1 hiro
114 1 hiro
Session *smtp_session_new        (void);
115 1 hiro
116 1 hiro
#endif /* __SMTP_H__ */