  
    
index.htmlMain Page     
modules.htmlModules     
annotated.htmlData Structures     
files.htmlFiles     
pages.htmlRelated Pages   
libhal-storage.c
00001 /*************************************************************************** 00002  * CVSID: $Id: libhal-storage.c,v 1.27 2006/01/15 16:54:05 david Exp $ 00003  * 00004  * libhal-storage.c : HAL convenience library for storage devices and volumes 00005  * 00006  * Copyright (C) 2004 Red Hat, Inc. David Zeuthen <davidz@redhat.com> 00007  * Copyright (C) 2005 Danny Kukawka, <danny.kukawka@web.de> 00008  * 00009  * Licensed under the Academic Free License version 2.1 00010  * 00011  * This program is free software; you can redistribute it and/or modify 00012  * it under the terms of the GNU General Public License as published by 00013  * the Free Software Foundation; either version 2 of the License, or 00014  * (at your option) any later version. 00015  * 00016  * This program is distributed in the hope that it will be useful, 00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 00019  * GNU General Public License for more details. 00020  * 00021  * You should have received a copy of the GNU General Public License 00022  * along with this program; if not, write to the Free Software 00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 00024  * 00025  **************************************************************************/ 00026 
00027 #ifdef HAVE_CONFIG_H 00028 #  include <config.h> 00029 #endif 00030 00031 #include <stdio.h> 00032 #include <stdlib.h> 00033 #include <string.h> 00034 #include <dbus/dbus.h> 00035 
00036 #include "../libhal/libhal.h" 00037 #include "libhal-storage.h" 00038 
00039 
00040 #ifdef ENABLE_NLS 00041 # include <libintl.h> 00042 # define _(String) dgettext (GETTEXT_PACKAGE, String) 00043 # ifdef gettext_noop 00044 #   define N_(String) gettext_noop (String) 00045 # else 00046 #   define N_(String) (String) 00047 # endif 00048 #else 00049 /* Stubs that do something close enough.  */ 00050 # define textdomain(String) (String) 00051 # define gettext(String) (String) 00052 # define dgettext(Domain,Message) (Message) 00053 # define dcgettext(Domain,Message,Type) (Message) 00054 # define bindtextdomain(Domain,Directory) (Domain) 00055 # define _(String) (String) 00056 # define N_(String) (String) 00057 #endif 00058 structIconMappingEntry__s.html00070  typedef struct structIconMappingEntry__s.htmlIconMappingEntry_s  {
structIconMappingEntry__s.html#a02d1566df029104542fc6b4d937d81c00071      group__HAL.html#gc27af7f0b8e7cf7120a3bc08bce80501LibHalStoragePolicyIcon  structIconMappingEntry__s.html#a02d1566df029104542fc6b4d937d81cicon ;
structIconMappingEntry__s.html#4cec89a1d882eda998716af763e7ae9000072      char * structIconMappingEntry__s.html#4cec89a1d882eda998716af763e7ae90path ;
structIconMappingEntry__s.html#2270f4f7f77b98348ccd272bfd51f38400073      struct structIconMappingEntry__s.htmlIconMappingEntry_s  * structIconMappingEntry__s.html#2270f4f7f77b98348ccd272bfd51f384next ;
00074 } structIconMappingEntry__s.htmlIconMappingEntry ;
00075 
structLibHalStoragePolicy__s.html00076  struct structLibHalStoragePolicy__s.htmlLibHalStoragePolicy_s  {
structLibHalStoragePolicy__s.html#0fb4ed232268af9ab4194b07b166ff9500077      structIconMappingEntry__s.htmlIconMappingEntry  * structLibHalStoragePolicy__s.html#0fb4ed232268af9ab4194b07b166ff95icon_mappings ;
00078 };
00079 
00080 LibHalStoragePolicy *
group__HAL.html#g93139ce1adc74b62027414c1421b20e700081  group__LibHalStorage.html#g2490ed5e0ca858c0b08ae43fe6666108libhal_storage_policy_new  ()
00082 {
00083     LibHalStoragePolicy *p;
00084 
00085     p = malloc (sizeof (LibHalStoragePolicy));
00086     if (p == NULL)
00087         goto out;
00088 
00089     p->icon_mappings = NULL;
00090 out:
00091     return p;
00092 }
00093 
00094 void group__HAL.html#gdd419823b454d73b7d569edd99cf84aa00095  group__LibHalStorage.html#gdd419823b454d73b7d569edd99cf84aalibhal_storage_policy_free  (LibHalStoragePolicy *policy)
00096 {
00097     structIconMappingEntry__s.htmlIconMappingEntry  *i;
00098     structIconMappingEntry__s.htmlIconMappingEntry  *j;
00099 
00100     /* free all icon mappings */ 00101     for (i = policy->icon_mappings; i != NULL; i = j) {
00102         j = i-> structIconMappingEntry__s.html#2270f4f7f77b98348ccd272bfd51f384next ;
00103         free (i-> structIconMappingEntry__s.html#4cec89a1d882eda998716af763e7ae90path );
00104         free (i);
00105     }
00106 
00107     free (policy);
00108 }
00109 
00110 void group__HAL.html#gd58e78dfbd3fdf2f5d8108173ac8b82100111  group__LibHalStorage.html#gd58e78dfbd3fdf2f5d8108173ac8b821libhal_storage_policy_set_icon_path  (LibHalStoragePolicy *policy, group__HAL.html#gc27af7f0b8e7cf7120a3bc08bce80501LibHalStoragePolicyIcon  icon, const char *path)
00112 {
00113     structIconMappingEntry__s.htmlIconMappingEntry  *i;
00114 
00115     /* see if it already exist */ 00116     for (i = policy->icon_mappings; i != NULL; i = i-> structIconMappingEntry__s.html#2270f4f7f77b98348ccd272bfd51f384next ) {
00117         if (i-> structIconMappingEntry__s.html#a02d1566df029104542fc6b4d937d81cicon  == icon) {
00118             free (i-> structIconMappingEntry__s.html#4cec89a1d882eda998716af763e7ae90path );
00119             i-> structIconMappingEntry__s.html#4cec89a1d882eda998716af763e7ae90path  = strdup (path);
00120             goto out;
00121         }
00122     }
00123 
00124     i = malloc (sizeof ( structIconMappingEntry__s.htmlIconMappingEntry ));
00125     if (i == NULL)
00126         goto out;
00127     i-> structIconMappingEntry__s.html#a02d1566df029104542fc6b4d937d81cicon  = icon;
00128     i-> structIconMappingEntry__s.html#4cec89a1d882eda998716af763e7ae90path  = strdup (path);
00129     i-> structIconMappingEntry__s.html#2270f4f7f77b98348ccd272bfd51f384next  = policy->icon_mappings;
00130     policy->icon_mappings = i;
00131 
00132 out:
00133     return;
00134 }
00135 
00136 void group__HAL.html#gafdaaedce096870ecef82ad37e19455500137  group__LibHalStorage.html#gafdaaedce096870ecef82ad37e194555libhal_storage_policy_set_icon_mapping  (LibHalStoragePolicy *policy, structLibHalStoragePolicyIconPair.htmlLibHalStoragePolicyIconPair  *pairs)
00138 {
00139     structLibHalStoragePolicyIconPair.htmlLibHalStoragePolicyIconPair  *i;
00140 
00141     for (i = pairs; i-> structLibHalStoragePolicyIconPair.html#30f253efd7b19c46fdc2b9beb6543cd2icon  != 0x00; i++) {
00142         group__LibHalStorage.html#gd58e78dfbd3fdf2f5d8108173ac8b821libhal_storage_policy_set_icon_path  (policy, i-> structLibHalStoragePolicyIconPair.html#30f253efd7b19c46fdc2b9beb6543cd2icon , i-> structLibHalStoragePolicyIconPair.html#556a53303db59c411ac24a68b3b68908icon_path );
00143     }
00144 }
00145 
00146 const char *
group__HAL.html#ge8387f9dd18101fa1ef15de9d1ccc4bb00147  group__LibHalStorage.html#ge8387f9dd18101fa1ef15de9d1ccc4bblibhal_storage_policy_lookup_icon  (LibHalStoragePolicy *policy, group__HAL.html#gc27af7f0b8e7cf7120a3bc08bce80501LibHalStoragePolicyIcon  icon)
00148 {
00149     structIconMappingEntry__s.htmlIconMappingEntry  *i;
00150     const char *path;
00151 
00152     path = NULL;
00153     for (i = policy->icon_mappings; i != NULL; i = i-> structIconMappingEntry__s.html#2270f4f7f77b98348ccd272bfd51f384next ) {
00154         if (i-> structIconMappingEntry__s.html#a02d1566df029104542fc6b4d937d81cicon  == icon) {
00155             path = i-> structIconMappingEntry__s.html#4cec89a1d882eda998716af763e7ae90path ;
00156             goto out;
00157         }
00158     }
00159 out:
00160     return path;
00161 }
00162 
00163 
group__LibHalStorage.html#g03b2fc955b65d7d53d0e859a0a0ef93a00164  #define MAX_STRING_SZ 256 00165 00166 char *
group__HAL.html#g3d66452cfca4bd8d21b791823a32258000167  group__LibHalStorage.html#g3d66452cfca4bd8d21b791823a322580libhal_volume_policy_compute_size_as_string  (LibHalVolume *volume)
00168 {
00169     dbus_uint64_t size;
00170     char *result;
00171     char* sizes_str[] = {"K", "M", "G", "T", NULL};
00172     dbus_uint64_t cur = 1000L;
00173     dbus_uint64_t base = 10L;
00174     dbus_uint64_t step = 10L*10L*10L;
00175     int cur_str = 0;
00176     char buf[ group__LibHalStorage.html#g03b2fc955b65d7d53d0e859a0a0ef93aMAX_STRING_SZ ];
00177 
00178     result = NULL;
00179 
00180     size = group__LibHalStorage.html#g40640d27b391a805ebad8d4dd3c09c07libhal_volume_get_size  (volume);
00181 
00182     do {
00183         if (sizes_str[cur_str+1] == NULL || size < cur*step) {
00184             /* found the unit, display a comma number if result is a single digit */ 00185             if (size < cur*base) {
00186                 snprintf (buf, group__LibHalStorage.html#g03b2fc955b65d7d53d0e859a0a0ef93aMAX_STRING_SZ , "%.01f%s", 
00187                       ((double)size)/((double)cur), sizes_str[cur_str]);
00188                 result = strdup (buf);
00189             } else {
00190                 snprintf (buf, group__LibHalStorage.html#g03b2fc955b65d7d53d0e859a0a0ef93aMAX_STRING_SZ , "%lld%s", size / cur, sizes_str[cur_str]);
00191                 result = strdup (buf);
00192                 }
00193             goto out;
00194         }
00195 
00196         cur *= step;
00197         cur_str++;
00198     } while (1);
00199 
00200 out:
00201     return result;
00202 }
00203 
00204 static void group__LibHalStorage.html#ge72f6b0282c8f8a156e33a73183b3fee00205  group__LibHalStorage.html#ge72f6b0282c8f8a156e33a73183b3feefixup_string  (char *s)
00206 {
00207     /* TODO: first strip leading and trailing whitespace */ 00208     /*g_strstrip (s);*/ 00209 
00210     /* TODO: could do nice things on all-upper case strings */ 00211 }
00212 
00213 /* volume may be NULL (e.g. if drive supports removable media) */ 00214 char *
group__HAL.html#ga4e1a1c76b9cbe9ea40c5716cb14c43500215  group__LibHalStorage.html#ga4e1a1c76b9cbe9ea40c5716cb14c435libhal_drive_policy_compute_display_name  (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
00216 {
00217     char *name;
00218     char *size_str;
00219     char *vendormodel_str;
00220     const char *model;
00221     const char *vendor;
00222     group__HAL.html#gc68e6cb3850c3cf3cbf25f25943f4327LibHalDriveType  drive_type;
00223     dbus_bool_t drive_is_hotpluggable;
00224     dbus_bool_t drive_is_removable;
00225     group__HAL.html#gf2bc93777748848615fa742b1e6dbdd8LibHalDriveCdromCaps  drive_cdrom_caps;
00226     char buf[ group__LibHalStorage.html#g03b2fc955b65d7d53d0e859a0a0ef93aMAX_STRING_SZ ];
00227 
00228     model = group__LibHalStorage.html#gee172a56c64d682b281ca24edadfaa1dlibhal_drive_get_model  (drive);
00229     vendor = group__LibHalStorage.html#gde8e944f388952bfa60b25cd34c56929libhal_drive_get_vendor  (drive);
00230     drive_type = group__LibHalStorage.html#gb0d94240b118af162290d2f8b3d8769alibhal_drive_get_type  (drive);
00231     drive_is_hotpluggable = group__LibHalStorage.html#g6670a3858fc3dc1772b1845f3f9d9079libhal_drive_is_hotpluggable  (drive);
00232     drive_is_removable = group__LibHalStorage.html#ga73733c37c764263cd9c087b29203391libhal_drive_uses_removable_media  (drive);
00233     drive_cdrom_caps = group__LibHalStorage.html#g110790451c4fd7556de7d21f58eb4fdalibhal_drive_get_cdrom_caps  (drive);
00234 
00235     if (volume != NULL)
00236         size_str = group__LibHalStorage.html#g3d66452cfca4bd8d21b791823a322580libhal_volume_policy_compute_size_as_string  (volume);
00237     else 00238         size_str = NULL;
00239 
00240     if (vendor == NULL || strlen (vendor) == 0) {
00241         if (model == NULL || strlen (model) == 0)
00242             vendormodel_str = strdup ("");
00243         else 00244             vendormodel_str = strdup (model);
00245     } else {
00246         if (model == NULL || strlen (model) == 0)
00247             vendormodel_str = strdup (vendor);
00248         else {
00249             snprintf (buf, group__LibHalStorage.html#g03b2fc955b65d7d53d0e859a0a0ef93aMAX_STRING_SZ , "%s %s", vendor, model);
00250             vendormodel_str = strdup (buf);
00251         }
00252     }
00253 
00254     group__LibHalStorage.html#ge72f6b0282c8f8a156e33a73183b3feefixup_string  (vendormodel_str);
00255 
00256     if (drive_type==LIBHAL_DRIVE_TYPE_CDROM) {
00257 
00258         /* Optical drive handling */ 00259         char *first;
00260         char *second;
00261 
00262 
00263         first = "CD-ROM";
00264         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_CDR)
00265             first = "CD-R";
00266         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_CDRW)
00267             first = "CD-RW";
00268 
00269         second = "";
00270         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDROM)
00271             second = "/DVD-ROM";
00272         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSR)
00273             second = "/DVD+R";
00274         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRW)
00275             second = "/DVD+RW";
00276         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDR)
00277             second = "/DVD-R";
00278         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDRW)
00279             second = "/DVD-RW";
00280         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDRAM)
00281             second = "/DVD-RAM";
00282         if ((drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDR) &&
00283             (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSR)) {
00284             if(drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRDL)
00285                 second = "/DVDÂ±R DL";
00286             else 00287                 second = "/DVDÂ±R";
00288         }
00289         if ((drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDRW) &&
00290             (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRW)) {
00291                         if(drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRDL || 
00292                drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRWDL)
00293                                 second = "/DVDÂ±RW DL";
00294                         else 00295                                 second = "/DVDÂ±RW";
00296                 }
00297 
00298 
00299         if (drive_is_hotpluggable) {
00300             snprintf (buf, group__LibHalStorage.html#g03b2fc955b65d7d53d0e859a0a0ef93aMAX_STRING_SZ , _("External %s%s Drive"), first, second);
00301             name = strdup (buf);
00302         } else {
00303             snprintf (buf, group__LibHalStorage.html#g03b2fc955b65d7d53d0e859a0a0ef93aMAX_STRING_SZ , _("%s%s Drive"), first, second);
00304             name = strdup (buf);
00305         }
00306             
00307     } else if (drive_type==LIBHAL_DRIVE_TYPE_FLOPPY) {
00308 
00309         /* Floppy Drive handling */ 00310 
00311         if (drive_is_hotpluggable)
00312             name = strdup (_("External Floppy Drive"));
00313         else 00314             name = strdup (_("Floppy Drive"));
00315     } else if (drive_type==LIBHAL_DRIVE_TYPE_DISK && !drive_is_removable) {
00316 
00317         /* Harddisks */ 00318 
00319         if (size_str != NULL) {
00320             if (drive_is_hotpluggable) {
00321                 snprintf (buf, group__LibHalStorage.html#g03b2fc955b65d7d53d0e859a0a0ef93aMAX_STRING_SZ , _("%s External Hard Drive"), size_str);
00322                 name = strdup (buf);
00323             } else {
00324                 snprintf (buf, group__LibHalStorage.html#g03b2fc955b65d7d53d0e859a0a0ef93aMAX_STRING_SZ , _("%s Hard Drive"), size_str);
00325                 name = strdup (buf);
00326             }
00327         } else {
00328             if (drive_is_hotpluggable)
00329                 name = strdup (_("External Hard Drive"));
00330             else 00331                 name = strdup (_("Hard Drive"));
00332         }
00333     } else {
00334 
00335         /* The rest - includes drives with removable Media */ 00336 
00337         if (strlen (vendormodel_str) > 0)
00338             name = strdup (vendormodel_str);
00339         else 00340             name = strdup (_("Drive"));
00341     }
00342 
00343     free (vendormodel_str);
00344     free (size_str);
00345 
00346     return name;
00347 }
00348 
00349 char *
group__HAL.html#g28a622fa093951916de48fea20fc929800350  group__LibHalStorage.html#g28a622fa093951916de48fea20fc9298libhal_volume_policy_compute_display_name  (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
00351 {
00352     char *name;
00353     char *size_str;
00354     const char *volume_label;
00355     const char *model;
00356     const char *vendor;
00357     group__HAL.html#gc68e6cb3850c3cf3cbf25f25943f4327LibHalDriveType  drive_type;
00358     dbus_bool_t drive_is_hotpluggable;
00359     dbus_bool_t drive_is_removable;
00360     group__HAL.html#gf2bc93777748848615fa742b1e6dbdd8LibHalDriveCdromCaps  drive_cdrom_caps;
00361     char buf[ group__LibHalStorage.html#g03b2fc955b65d7d53d0e859a0a0ef93aMAX_STRING_SZ ];
00362 
00363     volume_label = group__LibHalStorage.html#g596fc8a057ec95c3012413b54e36b847libhal_volume_get_label  (volume);
00364     model = group__LibHalStorage.html#gee172a56c64d682b281ca24edadfaa1dlibhal_drive_get_model  (drive);
00365     vendor = group__LibHalStorage.html#gde8e944f388952bfa60b25cd34c56929libhal_drive_get_vendor  (drive);
00366     drive_type = group__LibHalStorage.html#gb0d94240b118af162290d2f8b3d8769alibhal_drive_get_type  (drive);
00367     drive_is_hotpluggable = group__LibHalStorage.html#g6670a3858fc3dc1772b1845f3f9d9079libhal_drive_is_hotpluggable  (drive);
00368     drive_is_removable = group__LibHalStorage.html#ga73733c37c764263cd9c087b29203391libhal_drive_uses_removable_media  (drive);
00369     drive_cdrom_caps = group__LibHalStorage.html#g110790451c4fd7556de7d21f58eb4fdalibhal_drive_get_cdrom_caps  (drive);
00370 
00371     size_str = group__LibHalStorage.html#g3d66452cfca4bd8d21b791823a322580libhal_volume_policy_compute_size_as_string  (volume);
00372 
00373     /* If the volume label is available use that 00374      * 00375      * TODO: If label is a fully-qualified UNIX path don't use that 00376      */ 00377     if (volume_label != NULL) {
00378         name = strdup (volume_label);
00379         goto out;
00380     }
00381 
00382     /* Handle media in optical drives */ 00383     if (drive_type==LIBHAL_DRIVE_TYPE_CDROM) {
00384         switch ( group__LibHalStorage.html#gc0e3c1e24e973a4eb2b4f41f4e99f58dlibhal_volume_get_disc_type  (volume)) {
00385 
00386         default:
00387             /* explict fallthrough */ 00388         case LIBHAL_VOLUME_DISC_TYPE_CDROM:
00389             name = strdup (_("CD-ROM "));
00390             break;
00391             
00392         case LIBHAL_VOLUME_DISC_TYPE_CDR:
00393             if ( group__LibHalStorage.html#gebd31ba5682a0d17854e4ac74987304clibhal_volume_disc_is_blank  (volume))
00394                 name = strdup (_("Blank CD-R"));
00395             else 00396                 name = strdup (_("CD-R"));
00397             break;
00398             
00399         case LIBHAL_VOLUME_DISC_TYPE_CDRW:
00400             if ( group__LibHalStorage.html#gebd31ba5682a0d17854e4ac74987304clibhal_volume_disc_is_blank  (volume))
00401                 name = strdup (_("Blank CD-RW"));
00402             else 00403                 name = strdup (_("CD-RW"));
00404             break;
00405             
00406         case LIBHAL_VOLUME_DISC_TYPE_DVDROM:
00407             name = strdup (_("DVD-ROM"));
00408             break;
00409             
00410         case LIBHAL_VOLUME_DISC_TYPE_DVDRAM:
00411             if ( group__LibHalStorage.html#gebd31ba5682a0d17854e4ac74987304clibhal_volume_disc_is_blank  (volume))
00412                 name = strdup (_("Blank DVD-RAM"));
00413             else 00414                 name = strdup (_("DVD-RAM"));
00415             break;
00416             
00417         case LIBHAL_VOLUME_DISC_TYPE_DVDR:
00418             if ( group__LibHalStorage.html#gebd31ba5682a0d17854e4ac74987304clibhal_volume_disc_is_blank  (volume))
00419                 name = strdup (_("Blank DVD-R"));
00420             else 00421                 name = strdup (_("DVD-R"));
00422             break;
00423             
00424         case LIBHAL_VOLUME_DISC_TYPE_DVDRW:
00425             if ( group__LibHalStorage.html#gebd31ba5682a0d17854e4ac74987304clibhal_volume_disc_is_blank  (volume))
00426                 name = strdup (_("Blank DVD-RW"));
00427             else 00428                 name = strdup (_("DVD-RW"));
00429             break;
00430 
00431         case LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR:
00432             if ( group__LibHalStorage.html#gebd31ba5682a0d17854e4ac74987304clibhal_volume_disc_is_blank  (volume))
00433                 name = strdup (_("Blank DVD+R"));
00434             else 00435                 name = strdup (_("DVD+R"));
00436             break;
00437             
00438         case LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW:
00439             if ( group__LibHalStorage.html#gebd31ba5682a0d17854e4ac74987304clibhal_volume_disc_is_blank  (volume))
00440                 name = strdup (_("Blank DVD+RW"));
00441             else 00442                 name = strdup (_("DVD+RW"));
00443             break;
00444         
00445         case LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR_DL:
00446             if ( group__LibHalStorage.html#gebd31ba5682a0d17854e4ac74987304clibhal_volume_disc_is_blank  (volume))
00447                 name = strdup (_("Blank DVD+R Dual-Layer"));
00448             else 00449                 name = strdup (_("DVD+R Dual-Layer"));
00450             break;
00451         }
00452         
00453         /* Special case for pure audio disc */ 00454         if ( group__LibHalStorage.html#gb29922e78dcdcd3f588d4285d7ab6460libhal_volume_disc_has_audio  (volume) && ! group__LibHalStorage.html#g4cc4f1836c6d094c075b2de9e114ba4alibhal_volume_disc_has_data  (volume)) {
00455             free (name);
00456             name = strdup (_("Audio CD"));
00457         }
00458 
00459         goto out;
00460     }
00461 
00462     /* Fallback: size of media */ 00463     if (drive_is_removable) {
00464         snprintf (buf, group__LibHalStorage.html#g03b2fc955b65d7d53d0e859a0a0ef93aMAX_STRING_SZ , _("%s Removable Media"), size_str);
00465         name = strdup (buf);
00466     } else {
00467         snprintf (buf, group__LibHalStorage.html#g03b2fc955b65d7d53d0e859a0a0ef93aMAX_STRING_SZ , _("%s Media"), size_str);
00468         name = strdup (buf);
00469     }
00470 
00471     /* Fallback: Use drive name */ 00472     /*name = libhal_drive_policy_compute_display_name (drive, volume);*/ 00473 
00474 out:
00475     free (size_str);
00476     return name;
00477 }
00478 
00479 char *
group__HAL.html#g045d1e4dba53fa4624689ad19bccef9900480  group__LibHalStorage.html#g045d1e4dba53fa4624689ad19bccef99libhal_drive_policy_compute_icon_name  (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
00481 {
00482     const char *name;
00483     group__HAL.html#gf3deefc262e2d44adf65bf517b8e5b33LibHalDriveBus  bus;
00484     group__HAL.html#gc68e6cb3850c3cf3cbf25f25943f4327LibHalDriveType  drive_type;
00485 
00486     bus        = group__LibHalStorage.html#g2e777b14d4dd49c09bad933c6dae8b01libhal_drive_get_bus  (drive);
00487     drive_type = group__LibHalStorage.html#gb0d94240b118af162290d2f8b3d8769alibhal_drive_get_type  (drive);
00488 
00489     /* by design, the enums are laid out so we can do easy computations */ 00490 
00491     switch (drive_type) {
00492     case LIBHAL_DRIVE_TYPE_REMOVABLE_DISK:
00493     case LIBHAL_DRIVE_TYPE_DISK:
00494     case LIBHAL_DRIVE_TYPE_CDROM:
00495     case LIBHAL_DRIVE_TYPE_FLOPPY:
00496         name = group__LibHalStorage.html#ge8387f9dd18101fa1ef15de9d1ccc4bblibhal_storage_policy_lookup_icon  (policy, 0x10000 + drive_type*0x100 + bus);
00497         break;
00498 
00499     default:
00500         name = group__LibHalStorage.html#ge8387f9dd18101fa1ef15de9d1ccc4bblibhal_storage_policy_lookup_icon  (policy, 0x10000 + drive_type*0x100);
00501     }
00502 
00503     if (name != NULL)
00504         return strdup (name);
00505     else 00506         return NULL;
00507 }
00508 
00509 char *
group__HAL.html#g0f957a578e9863cfe317ab8dca2a0f9300510  group__LibHalStorage.html#g0f957a578e9863cfe317ab8dca2a0f93libhal_volume_policy_compute_icon_name  (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
00511 {
00512     const char *name;
00513     group__HAL.html#gf3deefc262e2d44adf65bf517b8e5b33LibHalDriveBus  bus;
00514     group__HAL.html#gc68e6cb3850c3cf3cbf25f25943f4327LibHalDriveType  drive_type;
00515     group__HAL.html#gf63ab855e3c70a13982592c11179df13LibHalVolumeDiscType  disc_type;
00516 
00517     /* by design, the enums are laid out so we can do easy computations */ 00518 
00519     if ( group__LibHalStorage.html#g6ca65999bf7e2ab0d4c1021861190b65libhal_volume_is_disc  (volume)) {
00520         disc_type = group__LibHalStorage.html#gc0e3c1e24e973a4eb2b4f41f4e99f58dlibhal_volume_get_disc_type  (volume);
00521         name = group__LibHalStorage.html#ge8387f9dd18101fa1ef15de9d1ccc4bblibhal_storage_policy_lookup_icon  (policy, 0x30000 + disc_type);
00522         goto out;
00523     }
00524 
00525     if (drive == NULL) {
00526         name = group__LibHalStorage.html#ge8387f9dd18101fa1ef15de9d1ccc4bblibhal_storage_policy_lookup_icon  (policy, LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK);
00527         goto out;
00528     }
00529 
00530     bus        = group__LibHalStorage.html#g2e777b14d4dd49c09bad933c6dae8b01libhal_drive_get_bus  (drive);
00531     drive_type = group__LibHalStorage.html#gb0d94240b118af162290d2f8b3d8769alibhal_drive_get_type  (drive);
00532 
00533     switch (drive_type) {
00534     case LIBHAL_DRIVE_TYPE_REMOVABLE_DISK:
00535     case LIBHAL_DRIVE_TYPE_DISK:
00536     case LIBHAL_DRIVE_TYPE_CDROM:
00537     case LIBHAL_DRIVE_TYPE_FLOPPY:
00538         name = group__LibHalStorage.html#ge8387f9dd18101fa1ef15de9d1ccc4bblibhal_storage_policy_lookup_icon  (policy, 0x20000 + drive_type*0x100 + bus);
00539         break;
00540 
00541     default:
00542         name = group__LibHalStorage.html#ge8387f9dd18101fa1ef15de9d1ccc4bblibhal_storage_policy_lookup_icon  (policy, 0x20000 + drive_type*0x100);
00543     }
00544 out:
00545     if (name != NULL)
00546         return strdup (name);
00547     else 00548         return NULL;
00549 }
00550 
00567 dbus_bool_t
group__HAL.html#g4657a8d27a2d7daf66a53b019f58b09500568  group__LibHalStorage.html#g4657a8d27a2d7daf66a53b019f58b095libhal_volume_policy_should_be_visible  (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy, 
00569                      const char *target_mount_point)
00570 {
00571     unsigned int i;
00572     dbus_bool_t is_visible;
00573     const char *label;
00574     const char *mount_point;
00575     const char *fstype;
00576     const char *fhs23_toplevel_mount_points[] = {
00577         "/",
00578         "/bin",
00579         "/boot",
00580         "/dev",
00581         "/etc",
00582         "/home",
00583         "/lib",
00584         "/lib64",
00585         "/media",
00586         "/mnt",
00587         "/opt",
00588         "/root",
00589         "/sbin",
00590         "/srv",
00591         "/tmp",
00592         "/usr",
00593         "/var",
00594         "/proc",
00595         "/sbin",
00596         NULL
00597     };
00598 
00599     is_visible = FALSE;
00600 
00601     /* skip if hal says it's not used as a filesystem */ 00602     if ( group__LibHalStorage.html#gb6650c31a5f04580cb762b546635a5a6libhal_volume_get_fsusage  (volume) != LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM)
00603         goto out;
00604 
00605     label = group__LibHalStorage.html#g596fc8a057ec95c3012413b54e36b847libhal_volume_get_label  (volume);
00606     mount_point = group__LibHalStorage.html#g11612b487cb110053cec837d8ccc7b65libhal_volume_get_mount_point  (volume);
00607     fstype = group__LibHalStorage.html#ga5e22676f2df3f4b02aacee00f42f347libhal_volume_get_fstype  (volume);
00608 
00609     /* use target mount point if we're not mounted yet */ 00610     if (mount_point == NULL)
00611         mount_point = target_mount_point;
00612 
00613     /* bail out if we don't know the filesystem */ 00614     if (fstype == NULL)
00615         goto out;
00616 
00617     /* blacklist fhs2.3 top level mount points */ 00618     if (mount_point != NULL) {
00619         for (i = 0; fhs23_toplevel_mount_points[i] != NULL; i++) {
00620             if (strcmp (mount_point, fhs23_toplevel_mount_points[i]) == 0)
00621                 goto out;
00622         }
00623     }
00624 
00625     /* blacklist partitions with name 'bootstrap' of type HFS (Apple uses that) */ 00626     if (label != NULL && strcmp (label, "bootstrap") == 0 && strcmp (fstype, "hfs") == 0)
00627         goto out;
00628 
00629     /* only the real lucky mount points will make it this far :-) */ 00630     is_visible = TRUE;
00631 
00632 out:
00633     return is_visible;
00634 }
00635 
00636 /*************************************************************************/ 00637 
group__LibHalStorage.html#g8679e1d7cfa6bcaf121b8432753098a600638  #define MOUNT_OPTIONS_SIZE 256 00639 structLibHalDrive__s.html00640  struct structLibHalDrive__s.htmlLibHalDrive_s  {
structLibHalDrive__s.html#a7768eed02976f9029d0e3ebce917d3000641      char * structLibHalDrive__s.html#a7768eed02976f9029d0e3ebce917d30udi ;
00642 
structLibHalDrive__s.html#f3fd158d2d28e257dea7587595e0e6a300643      int structLibHalDrive__s.html#f3fd158d2d28e257dea7587595e0e6a3device_major ;
structLibHalDrive__s.html#140556d681c7f96602d93868a134d89500644      int structLibHalDrive__s.html#140556d681c7f96602d93868a134d895device_minor ;
structLibHalDrive__s.html#de60e084436d30c0eef0f795ae6450bc00645      char * structLibHalDrive__s.html#de60e084436d30c0eef0f795ae6450bcdevice_file ;
00646 
structLibHalDrive__s.html#eb89fe50e32cd249514366c300e9699a00647      group__HAL.html#gf3deefc262e2d44adf65bf517b8e5b33LibHalDriveBus  structLibHalDrive__s.html#eb89fe50e32cd249514366c300e9699abus ;
structLibHalDrive__s.html#3a1a92fe46a532c05f2a3b68f7fa552600648      char * structLibHalDrive__s.html#3a1a92fe46a532c05f2a3b68f7fa5526vendor ;             /* may be "", is never NULL */ structLibHalDrive__s.html#9fa9928ec4b7ad34316c441a0d7a47f900649      char * structLibHalDrive__s.html#9fa9928ec4b7ad34316c441a0d7a47f9model ;              /* may be "", is never NULL */ structLibHalDrive__s.html#4acd7c25c3d7a62eda8d18666e9110d900650      dbus_bool_t structLibHalDrive__s.html#4acd7c25c3d7a62eda8d18666e9110d9is_hotpluggable ;
structLibHalDrive__s.html#d08ad0a354cd18aede7e354a03038eb900651      dbus_bool_t structLibHalDrive__s.html#d08ad0a354cd18aede7e354a03038eb9is_removable ;
structLibHalDrive__s.html#6a113a19d9aacf6a7cdc19ef6385568e00652      dbus_bool_t structLibHalDrive__s.html#6a113a19d9aacf6a7cdc19ef6385568erequires_eject ;
00653 
structLibHalDrive__s.html#b33dfd5b32ce9fffec2028b98703505c00654      group__HAL.html#gc68e6cb3850c3cf3cbf25f25943f4327LibHalDriveType  structLibHalDrive__s.html#b33dfd5b32ce9fffec2028b98703505ctype ;
structLibHalDrive__s.html#373dcd22beba195a7a5d839034f8cfa000655      char * structLibHalDrive__s.html#373dcd22beba195a7a5d839034f8cfa0type_textual ;
00656 
structLibHalDrive__s.html#186311ddba874cff8ca03ce76e26dec200657      char * structLibHalDrive__s.html#186311ddba874cff8ca03ce76e26dec2physical_device ;  /* UDI of physical device, e.g. the 00658                  * IDE, USB, IEEE1394 device */ 00659 
structLibHalDrive__s.html#da23c1365b9f0ee8eb9b99eb3fc65fcb00660      char * structLibHalDrive__s.html#da23c1365b9f0ee8eb9b99eb3fc65fcbdedicated_icon_drive ;
structLibHalDrive__s.html#9ec86316ecc5c96a17cf29f8cc07143a00661      char * structLibHalDrive__s.html#9ec86316ecc5c96a17cf29f8cc07143adedicated_icon_volume ;
00662 
structLibHalDrive__s.html#120cf2aa4740e501c36e94cd3c5494f600663      char * structLibHalDrive__s.html#120cf2aa4740e501c36e94cd3c5494f6serial ;
structLibHalDrive__s.html#38a75df0dbaf308ee594bf846cd9fedb00664      char * structLibHalDrive__s.html#38a75df0dbaf308ee594bf846cd9fedbfirmware_version ;
structLibHalDrive__s.html#6964d844f9285d646c67485b1f10399200665      group__HAL.html#gf2bc93777748848615fa742b1e6dbdd8LibHalDriveCdromCaps  structLibHalDrive__s.html#6964d844f9285d646c67485b1f103992cdrom_caps ;
00666 
structLibHalDrive__s.html#c3f379f342bb03729c09877c2a6da83300667      char * structLibHalDrive__s.html#c3f379f342bb03729c09877c2a6da833desired_mount_point ;
structLibHalDrive__s.html#7c256cd88c919162696150fd8625beb600668      char * structLibHalDrive__s.html#7c256cd88c919162696150fd8625beb6mount_filesystem ;
structLibHalDrive__s.html#56596af52ed21075807c2e1e4be921dc00669      dbus_bool_t structLibHalDrive__s.html#56596af52ed21075807c2e1e4be921dcshould_mount ;
00670 
structLibHalDrive__s.html#e84dc61750729404e5e521fa114c6b3200671      dbus_bool_t structLibHalDrive__s.html#e84dc61750729404e5e521fa114c6b32no_partitions_hint ;
00672 
structLibHalDrive__s.html#009b1ee554e3a2eb20a57920f2bf155b00673      LibHalContext * structLibHalDrive__s.html#009b1ee554e3a2eb20a57920f2bf155bhal_ctx ;
00674 
structLibHalDrive__s.html#9cbe09953593937f37c143c3bf3625d800675      char ** structLibHalDrive__s.html#9cbe09953593937f37c143c3bf3625d8capabilities ;
00676 
structLibHalDrive__s.html#e334a25aeedc06acb583873b56afd7e600677      char structLibHalDrive__s.html#e334a25aeedc06acb583873b56afd7e6mount_options [ group__LibHalStorage.html#g8679e1d7cfa6bcaf121b8432753098a6MOUNT_OPTIONS_SIZE ];
00678 };
00679 
structLibHalVolume__s.html00680  struct structLibHalVolume__s.htmlLibHalVolume_s  {
structLibHalVolume__s.html#3a0014014879fed1a930f344382b198900681      char * structLibHalVolume__s.html#3a0014014879fed1a930f344382b1989udi ;
00682 
structLibHalVolume__s.html#5e5bf75c6757a88fbad48f202152600100683      int structLibHalVolume__s.html#5e5bf75c6757a88fbad48f2021526001device_major ;
structLibHalVolume__s.html#7d11d24c50bb8ed19b76f3c1027599dd00684      int structLibHalVolume__s.html#7d11d24c50bb8ed19b76f3c1027599dddevice_minor ;
structLibHalVolume__s.html#84132339f3ff729f9b35e7b5ca2e175f00685      char * structLibHalVolume__s.html#84132339f3ff729f9b35e7b5ca2e175fdevice_file ;
structLibHalVolume__s.html#7e07ade216f8bdd7c79c50d9b4fb3ece00686      char * structLibHalVolume__s.html#7e07ade216f8bdd7c79c50d9b4fb3ecevolume_label ; /* may be NULL, is never "" */ structLibHalVolume__s.html#aae31d1fadf0a0177919188f8b1f304800687      dbus_bool_t structLibHalVolume__s.html#aae31d1fadf0a0177919188f8b1f3048is_mounted ;
structLibHalVolume__s.html#c0acf7f0ccb1037b48da41feb4c2e92d00688      char * structLibHalVolume__s.html#c0acf7f0ccb1037b48da41feb4c2e92dmount_point ;  /* NULL iff !is_mounted */ structLibHalVolume__s.html#0dbd9a3a6eb646cac1fe321da682b07c00689      char * structLibHalVolume__s.html#0dbd9a3a6eb646cac1fe321da682b07cfstype ;       /* NULL iff !is_mounted or unknown */ structLibHalVolume__s.html#f64337e0ea60bdfb9e2c5359b7ad9bb400690      char * structLibHalVolume__s.html#f64337e0ea60bdfb9e2c5359b7ad9bb4fsversion ;
structLibHalVolume__s.html#fe456612918e6beb06df518ee73c320400691      char * structLibHalVolume__s.html#fe456612918e6beb06df518ee73c3204uuid ;
structLibHalVolume__s.html#2f0e5164ae83dfe1a5b316bedbe4fa7b00692      char * structLibHalVolume__s.html#2f0e5164ae83dfe1a5b316bedbe4fa7bstorage_device ;
00693 
structLibHalVolume__s.html#44b7aa64820b49d9de537f60d22adf3d00694      group__HAL.html#gf31f482209ec633b2edafcb7ff5628a7LibHalVolumeUsage  structLibHalVolume__s.html#44b7aa64820b49d9de537f60d22adf3dfsusage ;
00695 
structLibHalVolume__s.html#89e9bb9b7e1915454d165b128c4d5fd600696      dbus_bool_t structLibHalVolume__s.html#89e9bb9b7e1915454d165b128c4d5fd6is_partition ;
structLibHalVolume__s.html#4c11c9fb2596788704dcbd4d5b50b89c00697      unsigned int structLibHalVolume__s.html#4c11c9fb2596788704dcbd4d5b50b89cpartition_number ;
00698 
structLibHalVolume__s.html#d71e7b1b537b45642a7a5d0ffc7ac95200699      int structLibHalVolume__s.html#d71e7b1b537b45642a7a5d0ffc7ac952msdos_part_table_type ;
00700     
00701 
structLibHalVolume__s.html#75bedb79c35baaba3a13eb21b8605f4d00702      dbus_bool_t structLibHalVolume__s.html#75bedb79c35baaba3a13eb21b8605f4dis_disc ;
structLibHalVolume__s.html#c029194609af8e5ee37a781288ffd8af00703      group__HAL.html#gf63ab855e3c70a13982592c11179df13LibHalVolumeDiscType  structLibHalVolume__s.html#c029194609af8e5ee37a781288ffd8afdisc_type ;
structLibHalVolume__s.html#8a6cfd6ee0cf4b927276468ab83efcff00704      dbus_bool_t structLibHalVolume__s.html#8a6cfd6ee0cf4b927276468ab83efcffdisc_has_audio ;
structLibHalVolume__s.html#01e3747d648c3aa7c88621b7526b925400705      dbus_bool_t structLibHalVolume__s.html#01e3747d648c3aa7c88621b7526b9254disc_has_data ;
structLibHalVolume__s.html#14bf37e8effcd76865721dbcefe753f800706      dbus_bool_t structLibHalVolume__s.html#14bf37e8effcd76865721dbcefe753f8disc_is_appendable ;
structLibHalVolume__s.html#a0915ed37648778a279aba235de66bc500707      dbus_bool_t structLibHalVolume__s.html#a0915ed37648778a279aba235de66bc5disc_is_blank ;
structLibHalVolume__s.html#85e1052a7dad629b56fe9b8432bf6a8000708      dbus_bool_t structLibHalVolume__s.html#85e1052a7dad629b56fe9b8432bf6a80disc_is_rewritable ;
00709 
structLibHalVolume__s.html#9168d8253aa8c2f9e7044fc77d27f05a00710      unsigned int structLibHalVolume__s.html#9168d8253aa8c2f9e7044fc77d27f05ablock_size ;
structLibHalVolume__s.html#e4f3946ae27c07f6f0126382e458f4b100711      unsigned int structLibHalVolume__s.html#e4f3946ae27c07f6f0126382e458f4b1num_blocks ;
00712 
structLibHalVolume__s.html#47d4c09834e2919a03442e3e8075e11900713      char * structLibHalVolume__s.html#47d4c09834e2919a03442e3e8075e119desired_mount_point ;
structLibHalVolume__s.html#a968c86c5b80a9a874564f86a8bd9a8c00714      char * structLibHalVolume__s.html#a968c86c5b80a9a874564f86a8bd9a8cmount_filesystem ;
structLibHalVolume__s.html#69584160ee224acbb71cbac911f236db00715      dbus_bool_t structLibHalVolume__s.html#69584160ee224acbb71cbac911f236dbshould_mount ;
00716 
structLibHalVolume__s.html#b8a072cbbe78e08f4e65321137db32f100717      dbus_bool_t structLibHalVolume__s.html#b8a072cbbe78e08f4e65321137db32f1ignore_volume ;
00718 
00719 
structLibHalVolume__s.html#8a893f199c9b301067db72ad305c6b6000720      char structLibHalVolume__s.html#8a893f199c9b301067db72ad305c6b60mount_options [ group__LibHalStorage.html#g8679e1d7cfa6bcaf121b8432753098a6MOUNT_OPTIONS_SIZE ];
00721 };
00722 
00723 const char *
group__HAL.html#g2b75df3bf1eeb6f305aa4497eb2493a300724  group__LibHalStorage.html#g2b75df3bf1eeb6f305aa4497eb2493a3libhal_drive_get_dedicated_icon_drive  (LibHalDrive *drive)
00725 {
00726     return drive->dedicated_icon_drive;
00727 }
00728 
00729 const char *
group__HAL.html#g794d8fc439fb7107582f23538bf3ca3700730  group__LibHalStorage.html#g794d8fc439fb7107582f23538bf3ca37libhal_drive_get_dedicated_icon_volume  (LibHalDrive *drive)
00731 {
00732     return drive->dedicated_icon_volume;
00733 }
00734 
00739 void group__HAL.html#gd6ee3d38e9fca5e839223e30e2c8038600740  group__LibHalStorage.html#gd6ee3d38e9fca5e839223e30e2c80386libhal_drive_free  (LibHalDrive *drive)
00741 {
00742     if (drive == NULL )
00743         return;
00744 
00745     free (drive->udi);
00746     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (drive->device_file);
00747     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (drive->vendor);
00748     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (drive->model);
00749     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (drive->type_textual);
00750     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (drive->physical_device);
00751     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (drive->serial);
00752     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (drive->firmware_version);
00753     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (drive->desired_mount_point);
00754     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (drive->mount_filesystem);
00755     group__LibHal.html#g588e0fe84f2982df4d4e7e99254bcd87libhal_free_string_array  (drive->capabilities);
00756 }
00757 
00758 
00763 void group__HAL.html#g97a187ce66d55e08bb7701b8a89878d800764  group__LibHalStorage.html#g2bffc5c44798d5408b275c917c769638libhal_volume_free  (LibHalVolume *vol)
00765 {
00766     if (vol == NULL )
00767         return;
00768 
00769     free (vol->udi);
00770     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (vol->device_file);
00771     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (vol->volume_label);
00772     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (vol->fstype);
00773     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (vol->mount_point);
00774     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (vol->fsversion);
00775     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (vol->uuid);
00776     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (vol->desired_mount_point);
00777     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (vol->mount_filesystem);
00778 }
00779 
00780 
00781 static char **
group__LibHalStorage.html#g2e0e9bb9c870ac6b9b3e90c01679905700782  group__LibHalStorage.html#g2e0e9bb9c870ac6b9b3e90c016799057my_strvdup  (char **strv)
00783 {
00784     unsigned int num_elems;
00785     unsigned int i;
00786     char **res;
00787 
00788     for (num_elems = 0; strv[num_elems] != NULL; num_elems++)
00789         ;
00790 
00791     res = calloc (num_elems + 1, sizeof (char*));
00792     if (res == NULL)
00793         goto out;
00794 
00795     for (i = 0; i < num_elems; i++)
00796         res[i] = strdup (strv[i]);
00797     res[i] = NULL;
00798 
00799 out:
00800     return res;
00801 }
00802 
00803 /* ok, hey, so this is a bit ugly */ 00804 
group__LibHalStorage.html#g492ca82f01c8e9847ac6633fb8f8e6bb00805  #define LIBHAL_PROP_EXTRACT_BEGIN if (FALSE) group__LibHalStorage.html#gc82a8804c26042aa5c8ef64c3cc05ad600806  #define LIBHAL_PROP_EXTRACT_END ; group__LibHalStorage.html#g95cda9638158e6afe4cab9a7a1a42e4200807  #define LIBHAL_PROP_EXTRACT_INT(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_INT32) _where_ = libhal_psi_get_int (&it) group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bcca00808  #define LIBHAL_PROP_EXTRACT_STRING(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_STRING) _where_ = (libhal_psi_get_string (&it) != NULL && strlen (libhal_psi_get_string (&it)) > 0) ? strdup (libhal_psi_get_string (&it)) : NULL group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf0200809  #define LIBHAL_PROP_EXTRACT_BOOL(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_BOOLEAN) _where_ = libhal_psi_get_bool (&it) group__LibHalStorage.html#g9169d49dab46a1a389d0a9aefd6c17b900810  #define LIBHAL_PROP_EXTRACT_BOOL_BITFIELD(_property_, _where_, _field_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_BOOLEAN) _where_ |= libhal_psi_get_bool (&it) ? _field_ : 0 group__LibHalStorage.html#gc8da1e8887d6e9865f06cb5ff381bbf400811  #define LIBHAL_PROP_EXTRACT_STRLIST(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_STRLIST) _where_ = my_strvdup (libhal_psi_get_strlist (&it)) 00812 00821 LibHalDrive *
group__HAL.html#g565881a288a14cd501bc304390ee32f000822  group__LibHalStorage.html#g565881a288a14cd501bc304390ee32f0libhal_drive_from_udi  (LibHalContext *hal_ctx, const char *udi)
00823 {   
00824     char *bus_textual;
00825     LibHalDrive *drive;
00826     LibHalPropertySet *properties;
00827     LibHalPropertySetIterator it;
00828     DBusError error;
00829     unsigned int i;
00830 
00831     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
00832 
00833     drive = NULL;
00834     properties = NULL;
00835     bus_textual = NULL;
00836 
00837     dbus_error_init (&error);
00838     if (! group__LibHal.html#gd817c044708a4749a44d180bf36dc04flibhal_device_query_capability  (hal_ctx, udi, "storage", &error))
00839         goto error;
00840 
00841     drive = malloc (sizeof (LibHalDrive));
00842     if (drive == NULL)
00843         goto error;
00844     memset (drive, 0x00, sizeof (LibHalDrive));
00845 
00846     drive->hal_ctx = hal_ctx;
00847 
00848     drive->udi = strdup (udi);
00849     if (drive->udi == NULL)
00850         goto error;
00851 
00852     properties = group__LibHal.html#g5dbaa81c388a097396cc4e79866f5f45libhal_device_get_all_properties  (hal_ctx, udi, &error);
00853     if (properties == NULL)
00854         goto error;
00855 
00856     /* we can count on hal to give us all these properties */ 00857     for ( group__LibHal.html#gb754976b6dbe4cfea0d7a18024e3ae4flibhal_psi_init  (&it, properties); group__LibHal.html#g8c985761b2909c7bdc49e49a3020abc9libhal_psi_has_more  (&it); group__LibHal.html#g8e628cb8aac74bd4fd307c133dc3fa92libhal_psi_next  (&it)) {
00858         int type;
00859         char *key;
00860         
00861         type = group__LibHal.html#g3df57f4bddd14e70a9237ac5ea16e18flibhal_psi_get_type  (&it);
00862         key = group__LibHal.html#gad021d85a856bad5653a61c82ec0f639libhal_psi_get_key  (&it);
00863 
00864         group__LibHalStorage.html#g492ca82f01c8e9847ac6633fb8f8e6bbLIBHAL_PROP_EXTRACT_BEGIN ;
00865 
00866         group__LibHalStorage.html#g95cda9638158e6afe4cab9a7a1a42e42LIBHAL_PROP_EXTRACT_INT     ("block.minor",               drive->device_minor);
00867         group__LibHalStorage.html#g95cda9638158e6afe4cab9a7a1a42e42LIBHAL_PROP_EXTRACT_INT     ("block.major",               drive->device_major);
00868         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("block.device",              drive->device_file);
00869         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("storage.bus",               bus_textual);
00870         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("storage.vendor",            drive->vendor);
00871         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("storage.model",             drive->model);
00872         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("storage.drive_type",        drive->type_textual);
00873 
00874 
00875         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("storage.icon.drive",        drive->dedicated_icon_drive);
00876         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("storage.icon.volume",       drive->dedicated_icon_volume);
00877 
00878         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("storage.hotpluggable",      drive->is_hotpluggable);
00879         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("storage.removable",         drive->is_removable);
00880         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("storage.requires_eject",    drive->requires_eject);
00881 
00882         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("storage.physical_device",   drive->physical_device);
00883         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("storage.firmware_version",  drive->firmware_version);
00884         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("storage.serial",            drive->serial);
00885 
00886         group__LibHalStorage.html#g9169d49dab46a1a389d0a9aefd6c17b9LIBHAL_PROP_EXTRACT_BOOL_BITFIELD  ("storage.cdrom.cdr", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_CDR);
00887         group__LibHalStorage.html#g9169d49dab46a1a389d0a9aefd6c17b9LIBHAL_PROP_EXTRACT_BOOL_BITFIELD  ("storage.cdrom.cdrw", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_CDRW);
00888         group__LibHalStorage.html#g9169d49dab46a1a389d0a9aefd6c17b9LIBHAL_PROP_EXTRACT_BOOL_BITFIELD  ("storage.cdrom.dvd", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDROM);
00889         group__LibHalStorage.html#g9169d49dab46a1a389d0a9aefd6c17b9LIBHAL_PROP_EXTRACT_BOOL_BITFIELD  ("storage.cdrom.dvdplusr", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSR);
00890         group__LibHalStorage.html#g9169d49dab46a1a389d0a9aefd6c17b9LIBHAL_PROP_EXTRACT_BOOL_BITFIELD  ("storage.cdrom.dvdplusrw", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRW);
00891         group__LibHalStorage.html#g9169d49dab46a1a389d0a9aefd6c17b9LIBHAL_PROP_EXTRACT_BOOL_BITFIELD  ("storage.cdrom.dvdplusrwdl", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRWDL);
00892         group__LibHalStorage.html#g9169d49dab46a1a389d0a9aefd6c17b9LIBHAL_PROP_EXTRACT_BOOL_BITFIELD  ("storage.cdrom.dvdplusrdl", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRDL);
00893         group__LibHalStorage.html#g9169d49dab46a1a389d0a9aefd6c17b9LIBHAL_PROP_EXTRACT_BOOL_BITFIELD  ("storage.cdrom.dvdr", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDR);
00894         group__LibHalStorage.html#g9169d49dab46a1a389d0a9aefd6c17b9LIBHAL_PROP_EXTRACT_BOOL_BITFIELD  ("storage.cdrom.dvdrw", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDRW);
00895         group__LibHalStorage.html#g9169d49dab46a1a389d0a9aefd6c17b9LIBHAL_PROP_EXTRACT_BOOL_BITFIELD  ("storage.cdrom.dvdram", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDRAM);
00896 
00897         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("storage.policy.should_mount",        drive->should_mount);
00898         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("storage.policy.desired_mount_point", drive->desired_mount_point);
00899         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("storage.policy.mount_filesystem",    drive->mount_filesystem);
00900 
00901         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("storage.no_partitions_hint",        drive->no_partitions_hint);
00902 
00903         group__LibHalStorage.html#gc8da1e8887d6e9865f06cb5ff381bbf4LIBHAL_PROP_EXTRACT_STRLIST  ("info.capabilities",                drive->capabilities);
00904 
00905         group__LibHalStorage.html#gc82a8804c26042aa5c8ef64c3cc05ad6LIBHAL_PROP_EXTRACT_END ;
00906     }
00907 
00908     if (drive->type_textual != NULL) {
00909         if (strcmp (drive->type_textual, "cdrom") == 0) {
00910             drive->cdrom_caps |= LIBHAL_DRIVE_CDROM_CAPS_CDROM;
00911             drive->type = LIBHAL_DRIVE_TYPE_CDROM;
00912         } else if (strcmp (drive->type_textual, "floppy") == 0) {
00913             drive->type = LIBHAL_DRIVE_TYPE_FLOPPY;
00914         } else if (strcmp (drive->type_textual, "disk") == 0) {
00915             if (drive->is_removable)
00916                 drive->type = LIBHAL_DRIVE_TYPE_REMOVABLE_DISK;
00917             else 00918                 drive->type = LIBHAL_DRIVE_TYPE_DISK;               
00919         } else if (strcmp (drive->type_textual, "tape") == 0) {
00920             drive->type = LIBHAL_DRIVE_TYPE_TAPE;
00921         } else if (strcmp (drive->type_textual, "compact_flash") == 0) {
00922             drive->type = LIBHAL_DRIVE_TYPE_COMPACT_FLASH;
00923         } else if (strcmp (drive->type_textual, "memory_stick") == 0) {
00924             drive->type = LIBHAL_DRIVE_TYPE_MEMORY_STICK;
00925         } else if (strcmp (drive->type_textual, "smart_media") == 0) {
00926             drive->type = LIBHAL_DRIVE_TYPE_SMART_MEDIA;
00927         } else if (strcmp (drive->type_textual, "sd_mmc") == 0) {
00928             drive->type = LIBHAL_DRIVE_TYPE_SD_MMC;
00929         } else if (strcmp (drive->type_textual, "zip") == 0) {
00930             drive->type = LIBHAL_DRIVE_TYPE_ZIP;
00931         } else if (strcmp (drive->type_textual, "jaz") == 0) {
00932             drive->type = LIBHAL_DRIVE_TYPE_JAZ;
00933         } else if (strcmp (drive->type_textual, "flashkey") == 0) {
00934             drive->type = LIBHAL_DRIVE_TYPE_FLASHKEY;
00935         } else {
00936                 drive->type = LIBHAL_DRIVE_TYPE_DISK; 
00937         }
00938 
00939     }
00940 
00941     if (drive->capabilities != NULL) {
00942         for (i = 0; drive->capabilities[i] != NULL; i++) {
00943             if (strcmp (drive->capabilities[i], "portable_audio_player") == 0) {
00944                 drive->type = LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER;
00945                 break;
00946             } else if (strcmp (drive->capabilities[i], "camera") == 0) {
00947                 drive->type = LIBHAL_DRIVE_TYPE_CAMERA;
00948                 break;
00949             }
00950         }
00951     }
00952 
00953     if (bus_textual != NULL) {
00954         if (strcmp (bus_textual, "usb") == 0) {
00955             drive->bus = LIBHAL_DRIVE_BUS_USB;
00956         } else if (strcmp (bus_textual, "ieee1394") == 0) {
00957             drive->bus = LIBHAL_DRIVE_BUS_IEEE1394;
00958         } else if (strcmp (bus_textual, "ide") == 0) {
00959             drive->bus = LIBHAL_DRIVE_BUS_IDE;
00960         } else if (strcmp (bus_textual, "scsi") == 0) {
00961             drive->bus = LIBHAL_DRIVE_BUS_SCSI;
00962         } else if (strcmp (bus_textual, "ccw") == 0) {
00963             drive->bus = LIBHAL_DRIVE_BUS_CCW;
00964         }
00965     }
00966 
00967     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (bus_textual);
00968     group__LibHal.html#g22b659f4c4ae06779ed22ef32e510044libhal_free_property_set  (properties);
00969 
00970     return drive;
00971 
00972 error:
00973     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (bus_textual);
00974     group__LibHal.html#g22b659f4c4ae06779ed22ef32e510044libhal_free_property_set  (properties);
00975     group__LibHalStorage.html#gd6ee3d38e9fca5e839223e30e2c80386libhal_drive_free  (drive);
00976     return NULL;
00977 }
00978 
00979 const char *
group__HAL.html#g7b27ae9d1de6464a307bee373cbbafd200980  group__LibHalStorage.html#g7b27ae9d1de6464a307bee373cbbafd2libhal_volume_get_storage_device_udi  (LibHalVolume *volume)
00981 {
00982     return volume->storage_device;
00983 }
00984 
group__HAL.html#g02db6ba41e8f5f2646a35ede87c9190700985  const char * group__LibHalStorage.html#g02db6ba41e8f5f2646a35ede87c91907libhal_drive_get_physical_device_udi  (LibHalDrive *drive)
00986 {
00987     return drive->physical_device;
00988 }
00989 
00990 dbus_bool_t
group__HAL.html#gca8748ec53420ff1fe16af4c6b0ad05300991  group__LibHalStorage.html#gca8748ec53420ff1fe16af4c6b0ad053libhal_drive_requires_eject  (LibHalDrive *drive)
00992 {
00993     return drive->requires_eject;
00994 }
00995 
01004 LibHalVolume *
group__HAL.html#g4ba7fda60e041bd88dad2c2cea7cb86701005  group__LibHalStorage.html#g4ba7fda60e041bd88dad2c2cea7cb867libhal_volume_from_udi  (LibHalContext *hal_ctx, const char *udi)
01006 {
01007     char *disc_type_textual;
01008     char *vol_fsusage_textual;
01009     LibHalVolume *vol;
01010     LibHalPropertySet *properties;
01011     LibHalPropertySetIterator it;
01012     DBusError error;
01013 
01014     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01015 
01016     vol = NULL;
01017     properties = NULL;
01018     disc_type_textual = NULL;
01019     vol_fsusage_textual = NULL;
01020 
01021     dbus_error_init (&error);
01022     if (! group__LibHal.html#gd817c044708a4749a44d180bf36dc04flibhal_device_query_capability  (hal_ctx, udi, "volume", &error))
01023         goto error;
01024 
01025     vol = malloc (sizeof (LibHalVolume));
01026     if (vol == NULL)
01027         goto error;
01028     memset (vol, 0x00, sizeof (LibHalVolume));
01029 
01030     vol->udi = strdup (udi);
01031 
01032     properties = group__LibHal.html#g5dbaa81c388a097396cc4e79866f5f45libhal_device_get_all_properties  (hal_ctx, udi, &error);
01033     if (properties == NULL)
01034         goto error;
01035 
01036     /* we can count on hal to give us all these properties */ 01037     for ( group__LibHal.html#gb754976b6dbe4cfea0d7a18024e3ae4flibhal_psi_init  (&it, properties); group__LibHal.html#g8c985761b2909c7bdc49e49a3020abc9libhal_psi_has_more  (&it); group__LibHal.html#g8e628cb8aac74bd4fd307c133dc3fa92libhal_psi_next  (&it)) {
01038         int type;
01039         char *key;
01040         
01041         type = group__LibHal.html#g3df57f4bddd14e70a9237ac5ea16e18flibhal_psi_get_type  (&it);
01042         key = group__LibHal.html#gad021d85a856bad5653a61c82ec0f639libhal_psi_get_key  (&it);
01043 
01044         group__LibHalStorage.html#g492ca82f01c8e9847ac6633fb8f8e6bbLIBHAL_PROP_EXTRACT_BEGIN ;
01045 
01046         group__LibHalStorage.html#g95cda9638158e6afe4cab9a7a1a42e42LIBHAL_PROP_EXTRACT_INT     ("volume.partition.msdos_part_table_type", vol->msdos_part_table_type);
01047 
01048         group__LibHalStorage.html#g95cda9638158e6afe4cab9a7a1a42e42LIBHAL_PROP_EXTRACT_INT     ("block.minor",               vol->device_minor);
01049         group__LibHalStorage.html#g95cda9638158e6afe4cab9a7a1a42e42LIBHAL_PROP_EXTRACT_INT     ("block.major",               vol->device_major);
01050         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("block.device",              vol->device_file);
01051 
01052         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("block.storage_device",      vol->storage_device);
01053 
01054         group__LibHalStorage.html#g95cda9638158e6afe4cab9a7a1a42e42LIBHAL_PROP_EXTRACT_INT     ("volume.block_size",         vol->block_size);
01055         group__LibHalStorage.html#g95cda9638158e6afe4cab9a7a1a42e42LIBHAL_PROP_EXTRACT_INT     ("volume.num_blocks",         vol->num_blocks);
01056         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("volume.label",              vol->volume_label);
01057         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("volume.mount_point",        vol->mount_point);
01058         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("volume.fstype",             vol->fstype);
01059         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("volume.is_mounted",         vol->is_mounted);
01060         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("volume.fsusage",            vol_fsusage_textual);
01061 
01062         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("volume.ignore",             vol->ignore_volume);
01063 
01064         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("volume.is_disc",            vol->is_disc);
01065         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("volume.disc.type",          disc_type_textual);
01066         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("volume.disc.has_audio",     vol->disc_has_audio);
01067         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("volume.disc.has_data",      vol->disc_has_data);
01068         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("volume.disc.is_appendable", vol->disc_is_appendable);
01069         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("volume.disc.is_blank",      vol->disc_is_blank);
01070         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("volume.disc.is_rewritable", vol->disc_is_rewritable);
01071 
01072         group__LibHalStorage.html#g9c80c44930fb1ee2221b25e9ddffcf02LIBHAL_PROP_EXTRACT_BOOL    ("volume.policy.should_mount",        vol->should_mount);
01073         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("volume.policy.desired_mount_point", vol->desired_mount_point);
01074         group__LibHalStorage.html#g49764ec01272f8e3529a2aa790c4bccaLIBHAL_PROP_EXTRACT_STRING  ("volume.policy.mount_filesystem",    vol->mount_filesystem);
01075 
01076         group__LibHalStorage.html#gc82a8804c26042aa5c8ef64c3cc05ad6LIBHAL_PROP_EXTRACT_END ;
01077     }
01078 
01079     if (disc_type_textual != NULL) {
01080         if (strcmp (disc_type_textual, "cd_rom") == 0) {
01081             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_CDROM;
01082         } else if (strcmp (disc_type_textual, "cd_r") == 0) {
01083             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_CDR;
01084         } else if (strcmp (disc_type_textual, "cd_rw") == 0) {
01085             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_CDRW;
01086         } else if (strcmp (disc_type_textual, "dvd_rom") == 0) {
01087             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDROM;
01088         } else if (strcmp (disc_type_textual, "dvd_ram") == 0) {
01089             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDRAM;
01090         } else if (strcmp (disc_type_textual, "dvd_r") == 0) {
01091             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDR;
01092         } else if (strcmp (disc_type_textual, "dvd_rw") == 0) {
01093             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDRW;
01094         } else if (strcmp (disc_type_textual, "dvd_plus_r") == 0) {
01095             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR;
01096         } else if (strcmp (disc_type_textual, "dvd_plus_rw") == 0) {
01097             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW;
01098         } else if (strcmp (disc_type_textual, "dvd_plus_r_dl") == 0) {
01099             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR_DL;
01100         }
01101     }
01102 
01103     vol->fsusage = LIBHAL_VOLUME_USAGE_UNKNOWN;
01104     if (vol_fsusage_textual != NULL) {
01105         if (strcmp (vol_fsusage_textual, "filesystem") == 0) {
01106             vol->fsusage = LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM;
01107         } else if (strcmp (vol_fsusage_textual, "partitiontable") == 0) {
01108             vol->fsusage = LIBHAL_VOLUME_USAGE_PARTITION_TABLE;
01109         } else if (strcmp (vol_fsusage_textual, "raid") == 0) {
01110             vol->fsusage = LIBHAL_VOLUME_USAGE_RAID_MEMBER;
01111         } else if (strcmp (vol_fsusage_textual, "crypto") == 0) {
01112             vol->fsusage = LIBHAL_VOLUME_USAGE_CRYPTO;
01113         } else {
01114             vol->fsusage = LIBHAL_VOLUME_USAGE_UNKNOWN;
01115         } 
01116     }
01117 
01118     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (vol_fsusage_textual);
01119     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (disc_type_textual);
01120     group__LibHal.html#g22b659f4c4ae06779ed22ef32e510044libhal_free_property_set  (properties);
01121     return vol;
01122 error:
01123     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (vol_fsusage_textual);
01124     group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (disc_type_textual);
01125     group__LibHal.html#g22b659f4c4ae06779ed22ef32e510044libhal_free_property_set  (properties);
01126     group__LibHalStorage.html#g2bffc5c44798d5408b275c917c769638libhal_volume_free  (vol);
01127     return NULL;
01128 }
01129 
01130 
01139 int group__HAL.html#g4c705dcf8d6f4489e6cdbba1cae9a3b501140  group__LibHalStorage.html#g4c705dcf8d6f4489e6cdbba1cae9a3b5libhal_volume_get_msdos_part_table_type  (LibHalVolume *volume)
01141 {
01142     return volume->msdos_part_table_type;
01143 }
01144 
01145 /***********************************************************************/ 01146 
01154 LibHalDrive *
group__HAL.html#gd1cb32cf09989cfe790d1bdfdd8a178c01155  group__LibHalStorage.html#gd1cb32cf09989cfe790d1bdfdd8a178clibhal_drive_from_device_file  (LibHalContext *hal_ctx, const char *device_file)
01156 {
01157     int i;
01158     char **hal_udis;
01159     int num_hal_udis;
01160     LibHalDrive *result;
01161     char *found_udi;
01162     DBusError error;
01163 
01164     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01165 
01166     result = NULL;
01167     found_udi = NULL;
01168 
01169     dbus_error_init (&error);
01170     if ((hal_udis = group__LibHal.html#g06a613466c9e59ae7d5ba0406a031a3flibhal_manager_find_device_string_match  (hal_ctx, "block.device", 
01171                                  device_file, &num_hal_udis, &error)) == NULL)
01172         goto out;
01173 
01174     for (i = 0; i < num_hal_udis; i++) {
01175         char *udi;
01176         char *storage_udi;
01177         DBusError err1;
01178         DBusError err2;
01179         udi = hal_udis[i];
01180 
01181         dbus_error_init (&err1);
01182         dbus_error_init (&err2);
01183         if ( group__LibHal.html#gd817c044708a4749a44d180bf36dc04flibhal_device_query_capability  (hal_ctx, udi, "volume", &err1)) {
01184 
01185             storage_udi = group__LibHal.html#g066ef29ec76a3389801c7e5980737657libhal_device_get_property_string  (hal_ctx, udi, "block.storage_device", &err1);
01186             if (storage_udi == NULL)
01187                 continue;
01188             found_udi = strdup (storage_udi);
01189             group__LibHal.html#g848151fe424e9b88eb43bf097cc864a9libhal_free_string  (storage_udi);
01190             break;
01191         } else if ( group__LibHal.html#gd817c044708a4749a44d180bf36dc04flibhal_device_query_capability  (hal_ctx, udi, "storage", &err2)) {
01192             found_udi = strdup (udi);
01193         }
01194     }
01195 
01196     group__LibHal.html#g588e0fe84f2982df4d4e7e99254bcd87libhal_free_string_array  (hal_udis);
01197 
01198     if (found_udi != NULL)
01199         result = group__LibHalStorage.html#g565881a288a14cd501bc304390ee32f0libhal_drive_from_udi  (hal_ctx, found_udi);
01200 
01201     free (found_udi);
01202 out:
01203     return result;
01204 }
01205 
01206 
01213 LibHalVolume *
group__HAL.html#ge75baba44fa829969d0f4393a905a3ea01214  group__LibHalStorage.html#ge75baba44fa829969d0f4393a905a3ealibhal_volume_from_device_file  (LibHalContext *hal_ctx, const char *device_file)
01215 {
01216     int i;
01217     char **hal_udis;
01218     int num_hal_udis;
01219     LibHalVolume *result;
01220     char *found_udi;
01221     DBusError error;
01222 
01223     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01224 
01225     result = NULL;
01226     found_udi = NULL;
01227 
01228     dbus_error_init (&error);
01229     if ((hal_udis = group__LibHal.html#g06a613466c9e59ae7d5ba0406a031a3flibhal_manager_find_device_string_match  (hal_ctx, "block.device", 
01230                                  device_file, &num_hal_udis, &error)) == NULL)
01231         goto out;
01232 
01233     for (i = 0; i < num_hal_udis; i++) {
01234         char *udi;
01235         udi = hal_udis[i];
01236         if ( group__LibHal.html#gd817c044708a4749a44d180bf36dc04flibhal_device_query_capability  (hal_ctx, udi, "volume", &error)) {
01237             found_udi = strdup (udi);
01238             break;
01239         }
01240     }
01241 
01242     group__LibHal.html#g588e0fe84f2982df4d4e7e99254bcd87libhal_free_string_array  (hal_udis);
01243 
01244     if (found_udi != NULL)
01245         result = group__LibHalStorage.html#g4ba7fda60e041bd88dad2c2cea7cb867libhal_volume_from_udi  (hal_ctx, found_udi);
01246 
01247     free (found_udi);
01248 out:
01249     return result;
01250 }
01251 
01252 dbus_uint64_t
group__HAL.html#g40640d27b391a805ebad8d4dd3c09c0701253  group__LibHalStorage.html#g40640d27b391a805ebad8d4dd3c09c07libhal_volume_get_size  (LibHalVolume *volume)
01254 {
01255     return ((dbus_uint64_t)volume->block_size) * ((dbus_uint64_t)volume->num_blocks);
01256 }
01257 
01258 
01259 dbus_bool_t
group__HAL.html#g6670a3858fc3dc1772b1845f3f9d907901260  group__LibHalStorage.html#g6670a3858fc3dc1772b1845f3f9d9079libhal_drive_is_hotpluggable  (LibHalDrive *drive)
01261 {
01262     return drive->is_hotpluggable;
01263 }
01264 
01265 dbus_bool_t
group__HAL.html#ga73733c37c764263cd9c087b2920339101266  group__LibHalStorage.html#ga73733c37c764263cd9c087b29203391libhal_drive_uses_removable_media  (LibHalDrive *drive)
01267 {
01268     return drive->is_removable;
01269 }
01270 
01271 group__HAL.html#gc68e6cb3850c3cf3cbf25f25943f4327LibHalDriveType group__HAL.html#gb0d94240b118af162290d2f8b3d8769a01272  group__LibHalStorage.html#gb0d94240b118af162290d2f8b3d8769alibhal_drive_get_type  (LibHalDrive *drive)
01273 {
01274     return drive->type;
01275 }
01276 
01277 group__HAL.html#gf3deefc262e2d44adf65bf517b8e5b33LibHalDriveBus group__HAL.html#g2e777b14d4dd49c09bad933c6dae8b0101278  group__LibHalStorage.html#g2e777b14d4dd49c09bad933c6dae8b01libhal_drive_get_bus  (LibHalDrive *drive)
01279 {
01280     return drive->bus;
01281 }
01282 
01283 group__HAL.html#gf2bc93777748848615fa742b1e6dbdd8LibHalDriveCdromCaps group__HAL.html#g110790451c4fd7556de7d21f58eb4fda01284  group__LibHalStorage.html#g110790451c4fd7556de7d21f58eb4fdalibhal_drive_get_cdrom_caps  (LibHalDrive *drive)
01285 {
01286     return drive->cdrom_caps;
01287 }
01288 
01289 unsigned int group__HAL.html#g28e32ce2257160e3cd4e40997885995b01290  group__LibHalStorage.html#g28e32ce2257160e3cd4e40997885995blibhal_drive_get_device_major  (LibHalDrive *drive)
01291 {
01292     return drive->device_major;
01293 }
01294 
01295 unsigned int group__HAL.html#gcc53b1231fdcc854fc2e5bc0b264a5be01296  group__LibHalStorage.html#gcc53b1231fdcc854fc2e5bc0b264a5belibhal_drive_get_device_minor  (LibHalDrive *drive)
01297 {
01298     return drive->device_minor;
01299 }
01300 
01301 const char *
group__HAL.html#g4a539131f265f49dda7fbbf05ed3e01501302  group__LibHalStorage.html#g4a539131f265f49dda7fbbf05ed3e015libhal_drive_get_type_textual  (LibHalDrive *drive)
01303 {
01304     return drive->type_textual;
01305 }
01306 
01307 const char *
group__HAL.html#g7513b5aa162b741e7117d436cffe7f5c01308  group__LibHalStorage.html#g7513b5aa162b741e7117d436cffe7f5clibhal_drive_get_device_file  (LibHalDrive *drive)
01309 {
01310     return drive->device_file;
01311 }
01312 
01313 const char *
group__HAL.html#gfdc2e6897937086f9a9609b302e7788201314  group__LibHalStorage.html#gfdc2e6897937086f9a9609b302e77882libhal_drive_get_udi  (LibHalDrive *drive)
01315 {
01316     return drive->udi;
01317 }
01318 
01319 const char *
group__HAL.html#gb854282ad2ab3113e675c1e5c8ce260001320  group__LibHalStorage.html#gb854282ad2ab3113e675c1e5c8ce2600libhal_drive_get_serial  (LibHalDrive *drive)
01321 {
01322     return drive->serial;
01323 }
01324 
01325 const char *
group__HAL.html#gbbdac9ef8a9ce1e87522f4ecf25300ed01326  group__LibHalStorage.html#gbbdac9ef8a9ce1e87522f4ecf25300edlibhal_drive_get_firmware_version  (LibHalDrive *drive)
01327 {
01328     return drive->firmware_version;
01329 }
01330 
01331 const char *
group__HAL.html#gee172a56c64d682b281ca24edadfaa1d01332  group__LibHalStorage.html#gee172a56c64d682b281ca24edadfaa1dlibhal_drive_get_model  (LibHalDrive *drive)
01333 {
01334     return drive->model;
01335 }
01336 
01337 const char *
group__HAL.html#gde8e944f388952bfa60b25cd34c5692901338  group__LibHalStorage.html#gde8e944f388952bfa60b25cd34c56929libhal_drive_get_vendor  (LibHalDrive *drive)
01339 {
01340     return drive->vendor;
01341 }
01342 
01343 /*****************************************************************************/ 01344 
01345 const char *
group__HAL.html#g6171a8a0221f082238cbeecd300438ad01346  group__LibHalStorage.html#g6171a8a0221f082238cbeecd300438adlibhal_volume_get_udi  (LibHalVolume *volume)
01347 {
01348     return volume->udi;
01349 }
01350 
01351 const char *
group__HAL.html#g2b9d511863ad0e43448d948da81ba74f01352  group__LibHalStorage.html#g2b9d511863ad0e43448d948da81ba74flibhal_volume_get_device_file  (LibHalVolume *volume)
01353 {
01354     return volume->device_file;
01355 }
01356 
group__HAL.html#gbe31eab81ac1f28f755cd8d4b6cdc57501357  unsigned int group__LibHalStorage.html#gbe31eab81ac1f28f755cd8d4b6cdc575libhal_volume_get_device_major  (LibHalVolume *volume)
01358 {
01359     return volume->device_major;
01360 }
01361 
group__HAL.html#g416078c837ca341b60efafc036ad0be101362  unsigned int group__LibHalStorage.html#g416078c837ca341b60efafc036ad0be1libhal_volume_get_device_minor  (LibHalVolume *volume)
01363 {
01364     return volume->device_minor;
01365 }
01366 
01367 const char *
group__HAL.html#ga5e22676f2df3f4b02aacee00f42f34701368  group__LibHalStorage.html#ga5e22676f2df3f4b02aacee00f42f347libhal_volume_get_fstype  (LibHalVolume *volume)
01369 {
01370     return volume->fstype;
01371 }
01372 
01373 const char *
group__HAL.html#g1db11f6d36326253c7e20613b870591d01374  group__LibHalStorage.html#g1db11f6d36326253c7e20613b870591dlibhal_volume_get_fsversion  (LibHalVolume *volume)
01375 {
01376     return volume->fsversion;
01377 }
01378 
01379 group__HAL.html#gf31f482209ec633b2edafcb7ff5628a7LibHalVolumeUsage  
group__HAL.html#gb6650c31a5f04580cb762b546635a5a601380  group__LibHalStorage.html#gb6650c31a5f04580cb762b546635a5a6libhal_volume_get_fsusage  (LibHalVolume *volume)
01381 {
01382     return volume->fsusage;
01383 }
01384 
01385 dbus_bool_t 
group__HAL.html#g25f6c0775b48a57b45f6a06b1c60700601386  group__LibHalStorage.html#g25f6c0775b48a57b45f6a06b1c607006libhal_volume_is_mounted  (LibHalVolume *volume)
01387 {
01388     return volume->is_mounted;
01389 }
01390 
01391 dbus_bool_t 
group__HAL.html#g2c34bb9977bdbcb68a211a1a4da01da001392  group__LibHalStorage.html#g2c34bb9977bdbcb68a211a1a4da01da0libhal_volume_is_partition  (LibHalVolume *volume)
01393 {
01394     return volume->is_partition;
01395 }
01396 
01397 dbus_bool_t
group__HAL.html#g6ca65999bf7e2ab0d4c1021861190b6501398  group__LibHalStorage.html#g6ca65999bf7e2ab0d4c1021861190b65libhal_volume_is_disc  (LibHalVolume *volume)
01399 {
01400     return volume->is_disc;
01401 }
01402 
01403 unsigned int group__HAL.html#g527a822bcab58add44109dbea59718ba01404  group__LibHalStorage.html#g527a822bcab58add44109dbea59718balibhal_volume_get_partition_number  (LibHalVolume *volume)
01405 {
01406     return volume->partition_number;
01407 }
01408 
01409 const char *
group__HAL.html#g596fc8a057ec95c3012413b54e36b84701410  group__LibHalStorage.html#g596fc8a057ec95c3012413b54e36b847libhal_volume_get_label  (LibHalVolume *volume)
01411 {
01412     return volume->volume_label;
01413 }
01414 
01415 const char *
group__HAL.html#g11612b487cb110053cec837d8ccc7b6501416  group__LibHalStorage.html#g11612b487cb110053cec837d8ccc7b65libhal_volume_get_mount_point  (LibHalVolume *volume)
01417 {
01418     return volume->mount_point;
01419 }
01420 
01421 const char *
group__HAL.html#g4e83cd2ef4e926d3d02154d07d04311f01422  group__LibHalStorage.html#g4e83cd2ef4e926d3d02154d07d04311flibhal_volume_get_uuid  (LibHalVolume *volume)
01423 {
01424     return volume->uuid;
01425 }
01426 
01427 dbus_bool_t
group__HAL.html#gb29922e78dcdcd3f588d4285d7ab646001428  group__LibHalStorage.html#gb29922e78dcdcd3f588d4285d7ab6460libhal_volume_disc_has_audio  (LibHalVolume *volume)
01429 {
01430     return volume->disc_has_audio;
01431 }
01432 
01433 dbus_bool_t
group__HAL.html#g4cc4f1836c6d094c075b2de9e114ba4a01434  group__LibHalStorage.html#g4cc4f1836c6d094c075b2de9e114ba4alibhal_volume_disc_has_data  (LibHalVolume *volume)
01435 {
01436     return volume->disc_has_data;
01437 }
01438 
01439 dbus_bool_t
group__HAL.html#gebd31ba5682a0d17854e4ac74987304c01440  group__LibHalStorage.html#gebd31ba5682a0d17854e4ac74987304clibhal_volume_disc_is_blank  (LibHalVolume *volume)
01441 {
01442     return volume->disc_is_blank;
01443 }
01444 
01445 dbus_bool_t
group__HAL.html#g014064e936c70ca52151bd22dcbae07d01446  group__LibHalStorage.html#g014064e936c70ca52151bd22dcbae07dlibhal_volume_disc_is_rewritable  (LibHalVolume *volume)
01447 {
01448     return volume->disc_is_rewritable;
01449 }
01450 
01451 dbus_bool_t
group__HAL.html#g58ccd0490abac4f16aae8ca842f6ff9601452  group__LibHalStorage.html#g58ccd0490abac4f16aae8ca842f6ff96libhal_volume_disc_is_appendable  (LibHalVolume *volume)
01453 {
01454     return volume->disc_is_appendable;
01455 }
01456 
01457 group__HAL.html#gf63ab855e3c70a13982592c11179df13LibHalVolumeDiscType group__HAL.html#gc0e3c1e24e973a4eb2b4f41f4e99f58d01458  group__LibHalStorage.html#gc0e3c1e24e973a4eb2b4f41f4e99f58dlibhal_volume_get_disc_type  (LibHalVolume *volume)
01459 {
01460     return volume->disc_type;
01461 }
01462 
01463 dbus_bool_t
group__HAL.html#gb22ae2d519676d37736228110d826f6501464  group__LibHalStorage.html#gb22ae2d519676d37736228110d826f65libhal_volume_should_ignore  (LibHalVolume     *volume)
01465 {
01466     return volume->ignore_volume;
01467 }
01468 
01469 char ** 
group__HAL.html#g8faa6fd8e83fcb9ef2d72acacf615d3201470  group__LibHalStorage.html#g8faa6fd8e83fcb9ef2d72acacf615d32libhal_drive_find_all_volumes  (LibHalContext *hal_ctx, LibHalDrive *drive, int *num_volumes)
01471 {
01472     int i;
01473     char **udis;
01474     int num_udis;
01475     const char *drive_udi;
01476     char **result;
01477     DBusError error;
01478 
01479     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01480 
01481     udis = NULL;
01482     result = NULL;
01483     *num_volumes = 0;
01484 
01485     drive_udi = group__LibHalStorage.html#gfdc2e6897937086f9a9609b302e77882libhal_drive_get_udi  (drive);
01486     if (drive_udi == NULL)
01487         goto out;
01488 
01489     /* get initial list... */ 01490     dbus_error_init (&error);
01491     if ((udis = group__LibHal.html#g06a613466c9e59ae7d5ba0406a031a3flibhal_manager_find_device_string_match  (hal_ctx, "block.storage_device", 
01492                                  drive_udi, &num_udis, &error)) == NULL)
01493         goto out;
01494 
01495     result = malloc (sizeof (char *) * num_udis);
01496     if (result == NULL)
01497         goto out;
01498 
01499     /* ...and filter out the single UDI that is the drive itself */ 01500     for (i = 0; i < num_udis; i++) {
01501         if (strcmp (udis[i], drive_udi) == 0)
01502             continue;
01503         result[*num_volumes] = strdup (udis[i]);
01504         *num_volumes = (*num_volumes) + 1;
01505     }
01506     /* set last element (above removed UDI) to NULL for libhal_free_string_array()*/ 01507     result[*num_volumes] = NULL;
01508 
01509 out:
01510     group__LibHal.html#g588e0fe84f2982df4d4e7e99254bcd87libhal_free_string_array  (udis);
01511     return result;
01512 }
01513 
01514 /*************************************************************************/ 01515 
01516 char *
group__HAL.html#g5750ba139d44e5d4ef62ff552b8a965f01517  group__LibHalStorage.html#g5750ba139d44e5d4ef62ff552b8a965flibhal_drive_policy_default_get_mount_root  (LibHalContext *hal_ctx)
01518 {
01519     DBusError error;
01520 
01521     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01522 
01523     dbus_error_init (&error);
01524     return group__LibHal.html#g066ef29ec76a3389801c7e5980737657libhal_device_get_property_string  (hal_ctx, "/org/freedesktop/Hal/devices/computer",
01525                           "storage.policy.default.mount_root", &error);
01526 }
01527 
01528 dbus_bool_t
group__HAL.html#g5490161b194ac80339fea73ae728de7d01529  group__LibHalStorage.html#g5490161b194ac80339fea73ae728de7dlibhal_drive_policy_default_use_managed_keyword  (LibHalContext *hal_ctx)
01530 {
01531     DBusError error;
01532 
01533     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, FALSE);
01534 
01535     dbus_error_init (&error);
01536     return group__LibHal.html#ge8ebd0da6bf3112b522d92a5fe0fcc7flibhal_device_get_property_bool  (hal_ctx, "/org/freedesktop/Hal/devices/computer",
01537                         "storage.policy.default.use_managed_keyword", &error);
01538 }
01539 
01540 char *
group__HAL.html#g277d381335a48d63e1b904f8f7ec505a01541  group__LibHalStorage.html#g277d381335a48d63e1b904f8f7ec505alibhal_drive_policy_default_get_managed_keyword_primary  (LibHalContext *hal_ctx)
01542 {
01543     DBusError error;
01544 
01545     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01546 
01547     dbus_error_init (&error);
01548     return group__LibHal.html#g066ef29ec76a3389801c7e5980737657libhal_device_get_property_string  (hal_ctx, "/org/freedesktop/Hal/devices/computer",
01549                           "storage.policy.default.managed_keyword.primary", &error);
01550 }
01551 
01552 char *
group__HAL.html#g7e3fb06d2b98ac5f6c5b72aaea21fe0801553  group__LibHalStorage.html#g7e3fb06d2b98ac5f6c5b72aaea21fe08libhal_drive_policy_default_get_managed_keyword_secondary  (LibHalContext *hal_ctx)
01554 {
01555     DBusError error;
01556 
01557     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01558 
01559     dbus_error_init (&error);
01560     return group__LibHal.html#g066ef29ec76a3389801c7e5980737657libhal_device_get_property_string  (hal_ctx, "/org/freedesktop/Hal/devices/computer",
01561                           "storage.policy.default.managed_keyword.secondary", &error);
01562 }
01563 
01564 /*************************************************************************/ 01565 
01566 dbus_bool_t
group__HAL.html#gc93dec19ed148c4473c4cfb4baf8535701567  group__LibHalStorage.html#gc93dec19ed148c4473c4cfb4baf85357libhal_drive_policy_is_mountable  (LibHalDrive *drive, LibHalStoragePolicy *policy)
01568 {
01569     printf ("should_mount=%d, no_partitions_hint=%d\n", drive->should_mount, drive->no_partitions_hint);
01570 
01571     return drive->should_mount && drive->no_partitions_hint;
01572 }
01573 
01574 const char *
group__HAL.html#gd20ac9d32ba51edf49c7e30c8cd8f27501575  group__LibHalStorage.html#gd20ac9d32ba51edf49c7e30c8cd8f275libhal_drive_policy_get_desired_mount_point  (LibHalDrive *drive, LibHalStoragePolicy *policy)
01576 {
01577     return drive->desired_mount_point;
01578 }
01579 
01580 /* safely strcat() at most the remaining space in 'dst' */ group__LibHalStorage.html#g5725d6ace1f3304c1a14af079377f1a501581  #define strcat_len(dst, src, dstmaxlen) do {    \ 01582     dst[dstmaxlen - 1] = '\0'; \ 01583     strncat (dst, src, dstmaxlen - strlen (dst) - 1); \ 01584 } while(0) 01585 01586 
01587 static void group__LibHalStorage.html#g0a8c440fa7aafeb97fc63a45e869485a01588  group__LibHalStorage.html#g0a8c440fa7aafeb97fc63a45e869485amopts_collect  (LibHalContext *hal_ctx, const char *namespace, int namespace_len, 
01589            const char *udi, char *options_string, size_t options_max_len, dbus_bool_t only_collect_imply_opts)
01590 {
01591     LibHalPropertySet *properties;
01592     LibHalPropertySetIterator it;
01593     DBusError error;
01594 
01595     if(hal_ctx == 0) {
01596         fprintf (stderr,"%s %d : LibHalContext *ctx is NULL\n",__FILE__, __LINE__);
01597         return;
01598     }
01599 
01600     dbus_error_init (&error);
01601 
01602     /* first collect from root computer device */ 01603     properties = group__LibHal.html#g5dbaa81c388a097396cc4e79866f5f45libhal_device_get_all_properties  (hal_ctx, udi, &error);
01604     if (properties == NULL)
01605         goto error;
01606     for ( group__LibHal.html#gb754976b6dbe4cfea0d7a18024e3ae4flibhal_psi_init  (&it, properties); group__LibHal.html#g8c985761b2909c7bdc49e49a3020abc9libhal_psi_has_more  (&it); group__LibHal.html#g8e628cb8aac74bd4fd307c133dc3fa92libhal_psi_next  (&it)) {
01607         int type;
01608         char *key;
01609         
01610         type = group__LibHal.html#g3df57f4bddd14e70a9237ac5ea16e18flibhal_psi_get_type  (&it);
01611         key = group__LibHal.html#gad021d85a856bad5653a61c82ec0f639libhal_psi_get_key  (&it);
01612         if ( group__LibHal.html#g3df57f4bddd14e70a9237ac5ea16e18flibhal_psi_get_type  (&it) == group__LibHal.html#gg5e5a8a56bd7ac6141dd67fdefb14f0e6ddf1c8c88ff976b5440c73eea63edd47LIBHAL_PROPERTY_TYPE_BOOLEAN  &&
01613             strncmp (key, namespace, namespace_len - 1) == 0) {
01614             const char *option = key + namespace_len - 1;
01615             char *location;
01616             dbus_bool_t is_imply_opt;
01617 
01618             is_imply_opt = FALSE;
01619             if (strcmp (option, "user") == 0 ||
01620                 strcmp (option, "users") == 0 ||
01621                 strcmp (option, "defaults") == 0 ||
01622                 strcmp (option, "pamconsole") == 0)
01623                 is_imply_opt = TRUE;
01624 
01625             
01626             if (only_collect_imply_opts) {
01627                 if (!is_imply_opt)
01628                     continue;
01629             } else {
01630                 if (is_imply_opt)
01631                     continue;
01632             }
01633 
01634             if ( group__LibHal.html#gc4a14b72e53feef0a6fe809790c00e53libhal_psi_get_bool  (&it)) {
01635                 /* see if option is already there */ 01636                 location = strstr (options_string, option);
01637                 if (location == NULL) {
01638                     if (strlen (options_string) > 0)
01639                         group__LibHalStorage.html#g5725d6ace1f3304c1a14af079377f1a5strcat_len  (options_string, ",", options_max_len);
01640                     group__LibHalStorage.html#g5725d6ace1f3304c1a14af079377f1a5strcat_len  (options_string, option, options_max_len);
01641                 }
01642             } else {
01643                 /* remove option if already there */ 01644                 location = strstr (options_string, option);
01645                 if (location != NULL) {
01646                     char *end;
01647 
01648                     end = strchr (location, ',');
01649                     if (end == NULL) {
01650                         location[0] = '\0';
01651                     } else {
01652                         strcpy (location, end + 1); /* skip the extra comma */ 01653                     }
01654                 }
01655 
01656             }
01657         }
01658     }
01659 error:
01660     group__LibHal.html#g22b659f4c4ae06779ed22ef32e510044libhal_free_property_set  (properties);
01661 }
01662 
01663 
01664 const char *
group__HAL.html#ge764427b3d908c1302e2f8949c735d4201665  group__LibHalStorage.html#ge764427b3d908c1302e2f8949c735d42libhal_drive_policy_get_mount_options  (LibHalDrive *drive, LibHalStoragePolicy *policy)
01666 {
01667     const char *result;
01668     char stor_mount_option_default_begin[] = "storage.policy.default.mount_option.";
01669     char stor_mount_option_begin[] = "storage.policy.mount_option.";
01670 
01671     result = NULL;
01672     drive->mount_options[0] = '\0';
01673 
01674     /* collect options != ('pamconsole', 'user', 'users', 'defaults' options that imply other options)  */ 01675     group__LibHalStorage.html#g0a8c440fa7aafeb97fc63a45e869485amopts_collect  (drive->hal_ctx, stor_mount_option_default_begin, sizeof (stor_mount_option_default_begin),
01676                "/org/freedesktop/Hal/devices/computer", drive->mount_options, group__LibHalStorage.html#g8679e1d7cfa6bcaf121b8432753098a6MOUNT_OPTIONS_SIZE , TRUE);
01677     group__LibHalStorage.html#g0a8c440fa7aafeb97fc63a45e869485amopts_collect  (drive->hal_ctx, stor_mount_option_begin, sizeof (stor_mount_option_begin),
01678                drive->udi, drive->mount_options, group__LibHalStorage.html#g8679e1d7cfa6bcaf121b8432753098a6MOUNT_OPTIONS_SIZE , TRUE);
01679     /* ensure ('pamconsole', 'user', 'users', 'defaults' options that imply other options), are first */ 01680     group__LibHalStorage.html#g0a8c440fa7aafeb97fc63a45e869485amopts_collect  (drive->hal_ctx, stor_mount_option_default_begin, sizeof (stor_mount_option_default_begin),
01681                "/org/freedesktop/Hal/devices/computer", drive->mount_options, group__LibHalStorage.html#g8679e1d7cfa6bcaf121b8432753098a6MOUNT_OPTIONS_SIZE , FALSE);
01682     group__LibHalStorage.html#g0a8c440fa7aafeb97fc63a45e869485amopts_collect  (drive->hal_ctx, stor_mount_option_begin, sizeof (stor_mount_option_begin),
01683                drive->udi, drive->mount_options, group__LibHalStorage.html#g8679e1d7cfa6bcaf121b8432753098a6MOUNT_OPTIONS_SIZE , FALSE);
01684 
01685     result = drive->mount_options;
01686 
01687     return result;
01688 }
01689 
01690 const char *
group__HAL.html#g61cb58f69494b03455cfe057613bb56401691  group__LibHalStorage.html#g61cb58f69494b03455cfe057613bb564libhal_drive_policy_get_mount_fs  (LibHalDrive *drive, LibHalStoragePolicy *policy)
01692 {
01693     return drive->mount_filesystem;
01694 }
01695 
01696 
01697 dbus_bool_t
group__HAL.html#g33824282e4965b593d44df8dc803751b01698  group__LibHalStorage.html#g33824282e4965b593d44df8dc803751blibhal_volume_policy_is_mountable  (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
01699 {
01700     return drive->should_mount && volume->should_mount;
01701 }
01702 
group__HAL.html#ged09d82b973589c6408c3f3d8e80ad5201703  const char * group__LibHalStorage.html#ged09d82b973589c6408c3f3d8e80ad52libhal_volume_policy_get_desired_mount_point  (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
01704 {
01705     return volume->desired_mount_point;
01706 }
01707 
group__HAL.html#gfa94e5b9f7c20f58df82f52948c20d2801708  const char * group__LibHalStorage.html#gfa94e5b9f7c20f58df82f52948c20d28libhal_volume_policy_get_mount_options  (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
01709 {
01710     const char *result;
01711     char stor_mount_option_default_begin[] = "storage.policy.default.mount_option.";
01712     char vol_mount_option_begin[] = "volume.policy.mount_option.";
01713 
01714     result = NULL;
01715     volume->mount_options[0] = '\0';
01716 
01717     /* ensure ('pamconsole', 'user', 'users', 'defaults' options that imply other options), are first */ 01718     group__LibHalStorage.html#g0a8c440fa7aafeb97fc63a45e869485amopts_collect  (drive->hal_ctx, stor_mount_option_default_begin, sizeof (stor_mount_option_default_begin),
01719                "/org/freedesktop/Hal/devices/computer", volume->mount_options, group__LibHalStorage.html#g8679e1d7cfa6bcaf121b8432753098a6MOUNT_OPTIONS_SIZE , TRUE);
01720     group__LibHalStorage.html#g0a8c440fa7aafeb97fc63a45e869485amopts_collect  (drive->hal_ctx, vol_mount_option_begin, sizeof (vol_mount_option_begin),
01721                volume->udi, volume->mount_options, group__LibHalStorage.html#g8679e1d7cfa6bcaf121b8432753098a6MOUNT_OPTIONS_SIZE , TRUE);
01722     /* collect options != ('pamconsole', 'user', 'users', 'defaults' options that imply other options)  */ 01723     group__LibHalStorage.html#g0a8c440fa7aafeb97fc63a45e869485amopts_collect  (drive->hal_ctx, stor_mount_option_default_begin, sizeof (stor_mount_option_default_begin),
01724                "/org/freedesktop/Hal/devices/computer", volume->mount_options, group__LibHalStorage.html#g8679e1d7cfa6bcaf121b8432753098a6MOUNT_OPTIONS_SIZE , FALSE);
01725     group__LibHalStorage.html#g0a8c440fa7aafeb97fc63a45e869485amopts_collect  (drive->hal_ctx, vol_mount_option_begin, sizeof (vol_mount_option_begin),
01726                volume->udi, volume->mount_options, group__LibHalStorage.html#g8679e1d7cfa6bcaf121b8432753098a6MOUNT_OPTIONS_SIZE , FALSE);
01727 
01728     result = volume->mount_options;
01729 
01730     return result;
01731 }
01732 
group__HAL.html#g7d34ec1b21ae339379d85b8c261242b801733  const char * group__LibHalStorage.html#g7d34ec1b21ae339379d85b8c261242b8libhal_volume_policy_get_mount_fs  (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
01734 {
01735     return volume->mount_filesystem;
01736 }
01737 
01738 dbus_bool_t       
group__HAL.html#g26fcf0bd736db0002500b476e7a81bf301739  group__LibHalStorage.html#g26fcf0bd736db0002500b476e7a81bf3libhal_drive_no_partitions_hint  (LibHalDrive *drive)
01740 {
01741     return drive->no_partitions_hint;
01742 }
01743 
Generated on Tue May 2 08:40:16 2006 for HAL by 
http://www.doxygen.org/index.htmldoxygen  1.4.6 