Added set and get thread status message methods.

Added thread status message updates in set_devices().

svn path=/trunk/; revision=943
This commit is contained in:
Curtis Gedak 2008-10-30 18:50:38 +00:00
parent a622e6fefd
commit 2331bd0763
3 changed files with 31 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2008-10-30 Curtis Gedak <gedakc@gmail.com>
* include/GParted_Core.h,
src/GParted_Core.cc: Added set and get thread status message methods
- Added thread status message updates in set_devices()
2008-10-28 Curtis Gedak <gedakc@gmail.com>
* src/GParted_Core.cc: Remove std:: prefix from llabs()

View File

@ -51,10 +51,12 @@ public:
std::vector<Glib::ustring> get_all_mountpoints() ;
std::map<Glib::ustring, bool> get_available_flags( const Partition & partition ) ;
Glib::ustring get_libparted_version() ;
Glib::ustring get_thread_status_message() ;
private:
//detectionstuff..
void init_maps() ;
void set_thread_status_message( Glib::ustring msg ) ;
void read_mountpoints_from_file( const Glib::ustring & filename,
std::map< Glib::ustring, std::vector<Glib::ustring> > & map ) ;
std::vector<Glib::ustring> get_alternate_paths( const Glib::ustring & path ) ;
@ -70,7 +72,7 @@ private:
void set_used_sectors( std::vector<Partition> & partitions ) ;
void LP_set_used_sectors( Partition & partition );
void set_flags( Partition & partition ) ;
//operationstuff...
bool create( const Device & device, Partition & new_partition, OperationDetail & operationdetail ) ;
bool create_partition( Partition & new_partition, OperationDetail & operationdetail, Sector min_size = 0 ) ;
@ -185,6 +187,7 @@ private:
FS fs ;
std::vector<Glib::ustring> device_paths ;
bool probe_devices ;
Glib::ustring thread_status_message; //Used to pass data to show_pulsebar method
std::map< Glib::ustring, std::vector<Glib::ustring> > mount_info ;
std::map< Glib::ustring, std::vector<Glib::ustring> > fstab_info ;

View File

@ -58,6 +58,7 @@ GParted_Core::GParted_Core()
lp_disk = NULL ;
lp_partition = NULL ;
p_filesystem = NULL ;
set_thread_status_message("") ;
ped_exception_set_handler( ped_exception_handler ) ;
@ -170,12 +171,14 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
{
//try to have libparted detect the device and add it to the list
device = "/dev/" + device;
set_thread_status_message( String::ucompose ( _("Scanning %1 ..."), device ) ) ;
ped_device_get( device .c_str() ) ;
}
}
proc_partitions .close() ;
std::set<unsigned int> dm_majors;
//Try to find dev mapper devices
std::set<unsigned int> dm_majors;
std::ifstream proc_devices( "/proc/devices" ) ;
if ( proc_devices )
{
@ -215,6 +218,7 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
continue;
if ( dm_majors .find( major( st.st_rdev ) ) != dm_majors .end() )
//TODO avoid probing partition nodes for dmraid devices
set_thread_status_message( String::ucompose ( _("Scanning %1 ..."), mapper_name ) ) ;
ped_device_get( mapper_name .c_str() ) ;
}
closedir( mapper_dir ) ;
@ -233,6 +237,7 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
char * buf = static_cast<char *>( malloc( lp_device ->sector_size ) ) ;
if ( buf )
{
set_thread_status_message( String::ucompose ( _("Reading %1 ..."), lp_device ->path ) ) ;
if ( ped_device_open( lp_device ) )
{
if ( ped_device_read( lp_device, buf, 0, 1 ) )
@ -251,10 +256,11 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
for ( unsigned int t = 0 ; t < device_paths .size() ; t++ )
{
set_thread_status_message( String::ucompose ( _("Scanning %1 for partitions ..."), device_paths[ t ] ) ) ;
if ( open_device_and_disk( device_paths[ t ], false ) )
{
temp_device .Reset() ;
//device info..
temp_device .add_path( device_paths[ t ] ) ;
temp_device .add_paths( get_alternate_paths( temp_device .get_path() ) ) ;
@ -305,10 +311,22 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
//clear leftover information...
//NOTE that we cannot clear mountinfo since it might be needed in get_all_mountpoints()
set_thread_status_message("") ;
alternate_paths .clear() ;
fstab_info .clear() ;
}
void GParted_Core::set_thread_status_message( Glib::ustring msg )
{
//Remember to clear status message when finished with thread.
thread_status_message = msg ;
}
Glib::ustring GParted_Core::get_thread_status_message( )
{
return thread_status_message ;
}
bool GParted_Core::snap_to_cylinder( const Device & device, Partition & partition, Glib::ustring & error )
{
if ( ! partition .strict )