2 * beagle-indexing-status-response.c
4 * Copyright (C) 2006 Novell, Inc.
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.
29 #include <sys/types.h>
30 #include <sys/socket.h>
33 #include "beagle-indexing-status-response.h"
34 #include "beagle-private.h"
38 } BeagleIndexingStatusResponsePrivate
;
40 #define BEAGLE_INDEXING_STATUS_RESPONSE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BEAGLE_TYPE_INDEXING_STATUS_RESPONSE, BeagleIndexingStatusResponsePrivate))
42 static BeagleResponseClass
*parent_class
= NULL
;
44 G_DEFINE_TYPE (BeagleIndexingStatusResponse
, beagle_indexing_status_response
, BEAGLE_TYPE_RESPONSE
)
47 end_status (BeagleParserContext
*ctx
)
49 BeagleIndexingStatusResponse
*response
= BEAGLE_INDEXING_STATUS_RESPONSE (_beagle_parser_context_get_response (ctx
));
50 BeagleIndexingStatusResponsePrivate
*priv
= BEAGLE_INDEXING_STATUS_RESPONSE_GET_PRIVATE (response
);
53 buf
= _beagle_parser_context_get_text_buffer (ctx
);
55 if (strcmp (buf
, "Running") == 0)
56 priv
->is_indexing
= TRUE
;
57 else if (strcmp (buf
, "NotRunning") == 0)
58 priv
->is_indexing
= FALSE
;
60 g_warning ("Unknown value for indexing status: %s", buf
);
61 priv
->is_indexing
= FALSE
;
71 static BeagleParserHandler parser_handlers
[] = {
82 beagle_indexing_status_response_class_init (BeagleIndexingStatusResponseClass
*klass
)
84 parent_class
= g_type_class_peek_parent (klass
);
86 _beagle_response_class_set_parser_handlers (BEAGLE_RESPONSE_CLASS (klass
),
89 g_type_class_add_private (klass
, sizeof (BeagleIndexingStatusResponsePrivate
));
93 beagle_indexing_status_response_init (BeagleIndexingStatusResponse
*response
)
98 * beagle_indexing_status_response_is_indexing
99 * @response: a #BeagleIndexingStatusResponse
101 * Returns whether or not the daemon is running a large indexing process. This
102 * will be TRUE if a long crawling process is running, but will return FALSE if
103 * it's just indexing one or two documents.
105 * Return value: TRUE if indexing, FALSE if not.
108 beagle_indexing_status_response_is_indexing (BeagleIndexingStatusResponse
*response
)
110 BeagleIndexingStatusResponsePrivate
*priv
;
112 g_return_val_if_fail (BEAGLE_IS_INDEXING_STATUS_RESPONSE (response
), -1);
113 priv
= BEAGLE_INDEXING_STATUS_RESPONSE_GET_PRIVATE (response
);
114 g_return_val_if_fail (priv
!= NULL
, -1);
116 return priv
->is_indexing
;