~ubuntu-branches/ubuntu/quantal/kdepimlibs/quantal-proposed

« back to all changes in this revision

Viewing changes to kcal/dummyscheduler.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-09-06 22:45:39 UTC
  • Revision ID: james.westby@ubuntu.com-20060906224539-fiq8t03qdbqu7z3i
Tags: upstream-3.80.1
ImportĀ upstreamĀ versionĀ 3.80.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This file is part of the kcal library.
 
3
 
 
4
    Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
 
5
 
 
6
    This library is free software; you can redistribute it and/or
 
7
    modify it under the terms of the GNU Library General Public
 
8
    License as published by the Free Software Foundation; either
 
9
    version 2 of the License, or (at your option) any later version.
 
10
 
 
11
    This library is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
    Library General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU Library General Public License
 
17
    along with this library; see the file COPYING.LIB.  If not, write to
 
18
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
19
    Boston, MA 02110-1301, USA.
 
20
*/
 
21
 
 
22
//
 
23
// DummyScheduler - iMIP implementation of iTIP methods
 
24
//
 
25
 
 
26
#include <QFile>
 
27
#include <QTextStream>
 
28
 
 
29
#include <kdebug.h>
 
30
#include <kstandarddirs.h>
 
31
 
 
32
#include "event.h"
 
33
#include "icalformat.h"
 
34
 
 
35
#include "dummyscheduler.h"
 
36
 
 
37
using namespace KCal;
 
38
 
 
39
DummyScheduler::DummyScheduler(Calendar *calendar)
 
40
  : Scheduler(calendar)
 
41
{
 
42
}
 
43
 
 
44
DummyScheduler::~DummyScheduler()
 
45
{
 
46
}
 
47
 
 
48
bool DummyScheduler::publish (IncidenceBase *incidence,const QString &/*recipients*/)
 
49
{
 
50
  QString messageText = mFormat->createScheduleMessage(incidence,
 
51
                                                       Scheduler::Publish);
 
52
 
 
53
  return saveMessage(messageText);
 
54
}
 
55
 
 
56
bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method,const QString &/*recipients*/)
 
57
{
 
58
  QString messageText = mFormat->createScheduleMessage(incidence,method);
 
59
 
 
60
  return saveMessage(messageText);
 
61
}
 
62
 
 
63
bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method)
 
64
{
 
65
  QString messageText = mFormat->createScheduleMessage(incidence,method);
 
66
 
 
67
  return saveMessage(messageText);
 
68
}
 
69
 
 
70
bool DummyScheduler::saveMessage(const QString &message)
 
71
{
 
72
  QFile f("dummyscheduler.store");
 
73
  if (f.open(QIODevice::WriteOnly | QIODevice::Append)) {
 
74
    QTextStream t(&f);
 
75
    t << message << endl;
 
76
    f.close();
 
77
    return true;
 
78
  } else {
 
79
    return false;
 
80
  }
 
81
}
 
82
 
 
83
QList<ScheduleMessage*> DummyScheduler::retrieveTransactions()
 
84
{
 
85
  QList<ScheduleMessage*> messageList;
 
86
 
 
87
  QFile f("dummyscheduler.store");
 
88
  if (!f.open(QIODevice::ReadOnly)) {
 
89
    kDebug(5800) << "DummyScheduler::retrieveTransactions(): Can't open file"
 
90
              << endl;
 
91
  } else {
 
92
    QTextStream t(&f);
 
93
    QString messageString;
 
94
    QString messageLine = t.readLine();
 
95
    while (!messageLine.isNull()) {
 
96
//      kDebug(5800) << "++++++++" << messageLine << endl;
 
97
      messageString += messageLine + '\n';
 
98
      if (messageLine.indexOf("END:VCALENDAR") >= 0) {
 
99
        kDebug(5800) << "---------------" << messageString << endl;
 
100
        ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar,
 
101
                                                                 messageString);
 
102
        kDebug(5800) << "--Parsed" << endl;
 
103
        if (message) {
 
104
          messageList.append(message);
 
105
        } else {
 
106
          QString errorMessage;
 
107
          if (mFormat->exception()) {
 
108
            errorMessage = mFormat->exception()->message();
 
109
          }
 
110
          kDebug(5800) << "DummyScheduler::retrieveTransactions() Error parsing "
 
111
                       "message: " << errorMessage << endl;
 
112
        }
 
113
        messageString="";
 
114
      }
 
115
      messageLine = t.readLine();
 
116
    }
 
117
    f.close();
 
118
  }
 
119
 
 
120
  return messageList;
 
121
}
 
122
 
 
123
QString DummyScheduler::freeBusyDir()
 
124
{
 
125
  // the dummy scheduler should never handle freebusy stuff - so it's hardcoded
 
126
  return QString("");
 
127
}