1/*
2 Copyright (c) 2010 Tom Albers <toma@kde.org>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#include "servertest.h"
21#include <mailtransport/transport.h>
22#include <mailtransport/servertest.h>
23
24#include <kdebug.h>
25#include <kmessagebox.h>
26#include <klocale.h>
27
28ServerTest::ServerTest( QObject* parent) :
29 QObject(parent), m_serverTest( new MailTransport::ServerTest( 0 ) )
30{
31 kDebug() << "Welcome!";
32 connect( m_serverTest, SIGNAL(finished(QList<int>)),
33 SLOT(testFinished(QList<int>)) );
34}
35
36ServerTest::~ServerTest()
37{
38 delete m_serverTest;
39}
40
41void ServerTest::test( const QString server, const QString protocol )
42{
43 kDebug() << server << protocol;
44 m_serverTest->setServer( server );
45 m_serverTest->setProtocol( protocol );
46 m_serverTest->start();
47}
48
49void ServerTest::testFinished( QList< int > list )
50{
51 kDebug() << "types: " << list;
52 if ( list.contains( MailTransport::Transport::EnumEncryption::TLS ) ) {
53 emit testResult( QLatin1String("tls") );
54 } else if ( list.contains( MailTransport::Transport::EnumEncryption::SSL ) ) {
55 emit testResult( QLatin1String("ssl") );
56 } else {
57 KMessageBox::information( 0, i18n( "There seems to be a problem in reaching this server "
58 "or choosing a safe way to sent the credentials to server. We advise you to "
59 "check the settings of the account and adjust it manually if needed." ),
60 i18n( "Autodetecting settings failed" ) );
61 emit testFail();
62 }
63}
64
65