1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2  *
3  * Copyright (C) 2020 Tomas Bzatek <tbzatek@redhat.com>
4  *
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.
9  *
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.
14  *
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
18  *
19  */
20 
21 #ifndef __UDISKS_MODULE_H__
22 #define __UDISKS_MODULE_H__
23 
24 #include <glib-object.h>
25 #include <gio/gio.h>
26 
27 #include "udisksdaemontypes.h"
28 
29 G_BEGIN_DECLS
30 
31 #define UDISKS_TYPE_MODULE              (udisks_module_get_type ())
32 #define UDISKS_MODULE(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), UDISKS_TYPE_MODULE, UDisksModule))
33 #define UDISKS_MODULE_CLASS(k)          (G_TYPE_CHECK_CLASS_CAST((k), UDISKS_TYPE_MODULE, UDisksModuleClass))
34 #define UDISKS_MODULE_GET_CLASS(o)      (G_TYPE_INSTANCE_GET_CLASS ((o), UDISKS_TYPE_MODULE, UDisksModuleClass))
35 #define UDISKS_IS_MODULE(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UDISKS_TYPE_MODULE))
36 #define UDISKS_IS_MODULE_CLASS(k)       (G_TYPE_CHECK_CLASS_TYPE ((k), UDISKS_TYPE_MODULE))
37 
38 typedef struct _UDisksModule UDisksModule;
39 typedef struct _UDisksModuleClass UDisksModuleClass;
40 
41 /**
42  * UDisksModule:
43  *
44  * The #UDisksModule structure contains only private data and
45  * should only be accessed using the provided API.
46  */
47 struct _UDisksModule
48 {
49   /*< private >*/
50   GObject parent_instance;
51 
52   UDisksDaemon *daemon;
53   gchar        *name;
54 };
55 
56 /**
57  * UDisksModuleIDFunc:
58  *
59  * Function prototype that is called by #UDisksModuleManager to get
60  * unique module identifier. No initialization is supposed to be done
61  * at this point.
62  *
63  * Returns: (transfer full): The module ID string. Free with g_free().
64  *
65  * Since: 2.0
66  */
67 typedef gchar *(*UDisksModuleIDFunc) (void);
68 
69 /**
70  * UDisksModuleNewFunc:
71  * @daemon: A #UDisksDaemon instance.
72  * @cancellable: (nullable): A #GCancellable or %NULL
73  * @error: Return location for error or %NULL.
74  *
75  * Function prototype that creates a new #UDisksModule instance. Module
76  * initialization is done at this point. This is a failable method call
77  * that properly reports module initialization failure.
78  *
79  * Returns: (transfer full): A #UDisksModule object or %NULL if @error is set.
80  *                           Free with g_object_unref().
81  *
82  * Since: 2.9
83  */
84 typedef UDisksModule* (*UDisksModuleNewFunc) (UDisksDaemon  *daemon,
85                                               GCancellable  *cancellable,
86                                               GError       **error);
87 /**
88  * UDisksModuleClass:
89  * @parent_class: The parent class.
90  * @new_manager: Virtual function for udisks_module_new_manager(). The default implementation returns %NULL.
91  * @new_object: Virtual function for udisks_module_new_object(). The default implementation returns %NULL.
92  * @track_parent: Virtual function for udisks_module_track_parent(). The default implementation returns %NULL.
93  * @get_block_object_interface_types: Virtual function for udisks_module_get_block_object_interface_types(). The default implementation returns %NULL.
94  * @get_drive_object_interface_types: Virtual function for udisks_module_get_drive_object_interface_types(). The default implementation returns %NULL.
95  * @new_block_object_interface: Virtual function for udisks_module_new_block_object_interface(). The default implementation returns %NULL.
96  * @new_drive_object_interface: Virtual function for udisks_module_new_drive_object_interface(). The default implementation returns %NULL.
97  *
98  * Class structure for #UDisksModule.
99  */
100 struct _UDisksModuleClass
101 {
102   GObjectClass parent_class;
103 
104   GDBusInterfaceSkeleton  * (*new_manager)                      (UDisksModule           *module);
105   GDBusObjectSkeleton    ** (*new_object)                       (UDisksModule           *module,
106                                                                  UDisksLinuxDevice      *device);
107   gchar                   * (*track_parent)                     (UDisksModule           *module,
108                                                                  const gchar            *path,
109                                                                  gchar                 **uuid);
110   GType                   * (*get_block_object_interface_types) (UDisksModule           *module);
111   GType                   * (*get_drive_object_interface_types) (UDisksModule           *module);
112   GDBusInterfaceSkeleton  * (*new_block_object_interface)       (UDisksModule           *module,
113                                                                  UDisksLinuxBlockObject *object,
114                                                                  GType                   interface_type);
115   GDBusInterfaceSkeleton  * (*new_drive_object_interface)       (UDisksModule           *module,
116                                                                  UDisksLinuxDriveObject *object,
117                                                                  GType                   interface_type);
118 };
119 
120 
121 
122 GType                    udisks_module_get_type                         (void) G_GNUC_CONST;
123 
124 const gchar             *udisks_module_get_name                         (UDisksModule           *module);
125 
126 UDisksDaemon            *udisks_module_get_daemon                       (UDisksModule           *module);
127 
128 GDBusInterfaceSkeleton  *udisks_module_new_manager                      (UDisksModule           *module);
129 GDBusObjectSkeleton    **udisks_module_new_object                       (UDisksModule           *module,
130                                                                          UDisksLinuxDevice      *device);
131 gchar                   *udisks_module_track_parent                     (UDisksModule           *module,
132                                                                          const gchar            *path,
133                                                                          gchar                 **uuid);
134 GType                   *udisks_module_get_block_object_interface_types (UDisksModule           *module);
135 GType                   *udisks_module_get_drive_object_interface_types (UDisksModule           *module);
136 GDBusInterfaceSkeleton  *udisks_module_new_block_object_interface       (UDisksModule           *module,
137                                                                          UDisksLinuxBlockObject *object,
138                                                                          GType                   interface_type);
139 GDBusInterfaceSkeleton  *udisks_module_new_drive_object_interface       (UDisksModule           *module,
140                                                                          UDisksLinuxDriveObject *object,
141                                                                          GType                   interface_type);
142 
143 
144 G_END_DECLS
145 
146 #endif /* __UDISKS_MODULE_H__ */
147