You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
147 lines
4.5 KiB
147 lines
4.5 KiB
15 years ago
|
/*=========================================================================
|
||
|
| KCalDAV
|
||
|
|--------------------------------------------------------------------------
|
||
|
| (c) 2010 Timothy Pearson
|
||
|
| (c) 2009 Kumaran Santhanam (initial KDE4 version)
|
||
|
|
|
||
|
| This project is released under the GNU General Public License.
|
||
|
| Please see the file COPYING for more details.
|
||
|
|--------------------------------------------------------------------------
|
||
|
| Remote calendar loading.
|
||
|
========================================================================*/
|
||
|
|
||
|
/*=========================================================================
|
||
|
| INCLUDES
|
||
|
========================================================================*/
|
||
|
|
||
|
#include "reader.h"
|
||
|
#include <kdebug.h>
|
||
15 years ago
|
#include <string>
|
||
15 years ago
|
|
||
|
/*=========================================================================
|
||
|
| NAMESPACE
|
||
|
========================================================================*/
|
||
|
|
||
|
using namespace KCal;
|
||
|
|
||
|
/*=========================================================================
|
||
|
| METHODS
|
||
|
========================================================================*/
|
||
|
|
||
|
void CalDavReader::cleanJob() {
|
||
|
CalDavJob::cleanJob();
|
||
|
mData = "";
|
||
14 years ago
|
}
|
||
|
|
||
|
void CalDavReader::cleanTasksJob() {
|
||
|
CalDavJob::cleanJob();
|
||
14 years ago
|
mTasksData = "";
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void CalDavReader::cleanJournalsJob() {
|
||
|
CalDavJob::cleanJob();
|
||
|
mJournalsData = "";
|
||
|
}
|
||
|
|
||
15 years ago
|
int CalDavReader::runJob(runtime_info* RT) {
|
||
13 years ago
|
kdDebug() << "reader::run, url: " << url() << '\n';
|
||
15 years ago
|
|
||
|
response* result = caldav_get_response();
|
||
|
CALDAV_RESPONSE res = OK;
|
||
|
|
||
14 years ago
|
if ((OK == res) && (url() != "")) {
|
||
|
if (mGetAll) {
|
||
13 years ago
|
kdDebug() << "getting all objects" << '\n';
|
||
14 years ago
|
res = caldav_getall_object(result, std::string(url().ascii()).c_str(), RT);
|
||
|
} else {
|
||
13 years ago
|
kdDebug() << "getting object from the specified time range" << '\n';
|
||
14 years ago
|
res = caldav_get_object(result, mTimeStart.toTime_t(), mTimeEnd.toTime_t(), std::string(url().ascii()).c_str(), RT);
|
||
|
}
|
||
15 years ago
|
|
||
14 years ago
|
if (OK == res) {
|
||
13 years ago
|
kdDebug() << "success" << '\n';
|
||
14 years ago
|
if (result->msg) {
|
||
|
mData = result->msg;
|
||
|
} else {
|
||
13 years ago
|
kdDebug() << "empty collection" << '\n';
|
||
14 years ago
|
// empty collection
|
||
|
mData = "";
|
||
|
}
|
||
|
}
|
||
15 years ago
|
}
|
||
|
|
||
|
caldav_free_response(&result);
|
||
|
|
||
14 years ago
|
return res;
|
||
|
}
|
||
|
|
||
|
int CalDavReader::runTasksJob(runtime_info* RT) {
|
||
13 years ago
|
kdDebug() << "reader::run, tasksUrl: " << tasksUrl() << '\n';
|
||
14 years ago
|
|
||
|
response* result = caldav_get_response();
|
||
14 years ago
|
CALDAV_RESPONSE tasksres = OK;
|
||
|
|
||
|
if ((OK == tasksres) && (tasksUrl() != "")) {
|
||
13 years ago
|
kdDebug() << "reader::run, url: " << tasksUrl() << '\n';
|
||
14 years ago
|
|
||
|
if (mGetAll) {
|
||
13 years ago
|
kdDebug() << "getting all objects" << '\n';
|
||
14 years ago
|
tasksres = caldav_tasks_getall_object(result, std::string(tasksUrl().ascii()).c_str(), RT);
|
||
14 years ago
|
} else {
|
||
13 years ago
|
kdDebug() << "getting object from the specified time range" << '\n';
|
||
14 years ago
|
tasksres = caldav_tasks_get_object(result, mTimeStart.toTime_t(), mTimeEnd.toTime_t(), std::string(tasksUrl().ascii()).c_str(), RT);
|
||
14 years ago
|
}
|
||
|
|
||
14 years ago
|
if (OK == tasksres) {
|
||
13 years ago
|
kdDebug() << "success" << '\n';
|
||
14 years ago
|
if (result->msg) {
|
||
|
mTasksData = result->msg;
|
||
|
} else {
|
||
13 years ago
|
kdDebug() << "empty collection" << '\n';
|
||
14 years ago
|
// empty collection
|
||
|
mTasksData = "";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
caldav_free_response(&result);
|
||
|
}
|
||
|
|
||
14 years ago
|
return tasksres;
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
int CalDavReader::runJournalsJob(runtime_info* RT) {
|
||
13 years ago
|
kdDebug() << "reader::run, journalsUrl: " << journalsUrl() << '\n';
|
||
14 years ago
|
|
||
|
response* result = caldav_get_response();
|
||
|
CALDAV_RESPONSE journalsres = OK;
|
||
|
|
||
|
if ((OK == journalsres) && (journalsUrl() != "")) {
|
||
13 years ago
|
kdDebug() << "reader::run, url: " << journalsUrl() << '\n';
|
||
14 years ago
|
|
||
|
if (mGetAll) {
|
||
13 years ago
|
kdDebug() << "getting all objects" << '\n';
|
||
14 years ago
|
journalsres = caldav_tasks_getall_object(result, std::string(journalsUrl().ascii()).c_str(), RT);
|
||
|
} else {
|
||
13 years ago
|
kdDebug() << "getting object from the specified time range" << '\n';
|
||
14 years ago
|
journalsres = caldav_tasks_get_object(result, mTimeStart.toTime_t(), mTimeEnd.toTime_t(), std::string(journalsUrl().ascii()).c_str(), RT);
|
||
|
}
|
||
|
|
||
|
if (OK == journalsres) {
|
||
13 years ago
|
kdDebug() << "success" << '\n';
|
||
14 years ago
|
if (result->msg) {
|
||
|
mJournalsData = result->msg;
|
||
|
} else {
|
||
13 years ago
|
kdDebug() << "empty collection" << '\n';
|
||
14 years ago
|
// empty collection
|
||
|
mJournalsData = "";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
caldav_free_response(&result);
|
||
|
}
|
||
|
|
||
|
return journalsres;
|
||
|
}
|
||
|
|
||
15 years ago
|
// EOF ========================================================================
|