diff --git a/ChangeLog b/ChangeLog index bb6c61f6..9734795a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-01-19 Bart Hakvoort + + * added detailed progressfeedback. It still needs some polishing, but + is already far better then the old situation. And what's more, it's + finally threadsafe :p + 2006-01-11 Bart Hakvoort * configure.in: bumped version to 0.1 diff --git a/include/Dialog_Progress.h b/include/Dialog_Progress.h index 0b2d66e0..d7f8218f 100644 --- a/include/Dialog_Progress.h +++ b/include/Dialog_Progress.h @@ -20,15 +20,14 @@ #include "../include/i18n.h" #include "../include/Utils.h" +#include "../include/Operation.h" #include #include -#include -#include -#include -#include -#include +#include +#include #include +#include namespace GParted { @@ -36,30 +35,52 @@ namespace GParted class Dialog_Progress : public Gtk::Dialog { public: - Dialog_Progress( int count_operations, Glib::RefPtr textbuffer ); - ~Dialog_Progress( ); - - void Set_Operation( ); - - Glib::ustring current_operation; - int TIME_LEFT ; + Dialog_Progress( const std::vector & operations ) ; + ~Dialog_Progress(); + + sigc::signal< bool, Operation & > signal_apply_operation ; private: - bool Show_Progress( ) ; - bool Pulse( ) { progressbar_current .pulse( ) ; return true ; } - void tglbtn_details_toggled( ) ; + void update_operation_details( const Gtk::TreeRow & treerow, const OperationDetails & operation_details ) ; + void on_signal_show() ; + void thread_apply_operation( Operation * operation ) ; Gtk::Label label_current ; Gtk::ProgressBar progressbar_all, progressbar_current ; - Gtk::ToggleButton tglbtn_details ; - Gtk::TextView textview_details ; + Gtk::TreeView treeview_operations ; + Gtk::TreeRow treerow ; Gtk::ScrolledWindow scrolledwindow ; + Gtk::Expander expander_details ; - void signal_textbuffer_insert( const Gtk::TextBuffer::iterator & iter, const Glib::ustring & text, int ) ; + Glib::RefPtr icon_execute ; + Glib::RefPtr icon_succes ; + Glib::RefPtr icon_error ; + + Glib::RefPtr treestore_operations; - double fraction, fraction_current; - int count_operations, current_operation_number; - sigc::connection conn ; + struct treeview_operations_Columns : public Gtk::TreeModelColumnRecord + { + Gtk::TreeModelColumn operation_description; + Gtk::TreeModelColumn< Glib::RefPtr > operation_icon; + Gtk::TreeModelColumn< Glib::RefPtr > status_icon; + Gtk::TreeModelColumn hidden_status ; + + treeview_operations_Columns() + { + add( operation_description ); + add( operation_icon ); + add( status_icon ) ; + add( hidden_status ) ; + } + }; + treeview_operations_Columns treeview_operations_columns; + + std::vector operations ; + bool pulse, succes ; + Glib::Thread *thread ; + double fraction ; + unsigned int t ; + Glib::ustring str_temp ; }; }//GParted diff --git a/include/FileSystem.h b/include/FileSystem.h index 183dbddb..fb6565af 100644 --- a/include/FileSystem.h +++ b/include/FileSystem.h @@ -19,11 +19,8 @@ #ifndef DEFINE_FILESYSTEM #define DEFINE_FILESYSTEM -#include "../include/Partition.h" +#include "../include/Operation.h" -#include - -#include #include #include @@ -38,28 +35,29 @@ public: virtual FS get_filesystem_support() = 0 ; virtual void Set_Used_Sectors( Partition & partition ) = 0 ; - virtual bool Create( const Partition & new_partition ) = 0 ; - virtual bool Resize( const Partition & partition_new, bool fill_partition = false ) = 0 ; - virtual bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) = 0 ; - virtual bool Check_Repair( const Partition & partition ) = 0 ; - virtual int get_estimated_time( long MB_to_Consider ) = 0 ; - - Glib::RefPtr textbuffer ; + virtual bool Create( const Partition & new_partition, std::vector & operation_details ) = 0 ; + virtual bool Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition = false ) = 0 ; + virtual bool Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) = 0 ; + virtual bool Check_Repair( const Partition & partition, std::vector & operation_details ) = 0 ; long cylinder_size ; //see GParted_Core::Resize() protected: int Execute_Command( Glib::ustring command ) ; + int execute_command( std::vector argv, std::vector & operation_details ) ; //those are used in several Set_Used_Sectors().. std::vector argv, envp ; - std::string output ; + std::string output, error ; Sector N, S ; unsigned int index ; + int exit_status ; private: - void Update_Textview() ; - Glib::ustring cmd_output ; }; diff --git a/include/GParted_Core.h b/include/GParted_Core.h index 36b8572c..7a53a950 100644 --- a/include/GParted_Core.h +++ b/include/GParted_Core.h @@ -32,6 +32,7 @@ #include "../include/hfsplus.h" #include "../include/reiser4.h" +#include #include #include @@ -45,21 +46,25 @@ public: void find_supported_filesystems( ) ; void get_devices( std::vector & devices ) ; - int get_estimated_time( const Operation & operation ) ; - - void Apply_Operation_To_Disk( Operation & operation ); + bool apply_operation_to_disk( Operation & operation ); - bool Create( const Device & device, Partition & new_partition ) ; - bool format( const Partition & partition ) ; - bool Delete( const Partition & partition ) ; - bool Resize( const Device & device, const Partition & partition_old, const Partition & partition_new ) ; - bool Copy( const Glib::ustring & src_part_path, Partition & partition_dest ) ; + bool create( const Device & device, + Partition & new_partition, + std::vector & operation_details ) ; + bool format( const Partition & partition, std::vector & operation_details ) ; + bool Delete( const Partition & partition, std::vector & operation_details ) ; + bool resize( const Device & device, + const Partition & partition_old, + const Partition & partition_new, + std::vector & operation_detail ) ; + bool copy( const Glib::ustring & src_part_path, + Partition & partition_dest, + std::vector & operation_details ) ; bool Set_Disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ; - + const std::vector & get_filesystems( ) const ; const FS & get_fs( GParted::FILESYSTEM filesystem ) const ; - Glib::RefPtr get_textbuffer( ) ; std::vector get_disklabeltypes( ) ; private: @@ -73,13 +78,20 @@ private: Glib::ustring get_short_path( const Glib::ustring & real_path ) ; void LP_Set_Used_Sectors( Partition & partition ); Glib::ustring Get_Flags( ) ; - int Create_Empty_Partition( Partition & new_partition, bool copy = false ) ; - bool Resize_Container_Partition( const Partition & partition_old, const Partition & partition_new, bool fixed_start ) ; - bool Resize_Normal_Using_Libparted( const Partition & partition_old, const Partition & partition_new ) ; + int create_empty_partition( Partition & new_partition, + std::vector & operation_details, + bool copy = false ) ; + bool resize_container_partition( const Partition & partition_old, + const Partition & partition_new, + bool fixed_start, + std::vector & operation_details ) ; + bool resize_normal_using_libparted( const Partition & partition_old, + const Partition & partition_new, + std::vector & operation_detail ) ; - void Show_Error( Glib::ustring message ) ; void set_proper_filesystem( const FILESYSTEM & filesystem ) ; - bool set_partition_type( const Partition & partition ) ; + bool set_partition_type( const Partition & partition, + std::vector & operation_details ) ; bool wait_for_node( const Glib::ustring & node ) ; bool erase_filesystem_signatures( const Partition & partition ) ; @@ -88,8 +100,6 @@ private: void close_device_and_disk( ) ; bool commit( ) ; - Glib::RefPtr textbuffer; - std::vector FILESYSTEMS ; FileSystem * p_filesystem ; std::vector flags; diff --git a/include/Operation.h b/include/Operation.h index a2b1df0d..7e5f8bd4 100644 --- a/include/Operation.h +++ b/include/Operation.h @@ -18,11 +18,7 @@ #ifndef OPERATION #define OPERATION -#include "../include/Partition.h" #include "../include/Device.h" -#include "../include/i18n.h" - -#include namespace GParted { @@ -35,10 +31,37 @@ enum OperationType { COPY = 4 }; +struct OperationDetails +{ + enum Status { + NONE = -1, + EXECUTE = 0, + SUCCES = 1, + ERROR = 2 + }; + + OperationDetails() + { + status = EXECUTE ; + } + + OperationDetails( const Glib::ustring & description, Status status = EXECUTE ) + { + this ->description = description ; + this ->status = status ; + } + + Glib::ustring description ; + Status status ; + + std::vector sub_details ; +}; + class Operation { public: + Operation() ; Operation( const Device & device, const Partition &, const Partition &, OperationType ); //this one can be a little confusing, it *DOES NOT* change any visual representation. It only applies the operation to the list with partitions. @@ -48,10 +71,13 @@ public: //public variables Device device ; OperationType operationtype; + Glib::RefPtr operation_icon ; Partition partition_original; //the original situation Partition partition_new; //the new situation ( can be an whole new partition or simply the old one with a new size or.... ) Glib::ustring str_operation ; Glib::ustring copied_partition_path ; //for copy operation.. + + OperationDetails operation_details ; private: void Insert_Unallocated( std::vector & partitions, Sector start, Sector end, bool inside_extended ); diff --git a/include/Win_GParted.h b/include/Win_GParted.h index 3df0bc5a..4ad7ff7d 100644 --- a/include/Win_GParted.h +++ b/include/Win_GParted.h @@ -68,7 +68,7 @@ private: void Fill_Label_Device_Info( bool clear = false ); //overridden signalhandler - virtual bool on_delete_event( GdkEventAny* ) ; + bool on_delete_event( GdkEventAny* ) ; void Add_Operation( OperationType, const Partition & ); void Refresh_Visual( ); @@ -139,7 +139,7 @@ private: void on_partition_activated() ; void on_partition_popup_menu( unsigned int button, unsigned int time ) ; - bool max_amount_prim_reached( ) ; + bool max_amount_prim_reached() ; void activate_resize(); void activate_copy(); @@ -152,9 +152,8 @@ private: void activate_disable_swap() ; void activate_disklabel() ; - void activate_undo( ); - void activate_apply( ); - void apply_operations_thread( ); + void activate_undo(); + void activate_apply(); //private variables unsigned int current_device ; @@ -210,13 +209,11 @@ private: struct treeview_operations_Columns : public Gtk::TreeModelColumnRecord { - Gtk::TreeModelColumn operation_number; Gtk::TreeModelColumn operation_description; Gtk::TreeModelColumn< Glib::RefPtr > operation_icon; treeview_operations_Columns() { - add( operation_number ); add( operation_description ); add( operation_icon ); } @@ -235,11 +232,10 @@ private: std::vector device_info ; //stuff for progress overview and pulsebar - Dialog_Progress *dialog_progress; Glib::Thread *thread ; Glib::Dispatcher dispatcher; sigc::connection conn ; - bool apply, pulse ; + bool pulse ; }; } //GParted diff --git a/include/ext2.h b/include/ext2.h index 85e88f85..f3920c72 100644 --- a/include/ext2.h +++ b/include/ext2.h @@ -29,11 +29,14 @@ class ext2 : public FileSystem public: FS get_filesystem_support( ) ; void Set_Used_Sectors( Partition & partition ) ; - bool Create( const Partition & new_partition ) ; - bool Resize( const Partition & partition_new, bool fill_partition = false ) ; - bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; - bool Check_Repair( const Partition & partition ) ; - int get_estimated_time( long MB_to_Consider ) ; + bool Create( const Partition & new_partition, std::vector & operation_details ) ; + bool Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition = false ) ; + bool Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) ; + bool Check_Repair( const Partition & partition, std::vector & operation_details ) ; }; } //GParted diff --git a/include/ext3.h b/include/ext3.h index a025a37f..71193a49 100644 --- a/include/ext3.h +++ b/include/ext3.h @@ -29,11 +29,14 @@ class ext3 : public FileSystem public: FS get_filesystem_support( ) ; void Set_Used_Sectors( Partition & partition ) ; - bool Create( const Partition & new_partition ) ; - bool Resize( const Partition & partition_new, bool fill_partition = false ) ; - bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; - bool Check_Repair( const Partition & partition ) ; - int get_estimated_time( long MB_to_Consider ) ; + bool Create( const Partition & new_partition, std::vector & operation_details ) ; + bool Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition = false ) ; + bool Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) ; + bool Check_Repair( const Partition & partition, std::vector & operation_details ) ; }; diff --git a/include/fat16.h b/include/fat16.h index 9b501923..bf08d4db 100644 --- a/include/fat16.h +++ b/include/fat16.h @@ -29,12 +29,14 @@ class fat16 : public FileSystem public: FS get_filesystem_support( ) ; void Set_Used_Sectors( Partition & partition ) ; - bool Create( const Partition & new_partition ) ; - bool Resize( const Partition & partition_new, bool fill_partition = false ) ; - bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; - bool Check_Repair( const Partition & partition ) ; - int get_estimated_time( long MB_to_Consider ) ; - + bool Create( const Partition & new_partition, std::vector & operation_details ) ; + bool Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition = false ) ; + bool Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) ; + bool Check_Repair( const Partition & partition, std::vector & operation_details ) ; }; } //GParted diff --git a/include/fat32.h b/include/fat32.h index 2ad20d68..6160f214 100644 --- a/include/fat32.h +++ b/include/fat32.h @@ -29,11 +29,14 @@ class fat32 : public FileSystem public: FS get_filesystem_support( ); void Set_Used_Sectors( Partition & partition ) ; - bool Create( const Partition & new_partition ) ; - bool Resize( const Partition & partition_new, bool fill_partition = false ) ; - bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; - bool Check_Repair( const Partition & partition ) ; - int get_estimated_time( long MB_to_Consider ) ; + bool Create( const Partition & new_partition, std::vector & operation_details ) ; + bool Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition = false ) ; + bool Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) ; + bool Check_Repair( const Partition & partition, std::vector & operation_details ) ; }; } //GParted diff --git a/include/hfs.h b/include/hfs.h index 13b355f4..97cc5a2a 100644 --- a/include/hfs.h +++ b/include/hfs.h @@ -29,11 +29,14 @@ class hfs : public FileSystem public: FS get_filesystem_support( ) ; void Set_Used_Sectors( Partition & partition ) ; - bool Create( const Partition & new_partition ) ; - bool Resize( const Partition & partition_new, bool fill_partition = false ) ; - bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; - bool Check_Repair( const Partition & partition ) ; - int get_estimated_time( long MB_to_Consider ) ; + bool Create( const Partition & new_partition, std::vector & operation_details ) ; + bool Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition = false ) ; + bool Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) ; + bool Check_Repair( const Partition & partition, std::vector & operation_details ) ; }; } //GParted diff --git a/include/hfsplus.h b/include/hfsplus.h index 154ee4bd..3cc196dd 100644 --- a/include/hfsplus.h +++ b/include/hfsplus.h @@ -29,11 +29,14 @@ class hfsplus : public FileSystem public: FS get_filesystem_support( ) ; void Set_Used_Sectors( Partition & partition ) ; - bool Create( const Partition & new_partition ) ; - bool Resize( const Partition & partition_new, bool fill_partition = false ) ; - bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; - bool Check_Repair( const Partition & partition ) ; - int get_estimated_time( long MB_to_Consider ) ; + bool Create( const Partition & new_partition, std::vector & operation_details ) ; + bool Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition = false ) ; + bool Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) ; + bool Check_Repair( const Partition & partition, std::vector & operation_details ) ; }; } //GParted diff --git a/include/jfs.h b/include/jfs.h index f82c7909..28841a4f 100644 --- a/include/jfs.h +++ b/include/jfs.h @@ -29,11 +29,14 @@ class jfs : public FileSystem public: FS get_filesystem_support( ) ; void Set_Used_Sectors( Partition & partition ) ; - bool Create( const Partition & new_partition ) ; - bool Resize( const Partition & partition_new, bool fill_partition = false ) ; - bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; - bool Check_Repair( const Partition & partition ) ; - int get_estimated_time( long MB_to_Consider ) ; + bool Create( const Partition & new_partition, std::vector & operation_details ) ; + bool Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition = false ) ; + bool Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) ; + bool Check_Repair( const Partition & partition, std::vector & operation_details ) ; }; } //GParted diff --git a/include/linux_swap.h b/include/linux_swap.h index 14d26047..6dd2cd12 100644 --- a/include/linux_swap.h +++ b/include/linux_swap.h @@ -29,11 +29,14 @@ class linux_swap : public FileSystem public: FS get_filesystem_support( ) ; void Set_Used_Sectors( Partition & partition ) ; - bool Create( const Partition & new_partition ) ; - bool Resize( const Partition & partition_new, bool fill_partition = false ) ; - bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; - bool Check_Repair( const Partition & partition ) ; - int get_estimated_time( long MB_to_Consider ) ; + bool Create( const Partition & new_partition, std::vector & operation_details ) ; + bool Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition = false ) ; + bool Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) ; + bool Check_Repair( const Partition & partition, std::vector & operation_details ) ; }; } //GParted diff --git a/include/ntfs.h b/include/ntfs.h index aea0ea01..4d4a707d 100644 --- a/include/ntfs.h +++ b/include/ntfs.h @@ -29,11 +29,14 @@ class ntfs : public FileSystem public: FS get_filesystem_support( ) ; void Set_Used_Sectors( Partition & partition ) ; - bool Create( const Partition & new_partition ) ; - bool Resize( const Partition & partition_new, bool fill_partition = false ) ; - bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; - bool Check_Repair( const Partition & partition ) ; - int get_estimated_time( long MB_to_Consider ) ; + bool Create( const Partition & new_partition, std::vector & operation_details ) ; + bool Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition = false ) ; + bool Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) ; + bool Check_Repair( const Partition & partition, std::vector & operation_details ) ; }; } //GParted diff --git a/include/reiser4.h b/include/reiser4.h index 5934b3f1..0cbd19d1 100644 --- a/include/reiser4.h +++ b/include/reiser4.h @@ -29,11 +29,14 @@ class reiser4 : public FileSystem public: FS get_filesystem_support( ) ; void Set_Used_Sectors( Partition & partition ) ; - bool Create( const Partition & new_partition ) ; - bool Resize( const Partition & partition_new, bool fill_partition = false ) ; - bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; - bool Check_Repair( const Partition & partition ) ; - int get_estimated_time( long MB_to_Consider ) ; + bool Create( const Partition & new_partition, std::vector & operation_details ) ; + bool Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition = false ) ; + bool Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) ; + bool Check_Repair( const Partition & partition, std::vector & operation_details ) ; }; } //GParted diff --git a/include/reiserfs.h b/include/reiserfs.h index d3eb88a2..6c5975ef 100644 --- a/include/reiserfs.h +++ b/include/reiserfs.h @@ -29,11 +29,14 @@ class reiserfs : public FileSystem public: FS get_filesystem_support( ) ; void Set_Used_Sectors( Partition & partition ) ; - bool Create( const Partition & new_partition ) ; - bool Resize( const Partition & partition_new, bool fill_partition = false ) ; - bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; - bool Check_Repair( const Partition & partition ) ; - int get_estimated_time( long MB_to_Consider ) ; + bool Create( const Partition & new_partition, std::vector & operation_details ) ; + bool Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition = false ) ; + bool Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) ; + bool Check_Repair( const Partition & partition, std::vector & operation_details ) ; }; } //GParted diff --git a/include/xfs.h b/include/xfs.h index 3fec231b..34f4458a 100644 --- a/include/xfs.h +++ b/include/xfs.h @@ -27,13 +27,16 @@ namespace GParted class xfs : public FileSystem { public: - FS get_filesystem_support( ) ; + FS get_filesystem_support() ; void Set_Used_Sectors( Partition & partition ) ; - bool Create( const Partition & new_partition ) ; - bool Resize( const Partition & partition_new, bool fill_partition = false ) ; - bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; - bool Check_Repair( const Partition & partition ) ; - int get_estimated_time( long MB_to_Consider ) ; + bool Create( const Partition & new_partition, std::vector & operation_details ) ; + bool Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition = false ) ; + bool Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) ; + bool Check_Repair( const Partition & partition, std::vector & operation_details ) ; }; } //GParted diff --git a/src/Dialog_Progress.cc b/src/Dialog_Progress.cc index 77c450c6..af112503 100644 --- a/src/Dialog_Progress.cc +++ b/src/Dialog_Progress.cc @@ -16,123 +16,225 @@ */ #include "../include/Dialog_Progress.h" -#include + +#include +#include +#include + namespace GParted { -Dialog_Progress::Dialog_Progress( int count_operations, Glib::RefPtr textbuffer ) +Dialog_Progress::Dialog_Progress( const std::vector & operations ) { - this ->set_resizable( false ) ; this ->set_has_separator( false ) ; this ->set_title( _("Applying pending operations") ) ; - - this ->count_operations = count_operations ; - current_operation_number = 0 ; - fraction = 1.00 / count_operations ; + this ->operations = operations ; + succes = true ; + + fraction = 1.00 / operations .size() ; Glib::ustring str_temp = "" ; - str_temp += _( "Applying pending operations" ) ; + str_temp += _("Applying pending operations") ; str_temp += "\n\n" ; str_temp += _("Applying all listed operations.") ; str_temp += "\n"; - str_temp += _("Clicking Cancel will prevent the next operations from being applied.") ; + str_temp += _("Depending on the amount and type of operations this might take a long time.") ; str_temp += "\n"; - this ->get_vbox( ) ->pack_start( * Utils::mk_label( str_temp ), Gtk::PACK_SHRINK ); + this ->get_vbox() ->pack_start( * Utils::mk_label( str_temp ), Gtk::PACK_SHRINK ); + + this ->get_vbox() ->pack_start( * Utils::mk_label( "" + static_cast( _("Current Operation:") ) + "" ), Gtk::PACK_SHRINK ); progressbar_current .set_pulse_step( 0.01 ) ; - progressbar_current .set_size_request( 500, -1 ) ; - this->get_vbox( ) ->pack_start( progressbar_current, Gtk::PACK_SHRINK ); + this->get_vbox() ->pack_start( progressbar_current, Gtk::PACK_SHRINK ); label_current .set_alignment( Gtk::ALIGN_LEFT ); - this ->get_vbox( ) ->pack_start( label_current, Gtk::PACK_SHRINK ); + this ->get_vbox() ->pack_start( label_current, Gtk::PACK_SHRINK ); - textview_details .set_sensitive( false ) ; - textview_details .set_size_request( -1, 100 ) ; - textview_details .set_wrap_mode( Gtk::WRAP_WORD ) ; + this ->get_vbox() ->pack_start( * Utils::mk_label( "" + static_cast( _("Completed Operations:") ) + "" ), Gtk::PACK_SHRINK ); + progressbar_all .set_size_request( 500, -1 ) ; + this ->get_vbox() ->pack_start( progressbar_all, Gtk::PACK_SHRINK ); + + //create some icons here, instead of recreating them every time + icon_execute = render_icon( Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_LARGE_TOOLBAR ) ; + icon_succes = render_icon( Gtk::Stock::APPLY, Gtk::ICON_SIZE_LARGE_TOOLBAR ) ; + icon_error = render_icon( Gtk::Stock::DIALOG_ERROR, Gtk::ICON_SIZE_LARGE_TOOLBAR ) ; + + treestore_operations = Gtk::TreeStore::create( treeview_operations_columns ); + treeview_operations .set_model( treestore_operations ); + treeview_operations .set_headers_visible( false ); + treeview_operations .append_column( "", treeview_operations_columns .operation_icon ); + treeview_operations .append_column( "", treeview_operations_columns .operation_description ); + treeview_operations .append_column( "", treeview_operations_columns .status_icon ); + treeview_operations .set_size_request( -1, 250 ) ; + treeview_operations .set_rules_hint( true ) ; + + //fill 'er up + for ( unsigned int t = 0 ; t < operations .size() ; t++ ) + { + treerow = *( treestore_operations ->append() ); + treerow[ treeview_operations_columns .operation_icon ] = operations[ t ] .operation_icon ; + treerow[ treeview_operations_columns .operation_description ] = operations[ t ] .str_operation ; + + this ->operations[ t ] .operation_details .description = operations[ t ] .str_operation ; + } + + treeview_operations .get_column( 1 ) ->set_expand( true ) ; - textbuffer ->signal_insert( ) .connect( sigc::mem_fun( this, &Dialog_Progress::signal_textbuffer_insert ) ) ; - textview_details .set_buffer( textbuffer ) ; - scrolledwindow .set_shadow_type( Gtk::SHADOW_ETCHED_IN ) ; - scrolledwindow .set_policy( Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC ) ; - scrolledwindow .add( textview_details ) ; + scrolledwindow .set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ) ; + scrolledwindow .add( treeview_operations ) ; + + expander_details .set_label( "" + static_cast( _("Details") ) + "" ) ; + expander_details .set_use_markup( true ) ; + expander_details .add( scrolledwindow ) ; - this ->get_vbox( ) ->pack_start( scrolledwindow, Gtk::PACK_SHRINK ); - this ->get_vbox( ) ->pack_start( * Utils::mk_label( "\n" + static_cast( _( "Completed Operations" ) ) + ":" ), Gtk::PACK_SHRINK ); - this ->get_vbox( ) ->pack_start( progressbar_all, Gtk::PACK_SHRINK ); + this ->get_vbox() ->pack_start( expander_details, Gtk::PACK_EXPAND_WIDGET ); + this ->get_vbox() ->set_spacing( 5 ) ; - this ->get_vbox( ) ->set_spacing( 5 ) ; + this ->add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_NONE ) ; - tglbtn_details .set_label( _("Details") ) ; - tglbtn_details .signal_toggled( ) .connect( sigc::mem_fun( this, &Dialog_Progress::tglbtn_details_toggled ) ) ; - - this ->get_action_area( ) ->set_layout( Gtk::BUTTONBOX_EDGE ) ; - this ->get_action_area( ) ->pack_start( tglbtn_details ) ; - this ->add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL ); - - this ->show_all_children( ) ; - scrolledwindow .hide( ) ; + this ->signal_show() .connect( sigc::mem_fun(*this, &Dialog_Progress::on_signal_show) ); + this ->show_all_children() ; } -void Dialog_Progress::Set_Operation( ) +void Dialog_Progress::update_operation_details( const Gtk::TreeRow & treerow, + const OperationDetails & operation_details ) { - //all operations - if ( current_operation_number && (progressbar_all .get_fraction( ) + fraction) <= 1.0 ) - progressbar_all .set_fraction( progressbar_all .get_fraction( ) + fraction ); + Gtk::TreeRow treerow_child ; - progressbar_all .set_text( String::ucompose( _("%1 of %2 operations completed"), current_operation_number++, count_operations ) ) ; - - //new operation - conn .disconnect( ) ; - - label_current .set_markup( "" + current_operation + "" ) ; - - progressbar_current .set_fraction( 0 ); - progressbar_current .set_text( "initializing..." ); - - if ( TIME_LEFT > 0 ) + //append new rows (if any) + for ( unsigned int t = treerow .children() .size() ; t < operation_details .sub_details .size() ; t++ ) { - fraction_current = 1.00 / TIME_LEFT ; - conn = Glib::signal_timeout( ) .connect( sigc::mem_fun( *this, &Dialog_Progress::Show_Progress ), 1000 ); + treerow_child = *( treestore_operations ->append( treerow .children() ) ) ; + + treerow_child[ treeview_operations_columns .operation_description ] = + operation_details .sub_details[ t ] .description ; + + treerow_child[ treeview_operations_columns .hidden_status ] = OperationDetails::NONE ; } - else - conn = Glib::signal_timeout( ) .connect( sigc::mem_fun( *this, &Dialog_Progress::Pulse ), 10 ); -} -bool Dialog_Progress::Show_Progress( ) -{ - if ( (progressbar_current .get_fraction( ) + fraction_current) <= 1.0 ) + for ( unsigned int t = 0 ; t < operation_details .sub_details .size() ; t++ ) { - progressbar_current .set_fraction( progressbar_current .get_fraction( ) + fraction_current ); - - if ( TIME_LEFT > 59 && TIME_LEFT < 120 ) - progressbar_current .set_text( String::ucompose( _("about %1 minute and %2 seconds left"), TIME_LEFT/60, TIME_LEFT % 60 ) ) ; - else - progressbar_current .set_text( String::ucompose( _("about %1 minutes and %2 seconds left"), TIME_LEFT/60, TIME_LEFT % 60 ) ) ; + treerow_child = treerow .children()[ t ] ; + + if ( operation_details .sub_details[ t ] .status != treerow_child[ treeview_operations_columns .hidden_status ] ) + { + treerow_child[ treeview_operations_columns .hidden_status ] = + operation_details .sub_details[ t ] .status ; + + switch ( operation_details .sub_details[ t ] .status ) + { + case OperationDetails::EXECUTE: + treerow_child[ treeview_operations_columns .status_icon ] = icon_execute ; + + break ; + case OperationDetails::SUCCES: + treerow_child[ treeview_operations_columns .status_icon ] = icon_succes ; + + break ; + case OperationDetails::ERROR: + treerow_child[ treeview_operations_columns .status_icon ] = icon_error ; + + break ; + + default : + //plain, old-fashioned paranoia ;) + treerow_child[ treeview_operations_columns .hidden_status ] = + OperationDetails::NONE ; + break ; + } + } - TIME_LEFT-- ; + update_operation_details( treerow_child, operation_details .sub_details[ t ] ) ; } +} + +void Dialog_Progress::on_signal_show() +{ + for ( t = 0 ; t < operations .size() && succes ; t++ ) + { + label_current .set_markup( "" + operations[ t ] .str_operation + "" ) ; - return true ; + progressbar_all .set_text( String::ucompose( _("%1 of %2 operations completed"), t, operations .size() ) ) ; + progressbar_all .set_fraction( fraction * t ) ; + + static_cast( treestore_operations ->children()[ t ] ) + [ treeview_operations_columns .status_icon ] = icon_execute ; + treeview_operations .set_cursor( static_cast( treestore_operations ->children()[ t ] ) ) ; + + pulse = true ; + thread = Glib::Thread::create( sigc::bind( + sigc::mem_fun( *this, &Dialog_Progress::thread_apply_operation ), &( operations[ t ] ) ), true ); + + treerow = treestore_operations ->children()[ t ] ; + while ( pulse ) + { + update_operation_details( treerow, operations[ t ] .operation_details ) ; + + progressbar_current .pulse() ; + + while ( Gtk::Main::events_pending() ) + Gtk::Main::iteration(); + + usleep( 10000 ) ; + } + + thread ->join() ; + + //final updates for this operation + update_operation_details( treerow, operations[ t ] .operation_details ) ; + static_cast( treestore_operations ->children()[ t ] ) + [ treeview_operations_columns .status_icon ] = succes ? icon_succes : icon_error ; + } + + //replace 'cancel' with 'close' + std::vector children = this ->get_action_area() ->get_children() ; + this ->get_action_area() ->remove( * children .back() ) ; + this ->add_button( Gtk::Stock::CLOSE, Gtk::RESPONSE_OK ); + + //hide 'current operation' stuff + children = this ->get_vbox() ->get_children() ; + children[ 1 ] ->hide() ; + progressbar_current .hide() ; + label_current .hide() ; + + //deal with succes/error... + if ( succes ) + { + progressbar_all .set_text( _("All operations succesfully completed") ) ; + progressbar_all .set_fraction( 1.0 ) ; + } + else + { + progressbar_all .set_text( _("Not all operations were succesfully completed") ) ; + expander_details .set_expanded( true ) ; + + Gtk::MessageDialog dialog( *this, + _("An error occurred while applying the operations"), + false, + Gtk::MESSAGE_ERROR, + Gtk::BUTTONS_OK, + true ) ; + str_temp = _("The following operation could not be applied to disk:") ; + str_temp += "\n" ; + str_temp += label_current .get_text() ; + str_temp += "\n\n" ; + str_temp += _("See the details for more information") ; + + dialog .set_secondary_text( str_temp, true ) ; + dialog .run() ; + } } -void Dialog_Progress::tglbtn_details_toggled( ) +void Dialog_Progress::thread_apply_operation( Operation * operation ) { - if ( tglbtn_details .get_active( ) ) - scrolledwindow .show( ) ; - else - scrolledwindow .hide( ) ; -} + succes = signal_apply_operation .emit( *operation ) ; -void Dialog_Progress::signal_textbuffer_insert( const Gtk::TextBuffer::iterator & iter, const Glib::ustring & text, int ) -{ - Gtk::TextBuffer::iterator temp = iter ; - textview_details .scroll_to( temp, 0 ) ; + pulse = false ; } Dialog_Progress::~Dialog_Progress() { - conn .disconnect( ) ; } diff --git a/src/FileSystem.cc b/src/FileSystem.cc index 04dd6718..2469da57 100644 --- a/src/FileSystem.cc +++ b/src/FileSystem.cc @@ -21,21 +21,18 @@ namespace GParted { -FileSystem::FileSystem( ) +FileSystem::FileSystem() { cylinder_size = 0 ; } int FileSystem::Execute_Command( Glib::ustring command ) { - Glib::Dispatcher dispatcher; - sigc::connection conn = dispatcher .connect( sigc::mem_fun(*this, &FileSystem::Update_Textview) ); //stderr to stdout //command += " 2>&1" ; std::cout << command << std::endl ; cmd_output = command + "\n\n" ; - dispatcher ( ) ; char c_buf[ 512 ] ; FILE *f = popen( command .c_str( ), "r" ) ; @@ -44,20 +41,48 @@ int FileSystem::Execute_Command( Glib::ustring command ) { //output = Glib::locale_to_utf8( c_buf ) ; //std::cout << output << std::endl ; - //dispatcher ( ) ;disabled for the moment. Hier moet ik nog eens fris naar kijken. (anjuta had zo'n ingebouwde terminal, hoe deed die dat?? !!! } cmd_output = "" ; - dispatcher( ) ; return pclose( f ) ; } -void FileSystem::Update_Textview( ) -{ - //std::cout << output << std::endl; - textbuffer ->set_text( cmd_output ) ; - //textbuffer ->insert( textbuffer ->end( ), output ) ; +int FileSystem::execute_command( std::vector argv, std::vector & operation_details ) +{ + Glib::ustring temp ; + for ( unsigned int t = 0 ; t < argv .size() ; t++ ) + temp += argv[ t ] + " " ; + + operation_details .push_back( OperationDetails( temp, OperationDetails::NONE ) ) ; + + envp .clear() ; + envp .push_back( "LC_ALL=C" ) ; + + try + { + Glib::spawn_sync( ".", + argv, + envp, + Glib::SPAWN_SEARCH_PATH, + sigc::slot< void >(), + &output, + &error, + &exit_status ) ; + } + catch ( Glib::Exception & e ) + { + std::cout << e .what() << std::endl ; + return -1 ; + } + + if ( ! output .empty() ) + operation_details .back() .sub_details .push_back( OperationDetails( output, OperationDetails::NONE ) ) ; + + if ( ! error .empty() ) + operation_details .back() .sub_details .push_back( OperationDetails( error, OperationDetails::NONE ) ) ; + + return exit_status ; } } //GParted diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 1b91a7fe..9a81328a 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -11,7 +11,6 @@ GParted_Core::GParted_Core( ) lp_disk = NULL ; lp_partition = NULL ; p_filesystem = NULL ; - textbuffer = Gtk::TextBuffer::create( ) ; //get valid flags ... for ( PedPartitionFlag flag = ped_partition_flag_next( (PedPartitionFlag) NULL ) ; flag ; flag = ped_partition_flag_next( flag ) ) @@ -469,72 +468,45 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path, std::v } } -int GParted_Core::get_estimated_time( const Operation & operation ) -{ - switch ( operation .operationtype ) - { - case GParted::DELETE: - return 2 ; //i guess it'll never take more then 2 secs to delete a partition ;) - - case GParted::CREATE: - case GParted::FORMAT: - set_proper_filesystem( operation .partition_new .filesystem ) ; - if ( p_filesystem ) - return p_filesystem ->get_estimated_time( operation .partition_new .Get_Length_MB( ) ) ; - - break ; - - case GParted::RESIZE_MOVE: - set_proper_filesystem( operation .partition_new .filesystem ) ; - if ( p_filesystem ) - return p_filesystem ->get_estimated_time( std::abs( operation .partition_original .Get_Length_MB( ) - operation .partition_new .Get_Length_MB( ) ) ) ; - - break ; - - case GParted::COPY: - //lets take 10MB/s for the moment.. - return operation .partition_new .Get_Length_MB( ) / 10 ; - } - - return -1 ; //pulsing -} - -void GParted_Core::Apply_Operation_To_Disk( Operation & operation ) +bool GParted_Core::apply_operation_to_disk( Operation & operation ) { switch ( operation .operationtype ) { case DELETE: - if ( ! Delete( operation .partition_original ) ) - Show_Error( String::ucompose( _("Error while deleting %1"), operation .partition_original .partition ) ) ; - - break; + return Delete( operation .partition_original, operation .operation_details .sub_details ) ; case CREATE: - if ( ! Create( operation .device, operation .partition_new ) ) - Show_Error( String::ucompose( _("Error while creating %1"), operation .partition_new .partition ) ); - - break; + return create( operation .device, + operation .partition_new, + operation .operation_details .sub_details ) ; case RESIZE_MOVE: - if ( ! Resize( operation .device, operation .partition_original, operation .partition_new ) ) - Show_Error( String::ucompose( _("Error while resizing/moving %1"), operation .partition_new .partition ) ) ; - - break; + return resize( operation .device, + operation .partition_original, + operation .partition_new, + operation .operation_details .sub_details ) ; case FORMAT: - if ( ! format( operation .partition_new ) ) - Show_Error( String::ucompose( _("Error while formattting filesystem of %1"), operation .partition_new .partition ) ) ; - - break; - case COPY: - if ( ! Copy( operation .copied_partition_path, operation .partition_new ) ) - Show_Error( String::ucompose( _("Error while copying %1"), operation .partition_new .partition ) ) ; + return format( operation .partition_new, operation .operation_details .sub_details ) ; + case COPY: + return copy( operation .copied_partition_path, + operation .partition_new, + operation .operation_details .sub_details ) ; } + + return false ; } -bool GParted_Core::Create( const Device & device, Partition & new_partition ) +bool GParted_Core::create( const Device & device, + Partition & new_partition, + std::vector & operation_details ) { - if ( new_partition .type == GParted::TYPE_EXTENDED ) - return Create_Empty_Partition( new_partition ) ; - else if ( Create_Empty_Partition( new_partition, ( new_partition .Get_Length_MB( ) - device .cylsize ) < get_fs( new_partition .filesystem ) .MIN ) > 0 ) + if ( new_partition .type == GParted::TYPE_EXTENDED ) + { + return create_empty_partition( new_partition, operation_details ) ; + } + else if ( create_empty_partition( + new_partition, + operation_details, + ( new_partition .Get_Length_MB() - device .cylsize ) < get_fs( new_partition .filesystem ) .MIN ) > 0 ) { set_proper_filesystem( new_partition .filesystem ) ; @@ -542,24 +514,26 @@ bool GParted_Core::Create( const Device & device, Partition & new_partition ) //however in theory, it could also screw some errorhandling. if ( ! p_filesystem ) return true ; - - return set_partition_type( new_partition ) && p_filesystem ->Create( new_partition ) ; + + return set_partition_type( new_partition, operation_details ) && + p_filesystem ->Create( new_partition, operation_details ) ; } return false ; } -bool GParted_Core::format( const Partition & partition ) +bool GParted_Core::format( const Partition & partition, std::vector & operation_details ) { //remove all filesystem signatures... erase_filesystem_signatures( partition ) ; set_proper_filesystem( partition .filesystem ) ; - return set_partition_type( partition ) && p_filesystem ->Create( partition ) ; + return set_partition_type( partition, operation_details ) && + p_filesystem ->Create( partition, operation_details ) ; } -bool GParted_Core::Delete( const Partition & partition ) +bool GParted_Core::Delete( const Partition & partition, std::vector & operation_details ) { bool return_value = false ; @@ -579,54 +553,70 @@ bool GParted_Core::Delete( const Partition & partition ) return return_value ; } -bool GParted_Core::Resize( const Device & device, const Partition & partition_old, const Partition & partition_new ) +bool GParted_Core::resize( const Device & device, + const Partition & partition_old, + const Partition & partition_new, + std::vector & operation_details ) { if ( partition_old .type == GParted::TYPE_EXTENDED ) - return Resize_Container_Partition( partition_old, partition_new, false ) ; + return resize_container_partition( partition_old, partition_new, false, operation_details ) ; //lazy check (only grow). it's possbile one day this should be separated in checks for grow,shrink,move .. if ( get_fs( partition_old .filesystem ) .grow == GParted::FS::LIBPARTED ) - return Resize_Normal_Using_Libparted( partition_old, partition_new ) ; + return resize_normal_using_libparted( partition_old, partition_new, operation_details ) ; else //use custom resize tools.. { set_proper_filesystem( partition_new .filesystem ) ; - if ( p_filesystem ->Check_Repair( partition_new ) ) - { + if ( p_filesystem ->Check_Repair( partition_new, operation_details ) ) + {//FIXME hier moet betere errorchecking!! momenteel kan er iets fout gaan en wordt de operatie toch + //als geslaagd gerapporteerd. ik ben er groot voorstander van om alles weer te fixen mbv resize e.d. + //maar de status moet wel correct zijn! //shrinking - if ( partition_new .Get_Length_MB( ) < partition_old .Get_Length_MB( ) ) + if ( partition_new .Get_Length_MB() < partition_old .Get_Length_MB() ) { p_filesystem ->cylinder_size = device .cylsize ; - if ( p_filesystem ->Resize( partition_new ) ) - Resize_Container_Partition( partition_old, partition_new, ! get_fs( partition_new .filesystem ) .move ) ; + if ( p_filesystem ->Resize( partition_new, operation_details ) ) + resize_container_partition( + partition_old, + partition_new, + ! get_fs( partition_new .filesystem ) .move, + operation_details ) ; } //growing/moving else - Resize_Container_Partition( partition_old, partition_new, ! get_fs( partition_new .filesystem ) .move ) ; + resize_container_partition( + partition_old, + partition_new, + ! get_fs( partition_new .filesystem ) .move, + operation_details ) ; - p_filesystem ->Check_Repair( partition_new ) ; + p_filesystem ->Check_Repair( partition_new, operation_details ) ; - p_filesystem ->Resize( partition_new, true ) ; //expand filesystem to fit exactly in partition + //expand filesystem to fit exactly in partition + p_filesystem ->Resize( partition_new, operation_details, true ) ; - return p_filesystem ->Check_Repair( partition_new ) ; + return p_filesystem ->Check_Repair( partition_new, operation_details ) ; } } return false ; } -bool GParted_Core::Copy( const Glib::ustring & src_part_path, Partition & partition_dest ) +bool GParted_Core::copy( const Glib::ustring & src_part_path, + Partition & partition_dest, + std::vector & operation_details ) { set_proper_filesystem( partition_dest .filesystem ) ; Partition src_partition ; src_partition .partition = src_part_path ; - - if ( p_filesystem ->Check_Repair( src_partition ) ) - if ( Create_Empty_Partition( partition_dest, true ) > 0 ) - return p_filesystem ->Copy( src_part_path, partition_dest .partition ) ; +//FIXME set correct type of dest partition + if ( p_filesystem ->Check_Repair( src_partition, operation_details ) ) + if ( create_empty_partition( partition_dest, operation_details, true ) > 0 ) + return p_filesystem ->Copy( src_part_path, partition_dest .partition, operation_details ) ; return false ; } @@ -667,11 +657,6 @@ const FS & GParted_Core::get_fs( GParted::FILESYSTEM filesystem ) const return FILESYSTEMS .back( ) ; } -Glib::RefPtr GParted_Core::get_textbuffer( ) -{ - return textbuffer ; -} - std::vector GParted_Core::get_disklabeltypes( ) { std::vector disklabeltypes ; @@ -716,8 +701,12 @@ void GParted_Core::LP_Set_Used_Sectors( Partition & partition ) } } -int GParted_Core::Create_Empty_Partition( Partition & new_partition, bool copy ) +int GParted_Core::create_empty_partition( Partition & new_partition, + std::vector & operation_details, + bool copy ) { + operation_details .push_back( OperationDetails( _("create empty partition") ) ) ; + new_partition .partition_number = 0 ; if ( open_device_and_disk( new_partition .device_path ) ) @@ -782,13 +771,26 @@ int GParted_Core::Create_Empty_Partition( Partition & new_partition, bool copy ) erase_filesystem_signatures( new_partition ) ) ) + { + operation_details .back() .status = new_partition .partition_number > 0 ? + OperationDetails::SUCCES : OperationDetails::ERROR ; + return new_partition .partition_number ; + } else - return 0 ; + { + operation_details .back() .status = OperationDetails::ERROR ; + return 0 ; + } } -bool GParted_Core::Resize_Container_Partition( const Partition & partition_old, const Partition & partition_new, bool fixed_start ) +bool GParted_Core::resize_container_partition( const Partition & partition_old, + const Partition & partition_new, + bool fixed_start, + std::vector & operation_details ) { + operation_details .push_back( OperationDetails( _("resize partition") ) ) ; + bool return_value = false ; PedConstraint *constraint = NULL ; @@ -828,13 +830,25 @@ bool GParted_Core::Resize_Container_Partition( const Partition & partition_old, } if ( partition_old .type == GParted::TYPE_EXTENDED ) + { + operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ; return return_value ; + } else - return wait_for_node( partition_new .partition ) && return_value ; + { + return_value &= wait_for_node( partition_new .partition ) ; + operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ; + + return return_value ; + } } -bool GParted_Core::Resize_Normal_Using_Libparted( const Partition & partition_old, const Partition & partition_new ) +bool GParted_Core::resize_normal_using_libparted( const Partition & partition_old, + const Partition & partition_new, + std::vector & operation_details ) { + operation_details .push_back( OperationDetails( _("resize partition and filesystem using libparted") ) ) ; + bool return_value = false ; PedFileSystem *fs = NULL ; @@ -867,6 +881,7 @@ bool GParted_Core::Resize_Normal_Using_Libparted( const Partition & partition_ol close_device_and_disk( ) ; } + operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ; return return_value ; } @@ -881,17 +896,6 @@ Glib::ustring GParted_Core::Get_Flags( ) return temp ; } -void GParted_Core::Show_Error( Glib::ustring message ) -{ - message = "" + message + "\n\n" ; - message += _( "Be aware that the failure to apply this operation could affect other operations on the list." ) ; - Gtk::MessageDialog dialog( message ,true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true ); - - gdk_threads_enter( ); - dialog .run( ); - gdk_threads_leave( ); -} - void GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem ) { if ( p_filesystem ) @@ -914,14 +918,14 @@ void GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem ) default : p_filesystem = NULL ; } - - if ( p_filesystem ) - p_filesystem ->textbuffer = textbuffer ; } -bool GParted_Core::set_partition_type( const Partition & partition ) +bool GParted_Core::set_partition_type( const Partition & partition, + std::vector & operation_details ) { + operation_details .push_back( OperationDetails( _("set partitiontype") ) ) ; + bool return_value = false ; if ( open_device_and_disk( partition .device_path ) ) @@ -943,6 +947,7 @@ bool GParted_Core::set_partition_type( const Partition & partition ) close_device_and_disk( ) ; } + operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ; return return_value ; } diff --git a/src/Operation.cc b/src/Operation.cc index a340cfd4..a51ead9e 100644 --- a/src/Operation.cc +++ b/src/Operation.cc @@ -19,6 +19,10 @@ namespace GParted { +Operation::Operation() +{ +} + Operation::Operation( const Device & device, const Partition & partition_original, const Partition & partition_new, OperationType operationtype ) { this ->device = device ; diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index d41cc1c7..54186335 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -18,6 +18,7 @@ #include "../include/Win_GParted.h" #include +#include #include #include @@ -350,9 +351,8 @@ void Win_GParted::init_operationslist( ) liststore_operations = Gtk::ListStore::create( treeview_operations_columns ); treeview_operations .set_model( liststore_operations ); treeview_operations .set_headers_visible( false ); - treeview_operations .append_column( "", treeview_operations_columns .operation_number ); + treeview_operations .append_column( "", treeview_operations_columns .operation_icon ); treeview_operations .append_column( "", treeview_operations_columns .operation_description ); - treeview_operations .get_column( 0 ) ->pack_start( treeview_operations_columns .operation_icon, false ); treeview_operations .get_selection( ) ->set_mode( Gtk::SELECTION_NONE ); //init scrollwindow_operations @@ -497,6 +497,30 @@ void Win_GParted::Add_Operation( OperationType operationtype, const Partition & { Operation operation( devices[ current_device ], selected_partition, new_partition, operationtype ); + switch ( operationtype ) + { + case GParted::DELETE : + operation .operation_icon = + render_icon( Gtk::Stock::DELETE, Gtk::ICON_SIZE_MENU ); + break; + case GParted::CREATE : + operation .operation_icon = + render_icon( Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU ); + break; + case GParted::RESIZE_MOVE: + operation .operation_icon = + render_icon( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU ); + break; + case GParted::FORMAT : + operation .operation_icon = + render_icon( Gtk::Stock::CONVERT, Gtk::ICON_SIZE_MENU ); + break; + case GParted::COPY : + operation .operation_icon = + render_icon( Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU ); + break; + } + operations.push_back( operation ); allow_undo( true ); @@ -525,31 +549,8 @@ void Win_GParted::Refresh_Visual( ) operations[ t ] .Apply_Operation_To_Visual( partitions ) ; treerow = *( liststore_operations ->append() ); - treerow[ treeview_operations_columns .operation_number ] = t +1; treerow[ treeview_operations_columns .operation_description ] = operations[ t ] .str_operation ; - switch ( operations[ t ] .operationtype ) - { - case GParted::DELETE : - treerow[ treeview_operations_columns.operation_icon ] = - render_icon( Gtk::Stock::DELETE, Gtk::ICON_SIZE_MENU ); - break; - case GParted::CREATE : - treerow[ treeview_operations_columns.operation_icon ] = - render_icon( Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU ); - break; - case GParted::RESIZE_MOVE: - treerow[ treeview_operations_columns.operation_icon ] = - render_icon( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU ); - break; - case GParted::FORMAT : - treerow[ treeview_operations_columns.operation_icon ] = - render_icon( Gtk::Stock::CONVERT, Gtk::ICON_SIZE_MENU ); - break; - case GParted::COPY : - treerow[ treeview_operations_columns.operation_icon ] = - render_icon( Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU ); - break; - } + treerow[ treeview_operations_columns .operation_icon ] = operations[ t ] .operation_icon ; } //set new statusbartext @@ -1360,37 +1361,29 @@ void Win_GParted::activate_undo( ) void Win_GParted::activate_apply( ) { - str_temp = "" ; - str_temp += _( "Are you sure you want to apply the pending operations?" ) ; - str_temp += "\n\n" ; - str_temp += _( "It is recommended to backup valuable data before proceeding.") ; - - Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE, true ); + Gtk::MessageDialog dialog( *this, + _( "Are you sure you want to apply the pending operations?" ), + false, + Gtk::MESSAGE_WARNING, + Gtk::BUTTONS_NONE, + true ); + dialog .set_secondary_text( _( "It is recommended to backup valuable data before proceeding.") ) ; dialog .set_title( _( "Apply operations to harddisk" ) ); dialog .add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL ); dialog .add_button( Gtk::Stock::APPLY, Gtk::RESPONSE_OK ); - dialog .show_all_children( ) ; - if ( dialog.run( ) == Gtk::RESPONSE_OK ) + dialog .show_all_children() ; + if ( dialog.run() == Gtk::RESPONSE_OK ) { - dialog .hide( ) ; //hide confirmationdialog + dialog .hide() ; //hide confirmationdialog - apply = true; - dialog_progress = new Dialog_Progress ( operations .size( ), gparted_core .get_textbuffer( ) ) ; - - conn = dispatcher .connect( sigc::mem_fun(*dialog_progress, &Dialog_Progress::Set_Operation) ); - - thread = Glib::Thread::create( SigC::slot_class( *this, &Win_GParted::apply_operations_thread ), true ); - - dialog_progress ->set_transient_for( *this ); - while ( dialog_progress ->run( ) != Gtk::RESPONSE_OK ) - apply = false ;//finish current operation . then stop applying operations - - //after hiding the progressdialog - delete ( dialog_progress ) ; - thread ->join( ) ; - conn .disconnect( ) ; + Dialog_Progress dialog_progress( operations ) ; + dialog_progress .signal_apply_operation .connect( + sigc::mem_fun(gparted_core, &GParted_Core::apply_operation_to_disk) ) ; + + for ( ; dialog_progress .run() != Gtk::RESPONSE_OK ; ) {} + dialog_progress .hide() ; //find out if any of the involved devices is busy bool any_busy = false ; @@ -1411,35 +1404,20 @@ void Win_GParted::activate_apply( ) str_temp += _("Because making changes to a busy device may confuse the kernel, you are advised to reboot your computer.") ; Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true ); - dialog .run( ) ; + dialog .run() ; } //wipe operations... - operations.clear( ) ; - liststore_operations ->clear( ) ; - close_operationslist( ) ; + operations.clear() ; + liststore_operations ->clear() ; + close_operationslist() ; //reset new_count to 1 new_count = 1 ; //reread devices and their layouts... - menu_gparted_refresh_devices( ) ; + menu_gparted_refresh_devices() ; } } -void Win_GParted::apply_operations_thread( ) -{ - for ( unsigned int t = 0 ; t < operations .size( ) && apply ; t++ ) - { - dialog_progress ->current_operation = operations[ t ] .str_operation ; - dialog_progress ->TIME_LEFT = gparted_core .get_estimated_time( operations[ t ] ) ; - dispatcher( ) ; - - gparted_core .Apply_Operation_To_Disk( operations[ t ] ); - } - - dialog_progress ->response( Gtk::RESPONSE_OK ); -} - - } // GParted diff --git a/src/ext2.cc b/src/ext2.cc index 30a04f61..8ddfa0f3 100644 --- a/src/ext2.cc +++ b/src/ext2.cc @@ -15,7 +15,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "../include/ext2.h" namespace GParted @@ -80,43 +79,102 @@ void ext2::Set_Used_Sectors( Partition & partition ) partition .Set_Unused( N * S / 512 ) ; } -bool ext2::Create( const Partition & new_partition ) +bool ext2::Create( const Partition & new_partition, std::vector & operation_details ) { - return ! Execute_Command( "mkfs.ext2 " + new_partition .partition ) ; -} - -bool ext2::Resize( const Partition & partition_new, bool fill_partition ) -{ - Glib::ustring str_temp = "resize2fs " + partition_new .partition ; - - if ( ! fill_partition ) - str_temp += " " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ; - - return ! Execute_Command( str_temp ) ; -} - -bool ext2::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) -{ - if ( ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) + operation_details .push_back( OperationDetails( String::ucompose( + _("create new %1 filesystem"), + Utils::Get_Filesystem_String( GParted::FS_EXT2 ) ) ) ) ; + argv .clear() ; + argv .push_back( "mkfs.ext2" ) ; + argv .push_back( new_partition .partition ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } +} + +bool ext2::Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition ) +{ + if ( fill_partition ) + operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ; + else + operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ; + + argv .clear() ; + argv .push_back( "resize2fs" ) ; + argv .push_back( partition_new .partition ) ; + + if ( ! fill_partition ) + argv .push_back( Utils::num_to_str( partition_new .Get_Length_MB() - cylinder_size, true ) + "M" ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } +} + +bool ext2::Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) +{ + operation_details .push_back( OperationDetails( + String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ; + + argv .clear() ; + argv .push_back( "dd" ) ; + argv .push_back( "bs=8192" ) ; + argv .push_back( "if=" + src_part_path ) ; + argv .push_back( "of=" + dest_part_path ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + Partition partition ; partition .partition = dest_part_path ; - return Resize( partition, true ) ; + return Resize( partition, operation_details, true ) ; } + operation_details .back() .status = OperationDetails::ERROR ; return false ; } -bool ext2::Check_Repair( const Partition & partition ) +bool ext2::Check_Repair( const Partition & partition, std::vector & operation_details ) { - return Execute_Command( "e2fsck -fy " + partition .partition ) <= 1 ; -} - -int ext2::get_estimated_time( long MB_to_Consider ) -{ - return -1 ; -} + operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ; + argv .clear() ; + argv .push_back( "e2fsck" ) ; + argv .push_back( "-f" ) ; + argv .push_back( "-y" ) ; + argv .push_back( "-v" ) ; + argv .push_back( partition .partition ) ; + + if ( 1 >= execute_command( argv, operation_details .back() .sub_details ) >= 0 ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } +} } //GParted diff --git a/src/ext3.cc b/src/ext3.cc index e626cda9..43fde2dc 100644 --- a/src/ext3.cc +++ b/src/ext3.cc @@ -80,41 +80,101 @@ void ext3::Set_Used_Sectors( Partition & partition ) partition .Set_Unused( N * S / 512 ) ; } -bool ext3::Create( const Partition & new_partition ) +bool ext3::Create( const Partition & new_partition, std::vector & operation_details ) { - return ! Execute_Command( "mkfs.ext3 " + new_partition .partition ) ; -} - -bool ext3::Resize( const Partition & partition_new, bool fill_partition ) -{ - Glib::ustring str_temp = "resize2fs " + partition_new .partition ; - - if ( ! fill_partition ) - str_temp += " " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ; - - return ! Execute_Command( str_temp ) ; -} - -bool ext3::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) -{ - if ( ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) + operation_details .push_back( OperationDetails( String::ucompose( + _("create new %1 filesystem"), + Utils::Get_Filesystem_String( GParted::FS_EXT3 ) ) ) ) ; + argv .clear() ; + argv .push_back( "mkfs.ext3" ) ; + argv .push_back( new_partition .partition ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } +} + +bool ext3::Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition ) +{ + if ( fill_partition ) + operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ; + else + operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ; + + argv .clear() ; + argv .push_back( "resize2fs" ) ; + argv .push_back( partition_new .partition ) ; + + if ( ! fill_partition ) + argv .push_back( Utils::num_to_str( partition_new .Get_Length_MB() - cylinder_size, true ) + "M" ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } +} + +bool ext3::Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) +{ + operation_details .push_back( OperationDetails( + String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ; + + argv .clear() ; + argv .push_back( "dd" ) ; + argv .push_back( "bs=8192" ) ; + argv .push_back( "if=" + src_part_path ) ; + argv .push_back( "of=" + dest_part_path ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + Partition partition ; partition .partition = dest_part_path ; - return Resize( partition, true ) ; + return Resize( partition, operation_details, true ) ; } + operation_details .back() .status = OperationDetails::ERROR ; return false ; } -bool ext3::Check_Repair( const Partition & partition ) +bool ext3::Check_Repair( const Partition & partition, std::vector & operation_details ) { - return Execute_Command( "e2fsck -fy " + partition .partition ) <= 1 ; -} + operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ; + + argv .clear() ; + argv .push_back( "e2fsck" ) ; + argv .push_back( "-f" ) ; + argv .push_back( "-y" ) ; + argv .push_back( "-v" ) ; + argv .push_back( partition .partition ) ; -int ext3::get_estimated_time( long MB_to_Consider ) -{ - return -1 ; + if ( 1 >= execute_command( argv, operation_details .back() .sub_details ) >= 0 ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } } //GParted diff --git a/src/fat16.cc b/src/fat16.cc index df26b8c5..0169e21a 100644 --- a/src/fat16.cc +++ b/src/fat16.cc @@ -54,6 +54,7 @@ FS fat16::get_filesystem_support( ) void fat16::Set_Used_Sectors( Partition & partition ) { argv .push_back( "dosfsck" ) ; + argv .push_back( "-a" ) ; argv .push_back( "-v" ) ; argv .push_back( partition .partition ) ; @@ -85,32 +86,84 @@ void fat16::Set_Used_Sectors( Partition & partition ) partition .Set_Unused( N * S / 512 ) ; } -bool fat16::Create( const Partition & new_partition ) +bool fat16::Create( const Partition & new_partition, std::vector & operation_details ) { - return ! Execute_Command( "mkdosfs -F16 " + new_partition .partition ) ; + operation_details .push_back( OperationDetails( String::ucompose( + _("create new %1 filesystem"), + Utils::Get_Filesystem_String( GParted::FS_FAT16 ) ) ) ) ; + argv .clear() ; + argv .push_back( "mkdosfs" ) ; + argv .push_back( "-F16" ) ; + argv .push_back( "-v" ) ; + argv .push_back( new_partition .partition ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -bool fat16::Resize( const Partition & partition_new, bool fill_partition ) +bool fat16::Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition ) { - //handled in GParted_Core::Resize_Normal_Using_Libparted + //handled in GParted_Core::resize_normal_using_libparted return false ; } -bool fat16::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) +bool fat16::Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) { - return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; -} - -bool fat16::Check_Repair( const Partition & partition ) -{ - return ! Execute_Command( "dosfsck -aw " + partition .partition ) ; -} - -int fat16::get_estimated_time( long MB_to_Consider ) -{ - return -1 ; -} + operation_details .push_back( OperationDetails( + String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ; + argv .clear() ; + argv .push_back( "dd" ) ; + argv .push_back( "bs=8192" ) ; + argv .push_back( "if=" + src_part_path ) ; + argv .push_back( "of=" + dest_part_path ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } +} + +bool fat16::Check_Repair( const Partition & partition, std::vector & operation_details ) +{ + operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ; + + argv .clear() ; + argv .push_back( "dosfsck" ) ; + argv .push_back( "-a" ) ; + argv .push_back( "-w" ) ; + argv .push_back( "-v" ) ; + argv .push_back( partition .partition ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } +} + } //GParted diff --git a/src/fat32.cc b/src/fat32.cc index 459f1437..046c011f 100644 --- a/src/fat32.cc +++ b/src/fat32.cc @@ -53,6 +53,7 @@ FS fat32::get_filesystem_support( ) void fat32::Set_Used_Sectors( Partition & partition ) { argv .push_back( "dosfsck" ) ; + argv .push_back( "-a" ) ; argv .push_back( "-v" ) ; argv .push_back( partition .partition ) ; @@ -84,33 +85,82 @@ void fat32::Set_Used_Sectors( Partition & partition ) partition .Set_Unused( N * S / 512 ) ; } -bool fat32::Create( const Partition & new_partition ) +bool fat32::Create( const Partition & new_partition, std::vector & operation_details ) { - return ! Execute_Command( "mkdosfs -F32 " + new_partition .partition ) ; + operation_details .push_back( OperationDetails( String::ucompose( + _("create new %1 filesystem"), + Utils::Get_Filesystem_String( GParted::FS_FAT32 ) ) ) ) ; + argv .clear() ; + argv .push_back( "mkdosfs" ) ; + argv .push_back( "-F32" ) ; + argv .push_back( "-v" ) ; + argv .push_back( new_partition .partition ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -bool fat32::Resize( const Partition & partition_new, bool fill_partition ) +bool fat32::Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition ) { //handled in GParted_Core::Resize_Normal_Using_Libparted return false ; } -bool fat32::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) +bool fat32::Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) { - return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; -} - -bool fat32::Check_Repair( const Partition & partition ) -{ - return ! Execute_Command( "dosfsck -aw " + partition .partition ) ; -} - -int fat32::get_estimated_time( long MB_to_Consider ) -{ - return -1 ; -} - + operation_details .push_back( OperationDetails( + String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ; + argv .clear() ; + argv .push_back( "dd" ) ; + argv .push_back( "bs=8192" ) ; + argv .push_back( "if=" + src_part_path ) ; + argv .push_back( "of=" + dest_part_path ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } +} + +bool fat32::Check_Repair( const Partition & partition, std::vector & operation_details ) +{ + operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ; + + argv .clear() ; + argv .push_back( "dosfsck" ) ; + argv .push_back( "-a" ) ; + argv .push_back( "-w" ) ; + argv .push_back( "-v" ) ; + argv .push_back( partition .partition ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } +} } //GParted diff --git a/src/hfs.cc b/src/hfs.cc index 4cea50bf..84421045 100644 --- a/src/hfs.cc +++ b/src/hfs.cc @@ -44,31 +44,62 @@ void hfs::Set_Used_Sectors( Partition & partition ) { } -bool hfs::Create( const Partition & new_partition ) +bool hfs::Create( const Partition & new_partition, std::vector & operation_details ) { - return ! Execute_Command( "hformat " + new_partition .partition ) ; + operation_details .push_back( OperationDetails( String::ucompose( + _("create new %1 filesystem"), + Utils::Get_Filesystem_String( GParted::FS_HFS ) ) ) ) ; + argv .clear() ; + argv .push_back( "hformat" ) ; + argv .push_back( new_partition .partition ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -bool hfs::Resize( const Partition & partition_new, bool fill_partition ) +bool hfs::Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition ) { return true ; } -bool hfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) +bool hfs::Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) { - return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; -} - -bool hfs::Check_Repair( const Partition & partition ) -{ - return true ; -} - -int hfs::get_estimated_time( long MB_to_Consider ) -{ - return -1 ; -} + operation_details .push_back( OperationDetails( + String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ; + argv .clear() ; + argv .push_back( "dd" ) ; + argv .push_back( "bs=8192" ) ; + argv .push_back( "if=" + src_part_path ) ; + argv .push_back( "of=" + dest_part_path ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } +} + +bool hfs::Check_Repair( const Partition & partition, std::vector & operation_details ) +{ + return true ; +} } //GParted diff --git a/src/hfsplus.cc b/src/hfsplus.cc index 3ad5a685..9681d7fd 100644 --- a/src/hfsplus.cc +++ b/src/hfsplus.cc @@ -36,32 +36,30 @@ void hfsplus::Set_Used_Sectors( Partition & partition ) { } -bool hfsplus::Create( const Partition & new_partition ) +bool hfsplus::Create( const Partition & new_partition, std::vector & operation_details ) { return true ; } -bool hfsplus::Resize( const Partition & partition_new, bool fill_partition ) +bool hfsplus::Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition ) { return true ; } -bool hfsplus::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) +bool hfsplus::Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) { return true ; } -bool hfsplus::Check_Repair( const Partition & partition ) +bool hfsplus::Check_Repair( const Partition & partition, std::vector & operation_details ) { return true ; } -int hfsplus::get_estimated_time( long MB_to_Consider ) -{ - return -1 ; -} - - } //GParted diff --git a/src/jfs.cc b/src/jfs.cc index 7ae7be65..9efce315 100644 --- a/src/jfs.cc +++ b/src/jfs.cc @@ -91,13 +91,36 @@ void jfs::Set_Used_Sectors( Partition & partition ) pclose( f ) ; } -bool jfs::Create( const Partition & new_partition ) +bool jfs::Create( const Partition & new_partition, std::vector & operation_details ) { - return ! Execute_Command( "mkfs.jfs -q " + new_partition .partition ) ; + operation_details .push_back( OperationDetails( String::ucompose( + _("create new %1 filesystem"), + Utils::Get_Filesystem_String( GParted::FS_JFS ) ) ) ) ; + argv .clear() ; + argv .push_back( "mkfs.jfs" ) ; + argv .push_back( "-q" ) ; + argv .push_back( new_partition .partition ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -bool jfs::Resize( const Partition & partition_new, bool fill_partition ) -{ +bool jfs::Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition ) +{//FIXME (no jfs on my laptop, so couldn't test it properly) + if ( fill_partition ) + operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ; + else + operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ; + bool return_value = false ; Glib::ustring error ; Glib::ustring TEMP_MP = "/tmp/gparted_tmp_jfs_mountpoint" ; @@ -111,31 +134,56 @@ bool jfs::Resize( const Partition & partition_new, bool fill_partition ) } rmdir( TEMP_MP .c_str() ) ; + operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ; return return_value ; } -bool jfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) +bool jfs::Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) { - if ( ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) + operation_details .push_back( OperationDetails( + String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ; + + argv .clear() ; + argv .push_back( "dd" ) ; + argv .push_back( "bs=8192" ) ; + argv .push_back( "if=" + src_part_path ) ; + argv .push_back( "of=" + dest_part_path ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) { + operation_details .back() .status = OperationDetails::SUCCES ; + Partition partition ; partition .partition = dest_part_path ; - return Resize( partition, true ) ; + return Resize( partition, operation_details, true ) ; } + operation_details .back() .status = OperationDetails::ERROR ; return false ; } -bool jfs::Check_Repair( const Partition & partition ) +bool jfs::Check_Repair( const Partition & partition, std::vector & operation_details ) { - return Execute_Command( "jfs_fsck -f " + partition .partition ) <= 1 ; -} - -int jfs::get_estimated_time( long MB_to_Consider ) -{ - return -1 ; -} + operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ; + argv .clear() ; + argv .push_back( "jfs_fsck" ) ; + argv .push_back( "-f" ) ; + argv .push_back( partition .partition ) ; + + if ( 1 >= execute_command( argv, operation_details .back() .sub_details ) >= 0 ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } +} } //GParted diff --git a/src/linux_swap.cc b/src/linux_swap.cc index 555b7c2f..ca6a7e5c 100644 --- a/src/linux_swap.cc +++ b/src/linux_swap.cc @@ -45,30 +45,61 @@ void linux_swap::Set_Used_Sectors( Partition & partition ) { } -bool linux_swap::Create( const Partition & new_partition ) +bool linux_swap::Create( const Partition & new_partition, std::vector & operation_details ) { - return ! Execute_Command( "mkswap " + new_partition .partition ) ; + operation_details .push_back( OperationDetails( String::ucompose( + _("create new %1 filesystem"), + Utils::Get_Filesystem_String( GParted::FS_LINUX_SWAP ) ) ) ) ; + argv .clear() ; + argv .push_back( "mkswap" ) ; + argv .push_back( new_partition .partition ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -bool linux_swap::Resize( const Partition & partition_new, bool fill_partition ) +bool linux_swap::Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition ) { - return Create( partition_new ) ; + return Create( partition_new, operation_details ) ; } -bool linux_swap::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) +bool linux_swap::Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) { - return ! Execute_Command( "LC_NUMERIC=C dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; + operation_details .push_back( OperationDetails( + String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ; + + argv .clear() ; + argv .push_back( "dd" ) ; + argv .push_back( "bs=8192" ) ; + argv .push_back( "if=" + src_part_path ) ; + argv .push_back( "of=" + dest_part_path ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -bool linux_swap::Check_Repair( const Partition & partition ) +bool linux_swap::Check_Repair( const Partition & partition, std::vector & operation_details ) { return true ; } -int linux_swap::get_estimated_time( long MB_to_Consider ) -{ - return 1 + MB_to_Consider / 5000 ; -} - - } //GParted diff --git a/src/main.cc b/src/main.cc index 65367e25..d3d6732e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -17,6 +17,7 @@ #include "../include/Win_GParted.h" +#include int main( int argc, char *argv[ ] ) { diff --git a/src/ntfs.cc b/src/ntfs.cc index 2e9d67d2..d3c63f12 100644 --- a/src/ntfs.cc +++ b/src/ntfs.cc @@ -77,46 +77,101 @@ void ntfs::Set_Used_Sectors( Partition & partition ) partition .Set_Unused( N ) ; } -bool ntfs::Create( const Partition & new_partition ) +bool ntfs::Create( const Partition & new_partition, std::vector & operation_details ) { - return ! Execute_Command( "mkntfs -Q " + new_partition .partition ) ; + operation_details .push_back( OperationDetails( String::ucompose( + _("create new %1 filesystem"), + Utils::Get_Filesystem_String( GParted::FS_NTFS ) ) ) ) ; + argv .clear() ; + argv .push_back( "mkntfs" ) ; + argv .push_back( "-Q" ) ; + argv .push_back( "-vv" ) ; + argv .push_back( new_partition .partition ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -bool ntfs::Resize( const Partition & partition_new, bool fill_partition ) -{ +bool ntfs::Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition ) +{//FIXME probeer dmv piping y the echoen in ntfsresize + //-contact szaka en probeer een --yes oid in de API te krijgen + //-perform eerst testruns e.d. in ntfsresize te bouwen.. + if ( fill_partition ) + operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ; + else + operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ; + Glib::ustring str_temp = "echo y | ntfsresize -f " + partition_new .partition ; if ( ! fill_partition ) str_temp += " -s " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ; - return ! Execute_Command( str_temp ) ; + if ( ! Execute_Command( str_temp ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -bool ntfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) +bool ntfs::Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) { - if ( ! Execute_Command( "ntfsclone -f --overwrite " + dest_part_path + " " + src_part_path ) ) + operation_details .push_back( OperationDetails( + String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ; + + argv .clear() ; + argv .push_back( "ntfsclone" ) ; + argv .push_back( "-f" ) ; + argv .push_back( "--overwrite" ) ; + argv .push_back( dest_part_path ) ; + argv .push_back( src_part_path ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) { + operation_details .back() .status = OperationDetails::SUCCES ; + Partition partition ; partition .partition = dest_part_path ; - return Resize( partition, true ) ; + return Resize( partition, operation_details, true ) ; } - + + operation_details .back() .status = OperationDetails::ERROR ; return false ; } -bool ntfs::Check_Repair( const Partition & partition ) +bool ntfs::Check_Repair( const Partition & partition, std::vector & operation_details ) { //according to Szaka it's best to use ntfsresize to check the partition for errors //since --info is read-only i'll leave it out. just calling ntfsresize --force has also a tendency of fixing stuff :) - return Resize( partition, true ) ; + operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ; +//FIXME.. ook hier kan eea verbeterd/verduidelijkt.. + if ( Resize( partition, operation_details .back() .sub_details, true ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -int ntfs::get_estimated_time( long MB_to_Consider ) -{ - return -1 ; -} - - } //GParted diff --git a/src/reiser4.cc b/src/reiser4.cc index 887b3c68..9490b044 100644 --- a/src/reiser4.cc +++ b/src/reiser4.cc @@ -73,31 +73,62 @@ void reiser4::Set_Used_Sectors( Partition & partition ) partition .Set_Unused( N * S / 512 ) ; } -bool reiser4::Create( const Partition & new_partition ) +bool reiser4::Create( const Partition & new_partition, std::vector & operation_details ) { - return ! Execute_Command( "mkfs.reiser4 --yes " + new_partition .partition ) ; + operation_details .push_back( OperationDetails( String::ucompose( + _("create new %1 filesystem"), + Utils::Get_Filesystem_String( GParted::FS_REISER4 ) ) ) ) ; + argv .clear() ; + argv .push_back( "mkfs.reiser4" ) ; + argv .push_back( "--yes" ) ; + argv .push_back( new_partition .partition ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -bool reiser4::Resize( const Partition & partition_new, bool fill_partition ) +bool reiser4::Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition ) { return true ; } -bool reiser4::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) +bool reiser4::Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) { return true ; } -bool reiser4::Check_Repair( const Partition & partition ) +bool reiser4::Check_Repair( const Partition & partition, std::vector & operation_details ) { - return ! Execute_Command( "fsck.reiser4 --yes --fix " + partition .partition ) ; -} - -int reiser4::get_estimated_time( long MB_to_Consider ) -{ - return -1 ; -} + operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ; + argv .clear() ; + argv .push_back( "fsck.reiser4" ) ; + argv .push_back( "--yes" ) ; + argv .push_back( "--fix" ) ; + argv .push_back( partition .partition ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } +} } //GParted diff --git a/src/reiserfs.cc b/src/reiserfs.cc index 7961c27f..6492c64b 100644 --- a/src/reiserfs.cc +++ b/src/reiserfs.cc @@ -83,47 +83,102 @@ void reiserfs::Set_Used_Sectors( Partition & partition ) partition .Set_Unused( N * S / 512 ) ; } -bool reiserfs::Create( const Partition & new_partition ) +bool reiserfs::Create( const Partition & new_partition, std::vector & operation_details ) { - return ! Execute_Command( "mkreiserfs -q " + new_partition .partition ) ; + operation_details .push_back( OperationDetails( String::ucompose( + _("create new %1 filesystem"), + Utils::Get_Filesystem_String( GParted::FS_REISERFS ) ) ) ) ; + argv .clear() ; + argv .push_back( "mkreiserfs" ) ; + argv .push_back( "-f" ) ; + argv .push_back( new_partition .partition ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -bool reiserfs::Resize( const Partition & partition_new, bool fill_partition ) -{ +bool reiserfs::Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition ) +{//FIXME implement use of execute_command() for improved feedback + if ( fill_partition ) + operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ; + else + operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ; + Glib::ustring str_temp = "echo y | resize_reiserfs " + partition_new .partition ; if ( ! fill_partition ) str_temp += " -s " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ; - return ! Execute_Command( str_temp ) ; + if ( ! Execute_Command( str_temp ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -bool reiserfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) +bool reiserfs::Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) { - if ( ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) + operation_details .push_back( OperationDetails( + String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ; + + argv .clear() ; + argv .push_back( "dd" ) ; + argv .push_back( "bs=8192" ) ; + argv .push_back( "if=" + src_part_path ) ; + argv .push_back( "of=" + dest_part_path ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) { + operation_details .back() .status = OperationDetails::SUCCES ; + Partition partition ; partition .partition = dest_part_path ; - return Resize( partition, true ) ; + return Resize( partition, operation_details, true ) ; } + operation_details .back() .status = OperationDetails::ERROR ; return false ; } -bool reiserfs::Check_Repair( const Partition & partition ) +bool reiserfs::Check_Repair( const Partition & partition, std::vector & operation_details ) { + operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ; + + argv .clear() ; + argv .push_back( "reiserfsck" ) ; + argv .push_back( "--y" ) ; + argv .push_back( "--fix-fixable" ) ; + argv .push_back( partition .partition ) ; + //according to the manpage it should return 0 or 1 on succes, instead it returns 256 on succes.. - //blah, don't have time for this. Just check for both options, we'll fix this later with our much improved errorhandling - int t = Execute_Command( "reiserfsck -y --fix-fixable " + partition .partition ) ; - - return ( t <= 1 || t == 256 ) ; + //blah, don't have time for this. Just check for both options + exit_status = execute_command( argv, operation_details .back() .sub_details ) ; + if ( exit_status == 0 || exit_status == 1 || exit_status == 256 ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -int reiserfs::get_estimated_time( long MB_to_Consider ) -{ - return -1 ; -} - - - } //GParted diff --git a/src/xfs.cc b/src/xfs.cc index 8a98872e..e6735704 100644 --- a/src/xfs.cc +++ b/src/xfs.cc @@ -94,13 +94,36 @@ void xfs::Set_Used_Sectors( Partition & partition ) partition .Set_Unused( N * S / 512 ) ; } -bool xfs::Create( const Partition & new_partition ) +bool xfs::Create( const Partition & new_partition, std::vector & operation_details ) { - return ! Execute_Command( "mkfs.xfs -f " + new_partition .partition ) ; + operation_details .push_back( OperationDetails( String::ucompose( + _("create new %1 filesystem"), + Utils::Get_Filesystem_String( GParted::FS_XFS ) ) ) ) ; + argv .clear() ; + argv .push_back( "mkfs.xfs" ) ; + argv .push_back( "-f" ) ; + argv .push_back( new_partition .partition ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } } -bool xfs::Resize( const Partition & partition_new, bool fill_partition ) -{ +bool xfs::Resize( const Partition & partition_new, + std::vector & operation_details, + bool fill_partition ) +{//FIXME + if ( fill_partition ) + operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ; + else + operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ; + bool return_value = false ; Glib::ustring error ; Glib::ustring TEMP_MP = "/tmp/gparted_tmp_xfs_mountpoint" ; @@ -114,11 +137,17 @@ bool xfs::Resize( const Partition & partition_new, bool fill_partition ) } rmdir( TEMP_MP .c_str() ) ; + operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ; return return_value ; } -bool xfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) -{ +bool xfs::Copy( const Glib::ustring & src_part_path, + const Glib::ustring & dest_part_path, + std::vector & operation_details ) +{//FIXME + operation_details .push_back( OperationDetails( + String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ; + bool return_value = false ; Glib::ustring error ; Glib::ustring SRC = "/tmp/gparted_tmp_xfs_src_mountpoint" ; @@ -139,19 +168,30 @@ bool xfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_ rmdir( SRC .c_str() ) ; rmdir( DST .c_str() ) ; + operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ; return return_value ; } -bool xfs::Check_Repair( const Partition & partition ) +bool xfs::Check_Repair( const Partition & partition, std::vector & operation_details ) { - return ! Execute_Command( "xfs_repair " + partition .partition ) ; -} - -int xfs::get_estimated_time( long MB_to_Consider ) -{ - return -1 ; -} + operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ; + argv .clear() ; + argv .push_back( "xfs_repair" ) ; + argv .push_back( "-v" ) ; + argv .push_back( partition .partition ) ; + + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) + { + operation_details .back() .status = OperationDetails::SUCCES ; + return true ; + } + else + { + operation_details .back() .status = OperationDetails::ERROR ; + return false ; + } +} } //GParted