Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:joshkress:PackageKit
hal
hal-cleanup-deprecated_libhal-storage.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File hal-cleanup-deprecated_libhal-storage.diff of Package hal
(volume); - else - size_str = NULL; - - if (vendor == NULL || strlen (vendor) == 0) { - if (model == NULL || strlen (model) == 0) - vendormodel_str = strdup (""); - else - vendormodel_str = strdup (model); - } else { - if (model == NULL || strlen (model) == 0) - vendormodel_str = strdup (vendor); - else { - snprintf (buf, MAX_STRING_SZ, "%s %s", vendor, model); - vendormodel_str = strdup (buf); - } - } - - fixup_string (vendormodel_str); - - if (drive_type==LIBHAL_DRIVE_TYPE_CDROM) { - - /* Optical drive handling */ - char *first; - char *second; - - - first = "CD-ROM"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_CDR) - first = "CD-R"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_CDRW) - first = "CD-RW"; - - second = ""; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDROM) - second = "/DVD-ROM"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSR) - second = "/DVD+R"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRW) - second = "/DVD+RW"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDR) - second = "/DVD-R"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDRW) - second = "/DVD-RW"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDRAM) - second = "/DVD-RAM"; - if ((drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDR) && - (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSR)) { - if(drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRDL) - second = "/DVD±R DL"; - else - second = "/DVD±R"; - } - if ((drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDRW) && - (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRW)) { - if(drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRDL || - drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRWDL) - second = "/DVD±RW DL"; - else - second = "/DVD±RW"; - } - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_BDROM) - second = "/BD-ROM"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_BDR) - second = "/BD-R"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_BDRE) - second = "/BD-RE"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_HDDVDROM) - second = "/HD DVD-ROM"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_HDDVDR) - second = "/HD DVD-R"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_HDDVDRW) - second = "/HD DVD-RW"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_MRW) - second = "/MRW"; - if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_MRWW) - second = "/MRW-W"; - - if (drive_is_hotpluggable) { - snprintf (buf, MAX_STRING_SZ, _("External %s%s Drive"), first, second); - name = strdup (buf); - } else { - snprintf (buf, MAX_STRING_SZ, _("%s%s Drive"), first, second); - name = strdup (buf); - } - - } else if (drive_type==LIBHAL_DRIVE_TYPE_MO) { - - if (drive_is_hotpluggable) - name = strdup (_("External Magneto Optical Drive")); - else - name = strdup (_("Magneto Optical Drive")); - } else if (drive_type==LIBHAL_DRIVE_TYPE_FLOPPY) { - - /* Floppy Drive handling */ - - if (drive_is_hotpluggable) - name = strdup (_("External Floppy Drive")); - else - name = strdup (_("Floppy Drive")); - } else if (drive_type==LIBHAL_DRIVE_TYPE_DISK && !drive_is_removable) { - - /* Harddisks */ - - if (size_str != NULL) { - if (drive_is_hotpluggable) { - snprintf (buf, MAX_STRING_SZ, _("%s External Hard Drive"), size_str); - name = strdup (buf); - } else { - snprintf (buf, MAX_STRING_SZ, _("%s Hard Drive"), size_str); - name = strdup (buf); - } - } else { - if (drive_is_hotpluggable) - name = strdup (_("External Hard Drive")); - else - name = strdup (_("Hard Drive")); - } - } else { - - /* The rest - includes drives with removable Media */ - - if (strlen (vendormodel_str) > 0) - name = strdup (vendormodel_str); - else - name = strdup (_("Drive")); - } - - free (vendormodel_str); - free (size_str); - - return name; -} - -char * -libhal_volume_policy_compute_display_name (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy) -{ - char *name; - char *size_str; - const char *volume_label; - const char *model; - const char *vendor; - LibHalDriveType drive_type; - dbus_bool_t drive_is_hotpluggable; - dbus_bool_t drive_is_removable; - LibHalDriveCdromCaps drive_cdrom_caps; - char buf[MAX_STRING_SZ]; - - volume_label = libhal_volume_get_label (volume); - model = libhal_drive_get_model (drive); - vendor = libhal_drive_get_vendor (drive); - drive_type = libhal_drive_get_type (drive); - drive_is_hotpluggable = libhal_drive_is_hotpluggable (drive); - drive_is_removable = libhal_drive_uses_removable_media (drive); - drive_cdrom_caps = libhal_drive_get_cdrom_caps (drive); - - size_str = libhal_volume_policy_compute_size_as_string (volume); - - /* If the volume label is available use that - * - * TODO: If label is a fully-qualified UNIX path don't use that - */ - if (volume_label != NULL) { - name = strdup (volume_label); - goto out; - } - - /* Handle media in optical drives */ - if (drive_type==LIBHAL_DRIVE_TYPE_CDROM) { - switch (libhal_volume_get_disc_type (volume)) { - - default: - /* explict fallthrough */ - case LIBHAL_VOLUME_DISC_TYPE_CDROM: - name = strdup (_("CD-ROM ")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_CDR: - if (libhal_volume_disc_is_blank (volume)) - name = strdup (_("Blank CD-R")); - else - name = strdup (_("CD-R")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_CDRW: - if (libhal_volume_disc_is_blank (volume)) - name = strdup (_("Blank CD-RW")); - else - name = strdup (_("CD-RW")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_DVDROM: - name = strdup (_("DVD-ROM")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_DVDRAM: - if (libhal_volume_disc_is_blank (volume)) - name = strdup (_("Blank DVD-RAM")); - else - name = strdup (_("DVD-RAM")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_DVDR: - if (libhal_volume_disc_is_blank (volume)) - name = strdup (_("Blank DVD-R")); - else - name = strdup (_("DVD-R")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_DVDRW: - if (libhal_volume_disc_is_blank (volume)) - name = strdup (_("Blank DVD-RW")); - else - name = strdup (_("DVD-RW")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR: - if (libhal_volume_disc_is_blank (volume)) - name = strdup (_("Blank DVD+R")); - else - name = strdup (_("DVD+R")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW: - if (libhal_volume_disc_is_blank (volume)) - name = strdup (_("Blank DVD+RW")); - else - name = strdup (_("DVD+RW")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR_DL: - if (libhal_volume_disc_is_blank (volume)) - name = strdup (_("Blank DVD+R Dual-Layer")); - else - name = strdup (_("DVD+R Dual-Layer")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_BDROM: - name = strdup (_("BD-ROM")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_BDR: - if (libhal_volume_disc_is_blank (volume)) - name = strdup (_("Blank BD-R")); - else - name = strdup (_("BD-R")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_BDRE: - if (libhal_volume_disc_is_blank (volume)) - name = strdup (_("Blank BD-RE")); - else - name = strdup (_("BD-RE")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_HDDVDROM: - name = strdup (_("HD DVD-ROM")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_HDDVDR: - if (libhal_volume_disc_is_blank (volume)) - name = strdup (_("Blank HD DVD-R")); - else - name = strdup (_("HD DVD-R")); - break; - - case LIBHAL_VOLUME_DISC_TYPE_HDDVDRW: - if (libhal_volume_disc_is_blank (volume)) - name = strdup (_("Blank HD DVD-RW")); - else - name = strdup (_("HD DVD-RW")); - break; - - } - - /* Special case for pure audio disc */ - if (libhal_volume_disc_has_audio (volume) && !libhal_volume_disc_has_data (volume)) { - free (name); - name = strdup (_("Audio CD")); - } - - goto out; - } else if (drive_type==LIBHAL_DRIVE_TYPE_MO) { - if (libhal_volume_get_disc_type (volume) == LIBHAL_VOLUME_DISC_TYPE_MO) { - if (libhal_volume_disc_is_blank (volume)) - name = strdup (_("Blank Magneto Optical")); - else - name = strdup (_("Magneto Optical")); - } - } - - /* Fallback: size of media */ - if (drive_is_removable) { - snprintf (buf, MAX_STRING_SZ, _("%s Removable Media"), size_str); - name = strdup (buf); - } else { - snprintf (buf, MAX_STRING_SZ, _("%s Media"), size_str); - name = strdup (buf); - } - - /* Fallback: Use drive name */ - /*name = libhal_drive_policy_compute_display_name (drive, volume);*/ - -out: - free (size_str); - return name; -} - -char * -libhal_drive_policy_compute_icon_name (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy) -{ - const char *name; - LibHalDriveBus bus; - LibHalDriveType drive_type; - - bus = libhal_drive_get_bus (drive); - drive_type = libhal_drive_get_type (drive); - - /* by design, the enums are laid out so we can do easy computations */ - - switch (drive_type) { - case LIBHAL_DRIVE_TYPE_REMOVABLE_DISK: - case LIBHAL_DRIVE_TYPE_DISK: - case LIBHAL_DRIVE_TYPE_CDROM: - case LIBHAL_DRIVE_TYPE_MO: - case LIBHAL_DRIVE_TYPE_FLOPPY: - name = libhal_storage_policy_lookup_icon (policy, 0x10000 + drive_type*0x100 + bus); - break; - - default: - name = libhal_storage_policy_lookup_icon (policy, 0x10000 + drive_type*0x100); - } - - if (name != NULL) - return strdup (name); - else - return NULL; -} - -char * -libhal_volume_policy_compute_icon_name (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy) -{ - const char *name; - LibHalDriveBus bus; - LibHalDriveType drive_type; - LibHalVolumeDiscType disc_type; - - /* by design, the enums are laid out so we can do easy computations */ - - if (libhal_volume_is_disc (volume)) { - disc_type = libhal_volume_get_disc_type (volume); - name = libhal_storage_policy_lookup_icon (policy, 0x30000 + disc_type); - goto out; - } - - if (drive == NULL) { - name = libhal_storage_policy_lookup_icon (policy, LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK); - goto out; - } - - bus = libhal_drive_get_bus (drive); - drive_type = libhal_drive_get_type (drive); - - switch (drive_type) { - case LIBHAL_DRIVE_TYPE_REMOVABLE_DISK: - case LIBHAL_DRIVE_TYPE_DISK: - case LIBHAL_DRIVE_TYPE_CDROM: - case LIBHAL_DRIVE_TYPE_MO: - case LIBHAL_DRIVE_TYPE_FLOPPY: - name = libhal_storage_policy_lookup_icon (policy, 0x20000 + drive_type*0x100 + bus); - break; - - default: - name = libhal_storage_policy_lookup_icon (policy, 0x20000 + drive_type*0x100); - } -out: - if (name != NULL) - return strdup (name); - else - return NULL; -} - -/** - * libhal_volume_policy_should_be_visible: - * @drive: Drive that the volume is stemming from - * @volume: Volume - * @policy: Policy object - * @target_mount_point: The mount point that the volume is expected to - * be mounted at if not already mounted. This may - * e.g. stem from /etc/fstab. If this is NULL the - * then mount point isn't taking into account when - * evaluating whether the volume should be visible - * Returns: Whether the volume should be shown in a desktop - * environment. - * Policy function to determine if a volume should be visible in a desktop - * environment. This is useful to hide certain system volumes as bootstrap - * partitions, the /usr partition, swap partitions and other volumes that - * a unprivileged desktop user shouldn't know even exists. - */ -dbus_bool_t -libhal_volume_policy_should_be_visible (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy, - const char *target_mount_point) -{ - unsigned int i; - dbus_bool_t is_visible; - const char *label; - const char *mount_point; - const char *fstype; - const char *fhs23_toplevel_mount_points[] = { - "/", - "/bin", - "/boot", - "/dev", - "/etc", - "/home", - "/lib", - "/lib64", - "/media", - "/mnt", - "/opt", - "/root", - "/sbin", - "/srv", - "/tmp", - "/usr", - "/var", - "/proc", - "/sbin", - NULL - }; - - is_visible = FALSE; - - /* skip if hal says it's not used as a filesystem */ - if (libhal_volume_get_fsusage (volume) != LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM) - goto out; - - label = libhal_volume_get_label (volume); - mount_point = libhal_volume_get_mount_point (volume); - fstype = libhal_volume_get_fstype (volume); - - /* use target mount point if we're not mounted yet */ - if (mount_point == NULL) - mount_point = target_mount_point; - - /* bail out if we don't know the filesystem */ - if (fstype == NULL) - goto out; - - /* blacklist fhs2.3 top level mount points */ - if (mount_point != NULL) { - for (i = 0; fhs23_toplevel_mount_points[i] != NULL; i++) { - if (strcmp (mount_point, fhs23_toplevel_mount_points[i]) == 0) - goto out; - } - } - - /* blacklist partitions with name 'bootstrap' of type HFS (Apple uses that) */ - if (label != NULL && strcmp (label, "bootstrap") == 0 && strcmp (fstype, "hfs") == 0) - goto out; - - /* only the real lucky mount points will make it this far :-) */ - is_visible = TRUE; - -out: - return is_visible; -} - /*************************************************************************/ #define MOUNT_OPTIONS_SIZE 256 @@ -723,10 +91,6 @@ struct LibHalDrive_s { char *firmware_version; LibHalDriveCdromCaps cdrom_caps; - char *desired_mount_point; - char *mount_filesystem; - dbus_bool_t should_mount; - dbus_bool_t no_partitions_hint; dbus_uint64_t drive_size; @@ -780,10 +144,6 @@ struct LibHalVolume_s { unsigned int block_size; unsigned int num_blocks; - char *desired_mount_point; - char *mount_filesystem; - dbus_bool_t should_mount; - dbus_bool_t ignore_volume; char *crypto_backing_volume; @@ -831,8 +191,6 @@ libhal_drive_free (LibHalDrive *drive) libhal_free_string (drive->dedicated_icon_volume); libhal_free_string (drive->serial); libhal_free_string (drive->firmware_version); - libhal_free_string (drive->desired_mount_point); - libhal_free_string (drive->mount_filesystem); libhal_free_string_array (drive->capabilities); libhal_free_string (drive->partition_scheme); @@ -859,8 +217,6 @@ libhal_volume_free (LibHalVolume *volume) libhal_free_string (volume->mount_point); libhal_free_string (volume->fsversion); libhal_free_string (volume->uuid); - libhal_free_string (volume->desired_mount_point); - libhal_free_string (volume->mount_filesystem); libhal_free_string (volume->crypto_backing_volume); libhal_free_string (volume->storage_device); @@ -1007,10 +363,6 @@ libhal_drive_from_udi (LibHalContext *hal_ctx, const char *udi) LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.mrw", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_MRW); LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.mrw_w", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_MRWW); - LIBHAL_PROP_EXTRACT_BOOL ("storage.policy.should_mount", drive->should_mount); - LIBHAL_PROP_EXTRACT_STRING ("storage.policy.desired_mount_point", drive->desired_mount_point); - LIBHAL_PROP_EXTRACT_STRING ("storage.policy.mount_filesystem", drive->mount_filesystem); - LIBHAL_PROP_EXTRACT_BOOL ("storage.no_partitions_hint", drive->no_partitions_hint); LIBHAL_PROP_EXTRACT_STRLIST ("info.capabilities", drive->capabilities); @@ -1207,10 +559,6 @@ libhal_volume_from_udi (LibHalContext *hal_ctx, const char *udi) LIBHAL_PROP_EXTRACT_BOOL ("volume.disc.is_rewritable", vol->disc_is_rewritable); LIBHAL_PROP_EXTRACT_UINT64 ("volume.disc.capacity", vol->disc_capacity); - LIBHAL_PROP_EXTRACT_BOOL ("volume.policy.should_mount", vol->should_mount); - LIBHAL_PROP_EXTRACT_STRING ("volume.policy.desired_mount_point", vol->desired_mount_point); - LIBHAL_PROP_EXTRACT_STRING ("volume.policy.mount_filesystem", vol->mount_filesystem); - LIBHAL_PROP_EXTRACT_END; } @@ -1285,57 +633,6 @@ error: } -/** - * libhal_volume_get_msdos_part_table_type: - * @volume: Volume object - * - * Returns: The partition type or -1 if volume is not - * a partition or the media the volume stems from - * isn't partition with a MS DOS style table - * - * If the volume is on a drive with a MSDOS style partition table, return - * the partition table id. - */ -int -libhal_volume_get_msdos_part_table_type (LibHalVolume *volume) -{ - return volume->msdos_part_table_type; -} - -/** - * libhal_volume_get_msdos_part_table_start: - * @volume: Volume object - * - * Returns: The partition start offset or -1 if volume isnt - * a partition or the media the volume stems from - * isn't partition with a MS DOS style table - * - * If the volume is on a drive with a MSDOS style partition table, return - * the partition start offset according to the partition table. - */ -dbus_uint64_t -libhal_volume_get_msdos_part_table_start (LibHalVolume *volume) -{ - return volume->msdos_part_table_start; -} - -/** - * libhal_volume_get_msdos_part_table_size: - * @volume: Volume object - * - * Returns: The partition size or -1 if volume is not - * a partition or the media the volume stems from - * isn't partition with a MS DOS style table - * - * If the volume is on a drive with a MSDOS style partition table, return - * the partition size according to the partition table. - */ -dbus_uint64_t -libhal_volume_get_msdos_part_table_size (LibHalVolume *volume) -{ - return volume->msdos_part_table_size; -} - /***********************************************************************/ /** @@ -1886,250 +1183,12 @@ libhal_volume_crypto_get_clear_volume_udi (LibHalContext *hal_ctx, LibHalVolume return result; } - -/*************************************************************************/ - -char * -libhal_drive_policy_default_get_mount_root (LibHalContext *hal_ctx) -{ - char *result; - DBusError error; - - LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL); - - dbus_error_init (&error); - if ((result = libhal_device_get_property_string (hal_ctx, "/org/freedesktop/Hal/devices/computer", - "storage.policy.default.mount_root", &error)) == NULL) - LIBHAL_FREE_DBUS_ERROR(&error); - - return result; -} - -dbus_bool_t -libhal_drive_policy_default_use_managed_keyword (LibHalContext *hal_ctx) -{ - dbus_bool_t result; - DBusError error; - - LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, FALSE); - - dbus_error_init (&error); - if ((result = libhal_device_get_property_bool (hal_ctx, "/org/freedesktop/Hal/devices/computer", - "storage.policy.default.use_managed_keyword", &error)) == FALSE) - LIBHAL_FREE_DBUS_ERROR(&error); - - return result; -} - -char * -libhal_drive_policy_default_get_managed_keyword_primary (LibHalContext *hal_ctx) -{ - char *result; - DBusError error; - - LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL); - - dbus_error_init (&error); - if ((result = libhal_device_get_property_string (hal_ctx, "/org/freedesktop/Hal/devices/computer", - "storage.policy.default.managed_keyword.primary", &error)) == NULL) - LIBHAL_FREE_DBUS_ERROR(&error); - - return result; -} - -char * -libhal_drive_policy_default_get_managed_keyword_secondary (LibHalContext *hal_ctx) -{ - char *result; - DBusError error; - - LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL); - - dbus_error_init (&error); - if ((result = libhal_device_get_property_string (hal_ctx, "/org/freedesktop/Hal/devices/computer", - "storage.policy.default.managed_keyword.secondary", &error)) == NULL) - LIBHAL_FREE_DBUS_ERROR(&error); - - return result; -} - -/*************************************************************************/ - -dbus_bool_t -libhal_drive_policy_is_mountable (LibHalDrive *drive, LibHalStoragePolicy *policy) -{ - printf ("should_mount=%d, no_partitions_hint=%d\n", drive->should_mount, drive->no_partitions_hint); - - return drive->should_mount && drive->no_partitions_hint; -} - -const char * -libhal_drive_policy_get_desired_mount_point (LibHalDrive *drive, LibHalStoragePolicy *policy) -{ - return drive->desired_mount_point; -} - /* safely strcat() at most the remaining space in 'dst' */ #define strcat_len(dst, src, dstmaxlen) do { \ dst[dstmaxlen - 1] = '\0'; \ strncat (dst, src, dstmaxlen - strlen (dst) - 1); \ } while(0) - -static void -mopts_collect (LibHalContext *hal_ctx, const char *namespace, int namespace_len, - const char *udi, char *options_string, size_t options_max_len, dbus_bool_t only_collect_imply_opts) -{ - LibHalPropertySet *properties; - LibHalPropertySetIterator it; - DBusError error; - - if(hal_ctx == 0) { - fprintf (stderr,"%s %d : LibHalContext *ctx is NULL\n",__FILE__, __LINE__); - return; - } - - dbus_error_init (&error); - - /* first collect from root computer device */ - properties = libhal_device_get_all_properties (hal_ctx, udi, &error); - if (properties == NULL ) { - LIBHAL_FREE_DBUS_ERROR(&error); - return; - } - - for (libhal_psi_init (&it, properties); libhal_psi_has_more (&it); libhal_psi_next (&it)) { - int type; - char *key; - - type = libhal_psi_get_type (&it); - key = libhal_psi_get_key (&it); - if (libhal_psi_get_type (&it) == LIBHAL_PROPERTY_TYPE_BOOLEAN && - strncmp (key, namespace, namespace_len - 1) == 0) { - const char *option = key + namespace_len - 1; - char *location; - dbus_bool_t is_imply_opt; - - is_imply_opt = FALSE; - if (strcmp (option, "user") == 0 || - strcmp (option, "users") == 0 || - strcmp (option, "defaults") == 0 || - strcmp (option, "pamconsole") == 0) - is_imply_opt = TRUE; - - - if (only_collect_imply_opts) { - if (!is_imply_opt) - continue; - } else { - if (is_imply_opt) - continue; - } - - if (libhal_psi_get_bool (&it)) { - /* see if option is already there */ - location = strstr (options_string, option); - if (location == NULL) { - if (strlen (options_string) > 0) - strcat_len (options_string, ",", options_max_len); - strcat_len (options_string, option, options_max_len); - } - } else { - /* remove option if already there */ - location = strstr (options_string, option); - if (location != NULL) { - char *end; - - end = strchr (location, ','); - if (end == NULL) { - location[0] = '\0'; - } else { - strcpy (location, end + 1); /* skip the extra comma */ - } - } - - } - } - } - - libhal_free_property_set (properties); -} - - -const char * -libhal_drive_policy_get_mount_options (LibHalDrive *drive, LibHalStoragePolicy *policy) -{ - const char *result; - char stor_mount_option_default_begin[] = "storage.policy.default.mount_option."; - char stor_mount_option_begin[] = "storage.policy.mount_option."; - - result = NULL; - drive->mount_options[0] = '\0'; - - /* collect options != ('pamconsole', 'user', 'users', 'defaults' options that imply other options) */ - mopts_collect (drive->hal_ctx, stor_mount_option_default_begin, sizeof (stor_mount_option_default_begin), - "/org/freedesktop/Hal/devices/computer", drive->mount_options, MOUNT_OPTIONS_SIZE, TRUE); - mopts_collect (drive->hal_ctx, stor_mount_option_begin, sizeof (stor_mount_option_begin), - drive->udi, drive->mount_options, MOUNT_OPTIONS_SIZE, TRUE); - /* ensure ('pamconsole', 'user', 'users', 'defaults' options that imply other options), are first */ - mopts_collect (drive->hal_ctx, stor_mount_option_default_begin, sizeof (stor_mount_option_default_begin), - "/org/freedesktop/Hal/devices/computer", drive->mount_options, MOUNT_OPTIONS_SIZE, FALSE); - mopts_collect (drive->hal_ctx, stor_mount_option_begin, sizeof (stor_mount_option_begin), - drive->udi, drive->mount_options, MOUNT_OPTIONS_SIZE, FALSE); - - result = drive->mount_options; - - return result; -} - -const char * -libhal_drive_policy_get_mount_fs (LibHalDrive *drive, LibHalStoragePolicy *policy) -{ - return drive->mount_filesystem; -} - - -dbus_bool_t -libhal_volume_policy_is_mountable (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy) -{ - return drive->should_mount && volume->should_mount; -} - -const char *libhal_volume_policy_get_desired_mount_point (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy) -{ - return volume->desired_mount_point; -} - -const char *libhal_volume_policy_get_mount_options (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy) -{ - const char *result; - char stor_mount_option_default_begin[] = "storage.policy.default.mount_option."; - char vol_mount_option_begin[] = "volume.policy.mount_option."; - - result = NULL; - volume->mount_options[0] = '\0'; - - /* ensure ('pamconsole', 'user', 'users', 'defaults' options that imply other options), are first */ - mopts_collect (drive->hal_ctx, stor_mount_option_default_begin, sizeof (stor_mount_option_default_begin), - "/org/freedesktop/Hal/devices/computer", volume->mount_options, MOUNT_OPTIONS_SIZE, TRUE); - mopts_collect (drive->hal_ctx, vol_mount_option_begin, sizeof (vol_mount_option_begin), - volume->udi, volume->mount_options, MOUNT_OPTIONS_SIZE, TRUE); - /* collect options != ('pamconsole', 'user', 'users', 'defaults' options that imply other options) */ - mopts_collect (drive->hal_ctx, stor_mount_option_default_begin, sizeof (stor_mount_option_default_begin), - "/org/freedesktop/Hal/devices/computer", volume->mount_options, MOUNT_OPTIONS_SIZE, FALSE); - mopts_collect (drive->hal_ctx, vol_mount_option_begin, sizeof (vol_mount_option_begin), - volume->udi, volume->mount_options, MOUNT_OPTIONS_SIZE, FALSE); - - result = volume->mount_options; - - return result; -} - -const char *libhal_volume_policy_get_mount_fs (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy) -{ - return volume->mount_filesystem; -} - dbus_bool_t libhal_drive_no_partitions_hint (LibHalDrive *drive) { diff --git a/libhal-storage/libhal-storage.h b/libhal-storage/libhal-storage.h index bb963f2..ee6325f 100644 --- a/libhal-storage/libhal-storage.h +++ b/libhal-storage/libhal-storage.h @@ -41,110 +41,6 @@ struct LibHalDrive_s; typedef struct LibHalDrive_s LibHalDrive; struct LibHalVolume_s; typedef struct LibHalVolume_s LibHalVolume; -struct LibHalStoragePolicy_s; -typedef struct LibHalStoragePolicy_s LibHalStoragePolicy; - - -typedef enum { - LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK = 0x10000, - LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_IDE = 0x10001, - LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_SCSI = 0x10002, - LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_USB = 0x10003, - LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_IEEE1394 = 0x10004, - LIBHAL_STORAGE_ICON_DRIVE_DISK = 0x10100, - LIBHAL_STORAGE_ICON_DRIVE_DISK_IDE = 0x10101, - LIBHAL_STORAGE_ICON_DRIVE_DISK_SCSI = 0x10102, - LIBHAL_STORAGE_ICON_DRIVE_DISK_USB = 0x10103, - LIBHAL_STORAGE_ICON_DRIVE_DISK_IEEE1394 = 0x10104, - LIBHAL_STORAGE_ICON_DRIVE_CDROM = 0x10200, - LIBHAL_STORAGE_ICON_DRIVE_CDROM_IDE = 0x10201, - LIBHAL_STORAGE_ICON_DRIVE_CDROM_SCSI = 0x10202, - LIBHAL_STORAGE_ICON_DRIVE_CDROM_USB = 0x10203, - LIBHAL_STORAGE_ICON_DRIVE_CDROM_IEEE1394 = 0x10204, - LIBHAL_STORAGE_ICON_DRIVE_FLOPPY = 0x10300, - LIBHAL_STORAGE_ICON_DRIVE_FLOPPY_IDE = 0x10301, - LIBHAL_STORAGE_ICON_DRIVE_FLOPPY_SCSI = 0x10302, - LIBHAL_STORAGE_ICON_DRIVE_FLOPPY_USB = 0x10303, - LIBHAL_STORAGE_ICON_DRIVE_FLOPPY_IEEE1394 = 0x10304, - LIBHAL_STORAGE_ICON_DRIVE_TAPE = 0x10400, - LIBHAL_STORAGE_ICON_DRIVE_COMPACT_FLASH = 0x10500, - LIBHAL_STORAGE_ICON_DRIVE_MEMORY_STICK = 0x10600, - LIBHAL_STORAGE_ICON_DRIVE_SMART_MEDIA = 0x10700, - LIBHAL_STORAGE_ICON_DRIVE_SD_MMC = 0x10800, - LIBHAL_STORAGE_ICON_DRIVE_CAMERA = 0x10900, - LIBHAL_STORAGE_ICON_DRIVE_PORTABLE_AUDIO_PLAYER = 0x10a00, - LIBHAL_STORAGE_ICON_DRIVE_ZIP = 0x10b00, - LIBHAL_STORAGE_ICON_DRIVE_JAZ = 0x10c00, - LIBHAL_STORAGE_ICON_DRIVE_FLASH_KEY = 0x10d00, - - LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK = 0x20000, - LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_IDE = 0x20001, - LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_SCSI = 0x20002, - LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_USB = 0x20003, - LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_IEEE1394 = 0x20004, - LIBHAL_STORAGE_ICON_VOLUME_DISK = 0x20100, - LIBHAL_STORAGE_ICON_VOLUME_DISK_IDE = 0x20101, - LIBHAL_STORAGE_ICON_VOLUME_DISK_SCSI = 0x20102, - LIBHAL_STORAGE_ICON_VOLUME_DISK_USB = 0x20103, - LIBHAL_STORAGE_ICON_VOLUME_DISK_IEEE1394 = 0x20104, - LIBHAL_STORAGE_ICON_VOLUME_CDROM = 0x20200, - LIBHAL_STORAGE_ICON_VOLUME_CDROM_IDE = 0x20201, - LIBHAL_STORAGE_ICON_VOLUME_CDROM_SCSI = 0x20202, - LIBHAL_STORAGE_ICON_VOLUME_CDROM_USB = 0x20203, - LIBHAL_STORAGE_ICON_VOLUME_CDROM_IEEE1394 = 0x20204, - LIBHAL_STORAGE_ICON_VOLUME_FLOPPY = 0x20300, - LIBHAL_STORAGE_ICON_VOLUME_FLOPPY_IDE = 0x20301, - LIBHAL_STORAGE_ICON_VOLUME_FLOPPY_SCSI = 0x20302, - LIBHAL_STORAGE_ICON_VOLUME_FLOPPY_USB = 0x20303, - LIBHAL_STORAGE_ICON_VOLUME_FLOPPY_IEEE1394 = 0x20304, - LIBHAL_STORAGE_ICON_VOLUME_TAPE = 0x20400, - LIBHAL_STORAGE_ICON_VOLUME_COMPACT_FLASH = 0x20500, - LIBHAL_STORAGE_ICON_VOLUME_MEMORY_STICK = 0x20600, - LIBHAL_STORAGE_ICON_VOLUME_SMART_MEDIA = 0x20700, - LIBHAL_STORAGE_ICON_VOLUME_SD_MMC = 0x20800, - LIBHAL_STORAGE_ICON_VOLUME_CAMERA = 0x20900, - LIBHAL_STORAGE_ICON_VOLUME_PORTABLE_AUDIO_PLAYER = 0x20a00, - LIBHAL_STORAGE_ICON_VOLUME_ZIP = 0x20b00, - LIBHAL_STORAGE_ICON_VOLUME_JAZ = 0x20c00, - LIBHAL_STORAGE_ICON_VOLUME_FLASH_KEY = 0x20d00, - - LIBHAL_STORAGE_ICON_DISC_CDROM = 0x30000, - LIBHAL_STORAGE_ICON_DISC_CDR = 0x30001, - LIBHAL_STORAGE_ICON_DISC_CDRW = 0x30002, - LIBHAL_STORAGE_ICON_DISC_DVDROM = 0x30003, - LIBHAL_STORAGE_ICON_DISC_DVDRAM = 0x30004, - LIBHAL_STORAGE_ICON_DISC_DVDR = 0x30005, - LIBHAL_STORAGE_ICON_DISC_DVDRW = 0x30006, - LIBHAL_STORAGE_ICON_DISC_DVDPLUSR = 0x30007, - LIBHAL_STORAGE_ICON_DISC_DVDPLUSRW = 0x30008, - LIBHAL_STORAGE_ICON_DISC_DVDPLUSRWDL = 0x30009, - LIBHAL_STORAGE_ICON_DISC_BDROM = 0x3000a, - LIBHAL_STORAGE_ICON_DISC_BDR = 0x3000b, - LIBHAL_STORAGE_ICON_DISC_BDRE = 0x3000c, - LIBHAL_STORAGE_ICON_DISC_HDDVDROM = 0x3000d, - LIBHAL_STORAGE_ICON_DISC_HDDVDR = 0x3000e, - LIBHAL_STORAGE_ICON_DISC_HDDVDRW = 0x3000f, - LIBHAL_STORAGE_ICON_DISC_MRW = 0x30010, - LIBHAL_STORAGE_ICON_DISC_MRWW = 0x30011, - LIBHAL_STORAGE_ICON_DISC_MO = 0x30012 -} LibHalStoragePolicyIcon; - -typedef struct { - LibHalStoragePolicyIcon icon; - const char *icon_path; -} LibHalStoragePolicyIconPair; - -LibHalStoragePolicy *libhal_storage_policy_new (void) LIBHAL_DEPRECATED; -void libhal_storage_policy_free (LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; - -void libhal_storage_policy_set_icon_path (LibHalStoragePolicy *policy, - LibHalStoragePolicyIcon icon, - const char *path) LIBHAL_DEPRECATED; - -void libhal_storage_policy_set_icon_mapping (LibHalStoragePolicy *policy, - LibHalStoragePolicyIconPair *pairs) LIBHAL_DEPRECATED; -const char *libhal_storage_policy_lookup_icon (LibHalStoragePolicy *policy, - LibHalStoragePolicyIcon icon) LIBHAL_DEPRECATED; typedef enum { LIBHAL_DRIVE_BUS_UNKNOWN = 0x00, @@ -227,33 +123,10 @@ const char *libhal_drive_get_physical_device_udi (LibHalDrive *dr const char *libhal_drive_get_dedicated_icon_drive (LibHalDrive *drive); const char *libhal_drive_get_dedicated_icon_volume (LibHalDrive *drive); -char *libhal_drive_policy_compute_display_name (LibHalDrive *drive, - LibHalVolume *volume, - LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; -char *libhal_drive_policy_compute_icon_name (LibHalDrive *drive, - LibHalVolume *volume, - LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; - -dbus_bool_t libhal_drive_policy_is_mountable (LibHalDrive *drive, - LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; -const char *libhal_drive_policy_get_desired_mount_point (LibHalDrive *drive, - LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; -const char *libhal_drive_policy_get_mount_options (LibHalDrive *drive, - LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; -const char *libhal_drive_policy_get_mount_fs (LibHalDrive *drive, - LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; - char **libhal_drive_find_all_volumes (LibHalContext *hal_ctx, LibHalDrive *drive, int *num_volumes); - -char *libhal_drive_policy_default_get_mount_root (LibHalContext *hal_ctx) LIBHAL_DEPRECATED; -dbus_bool_t libhal_drive_policy_default_use_managed_keyword (LibHalContext *hal_ctx) LIBHAL_DEPRECATED; -char *libhal_drive_policy_default_get_managed_keyword_primary (LibHalContext *hal_ctx) LIBHAL_DEPRECATED; -char *libhal_drive_policy_default_get_managed_keyword_secondary (LibHalContext *hal_ctx) LIBHAL_DEPRECATED; - - typedef enum { LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM, LIBHAL_VOLUME_USAGE_PARTITION_TABLE, @@ -330,40 +203,7 @@ dbus_bool_t libhal_volume_disc_is_rewritable (LibHalVolume dbus_bool_t libhal_volume_disc_is_appendable (LibHalVolume *volume); LibHalVolumeDiscType libhal_volume_get_disc_type (LibHalVolume *volume); -int libhal_volume_get_msdos_part_table_type (LibHalVolume *volume) LIBHAL_DEPRECATED; -dbus_uint64_t libhal_volume_get_msdos_part_table_start (LibHalVolume *volume) LIBHAL_DEPRECATED; -dbus_uint64_t libhal_volume_get_msdos_part_table_size (LibHalVolume *volume) LIBHAL_DEPRECATED; - - -dbus_bool_t libhal_volume_should_ignore (LibHalVolume *volume); - -char *libhal_volume_policy_compute_size_as_string (LibHalVolume *volume) LIBHAL_DEPRECATED; - -char *libhal_volume_policy_compute_display_name (LibHalDrive *drive, - LibHalVolume *volume, - LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; -char *libhal_volume_policy_compute_icon_name (LibHalDrive *drive, - LibHalVolume *volume, - LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; - -dbus_bool_t libhal_volume_policy_should_be_visible (LibHalDrive *drive, - LibHalVolume *volume, - LibHalStoragePolicy *policy, - const char *target_mount_point) LIBHAL_DEPRECATED; - -dbus_bool_t libhal_volume_policy_is_mountable (LibHalDrive *drive, - LibHalVolume *volume, - LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; -const char *libhal_volume_policy_get_desired_mount_point (LibHalDrive *drive, - LibHalVolume *volume, - LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; -const char *libhal_volume_policy_get_mount_options (LibHalDrive *drive, - LibHalVolume *volume, - LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; -const char *libhal_volume_policy_get_mount_fs (LibHalDrive *drive, - LibHalVolume *volume, - LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; - +dbus_bool_t libhal_volume_should_ignore (LibHalVolume *volume); #if defined(__cplusplus) }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor