kmail

vacationdialog.cpp
1/*
2 vacationdialog.cpp
3
4 KMail, the KDE mail client.
5 Copyright (c) 2002 Marc Mutz <mutz@kde.org>
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License,
9 version 2.0, as published by the Free Software Foundation.
10 You should have received a copy of the GNU General Public License
11 along with this program; if not, write to the Free Software Foundation,
12 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
13*/
14
15#ifdef HAVE_CONFIG_H
16#include <config.h>
17#endif
18
19#include "vacationdialog.h"
20
21#include <kmime_header_parsing.h>
22using KMime::Types::AddrSpecList;
23using KMime::Types::AddressList;
24using KMime::Types::MailboxList;
25using KMime::HeaderParsing::parseAddressList;
26
27#include <knuminput.h>
28#include <tdelocale.h>
29#include <kdebug.h>
30#include <twin.h>
31#include <tdeapplication.h>
32
33#include <tqlayout.h>
34#include <tqlabel.h>
35#include <tqcheckbox.h>
36#include <tqlineedit.h>
37#include <tqtextedit.h>
38#include <tqvalidator.h>
39
40namespace KMail {
41
42 VacationDialog::VacationDialog( const TQString & caption, TQWidget * parent,
43 const char * name, bool modal )
44 : KDialogBase( Plain, caption, Ok|Cancel|Default, Ok, parent, name, modal )
45 {
46 KWin::setIcons( winId(), tdeApp->icon(), tdeApp->miniIcon() );
47
48 static const int rows = 7;
49 int row = -1;
50
51 TQGridLayout * glay = new TQGridLayout( plainPage(), rows, 2, 0, spacingHint() );
52 glay->setColStretch( 1, 1 );
53
54 // explanation label:
55 ++row;
56 glay->addMultiCellWidget( new TQLabel( i18n("Configure vacation "
57 "notifications to be sent:"),
58 plainPage() ), row, row, 0, 1 );
59
60 // Activate checkbox:
61 ++row;
62 mActiveCheck = new TQCheckBox( i18n("&Activate vacation notifications"), plainPage() );
63 glay->addMultiCellWidget( mActiveCheck, row, row, 0, 1 );
64
65 // Message text edit:
66 ++row;
67 glay->setRowStretch( row, 1 );
68 mTextEdit = new TQTextEdit( plainPage(), "mTextEdit" );
69 mTextEdit->setTextFormat( TQTextEdit::PlainText );
70 glay->addMultiCellWidget( mTextEdit, row, row, 0, 1 );
71
72 // "Resent only after" spinbox and label:
73 ++row;
74 int defDayInterval = 7; //default day interval
75 mIntervalSpin = new KIntSpinBox( 1, 356, 1, defDayInterval, 10, plainPage(), "mIntervalSpin" );
76 mIntervalSpin->setSuffix( i18n(" day", " days", defDayInterval) );
77 connect(mIntervalSpin, TQ_SIGNAL( valueChanged( int )), TQ_SLOT( slotIntervalSpinChanged( int ) ) );
78 glay->addWidget( new TQLabel( mIntervalSpin, i18n("&Resend notification only after:"), plainPage() ), row, 0 );
79 glay->addWidget( mIntervalSpin, row, 1 );
80
81 // "Send responses for these addresses" lineedit and label:
82 ++row;
83 mMailAliasesEdit = new TQLineEdit( plainPage(), "mMailAliasesEdit" );
84 glay->addWidget( new TQLabel( mMailAliasesEdit, i18n("&Send responses for these addresses:"), plainPage() ), row, 0 );
85 glay->addWidget( mMailAliasesEdit, row, 1 );
86
87 // "Send responses also to SPAM mail" checkbox:
88 ++row;
89 mSpamCheck = new TQCheckBox( i18n("Do not send vacation replies to spam messages"), plainPage(), "mSpamCheck" );
90 mSpamCheck->setChecked( true );
91 glay->addMultiCellWidget( mSpamCheck, row, row, 0, 1 );
92
93 // domain checkbox and linedit:
94 ++row;
95 mDomainCheck = new TQCheckBox( i18n("Only react to mail coming from domain"), plainPage(), "mDomainCheck" );
96 mDomainCheck->setChecked( false );
97 mDomainEdit = new TQLineEdit( plainPage(), "mDomainEdit" );
98 mDomainEdit->setEnabled( false );
99 mDomainEdit->setValidator( new TQRegExpValidator( TQRegExp( "[a-zA-Z0-9+-]+(?:\\.[a-zA-Z0-9+-]+)*" ), mDomainEdit ) );
100 glay->addWidget( mDomainCheck, row, 0 );
101 glay->addWidget( mDomainEdit, row, 1 );
102 connect( mDomainCheck, TQ_SIGNAL(toggled(bool)),
103 mDomainEdit, TQ_SLOT(setEnabled(bool)) );
104
105 Q_ASSERT( row == rows - 1 );
106 }
107
108 VacationDialog::~VacationDialog() {
109 kdDebug(5006) << "~VacationDialog()" << endl;
110 }
111
112 bool VacationDialog::activateVacation() const {
113 return mActiveCheck->isChecked();
114 }
115
116 void VacationDialog::setActivateVacation( bool activate ) {
117 mActiveCheck->setChecked( activate );
118 }
119
120 TQString VacationDialog::messageText() const {
121 return mTextEdit->text().stripWhiteSpace();
122 }
123
124 void VacationDialog::setMessageText( const TQString & text ) {
125 mTextEdit->setText( text );
126 const int height = ( mTextEdit->fontMetrics().lineSpacing() + 1 ) * 11;
127 mTextEdit->setMinimumHeight( height );
128 }
129
130 int VacationDialog::notificationInterval() const {
131 return mIntervalSpin->value();
132 }
133
134 void VacationDialog::setNotificationInterval( int days ) {
135 mIntervalSpin->setValue( days );
136 }
137
138 AddrSpecList VacationDialog::mailAliases() const {
139 TQCString text = mMailAliasesEdit->text().latin1(); // ### IMAA: !ok
140 AddressList al;
141 const char * s = text.begin();
142 parseAddressList( s, text.end(), al );
143
144 AddrSpecList asl;
145 for ( AddressList::const_iterator it = al.begin() ; it != al.end() ; ++it ) {
146 const MailboxList & mbl = (*it).mailboxList;
147 for ( MailboxList::const_iterator jt = mbl.begin() ; jt != mbl.end() ; ++jt )
148 asl.push_back( (*jt).addrSpec );
149 }
150 return asl;
151 }
152
153 void VacationDialog::setMailAliases( const AddrSpecList & aliases ) {
154 TQStringList sl;
155 for ( AddrSpecList::const_iterator it = aliases.begin() ; it != aliases.end() ; ++it )
156 sl.push_back( (*it).asString() );
157 mMailAliasesEdit->setText( sl.join(", ") );
158 }
159
160 void VacationDialog::setMailAliases( const TQString & aliases ) {
161 mMailAliasesEdit->setText( aliases );
162 }
163
164 void VacationDialog::slotIntervalSpinChanged ( int value ) {
165 mIntervalSpin->setSuffix( i18n(" day", " days", value) );
166 }
167
168 TQString VacationDialog::domainName() const {
169 return mDomainCheck->isChecked() ? mDomainEdit->text() : TQString() ;
170 }
171
172 void VacationDialog::setDomainName( const TQString & domain ) {
173 if ( !domain.isEmpty() ) {
174 mDomainEdit->setText( domain );
175 mDomainCheck->setChecked( true );
176 }
177 }
178
179 bool VacationDialog::domainCheck() const
180 {
181 return mDomainCheck->isChecked();
182 }
183
184 void VacationDialog::setDomainCheck( bool check )
185 {
186 mDomainCheck->setChecked( check );
187 }
188
189 bool VacationDialog::sendForSpam() const
190 {
191 return !mSpamCheck->isChecked();
192 }
193
194 void VacationDialog::setSendForSpam( bool enable )
195 {
196 mSpamCheck->setChecked( !enable );
197 }
198
199 /* virtual*/
200 void KMail::VacationDialog::enableDomainAndSendForSpam( bool enable )
201 {
202 mDomainCheck->setEnabled( enable );
203 mDomainEdit->setEnabled( enable && mDomainCheck->isChecked() );
204 mSpamCheck->setEnabled( enable );
205 }
206
207} // namespace KMail
208
209#include "vacationdialog.moc"
@ Ok
The user rights/ACL have been fetched from the server sucessfully.
Definition: acljobs.h:66
folderdiaquotatab.h
Definition: aboutdata.cpp:40