1
# -*- coding: utf-8 -*-
2
# Copyright (c) 2009 - Luca Invernizzi <invernizzi.l@gmail.com>
4
# This program is free software: you can redistribute it and/or modify it under
5
# the terms of the GNU General Public License as published by the Free Software
6
# Foundation, either version 3 of the License, or (at your option) any later
9
# This program is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
# You should have received a copy of the GNU General Public License along with
15
# this program. If not, see <http://www.gnu.org/licenses/>.
19
from GTG.core.task import Task
20
from GTG.plugins.evolution_sync.evolutionTask import EvolutionTask
21
from GTG.plugins.evolution_sync.genericProxy import GenericProxy
24
class EvolutionProxy(GenericProxy):
26
__GTG_STATUSES = [Task.STA_ACTIVE,
30
__EVO_STATUSES = [evolution.ecal.ICAL_STATUS_CONFIRMED,
31
evolution.ecal.ICAL_STATUS_COMPLETED,
32
evolution.ecal.ICAL_STATUS_CANCELLED]
35
super(EvolutionProxy, self).__init__()
37
def generateTaskList(self):
38
task_personal = evolution.ecal.list_task_sources()[0][1]
39
self._evolution_tasks = evolution.ecal.open_calendar_source(task_personal,
40
evolution.ecal.CAL_SOURCE_TYPE_TODO)
41
self._gtg_to_evo_status = dict(zip(self.__GTG_STATUSES,
43
self._evo_to_gtg_status = dict(zip(self.__EVO_STATUSES,
45
#Need to find a solution for the statuses GTG doesn't expect:
46
for evo_status in [evolution.ecal.ICAL_STATUS_DRAFT,
47
evolution.ecal.ICAL_STATUS_FINAL,
48
evolution.ecal.ICAL_STATUS_INPROCESS,
49
evolution.ecal.ICAL_STATUS_NEEDSACTION,
50
evolution.ecal.ICAL_STATUS_NONE,
51
evolution.ecal.ICAL_STATUS_TENTATIVE,
52
evolution.ecal.ICAL_STATUS_X]:
53
self._evo_to_gtg_status[evo_status] = Task.STA_ACTIVE
55
for task in self._evolution_tasks.get_all_objects():
56
self._tasks_list.append(EvolutionTask(task, self))
58
def create_new_task(self, title):
59
task = evolution.ecal.ECalComponent(ical=evolution.ecal.CAL_COMPONENT_TODO)
60
self._evolution_tasks.add_object(task)
61
new_task = EvolutionTask(task, self)
62
new_task.title = title
63
self._tasks_list.append(new_task)
66
def delete_task(self, task):
67
evo_task = task.get_evolution_task()
68
self._evolution_tasks.remove_object(evo_task)
69
self._evolution_tasks.update_object(evo_task)
71
def update_task(self, task):
72
evo_task = task.get_evolution_task()
73
self._evolution_tasks.update_object(evo_task)