If we get an EOF trying to read a uint or a time value, throw an exception.
[beagle.git] / libbeagle / beagle / beagle-informational-messages-request.c
blob73b65d1905bef196d7a30578b0f0e9aeb5db91bb
1 /*
2 * beagle-informational-messages-request.c
4 * Copyright (C) 2006 Novell, Inc.
6 */
8 /*
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
28 #include <stdlib.h>
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <sys/un.h>
33 #include "beagle-private.h"
34 #include "beagle-informational-messages-request.h"
35 #include "beagle-indexing-status-response.h"
37 enum {
38 INDEXING_STATUS,
39 LAST_SIGNAL
42 static GObjectClass *parent_class = NULL;
43 static guint signals [LAST_SIGNAL] = { 0 };
45 static GString *
46 beagle_informational_messages_request_to_xml (BeagleRequest *request, GError **err)
48 GString *data = g_string_new (NULL);
50 _beagle_request_append_standard_header (data,
51 "InformationalMessagesRequest");
53 _beagle_request_append_standard_footer (data);
55 return data;
58 static void
59 beagle_informational_messages_request_response (BeagleRequest *request, BeagleResponse *response)
61 if (BEAGLE_IS_INDEXING_STATUS_RESPONSE (response))
62 g_signal_emit (request, signals [INDEXING_STATUS], 0, response);
65 G_DEFINE_TYPE (BeagleInformationalMessagesRequest, beagle_informational_messages_request, BEAGLE_TYPE_REQUEST)
67 static void
68 beagle_informational_messages_request_class_init (BeagleInformationalMessagesRequestClass *klass)
70 GObjectClass *obj_class = G_OBJECT_CLASS (klass);
71 BeagleRequestClass *request_class = BEAGLE_REQUEST_CLASS (klass);
73 parent_class = g_type_class_peek_parent (klass);
75 request_class->to_xml = beagle_informational_messages_request_to_xml;
76 request_class->response = beagle_informational_messages_request_response;
78 signals [INDEXING_STATUS] =
79 g_signal_new ("indexing_status",
80 G_TYPE_FROM_CLASS (klass),
81 G_SIGNAL_RUN_LAST,
82 G_STRUCT_OFFSET (BeagleInformationalMessagesRequestClass, indexing_status),
83 NULL, NULL,
84 g_cclosure_marshal_VOID__OBJECT,
85 G_TYPE_NONE, 1,
86 BEAGLE_TYPE_INDEXING_STATUS_RESPONSE);
88 _beagle_request_class_set_response_types (request_class,
89 "IndexingStatusResponse",
90 BEAGLE_TYPE_INDEXING_STATUS_RESPONSE,
91 NULL);
94 static void
95 beagle_informational_messages_request_init (BeagleInformationalMessagesRequest *informational_messages_request)
100 * beagle_informational_messages_request_new:
102 * Creates a new #BeagleInformationalMessagesRequest message. You will need to
103 * connect to the signals on this message for it to be useful.
105 * Return value: a newly created #BeagleInformationalMessagesRequest.
107 BeagleInformationalMessagesRequest *
108 beagle_informational_messages_request_new (void)
110 return g_object_new (BEAGLE_TYPE_INFORMATIONAL_MESSAGES_REQUEST, 0);