2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2011 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,
99 time_t last_access_time;
106 gchar read_buf[SESSION_BUFFSIZE];
110 GString *read_msg_buf;
111 GByteArray *read_data_buf;
112 gchar *read_data_terminator;
114 /* buffer for short messages */
119 /* buffer for large data */
120 const guchar *write_data;
121 const guchar *write_data_p;
125 guint timeout_interval;
129 /* virtual methods to parse server responses */
130 gint (*recv_msg) (Session *session,
133 gint (*send_data_finished) (Session *session,
135 gint (*recv_data_finished) (Session *session,
139 void (*destroy) (Session *session);
141 /* notification functions */
142 RecvMsgNotify recv_msg_notify;
143 RecvDataProgressiveNotify recv_data_progressive_notify;
144 RecvDataNotify recv_data_notify;
145 SendDataProgressiveNotify send_data_progressive_notify;
146 SendDataNotify send_data_notify;
148 gpointer recv_msg_notify_data;
149 gpointer recv_data_progressive_notify_data;
150 gpointer recv_data_notify_data;
151 gpointer send_data_progressive_notify_data;
152 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_running (Session *session);
171 gboolean session_is_connected (Session *session);
173 void session_set_access_time (Session *session);
175 void session_set_timeout (Session *session,
178 void session_set_recv_message_notify (Session *session,
179 RecvMsgNotify notify_func,
181 void session_set_recv_data_progressive_notify
183 RecvDataProgressiveNotify notify_func,
185 void session_set_recv_data_notify (Session *session,
186 RecvDataNotify notify_func,
188 void session_set_send_data_progressive_notify
190 SendDataProgressiveNotify notify_func,
192 void session_set_send_data_notify (Session *session,
193 SendDataNotify notify_func,
197 gint session_start_tls (Session *session);
200 gint session_send_msg (Session *session,
203 gint session_recv_msg (Session *session);
204 gint session_send_data (Session *session,
207 gint session_recv_data (Session *session,
209 const gchar *terminator);
211 #endif /* __SESSION_H__ */