22 #include "vacationdialog.h"
24 using KMail::SieveJob;
26 #include "kmmainwidget.h"
27 #include "accountmanager.h"
29 #include "kmacctimap.h"
30 #include "kmmessage.h"
31 #include "globalsettings.h"
32 #include <libkpimidentities/identitymanager.h>
33 #include <libkpimidentities/identity.h>
35 #include <kmime_header_parsing.h>
36 using KMime::Types::AddrSpecList;
38 #include <ksieve/parser.h>
39 #include <ksieve/scriptbuilder.h>
40 #include <ksieve/error.h>
42 #include <tdelocale.h>
43 #include <tdemessagebox.h>
46 #include <tqdatetime.h>
55 class MultiScriptBuilder :
public KSieve::ScriptBuilder {
56 std::vector<KSieve::ScriptBuilder*> mBuilders;
58 MultiScriptBuilder() : KSieve::ScriptBuilder() {}
59 MultiScriptBuilder( KSieve::ScriptBuilder * sb1 )
60 : KSieve::ScriptBuilder(), mBuilders( 1 )
65 MultiScriptBuilder( KSieve::ScriptBuilder * sb1,
66 KSieve::ScriptBuilder * sb2 )
67 : KSieve::ScriptBuilder(), mBuilders( 2 )
71 assert( sb1 ); assert( sb2 );
73 MultiScriptBuilder( KSieve::ScriptBuilder * sb1,
74 KSieve::ScriptBuilder * sb2,
75 KSieve::ScriptBuilder * sb3 )
76 : KSieve::ScriptBuilder(), mBuilders( 3 )
81 assert( sb1 ); assert( sb2 ); assert( sb3 );
83 ~MultiScriptBuilder() {}
88 #define FOREACH for ( std::vector<KSieve::ScriptBuilder*>::const_iterator it = mBuilders.begin(), end = mBuilders.end() ; it != end ; ++it ) (*it)->
89 void commandStart(
const TQString & identifier ) { FOREACH commandStart( identifier ); }
90 void commandEnd() { FOREACH commandEnd(); }
91 void testStart(
const TQString & identifier ) { FOREACH testStart( identifier ); }
92 void testEnd() { FOREACH testEnd(); }
93 void testListStart() { FOREACH testListStart(); }
94 void testListEnd() { FOREACH testListEnd(); }
95 void blockStart() { FOREACH blockStart(); }
96 void blockEnd() { FOREACH blockEnd(); }
97 void hashComment(
const TQString & comment ) { FOREACH hashComment( comment ); }
98 void bracketComment(
const TQString & comment ) { FOREACH bracketComment( comment ); }
99 void lineFeed() { FOREACH lineFeed(); }
100 void error(
const KSieve::Error & e ) { FOREACH error( e ); }
101 void finished() { FOREACH finished(); }
102 void taggedArgument(
const TQString & tag ) { FOREACH taggedArgument( tag ); }
103 void stringArgument(
const TQString &
string,
bool multiline,
const TQString & fixme ) { FOREACH stringArgument(
string, multiline, fixme ); }
104 void numberArgument(
unsigned long number,
char quantifier ) { FOREACH numberArgument( number, quantifier ); }
105 void stringListArgumentStart() { FOREACH stringListArgumentStart(); }
106 void stringListEntry(
const TQString &
string,
bool multiline,
const TQString & fixme) { FOREACH stringListEntry(
string, multiline, fixme ); }
107 void stringListArgumentEnd() { FOREACH stringListArgumentEnd(); }
115 class GenericInformationExtractor :
public KSieve::ScriptBuilder {
130 StringListArgumentStart,
132 StringListArgumentEnd
138 BuilderMethod method;
143 const char * save_tag;
146 const std::vector<StateNode> mNodes;
147 std::map<TQString,TQString> mResults;
148 std::set<unsigned int> mRecursionGuard;
153 GenericInformationExtractor(
const std::vector<StateNode> & nodes )
154 : KSieve::ScriptBuilder(), mNodes( nodes ), mState( 0 ), mNestingDepth( 0 ) {}
156 const std::map<TQString,TQString> & results()
const {
return mResults; }
159 void process( BuilderMethod method,
const TQString &
string=TQString() ) {
160 doProcess( method,
string );
161 mRecursionGuard.clear();
163 void doProcess( BuilderMethod method,
const TQString &
string ) {
164 mRecursionGuard.insert( mState );
166 const StateNode & expected = mNodes[mState];
167 if ( expected.depth != -1 && mNestingDepth != expected.depth )
169 if ( expected.method != Any && method != expected.method )
171 if (
const char * str = expected.string )
172 if (
string.lower() != TQString::fromUtf8( str ).lower() )
174 kdDebug(5006) << ( found ?
"found: " :
"not found: " )
176 << ( found ? expected.if_found : expected.if_not_found ) << endl;
177 mState = found ? expected.if_found : expected.if_not_found ;
178 assert( mState < mNodes.size() );
180 if (
const char * save_tag = expected.save_tag )
181 mResults[save_tag] = string;
182 if ( !found && !mRecursionGuard.count( mState ) ) {
183 doProcess( method,
string );
186 void commandStart(
const TQString & identifier ) { kdDebug(5006) << k_funcinfo << endl; process( CommandStart, identifier ); }
187 void commandEnd() { kdDebug(5006) << k_funcinfo << endl; process( CommandEnd ); }
188 void testStart(
const TQString & identifier ) { kdDebug(5006) << k_funcinfo << endl; process( TestStart, identifier ); }
189 void testEnd() { kdDebug(5006) << k_funcinfo << endl; process( TestEnd ); }
190 void testListStart() { kdDebug(5006) << k_funcinfo << endl; process( TestListStart ); }
191 void testListEnd() { kdDebug(5006) << k_funcinfo << endl; process( TestListEnd ); }
192 void blockStart() { kdDebug(5006) << k_funcinfo << endl; process( BlockStart ); ++mNestingDepth; }
193 void blockEnd() { kdDebug(5006) << k_funcinfo << endl; --mNestingDepth; process( BlockEnd ); }
194 void hashComment(
const TQString & ) { kdDebug(5006) << k_funcinfo << endl; }
195 void bracketComment(
const TQString & ) { kdDebug(5006) << k_funcinfo << endl; }
196 void lineFeed() { kdDebug(5006) << k_funcinfo << endl; }
197 void error(
const KSieve::Error & ) {
198 kdDebug(5006) << k_funcinfo << endl;
201 void finished() { kdDebug(5006) << k_funcinfo << endl; }
203 void taggedArgument(
const TQString & tag ) { kdDebug(5006) << k_funcinfo << endl; process( TaggedArgument, tag ); }
204 void stringArgument(
const TQString &
string,
bool,
const TQString & ) { kdDebug(5006) << k_funcinfo << endl; process( StringArgument,
string ); }
205 void numberArgument(
unsigned long number,
char ) { kdDebug(5006) << k_funcinfo << endl; process( NumberArgument, TQString::number( number ) ); }
206 void stringListArgumentStart() { kdDebug(5006) << k_funcinfo << endl; process( StringListArgumentStart ); }
207 void stringListEntry(
const TQString &
string,
bool,
const TQString & ) { kdDebug(5006) << k_funcinfo << endl; process( StringListEntry,
string ); }
208 void stringListArgumentEnd() { kdDebug(5006) << k_funcinfo << endl; process( StringListArgumentEnd ); }
211 typedef GenericInformationExtractor GIE;
212 static const GenericInformationExtractor::StateNode spamNodes[] = {
213 { 0, GIE::CommandStart,
"if", 1, 0, 0 },
214 { 0, GIE::TestStart,
"header", 2, 0, 0 },
215 { 0, GIE::TaggedArgument,
"contains", 3, 0, 0 },
218 { 0, GIE::StringArgument,
"x-spam-flag", 9, 4,
"x-spam-flag" },
219 { 0, GIE::StringListArgumentStart, 0, 5, 0, 0 },
220 { 0, GIE::StringListEntry,
"x-spam-flag", 6, 7,
"x-spam-flag" },
221 { 0, GIE::StringListEntry, 0, 6, 8, 0 },
222 { 0, GIE::StringListArgumentEnd, 0, 0, 5, 0 },
223 { 0, GIE::StringListArgumentEnd, 0, 9, 0, 0 },
226 { 0, GIE::StringArgument,
"yes", 15, 10,
"spam-flag-yes" },
227 { 0, GIE::StringListArgumentStart, 0, 11, 0, 0 },
228 { 0, GIE::StringListEntry,
"yes", 12, 13,
"spam-flag-yes" },
229 { 0, GIE::StringListEntry, 0, 12, 14, 0 },
230 { 0, GIE::StringListArgumentEnd, 0, 0, 11, 0 },
231 { 0, GIE::StringListArgumentEnd, 0, 15, 0, 0 },
233 { 0, GIE::TestEnd, 0, 16, 0, 0 },
236 { 0, GIE::BlockStart, 0, 17, 0, 0 },
237 { 1, GIE::CommandStart,
"stop", 20, 19,
"stop" },
238 { -1, GIE::Any, 0, 17, 0, 0 },
239 { 0, GIE::BlockEnd, 0, 0, 18, 0 },
241 { -1, GIE::Any, 0, 20, 20, 0 },
243 static const unsigned int numSpamNodes =
sizeof spamNodes /
sizeof *spamNodes ;
245 class SpamDataExtractor :
public GenericInformationExtractor {
248 : GenericInformationExtractor( std::vector<StateNode>( spamNodes, spamNodes + numSpamNodes ) )
254 return mResults.count(
"x-spam-flag" ) &&
255 mResults.count(
"spam-flag-yes" ) &&
256 mResults.count(
"stop" ) ;
263 static const GenericInformationExtractor::StateNode domainNodes[] = {
264 { 0, GIE::CommandStart,
"if", 1, 0, 0 },
265 { 0, GIE::TestStart,
"not", 2, 0, 0, },
266 { 0, GIE::TestStart,
"address", 3, 0, 0 },
269 { 0, GIE::TaggedArgument,
"domain", 4, 5, 0 },
270 { 0, GIE::TaggedArgument,
"contains", 7, 0, 0 },
271 { 0, GIE::TaggedArgument,
"contains", 6, 0, 0 },
272 { 0, GIE::TaggedArgument,
"domain", 7, 0, 0 },
275 { 0, GIE::StringArgument,
"from", 13, 8,
"from" },
276 { 0, GIE::StringListArgumentStart, 0, 9, 0, 0 },
277 { 0, GIE::StringListEntry,
"from", 10, 11,
"from" },
278 { 0, GIE::StringListEntry, 0, 10, 12, 0 },
279 { 0, GIE::StringListArgumentEnd, 0, 0, 9, 0 },
280 { 0, GIE::StringListArgumentEnd, 0, 13, 0, 0 },
283 { 0, GIE::StringArgument, 0, 17, 14,
"domainName" },
284 { 0, GIE::StringListArgumentStart, 0, 15, 0, 0 },
285 { 0, GIE::StringListEntry, 0, 15, 16,
"domainName" },
286 { 0, GIE::StringListArgumentEnd, 0, 17, 0, 0 },
288 { 0, GIE::TestEnd, 0, 18, 0, 0 },
289 { 0, GIE::TestEnd, 0, 19, 0, 0 },
292 { 0, GIE::BlockStart, 0, 20, 0, 0 },
293 { 1, GIE::CommandStart,
"stop", 23, 22,
"stop" },
294 { -1, GIE::Any, 0, 20, 0, 0 },
295 { 0, GIE::BlockEnd, 0, 0, 21, 0 },
297 { -1, GIE::Any, 0, 23, 23, 0 }
299 static const unsigned int numDomainNodes =
sizeof domainNodes /
sizeof *domainNodes ;
301 class DomainRestrictionDataExtractor :
public GenericInformationExtractor {
303 DomainRestrictionDataExtractor()
304 : GenericInformationExtractor( std::vector<StateNode>( domainNodes, domainNodes+numDomainNodes ) )
309 TQString domainName() {
310 return mResults.count(
"stop" ) && mResults.count(
"from" )
311 ? mResults[
"domainName"] : TQString() ;
315 class VacationDataExtractor :
public KSieve::ScriptBuilder {
324 VacationDataExtractor()
325 : KSieve::ScriptBuilder(),
326 mContext( None ), mNotificationInterval( 0 )
328 kdDebug(5006) <<
"VacationDataExtractor instantiated" << endl;
330 virtual ~VacationDataExtractor() {}
332 int notificationInterval()
const {
return mNotificationInterval; }
333 const TQString & messageText()
const {
return mMessageText; }
334 const TQStringList & aliases()
const {
return mAliases; }
337 void commandStart(
const TQString & identifier ) {
338 kdDebug( 5006 ) <<
"VacationDataExtractor::commandStart( \"" << identifier <<
"\" )" << endl;
339 if ( identifier !=
"vacation" )
342 mContext = VacationCommand;
346 kdDebug( 5006 ) <<
"VacationDataExtractor::commandEnd()" << endl;
350 void testStart(
const TQString & ) {}
352 void testListStart() {}
353 void testListEnd() {}
356 void hashComment(
const TQString & ) {}
357 void bracketComment(
const TQString & ) {}
359 void error(
const KSieve::Error & e ) {
360 kdDebug( 5006 ) <<
"VacationDataExtractor::error() ### "
361 << e.asString() <<
" @ " << e.line() <<
"," << e.column()
366 void taggedArgument(
const TQString & tag ) {
367 kdDebug( 5006 ) <<
"VacationDataExtractor::taggedArgument( \"" << tag <<
"\" )" << endl;
368 if ( mContext != VacationCommand )
372 else if ( tag ==
"addresses" )
373 mContext = Addresses;
376 void stringArgument(
const TQString &
string,
bool,
const TQString & ) {
377 kdDebug( 5006 ) <<
"VacationDataExtractor::stringArgument( \"" <<
string <<
"\" )" << endl;
378 if ( mContext == Addresses ) {
379 mAliases.push_back(
string );
380 mContext = VacationCommand;
381 }
else if ( mContext == VacationCommand ) {
382 mMessageText = string;
383 mContext = VacationCommand;
387 void numberArgument(
unsigned long number,
char ) {
388 kdDebug( 5006 ) <<
"VacationDataExtractor::numberArgument( \"" << number <<
"\" )" << endl;
389 if ( mContext != Days )
391 if ( number > INT_MAX )
392 mNotificationInterval = INT_MAX;
394 mNotificationInterval = number;
395 mContext = VacationCommand;
398 void stringListArgumentStart() {}
399 void stringListEntry(
const TQString &
string,
bool,
const TQString & ) {
400 kdDebug( 5006 ) <<
"VacationDataExtractor::stringListEntry( \"" <<
string <<
"\" )" << endl;
401 if ( mContext != Addresses )
403 mAliases.push_back(
string );
405 void stringListArgumentEnd() {
406 kdDebug( 5006 ) <<
"VacationDataExtractor::stringListArgumentEnd()" << endl;
407 if ( mContext != Addresses )
409 mContext = VacationCommand;
414 int mNotificationInterval;
415 TQString mMessageText;
416 TQStringList mAliases;
419 kdDebug(5006) <<
"VacationDataExtractor::reset()" << endl;
421 mNotificationInterval = 0;
423 mMessageText = TQString();
431 Vacation::Vacation( TQObject * parent,
bool checkOnly,
const char * name )
432 : TQObject( parent, name ), mSieveJob( 0 ), mDialog( 0 ), mWasActive( false ), mCheckOnly( checkOnly )
435 kdDebug(5006) <<
"Vacation: found url \"" << mUrl.prettyURL() <<
"\"" << endl;
436 if ( mUrl.isEmpty() )
438 mSieveJob = SieveJob::get( mUrl, !checkOnly );
439 connect( mSieveJob, TQ_SIGNAL(gotScript(KMail::SieveJob*,
bool,
const TQString&,
bool)),
440 TQ_SLOT(slotGetResult(KMail::SieveJob*,
bool,
const TQString&,
bool)) );
443 Vacation::~Vacation() {
444 if ( mSieveJob ) mSieveJob->kill(); mSieveJob = 0;
445 delete mDialog; mDialog = 0;
446 kdDebug(5006) <<
"~Vacation()" << endl;
449 static inline TQString dotstuff( TQString s ) {
450 if ( s.startsWith(
"." ) )
451 return '.' + s.replace(
"\n.",
"\n.." );
453 return s.replace(
"\n.",
"\n.." );
456 TQString Vacation::composeScript(
const TQString & messageText,
457 int notificationInterval,
458 const AddrSpecList & addrSpecs,
459 bool sendForSpam,
const TQString & domain )
461 TQString addressesArgument;
462 TQStringList aliases;
463 if ( !addrSpecs.empty() ) {
464 addressesArgument +=
":addresses [ ";
466 for ( AddrSpecList::const_iterator it = addrSpecs.begin() ; it != addrSpecs.end() ; ++it ) {
467 sl.push_back(
'"' + (*it).asString().replace(
'\\',
"\\\\" ).replace(
'"',
"\\\"" ) +
'"' );
468 aliases.push_back( (*it).asString() );
470 addressesArgument += sl.join(
", " ) +
" ] ";
472 TQString script = TQString::fromLatin1(
"require \"vacation\";\n\n" );
474 script += TQString::fromLatin1(
"if header :contains \"X-Spam-Flag\" \"YES\""
475 " { keep; stop; }\n" );
477 if ( !domain.isEmpty() )
478 script += TQString::fromLatin1(
"if not address :domain :contains \"from\" \"%1\" { keep; stop; }\n" ).arg( domain );
480 script +=
"vacation ";
481 script += addressesArgument;
482 if ( notificationInterval > 0 )
483 script += TQString::fromLatin1(
":days %1 ").arg( notificationInterval );
484 script += TQString::fromLatin1(
"text:\n");
485 script += dotstuff( messageText.isEmpty() ? defaultMessageText() : messageText );
486 script += TQString::fromLatin1(
"\n.\n;\n" );
490 static KURL findUrlForAccount(
const KMail::ImapAccountBase * a ) {
492 const SieveConfig sieve = a->sieveConfig();
493 if ( !sieve.managesieveSupported() )
495 if ( sieve.reuseConfig() ) {
498 u.setProtocol(
"sieve" );
499 u.setHost( a->host() );
500 u.setUser( a->login() );
501 u.setPass( a->passwd() );
502 u.setPort( sieve.port() );
503 u.addQueryItem(
"x-mech", a->auth() ==
"*" ?
"PLAIN" : a->auth() );
504 if ( !a->useSSL() && !a->useTLS() )
505 u.addQueryItem(
"x-allow-unencrypted",
"true" );
506 u.setFileName( sieve.vacationFileName() );
509 KURL u = sieve.alternateURL();
510 if ( u.protocol().lower() ==
"sieve" && !a->useSSL() && !a->useTLS() && u.queryItem(
"x-allow-unencrypted").isEmpty() )
511 u.addQueryItem(
"x-allow-unencrypted",
"true" );
512 u.setFileName( sieve.vacationFileName() );
517 KURL Vacation::findURL()
const {
520 for ( KMAccount * a = am->
first() ; a ; a = am->
next() )
521 if ( KMail::ImapAccountBase * iab =
dynamic_cast<KMail::ImapAccountBase*
>( a ) ) {
522 KURL u = findUrlForAccount( iab );
529 bool Vacation::parseScript(
const TQString & script, TQString & messageText,
530 int & notificationInterval, TQStringList & aliases,
531 bool & sendForSpam, TQString & domainName ) {
532 if ( script.stripWhiteSpace().isEmpty() ) {
533 messageText = defaultMessageText();
534 notificationInterval = defaultNotificationInterval();
535 aliases = defaultMailAliases();
536 sendForSpam = defaultSendForSpam();
537 domainName = defaultDomainName();
544 const TQCString scriptUTF8 = script.stripWhiteSpace().utf8();
545 kdDebug(5006) <<
"scriptUtf8 = \"" + scriptUTF8 +
"\"" << endl;
546 KSieve::Parser parser( scriptUTF8.begin(),
547 scriptUTF8.begin() + scriptUTF8.length() );
548 VacationDataExtractor vdx;
549 SpamDataExtractor sdx;
550 DomainRestrictionDataExtractor drdx;
551 KSieveExt::MultiScriptBuilder tsb( &vdx, &sdx, &drdx );
552 parser.setScriptBuilder( &tsb );
553 if ( !parser.parse() )
555 messageText = vdx.messageText().stripWhiteSpace();
556 notificationInterval = vdx.notificationInterval();
557 aliases = vdx.aliases();
558 if ( !GlobalSettings::allowOutOfOfficeUploadButNoSettings() ) {
559 sendForSpam = !sdx.found();
560 domainName = drdx.domainName();
565 TQString Vacation::defaultMessageText() {
566 return i18n(
"I am out of office till %1.\n"
568 "In urgent cases, please contact Mrs. <vacation replacement>\n"
570 "email: <email address of vacation replacement>\n"
571 "phone: +49 711 1111 11\n"
572 "fax.: +49 711 1111 12\n"
575 "-- <enter your name and email address here>\n")
576 .arg( TDEGlobal::locale()->formatDate( TQDate::currentDate().addDays( 1 ) ) );
579 int Vacation::defaultNotificationInterval() {
583 TQStringList Vacation::defaultMailAliases() {
585 for ( KPIM::IdentityManager::ConstIterator it = kmkernel->identityManager()->begin() ;
586 it != kmkernel->identityManager()->end() ; ++it ) {
587 if ( !(*it).primaryEmailAddress().isEmpty() )
588 sl.push_back( (*it).primaryEmailAddress() );
589 sl += (*it).emailAliases();
594 bool Vacation::defaultSendForSpam() {
595 return GlobalSettings::outOfOfficeReactToSpam();
598 TQString Vacation::defaultDomainName() {
599 return GlobalSettings::outOfOfficeDomain();
602 void Vacation::slotGetResult( SieveJob * job,
bool success,
603 const TQString & script,
bool active ) {
604 kdDebug(5006) <<
"Vacation::slotGetResult( ??, " << success
605 <<
", ?, " << active <<
" )" << endl
610 if ( !mCheckOnly && mUrl.protocol() ==
"sieve" && !job->sieveCapabilities().isEmpty() &&
611 !job->sieveCapabilities().contains(
"vacation") ) {
612 KMessageBox::sorry( 0, i18n(
"Your server did not list \"vacation\" in "
613 "its list of supported Sieve extensions;\n"
614 "without it, KMail cannot install out-of-"
615 "office replies for you.\n"
616 "Please contact you system administrator.") );
617 emit result(
false );
621 if ( !mDialog && !mCheckOnly )
622 mDialog =
new VacationDialog( i18n(
"Configure \"Out of Office\" Replies"), 0, 0,
false );
624 TQString messageText = defaultMessageText();
625 int notificationInterval = defaultNotificationInterval();
626 TQStringList aliases = defaultMailAliases();
627 bool sendForSpam = defaultSendForSpam();
628 TQString domainName = defaultDomainName();
629 if ( !success ) active =
false;
631 if ( !mCheckOnly && ( !success || !parseScript( script, messageText, notificationInterval, aliases, sendForSpam, domainName ) ) )
632 KMessageBox::information( 0, i18n(
"Someone (probably you) changed the "
633 "vacation script on the server.\n"
634 "KMail is no longer able to determine "
635 "the parameters for the autoreplies.\n"
636 "Default values will be used." ) );
640 mDialog->setActivateVacation( active );
641 mDialog->setMessageText( messageText );
642 mDialog->setNotificationInterval( notificationInterval );
643 mDialog->setMailAliases( aliases.join(
", ") );
644 mDialog->setSendForSpam( sendForSpam );
645 mDialog->setDomainName( domainName );
646 mDialog->enableDomainAndSendForSpam( !GlobalSettings::allowOutOfOfficeUploadButNoSettings() );
648 connect( mDialog, TQ_SIGNAL(okClicked()), TQ_SLOT(slotDialogOk()) );
649 connect( mDialog, TQ_SIGNAL(cancelClicked()), TQ_SLOT(slotDialogCancel()) );
650 connect( mDialog, TQ_SIGNAL(defaultClicked()), TQ_SLOT(slotDialogDefaults()) );
655 emit scriptActive( mWasActive );
656 if ( mCheckOnly && mWasActive ) {
657 if ( KMessageBox::questionYesNo( 0, i18n(
"There is still an active out-of-office reply configured.\n"
658 "Do you want to edit it?"), i18n(
"Out-of-office reply still active"),
659 KGuiItem( i18n(
"Edit"),
"edit" ), KGuiItem( i18n(
"Ignore"),
"button_cancel" ) )
660 == KMessageBox::Yes ) {
661 kmkernel->getKMMainWidget()->slotEditVacation();
666 void Vacation::slotDialogDefaults() {
669 mDialog->setActivateVacation(
true );
670 mDialog->setMessageText( defaultMessageText() );
671 mDialog->setNotificationInterval( defaultNotificationInterval() );
672 mDialog->setMailAliases( defaultMailAliases().join(
", ") );
673 mDialog->setSendForSpam( defaultSendForSpam() );
674 mDialog->setDomainName( defaultDomainName() );
675 mDialog->setDomainCheck(
false );
678 void Vacation::slotDialogOk() {
679 kdDebug(5006) <<
"Vacation::slotDialogOk()" << endl;
681 const TQString script = composeScript( mDialog->messageText(),
682 mDialog->notificationInterval(),
683 mDialog->mailAliases(),
684 mDialog->sendForSpam(),
685 mDialog->domainName() );
686 const bool active = mDialog->activateVacation();
687 emit scriptActive( active );
689 kdDebug(5006) <<
"script:" << endl << script << endl;
692 mSieveJob = SieveJob::put( mUrl, script, active, mWasActive );
693 connect( mSieveJob, TQ_SIGNAL(gotScript(KMail::SieveJob*,
bool,
const TQString&,
bool)),
695 ? TQ_SLOT(slotPutActiveResult(KMail::SieveJob*,
bool))
696 : TQ_SLOT(slotPutInactiveResult(KMail::SieveJob*,
bool)) );
699 mDialog->delayedDestruct();
703 void Vacation::slotDialogCancel() {
704 kdDebug(5006) <<
"Vacation::slotDialogCancel()" << endl;
705 mDialog->delayedDestruct();
707 emit result(
false );
710 void Vacation::slotPutActiveResult( SieveJob * job,
bool success ) {
711 handlePutResult( job, success,
true );
714 void Vacation::slotPutInactiveResult( SieveJob * job,
bool success ) {
715 handlePutResult( job, success,
false );
718 void Vacation::handlePutResult( SieveJob *,
bool success,
bool activated ) {
720 KMessageBox::information( 0, activated
721 ? i18n(
"Sieve script installed successfully on the server.\n"
722 "Out of Office reply is now active.")
723 : i18n(
"Sieve script installed successfully on the server.\n"
724 "Out of Office reply has been deactivated.") );
726 kdDebug(5006) <<
"Vacation::handlePutResult( ???, " << success <<
", ? )"
729 emit result( success );
730 emit scriptActive( activated );
736 #include "vacation.moc"
The account manager is responsible for creating accounts of various types via the factory method crea...
const KMAccount * first() const
First account of the list.
const KMAccount * next() const
Next account of the list.