15
15
vm.mount_changed.connect(mount_changed);
16
16
vm.mount_pre_unmount.connect(mount_pre_unmount);
17
17
vm.mount_removed.connect(mount_removed);
18
vm.volume_added.connect(volume_added);
19
vm.volume_changed.connect(volume_changed);
20
vm.volume_removed.connect(volume_removed);
19
/*vmVfs = GnomeVFS.get_volume_monitor();
20
vmVfs.volume_mounted.connect(gvfs_mounted);
21
vmVfs.drive_connected.connect( () => { stdout.printf("drive connected\n"); });
22
vmVfs.drive_disconnected.connect( () => { stdout.printf("drive disconnected\n"); });
23
vmVfs.volume_unmounted.connect(gvfs_unmounted);
25
var monitor = File.new_for_path("/home/scott/.gvfs").monitor_directory(FileMonitorFlags.NONE);
27
monitor.changed.connect( () => { stdout.printf("changed\n"); });
30
GUdev.Client client = new GUdev.Client({"usb", null});
31
client.uevent.connect(uevent_cb);*/
34
/*public void uevent_cb(string action, GUdev.Device device) {
35
stdout.printf("action; %s\n", action);
36
stdout.printf("device: %s\n", device.get_device_file());
23
39
public void loadPreExistingMounts() {
25
41
// this can take time if we have to rev up the cd drive
69
public void add_mount(string path) {
70
stdout.printf("added mount %s\n", path);
52
73
public virtual void mount_added (Mount mount) {
74
stdout.printf("mount added at %s\n", mount.get_default_location().get_path());
53
75
foreach(var dev in devices) {
54
if(dev.getMountLocation() == mount.get_default_location().get_parse_name()) {
76
if(dev.get_path() == mount.get_default_location().get_path()) {
59
/*stdout.printf("mount_added: %s\n", mount.get_name());
60
stdout.printf(" parse_name: %s\n uri: %s\n nice_name: %s\n unix_device: %s\n test: %s\n",
61
mount.get_default_location().get_parse_name(),
62
mount.get_default_location().get_uri(),
63
mount.get_volume().get_identifier(VOLUME_IDENTIFIER_KIND_LABEL),
64
mount.get_volume().get_identifier(VOLUME_IDENTIFIER_KIND_UNIX_DEVICE),
65
new UnixMountEntry(mount.get_default_location().get_path(), 0).get_device_path());*/
66
var device = new Device(mount);
68
//stdout.printf("mount preview icon: %s\n", mount.get_default_location().query_info("*", FileQueryInfoFlags.NONE).get_attribute_string(FILE_ATTRIBUTE_PREVIEW_ICON));
70
if(device.getContentType() == "cdrom" || device.getContentType().contains("ipod")
71
|| device.getContentType() == "android") {
82
if(mount.get_default_location().get_path().has_prefix("cdda://")) {
83
added = new CDRomDevice(mount);
85
else if(File.new_for_path(mount.get_default_location().get_path() + "/iTunes_Control").query_exists() ||
86
File.new_for_path(mount.get_default_location().get_path() + "/iPod_Control").query_exists() ||
87
File.new_for_path(mount.get_default_location().get_path() + "/iTunes/iTunes_Control").query_exists()) {
88
added = new iPodDevice(mount);
90
else if(mount.get_default_location().get_parse_name().has_prefix("afc://")) {
91
added = new iPodDevice(mount);
93
else if(File.new_for_path(mount.get_default_location().get_path() + "/Android").query_exists()) {
94
added = new AndroidDevice(mount);
96
else { // not a music player, ignore it
101
stdout.printf("added is null. initialization failed, meaning it is invalid. not using it\n");
105
added.set_mount(mount);
110
if(!added.initialize()) {
111
mount_removed(added.get_mount());
86
124
stdout.printf("mount_removed: %s\n", mount.get_default_location().get_parse_name());
88
126
foreach(var dev in devices) {
89
if(dev.getMountLocation() == mount.get_default_location().get_parse_name()) {
127
stdout.printf("comparing %s to %s\n", dev.get_path(), mount.get_default_location().get_path());
128
if(dev.get_path() == mount.get_default_location().get_path()) {
129
stdout.printf("removed %s\n", mount.get_default_location().get_path());
90
130
devices.remove(dev);
91
131
device_removed(dev);
98
public void mountedCallback(Object? source_object, AsyncResult res) {
99
//stdout.printf("mounted %s!\n", (string)current.get_mount().guess_content_type_sync(true, null));
102
public virtual void volume_added (Volume volume) {
103
//Device d = new Device(volume);
105
//stdout.printf("volume added: %s, %s\n", volume.get_name(), volume.get_mount().guess_content_type_sync(true, null));
107
//Timeout.add(5000, () => { stdout.printf("volume added: %s\n", volume.get_mount().guess_content_type_sync(true, null)); return false; } );
110
public virtual void volume_changed (Volume volume) {
111
//stdout.printf("volume changed: %s %s\n", volume.get_name(), volume.get_mount().guess_content_type_sync(true, null));
113
//Timeout.add(5000, () => { stdout.printf("volume changed: %s\n", volume.get_mount().guess_content_type_sync(true, null)); return false; } );
116
public virtual void volume_removed (Volume volume) {
117
//stdout.printf("volume removed: %s, %S\n", volume.get_name(), volume.get_mount().guess_content_type_sync(true, null));
119
//Timeout.add(5000, () => { stdout.printf("volume removed: %s\n", volume.get_mount().guess_content_type_sync(true, null)); return false; } );
138
public void gvfs_mounted(GnomeVFS.Volume volume) {
139
stdout.printf("gvfs mounted\n");
142
public void gvfs_unmounted(GnomeVFS.Volume volume) {
143
stdout.printf("gvfs unmounted\n");