"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Win_GParted.cc" between
gparted-1.2.0.tar.gz and gparted-1.3.0.tar.gz

About: GParted is a graphical partition editor for creating, reorganizing, and deleting disk partitions (using GNU libparted).

Win_GParted.cc  (gparted-1.2.0):Win_GParted.cc  (gparted-1.3.0)
skipping to change at line 48 skipping to change at line 48
#include "OperationDelete.h" #include "OperationDelete.h"
#include "OperationFormat.h" #include "OperationFormat.h"
#include "OperationResizeMove.h" #include "OperationResizeMove.h"
#include "OperationChangeUUID.h" #include "OperationChangeUUID.h"
#include "OperationLabelFileSystem.h" #include "OperationLabelFileSystem.h"
#include "OperationNamePartition.h" #include "OperationNamePartition.h"
#include "Partition.h" #include "Partition.h"
#include "PartitionVector.h" #include "PartitionVector.h"
#include "PasswordRAMStore.h" #include "PasswordRAMStore.h"
#include "LVM2_PV_Info.h" #include "LVM2_PV_Info.h"
#include "LUKS_Info.h"
#include "Utils.h" #include "Utils.h"
#include "../config.h" #include "../config.h"
#include <string.h> #include <string.h>
#include <gtkmm/cssprovider.h> #include <gtkmm/cssprovider.h>
#include <gtkmm/aboutdialog.h> #include <gtkmm/aboutdialog.h>
#include <gtkmm/messagedialog.h> #include <gtkmm/messagedialog.h>
#include <gtkmm/radiobuttongroup.h> #include <gtkmm/radiobuttongroup.h>
#include <gtkmm/radiomenuitem.h> #include <gtkmm/radiomenuitem.h>
#include <gtkmm/main.h> #include <gtkmm/main.h>
skipping to change at line 110 skipping to change at line 111
this ->add( vbox_main ); this ->add( vbox_main );
//menubar.... //menubar....
init_menubar() ; init_menubar() ;
vbox_main .pack_start( menubar_main, Gtk::PACK_SHRINK ); vbox_main .pack_start( menubar_main, Gtk::PACK_SHRINK );
//toolbar.... //toolbar....
init_toolbar() ; init_toolbar() ;
vbox_main.pack_start( hbox_toolbar, Gtk::PACK_SHRINK ); vbox_main.pack_start( hbox_toolbar, Gtk::PACK_SHRINK );
//drawingarea_visualdisk... ( contains the visual represenation of the d isks ) //drawingarea_visualdisk... ( contains the visual representation of the disks )
drawingarea_visualdisk .signal_partition_selected .connect( drawingarea_visualdisk .signal_partition_selected .connect(
sigc::mem_fun( this, &Win_GParted::on_partition_selected ) ) ; sigc::mem_fun( this, &Win_GParted::on_partition_selected ) ) ;
drawingarea_visualdisk .signal_partition_activated .connect( drawingarea_visualdisk .signal_partition_activated .connect(
sigc::mem_fun( this, &Win_GParted::on_partition_activated ) ) ; sigc::mem_fun( this, &Win_GParted::on_partition_activated ) ) ;
drawingarea_visualdisk .signal_popup_menu .connect( drawingarea_visualdisk .signal_popup_menu .connect(
sigc::mem_fun( this, &Win_GParted::on_partition_popup_men u ) ); sigc::mem_fun( this, &Win_GParted::on_partition_popup_men u ) );
vbox_main .pack_start( drawingarea_visualdisk, Gtk::PACK_SHRINK ) ; vbox_main .pack_start( drawingarea_visualdisk, Gtk::PACK_SHRINK ) ;
//hpaned_main (NOTE: added to vpaned_main) //hpaned_main (NOTE: added to vpaned_main)
init_hpaned_main() ; init_hpaned_main() ;
skipping to change at line 549 skipping to change at line 550
} }
//Add cleared at the end of the list //Add cleared at the end of the list
create_format_menu_add_item( FS_CLEARED, true ) ; create_format_menu_add_item( FS_CLEARED, true ) ;
return menu ; return menu ;
} }
//Add one entry to the Partition --> Format to --> (file system list) menu //Add one entry to the Partition --> Format to --> (file system list) menu
void Win_GParted::create_format_menu_add_item(FSType fstype, bool activate) void Win_GParted::create_format_menu_add_item(FSType fstype, bool activate)
{ {
hbox = manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); Gtk::Box *hbox = manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
//the colored square //the colored square
hbox->pack_start(*manage(new Gtk::Image(Utils::get_color_as_pixbuf(fstype , 16, 16))), hbox->pack_start(*manage(new Gtk::Image(Utils::get_color_as_pixbuf(fstype , 16, 16))),
Gtk::PACK_SHRINK); Gtk::PACK_SHRINK);
//the label... //the label...
hbox->pack_start(*Utils::mk_label(" " + Utils::get_filesystem_string(fsty pe)), hbox->pack_start(*Utils::mk_label(" " + Utils::get_filesystem_string(fsty pe)),
Gtk::PACK_SHRINK); Gtk::PACK_SHRINK);
Gtk::MenuItem *item = manage(new Gtk::MenuItem(*hbox)); Gtk::MenuItem *item = manage(new Gtk::MenuItem(*hbox));
menu->append(*item); menu->append(*item);
if ( activate ) if ( activate )
skipping to change at line 730 skipping to change at line 731
for ( unsigned int i = 0 ; i < devices .size( ) ; i++ ) for ( unsigned int i = 0 ; i < devices .size( ) ; i++ )
{ {
//combo... //combo...
treerow = *( liststore_devices ->append() ) ; treerow = *( liststore_devices ->append() ) ;
treerow[ treeview_devices_columns .icon ] = treerow[ treeview_devices_columns .icon ] =
Utils::mk_pixbuf(*this, Gtk::Stock::HARDDISK, Gtk::ICON_S IZE_LARGE_TOOLBAR); Utils::mk_pixbuf(*this, Gtk::Stock::HARDDISK, Gtk::ICON_S IZE_LARGE_TOOLBAR);
treerow[ treeview_devices_columns .device ] = devices[ i ] .get_p ath() ; treerow[ treeview_devices_columns .device ] = devices[ i ] .get_p ath() ;
treerow[ treeview_devices_columns .size ] = "(" + Utils::format_s ize( devices[ i ] .length, devices[ i ] .sector_size ) + ")" ; treerow[ treeview_devices_columns .size ] = "(" + Utils::format_s ize( devices[ i ] .length, devices[ i ] .sector_size ) + ")" ;
// Devices submenu... // Devices submenu...
hbox = manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); Gtk::Box *hbox = manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL) );
hbox ->pack_start( * Utils::mk_label( devices[ i ] .get_path() ), Gtk::PACK_EXPAND_WIDGET ) ; hbox ->pack_start( * Utils::mk_label( devices[ i ] .get_path() ), Gtk::PACK_EXPAND_WIDGET ) ;
hbox ->pack_start( * Utils::mk_label( " (" + Utils::format_size ( devices[ i ] .length, devices[ i ] .sector_size ) + ")" ), hbox ->pack_start( * Utils::mk_label( " (" + Utils::format_size ( devices[ i ] .length, devices[ i ] .sector_size ) + ")" ),
Gtk::PACK_SHRINK ) ; Gtk::PACK_SHRINK ) ;
Gtk::RadioMenuItem *item = manage(new Gtk::RadioMenuItem(radio_gr oup)); Gtk::RadioMenuItem *item = manage(new Gtk::RadioMenuItem(radio_gr oup));
menu->append(*item); menu->append(*item);
item->add(*hbox); item->add(*hbox);
item->signal_activate().connect( item->signal_activate().connect(
sigc::bind<unsigned int>( sigc::mem_fun(*this, &Win_GPart ed::radio_devices_changed), i ) ) ; sigc::bind<unsigned int>( sigc::mem_fun(*this, &Win_GPart ed::radio_devices_changed), i ) ) ;
} }
skipping to change at line 1392 skipping to change at line 1393
} }
// PRIMARY, LOGICAL and UNPARTITIONED; partitions with supported file sys tem. // PRIMARY, LOGICAL and UNPARTITIONED; partitions with supported file sys tem.
if ( ( selected_partition_ptr->type == TYPE_PRIMARY || if ( ( selected_partition_ptr->type == TYPE_PRIMARY ||
selected_partition_ptr->type == TYPE_LOGICAL || selected_partition_ptr->type == TYPE_LOGICAL ||
selected_partition_ptr->type == TYPE_UNPARTITIONED ) && selected_partition_ptr->type == TYPE_UNPARTITIONED ) &&
selected_partition_ptr->fstype != FS_UNALLOCATED ) selected_partition_ptr->fstype != FS_UNALLOCATED )
{ {
allow_format( true ) ; allow_format( true ) ;
// only allow deletion of partitions within a partition table // Only allow deletion of inactive partitions within a partition
// Also exclude open LUKS mappings until open/close is supported table.
if ( ( selected_partition_ptr->type == TYPE_PRIMARY || if ( ( selected_partition_ptr->type == TYPE_PRIMARY ||
selected_partition_ptr->type == TYPE_LOGICAL ) && selected_partition_ptr->type == TYPE_LOGICAL ) &&
! selected_partition_ptr->busy ) ! selected_partition_ptr->busy )
allow_delete( true ); allow_delete( true );
// Resizing/moving always requires the ability to update the part ition // Resizing/moving always requires the ability to update the part ition
// table ... // table ...
if ( ! devices[current_device].readonly ) if ( ! devices[current_device].readonly )
{ {
// Can the plain file system be resized or moved? // Can the plain file system be resized or moved?
skipping to change at line 2037 skipping to change at line 2037
Dialog_Partition_Resize_Move dialog(devices[current_device], Dialog_Partition_Resize_Move dialog(devices[current_device],
fs_cap, fs_cap,
fs_limits, fs_limits,
*working_ptn, *working_ptn,
*display_partitions_ptr); *display_partitions_ptr);
dialog .set_transient_for( *this ) ; dialog .set_transient_for( *this ) ;
delete working_ptn; delete working_ptn;
working_ptn = NULL; working_ptn = NULL;
if ( dialog .run() == Gtk::RESPONSE_OK ) if (dialog.run() == Gtk::RESPONSE_OK
&&
ask_for_password_for_encrypted_resize_as_required(*selected_partition
_ptr) )
{ {
dialog .hide() ; dialog .hide() ;
// Apply resize/move from the dialog to a copy of the selected pa rtition. // Apply resize/move from the dialog to a copy of the selected pa rtition.
Partition * resized_ptn = selected_partition_ptr->clone(); Partition * resized_ptn = selected_partition_ptr->clone();
resized_ptn->resize( dialog.Get_New_Partition() ); resized_ptn->resize( dialog.Get_New_Partition() );
// When resizing/moving a partition which already exists on the d isk all // When resizing/moving a partition which already exists on the d isk all
// possible operations could be pending so only try merging with the // possible operations could be pending so only try merging with the
// previous operation. // previous operation.
skipping to change at line 2106 skipping to change at line 2107
dialog.run(); dialog.run();
} }
Add_Operation( devices[current_device], operation ); Add_Operation( devices[current_device], operation );
merge_operations( mergetype ); merge_operations( mergetype );
} }
show_operationslist() ; show_operationslist() ;
} }
bool Win_GParted::ask_for_password_for_encrypted_resize_as_required(const Partit
ion& partition)
{
if (partition.fstype != FS_LUKS || ! partition.busy)
// Not active LUKS so won't need a password.
return true;
LUKS_Mapping mapping = LUKS_Info::get_cache_entry(partition.get_path());
if (mapping.name.empty() || mapping.key_loc == KEYLOC_DMCrypt)
// LUKS volume key stored in crypt Device-Mapper target so won't
require a
// password for encryption mapping resize.
return true;
const char *pw = PasswordRAMStore::lookup(partition.uuid);
if (pw != NULL)
// GParted already has a password for this encryption mapping whi
ch was
// previously used successfully or tested for correctness.
//
// The password will still be correct, unless it was changed by s
omeone
// outside GParted while running and since the last time the pass
word was
// used. Re-testing the password takes 2-3 seconds which would p
ause the
// UI after the [Resize/Move] button was pressed in the Resize/Mo
ve dialog
// but before the dialog closes. With no trivial way to provide
feedback
// that the password is being re-tested, don't spend coding effor
t to
// support this use case. So just assume the known password is s
till
// correct and don't re-prompt when it will be correct 99.9% of t
he time.
return true;
DialogPasswordEntry dialog(partition,
/* TO TRANSLATORS: looks like Enter LUKS pas
sphrase to resize /dev/sda1 */
Glib::ustring::compose(_("Enter LUKS passphras
e to resize %1"),
partition.get_path()));
dialog.set_transient_for(*this);
bool success = false;
do
{
if (dialog.run() != Gtk::RESPONSE_OK)
// Password dialog cancelled or closed without having con
firmed
// the LUKS mapping passphrase.
return false;
pw = dialog.get_password();
if (strlen(pw) == 0)
{
// cryptsetup won't accept a zero length password.
dialog.set_error_message("");
continue;
}
// Test the password can open the encryption mapping.
const Glib::ustring mapping_name = Utils::generate_encryption_map
ping_name(
selected_partition_ptr
->get_path());
Glib::ustring cmd = "cryptsetup luksOpen --test-passphrase " +
Glib::shell_quote(partition.get_path()) + " "
+
Glib::shell_quote(mapping_name);
Glib::ustring output;
Glib::ustring error;
success = ! Utils::execute_command(cmd, pw, output, error);
Glib::ustring message = (success) ? "" : _("LUKS encryption passp
hrase check failed");
dialog.set_error_message(message);
}
while (! success);
// Save the password just entered and successfully tested on the LUKS map
ping.
PasswordRAMStore::store(partition.uuid, pw);
dialog.hide();
return true;
}
void Win_GParted::activate_copy() void Win_GParted::activate_copy()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback w ithout a selected partition g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback w ithout a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bu g: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bu g: Not pointing at a valid display partition object
delete copied_partition; delete copied_partition;
copied_partition = selected_partition_ptr->clone(); copied_partition = selected_partition_ptr->clone();
} }
void Win_GParted::activate_paste() void Win_GParted::activate_paste()
skipping to change at line 2624 skipping to change at line 2696
{ {
pw = entered_password; pw = entered_password;
if ( strlen( pw ) == 0 ) if ( strlen( pw ) == 0 )
{ {
// "cryptsetup" won't accept a zero length password. // "cryptsetup" won't accept a zero length password.
message = ""; message = "";
return false; return false;
} }
} }
// Create LUKS mapping name from partition name: const Glib::ustring mapping_name = Utils::generate_encryption_mapping_nam
// "/dev/sdb1" -> "sdb1_crypt" e(selected_partition_ptr->get_path());
Glib::ustring mapping_name = selected_partition_ptr->get_path();
Glib::ustring::size_type last_slash = mapping_name.rfind( "/" );
if ( last_slash != Glib::ustring::npos )
mapping_name = mapping_name.substr( last_slash + 1 );
mapping_name += "_crypt";
Glib::ustring cmd = "cryptsetup luksOpen " + Glib::ustring cmd = "cryptsetup luksOpen " +
Glib::shell_quote( partition.get_path() ) + " " + Glib::shell_quote( partition.get_path() ) + " " +
Glib::shell_quote( mapping_name ); Glib::shell_quote( mapping_name );
show_pulsebar( Glib::ustring::compose( _("Opening encryption on %1"), par tition.get_path() ) ); show_pulsebar( Glib::ustring::compose( _("Opening encryption on %1"), par tition.get_path() ) );
Glib::ustring output; Glib::ustring output;
Glib::ustring error; Glib::ustring error;
bool success = ! Utils::execute_command( cmd, pw, output, error ); bool success = ! Utils::execute_command( cmd, pw, output, error );
hide_pulsebar(); hide_pulsebar();
if ( success && pw != NULL ) if ( success && pw != NULL )
skipping to change at line 2715 skipping to change at line 2780
error_msg = "<i># " + cmd + "\n" + error + "</i>"; error_msg = "<i># " + cmd + "\n" + error + "</i>";
break; break;
case LUKSOPEN: case LUKSOPEN:
{ {
// Attempt to unlock LUKS using stored passphrase first. // Attempt to unlock LUKS using stored passphrase first.
success = open_encrypted_partition( *selected_partition_p tr, NULL, error_msg ); success = open_encrypted_partition( *selected_partition_p tr, NULL, error_msg );
if ( success ) if ( success )
break; break;
// Open password dialog and attempt to unlock LUKS mappin g. // Open password dialog and attempt to unlock LUKS mappin g.
DialogPasswordEntry dialog( *selected_partition_ptr ); DialogPasswordEntry dialog(*selected_partition_ptr,
/* TO TRANSLATORS: looks like
* Enter LUKS passphrase to op
en /dev/sda1
*/
Glib::ustring::compose(_("Ente
r LUKS passphrase to open %1"),
selecte
d_partition_ptr->get_path()));
dialog.set_transient_for( *this ); dialog.set_transient_for( *this );
do do
{ {
if ( dialog.run() != Gtk::RESPONSE_OK ) if ( dialog.run() != Gtk::RESPONSE_OK )
// Password dialog cancelled or closed wi thout the // Password dialog cancelled or closed wi thout the
// LUKS mapping having been opened. Skip refresh. // LUKS mapping having been opened. Skip refresh.
return; return;
success = open_encrypted_partition( *selected_par tition_ptr, success = open_encrypted_partition( *selected_par tition_ptr,
dialog.get_pa ssword(), dialog.get_pa ssword(),
skipping to change at line 3178 skipping to change at line 3248
if ( dialog .any_change ) if ( dialog .any_change )
menu_gparted_refresh_devices() ; menu_gparted_refresh_devices() ;
} }
void Win_GParted::activate_check() void Win_GParted::activate_check()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback w ithout a selected partition g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback w ithout a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bu g: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bu g: Not pointing at a valid display partition object
if (! ask_for_password_for_encrypted_resize_as_required(*selected_partiti
on_ptr))
// Open encryption mapping needing a passphrase to resize but the
password
// dialog was cancelled or closed without providing a working pas
sphrase.
return;
// FIXME: Consider constructing new partition object with zero unallocate d and // FIXME: Consider constructing new partition object with zero unallocate d and
// messages cleared to represent how applying a check operation also grow s the // messages cleared to represent how applying a check operation also grow s the
// file system to fill the partition. // file system to fill the partition.
Operation * operation = new OperationCheck( devices[current_device], *sel ected_partition_ptr ); Operation * operation = new OperationCheck( devices[current_device], *sel ected_partition_ptr );
operation->icon = Utils::mk_pixbuf(*this, Gtk::Stock::EXECUTE, Gtk::ICON_ SIZE_MENU); operation->icon = Utils::mk_pixbuf(*this, Gtk::Stock::EXECUTE, Gtk::ICON_ SIZE_MENU);
Add_Operation( devices[current_device], operation ); Add_Operation( devices[current_device], operation );
// Try to merge this check operation with all previous operations. // Try to merge this check operation with all previous operations.
merge_operations( MERGE_LAST_WITH_ANY ); merge_operations( MERGE_LAST_WITH_ANY );
 End of changes. 10 change blocks. 
15 lines changed or deleted 119 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)