aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtransfugdrake231
1 files changed, 170 insertions, 61 deletions
diff --git a/transfugdrake b/transfugdrake
index f760c42..59a3773 100755
--- a/transfugdrake
+++ b/transfugdrake
@@ -30,6 +30,19 @@
# 01/12/18 - cbelisle@mandrakesoft.com
# - Move instructions in functions (read better).
# - Add the partition chooser page.
+# 01/12/27 - cbelisle@mandrakesoft.com
+# - Finished to move instructions in functions.
+# - Added many "yes or no" choices to user.
+# 01/12/31 - cbelisle@mandrakesoft.com
+# - Many changes during last days:
+# - Remake the application logic walkthru
+# - Fix Mail import (in transfug, not transfug_oe)
+# 02/01/03 - cbelisle@mandrakesoft.com
+# - Many changes once again:
+# - Finish the application logic
+# - Add User Chooser page
+# - Add checkups instead of giving impossible choices
+# - Email migration should work with OE 4.5 and 5
use lib q(/usr/lib/libDrakX);
@@ -42,7 +55,10 @@ use fsedit qw(:read_partitions);
use detect_devices;
use File::NCopy qw(copy);
-# Variables
+# TODO TODO TODO
+# Add a variable and a detection for Windows version
+
+## Variables
my $version = 0.1; # Version number
my $debug = 1; # Debug flag
my $chosen_partition = ""; # Partition chosen by the user
@@ -53,6 +69,17 @@ my @documents_folders =
'My Documents', # 95,98 - English
'Documents and Settings'); # XP - French & English
+# Ignored users in the document folder (XP)
+my @ignored_document_folders =
+('LocalService',
+ 'NetworkService',
+ 'Owner',
+ '.',
+ '..');
+
+# Address book location
+my $address_book_location = "Application Data/Microsoft/Address Book";
+
# If it's started during install, die.
$::isInstall and die "Not supported during install.\n";
@@ -77,95 +104,176 @@ begin:
$::Wizard_no_previous = 1;
#- **********************************
-#- * 1st step: Welcome message
+#- * 0th step: Welcome page
+step_0:
+if($debug) { print "- Starting Transfugdrake\n"; }
+
+$::direct or $in->ask_okcancel(_("Transfugdrake"),
+_("Welcome to Transfugdrake! I will help you to ease the step windows-linux
+by migrating your documents, mails and address books"), 1) or quit_global($in, 0);
+
+#- **********************************
+#- * 1st step: Which partition do we use?
step_1:
-# TODO: Put a bigger message with some instructions and agreement
+if($debug) { print "- Starting Transfugdrake\n"; }
-if($debug) { print "- Printing welcome message and waiting for user response\n"; }
-$::direct or $in->ask_okcancel(_("Transfug"),
-_("Welcome to TransfugDrake!
-In this wizard, you will be able to transfer documents,
-email and address books from Microsoft Windows to Mandrake Linux."), 1) or quit_global($in, 0);
+# Detect windows partitions
+if($debug) { print "- Detecting Partitions\n"; }
+my @mnt_win_folder = detect_partition();
+
+# If we have only one partition, goto the user chooser page
+if(@mnt_win_folder[1] eq "") { goto step_2; }
+
+my $chosen_partition = $in->ask_from_list_(_("Select your windows partition"),
+ _("Please specify your windows partition from the following list"),
+ [ @mnt_win_folder ],
+ @mnt_win_folder[0]) or
+ quit_global($in, 0);
+if($debug) { print "-- Chosen Partition = $chosen_partition"; }
#- **********************************
-#- * 2nd step: win files
+#- * 2nd step: Windows User Chooser
step_2:
-# TODO Get partition listing in a listbox and home listing in another listbox (gftp like)
+my $notvalid = 0;
+my $addbook = "";
+my $addbook_folder_win95 = "$chosen_partition/WINDOWS/Application Data/Microsoft/Address Book";
-# Detect windows partitions
-my @mnt_win_folder = detect_partition();
+if($debug) { print "- Windows User Chooser page\n"; }
+
+if($debug) { print "-- Looking where is the document folder\n"; }
+my $document_location = get_documents_folder(@documents_folders, $chosen_partition);
-# If we have only one partition, goto the copy page
-if(@mnt_win_folder[1] eq "") {
- goto step_3;
+if($document_location eq "") {
+ $in->ask_warn(_("Can't find documents folder!"),
+ _("Can't find the folder where the documents are located. Exiting..."));
+ quit_global($in, 0);
}
-# Create radio buttons to give the user the choice of the partition.
-my $chosen_partition = $in->ask_from_list_(_("Select your windows partition"),
- _("Please specify your windows partition from the following list"),
- [ @mnt_win_folder ],
- @mnt_win_folder[0]) or
- quit_global($in, 0);
+if($debug) { print "-- Looking which Windows version we have\n"; }
+
+if($document_location eq $chosen_partition.'/'.$documents_folders[0] ||
+ $document_location eq $chosen_partition.'/'.$documents_folders[1]) {
+ # For 95-98, go see in the address books folder to get the users
+ if($debug) { print "--- Windows 95/98 found\n"; }
+ opendir YREP, $addbook_folder_win95 or die "unable to open dir: $!\n";
+ my @addbook_files = grep /.*dbx$/, readdir YREP;
+ closedir YREP;
+ foreach my $addbook (@addbook_files) {
+ $addbook =~ s/.wab//g;
+ push(@users, $addbook);
+ }
+}
+elsif($document_location eq $chosen_partition.'/'.$documents_folders[2]) {
+ # For XP, go see in the documents folder to get the directory listing
+ if($debug) { print "--- Windows XP found\n"; }
+ opendir YREP, $document_location or die "unable to opendir: $!\n";
+ my @tmp_user_array = readdir YREP;
+ closedir YREP;
+ foreach my $tmp_user (@tmp_user_array) {
+ foreach my $tmp_ignored (@ignored_document_folders) {
+ if ($tmp_user eq $tmp_ignored) { $notvalid = 1; }
+ }
+ if($notvalid != 1) { push(@users, $tmp_user); }
+ $notvalid = 0;
+ }
+}
+
+
+my $chosen_user = $in->ask_from_list(_("Transfugdrake"),
+_("You have the following users in Windows. Which one do you want to use for migration?"),
+[ @users ], $users[0]) or quit_global($in, 0);
+
#- **********************************
-#- * 3rd step: win files
+#- * 3rd step: Task Chooser
step_3:
-if($debug) { print "- Ready to copy all the documents, waiting for user response\n"; }
+my @tasks = ('Copy files and folders from your Windows partition');
-my $source_folder = get_documents_folder(@documents_folders, $chosen_partition);
+if($debug) { print "- Task Chooser\n"; }
-if ($source_folder eq "") {
- $in->ask_warn(_("Can't find documents folder!"),
- _("Can't find the folder where the documents are located. Exiting..."));
- quit_global($in);
+$document_location .= '/'.$chosen_user;
+if(-f $chosen_partition."/WINDOWS".$address_book_location.$chosen_user.".wab" ||
+ -f $document_location.'/'.$address_book_location.'/'.$chosen_user.".wab") {
+ push(@tasks, "Migrate address book from Windows (not implemented yet)");
+}
+# This is the Windows XP mailbox checkup. Will be active as soon as transfug_oe support OE 6.
+#if(-d $document_location."/Local Settings/Application Data/Identities") {
+ # opendir YREP, $document_location."/Local Settings/Application Data/Identities" or die "unable to opendir: $!\n";
+ # my @identity = readdir YREP;
+ # closedir YREP;
+ # if(-f $document_location."/Local Settings/Application Data/Identities/".$identity[2]."/Microsoft/Outlook Express/Inbox.dbx") {
+ # push(@tasks, "Migrate your mail messages from Windows (Outlook Express 4 & 5 ONLY)");
+ # }
+ #}
+if(-d $chosen_partition."/WINDOWS/Application Data/Identities") {
+ opendir YREP, $chosen_partition."/WINDOWS/Application Data/Identities" or die "unable to opendir: $!\n";
+ my @identity = readdir YREP;
+ closedir YREP;
+ if(-f $chosen_partition."/WINDOWS/Application Data/Identities/".$identity[2]."/Microsoft/Outlook Express/Inbox.dbx") {
+ push(@tasks, "Migrate your mail messages from Windows (Outlook Express 4.5 & 5 ONLY)");
+ }
}
-copy_documents($source_folder, $ENV{HOME});
+my $chosen_task = $in->ask_from_list(_("Transfugdrake"),
+_("Welcome to TransfugDrake! You are now able to ease\n the step Windows-Linux with many migrations. Please choose what you\n want to do:"), [ @tasks ], $tasks[0]) or quit_global($in, 0);
-#- ******************************
-#- * 4th step: redo if needed
+if($chosen_task eq "Copy files and folders from your Windows partition") { goto step_4; }
+if($chosen_task eq "Migrate address book from Windows (not implemented yet)") { goto step_7; }
+if($chosen_task eq "Migrate your mail messages from Windows (Outlook Express 4.5 & 5 ONLY)") { goto step_6; }
+
+#- **********************************
+#- * 4th step: Copy Windows Files
step_4:
+if($debug) { print "- Ready to copy all the documents, waiting for user response\n"; }
-$::direct or $in->ask_okcancel(_("Transfugdrake"),
-_("Do you want to copy other files from another folder?"), 1) or goto step_4;
+copy_documents($document_location, $ENV{HOME});
+
+#- ******************************
+#- * 5th step: redo if needed
+step_5:
+
+if($in->ask_yesorno(_("Transfugdrake"),
+_("Do you want to copy other files from another folder?"), 1)) {
+ goto step_2;
+}
#- *******************************
#- * 4th step: mail from windows
-step_5:
+step_6:
$::direct or $in->ask_okcancel(_("Transfug"),
_("We will bring back your Outlook Mailboxes to a standard unix mbox\n
-NB: This feature works only with Outlook Express 4.5 and 5"), 1) or goto step_4;
+NB: This feature works only with Outlook Express 4.5 and 5"), 1) or goto step_7;
mkdir "$ENV{HOME}/Mail" unless (-e "$ENV{HOME}/Mail");
-$oe5onwin98="$win/WINDOWS/Application Data/Identities/{424975E0-8577-11D4-A891-989048140B20}/Microsoft/Outlook Express";
+
+$oe5onwin98="$win/WINDOWS/Application Data/Identities";
+opendir YREP, $oe5onwin98;
+my @tmp_identitity = readdir YREP;
+closedir YREP;
+$oe5onwin98 .= '/'.$tmp_identity[2]."/Microsoft/Outlook Express";
if (-e $oe5onwin98) {
- print "OE5 on win98 detected\n";
+ print "OE detected\n";
opendir YREP, $oe5onwin98 or die "unable to open dir: $!";
@files = grep /.*dbx$/, readdir YREP;
closedir YREP;
foreach $i (@files) {
`transfug_oe \"$oe5onwin98/$i\" \"$ENV{HOME}/Mail/$i\"`;
}
-} else {
- while (1) {
- $a=ask_file_path(_("Select file"),"$win/Application Data/Identities") or goto step_4;
- `transfug_oe \"$a\" \"$ENV{HOME}/Mail/$i\"`;
- }
-
}
-
#- *******************************
-#- * 5th step: address book from windows
-step_6:
-$::direct or $in->ask_okcancel(_("Transfug"),
-_("We will migrate your windows address book to Mandrake (not implemented yet)"), 1) or quit_global($in, 0);
+#- * 6th step: address book from windows
+# In XP, address book is located in /Document and Settings/user/Appli Data/Microsoft/Address Book/
+step_7:
+
+$::direct or $in->ask_okcancel(_("Transfugdrake"),
+_("Here will come the address book migration page."), 1) or quit_global($in, 0);
#- *******************************
-#- * 6th step: finish
-step_6:
+#- * 8th step: finish
+step_8:
$::direct or $in->ask_okcancel(_("Transfugdrake"),
_("The migration of all of your Windows data is finished."), 1) or quit_global($in, 0);
@@ -190,7 +298,7 @@ sub detect_partition {
while(@mnt_dir_folder[$folders_count] ne "") {
push(@win,"/mnt/".@mnt_dir_folder[$folders_count]);
$found = 1;
- if($debug) { print "- Found windows partition at /mnt/@mnt_dir_folder[$folders_count]\n"; }
+ if($debug) { print "-- Found windows partition at /mnt/@mnt_dir_folder[$folders_count]\n"; }
$folders_count++;
}
@@ -217,7 +325,8 @@ sub get_documents_folder {
# Make a whole checkup to see where My Documents is located.
foreach my $test_doc (@doc_folders) {
if(-d $mountpoint.$test_doc) {
- if(debug) { print " -- $mountpoint.$test_doc found\n"; }
+ if(debug) { print "-- $mountpoint$test_doc found\n"; }
+ if($test_doc eq $doc_folders[2]) { $xp = 1; }
return $mountpoint.$test_doc;
}
}
@@ -226,19 +335,19 @@ sub get_documents_folder {
sub copy_documents {
my $source = $_[0];
my $dest = $_[1];
-
+
mkdir("$dest/win_backup");
$dest .= "/win_backup";
- $::direct or $in->ask_okcancel(_("Transfugdrake"),
- _("Do you want to copy all the content of\n \"$source\" to \"$dest\"?"), 1) or goto step_3;
+ if(!($in->ask_yesorno(_("Transfugdrake"),
+ _("Do you want to copy all the content of\n \"$source\" to \"$dest\"?"), 1))) {
+ goto step_5;
+ }
$wait_configuring = $in->wait_message(_("Copying files..."),
- _("Copying all files from $source to $dest."));
+ _("Copying all files from $source to $dest. This may take several minutes."));
- print "euuuuuh $source\n";
- print "tabr $dest \n";
- #$file = File::NCopy->new(recursive => 1);
- copy \1, $source, $dest;
+ $source =~ s/\ /\\ /g;
+ print "prout: $source\n";
+ system("cp -R $source $dest");
undef $wait_configuring;
}
-