1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2007-2010 David Zeuthen <zeuthen@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "config.h"
#include <glib/gi18n-lib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "udisksbasejob.h"
#include "udiskssimplejob.h"
#include "udisks-daemon-marshal.h"
/**
* SECTION:udiskssimplejob
* @title: UDisksSimpleJob
* @short_description: A simple job
*
* This type provides an implementation of the #UDisksJob interface
* for simple jobs.
*/
typedef struct _UDisksSimpleJobClass UDisksSimpleJobClass;
/**
* UDisksSimpleJob:
*
* The #UDisksSimpleJob structure contains only private data and should
* only be accessed using the provided API.
*/
struct _UDisksSimpleJob
{
UDisksBaseJob parent_instance;
};
struct _UDisksSimpleJobClass
{
UDisksBaseJobClass parent_class;
};
static void job_iface_init (UDisksJobIface *iface);
G_DEFINE_TYPE_WITH_CODE (UDisksSimpleJob, udisks_simple_job, UDISKS_TYPE_BASE_JOB,
G_IMPLEMENT_INTERFACE (UDISKS_TYPE_JOB, job_iface_init));
/* ---------------------------------------------------------------------------------------------------- */
static void
udisks_simple_job_init (UDisksSimpleJob *job)
{
}
static void
udisks_simple_job_class_init (UDisksSimpleJobClass *klass)
{
}
/**
* udisks_simple_job_new:
* @cancellable: A #GCancellable or %NULL.
*
* Creates a new #UDisksSimpleJob instance.
*
* Call udisks_simple_job_complete() to compelte the returned job.
*
* Returns: A new #UDisksSimpleJob. Free with g_object_unref().
*/
UDisksSimpleJob *
udisks_simple_job_new (GCancellable *cancellable)
{
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
return UDISKS_SIMPLE_JOB (g_object_new (UDISKS_TYPE_SIMPLE_JOB,
"cancellable", cancellable,
NULL));
}
/**
* udisks_simple_job_complete:
* @job: A #UDisksSimpleJob.
* @succeess: Whether the job succeeded.
* @message: An error message or %NULL.
*
* Completes @job.
*/
void
udisks_simple_job_complete (UDisksSimpleJob *job,
gboolean success,
const gchar *message)
{
g_return_if_fail (UDISKS_IS_SIMPLE_JOB (job));
udisks_job_emit_completed (UDISKS_JOB (job), success, message);
}
/* ---------------------------------------------------------------------------------------------------- */
static void
job_iface_init (UDisksJobIface *iface)
{
/* For Cancel(), just use the implementation from our super class (UDisksBaseJob) */
/* iface->handle_cancel = handle_cancel; */
}
|