Diffstat (limited to 'korganizer/incomingdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/incomingdialog.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/korganizer/incomingdialog.cpp b/korganizer/incomingdialog.cpp index fe78356..c2402d4 100644 --- a/korganizer/incomingdialog.cpp +++ b/korganizer/incomingdialog.cpp | |||
@@ -1,368 +1,370 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qlistview.h> | 20 | #include <q3listview.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qdir.h> | 22 | #include <qdir.h> |
23 | #include <qmap.h> | 23 | #include <qmap.h> |
24 | //Added by qt3to4: | ||
25 | #include <Q3PtrList> | ||
24 | 26 | ||
25 | #include <kglobal.h> | 27 | #include <kglobal.h> |
26 | #include <klocale.h> | 28 | #include <klocale.h> |
27 | #include <kdebug.h> | 29 | #include <kdebug.h> |
28 | #include <kstandarddirs.h> | 30 | #include <kstandarddirs.h> |
29 | #include <kmessagebox.h> | 31 | #include <kmessagebox.h> |
30 | 32 | ||
31 | #include <libkcal/incidence.h> | 33 | #include <libkcal/incidence.h> |
32 | #include <libkcal/event.h> | 34 | #include <libkcal/event.h> |
33 | #include <libkcal/calendar.h> | 35 | #include <libkcal/calendar.h> |
34 | #include <libkcal/freebusy.h> | 36 | #include <libkcal/freebusy.h> |
35 | #include <libkcal/attendee.h> | 37 | #include <libkcal/attendee.h> |
36 | #include <libkcal/calendarresources.h> | 38 | #include <libkcal/calendarresources.h> |
37 | #include <libkcal/resourcecalendar.h> | 39 | #include <libkcal/resourcecalendar.h> |
38 | #include <kresources/resourceselectdialog.h> | 40 | #include <kresources/resourceselectdialog.h> |
39 | 41 | ||
40 | #ifndef KORG_NOMAIL | 42 | #ifndef KORG_NOMAIL |
41 | #include "mailscheduler.h" | 43 | #include "mailscheduler.h" |
42 | #else | 44 | #else |
43 | #include <libkcal/dummyscheduler.h> | 45 | #include <libkcal/dummyscheduler.h> |
44 | #endif | 46 | #endif |
45 | 47 | ||
46 | 48 | ||
47 | #include "incomingdialog.h" | 49 | #include "incomingdialog.h" |
48 | #include "koeventviewerdialog.h" | 50 | #include "koeventviewerdialog.h" |
49 | #include "kocounterdialog.h" | 51 | #include "kocounterdialog.h" |
50 | #include "koprefs.h" | 52 | #include "koprefs.h" |
51 | 53 | ||
52 | #ifndef KORG_NOKABC | 54 | #ifndef KORG_NOKABC |
53 | #define KORG_NOKABC | 55 | #define KORG_NOKABC |
54 | //#include <kabc/stdaddressbook.h> | 56 | //#include <kabc/stdaddressbook.h> |
55 | #define size count | 57 | #define size count |
56 | #endif | 58 | #endif |
57 | 59 | ||
58 | 60 | ||
59 | ScheduleItemIn::ScheduleItemIn(QListView *parent,IncidenceBase *ev, | 61 | ScheduleItemIn::ScheduleItemIn(Q3ListView *parent,IncidenceBase *ev, |
60 | Scheduler::Method method,ScheduleMessage::Status status) | 62 | Scheduler::Method method,ScheduleMessage::Status status) |
61 | : QListViewItem(parent) | 63 | : Q3ListViewItem(parent) |
62 | { | 64 | { |
63 | mIncidence = ev; | 65 | mIncidence = ev; |
64 | mMethod = method; | 66 | mMethod = method; |
65 | mStatus = status; | 67 | mStatus = status; |
66 | setText(6,Scheduler::translatedMethodName(mMethod)+" "); | 68 | setText(6,Scheduler::translatedMethodName(mMethod)+" "); |
67 | setText(7,ScheduleMessage::statusName(status)); | 69 | setText(7,ScheduleMessage::statusName(status)); |
68 | } | 70 | } |
69 | 71 | ||
70 | 72 | ||
71 | /* Visitor */ | 73 | /* Visitor */ |
72 | ScheduleItemVisitor::ScheduleItemVisitor(ScheduleItemIn *item) | 74 | ScheduleItemVisitor::ScheduleItemVisitor(ScheduleItemIn *item) |
73 | { | 75 | { |
74 | mItem = item; | 76 | mItem = item; |
75 | } | 77 | } |
76 | 78 | ||
77 | ScheduleItemVisitor::~ScheduleItemVisitor() | 79 | ScheduleItemVisitor::~ScheduleItemVisitor() |
78 | { | 80 | { |
79 | } | 81 | } |
80 | 82 | ||
81 | bool ScheduleItemVisitor::visit(Event *e) | 83 | bool ScheduleItemVisitor::visit(Event *e) |
82 | { | 84 | { |
83 | mItem->setText(0,e->summary()); | 85 | mItem->setText(0,e->summary()); |
84 | mItem->setText(1,e->dtStartDateStr()); | 86 | mItem->setText(1,e->dtStartDateStr()); |
85 | if (e->doesFloat()) { | 87 | if (e->doesFloat()) { |
86 | mItem->setText(2,i18n("no time ")); | 88 | mItem->setText(2,i18n("no time ")); |
87 | mItem->setText(4,i18n("no time ")); | 89 | mItem->setText(4,i18n("no time ")); |
88 | } | 90 | } |
89 | else { | 91 | else { |
90 | mItem->setText(2,e->dtStartTimeStr()); | 92 | mItem->setText(2,e->dtStartTimeStr()); |
91 | mItem->setText(4,e->dtEndTimeStr()); | 93 | mItem->setText(4,e->dtEndTimeStr()); |
92 | } | 94 | } |
93 | if (e->hasEndDate()) { | 95 | if (e->hasEndDate()) { |
94 | mItem->setText(3,e->dtEndDateStr()); | 96 | mItem->setText(3,e->dtEndDateStr()); |
95 | } | 97 | } |
96 | else { | 98 | else { |
97 | mItem->setText(3,""); | 99 | mItem->setText(3,""); |
98 | } | 100 | } |
99 | mItem->setText(5,e->organizer()+" "); | 101 | mItem->setText(5,e->organizer()+" "); |
100 | 102 | ||
101 | return true; | 103 | return true; |
102 | } | 104 | } |
103 | 105 | ||
104 | bool ScheduleItemVisitor::visit(Todo *e) | 106 | bool ScheduleItemVisitor::visit(Todo *e) |
105 | { | 107 | { |
106 | mItem->setText(0,e->summary()); | 108 | mItem->setText(0,e->summary()); |
107 | if (e->hasStartDate()) { | 109 | if (e->hasStartDate()) { |
108 | mItem->setText(1,e->dtStartDateStr()); | 110 | mItem->setText(1,e->dtStartDateStr()); |
109 | if (!e->doesFloat()) { | 111 | if (!e->doesFloat()) { |
110 | mItem->setText(2,e->dtStartTimeStr()); | 112 | mItem->setText(2,e->dtStartTimeStr()); |
111 | } | 113 | } |
112 | } | 114 | } |
113 | if (e->hasDueDate()) { | 115 | if (e->hasDueDate()) { |
114 | mItem->setText(1,e->dtDueDateStr()); | 116 | mItem->setText(1,e->dtDueDateStr()); |
115 | if (!e->doesFloat()) { | 117 | if (!e->doesFloat()) { |
116 | mItem->setText(2,e->dtDueTimeStr()); | 118 | mItem->setText(2,e->dtDueTimeStr()); |
117 | } | 119 | } |
118 | } | 120 | } |
119 | mItem->setText(5,e->organizer()+" "); | 121 | mItem->setText(5,e->organizer()+" "); |
120 | 122 | ||
121 | return true; | 123 | return true; |
122 | } | 124 | } |
123 | 125 | ||
124 | bool ScheduleItemVisitor::visit(Journal *) | 126 | bool ScheduleItemVisitor::visit(Journal *) |
125 | { | 127 | { |
126 | return false; | 128 | return false; |
127 | } | 129 | } |
128 | 130 | ||
129 | 131 | ||
130 | /* | 132 | /* |
131 | * Constructs a IncomingDialog which is a child of 'parent', with the | 133 | * Constructs a IncomingDialog which is a child of 'parent', with the |
132 | * name 'name' and widget flags set to 'f' | 134 | * name 'name' and widget flags set to 'f' |
133 | * | 135 | * |
134 | * The dialog will by default be modeless, unless you set 'modal' to | 136 | * The dialog will by default be modeless, unless you set 'modal' to |
135 | * TRUE to construct a modal dialog. | 137 | * TRUE to construct a modal dialog. |
136 | */ | 138 | */ |
137 | IncomingDialog::IncomingDialog(Calendar *calendar,OutgoingDialog *outgoing, | 139 | IncomingDialog::IncomingDialog(Calendar *calendar,OutgoingDialog *outgoing, |
138 | QWidget* parent,const char* name,bool modal,WFlags fl) : | 140 | QWidget* parent,const char* name,bool modal,Qt::WFlags fl) : |
139 | IncomingDialog_base(parent,name,modal,fl) | 141 | IncomingDialog_base(parent,name,modal,fl) |
140 | { | 142 | { |
141 | mCalendar = calendar; | 143 | mCalendar = calendar; |
142 | mOutgoing = outgoing; | 144 | mOutgoing = outgoing; |
143 | #ifndef KORG_NOMAIL | 145 | #ifndef KORG_NOMAIL |
144 | mScheduler = new MailScheduler(mCalendar); | 146 | mScheduler = new MailScheduler(mCalendar); |
145 | #else | 147 | #else |
146 | mScheduler = new DummyScheduler(mCalendar); | 148 | mScheduler = new DummyScheduler(mCalendar); |
147 | #endif | 149 | #endif |
148 | mMessageListView->setColumnAlignment(1,AlignHCenter); | 150 | mMessageListView->setColumnAlignment(1,Qt::AlignHCenter); |
149 | mMessageListView->setColumnAlignment(2,AlignHCenter); | 151 | mMessageListView->setColumnAlignment(2,Qt::AlignHCenter); |
150 | mMessageListView->setColumnAlignment(3,AlignHCenter); | 152 | mMessageListView->setColumnAlignment(3,Qt::AlignHCenter); |
151 | mMessageListView->setColumnAlignment(4,AlignHCenter); | 153 | mMessageListView->setColumnAlignment(4,Qt::AlignHCenter); |
152 | QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), | 154 | QObject::connect(mMessageListView,SIGNAL(doubleClicked(Q3ListViewItem *)), |
153 | this,SLOT(showEvent(QListViewItem *))); | 155 | this,SLOT(showEvent(Q3ListViewItem *))); |
154 | retrieve(); | 156 | retrieve(); |
155 | } | 157 | } |
156 | 158 | ||
157 | /* | 159 | /* |
158 | * Destroys the object and frees any allocated resources | 160 | * Destroys the object and frees any allocated resources |
159 | */ | 161 | */ |
160 | IncomingDialog::~IncomingDialog() | 162 | IncomingDialog::~IncomingDialog() |
161 | { | 163 | { |
162 | // no need to delete child widgets, Qt does it all for us | 164 | // no need to delete child widgets, Qt does it all for us |
163 | } | 165 | } |
164 | 166 | ||
165 | void IncomingDialog::setOutgoingDialog(OutgoingDialog *outgoing) | 167 | void IncomingDialog::setOutgoingDialog(OutgoingDialog *outgoing) |
166 | { | 168 | { |
167 | mOutgoing = outgoing; | 169 | mOutgoing = outgoing; |
168 | } | 170 | } |
169 | 171 | ||
170 | void IncomingDialog::retrieve() | 172 | void IncomingDialog::retrieve() |
171 | { | 173 | { |
172 | QPtrList <ScheduleMessage> messages = mScheduler->retrieveTransactions(); | 174 | Q3PtrList <ScheduleMessage> messages = mScheduler->retrieveTransactions(); |
173 | 175 | ||
174 | ScheduleMessage *message; | 176 | ScheduleMessage *message; |
175 | for(message = messages.first();message;message = messages.next()) { | 177 | for(message = messages.first();message;message = messages.next()) { |
176 | IncidenceBase *inc = message->event(); | 178 | IncidenceBase *inc = message->event(); |
177 | Scheduler::Method method = (Scheduler::Method)message->method(); | 179 | Scheduler::Method method = (Scheduler::Method)message->method(); |
178 | ScheduleMessage::Status status = message->status(); | 180 | ScheduleMessage::Status status = message->status(); |
179 | 181 | ||
180 | ScheduleItemIn *item = new ScheduleItemIn(mMessageListView,inc,method,status); | 182 | ScheduleItemIn *item = new ScheduleItemIn(mMessageListView,inc,method,status); |
181 | if(inc->typeID() != freebusyID ) { | 183 | if(inc->typeID() != freebusyID ) { |
182 | Incidence *incidence = static_cast<Incidence *>(inc); | 184 | Incidence *incidence = static_cast<Incidence *>(inc); |
183 | ScheduleItemVisitor v(item); | 185 | ScheduleItemVisitor v(item); |
184 | if (!incidence->accept(v)) delete item; | 186 | if (!incidence->accept(v)) delete item; |
185 | } else { | 187 | } else { |
186 | FreeBusy *fb = static_cast<FreeBusy *>(item->event()); | 188 | FreeBusy *fb = static_cast<FreeBusy *>(item->event()); |
187 | item->setText(0, "FreeBusy"); | 189 | item->setText(0, "FreeBusy"); |
188 | item->setText(1, KGlobal::locale()->formatDate( fb->dtStart().date() ) ); | 190 | item->setText(1, KGlobal::locale()->formatDate( fb->dtStart().date() ) ); |
189 | item->setText(2, KGlobal::locale()->formatTime( fb->dtStart().time() ) ); | 191 | item->setText(2, KGlobal::locale()->formatTime( fb->dtStart().time() ) ); |
190 | item->setText(3, KGlobal::locale()->formatDate( fb->dtEnd().date() ) ); | 192 | item->setText(3, KGlobal::locale()->formatDate( fb->dtEnd().date() ) ); |
191 | item->setText(4, KGlobal::locale()->formatTime( fb->dtEnd().time() ) ); | 193 | item->setText(4, KGlobal::locale()->formatTime( fb->dtEnd().time() ) ); |
192 | item->setText(5, fb->organizer()); | 194 | item->setText(5, fb->organizer()); |
193 | } | 195 | } |
194 | automaticAction(item); | 196 | automaticAction(item); |
195 | } | 197 | } |
196 | emit numMessagesChanged(mMessageListView->childCount()); | 198 | emit numMessagesChanged(mMessageListView->childCount()); |
197 | } | 199 | } |
198 | 200 | ||
199 | void IncomingDialog::acceptAllMessages() | 201 | void IncomingDialog::acceptAllMessages() |
200 | { | 202 | { |
201 | bool success = false; | 203 | bool success = false; |
202 | 204 | ||
203 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->firstChild(); | 205 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->firstChild(); |
204 | while(item) { | 206 | while(item) { |
205 | ScheduleItemIn *nextitem = (ScheduleItemIn *)(item->nextSibling()); | 207 | ScheduleItemIn *nextitem = (ScheduleItemIn *)(item->nextSibling()); |
206 | if (acceptMessage(item)) success = true; | 208 | if (acceptMessage(item)) success = true; |
207 | item = nextitem; | 209 | item = nextitem; |
208 | } | 210 | } |
209 | 211 | ||
210 | if (success) emit calendarUpdated(); | 212 | if (success) emit calendarUpdated(); |
211 | } | 213 | } |
212 | 214 | ||
213 | void IncomingDialog::acceptMessage() | 215 | void IncomingDialog::acceptMessage() |
214 | { | 216 | { |
215 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); | 217 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); |
216 | if (item) { | 218 | if (item) { |
217 | if (acceptMessage(item)) emit calendarUpdated(); | 219 | if (acceptMessage(item)) emit calendarUpdated(); |
218 | } | 220 | } |
219 | } | 221 | } |
220 | 222 | ||
221 | bool IncomingDialog::acceptMessage(ScheduleItemIn *item) | 223 | bool IncomingDialog::acceptMessage(ScheduleItemIn *item) |
222 | { | 224 | { |
223 | switch (item->method()) { | 225 | switch (item->method()) { |
224 | case Scheduler::Refresh: | 226 | case Scheduler::Refresh: |
225 | return incomeRefresh(item); | 227 | return incomeRefresh(item); |
226 | break; | 228 | break; |
227 | case Scheduler::Counter: | 229 | case Scheduler::Counter: |
228 | return incomeCounter(item); | 230 | return incomeCounter(item); |
229 | break; | 231 | break; |
230 | case Scheduler::Declinecounter: | 232 | case Scheduler::Declinecounter: |
231 | return incomeDeclineCounter(item); | 233 | return incomeDeclineCounter(item); |
232 | break; | 234 | break; |
233 | case Scheduler::Add: | 235 | case Scheduler::Add: |
234 | return incomeAdd(item); | 236 | return incomeAdd(item); |
235 | break; | 237 | break; |
236 | case Scheduler::Request: | 238 | case Scheduler::Request: |
237 | return incomeRequest(item); | 239 | return incomeRequest(item); |
238 | break; | 240 | break; |
239 | default: | 241 | default: |
240 | return incomeDefault(item); | 242 | return incomeDefault(item); |
241 | } | 243 | } |
242 | return false; | 244 | return false; |
243 | } | 245 | } |
244 | 246 | ||
245 | void IncomingDialog::rejectMessage() | 247 | void IncomingDialog::rejectMessage() |
246 | { | 248 | { |
247 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); | 249 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); |
248 | if (item) { | 250 | if (item) { |
249 | mScheduler->deleteTransaction(item->event()); | 251 | mScheduler->deleteTransaction(item->event()); |
250 | delete item; | 252 | delete item; |
251 | emit numMessagesChanged(mMessageListView->childCount()); | 253 | emit numMessagesChanged(mMessageListView->childCount()); |
252 | } | 254 | } |
253 | } | 255 | } |
254 | 256 | ||
255 | void IncomingDialog::showEvent(QListViewItem *item) | 257 | void IncomingDialog::showEvent(Q3ListViewItem *item) |
256 | { | 258 | { |
257 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); | 259 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); |
258 | if( incidence && incidence->typeID() == eventID ) { | 260 | if( incidence && incidence->typeID() == eventID ) { |
259 | Event *event = static_cast<Event *>(incidence); | 261 | Event *event = static_cast<Event *>(incidence); |
260 | KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); | 262 | KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); |
261 | eventViewer->setEvent(event); | 263 | eventViewer->setEvent(event); |
262 | eventViewer->show(); | 264 | eventViewer->show(); |
263 | } | 265 | } |
264 | } | 266 | } |
265 | 267 | ||
266 | bool IncomingDialog::incomeRefresh(ScheduleItemIn *item) | 268 | bool IncomingDialog::incomeRefresh(ScheduleItemIn *item) |
267 | { | 269 | { |
268 | Event *ev = mCalendar->event(item->event()->uid()); | 270 | Event *ev = mCalendar->event(item->event()->uid()); |
269 | if (ev) { | 271 | if (ev) { |
270 | //user interaction before?? | 272 | //user interaction before?? |
271 | Attendee *att; | 273 | Attendee *att; |
272 | QPtrList<Attendee> attlist = ev->attendees(); | 274 | Q3PtrList<Attendee> attlist = ev->attendees(); |
273 | for (att=attlist.first(); att; att=attlist.next()) { | 275 | for (att=attlist.first(); att; att=attlist.next()) { |
274 | Event *event = new Event(*ev); | 276 | Event *event = new Event(*ev); |
275 | mOutgoing->addMessage(event,Scheduler::Request,att->email()); | 277 | mOutgoing->addMessage(event,Scheduler::Request,att->email()); |
276 | delete(event); | 278 | delete(event); |
277 | } | 279 | } |
278 | mScheduler->deleteTransaction(item->event()); | 280 | mScheduler->deleteTransaction(item->event()); |
279 | delete item; | 281 | delete item; |
280 | emit numMessagesChanged(mMessageListView->childCount()); | 282 | emit numMessagesChanged(mMessageListView->childCount()); |
281 | return true; | 283 | return true; |
282 | } | 284 | } |
283 | mScheduler->deleteTransaction(item->event()); | 285 | mScheduler->deleteTransaction(item->event()); |
284 | delete item; | 286 | delete item; |
285 | emit numMessagesChanged(mMessageListView->childCount()); | 287 | emit numMessagesChanged(mMessageListView->childCount()); |
286 | return false; | 288 | return false; |
287 | } | 289 | } |
288 | 290 | ||
289 | bool IncomingDialog::incomeCounter(ScheduleItemIn *item) | 291 | bool IncomingDialog::incomeCounter(ScheduleItemIn *item) |
290 | { | 292 | { |
291 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); | 293 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); |
292 | // currently only events supportet - attetion at insertion below! | 294 | // currently only events supportet - attetion at insertion below! |
293 | if ( incidence->typeID() != eventID ) return false; | 295 | if ( incidence->typeID() != eventID ) return false; |
294 | 296 | ||
295 | Event *counterEvent = static_cast<Event *>( incidence ); | 297 | Event *counterEvent = static_cast<Event *>( incidence ); |
296 | 298 | ||
297 | Event *even = mCalendar->event(counterEvent->uid()); | 299 | Event *even = mCalendar->event(counterEvent->uid()); |
298 | 300 | ||
299 | KOCounterDialog *eventViewer = new KOCounterDialog(this); | 301 | KOCounterDialog *eventViewer = new KOCounterDialog(this); |
300 | eventViewer->addText(i18n("counter proposal event","<b>Counter-event:</b><p>")); | 302 | eventViewer->addText(i18n("counter proposal event","<b>Counter-event:</b><p>")); |
301 | eventViewer->addEvent(counterEvent); | 303 | eventViewer->addEvent(counterEvent); |
302 | eventViewer->addText("<hr>"); | 304 | eventViewer->addText("<hr>"); |
303 | eventViewer->addText(i18n("<b>Original event:</b><p>")); | 305 | eventViewer->addText(i18n("<b>Original event:</b><p>")); |
304 | if (even) eventViewer->addEvent(even); | 306 | if (even) eventViewer->addEvent(even); |
305 | else eventViewer->addText(i18n("A corresponding event is missing in your calendar!")); | 307 | else eventViewer->addText(i18n("A corresponding event is missing in your calendar!")); |
306 | eventViewer->addText("<hr>"); | 308 | eventViewer->addText("<hr>"); |
307 | eventViewer->addText(i18n("If this counter-event is a good proposal for your event, press 'Accept'. All Attendees will then get the new version of this event")); | 309 | eventViewer->addText(i18n("If this counter-event is a good proposal for your event, press 'Accept'. All Attendees will then get the new version of this event")); |
308 | eventViewer->show(); | 310 | eventViewer->show(); |
309 | 311 | ||
310 | eventViewer->exec(); | 312 | eventViewer->exec(); |
311 | if (eventViewer->result()) { | 313 | if (eventViewer->result()) { |
312 | kdDebug() << "IncomingDialog::Counter:Accept" << endl; | 314 | kdDebug() << "IncomingDialog::Counter:Accept" << endl; |
313 | int revision = 0; | 315 | int revision = 0; |
314 | if (even) { | 316 | if (even) { |
315 | revision = even->revision(); | 317 | revision = even->revision(); |
316 | mCalendar->deleteEvent(even); | 318 | mCalendar->deleteEvent(even); |
317 | } | 319 | } |
318 | mCalendar->addIncidence(counterEvent); | 320 | mCalendar->addIncidence(counterEvent); |
319 | 321 | ||
320 | even = mCalendar->event(item->event()->uid()); | 322 | even = mCalendar->event(item->event()->uid()); |
321 | if (even) { | 323 | if (even) { |
322 | if (revision < even->revision()) | 324 | if (revision < even->revision()) |
323 | even->setRevision(even->revision()+1); | 325 | even->setRevision(even->revision()+1); |
324 | else | 326 | else |
325 | even->setRevision(revision+1); | 327 | even->setRevision(revision+1); |
326 | Event *ev = new Event(*even); | 328 | Event *ev = new Event(*even); |
327 | mOutgoing->addMessage(ev,Scheduler::Request); | 329 | mOutgoing->addMessage(ev,Scheduler::Request); |
328 | delete(ev); | 330 | delete(ev); |
329 | } | 331 | } |
330 | mScheduler->deleteTransaction(item->event()); | 332 | mScheduler->deleteTransaction(item->event()); |
331 | delete item; | 333 | delete item; |
332 | emit numMessagesChanged(mMessageListView->childCount()); | 334 | emit numMessagesChanged(mMessageListView->childCount()); |
333 | return true; | 335 | return true; |
334 | } else { | 336 | } else { |
335 | kdDebug() << "IncomingDialog::Counter:Decline" << endl; | 337 | kdDebug() << "IncomingDialog::Counter:Decline" << endl; |
336 | //the counter-sender's email is missing... | 338 | //the counter-sender's email is missing... |
337 | //now every attendee gets an declinecounter :-( | 339 | //now every attendee gets an declinecounter :-( |
338 | mOutgoing->addMessage(counterEvent,Scheduler::Declinecounter); | 340 | mOutgoing->addMessage(counterEvent,Scheduler::Declinecounter); |
339 | delete item; | 341 | delete item; |
340 | emit numMessagesChanged(mMessageListView->childCount()); | 342 | emit numMessagesChanged(mMessageListView->childCount()); |
341 | mScheduler->deleteTransaction(item->event()); | 343 | mScheduler->deleteTransaction(item->event()); |
342 | delete item; | 344 | delete item; |
343 | emit numMessagesChanged(mMessageListView->childCount()); | 345 | emit numMessagesChanged(mMessageListView->childCount()); |
344 | return true; | 346 | return true; |
345 | } | 347 | } |
346 | //mScheduler->deleteTransaction(item->event()); | 348 | //mScheduler->deleteTransaction(item->event()); |
347 | delete item; | 349 | delete item; |
348 | emit numMessagesChanged(mMessageListView->childCount()); | 350 | emit numMessagesChanged(mMessageListView->childCount()); |
349 | return false; | 351 | return false; |
350 | } | 352 | } |
351 | 353 | ||
352 | bool IncomingDialog::incomeDeclineCounter(ScheduleItemIn *item) | 354 | bool IncomingDialog::incomeDeclineCounter(ScheduleItemIn *item) |
353 | { | 355 | { |
354 | Event *even = mCalendar->event(item->event()->uid()); | 356 | Event *even = mCalendar->event(item->event()->uid()); |
355 | if (even) { | 357 | if (even) { |
356 | mOutgoing->addMessage(even,Scheduler::Refresh); | 358 | mOutgoing->addMessage(even,Scheduler::Refresh); |
357 | mScheduler->deleteTransaction(item->event()); | 359 | mScheduler->deleteTransaction(item->event()); |
358 | delete item; | 360 | delete item; |
359 | emit numMessagesChanged(mMessageListView->childCount()); | 361 | emit numMessagesChanged(mMessageListView->childCount()); |
360 | return true; | 362 | return true; |
361 | } | 363 | } |
362 | mScheduler->deleteTransaction(item->event()); | 364 | mScheduler->deleteTransaction(item->event()); |
363 | delete item; | 365 | delete item; |
364 | emit numMessagesChanged(mMessageListView->childCount()); | 366 | emit numMessagesChanged(mMessageListView->childCount()); |
365 | return false; | 367 | return false; |
366 | } | 368 | } |
367 | 369 | ||
368 | bool IncomingDialog::incomeAdd(ScheduleItemIn *item) | 370 | bool IncomingDialog::incomeAdd(ScheduleItemIn *item) |
@@ -421,108 +423,108 @@ bool IncomingDialog::incomeRequest(ScheduleItemIn *item) | |||
421 | if (mOutgoing->addMessage(freebusy,Scheduler::Reply)) { | 423 | if (mOutgoing->addMessage(freebusy,Scheduler::Reply)) { |
422 | delete item; | 424 | delete item; |
423 | emit numMessagesChanged(mMessageListView->childCount()); | 425 | emit numMessagesChanged(mMessageListView->childCount()); |
424 | delete(freebusy); | 426 | delete(freebusy); |
425 | return true; | 427 | return true; |
426 | } | 428 | } |
427 | return false; | 429 | return false; |
428 | } else { | 430 | } else { |
429 | return incomeDefault(item); | 431 | return incomeDefault(item); |
430 | } | 432 | } |
431 | return false; | 433 | return false; |
432 | } | 434 | } |
433 | 435 | ||
434 | bool IncomingDialog::automaticAction(ScheduleItemIn *item) | 436 | bool IncomingDialog::automaticAction(ScheduleItemIn *item) |
435 | { | 437 | { |
436 | bool autoAction = false; | 438 | bool autoAction = false; |
437 | IncidenceBase *inc = item->event(); | 439 | IncidenceBase *inc = item->event(); |
438 | Scheduler::Method method = item->method(); | 440 | Scheduler::Method method = item->method(); |
439 | 441 | ||
440 | if( inc->typeID() == freebusyID ) { | 442 | if( inc->typeID() == freebusyID ) { |
441 | if ( method==Scheduler::Request ) { | 443 | if ( method==Scheduler::Request ) { |
442 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { | 444 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { |
443 | // reply freebusy information | 445 | // reply freebusy information |
444 | if ( checkOrganizerInAddressbook(inc->organizer()) ) { | 446 | if ( checkOrganizerInAddressbook(inc->organizer()) ) { |
445 | incomeRequest(item); | 447 | incomeRequest(item); |
446 | } | 448 | } |
447 | } else return false; | 449 | } else return false; |
448 | } else { | 450 | } else { |
449 | 451 | ||
450 | if ( method==Scheduler::Reply ) { | 452 | if ( method==Scheduler::Reply ) { |
451 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { | 453 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { |
452 | // insert freebusy information | 454 | // insert freebusy information |
453 | //if ( checkAttendeesInAddressbook(inc) ) | 455 | //if ( checkAttendeesInAddressbook(inc) ) |
454 | 456 | ||
455 | } else return false; | 457 | } else return false; |
456 | } else { | 458 | } else { |
457 | if ( method==Scheduler::Publish) { | 459 | if ( method==Scheduler::Publish) { |
458 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { | 460 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { |
459 | // insert freebusy information | 461 | // insert freebusy information |
460 | //if ( checkOrganizerInAddressbook(inc->organizer()) ) | 462 | //if ( checkOrganizerInAddressbook(inc->organizer()) ) |
461 | 463 | ||
462 | } | 464 | } |
463 | } else return false; | 465 | } else return false; |
464 | } | 466 | } |
465 | } | 467 | } |
466 | } | 468 | } |
467 | 469 | ||
468 | if ( inc->typeID() == eventID ) { | 470 | if ( inc->typeID() == eventID ) { |
469 | if ( method==Scheduler::Request || method==Scheduler::Publish ) { | 471 | if ( method==Scheduler::Request || method==Scheduler::Publish ) { |
470 | if ( KOPrefs::instance()->mIMIPAutoInsertRequest==KOPrefs::addressbookAuto ) { | 472 | if ( KOPrefs::instance()->mIMIPAutoInsertRequest==KOPrefs::addressbookAuto ) { |
471 | // insert event | 473 | // insert event |
472 | if ( checkOrganizerInAddressbook(inc->organizer()) ) | 474 | if ( checkOrganizerInAddressbook(inc->organizer()) ) |
473 | autoAction = acceptMessage(item); | 475 | autoAction = acceptMessage(item); |
474 | } else return false; | 476 | } else return false; |
475 | } else { | 477 | } else { |
476 | 478 | ||
477 | if ( method==Scheduler::Reply ) { | 479 | if ( method==Scheduler::Reply ) { |
478 | if ( KOPrefs::instance()->mIMIPAutoInsertReply==KOPrefs::addressbookAuto ) { | 480 | if ( KOPrefs::instance()->mIMIPAutoInsertReply==KOPrefs::addressbookAuto ) { |
479 | // update event information | 481 | // update event information |
480 | if ( checkAttendeesInAddressbook(inc) ) | 482 | if ( checkAttendeesInAddressbook(inc) ) |
481 | autoAction = acceptMessage(item); | 483 | autoAction = acceptMessage(item); |
482 | } else return false; | 484 | } else return false; |
483 | } else { | 485 | } else { |
484 | 486 | ||
485 | if ( method==Scheduler::Refresh ) { | 487 | if ( method==Scheduler::Refresh ) { |
486 | if ( KOPrefs::instance()->mIMIPAutoRefresh==KOPrefs::addressbookAuto ) { | 488 | if ( KOPrefs::instance()->mIMIPAutoRefresh==KOPrefs::addressbookAuto ) { |
487 | // send refresh-information | 489 | // send refresh-information |
488 | if ( checkAttendeesInAddressbook(inc) ) | 490 | if ( checkAttendeesInAddressbook(inc) ) |
489 | autoAction = acceptMessage(item); | 491 | autoAction = acceptMessage(item); |
490 | else return false; | 492 | else return false; |
491 | } else return false; | 493 | } else return false; |
492 | } else return false; | 494 | } else return false; |
493 | } | 495 | } |
494 | } | 496 | } |
495 | } | 497 | } |
496 | return autoAction; | 498 | return autoAction; |
497 | } | 499 | } |
498 | 500 | ||
499 | bool IncomingDialog::checkOrganizerInAddressbook(QString organizer) | 501 | bool IncomingDialog::checkOrganizerInAddressbook(QString organizer) |
500 | { | 502 | { |
501 | bool inBook = false; | 503 | bool inBook = false; |
502 | #ifndef KORG_NOKABC | 504 | #ifndef KORG_NOKABC |
503 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 505 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
504 | KABC::Addressee::List addressList; | 506 | KABC::Addressee::List addressList; |
505 | addressList = add_book->findByEmail(organizer); | 507 | addressList = add_book->findByEmail(organizer); |
506 | if ( addressList.size()>0 ) inBook = true; | 508 | if ( addressList.size()>0 ) inBook = true; |
507 | #endif | 509 | #endif |
508 | return inBook; | 510 | return inBook; |
509 | } | 511 | } |
510 | 512 | ||
511 | bool IncomingDialog::checkAttendeesInAddressbook(IncidenceBase *inc) | 513 | bool IncomingDialog::checkAttendeesInAddressbook(IncidenceBase *inc) |
512 | { | 514 | { |
513 | bool inBook = false; | 515 | bool inBook = false; |
514 | #ifndef KORG_NOKABC | 516 | #ifndef KORG_NOKABC |
515 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 517 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
516 | KABC::Addressee::List addressList; | 518 | KABC::Addressee::List addressList; |
517 | QPtrList <Attendee> attendees; | 519 | Q3PtrList <Attendee> attendees; |
518 | Attendee *att; | 520 | Attendee *att; |
519 | attendees = inc->attendees(); | 521 | attendees = inc->attendees(); |
520 | for (att=attendees.first();att;att=attendees.next()) { | 522 | for (att=attendees.first();att;att=attendees.next()) { |
521 | addressList = add_book->findByEmail(att->email()); | 523 | addressList = add_book->findByEmail(att->email()); |
522 | if (addressList.size()>0 ) inBook = true; | 524 | if (addressList.size()>0 ) inBook = true; |
523 | } | 525 | } |
524 | #endif | 526 | #endif |
525 | return inBook; | 527 | return inBook; |
526 | } | 528 | } |
527 | 529 | ||
528 | //#include "incomingdialog.moc" | 530 | //#include "incomingdialog.moc" |