diff -r 8d3b1ddf789c -r 8b50be3e2998 app-manager/localmedia.c --- a/app-manager/localmedia.c Sat Feb 20 12:11:02 2010 +0000 +++ b/app-manager/localmedia.c Fri Apr 30 20:37:08 2010 +0100 @@ -19,10 +19,14 @@ #include "config.h" #include #include +#ifdef WIN32 +#include +#endif #include #include #include #include +#include "app-manager.h" #include "localmedia.h" G_DEFINE_TYPE(PloverLocalMediaStore,plover_local_media_store, @@ -56,12 +60,37 @@ { GFile *root; gchar *path; +#ifdef WIN32 + gunichar2 *path2; + UINT type; +#endif PloverPackageSet *set; root=g_mount_get_root(mount); path=g_file_get_path(root); +#ifdef WIN32 if (path) { - set=plover_package_set_new_from_repository(path,NULL); + path2=g_utf8_to_utf16(path,-1,NULL,NULL,NULL); + if (path2) + { + type=GetDriveTypeW(path2); + g_free(path2); + } + else + type=DRIVE_UNKNOWN; + if (type!=DRIVE_REMOVABLE && type!=DRIVE_CDROM) + { + gchar *name=g_mount_get_name(mount); + g_debug("Skipping non-local mount \"%s\"",name); + g_free(name); + g_free(path); + path=NULL; + } + } +#endif + if (path) + { + set=plover_package_set_new_from_repository(path,relocations,NULL); if (set) { g_object_set_data(G_OBJECT(mount),"plover-local-media-set",set); @@ -94,25 +123,38 @@ { GVolume *volume; GMount *mount; - GList *volumes,*link; - if (g_drive_has_media(drive)) + GList *volumes,*mounts,*link; + if (!drive) + volumes=g_volume_monitor_get_volumes(store->monitor); + else if (g_drive_has_media(drive)) + volumes=g_drive_get_volumes(drive); + else + volumes=NULL; + for(link=volumes;link;link=link->next) { - volumes=g_drive_get_volumes(drive); - for(link=volumes;link;link=link->next) + volume=G_VOLUME(link->data); + mount=g_volume_get_mount(volume); + if (mount) { - volume=G_VOLUME(link->data); - mount=g_volume_get_mount(volume); - if (mount) - { - local_media_scan_mount(store,mount); - g_object_unref(mount); - } - else if (!store->implicit_scan && g_volume_can_mount(volume)) - g_volume_mount(volume,G_MOUNT_MOUNT_NONE,NULL,NULL, - local_media_mounted,store); - g_object_unref(volume); + local_media_scan_mount(store,mount); + g_object_unref(mount); } - g_list_free(volumes); + else if (!store->implicit_scan && g_volume_can_mount(volume)) + g_volume_mount(volume,G_MOUNT_MOUNT_NONE,NULL,NULL, + local_media_mounted,store); + g_object_unref(volume); + } + g_list_free(volumes); + if (!drive) + { + mounts=g_volume_monitor_get_mounts(store->monitor); + for(link=mounts;link;link=link->next) + { + mount=G_MOUNT(link->data); + local_media_scan_mount(store,mount); + g_object_unref(mount); + } + g_list_free(mounts); } } @@ -127,9 +169,15 @@ void plover_local_media_store_scan(PloverLocalMediaStore *store) { - GList *drives,*link; + GList *sets,*drives,*link; GDrive *drive; g_return_if_fail(PLOVER_IS_LOCAL_MEDIA_STORE(store)); + sets= + g_slist_copy(plover_package_store_get_sets(PLOVER_PACKAGE_STORE(store))); + for(link=sets;link;link=link->next) + plover_package_store_remove_set(PLOVER_PACKAGE_STORE(store), + PLOVER_PACKAGE_SET(link->data)); + g_slist_free(sets); drives=g_volume_monitor_get_connected_drives(store->monitor); for(link=drives;link;link=link->next) { @@ -149,6 +197,7 @@ g_object_unref(drive); } g_list_free(drives); + local_media_scan_drive(store,NULL); } static void local_media_mount_added(GVolumeMonitor *volume_monitor,