00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "transportconfigdialog.h"
00026 #include "transport.h"
00027 #include "transportconfigwidget.h"
00028 #include "transportmanager.h"
00029 #include "transporttype.h"
00030 #include "sendmailconfigwidget.h"
00031 #include "smtpconfigwidget.h"
00032
00033 #include <QLabel>
00034 #include <QString>
00035
00036 #include <KDebug>
00037 #include <KLocalizedString>
00038
00039 using namespace MailTransport;
00040
00041 class MailTransport::TransportConfigDialog::Private
00042 {
00043 public:
00044 Transport *transport;
00045 QWidget *configWidget;
00046
00047
00048 void okClicked();
00049 };
00050
00051 void TransportConfigDialog::Private::okClicked()
00052 {
00053 if( TransportConfigWidget *w = dynamic_cast<TransportConfigWidget*>( configWidget ) ) {
00054
00055 w->apply();
00056 transport->writeConfig();
00057 }
00058 }
00059
00060 TransportConfigDialog::TransportConfigDialog( Transport *transport, QWidget *parent )
00061 : KDialog( parent ), d( new Private )
00062 {
00063 Q_ASSERT( transport );
00064 d->transport = transport;
00065
00066 switch( transport->type() ) {
00067 case Transport::EnumType::SMTP:
00068 {
00069 d->configWidget = new SMTPConfigWidget( transport, this );
00070 break;
00071 }
00072 case Transport::EnumType::Sendmail:
00073 {
00074 d->configWidget = new SendmailConfigWidget( transport, this );
00075 break;
00076 }
00077 case Transport::EnumType::Akonadi:
00078 {
00079 kWarning() << "Tried to configure an Akonadi transport.";
00080 d->configWidget = new QLabel( i18n( "This transport cannot be configured." ), this );
00081 break;
00082 }
00083 default:
00084 {
00085 Q_ASSERT( false );
00086 d->configWidget = 0;
00087 break;
00088 }
00089 }
00090 setMainWidget( d->configWidget );
00091
00092 setButtons( Ok|Cancel );
00093 connect( this, SIGNAL(okClicked()), this, SLOT(okClicked()) );
00094 }
00095
00096 TransportConfigDialog::~TransportConfigDialog()
00097 {
00098 delete d;
00099 }
00100
00101 #include "transportconfigdialog.moc"