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

gtask-task-packet.c

Go to the documentation of this file.
00001 #include <gtask/gtask-task-packet.h>
00002 
00005 /* @{ */
00006 
00007 static gpointer parent_class;
00008 
00009 static void
00010 gtask_task_packet_class_init( GTaskTaskPacketClass *klass );
00011 
00012 static void
00013 gtask_task_packet_init( GTaskTaskPacket *packet, gpointer g_class );
00014 
00015 static void
00016 gtask_task_packet_dispose( GObject *obj );
00017 
00018 static void
00019 gtask_task_packet_finalize( GObject *obj );
00020 
00021 static gboolean
00022 gtask_task_packet_serialize_to( GTaskPacket     *packet,
00023                                 GTaskConnection *conn );
00024 
00025 GType gtask_task_packet_get_type( void ) {
00026     static GType type = 0;
00027 
00028     if( type == 0 ) {
00029         static const GTypeInfo info = {
00030             sizeof( GTaskTaskPacketClass ),
00031             NULL,   /* base_init */
00032             NULL,   /* base_finalize */
00033             (GClassInitFunc) gtask_task_packet_class_init,   /* class_init */
00034             NULL,   /* class_finalize */
00035             NULL,   /* class_data */
00036             sizeof( GTaskTaskPacket ),
00037             0,      /* n_preallocs */
00038             (GInstanceInitFunc) gtask_task_packet_init
00039         };
00040 
00041         type = g_type_register_static( GTASK_PACKET_TYPE,
00042                                        "GTaskTaskPacket",
00043                                        &info,
00044                                        0 );
00045     }
00046 
00047     return type;
00048 }
00049 
00050 static void
00051 gtask_task_packet_class_init( GTaskTaskPacketClass *klass ) {
00052     GObjectClass     *gobject_class = G_OBJECT_CLASS( klass );
00053     GTaskPacketClass *packet_class = GTASK_PACKET_CLASS( klass );
00054 
00055     parent_class = g_type_class_peek_parent( klass );
00056 
00057     gobject_class->dispose = gtask_task_packet_dispose;
00058     gobject_class->finalize = gtask_task_packet_finalize;
00059 
00060     packet_class->serialize_packet = gtask_task_packet_serialize_to;
00061 }
00062 
00063 static void
00064 gtask_task_packet_init( GTaskTaskPacket *packet, gpointer g_class ) {
00065     GTaskTaskPacketPrivate *private = g_new0( GTaskTaskPacketPrivate, 1 );
00066 
00067     packet->private = private;
00068     private->task = NULL;
00069     private->dispose_has_run = FALSE;
00070 }
00071 
00073 static void
00074 gtask_task_packet_dispose( GObject *obj ) {
00075     GTaskTaskPacket        *packet = GTASK_TASK_PACKET( obj );
00076     GTaskTaskPacketPrivate *private = packet->private;
00077 
00078     if( packet->private->dispose_has_run )
00079         return;
00080 
00081     if( private->task ) {
00082         g_object_unref( private->task );
00083 
00084         private->task = NULL;
00085     }
00086 
00087     packet->private->dispose_has_run = TRUE;
00088 
00089     if( G_OBJECT_CLASS( parent_class )->dispose )
00090         G_OBJECT_CLASS( parent_class )->dispose( obj );
00091 }
00092 
00093 static void
00094 gtask_task_packet_finalize( GObject *obj ) {
00095     GTaskTaskPacket *packet = GTASK_TASK_PACKET( obj );
00096 
00097     g_free( packet->private );
00098 
00099     if( G_OBJECT_CLASS( parent_class )->finalize )
00100         G_OBJECT_CLASS( parent_class )->finalize( obj );
00101 }
00102 
00117 static gboolean
00118 gtask_task_packet_serialize_to( GTaskPacket     *packet,
00119                                 GTaskConnection *conn )
00120 {
00121     g_return_val_if_fail( GTASK_IS_TASK_PACKET( packet ), FALSE );
00122 
00123     return gtask_generic_task_serialize_to( ((GTaskTaskPacket *) packet)->private->task, conn );
00124 }
00125 
00137 GTaskTaskPacket *
00138 gtask_task_packet_new_with_task( GTaskGenericTask *task ) {
00139     GTaskTaskPacket *packet;
00140 
00141     packet = g_object_new( GTASK_TASK_PACKET_TYPE, NULL );
00142 
00143     packet->private->task = task;
00144 
00145     g_object_ref( task );
00146 
00147     return packet;
00148 }
00149 
00162 GTaskGenericTask *
00163 gtask_task_packet_get_task( GTaskTaskPacket *packet ) {
00164     g_return_val_if_fail( GTASK_IS_TASK_PACKET( packet ), NULL );
00165     g_return_val_if_fail( !packet->private->dispose_has_run, NULL );
00166 
00167     return packet->private->task;
00168 }
00169 
00170 /* @} */

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