SoupSession: bind connections to messages sooner, improve conn failure case
[platform/upstream/libsoup.git] / libsoup / soup-message-queue.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2003 Novell, Inc.
4  * Copyright (C) 2008 Red Hat, Inc.
5  */
6
7 #ifndef SOUP_MESSAGE_QUEUE_H
8 #define SOUP_MESSAGE_QUEUE_H 1
9
10 #include <glib.h>
11 #include <gio/gio.h>
12
13 #include "soup-connection.h"
14 #include "soup-message.h"
15 #include "soup-session.h"
16
17 G_BEGIN_DECLS
18
19 typedef enum {
20         SOUP_MESSAGE_STARTING,
21         SOUP_MESSAGE_RESOLVING_PROXY_URI,
22         SOUP_MESSAGE_RESOLVED_PROXY_URI,
23         SOUP_MESSAGE_RESOLVING_PROXY_ADDRESS,
24         SOUP_MESSAGE_RESOLVED_PROXY_ADDRESS,
25         SOUP_MESSAGE_AWAITING_CONNECTION,
26         SOUP_MESSAGE_GOT_CONNECTION,
27         SOUP_MESSAGE_CONNECTING,
28         SOUP_MESSAGE_CONNECTED,
29         SOUP_MESSAGE_TUNNELING,
30         SOUP_MESSAGE_TUNNELED,
31         SOUP_MESSAGE_READY,
32         SOUP_MESSAGE_RUNNING,
33         SOUP_MESSAGE_RESTARTING,
34         SOUP_MESSAGE_FINISHED
35 } SoupMessageQueueItemState;
36
37 struct _SoupMessageQueueItem {
38         /*< public >*/
39         SoupSession *session;
40         SoupMessageQueue *queue;
41         SoupMessage *msg;
42         SoupSessionCallback callback;
43         gpointer callback_data;
44
45         GCancellable *cancellable;
46         SoupAddress *proxy_addr;
47         SoupURI *proxy_uri;
48         SoupConnection *conn;
49
50         guint redirection_count;
51
52         SoupMessageQueueItemState state;
53
54         /*< private >*/
55         guint removed              : 1;
56         guint ref_count            : 31;
57         SoupMessageQueueItem *prev, *next;
58         SoupMessageQueueItem *related;
59 };
60
61 SoupMessageQueue     *soup_message_queue_new        (SoupSession          *session);
62 SoupMessageQueueItem *soup_message_queue_append     (SoupMessageQueue     *queue,
63                                                      SoupMessage          *msg,
64                                                      SoupSessionCallback   callback,
65                                                      gpointer              user_data);
66
67 SoupMessageQueueItem *soup_message_queue_lookup     (SoupMessageQueue     *queue,
68                                                      SoupMessage          *msg);
69
70 SoupMessageQueueItem *soup_message_queue_first      (SoupMessageQueue     *queue);
71 SoupMessageQueueItem *soup_message_queue_next       (SoupMessageQueue     *queue,
72                                                      SoupMessageQueueItem *item);
73
74 void                  soup_message_queue_remove     (SoupMessageQueue     *queue,
75                                                      SoupMessageQueueItem *item);
76
77 void                  soup_message_queue_item_ref   (SoupMessageQueueItem *item);
78 void                  soup_message_queue_item_unref (SoupMessageQueueItem *item);
79
80 void                  soup_message_queue_destroy    (SoupMessageQueue     *queue);
81
82
83 G_END_DECLS
84
85 #endif /* SOUP_MESSAGE_QUEUE_H */