2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2003 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)
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,
103 time_t last_access_time;
104 struct timeval tv_prev;
110 gchar read_buf[SESSION_BUFFSIZE];
114 GString *read_msg_buf;
115 GByteArray *read_data_buf;
116 gchar *read_data_terminator;
124 /* virtual methods to parse server responses */
125 gint (*recv_msg) (Session *session,
128 gint (*send_data_finished) (Session *session,
130 gint (*recv_data_finished) (Session *session,
134 void (*destroy) (Session *session);
136 /* notification functions */
137 RecvMsgNotify recv_msg_notify;
138 RecvDataProgressiveNotify recv_data_progressive_notify;
139 RecvDataNotify recv_data_notify;
140 SendDataProgressiveNotify send_data_progressive_notify;
141 SendDataNotify send_data_notify;
143 gpointer recv_msg_notify_data;
144 gpointer recv_data_progressive_notify_data;
145 gpointer recv_data_notify_data;
146 gpointer send_data_progressive_notify_data;
147 gpointer send_data_notify_data;
150 void session_init (Session *session);
151 gint session_connect (Session *session,
154 gint session_disconnect (Session *session);
155 void session_destroy (Session *session);
156 gboolean session_is_connected (Session *session);
158 void session_set_recv_message_notify (Session *session,
159 RecvMsgNotify notify_func,
161 void session_set_recv_data_progressive_notify
163 RecvDataProgressiveNotify notify_func,
165 void session_set_recv_data_notify (Session *session,
166 RecvDataNotify notify_func,
168 void session_set_send_data_progressive_notify
170 SendDataProgressiveNotify notify_func,
172 void session_set_send_data_notify (Session *session,
173 SendDataNotify notify_func,
177 gint session_start_tls (Session *session);
180 gint session_send_msg (Session *session,
183 gint session_recv_msg (Session *session);
184 gint session_send_data (Session *session,
187 gint session_recv_data (Session *session,
189 const gchar *terminator);
191 #endif /* __SESSION_H__ */