2 * Copyright (C) 2010 Ixonos Plc.
3 * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
5 * This file is part of ConfClerk.
7 * ConfClerk is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation, either version 2 of the License, or (at your option)
12 * ConfClerk is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * ConfClerk. If not, see <http://www.gnu.org/licenses/>.
24 #include <calendar-backend/CMulticalendar.h>
25 #include <calendar-backend/CCalendar.h>
26 #include <calendar-backend/CEvent.h>
27 #include <calendar-backend/CAlarm.h>
33 m_pMultiCalendar = CMulticalendar::MCInstance();
35 if(m_pMultiCalendar != NULL)
36 m_pCalendar = m_pMultiCalendar->getSynchronizedCalendar();
43 delete m_pMultiCalendar;
46 int Calendar::addCalendarEvent(QString summary, QString description, QString location, uint dateStart, uint dateEnd, int eventId)
50 if(m_pMultiCalendar == NULL)
53 if(m_pCalendar == NULL)
57 CEvent event(summary.toStdString(), description.toStdString(), location.toStdString(), dateStart, dateEnd);
61 alarm.setTrigger(dateStart - 15 * 60);
65 alarm.setAttach(QString::number(eventId).toLocal8Bit().data());
68 event.setAlarm(&alarm);
70 // register event into calendar
71 m_pMultiCalendar->addEvent(&event,m_pCalendar->getCalendarId(),errorCode);
76 void Calendar::deleteCalendarEvent(uint dateStart, uint dateEnd, int eventId)
80 vector< CComponent * > components;
83 components = m_pMultiCalendar->getComponents(m_pCalendar->getCalendarId(), 1, dateStart, dateEnd, errorCode);
85 for (vector<CComponent *>::iterator it = components.begin();it!=components.end(); ++it)
87 // get alarm properties
88 if( (*it)->getAlarmProperties() == true)
90 CAlarm * pAlarm = (*it)->getAlarm();
92 bool converted = false;
93 int tempId = QVariant(pAlarm->getAttach().data()).toInt(&converted);
100 m_pCalendar->deleteComponent((*it)->getId(),errorCode);
107 bool Calendar::hasCalendarEvent(int eventId)
112 vector< CEvent * > events;
115 events = m_pCalendar->getEvents(errorCode);
117 if(events.size() > 0)
119 for (vector<CEvent *>::iterator it = events.begin(); it!=events.end(); ++it)
121 // get alarm properties
122 if( (*it)->getAlarmProperties() == true)
124 CAlarm * pAlarm = (*it)->getAlarm();
126 bool converted = false;
127 int tempId = QVariant(pAlarm->getAttach().data()).toInt(&converted);
130 if(converted == true)
131 if(tempId == eventId)