29 #include <tdelocale.h>
30 #include <kstandarddirs.h>
34 #include <libkcal/event.h>
35 #include <libkcal/icalformat.h>
37 #include "komailclient.h"
38 #include "incidencechanger.h"
40 #include "mailscheduler.h"
45 MailScheduler::MailScheduler(
Calendar *calendar )
46 : IMIPScheduler( calendar )
50 MailScheduler::~MailScheduler()
55 const TQString &recipients )
57 TQString messageText = mFormat->createScheduleMessage( incidence,
60 return mailer.mailTo( incidence, recipients, messageText );
63 bool MailScheduler::performTransaction(
IncidenceBase *incidence,
65 const TQString &recipients )
67 TQString messageText = mFormat->createScheduleMessage( incidence, method );
70 return mailer.mailTo( incidence, recipients, messageText );
73 bool MailScheduler::performTransaction(
IncidenceBase *incidence,
76 TQString messageText = mFormat->createScheduleMessage( incidence, method );
80 if ( method == Request ||
83 method == Declinecounter ) {
84 status = mailer.mailAttendees( incidence, messageText );
88 if ( inc && method == Counter )
89 subject = i18n(
"Counter proposal: %1" ).arg( inc->
summary() );
90 status = mailer.mailOrganizer( incidence, messageText, subject );
95 TQPtrList<ScheduleMessage> MailScheduler::retrieveTransactions()
97 TQString incomingDirName = locateLocal(
"data",
"korganizer/income" );
98 kdDebug(5850) <<
"MailScheduler::retrieveTransactions: dir: "
99 << incomingDirName << endl;
101 TQPtrList<ScheduleMessage> messageList;
103 TQDir incomingDir( incomingDirName );
104 TQStringList incoming = incomingDir.entryList( TQDir::Files );
105 TQStringList::ConstIterator it;
106 for( it = incoming.begin(); it != incoming.end(); ++it ) {
107 kdDebug(5850) <<
"-- File: " << (*it) << endl;
109 TQFile f( incomingDirName +
"/" + (*it) );
110 bool inserted =
false;
111 TQMap<IncidenceBase*, TQString>::Iterator iter;
112 for ( iter = mEventMap.begin(); iter != mEventMap.end(); ++iter ) {
113 if ( iter.data() == incomingDirName +
"/" + (*it) )
117 if ( !f.open( IO_ReadOnly ) ) {
119 <<
"MailScheduler::retrieveTransactions(): Can't open file'"
120 << (*it) <<
"'" << endl;
122 TQTextStream t( &f );
123 t.setEncoding( TQTextStream::Latin1 );
124 TQString messageString = t.read();
125 messageString.replace( TQRegExp(
"\n[ \t]"),
"" );
126 messageString = TQString::fromUtf8( messageString.latin1() );
131 <<
"MailScheduler::retrieveTransactions: got message '"
132 << (*it) <<
"'" << endl;
133 messageList.append( mess );
134 mEventMap[ mess->
event() ] = incomingDirName +
"/" + (*it);
136 TQString errorMessage;
137 if ( mFormat->exception() ) {
138 errorMessage = mFormat->exception()->message();
141 <<
"MailScheduler::retrieveTransactions() Error parsing message: "
142 << errorMessage << endl;
151 bool MailScheduler::deleteTransaction(
IncidenceBase *incidence )
154 TQFile f( mEventMap[incidence] );
155 mEventMap.remove( incidence );
164 TQString MailScheduler::freeBusyDir()
166 return locateLocal(
"data",
"korganizer/freebusy" );
169 bool MailScheduler::acceptCounterProposal(
Incidence *incidence )
174 Incidence *exInc = mCalendar->incidence( incidence->
uid() );
176 exInc = mCalendar->incidenceFromSchedulingID( incidence->
uid() );
184 mCalendar->beginChange( exInc );
185 IncidenceChanger::assignIncidence( exInc, incidence );
187 mCalendar->endChange( exInc );
189 mCalendar->addIncidence( incidence );
void setUid(const TQString &)
void setSchedulingID(const TQString &sid)
TQString schedulingID() const
void setRevision(int rev)