22 #include <tqcombobox.h>
24 #include <tdeapplication.h>
25 #include <tdeconfig.h>
26 #include <tdelocale.h>
28 #include <tdemessagebox.h>
30 #include <exchangeaccount.h>
32 #include "exchangeconfig.h"
34 ExchangeConfig::ExchangeConfig( KPIM::ExchangeAccount* account, TQWidget* parent )
35 : KDialogBase(Plain,i18n(
"Exchange Plugin"),Ok|Cancel,Ok,parent)
39 kdDebug(5850) <<
"Creating ExchangeConfig with account: " <<
40 account->host() <<
":" << account->account() << endl;
42 TQFrame *topFrame = plainPage();
43 TQGridLayout *topLayout =
new TQGridLayout( topFrame, 5, 3, 3 );
45 m_host =
new KLineEdit( mAccount->host(), topFrame );
46 topLayout->addWidget(
new TQLabel( i18n(
"Exchange server:" ), topFrame ), 0, 0 );
47 topLayout->addWidget( m_host, 0, 1 );
49 m_port =
new KLineEdit( mAccount->port(), topFrame );
50 topLayout->addWidget(
new TQLabel( i18n(
"Port:" ), topFrame ), 1, 0 );
51 topLayout->addWidget( m_port, 1, 1 );
53 m_user =
new KLineEdit( mAccount->account(), topFrame );
54 topLayout->addWidget(
new TQLabel( i18n(
"User:" ), topFrame ), 2, 0 );
55 topLayout->addWidget( m_user, 2, 1 );
56 connect( m_user, TQ_SIGNAL(textChanged(
const TQString&)),
this, TQ_SLOT(slotUserChanged(
const TQString&)) );
58 m_password =
new KLineEdit( mAccount->password(), topFrame );
59 topLayout->addWidget(
new TQLabel( i18n(
"Password:" ), topFrame ), 3, 0 );
60 topLayout->addWidget( m_password, 3, 1 );
61 m_password->setEchoMode( TQLineEdit::Password );
63 m_autoMailbox =
new TQCheckBox( i18n(
"Determine mailbox automatically" ), topFrame );
64 topLayout->addMultiCellWidget( m_autoMailbox, 4, 4, 0, 1 );
65 connect( m_autoMailbox, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotToggleAuto(
bool)) );
67 m_mailbox=
new KLineEdit( mAccount->mailbox(), topFrame );
68 topLayout->addWidget(
new TQLabel( i18n(
"Mailbox URL:" ), topFrame ), 5, 0 );
69 topLayout->addWidget( m_mailbox, 5, 1 );
71 m_tryFindMailbox =
new TQPushButton(
"&Find", topFrame );
72 topLayout->addWidget( m_tryFindMailbox, 5, 2 );
73 connect( m_tryFindMailbox, TQ_SIGNAL(clicked()),
this, TQ_SLOT(slotFindClicked()) );
75 kapp->config()->setGroup(
"Calendar/Exchange Plugin" );
76 bool autoChecked = kapp->config()->readBoolEntry(
"auto-mailbox",
true );
77 m_autoMailbox->setChecked( autoChecked );
80 ExchangeConfig::~ExchangeConfig()
84 void ExchangeConfig::slotToggleAuto(
bool on )
86 m_mailbox->setEnabled( ! on );
93 void ExchangeConfig::slotUserChanged(
const TQString& )
100 void ExchangeConfig::slotOk()
102 if ( m_autoMailbox->isChecked() ) {
103 TQString mailbox = mAccount->tryFindMailbox( m_host->text(), m_port->text(), m_user->text(), m_password->text() );
104 if ( mailbox.isNull() ) {
105 kdWarning() <<
"Could not find Exchange mailbox URL, incomplete settings!"<< endl;
106 KMessageBox::sorry(
this,
"Could not determine mailbox URL" );
109 mAccount->setMailbox( mailbox );
112 mAccount->setMailbox( m_mailbox->text() );
114 mAccount->setHost( m_host->text() );
115 mAccount->setPort( m_port->text() );
116 mAccount->setAccount( m_user->text() );
117 mAccount->setPassword( m_password->text() );
119 kapp->config()->setGroup(
"Calendar/Exchange Plugin" );
120 kapp->config()->writeEntry(
"auto-mailbox", m_autoMailbox->isChecked() );
125 void ExchangeConfig::slotFindClicked()
127 TQString mailbox = mAccount->tryFindMailbox( m_host->text(), m_port->text(), m_user->text(), m_password->text() );
128 if ( mailbox.isNull() ) {
129 KMessageBox::sorry(
this,
"Could not determine mailbox URL" );
131 m_mailbox->setText( mailbox );
135 #include "exchangeconfig.moc"