2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2004 Hiroyuki Yamamoto
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 2 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, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 #define SESSION_BUFFSIZE 4096
37 typedef struct _Session Session;
39 #define SESSION(obj) ((Session *)obj)
62 SESSION_MSG_SEND_DATA,
63 SESSION_MSG_RECV_DATA,
69 typedef gint (*RecvMsgNotify) (Session *session,
72 typedef gint (*RecvDataProgressiveNotify) (Session *session,
76 typedef gint (*RecvDataNotify) (Session *session,
79 typedef gint (*SendDataProgressiveNotify) (Session *session,
83 typedef gint (*SendDataNotify) (Session *session,
100 gboolean nonblocking;
104 time_t last_access_time;
105 struct timeval tv_prev;
111 gchar read_buf[SESSION_BUFFSIZE];
115 GString *read_msg_buf;
116 GByteArray *read_data_buf;
117 gchar *read_data_terminator;
124 guint timeout_interval;
128 /* virtual methods to parse server responses */
129 gint (*recv_msg) (Session *session,
132 gint (*send_data_finished) (Session *session,
134 gint (*recv_data_finished) (Session *session,
138 void (*destroy) (Session *session);
140 /* notification functions */
141 RecvMsgNotify recv_msg_notify;
142 RecvDataProgressiveNotify recv_data_progressive_notify;
143 RecvDataNotify recv_data_notify;
144 SendDataProgressiveNotify send_data_progressive_notify;
145 SendDataNotify send_data_notify;
147 gpointer recv_msg_notify_data;
148 gpointer recv_data_progressive_notify_data;
149 gpointer recv_data_notify_data;
150 gpointer send_data_progressive_notify_data;
151 gpointer send_data_notify_data;
154 void session_init (Session *session);
155 gint session_connect (Session *session,
158 gint session_disconnect (Session *session);
159 void session_destroy (Session *session);
160 gboolean session_is_connected (Session *session);
162 void session_set_access_time (Session *session);
164 void session_set_timeout (Session *session,
167 void session_set_recv_message_notify (Session *session,
168 RecvMsgNotify notify_func,
170 void session_set_recv_data_progressive_notify
172 RecvDataProgressiveNotify notify_func,
174 void session_set_recv_data_notify (Session *session,
175 RecvDataNotify notify_func,
177 void session_set_send_data_progressive_notify
179 SendDataProgressiveNotify notify_func,
181 void session_set_send_data_notify (Session *session,
182 SendDataNotify notify_func,
186 gint session_start_tls (Session *session);
189 gint session_send_msg (Session *session,
192 gint session_recv_msg (Session *session);
193 gint session_send_data (Session *session,
196 gint session_recv_data (Session *session,
198 const gchar *terminator);
200 #endif /* __SESSION_H__ */