Commit adc88ef0 authored by Àlex Fiestas's avatar Àlex Fiestas
Browse files

Added CreateTask job which inherits from CreateCalendar

parent 56294a5c
......@@ -10,6 +10,7 @@ set(webaccounts_SRCS
google/services.cpp
google/serviceoption.cpp
jobs/createcalendar.cpp
jobs/createtask.cpp
jobs/createchat.cpp
)
......
/*************************************************************************************
* Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#include "createtask.h"
#include "google_calendar_settings.h"
#include <libkgoogle/auth.h>
#include <libkgoogle/reply.h>
#include <libkgoogle/request.h>
#include <libkgoogle/accessmanager.h>
#include <libkgoogle/objects/tasklist.h>
#include <libkgoogle/services/tasks.h>
using namespace KGoogle;
CreateTask::CreateTask(KConfigGroup& group, QObject* parent) : CreateCalendar(group, parent)
{
qRegisterMetaType< KGoogle::Services::Tasks >("Task");
}
CreateTask::~CreateTask()
{
}
void CreateTask::start()
{
CreateCalendar::start();
}
void CreateTask::fetchDefaultCollections()
{
AccessManager *gam = new AccessManager;
connect(gam, SIGNAL(replyReceived(KGoogle::Reply*)),
this, SLOT(replyReceived(KGoogle::Reply*)));
Request *request = new Request(Services::Tasks::fetchTaskListsUrl(), Request::FetchAll, "Task", Auth::instance()->getAccount(m_config.name()));
gam->sendRequest(request);
}
void CreateTask::replyReceived(KGoogle::Reply* reply)
{
QStringList tasks;
QList< KGoogle::Object* > objects = reply->replyData();
Q_FOREACH(KGoogle::Object * object, objects) {
Objects::TaskList *task;
task = static_cast< Objects::TaskList* >(object);
qDebug() << task->uid();
tasks.append(task->uid());
delete task;
}
m_calendarSettings->setTaskLists(tasks);
m_calendarSettings->writeConfig();
delete reply;
}
/*************************************************************************************
* Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#ifndef CREATETASK_H
#define CREATETASK_H
#include "createcalendar.h"
#include <QtCore/QString>
class CreateTask : public CreateCalendar
{
Q_OBJECT
public:
CreateTask(KConfigGroup &group, QObject* parent = 0);
virtual ~CreateTask();
virtual void start();
protected:
virtual void fetchDefaultCollections();
private Q_SLOTS:
void replyReceived(KGoogle::Reply *reply);
};
#endif //CREATETASK_H
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment