Commit ab3b7331 authored by Volker Krause's avatar Volker Krause
Browse files

complete config migration from KMail and KNode

svn path=/trunk/KDE/kdepim/mailtransport/; revision=618576
parent 8519f218
......@@ -8,10 +8,8 @@ General
Migration
---------
- migration from kmail and knode config files
- password migration within kwallet (for kmail and knode), requires KWallet to
be fixed first
- convert enum valus (eg '-' is not supported by kcfg)
- reading passwords from config file still using legacy encryption
TransportManager
......
......@@ -3,3 +3,9 @@ Id=initial-kmail-migration
File=kmailrc,mailtransports
ScriptArguments=kmail
Script=migrate-transports.pl,perl
# Migrate knode's mailserver settings
Id=initial-knode-migration
File=knoderc,mailtransports
ScriptArguments=knode
Script=migrate-transports.pl,perl
......@@ -14,25 +14,51 @@
$currentGroup = "";
$source = $ARGV[0];
%knode_key_map = (
"server", "host",
"needsLogon", "auth",
"timeout", "",
"holdTime", ""
);
while (<STDIN>) {
next if /^$/;
# recognize groups:
if ( /^\[(.+)\]$/ ) {
$currentGroup = $1;
if ( $currentGroup =~ /^Transport/ ) {
if ( $source eq "kmail" && $currentGroup =~ /^Transport/ ) {
print "# DELETEGROUP [$currentGroup]\n";
$groupid = $currentGroup;
$groupid =~ s/^Transport //;
print "[Transport kmail-$groupid]\n";
}
elsif ( $source eq "knode" && $currentGroup eq "MAILSERVER" ) {
print "# DELETEGROUP [$currentGroup]\n";
print "[$currentGroup]\n";
print "[Transport knode-0]\n";
print "name=KNode Mail Transport\n";
}
next;
};
($key,$value) = split /=/;
chomp $value;
# Move over keys from the transport groups
if ( $currentGroup =~ /^Transport/ ) {
print;
if ( $source eq "kmail" && $currentGroup =~ /^Transport/ ) {
if ( $key eq "authtype" ) {
$value =~ s/-/_/g;
}
print "$key=$value\n";
}
elsif ( $source eq "knode" && $currentGroup eq "MAILSERVER" ) {
$key = $knode_key_map{$key} if exists $knode_key_map{$key};
next if $key eq "";
print "$key=$value\n";
}
# Move over the key for the default transport
elsif ( $currentGroup eq 'Composer' ) {
($key,$value) = split /=/;
chomp $value;
elsif ( $source eq "kmail" && $currentGroup eq 'Composer' ) {
if ( $key eq 'default-transport' ) {
print "[General]\n$key=$value\n";
#print "# DELETE [$currentGroup]$key\n";
......
......@@ -98,12 +98,9 @@ QList< Transport * > TransportManager::transports() const
Transport* TransportManager::createTransport() const
{
int id;
do {
id = KRandom::random();
} while ( mConfig->hasGroup( QString::fromLatin1( "Transport %1" ).arg( id ) ) );
int id = createId();
Transport *t = new Transport( QString::number( id ) );
t->setId( createId() );
t->setId( id );
return t;
}
......@@ -175,15 +172,16 @@ void TransportManager::readConfig()
qDeleteAll( mTransports );
mTransports.clear();
QRegExp re( "^Transport (\\d+)$" );
QRegExp re( "^Transport (.+)$" );
QStringList groups = mConfig->groupList().filter( re );
foreach ( QString s, groups ) {
re.indexIn( s );
Transport* t = new Transport( re.cap( 1 ) );
if ( !t->isNull() )
mTransports.append( t );
else
kWarning() << k_funcinfo << "Found invalid transport id - skipping" << endl;
if ( t->id() <= 0 ) {
t->setId( createId() );
t->writeConfig();
}
mTransports.append( t );
}
// read default transport
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment