4 * VMU management - maintains a list of all known VMUs
6 * Copyright (c) 2009 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
20 #ifndef lxdream_vmulist_H
21 #define lxdream_vmulist_H 1
28 #include "vmu/vmuvol.h"
30 typedef enum { VMU_ADDED, VMU_MODIFIED, VMU_REMOVED } vmulist_change_type_t;
32 /* Hook for notification of list change events */
33 typedef gboolean (*vmulist_change_hook_t)(vmulist_change_type_t change, int rowidx, void *user_data);
34 DECLARE_HOOK(vmulist_change_hook, vmulist_change_hook_t);
36 vmu_volume_t vmulist_get_vmu(unsigned int index);
38 /** Retrieve a known vmu by name */
39 vmu_volume_t vmulist_get_vmu_by_name(const gchar *name);
41 /** Retrieve a vmu by filename. The filename/vmu will be added to the list if it's
44 vmu_volume_t vmulist_get_vmu_by_filename(const gchar *name);
46 const char *vmulist_get_name(unsigned int index);
48 const char *vmulist_get_filename(unsigned int index);
50 const char *vmulist_get_volume_name( vmu_volume_t vol );
54 /** Mark a VMU as being attached.
55 * @return FALSE if the VMU was already attached, otherwise TRUE
57 gboolean vmulist_attach_vmu( vmu_volume_t vol, const gchar *where );
59 /** Mark a VMU as detached. */
60 void vmulist_detach_vmu( vmu_volume_t vol );
63 * Create a new VMU at the given filename, and add it to the list
64 * @param filename to save the new VMU as
65 * @param create_only if TRUE, the file must not already exist. If FALSE,
66 * the create will overwrite any existing file at that filename.
67 * @return index of the VMU in the list, or -1 if the call failed.
69 int vmulist_create_vmu(const gchar *filename, gboolean create_only);
71 /** Add a VMU volume to the list. Returns the index of the added volume */
72 int vmulist_add_vmu(const gchar *filename, vmu_volume_t vol);
74 int vmulist_get_index_by_filename( const gchar *name );
76 /** Remove a VMU volume from the list */
77 void vmulist_remove_vmu(vmu_volume_t vol);
79 /** Initialize the list */
80 void vmulist_init(void);
82 /** Save all VMUs in the list (actually only ones which have been written to
85 void vmulist_save_all(void);
87 void vmulist_shutdown(void);
89 unsigned int vmulist_get_size(void);
95 #endif /* !lxdream_vmulist_H */
.