1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
3
* Copyright (C) 2008 David Zeuthen <zeuthen@gmail.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (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
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#include <glib/gi18n-lib.h>
29
#include <sys/types.h>
34
#include <glib-object.h>
36
#include "udiskscrypttabentry.h"
37
#include "udisksprivate.h"
40
* UDisksCrypttabEntry:
42
* The #UDisksCrypttabEntry structure contains only private data and should
43
* only be accessed using the provided API.
45
struct _UDisksCrypttabEntry
47
GObject parent_instance;
51
gchar *passphrase_path;
55
typedef struct _UDisksCrypttabEntryClass UDisksCrypttabEntryClass;
57
struct _UDisksCrypttabEntryClass
59
GObjectClass parent_class;
62
G_DEFINE_TYPE (UDisksCrypttabEntry, udisks_crypttab_entry, G_TYPE_OBJECT);
65
udisks_crypttab_entry_finalize (GObject *object)
67
UDisksCrypttabEntry *entry = UDISKS_CRYPTTAB_ENTRY (object);
70
g_free (entry->device);
71
g_free (entry->passphrase_path);
72
g_free (entry->options);
74
if (G_OBJECT_CLASS (udisks_crypttab_entry_parent_class)->finalize)
75
G_OBJECT_CLASS (udisks_crypttab_entry_parent_class)->finalize (object);
79
udisks_crypttab_entry_init (UDisksCrypttabEntry *crypttab_entry)
84
udisks_crypttab_entry_class_init (UDisksCrypttabEntryClass *klass)
86
GObjectClass *gobject_class;
88
gobject_class = G_OBJECT_CLASS (klass);
89
gobject_class->finalize = udisks_crypttab_entry_finalize;
93
_udisks_crypttab_entry_new (const gchar *name,
95
const gchar *passphrase_path,
98
UDisksCrypttabEntry *entry;
100
entry = UDISKS_CRYPTTAB_ENTRY (g_object_new (UDISKS_TYPE_CRYPTTAB_ENTRY, NULL));
101
entry->name = g_strdup (name);
102
entry->device = g_strdup (device);
103
entry->passphrase_path = g_strdup (passphrase_path);
104
entry->options = g_strdup (options);
110
* udisks_crypttab_entry_compare:
111
* @entry: A #UDisksCrypttabEntry
112
* @other_entry: Another #UDisksCrypttabEntry.
114
* Comparison function for comparing two #UDisksCrypttabEntry objects.
116
* Returns: Negative value if @entry < @other_entry; zero if @entry = @other_entry; positive value if @entry > @other_entry.
119
udisks_crypttab_entry_compare (UDisksCrypttabEntry *entry,
120
UDisksCrypttabEntry *other_entry)
124
g_return_val_if_fail (UDISKS_IS_CRYPTTAB_ENTRY (entry), 0);
125
g_return_val_if_fail (UDISKS_IS_CRYPTTAB_ENTRY (other_entry), 0);
127
ret = g_strcmp0 (other_entry->name, entry->name);
131
ret = g_strcmp0 (other_entry->device, entry->device);
135
ret = g_strcmp0 (other_entry->passphrase_path, entry->passphrase_path);
139
ret = g_strcmp0 (other_entry->options, entry->options);
146
* udisks_crypttab_entry_get_name:
147
* @entry: A #UDisksCrypttabEntry.
149
* Gets the name field of @entry.
151
* Returns: The name field.
154
udisks_crypttab_entry_get_name (UDisksCrypttabEntry *entry)
156
g_return_val_if_fail (UDISKS_IS_CRYPTTAB_ENTRY (entry), NULL);
161
* udisks_crypttab_entry_get_device:
162
* @entry: A #UDisksCrypttabEntry.
164
* Gets the device field of @entry.
166
* Returns: The device field.
169
udisks_crypttab_entry_get_device (UDisksCrypttabEntry *entry)
171
g_return_val_if_fail (UDISKS_IS_CRYPTTAB_ENTRY (entry), NULL);
172
return entry->device;
176
* udisks_crypttab_entry_get_passphrase_path:
177
* @entry: A #UDisksCrypttabEntry.
179
* Gets the passphrase path field of @entry.
181
* Returns: The passphrase path field.
184
udisks_crypttab_entry_get_passphrase_path (UDisksCrypttabEntry *entry)
186
g_return_val_if_fail (UDISKS_IS_CRYPTTAB_ENTRY (entry), NULL);
187
return entry->passphrase_path;
191
* udisks_crypttab_entry_get_options:
192
* @entry: A #UDisksCrypttabEntry.
194
* Gets the options field of @entry.
196
* Returns: The options field.
199
udisks_crypttab_entry_get_options (UDisksCrypttabEntry *entry)
201
g_return_val_if_fail (UDISKS_IS_CRYPTTAB_ENTRY (entry), NULL);
202
return entry->options;