removed the content from template.docbook, which is completly unrelated to kmobiletools
[kdepim.git] / korn / pop3_proto.cpp
blob6c4d32676863d6d8ccbaf2fecd1483df0a90707a
1 /*
2 * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "pop3_proto.h"
22 #include "account_input.h"
24 #include <kdebug.h>
26 #include <QWidget>
27 #include <QObject>
28 #include <QList>
29 #include <QStringList>
30 #include <QVector>
32 void Pop3_Protocol::configFillGroupBoxes( QStringList* groupBoxes ) const
34 groupBoxes->append( "Server" );
35 groupBoxes->append( "Identify" );
38 void Pop3_Protocol::configFields( QVector< QWidget* >* vector, const QObject* configDialog, QList< AccountInput* > * result ) const
40 QMap< QString, QString > encrList;
41 encrList.insert( "ssl", i18n( "SSL" ) );
42 encrList.insert( "tls=auto", i18n( "TLS if possible" ) );
43 encrList.insert( "tls=on", i18n( "Always TLS" ) );
44 encrList.insert( "tls=off", i18n( "Never TLS" ) );
46 QMap< QString, QString > authList;
47 authList.insert( "", i18n( "Plain" ) );
48 authList.insert( "auth=APOP", i18n( "APOP" ) );
50 result->append( new TextInput( vector->at( 0 ), i18n( "Server" ), TextInput::text, "", "server" ) );
51 result->append( new TextInput( vector->at( 0 ), i18n( "Port" ), 0, 65535, "110", "port" ) );
52 result->append( new ComboInput( vector->at( 0 ), i18n( "Encryption" ), encrList, "tls=auto", "encryption" ) );
53 QObject::connect( (QObject*)result->last()->rightWidget(), SIGNAL( activated( int) ),
54 configDialog, SLOT( slotSSLChanged() ) );
56 result->append( new TextInput( vector->at( 1 ), i18n( "Username" ), TextInput::text, "", "username" ) );
57 result->append( new TextInput( vector->at( 1 ), i18n( "Password" ), TextInput::password, "", "password" ) );
58 result->append( new CheckboxInput( vector->at( 1 ), i18n( "Save password" ), "true", "savepassword" ) );
59 QObject::connect( (QObject*)result->at( result->size() - 1 )->rightWidget(), SIGNAL(toggled( bool)),
60 (QObject*)result->at( result->size() - 2 )->rightWidget(), SLOT(setEnabled(bool)) );
61 result->last()->setValue( "false" );
62 result->append( new ComboInput( vector->at( 1 ), i18n( "Authentication" ), authList, "", "auth" ) );
65 void Pop3_Protocol::readEntries( QMap< QString, QString >* map, QMap< QString, QString > *metadata ) const
67 if( map->contains( "ssl" ) && *map->find( "ssl" ) == "true" )
68 map->insert( "encryption", "ssl" );
69 if( metadata->contains( "tls" ) )
70 map->insert( "encryption", QString( "tls=%1" ).arg( *metadata->find( "tls" ) ) );
71 if( metadata->contains( "auth" ) )
72 map->insert( "auth", QString( "auth=APOP" ) );
75 void Pop3_Protocol::writeEntries( QMap< QString, QString >* map ) const
77 QString metadata;
78 if( map->contains( "encryption" ) )
80 if( *map->find( "encryption" ) == "ssl" )
81 map->insert( "ssl", "true" );
82 else
84 map->insert( "ssl", "false" );
85 metadata += *map->find( "encryption" );
87 map->remove( "encryption" );
90 if( map->contains( "auth" ) )
92 if( !metadata.isEmpty() && ! (*map->find( "auth" )).isEmpty() )
93 metadata += ',';
94 metadata += *map->find( "auth" );
95 map->remove( "auth" );
98 map->insert( "metadata", metadata );
100 clearFields( map, KIO_Protocol::mailbox );