Search
lxdream.org :: lxdream/src/vmu/vmulist.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/vmu/vmulist.h
changeset 1035:e3093fd7d1da
prev1034:7044e01148f0
author nkeynes
date Wed Jun 24 05:10:25 2009 +0000 (13 years ago)
permissions -rw-r--r--
last change Set svn:keywords property on new files
file annotate diff log raw
nkeynes@1034
     1
/**
nkeynes@1035
     2
 * $Id$
nkeynes@1034
     3
 *
nkeynes@1034
     4
 * VMU management - maintains a list of all known VMUs
nkeynes@1034
     5
 *
nkeynes@1034
     6
 * Copyright (c) 2009 Nathan Keynes.
nkeynes@1034
     7
 *
nkeynes@1034
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@1034
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@1034
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@1034
    11
 * (at your option) any later version.
nkeynes@1034
    12
 *
nkeynes@1034
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@1034
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@1034
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@1034
    16
 * GNU General Public License for more details.
nkeynes@1034
    17
 */
nkeynes@1034
    18
nkeynes@1034
    19
nkeynes@1034
    20
#ifndef lxdream_vmulist_H
nkeynes@1034
    21
#define lxdream_vmulist_H 1
nkeynes@1034
    22
nkeynes@1034
    23
#ifdef __cplusplus
nkeynes@1034
    24
extern "C" {
nkeynes@1034
    25
#endif
nkeynes@1034
    26
nkeynes@1034
    27
#include "hook.h"
nkeynes@1034
    28
#include "vmu/vmuvol.h"
nkeynes@1034
    29
nkeynes@1034
    30
typedef enum { VMU_ADDED, VMU_MODIFIED, VMU_REMOVED } vmulist_change_type_t;
nkeynes@1034
    31
    
nkeynes@1034
    32
/* Hook for notification of list change events */
nkeynes@1034
    33
typedef gboolean (*vmulist_change_hook_t)(vmulist_change_type_t change, int rowidx, void *user_data);
nkeynes@1034
    34
DECLARE_HOOK(vmulist_change_hook, vmulist_change_hook_t);
nkeynes@1034
    35
nkeynes@1034
    36
vmu_volume_t vmulist_get_vmu(unsigned int index);
nkeynes@1034
    37
nkeynes@1034
    38
/** Retrieve a known vmu by name */
nkeynes@1034
    39
vmu_volume_t vmulist_get_vmu_by_name(const gchar *name);
nkeynes@1034
    40
nkeynes@1034
    41
/** Retrieve a vmu by filename. The filename/vmu will be added to the list if it's
nkeynes@1034
    42
 * not already in it.
nkeynes@1034
    43
 */
nkeynes@1034
    44
vmu_volume_t vmulist_get_vmu_by_filename(const gchar *name);
nkeynes@1034
    45
nkeynes@1034
    46
const char *vmulist_get_name(unsigned int index);
nkeynes@1034
    47
nkeynes@1034
    48
const char *vmulist_get_filename(unsigned int index);
nkeynes@1034
    49
nkeynes@1034
    50
const char *vmulist_get_volume_name( vmu_volume_t vol );
nkeynes@1034
    51
nkeynes@1034
    52
nkeynes@1034
    53
nkeynes@1034
    54
/** Mark a VMU as being attached.
nkeynes@1034
    55
 * @return FALSE if the VMU was already attached, otherwise TRUE
nkeynes@1034
    56
 */
nkeynes@1034
    57
gboolean vmulist_attach_vmu( vmu_volume_t vol, const gchar *where );
nkeynes@1034
    58
nkeynes@1034
    59
/** Mark a VMU as detached. */
nkeynes@1034
    60
void vmulist_detach_vmu( vmu_volume_t vol );
nkeynes@1034
    61
nkeynes@1034
    62
/** 
nkeynes@1034
    63
 * Create a new VMU at the given filename, and add it to the list 
nkeynes@1034
    64
 * @param filename to save the new VMU as
nkeynes@1034
    65
 * @param create_only if TRUE, the file must not already exist. If FALSE,
nkeynes@1034
    66
 *   the create will overwrite any existing file at that filename.
nkeynes@1034
    67
 * @return index of the VMU in the list, or -1 if the call failed.
nkeynes@1034
    68
 **/
nkeynes@1034
    69
int vmulist_create_vmu(const gchar *filename, gboolean create_only);
nkeynes@1034
    70
nkeynes@1034
    71
/** Add a VMU volume to the list. Returns the index of the added volume */
nkeynes@1034
    72
int vmulist_add_vmu(const gchar *filename, vmu_volume_t vol);
nkeynes@1034
    73
nkeynes@1034
    74
int vmulist_get_index_by_filename( const gchar *name );
nkeynes@1034
    75
nkeynes@1034
    76
/** Remove a VMU volume from the list */
nkeynes@1034
    77
void vmulist_remove_vmu(vmu_volume_t vol);
nkeynes@1034
    78
nkeynes@1034
    79
/** Initialize the list */
nkeynes@1034
    80
void vmulist_init(void);
nkeynes@1034
    81
nkeynes@1034
    82
/** Save all VMUs in the list (actually only ones which have been written to
nkeynes@1034
    83
 * some point)
nkeynes@1034
    84
 **/
nkeynes@1034
    85
void vmulist_save_all(void);
nkeynes@1034
    86
nkeynes@1034
    87
void vmulist_shutdown(void);
nkeynes@1034
    88
nkeynes@1034
    89
unsigned int vmulist_get_size(void);
nkeynes@1034
    90
nkeynes@1034
    91
#ifdef __cplusplus
nkeynes@1034
    92
}
nkeynes@1034
    93
#endif
nkeynes@1034
    94
nkeynes@1034
    95
#endif /* !lxdream_vmulist_H */
.