aboutsummaryrefslogtreecommitdiff
path: root/libsylph
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-09-25 09:42:39 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-09-25 09:42:39 +0000
commit1ff05553158408570a7cd548fdcdf4ec7be07f5d (patch)
tree3667621c49e8ba4006ad3fd6e668292b3ffb83cb /libsylph
parentcd87d5c742ab84c90e4338d46a23f17f9dbf9d2b (diff)
fixed the handling of GDK thread lock.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2258 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r--libsylph/pop.c10
-rw-r--r--libsylph/session.c17
-rw-r--r--libsylph/socket.c13
-rw-r--r--libsylph/socket.h2
-rw-r--r--libsylph/utils.c18
-rw-r--r--libsylph/utils.h4
6 files changed, 53 insertions, 11 deletions
diff --git a/libsylph/pop.c b/libsylph/pop.c
index 57d7fd2b..e384e66c 100644
--- a/libsylph/pop.c
+++ b/libsylph/pop.c
@@ -335,6 +335,7 @@ gint pop3_retr_send(Pop3Session *session)
{
session->state = POP3_RETR;
pop3_gen_send(session, "RETR %d", session->cur_msg);
+ g_print("sent RETR\n");
return PS_SUCCESS;
}
@@ -343,6 +344,8 @@ gint pop3_retr_recv(Pop3Session *session, FILE *fp, guint len)
gchar *file;
gint drop_ok;
+ g_print("pop3_retr_recv (%d)\n", session->cur_msg);
+
file = get_tmp_file();
if (pop3_write_msg_to_file(file, fp, len) < 0) {
g_free(file);
@@ -368,6 +371,7 @@ gint pop3_retr_recv(Pop3Session *session, FILE *fp, guint len)
: drop_ok == DROP_DELETE ? RECV_TIME_DELETE
: session->current_time;
+ g_print("pop3_retr_recv done (%d)\n", session->cur_msg);
return PS_SUCCESS;
}
@@ -630,6 +634,7 @@ static Pop3State pop3_lookup_next(Pop3Session *session)
gint size;
gboolean size_limit_over;
+ g_print("pop3_lookup_next (%d -)\n", session->cur_msg);
for (;;) {
msg = &session->msg[session->cur_msg];
size = msg->size;
@@ -670,6 +675,7 @@ static Pop3State pop3_lookup_next(Pop3Session *session)
}
pop3_retr_send(session);
+ g_print("pop3_lookup_next (%d) done\n", session->cur_msg);
return POP3_RETR;
}
@@ -852,6 +858,7 @@ static gint pop3_session_recv_data_finished(Session *session, guchar *data,
Pop3Session *pop3_session = POP3_SESSION(session);
Pop3ErrorValue val = PS_SUCCESS;
+ g_print("pop3_session_recv_data_finished\n");
switch (pop3_session->state) {
case POP3_GETRANGE_UIDL_RECV:
val = pop3_getrange_uidl_recv(pop3_session, (gchar *)data, len);
@@ -876,6 +883,7 @@ static gint pop3_session_recv_data_finished(Session *session, guchar *data,
return -1;
}
+ g_print("pop3_session_recv_data_finished done\n");
return 0;
}
@@ -886,6 +894,7 @@ static gint pop3_session_recv_data_as_file_finished(Session *session, FILE *fp,
g_return_val_if_fail(pop3_session->state == POP3_RETR_RECV, -1);
+ g_print("pop3_session_recv_data_as_file_finished (%d)\n", pop3_session->cur_msg);
if (pop3_retr_recv(pop3_session, fp, len) < 0)
return -1;
@@ -903,6 +912,7 @@ static gint pop3_session_recv_data_as_file_finished(Session *session, FILE *fp,
if (pop3_lookup_next(pop3_session) == POP3_ERROR)
return -1;
}
+ g_print("pop3_session_recv_data_as_file_finished done (next %d)\n", pop3_session->cur_msg);
return 0;
}
diff --git a/libsylph/session.c b/libsylph/session.c
index 0617e402..4d043063 100644
--- a/libsylph/session.c
+++ b/libsylph/session.c
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2009 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -121,7 +121,6 @@ gint session_connect(Session *session, const gchar *server, gushort port)
{
#ifndef G_OS_UNIX
SockInfo *sock = NULL;
- gint flag = 0;
#endif
g_return_val_if_fail(session != NULL, -1);
g_return_val_if_fail(server != NULL, -1);
@@ -143,7 +142,7 @@ gint session_connect(Session *session, const gchar *server, gushort port)
}
return 0;
-#else
+#elif USE_THREADS
session->conn_id = sock_connect_async(server, port);
if (session->conn_id < 0) {
g_warning("can't connect to server.");
@@ -157,6 +156,15 @@ gint session_connect(Session *session, const gchar *server, gushort port)
}
return session_connect_cb(sock, session);
+#else /* !USE_THREADS */
+ sock = sock_connect(server, port);
+ if (sock == NULL) {
+ g_warning("can't connect to server.");
+ session->state = SESSION_ERROR;
+ return -1;
+ }
+
+ return session_connect_cb(sock, session);
#endif
}
@@ -348,7 +356,8 @@ static gint session_close(Session *session)
{
g_return_val_if_fail(session != NULL, -1);
-#ifdef G_OS_UNIX
+//#ifdef G_OS_UNIX
+#if 0
if (session->conn_id > 0) {
sock_connect_async_cancel(session->conn_id);
session->conn_id = 0;
diff --git a/libsylph/socket.c b/libsylph/socket.c
index 5e6df275..5b2ea960 100644
--- a/libsylph/socket.c
+++ b/libsylph/socket.c
@@ -87,11 +87,11 @@ struct _SockConnectData {
SockLookupData *lookup_data;
GIOChannel *channel;
guint io_tag;
-#else
+#elif USE_THREADS
gint flag;
GThread *thread;
SockInfo *sock;
-#endif
+#endif /* G_OS_UNIX */
SockConnectFunc func;
gpointer data;
};
@@ -1323,8 +1323,8 @@ static gint sock_get_address_info_async_cancel(SockLookupData *lookup_data)
return 0;
}
-#else /* G_OS_UNIX */
-
+#else /* !G_OS_UNIX */
+#if USE_THREADS
static gpointer sock_connect_async_func(gpointer data)
{
SockConnectData *conn_data = (SockConnectData *)data;
@@ -1382,7 +1382,7 @@ gint sock_connect_async_wait(gint id, SockInfo **sock)
g_print("sock_connect_async_wait: waiting thread\n");
while (conn_data->flag == 0)
- g_main_context_iteration(NULL, TRUE);
+ event_loop_iterate();
g_print("sock_connect_async_wait: flagged\n");
g_thread_join(conn_data->thread);
@@ -1394,7 +1394,10 @@ gint sock_connect_async_wait(gint id, SockInfo **sock)
conn_data);
g_free(conn_data->hostname);
g_free(conn_data);
+
+ return 0;
}
+#endif /* USE_THREADS */
#endif /* G_OS_UNIX */
diff --git a/libsylph/socket.h b/libsylph/socket.h
index 0ddf0374..37d1e397 100644
--- a/libsylph/socket.h
+++ b/libsylph/socket.h
@@ -103,7 +103,7 @@ SockInfo *sock_connect (const gchar *hostname, gushort port);
gint sock_connect_async (const gchar *hostname, gushort port,
SockConnectFunc func, gpointer data);
gint sock_connect_async_cancel (gint id);
-#else
+#elif USE_THREADS
gint sock_connect_async (const gchar *hostname, gushort port);
gint sock_connect_async_wait (gint id, SockInfo **sock);
#endif
diff --git a/libsylph/utils.c b/libsylph/utils.c
index 2898ef76..c0664488 100644
--- a/libsylph/utils.c
+++ b/libsylph/utils.c
@@ -3884,6 +3884,7 @@ static gpointer execute_command_line_async_func(gpointer data)
cmd_data->flag = 1;
g_main_context_wakeup(NULL);
+ g_print("execute_command_line_async_func: exiting\n");
return GINT_TO_POINTER(0);
}
@@ -3910,7 +3911,7 @@ gint execute_command_line_async_wait(const gchar *cmdline)
g_print("execute_command_line_async_wait: waiting thread\n");
while (data.flag == 0)
- g_main_context_iteration(NULL, TRUE);
+ event_loop_iterate();
g_print("execute_command_line_async_wait: flagged\n");
g_thread_join(thread);
@@ -4216,6 +4217,21 @@ void ui_update(void)
ui_update_func();
}
+static EventLoopFunc event_loop_func = NULL;
+
+void set_event_loop_func(EventLoopFunc func)
+{
+ event_loop_func = func;
+}
+
+void event_loop_iterate(void)
+{
+ if (event_loop_func)
+ event_loop_func();
+ else
+ g_main_context_iteration(NULL, TRUE);
+}
+
static ProgressFunc progress_func = NULL;
void set_progress_func(ProgressFunc func)
diff --git a/libsylph/utils.h b/libsylph/utils.h
index 3bbc42cb..5f21dc63 100644
--- a/libsylph/utils.h
+++ b/libsylph/utils.h
@@ -181,6 +181,7 @@ gint syl_link (const gchar *src,
}
typedef void (*UIUpdateFunc) (void);
+typedef void (*EventLoopFunc) (void);
typedef void (*ProgressFunc) (gint cur,
gint total);
typedef gchar * (*QueryPasswordFunc) (const gchar *server,
@@ -496,6 +497,9 @@ size_t my_strftime (gchar *s,
void set_ui_update_func (UIUpdateFunc func);
void ui_update (void);
+void set_event_loop_func (EventLoopFunc func);
+void event_loop_iterate (void);
+
void set_progress_func (ProgressFunc func);
void progress_show (gint cur,
gint total);