NoiseFilter: Dont drop last word of apparent hostnames. Too many non-hostnames can...
[beagle.git] / libbeagle / beagle / beagle-daemon-information-request.c
blob86b1941362f3fc1eaede73f17037d96efb964291
1 /*
2 * beagle-daemon-information-request.c
4 * Copyright (C) 2005 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-daemon-information-request.h"
35 #include "beagle-daemon-information-response.h"
37 typedef struct {
38 gboolean get_version : 1;
39 gboolean get_sched_info : 1;
40 gboolean get_index_status : 1;
41 gboolean get_is_indexing : 1;
42 } BeagleDaemonInformationRequestPrivate;
44 #define BEAGLE_DAEMON_INFORMATION_REQUEST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BEAGLE_TYPE_DAEMON_INFORMATION_REQUEST, BeagleDaemonInformationRequestPrivate))
46 static GObjectClass *parent_class = NULL;
48 static GString *
49 beagle_daemon_information_request_to_xml (BeagleRequest *request, GError **err)
51 BeagleDaemonInformationRequestPrivate *priv = BEAGLE_DAEMON_INFORMATION_REQUEST_GET_PRIVATE (request);
52 GString *data = g_string_new (NULL);
54 _beagle_request_append_standard_header (data,
55 "DaemonInformationRequest");
57 if (priv->get_version)
58 g_string_append (data, "<GetVersion>true</GetVersion>");
59 else
60 g_string_append (data, "<GetVersion>false</GetVersion>");
62 if (priv->get_sched_info)
63 g_string_append (data, "<GetSchedInfo>true</GetSchedInfo>");
64 else
65 g_string_append (data, "<GetSchedInfo>false</GetSchedInfo>");
67 if (priv->get_index_status)
68 g_string_append (data, "<GetIndexStatus>true</GetIndexStatus>");
69 else
70 g_string_append (data, "<GetIndexStatus>false</GetIndexStatus>");
72 if (priv->get_is_indexing)
73 g_string_append (data, "<GetIsIndexing>true</GetIsIndexing>");
74 else
75 g_string_append (data, "<GetIsIndexing>false</GetIsIndexing>");
77 _beagle_request_append_standard_footer (data);
79 return data;
82 G_DEFINE_TYPE (BeagleDaemonInformationRequest, beagle_daemon_information_request, BEAGLE_TYPE_REQUEST)
84 static void
85 beagle_daemon_information_request_finalize (GObject *obj)
87 if (G_OBJECT_CLASS (parent_class)->finalize) {
88 G_OBJECT_CLASS (parent_class)->finalize (obj);
92 static void
93 beagle_daemon_information_request_class_init (BeagleDaemonInformationRequestClass *klass)
95 GObjectClass *obj_class = G_OBJECT_CLASS (klass);
96 BeagleRequestClass *request_class = BEAGLE_REQUEST_CLASS (klass);
98 parent_class = g_type_class_peek_parent (klass);
100 obj_class->finalize = beagle_daemon_information_request_finalize;
101 request_class->to_xml = beagle_daemon_information_request_to_xml;
103 g_type_class_add_private (klass, sizeof (BeagleDaemonInformationRequestPrivate));
105 _beagle_request_class_set_response_types (request_class,
106 "DaemonInformationResponse",
107 BEAGLE_TYPE_DAEMON_INFORMATION_RESPONSE,
108 NULL);
111 static void
112 beagle_daemon_information_request_init (BeagleDaemonInformationRequest *daemon_information_request)
117 * beagle_daemon_information_request_new:
119 * Creates a new #BeagleDaemonInformationRequest requesting all fields.
121 * Return value: a newly created #BeagleDaemonInformationRequest.
123 BeagleDaemonInformationRequest *
124 beagle_daemon_information_request_new (void)
126 return beagle_daemon_information_request_new_specific (TRUE, TRUE, TRUE, TRUE);
130 * beagle_daemon_information_request_new_specific:
132 * Creates a new #BeagleDaemonInformationRequest allowing retrieval of specific fields.
134 * Return value: a newly created #BeagleDaemonInformationRequest.
136 BeagleDaemonInformationRequest *
137 beagle_daemon_information_request_new_specific (gboolean get_version,
138 gboolean get_sched_info,
139 gboolean get_index_status,
140 gboolean get_is_indexing)
142 BeagleDaemonInformationRequest *daemon_information_request = g_object_new (BEAGLE_TYPE_DAEMON_INFORMATION_REQUEST, 0);
144 BeagleDaemonInformationRequestPrivate *priv
145 = BEAGLE_DAEMON_INFORMATION_REQUEST_GET_PRIVATE (daemon_information_request);
147 priv->get_version = get_version;
148 priv->get_sched_info = get_sched_info;
149 priv->get_index_status = get_index_status;
150 priv->get_is_indexing = get_is_indexing;
152 return daemon_information_request;