2012-01-22 13:49:52 -07:00
|
|
|
/* Copyright (C) 2012 Rogier Goossens
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2014-01-23 03:59:48 -07:00
|
|
|
* GNU General Public License for more details.
|
2012-01-22 13:49:52 -07:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 03:59:48 -07:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2012-01-22 13:49:52 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../include/OperationChangeUUID.h"
|
2015-05-23 13:22:37 -06:00
|
|
|
#include "../include/Partition.h"
|
|
|
|
#include "../include/PartitionVector.h"
|
2012-01-22 13:49:52 -07:00
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
|
|
|
OperationChangeUUID::OperationChangeUUID( const Device & device
|
|
|
|
, const Partition & partition_orig
|
|
|
|
, const Partition & partition_new
|
|
|
|
)
|
|
|
|
{
|
|
|
|
type = OPERATION_CHANGE_UUID ;
|
|
|
|
|
2015-05-24 07:13:37 -06:00
|
|
|
this->device = device.get_copy_without_partitions();
|
2012-01-22 13:49:52 -07:00
|
|
|
this ->partition_original = partition_orig ;
|
|
|
|
this ->partition_new = partition_new ;
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:22:37 -06:00
|
|
|
void OperationChangeUUID::apply_to_visual( PartitionVector & partitions )
|
2012-01-22 13:49:52 -07:00
|
|
|
{
|
2015-09-26 07:25:58 -06:00
|
|
|
substitute_new( partitions );
|
2012-01-22 13:49:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void OperationChangeUUID::create_description()
|
|
|
|
{
|
2012-01-30 11:33:33 -07:00
|
|
|
if ( partition_new .uuid == UUID_RANDOM_NTFS_HALF ) {
|
2012-01-30 15:45:50 -07:00
|
|
|
/*TO TRANSLATORS: looks like Set half the UUID to a new random value on ntfs file system on /dev/sda1 */
|
|
|
|
description = String::ucompose( _("Set half the UUID to a new random value on %1 file system on %2")
|
2012-01-30 11:33:33 -07:00
|
|
|
, Utils::get_filesystem_string( partition_new .filesystem )
|
|
|
|
, partition_new .get_path()
|
|
|
|
) ;
|
|
|
|
} else {
|
2012-01-30 15:45:50 -07:00
|
|
|
/*TO TRANSLATORS: looks like Set a new random UUID on ext4 file system on /dev/sda1 */
|
|
|
|
description = String::ucompose( _("Set a new random UUID on %1 file system on %2")
|
2012-01-30 11:33:33 -07:00
|
|
|
, Utils::get_filesystem_string( partition_new .filesystem )
|
|
|
|
, partition_new .get_path()
|
|
|
|
) ;
|
|
|
|
}
|
2012-01-22 13:49:52 -07:00
|
|
|
}
|
|
|
|
|
2015-09-12 07:59:40 -06:00
|
|
|
bool OperationChangeUUID::merge_operations( const Operation & candidate )
|
|
|
|
{
|
2015-09-19 08:57:39 -06:00
|
|
|
if ( candidate.type == OPERATION_CHANGE_UUID &&
|
|
|
|
partition_new == candidate.get_partition_original() )
|
2015-09-12 07:59:40 -06:00
|
|
|
{
|
|
|
|
// Changing half the UUID must not override changing all of it
|
2015-09-19 08:57:39 -06:00
|
|
|
if ( candidate.get_partition_new().uuid != UUID_RANDOM_NTFS_HALF )
|
2015-09-12 07:59:40 -06:00
|
|
|
{
|
2015-09-19 08:57:39 -06:00
|
|
|
partition_new.uuid = candidate.get_partition_new().uuid;
|
2015-09-12 07:59:40 -06:00
|
|
|
create_description();
|
|
|
|
}
|
|
|
|
// Else no change required to this operation to merge candidate
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-22 13:49:52 -07:00
|
|
|
} //GParted
|