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() << "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_user = new KLineEdit( mAccount->account(), topFrame );
00050 topLayout->addWidget( new QLabel( i18n( "User:" ), topFrame ), 1, 0 );
00051 topLayout->addWidget( m_user, 1, 1 );
00052
00053 m_password = new KLineEdit( mAccount->password(), topFrame );
00054 topLayout->addWidget( new QLabel( i18n( "Password:" ), topFrame ), 2, 0 );
00055 topLayout->addWidget( m_password, 2, 1 );
00056 m_password->setEchoMode( QLineEdit::Password );
00057
00058 m_autoMailbox = new QCheckBox( i18n( "Determine mailbox automatically" ), topFrame );
00059 topLayout->addMultiCellWidget( m_autoMailbox, 3, 3, 0, 1 );
00060 connect( m_autoMailbox, SIGNAL(toggled(bool)), this, SLOT(slotToggleAuto(bool)) );
00061
00062 m_mailbox= new KLineEdit( mAccount->mailbox(), topFrame );
00063 topLayout->addWidget( new QLabel( i18n( "Mailbox URL:" ), topFrame ), 4, 0 );
00064 topLayout->addWidget( m_mailbox, 4, 1 );
00065
00066 m_tryFindMailbox = new QPushButton( "&Find", topFrame );
00067 topLayout->addWidget( m_tryFindMailbox, 4, 2 );
00068 connect( m_tryFindMailbox, SIGNAL(clicked()), this, SLOT(slotFindClicked()) );
00069
00070 kapp->config()->setGroup( "Calendar/Exchange Plugin" );
00071 bool autoChecked = kapp->config()->readBoolEntry( "auto-mailbox", true );
00072 m_autoMailbox->setChecked( autoChecked );
00073 }
00074
00075 ExchangeConfig::~ExchangeConfig()
00076 {
00077 }
00078
00079 void ExchangeConfig::slotToggleAuto( bool on )
00080 {
00081 m_mailbox->setEnabled( ! on );
00082 }
00083
00084 void ExchangeConfig::slotOk()
00085 {
00086 if ( m_autoMailbox->isChecked() ) {
00087 QString mailbox = mAccount->tryFindMailbox( m_host->text(), m_user->text(), m_password->text() );
00088 if ( mailbox.isNull() ) {
00089 kdWarning() << "Could not find Exchange mailbox URL, incomplete settings!"<< endl;
00090 KMessageBox::sorry( this, "Could not determine mailbox URL" );
00091 return;
00092 } else {
00093 mAccount->setMailbox( mailbox );
00094 }
00095 } else {
00096 mAccount->setMailbox( m_mailbox->text() );
00097 }
00098 mAccount->setHost( m_host->text() );
00099 mAccount->setAccount( m_user->text() );
00100 mAccount->setPassword( m_password->text() );
00101
00102 kapp->config()->setGroup( "Calendar/Exchange Plugin" );
00103 kapp->config()->writeEntry( "auto-mailbox", m_autoMailbox->isChecked() );
00104
00105 accept();
00106 }
00107
00108 void ExchangeConfig::slotFindClicked()
00109 {
00110 QString mailbox = mAccount->tryFindMailbox( m_host->text(), m_user->text(), m_password->text() );
00111 if ( mailbox.isNull() ) {
00112 KMessageBox::sorry( this, "Could not determine mailbox URL" );
00113 } else {
00114 m_mailbox->setText( mailbox );
00115 }
00116 }
00117
00118 #include "exchangeconfig.moc"