[libsoup/wip/nacho/soup-extern: 1/7] Mark old session-(async|sync) methods as deprecated
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/wip/nacho/soup-extern: 1/7] Mark old session-(async|sync) methods as deprecated
- Date: Tue, 3 Nov 2015 09:03:54 +0000 (UTC)
commit 2de1625d9a8ec3de27e65ea6e7c43115353aeeb3
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Tue Nov 3 08:05:25 2015 +0100
Mark old session-(async|sync) methods as deprecated
They were not marked as deprecated yet to give people time to port over
without getting annoying warnings. Now that we are at the start
of a cycle let's mark them.
Fix all the consequent deprecation warnings.
https://bugzilla.gnome.org/show_bug.cgi?id=757146
examples/simple-proxy.c | 2 +-
libsoup/soup-message-client-io.c | 13 +++++++++----
libsoup/soup-message-io.c | 2 ++
libsoup/soup-request-http.c | 4 ++++
libsoup/soup-session-async.c | 4 ++++
libsoup/soup-session-async.h | 3 +++
libsoup/soup-session-sync.c | 4 ++++
libsoup/soup-session-sync.h | 3 +++
libsoup/soup-session.c | 9 +++++++--
tests/test-utils.c | 22 +++++++++++++++++-----
10 files changed, 54 insertions(+), 12 deletions(-)
---
diff --git a/examples/simple-proxy.c b/examples/simple-proxy.c
index 7657355..e585490 100644
--- a/examples/simple-proxy.c
+++ b/examples/simple-proxy.c
@@ -405,7 +405,7 @@ main (int argc, char **argv)
}
g_slist_free (uris);
- session = soup_session_async_new ();
+ session = soup_session_new ();
g_print ("\nWaiting for requests...\n");
diff --git a/libsoup/soup-message-client-io.c b/libsoup/soup-message-client-io.c
index f571ef7..6a21e71 100644
--- a/libsoup/soup-message-client-io.c
+++ b/libsoup/soup-message-client-io.c
@@ -147,15 +147,20 @@ soup_message_send_request (SoupMessageQueueItem *item,
SoupMessageCompletionFn completion_cb,
gpointer user_data)
{
- GMainContext *async_context;
+ gboolean is_sync = FALSE;
+ GMainContext *async_context = NULL;
GIOStream *iostream;
- if (!SOUP_IS_SESSION_SYNC (item->session)) {
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ is_sync = SOUP_IS_SESSION_SYNC (item->session);
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
+ if (!is_sync) {
async_context = soup_session_get_async_context (item->session);
if (!async_context)
async_context = g_main_context_default ();
- } else
- async_context = NULL;
+ }
+
iostream = soup_socket_get_iostream (soup_connection_get_socket (item->conn));
soup_message_io_client (item, iostream, async_context,
diff --git a/libsoup/soup-message-io.c b/libsoup/soup-message-io.c
index f7ae436..207c7bb 100644
--- a/libsoup/soup-message-io.c
+++ b/libsoup/soup-message-io.c
@@ -1226,12 +1226,14 @@ soup_message_io_client (SoupMessageQueueItem *item,
io->write_state = SOUP_MESSAGE_IO_STATE_HEADERS;
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if (!item->new_api) {
gboolean blocking =
SOUP_IS_SESSION_SYNC (item->session) ||
(!SOUP_IS_SESSION_ASYNC (item->session) && !item->async);
io_run (item->msg, blocking);
}
+ G_GNUC_END_IGNORE_DEPRECATIONS;
}
void
diff --git a/libsoup/soup-request-http.c b/libsoup/soup-request-http.c
index 9ae2c2a..49b0d0b 100644
--- a/libsoup/soup-request-http.c
+++ b/libsoup/soup-request-http.c
@@ -105,7 +105,9 @@ soup_request_http_send (SoupRequest *request,
SoupRequestHTTP *http = SOUP_REQUEST_HTTP (request);
SoupSession *session = soup_request_get_session (request);
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
g_return_val_if_fail (!SOUP_IS_SESSION_ASYNC (session), NULL);
+ G_GNUC_END_IGNORE_DEPRECATIONS;
return soup_session_send (session, http->priv->msg,
cancellable, error);
@@ -137,7 +139,9 @@ soup_request_http_send_async (SoupRequest *request,
SoupSession *session = soup_request_get_session (request);
GTask *task;
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
g_return_if_fail (!SOUP_IS_SESSION_SYNC (session));
+ G_GNUC_END_IGNORE_DEPRECATIONS;
task = g_task_new (request, cancellable, callback, user_data);
soup_session_send_async (session, http->priv->msg, cancellable,
diff --git a/libsoup/soup-session-async.c b/libsoup/soup-session-async.c
index b935348..e9d4712 100644
--- a/libsoup/soup-session-async.c
+++ b/libsoup/soup-session-async.c
@@ -30,6 +30,8 @@
* linkend="libsoup-session-porting">porting guide</link>.
**/
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
G_DEFINE_TYPE (SoupSessionAsync, soup_session_async, SOUP_TYPE_SESSION)
static void
@@ -141,3 +143,5 @@ soup_session_async_class_init (SoupSessionAsyncClass *soup_session_async_class)
session_class->send_message = soup_session_async_send_message;
session_class->cancel_message = soup_session_async_cancel_message;
}
+
+G_GNUC_END_IGNORE_DEPRECATIONS;
diff --git a/libsoup/soup-session-async.h b/libsoup/soup-session-async.h
index 9621763..d4d14f7 100644
--- a/libsoup/soup-session-async.h
+++ b/libsoup/soup-session-async.h
@@ -33,10 +33,13 @@ typedef struct {
void (*_libsoup_reserved4) (void);
} SoupSessionAsyncClass;
+SOUP_DEPRECATED_IN_2_42
GType soup_session_async_get_type (void);
#ifndef SOUP_DISABLE_DEPRECATED
+SOUP_DEPRECATED_IN_2_42
SoupSession *soup_session_async_new (void);
+SOUP_DEPRECATED_IN_2_42
SoupSession *soup_session_async_new_with_options (const char *optname1,
...) G_GNUC_NULL_TERMINATED;
#endif
diff --git a/libsoup/soup-session-sync.c b/libsoup/soup-session-sync.c
index 374f22b..42e5078 100644
--- a/libsoup/soup-session-sync.c
+++ b/libsoup/soup-session-sync.c
@@ -29,6 +29,8 @@
* linkend="libsoup-session-porting">porting guide</link>.
**/
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
G_DEFINE_TYPE (SoupSessionSync, soup_session_sync, SOUP_TYPE_SESSION)
static void
@@ -127,3 +129,5 @@ soup_session_sync_class_init (SoupSessionSyncClass *session_sync_class)
/* virtual method override */
session_class->queue_message = soup_session_sync_queue_message;
}
+
+G_GNUC_END_IGNORE_DEPRECATIONS;
diff --git a/libsoup/soup-session-sync.h b/libsoup/soup-session-sync.h
index cf81f6b..256ca59 100644
--- a/libsoup/soup-session-sync.h
+++ b/libsoup/soup-session-sync.h
@@ -33,10 +33,13 @@ typedef struct {
void (*_libsoup_reserved4) (void);
} SoupSessionSyncClass;
+SOUP_DEPRECATED_IN_2_42
GType soup_session_sync_get_type (void);
#ifndef SOUP_DISABLE_DEPRECATED
+SOUP_DEPRECATED_IN_2_42
SoupSession *soup_session_sync_new (void);
+SOUP_DEPRECATED_IN_2_42
SoupSession *soup_session_sync_new_with_options (const char *optname1,
...) G_GNUC_NULL_TERMINATED;
#endif
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 9831172..34011dc 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -2480,11 +2480,16 @@ static void
soup_session_real_flush_queue (SoupSession *session)
{
SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session);
+ gboolean is_sync;
SoupMessageQueueItem *item;
GHashTable *current = NULL;
gboolean done = FALSE;
- if (SOUP_IS_SESSION_SYNC (session)) {
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ is_sync = SOUP_IS_SESSION_SYNC (session);
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+
+ if (is_sync) {
/* Record the current contents of the queue */
current = g_hash_table_new (NULL, NULL);
for (item = soup_message_queue_first (priv->queue);
@@ -2501,7 +2506,7 @@ soup_session_real_flush_queue (SoupSession *session)
SOUP_STATUS_CANCELLED);
}
- if (SOUP_IS_SESSION_SYNC (session)) {
+ if (is_sync) {
/* Wait until all of the items in @current have been
* removed from the queue. (This is not the same as
* "wait for the queue to be empty", because the app
diff --git a/tests/test-utils.c b/tests/test-utils.c
index 9c74206..22d8521 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -613,6 +613,18 @@ cancel_request_thread (gpointer data)
return NULL;
}
+static gboolean
+is_session_sync(SoupSession *session)
+{
+ gboolean is_sync = FALSE;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ is_sync = SOUP_IS_SESSION_SYNC (session);
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+
+ return is_sync;
+}
+
GInputStream *
soup_test_request_send (SoupRequest *req,
GCancellable *cancellable,
@@ -623,7 +635,7 @@ soup_test_request_send (SoupRequest *req,
GInputStream *stream;
CancelData *cancel_data = create_cancel_data (req, cancellable, flags);
- if (SOUP_IS_SESSION_SYNC (soup_request_get_session (req))) {
+ if (is_session_sync (soup_request_get_session (req))) {
GThread *thread;
if (cancel_data)
@@ -674,11 +686,11 @@ soup_test_request_read_all (SoupRequest *req,
AsyncAsSyncData data;
gsize nread;
- if (!SOUP_IS_SESSION_SYNC (soup_request_get_session (req)))
+ if (!is_session_sync (soup_request_get_session (req)))
data.loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
do {
- if (SOUP_IS_SESSION_SYNC (soup_request_get_session (req))) {
+ if (is_session_sync (soup_request_get_session (req))) {
nread = g_input_stream_read (stream, buf, sizeof (buf),
cancellable, error);
} else {
@@ -691,7 +703,7 @@ soup_test_request_read_all (SoupRequest *req,
}
} while (nread > 0);
- if (!SOUP_IS_SESSION_SYNC (soup_request_get_session (req)))
+ if (!is_session_sync (soup_request_get_session (req)))
g_main_loop_unref (data.loop);
return nread == 0;
@@ -706,7 +718,7 @@ soup_test_request_close_stream (SoupRequest *req,
AsyncAsSyncData data;
gboolean ok;
- if (SOUP_IS_SESSION_SYNC (soup_request_get_session (req)))
+ if (is_session_sync (soup_request_get_session (req)))
return g_input_stream_close (stream, cancellable, error);
data.loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]