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;
162 void session_init (Session *session,
163 const void *prefs_account,
165 gint session_connect (Session *session,
168 gint session_disconnect (Session *session);
169 void session_destroy (Session *session);
170 gboolean session_is_connected (Session *session);
172 void session_set_access_time (Session *session);
174 void session_set_timeout (Session *session,
177 void session_set_recv_message_notify (Session *session,
178 RecvMsgNotify notify_func,
180 void session_set_recv_data_progressive_notify
182 RecvDataProgressiveNotify notify_func,
184 void session_set_recv_data_notify (Session *session,
185 RecvDataNotify notify_func,
187 void session_set_send_data_progressive_notify
189 SendDataProgressiveNotify notify_func,
191 void session_set_send_data_notify (Session *session,
192 SendDataNotify notify_func,
195 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
196 gint session_start_tls (Session *session);
199 gint session_send_msg (Session *session,
202 gint session_recv_msg (Session *session);
203 gint session_send_data (Session *session,
206 gint session_recv_data (Session *session,
208 const gchar *terminator);
210 #endif /* __SESSION_H__ */