gint last);
static void imap_delete_all_messages (FolderItem *item);
-static gint imap_open (const gchar *server,
+static SockInfo *imap_open (const gchar *server,
gushort port,
gchar *buf);
-static gint imap_auth (gint sock,
+static gint imap_auth (SockInfo *sock,
const gchar *user,
const gchar *pass);
-static gint imap_logout (gint sock);
-static gint imap_noop (gint sock);
-static gint imap_select (gint sock,
+static gint imap_logout (SockInfo *sock);
+static gint imap_noop (SockInfo *sock);
+static gint imap_select (SockInfo *sock,
const gchar *folder,
gint *exists,
gint *recent,
gint *unseen,
gulong *uid);
-static gint imap_get_envelope (gint sock,
+static gint imap_get_envelope (SockInfo *sock,
gint first,
gint last);
#if 0
-static gint imap_search (gint sock,
+static gint imap_search (SockInfo *sock,
GSList *numlist);
#endif
-static gint imap_get_message (gint sock,
+static gint imap_get_message (SockInfo *sock,
gint num,
const gchar *filename);
-static gint imap_copy_message (gint sock,
+static gint imap_copy_message (SockInfo *sock,
gint num,
const gchar *destfolder);
-static gint imap_store (gint sock,
+static gint imap_store (SockInfo *sock,
gint first,
gint last,
gchar *sub_cmd);
gboolean is_set);
static gint imap_expunge (IMAPSession *session);
-static gchar *imap_parse_atom (gint sock,
- gchar *src,
- gchar *dest,
- gchar *orig_buf);
-static gchar *imap_parse_one_address (gint sock,
- gchar *start,
- gchar *out_from_str,
- gchar *out_fromname_str,
- gchar *orig_buf);
-static gchar *imap_parse_address (gint sock,
- gchar *start,
- gchar **out_from_str,
- gchar **out_fromname_str,
- gchar *orig_buf);
+static gchar *imap_parse_atom (SockInfo *sock,
+ gchar *src,
+ gchar *dest,
+ gchar *orig_buf);
+static gchar *imap_parse_one_address (SockInfo *sock,
+ gchar *start,
+ gchar *out_from_str,
+ gchar *out_fromname_str,
+ gchar *orig_buf);
+static gchar *imap_parse_address (SockInfo *sock,
+ gchar *start,
+ gchar **out_from_str,
+ gchar **out_fromname_str,
+ gchar *orig_buf);
static MsgFlags imap_parse_flags (const gchar *flag_str);
-static MsgInfo *imap_parse_envelope (gint sock,
- gchar *line_str);
+static MsgInfo *imap_parse_envelope (SockInfo *sock,
+ gchar *line_str);
-static gint imap_ok (gint sock,
+static gint imap_ok (SockInfo *sock,
GPtrArray *argbuf);
-static void imap_gen_send (gint sock,
+static void imap_gen_send (SockInfo *sock,
const gchar *format, ...);
-static gint imap_gen_recv (gint sock,
+static gint imap_gen_recv (SockInfo *sock,
gchar *buf,
gint size);
{
gchar buf[IMAPBUFSIZE];
IMAPSession *session;
- gint imap_sock;
+ SockInfo *imap_sock;
g_return_val_if_fail(server != NULL, NULL);
return NULL;
if (imap_auth(imap_sock, user, pass) != IMAP_SUCCESS) {
imap_logout(imap_sock);
- close(imap_sock);
+ sock_close(imap_sock);
return NULL;
}
void imap_session_destroy(IMAPSession *session)
{
- close(SESSION(session)->sock);
+ sock_close(SESSION(session)->sock);
+ SESSION(session)->sock = NULL;
g_free(session->mbox);
item->last_num = procmsg_get_last_num_in_cache(mlist);
procmsg_set_flags(mlist, item);
} else {
- gint ok, exists = 0, recent = 0, unseen = 0, begin = 1;
- gulong uid = 0, last_uid = item->mtime;
+ gint ok, exists = 0, recent = 0, unseen = 0, begin = 1;
+ gulong uid = 0, last_uid = item->mtime;
ok = imap_select(SESSION(session)->sock, item->path,
&exists, &recent, &unseen, &uid);
}
-static gint imap_open(const gchar *server, gushort port, gchar *buf)
+static SockInfo *imap_open(const gchar *server, gushort port, gchar *buf)
{
- SockInfo *sockinfo;
- gint sock;
+ SockInfo *sock;
- if ((sockinfo = sock_connect(server, port)) == NULL) {
+ if ((sock = sock_connect(server, port)) == NULL) {
log_warning(_("Can't connect to IMAP4 server: %s:%d\n"),
server, port);
- return -1;
+ return NULL;
}
- sock = sockinfo->sock;
- sock_sockinfo_free(sockinfo);
imap_cmd_count = 0;
if (imap_noop(sock) != IMAP_SUCCESS) {
sock_close(sock);
- return -1;
+ return NULL;
}
return sock;
}
-static gint imap_auth(gint sock, const gchar *user, const gchar *pass)
+static gint imap_auth(SockInfo *sock, const gchar *user, const gchar *pass)
{
gint ok;
GPtrArray *argbuf;
return ok;
}
-static gint imap_logout(gint sock)
+static gint imap_logout(SockInfo *sock)
{
imap_gen_send(sock, "LOGOUT");
return imap_ok(sock, NULL);
}
-static gint imap_noop(gint sock)
+static gint imap_noop(SockInfo *sock)
{
imap_gen_send(sock, "NOOP");
return imap_ok(sock, NULL);
}
-static gint imap_select(gint sock, const gchar *folder,
+static gint imap_select(SockInfo *sock, const gchar *folder,
gint *exists, gint *recent, gint *unseen, gulong *uid)
{
gint ok;
return tmp + 1;
}
-static gint imap_get_message(gint sock, gint num, const gchar *filename)
+static gint imap_get_message(SockInfo *sock, gint num, const gchar *filename)
{
gint ok;
gchar buf[IMAPBUFSIZE];
return ok;
}
-static gint imap_copy_message(gint sock, gint num, const gchar *destfolder)
+static gint imap_copy_message(SockInfo *sock, gint num, const gchar *destfolder)
{
gint ok;
return ok;
}
-static gchar *imap_parse_atom(gint sock, gchar *src, gchar *dest,
+static gchar *imap_parse_atom(SockInfo *sock, gchar *src, gchar *dest,
gchar *orig_buf)
{
gchar *cur_pos = src;
return cur_pos;
}
-static gchar *imap_parse_one_address(gint sock, gchar *start,
+static gchar *imap_parse_one_address(SockInfo *sock, gchar *start,
gchar *out_from_str,
gchar *out_fromname_str,
gchar *orig_buf)
return cur_pos + 1;
}
-static gchar *imap_parse_address(gint sock, gchar *start,
+static gchar *imap_parse_address(SockInfo *sock, gchar *start,
gchar **out_from_str,
gchar **out_fromname_str,
gchar *orig_buf)
return flags;
}
-static MsgInfo *imap_parse_envelope(gint sock, gchar *line_str)
+static MsgInfo *imap_parse_envelope(SockInfo *sock, gchar *line_str)
{
MsgInfo *msginfo;
gchar buf[IMAPBUFSIZE];
return msginfo;
}
-gint imap_get_envelope(gint sock, gint first, gint last)
+gint imap_get_envelope(SockInfo *sock, gint first, gint last)
{
imap_gen_send(sock, "FETCH %d:%d (FLAGS RFC822.SIZE ENVELOPE)",
first, last);
return IMAP_SUCCESS;
}
-static gint imap_store(gint sock, gint first, gint last, gchar *sub_cmd)
+static gint imap_store(SockInfo *sock, gint first, gint last, gchar *sub_cmd)
{
gint ok;
GPtrArray *argbuf;
return IMAP_SUCCESS;
}
-static gint imap_ok(gint sock, GPtrArray *argbuf)
+static gint imap_ok(SockInfo *sock, GPtrArray *argbuf)
{
gint ok;
gchar buf[IMAPBUFSIZE];
return NULL;
}
-static void imap_gen_send(gint sock, const gchar *format, ...)
+static void imap_gen_send(SockInfo *sock, const gchar *format, ...)
{
gchar buf[IMAPBUFSIZE];
gchar tmp[IMAPBUFSIZE];
sock_write(sock, buf, strlen(buf));
}
-static gint imap_gen_recv(gint sock, gchar *buf, gint size)
+static gint imap_gen_recv(SockInfo *sock, gchar *buf, gint size)
{
if (sock_read(sock, buf, size) == -1)
return IMAP_SOCKET;