2 * beagle-snippet-response.c
4 * Copyright (C) 2005 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-snippet-response.h"
34 #include "beagle-private.h"
38 } BeagleSnippetResponsePrivate
;
40 #define BEAGLE_SNIPPET_RESPONSE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BEAGLE_TYPE_SNIPPET_RESPONSE, BeagleSnippetResponsePrivate))
42 static BeagleResponseClass
*parent_class
= NULL
;
44 G_DEFINE_TYPE (BeagleSnippetResponse
, beagle_snippet_response
, BEAGLE_TYPE_RESPONSE
)
47 beagle_snippet_response_finalize (GObject
*obj
)
49 BeagleSnippetResponsePrivate
*priv
= BEAGLE_SNIPPET_RESPONSE_GET_PRIVATE (obj
);
51 g_free (priv
->snippet
);
53 if (G_OBJECT_CLASS (parent_class
)->finalize
)
54 G_OBJECT_CLASS (parent_class
)->finalize (obj
);
58 end_snippet (BeagleParserContext
*ctx
)
60 BeagleSnippetResponse
*response
= BEAGLE_SNIPPET_RESPONSE (_beagle_parser_context_get_response (ctx
));
61 BeagleSnippetResponsePrivate
*priv
= BEAGLE_SNIPPET_RESPONSE_GET_PRIVATE (response
);
63 priv
->snippet
= _beagle_parser_context_get_text_buffer (ctx
);
70 static BeagleParserHandler parser_handlers
[] = {
80 beagle_snippet_response_class_init (BeagleSnippetResponseClass
*klass
)
82 GObjectClass
*obj_class
= G_OBJECT_CLASS (klass
);
84 parent_class
= g_type_class_peek_parent (klass
);
86 obj_class
->finalize
= beagle_snippet_response_finalize
;
88 _beagle_response_class_set_parser_handlers (BEAGLE_RESPONSE_CLASS (klass
),
91 g_type_class_add_private (klass
, sizeof (BeagleSnippetResponsePrivate
));
95 beagle_snippet_response_init (BeagleSnippetResponse
*response
)
100 * beagle_snippet_response_get_snippet:
101 * @response: a #BeagleSnippetResponse
103 * Fetches the snippet from the given #BeagleSnippetResponse.
105 * Return value: the snippet string from the #BeagleSnippetResponse.
107 G_CONST_RETURN
char *
108 beagle_snippet_response_get_snippet (BeagleSnippetResponse
*response
)
110 BeagleSnippetResponsePrivate
*priv
;
112 g_return_val_if_fail (BEAGLE_IS_SNIPPET_RESPONSE (response
), NULL
);
114 priv
= BEAGLE_SNIPPET_RESPONSE_GET_PRIVATE (response
);
116 return priv
->snippet
;