1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007 Imendio AB
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
23 #include "giggle-job.h"
25 typedef struct GiggleJobPriv GiggleJobPriv
;
27 struct GiggleJobPriv
{
31 static void job_finalize (GObject
*object
);
32 static void job_set_property (GObject
*object
,
36 static void job_get_property (GObject
*object
,
41 G_DEFINE_ABSTRACT_TYPE (GiggleJob
, giggle_job
, G_TYPE_OBJECT
)
48 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIGGLE_TYPE_JOB, GiggleJobPriv))
51 giggle_job_class_init (GiggleJobClass
*class)
53 GObjectClass
*object_class
= G_OBJECT_CLASS (class);
55 object_class
->finalize
= job_finalize
;
56 object_class
->get_property
= job_get_property
;
57 object_class
->set_property
= job_set_property
;
59 g_object_class_install_property (object_class
,
61 g_param_spec_uint ("id",
63 "A unique identifier for the job.",
68 g_type_class_add_private (object_class
, sizeof (GiggleJobPriv
));
72 giggle_job_init (GiggleJob
*job
)
76 priv
= GET_PRIV (job
);
82 job_finalize (GObject
*object
)
84 /* FIXME: Free object data */
86 G_OBJECT_CLASS (giggle_job_parent_class
)->finalize (object
);
90 job_get_property (GObject
*object
,
97 priv
= GET_PRIV (object
);
101 g_value_set_uint (value
, priv
->id
);
104 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, param_id
, pspec
);
110 job_set_property (GObject
*object
,
117 priv
= GET_PRIV (object
);
121 priv
->id
= g_value_get_uint (value
);
124 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, param_id
, pspec
);
130 giggle_job_get_command_line (GiggleJob
*job
, gchar
**command_line
)
132 GiggleJobClass
*klass
;
134 g_return_val_if_fail (GIGGLE_IS_JOB (job
), FALSE
);
135 g_return_val_if_fail (command_line
!= NULL
, FALSE
);
137 klass
= GIGGLE_JOB_GET_CLASS (job
);
138 if (klass
->get_command_line
) {
139 return klass
->get_command_line (job
, command_line
);
142 *command_line
= NULL
;
147 giggle_job_handle_output (GiggleJob
*job
,
148 const gchar
*output_str
,
151 GiggleJobClass
*klass
;
153 g_return_if_fail (GIGGLE_IS_JOB (job
));
155 klass
= GIGGLE_JOB_GET_CLASS (job
);
156 if (klass
->handle_output
) {
157 klass
->handle_output (job
, output_str
, output_len
);