2 * Claws Mail -- 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"
35 #define SESSION_BUFFSIZE 4096
37 typedef struct _Session Session
;
39 #define SESSION(obj) ((Session *)obj)
59 typedef gint (*RecvMsgNotify
) (Session
*session
,
62 typedef gint (*RecvDataProgressiveNotify
) (Session
*session
,
66 typedef gint (*RecvDataNotify
) (Session
*session
,
69 typedef gint (*SendDataProgressiveNotify
) (Session
*session
,
73 typedef gint (*SendDataNotify
) (Session
*session
,
90 time_t last_access_time
;
96 gchar read_buf
[SESSION_BUFFSIZE
];
100 GString
*read_msg_buf
;
101 GByteArray
*read_data_buf
;
102 gchar
*read_data_terminator
;
104 /* buffer for short messages */
109 /* buffer for large data */
110 const guchar
*write_data
;
111 const guchar
*write_data_p
;
115 guint timeout_interval
;
119 /* virtual methods to parse server responses */
120 gint (*recv_msg
) (Session
*session
,
123 void (*connect_finished
) (Session
*session
,
125 gint (*send_data_finished
) (Session
*session
,
127 gint (*recv_data_finished
) (Session
*session
,
131 void (*destroy
) (Session
*session
);
133 /* notification functions */
134 RecvMsgNotify recv_msg_notify
;
135 RecvDataProgressiveNotify recv_data_progressive_notify
;
136 RecvDataNotify recv_data_notify
;
137 SendDataProgressiveNotify send_data_progressive_notify
;
138 SendDataNotify send_data_notify
;
140 gpointer recv_msg_notify_data
;
141 gpointer recv_data_progressive_notify_data
;
142 gpointer recv_data_notify_data
;
143 gpointer send_data_progressive_notify_data
;
144 gpointer send_data_notify_data
;
148 gboolean ssl_cert_auto_accept
;
151 /* Pointer to ProxyInfo struct holding the info about proxy
152 * to be used. Set to NULL if no proxy is used.
153 * If non-NULL, the memory this pointer is pointing at does
154 * not belong to this Session, and shouldn't be modified
155 * or freed by Session. It is usually a pointer to the
156 * SockInfo in common prefs, or in account prefs. */
157 ProxyInfo
*proxy_info
;
161 gchar
*gnutls_priority
;
162 gboolean use_tls_sni
;
166 void session_init (Session
*session
,
167 const void *prefs_account
,
169 gint
session_connect (Session
*session
,
172 gint
session_disconnect (Session
*session
);
173 void session_destroy (Session
*session
);
174 gboolean
session_is_running (Session
*session
);
175 gboolean
session_is_connected (Session
*session
);
177 void session_set_access_time (Session
*session
);
179 void session_set_timeout (Session
*session
,
182 void session_set_recv_message_notify (Session
*session
,
183 RecvMsgNotify notify_func
,
185 void session_set_recv_data_progressive_notify
187 RecvDataProgressiveNotify notify_func
,
189 void session_set_recv_data_notify (Session
*session
,
190 RecvDataNotify notify_func
,
192 void session_set_send_data_progressive_notify
194 SendDataProgressiveNotify notify_func
,
196 void session_set_send_data_notify (Session
*session
,
197 SendDataNotify notify_func
,
201 gint
session_start_tls (Session
*session
);
204 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__ */