Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

gtask-query-packet.c

Go to the documentation of this file.
00001 #include <gtask/gtask-query-packet.h>
00002 
00005 /* @{ */
00006 
00007 static gpointer parent_class = NULL;
00008 
00009 static void
00010 gtask_query_packet_class_init( GTaskQueryPacketClass *klass );
00011 
00012 static void
00013 gtask_query_packet_init( GTaskQueryPacket *packet, gpointer g_class );
00014 
00015 static void
00016 gtask_query_packet_finalize( GObject *obj );
00017 
00018 static gboolean
00019 gtask_query_packet_serialize_to( GTaskPacket *packet,
00020                                  GTaskConnection *conn );
00021 
00022 GType gtask_query_packet_get_type( void ) {
00023     static GType type = 0;
00024 
00025     if( type == 0 ) {
00026         static const GTypeInfo info = {
00027             sizeof( GTaskQueryPacketClass ),
00028             NULL,   /* base_init */
00029             NULL,   /* base_finalize */
00030             (GClassInitFunc) gtask_query_packet_class_init,   /* class_init */
00031             NULL,   /* class_finalize */
00032             NULL,   /* class_data */
00033             sizeof( GTaskQueryPacket ),
00034             0,      /* n_preallocs */
00035             (GInstanceInitFunc) gtask_query_packet_init
00036         };
00037 
00038         type = g_type_register_static( GTASK_PACKET_TYPE,
00039                                        "GTaskQueryPacket",
00040                                        &info,
00041                                        0 );
00042     }
00043 
00044     return type;
00045 }
00046 
00047 static void
00048 gtask_query_packet_class_init( GTaskQueryPacketClass *klass ) {
00049     GObjectClass     *gobject_class = G_OBJECT_CLASS( klass );
00050     GTaskPacketClass *packet_class = GTASK_PACKET_CLASS( klass );
00051 
00052     parent_class = g_type_class_peek_parent( klass );
00053 
00054     gobject_class->finalize = gtask_query_packet_finalize;
00055 
00056     packet_class->serialize_packet = gtask_query_packet_serialize_to;
00057 }
00058 
00059 static void
00060 gtask_query_packet_init( GTaskQueryPacket *packet, gpointer g_class ) {
00061     packet->private = g_new0( GTaskQueryPacketPrivate, 1 );
00062 }
00063 
00064 static void
00065 gtask_query_packet_finalize( GObject *obj ) {
00066     GTaskQueryPacket *packet = GTASK_QUERY_PACKET( obj );
00067 
00068     g_free( packet->private );
00069 
00070     if( G_OBJECT_CLASS( parent_class )->finalize )
00071         G_OBJECT_CLASS( parent_class )->finalize( obj );
00072 }
00073 
00088 static gboolean
00089 gtask_query_packet_serialize_to( GTaskPacket *packet,
00090                                  GTaskConnection *conn ) 
00091 {
00092     GTaskQueryPacket   *q_packet;
00093     xmlOutputBufferPtr  xml_output;
00094     xmlDocPtr           doc;
00095     xmlNodePtr          watch_node;
00096 
00097     g_return_val_if_fail( GTASK_IS_QUERY_PACKET( packet ), FALSE );
00098     g_return_val_if_fail( GTASK_IS_CONNECTION( conn ), FALSE );
00099     g_return_val_if_fail( gtask_connection_is_connected( conn ), FALSE );
00100 
00101     q_packet = (GTaskQueryPacket *) packet;
00102 
00103     doc = xmlNewDoc( "1.0" );
00104 
00105     if( !doc )
00106         return FALSE;
00107 
00108     watch_node = xmlNewNode( NULL, "query" );
00109 
00110     if( !watch_node ) {
00111         xmlFreeDoc( doc );
00112 
00113         return FALSE;
00114     }
00115 
00116     xmlDocSetRootElement( doc, watch_node );
00117 
00118     xml_output = gtask_connection_get_xml_output_buffer( conn );
00119     xmlNodeDumpOutput( xml_output, doc, watch_node, 1, 0, NULL );
00120     xmlOutputBufferFlush( xml_output );
00121 
00122     xmlFreeDoc( doc );
00123 
00124     return TRUE;
00125 }
00126 
00134 GTaskQueryPacket *
00135 gtask_query_packet_new( ) {
00136     return g_object_new( GTASK_QUERY_PACKET_TYPE, NULL );
00137 }
00138 
00139 /* @} */

Generated on Mon Feb 2 21:26:14 2004 for libgtask by doxygen 1.3.4