00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <qlayout.h>
00021 #include <qlabel.h>
00022 #include <qcombobox.h>
00023
00024 #include <kapplication.h>
00025 #include <kconfig.h>
00026 #include <klocale.h>
00027 #include <kdebug.h>
00028 #include <kmessagebox.h>
00029
00030 #include <exchangeaccount.h>
00031
00032 #include "exchangeconfig.h"
00033
00034 ExchangeConfig::ExchangeConfig( KPIM::ExchangeAccount* account, QWidget* parent )
00035 : KDialogBase(Plain,i18n("Exchange Plugin"),Ok|Cancel,Ok,parent)
00036 {
00037 mAccount = account;
00038
00039 kdDebug(5850) << "Creating ExchangeConfig with account: " <<
00040 account->host() << ":" << account->account() << endl;
00041
00042 QFrame *topFrame = plainPage();
00043 QGridLayout *topLayout = new QGridLayout( topFrame, 5, 3, 3 );
00044
00045 m_host = new KLineEdit( mAccount->host(), topFrame );
00046 topLayout->addWidget( new QLabel( i18n( "Exchange server:" ), topFrame ), 0, 0 );
00047 topLayout->addWidget( m_host, 0, 1 );
00048
00049 m_port = new KLineEdit( mAccount->port(), topFrame );
00050 topLayout->addWidget( new QLabel( i18n( "Port:" ), topFrame ), 1, 0 );
00051 topLayout->addWidget( m_port, 1, 1 );
00052
00053 m_user = new KLineEdit( mAccount->account(), topFrame );
00054 topLayout->addWidget( new QLabel( i18n( "User:" ), topFrame ), 2, 0 );
00055 topLayout->addWidget( m_user, 2, 1 );
00056 connect( m_user, SIGNAL(textChanged(const QString&)), this, SLOT(slotUserChanged(const QString&)) );
00057
00058 m_password = new KLineEdit( mAccount->password(), topFrame );
00059 topLayout->addWidget( new QLabel( i18n( "Password:" ), topFrame ), 3, 0 );
00060 topLayout->addWidget( m_password, 3, 1 );
00061 m_password->setEchoMode( QLineEdit::Password );
00062
00063 m_autoMailbox = new QCheckBox( i18n( "Determine mailbox automatically" ), topFrame );
00064 topLayout->addMultiCellWidget( m_autoMailbox, 4, 4, 0, 1 );
00065 connect( m_autoMailbox, SIGNAL(toggled(bool)), this, SLOT(slotToggleAuto(bool)) );
00066
00067 m_mailbox= new KLineEdit( mAccount->mailbox(), topFrame );
00068 topLayout->addWidget( new QLabel( i18n( "Mailbox URL:" ), topFrame ), 5, 0 );
00069 topLayout->addWidget( m_mailbox, 5, 1 );
00070
00071 m_tryFindMailbox = new QPushButton( "&Find", topFrame );
00072 topLayout->addWidget( m_tryFindMailbox, 5, 2 );
00073 connect( m_tryFindMailbox, SIGNAL(clicked()), this, SLOT(slotFindClicked()) );
00074
00075 kapp->config()->setGroup( "Calendar/Exchange Plugin" );
00076 bool autoChecked = kapp->config()->readBoolEntry( "auto-mailbox", true );
00077 m_autoMailbox->setChecked( autoChecked );
00078 }
00079
00080 ExchangeConfig::~ExchangeConfig()
00081 {
00082 }
00083
00084 void ExchangeConfig::slotToggleAuto( bool on )
00085 {
00086 m_mailbox->setEnabled( ! on );
00087
00088
00089
00090
00091 }
00092
00093 void ExchangeConfig::slotUserChanged( const QString& text )
00094 {
00095
00096
00097
00098 }
00099
00100 void ExchangeConfig::slotOk()
00101 {
00102 if ( m_autoMailbox->isChecked() ) {
00103 QString mailbox = mAccount->tryFindMailbox( m_host->text(), m_port->text(), m_user->text(), m_password->text() );
00104 if ( mailbox.isNull() ) {
00105 kdWarning() << "Could not find Exchange mailbox URL, incomplete settings!"<< endl;
00106 KMessageBox::sorry( this, "Could not determine mailbox URL" );
00107 return;
00108 } else {
00109 mAccount->setMailbox( mailbox );
00110 }
00111 } else {
00112 mAccount->setMailbox( m_mailbox->text() );
00113 }
00114 mAccount->setHost( m_host->text() );
00115 mAccount->setPort( m_port->text() );
00116 mAccount->setAccount( m_user->text() );
00117 mAccount->setPassword( m_password->text() );
00118
00119 kapp->config()->setGroup( "Calendar/Exchange Plugin" );
00120 kapp->config()->writeEntry( "auto-mailbox", m_autoMailbox->isChecked() );
00121
00122 accept();
00123 }
00124
00125 void ExchangeConfig::slotFindClicked()
00126 {
00127 QString mailbox = mAccount->tryFindMailbox( m_host->text(), m_port->text(), m_user->text(), m_password->text() );
00128 if ( mailbox.isNull() ) {
00129 KMessageBox::sorry( this, "Could not determine mailbox URL" );
00130 } else {
00131 m_mailbox->setText( mailbox );
00132 }
00133 }
00134
00135 #include "exchangeconfig.moc"