source: trunk/third/libsoup/libsoup/soup-server-message.c @ 21108

Revision 21108, 3.0 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21107, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * soup-server-message.c: Server-side messages
4 *
5 * Copyright (C) 2001-2003, Ximian, Inc.
6 */
7
8#ifdef HAVE_CONFIG_H
9#include <config.h>
10#endif
11
12#include <string.h>
13#include <stdio.h>
14#include <stdlib.h>
15#include <unistd.h>
16
17#include "soup-server-message.h"
18#include "soup-server.h"
19
20struct SoupServerMessagePrivate {
21        SoupServer *server;
22
23        SoupTransferEncoding encoding;
24
25        gboolean  started;
26        gboolean  finished;
27};
28
29#define PARENT_TYPE SOUP_TYPE_MESSAGE
30static SoupMessageClass *parent_class;
31
32static void
33init (GObject *object)
34{
35        SoupServerMessage *smsg = SOUP_SERVER_MESSAGE (object);
36
37        smsg->priv = g_new0 (SoupServerMessagePrivate, 1);
38}
39
40static void
41finalize (GObject *object)
42{
43        SoupServerMessage *smsg = SOUP_SERVER_MESSAGE (object);
44
45        /* FIXME */
46        g_free ((char *) ((SoupMessage *)smsg)->method);
47
48        g_free (smsg->priv);
49
50        G_OBJECT_CLASS (parent_class)->finalize (object);
51}
52
53static void
54dispose (GObject *object)
55{
56        SoupServerMessage *smsg = SOUP_SERVER_MESSAGE (object);
57
58        if (smsg->priv->server)
59                g_object_unref (smsg->priv->server);
60
61        G_OBJECT_CLASS (parent_class)->dispose (object);
62}
63
64
65
66static void
67class_init (GObjectClass *object_class)
68{
69        parent_class = g_type_class_ref (PARENT_TYPE);
70
71        /* virtual method override */
72        object_class->finalize = finalize;
73        object_class->dispose = dispose;
74}
75
76SOUP_MAKE_TYPE (soup_server_message, SoupServerMessage, class_init, init, PARENT_TYPE)
77
78
79SoupServerMessage *
80soup_server_message_new (SoupServer *server)
81{
82        SoupServerMessage *smsg;
83
84        g_return_val_if_fail (SOUP_IS_SERVER (server), NULL);
85
86        smsg = g_object_new (SOUP_TYPE_SERVER_MESSAGE, NULL);
87        smsg->priv->server = g_object_ref (server);
88
89        return smsg;
90}
91
92SoupServer *
93soup_server_message_get_server (SoupServerMessage *smsg)
94{
95        g_return_val_if_fail (SOUP_IS_SERVER_MESSAGE (smsg), NULL);
96
97        return smsg->priv->server;
98}
99
100void
101soup_server_message_set_encoding (SoupServerMessage *smsg,
102                                  SoupTransferEncoding encoding)
103{
104        g_return_if_fail (SOUP_IS_SERVER_MESSAGE (smsg));
105
106        smsg->priv->encoding = encoding;
107}
108
109SoupTransferEncoding
110soup_server_message_get_encoding (SoupServerMessage *smsg)
111{
112        g_return_val_if_fail (SOUP_IS_SERVER_MESSAGE (smsg), SOUP_TRANSFER_UNKNOWN);
113
114        return smsg->priv->encoding;
115}
116
117void
118soup_server_message_start (SoupServerMessage *smsg)
119{
120        g_return_if_fail (SOUP_IS_SERVER_MESSAGE (smsg));
121
122        smsg->priv->started = TRUE;
123
124        soup_message_io_unpause (SOUP_MESSAGE (smsg));
125}
126
127gboolean
128soup_server_message_is_started (SoupServerMessage *smsg)
129{
130        g_return_val_if_fail (SOUP_IS_SERVER_MESSAGE (smsg), TRUE);
131
132        return smsg->priv->started;
133}
134
135void
136soup_server_message_finish  (SoupServerMessage *smsg)
137{
138        g_return_if_fail (SOUP_IS_SERVER_MESSAGE (smsg));
139
140        smsg->priv->started = TRUE;
141        smsg->priv->finished = TRUE;
142
143        soup_message_io_unpause (SOUP_MESSAGE (smsg));
144}
145
146gboolean
147soup_server_message_is_finished (SoupServerMessage *smsg)
148{
149        g_return_val_if_fail (SOUP_IS_SERVER_MESSAGE (smsg), TRUE);
150
151        return smsg->priv->finished;
152}
Note: See TracBrowser for help on using the repository browser.