2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2012 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/>.
24 #include "claws-features.h"
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;
161 gchar *gnutls_priority;
165 void session_init (Session *session,
166 const void *prefs_account,
168 gint session_connect (Session *session,
171 gint session_disconnect (Session *session);
172 void session_destroy (Session *session);
173 gboolean session_is_running (Session *session);
174 gboolean session_is_connected (Session *session);
176 void session_set_access_time (Session *session);
178 void session_set_timeout (Session *session,
181 void session_set_recv_message_notify (Session *session,
182 RecvMsgNotify notify_func,
184 void session_set_recv_data_progressive_notify
186 RecvDataProgressiveNotify notify_func,
188 void session_set_recv_data_notify (Session *session,
189 RecvDataNotify notify_func,
191 void session_set_send_data_progressive_notify
193 SendDataProgressiveNotify notify_func,
195 void session_set_send_data_notify (Session *session,
196 SendDataNotify notify_func,
200 gint session_start_tls (Session *session);
203 gint session_send_msg (Session *session,
206 gint session_recv_msg (Session *session);
207 gint session_send_data (Session *session,
210 gint session_recv_data (Session *session,
212 const gchar *terminator);
213 void session_register_ping(Session *session, gboolean (*ping_cb)(gpointer data));
215 #endif /* __SESSION_H__ */