aboutsummaryrefslogtreecommitdiffstats
path: root/transfugdrake
blob: f2e33bd81dd03de1ee7ff7dd00a4a83ad009db7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#! /usr/bin/perl
# $Id$

#
# Yves Duret (yduret at mandrakesoft.com)
# Christian Belisle (cbelisle at mandrakesoft.com)
#
# Copyright 2001 MandrakeSoft
#
# This software may be freely redistributed under the terms of the GNU
# public license.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# ChangeLog
# 	01/11/27 - cbelisle@mandrakesoft.com
#  	 - Enhanced the windows partition search algorithm
#  	 - Put another message in the welcome screen (more professional)
#  	 - Enhance the data copying-moving function

use lib q(/usr/lib/libDrakX);

#use common qw(:common :file :functional :system);
use interactive;
use standalone;
#use log;
use my_gtk qw(:helpers :wrappers :ask);
#use netconnect;
use detect_devices;
use File::NCopy;

my $i = 0;
my $found = 0;
my @win = "";
my $version = 0.1;
my $file;

$::isInstall and die "Not supported during install.\n";

$::isEmbedded = ($::XID, $::CCPID) = "@ARGV" =~ /--embedded (\w+) (\w+)/;

local $_ = join '', @ARGV;

/-h/ and die "usage: transfug [--version]\n";
/-version/ and die 'transfugdrake '.$version."\n";
$::isEmbedded or $::isWizard = 1;
$::Wizard_pix_up = "wiz_drakgw.png";
$::Wizard_title = _("Transfugdrake");
$::direct = /-direct/;

# Debug flag
my $debug = 1;

# Application initialization
my $in = interactive::vnew(su);

# Get folder listing in /mnt
my @mnt_dir_folder = split("\n", `ls /mnt/`);

# Look in the array if we have a windows partition
my $folders_count = 1;
while(@mnt_dir_folder[$folders_count] ne "") {
   if(@mnt_dir_folder[$folders_count] =~ /win/) {
      push(@win,"/mnt/".@mnt_dir_folder[$folders_count]);
      $found = 1;
      if($debug) { print "- Found windows partition at /mnt/@mnt_dir_folder[$folders_count]\n"; }
   }
   $folders_count++;
}

# If nothing is found, print an error and exit.
if(!$found) {
   print "- No windows partitions\n";
   $in->ask_warn(_("Can't find windows!"), 
   _("Sorry, I can't find windows. Maybe it's not installed, or your windows partition is not mounted on Mandrake."));
   quit_global($in);
}	

#- **********************************
#- * 0th step: verify if we are already set up
begin:

$::Wizard_no_previous = 1;

#- **********************************
#- * 1st step: Welcome message
step_1:
# TODO: Put a bigger message with some instructions and agreement

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);


#- **********************************
#- * 2nd step: win files
step_2:
# TODO Get windows listing in a listbox and home listing in another listbox (gftp like) 

# Automatic configuration
#if($debug) { print "- Beginning automatic configuration\n"; }
#$wait_configuring = $in->wait_message(_("Configuring..."), 
#				      _("Finding all documents on your Windows partition. Can take several minutes."));

if($debug) { print "- Ready to copy all the documents, waiting for user response\n"; }

if(-e "@win[1]/My\ Documents") {
    print "-- @win[1]/My\ Documents found\n";
    $::direct or $in->ask_okcancel(_("Transfugdrake"),
       _("Do you want to copy all the content of @win[1]/My Documents to $ENV{HOME}/win_backup ?"), 1) or goto step_3;
    $wait_configuring = $in->wait_message(_("Copying files..."),
                         _("Copying all files from @win[1]/My Documents to $ENV{HOME}/win_backup."));
    mkdir("$ENV{HOME}/win_backup}");
    $file = File::Ncopy->new(recursive => 1);
    $file->copy("@win[1]/My\ Documents", "$ENV{HOME}/win_backup");
    undef $wait_configuring;
}
elsif(-e "@win[1]/Mes\ Documents") {
    print "-- @win[1]/Mes\ Documents found\n";
    $::direct or $in->ask_okcancel(_("Transfugdrake"),
       _("Do you want to copy all the content of @win[1]/My Documents to $ENV{HOME}/win_backup ?"), 1) or goto step_3;
    $wait_configuring = $in->wait_message(_("Copying files..."),
                         _("Copying all files from @win[1]/Mes Documents to $ENV{HOME}/win_backup."));
    mkdir("$ENV{HOME}/win_backup}");
    $file = File::Ncopy->new(recursive => 1);
    $file->copy("@win[1]/Mes\ Documents", "$ENV{HOME}/win_backup");
    undef $wait_configuring;
}
elsif(-e "@win[1]/Documents\ and\ Settings") {
    print "-- @win[1]/Documents and Settings found\n";
    my @doc_listing = split("\n", `ls @win[1]/Documents\\ and\\ Settings/`);
    $::direct or $in->ask_okcancel(_("Transfugdrake"),
       _("Do you want to copy all the content of @win[1]/Documents and Settings to $ENV{HOME} ?"), 1) or goto step_3;
    $wait_configuring = $in->wait_message(_("Copying files..."),
                         _("Copying all files from @win[1]/Documents and Settings to $ENV{HOME}."));
    $folders_count = 1;
    while(@doc_listing[$folders_count] ne "") {
        mkdir("$ENV{HOME}/win_backup/@doc_listing[$folders_count]");
        $file = File::NCopy->new(recursive => 1);
        $file->copy("@win[1]/Documents\ and\ Settings/@doc_listing[$folders_count]",
         "$ENV{HOME}/win_backup/@doc_listing[$folders_count]");
    }
    undef $wait_configuring;
}
else {
    $in->ask_warn(_("Can't find documents folder!"),
                  _("Can't find the folder where the documents are located. Exiting..."));
    quit_global($in);
}

#- *******************************
#- * 3rd step: mail from windows
step_3:

$::direct or $in->ask_okcancel(_("Transfug"),
_("We will bring back your Outlook Mailboxes to a standard unix mbox"), 1) or quit_global($in, 0);

mkdir "$ENV{HOME}/Mail" unless (-e "$ENV{HOME}/Mail");
$oe5onwin98="$win/WINDOWS/Application Data/Identities/{424975E0-8577-11D4-A891-989048140B20}/Microsoft/Outlook Express";

if (-e $oe5onwin98) {
    print "OE5 on win98 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\"`;
    }
    
}

#- *******************************
#- * 4th step: address book from windows
step_4:
$::direct or $in->ask_okcancel(_("Transfug"),
_("We will migrate your windows address book to mandrake"), 1) or quit_global($in, 0);

#- *******************************
#- * 5th step: finish
step_5:
$::direct or $in->ask_okcancel(_("Transfugdrake"),
_("The migration of all of your Windows data is finished."), 1) or quit_global($in, 0);