2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 #define SESSION_BUFFSIZE 4096
36 typedef struct _Session Session;
38 #define SESSION(obj) ((Session *)obj)
61 SESSION_MSG_SEND_DATA,
62 SESSION_MSG_RECV_DATA,
68 typedef gint (*RecvMsgNotify) (Session *session,
71 typedef gint (*RecvDataProgressiveNotify) (Session *session,
75 typedef gint (*RecvDataNotify) (Session *session,
78 typedef gint (*SendDataProgressiveNotify) (Session *session,
82 typedef gint (*SendDataNotify) (Session *session,
95 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
103 time_t last_access_time;
110 gchar read_buf[SESSION_BUFFSIZE];
114 GString *read_msg_buf;
115 GByteArray *read_data_buf;
116 gchar *read_data_terminator;
118 /* buffer for short messages */
123 /* buffer for large data */
124 const guchar *write_data;
125 const guchar *write_data_p;
129 guint timeout_interval;
133 /* virtual methods to parse server responses */
134 gint (*recv_msg) (Session *session,
137 gint (*send_data_finished) (Session *session,
139 gint (*recv_data_finished) (Session *session,
143 void (*destroy) (Session *session);
145 /* notification functions */
146 RecvMsgNotify recv_msg_notify;
147 RecvDataProgressiveNotify recv_data_progressive_notify;
148 RecvDataNotify recv_data_notify;
149 SendDataProgressiveNotify send_data_progressive_notify;
150 SendDataNotify send_data_notify;
152 gpointer recv_msg_notify_data;
153 gpointer recv_data_progressive_notify_data;
154 gpointer recv_data_notify_data;
155 gpointer send_data_progressive_notify_data;
156 gpointer send_data_notify_data;
159 void session_init (Session *session);
160 gint session_connect (Session *session,
163 gint session_disconnect (Session *session);
164 void session_destroy (Session *session);
165 gboolean session_is_connected (Session *session);
167 void session_set_access_time (Session *session);
169 void session_set_timeout (Session *session,
172 void session_set_recv_message_notify (Session *session,
173 RecvMsgNotify notify_func,
175 void session_set_recv_data_progressive_notify
177 RecvDataProgressiveNotify notify_func,
179 void session_set_recv_data_notify (Session *session,
180 RecvDataNotify notify_func,
182 void session_set_send_data_progressive_notify
184 SendDataProgressiveNotify notify_func,
186 void session_set_send_data_notify (Session *session,
187 SendDataNotify notify_func,
190 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
191 gint session_start_tls (Session *session);
194 gint session_send_msg (Session *session,
197 gint session_recv_msg (Session *session);
198 gint session_send_data (Session *session,
201 gint session_recv_data (Session *session,
203 const gchar *terminator);
205 #endif /* __SESSION_H__ */