1 # Canola2 Remember The Milk Plugin
2 # Authors: Andrey Popelo <andrey@popelo.com>
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Additional permission under GNU GPL version 3 section 7
19 # If you modify this Program, or any covered work, by linking or combining it
20 # with Canola2 and its core components (or a modified version of any of those),
21 # containing parts covered by the terms of Instituto Nokia de Tecnologia End
22 # User Software Agreement, the licensors of this Program grant you additional
23 # permission to convey the resulting work.
27 from terra.core.manager import Manager
28 from terra.core.task import Task
29 from terra.core.model import ModelFolder, Model
31 from client import Client
35 PluginDefaultIcon = manager.get_class("Icon/Plugin")
37 log = logging.getLogger("plugins.canola-rtm.model")
40 class Icon(PluginDefaultIcon):
41 terra_type = "Icon/Folder/Task/Apps/RTM"
42 icon = "icon/main_item/rtm"
45 # TODO more documentation
46 class RTMTaskModel(Model):
47 """Base class for Remember The Milk task models.
50 terra_type = "Model/RTMTask"
52 def __init__(self, name, parent=None):
53 Model.__init__(self, name, parent)
57 class ServiceModelFolder(ModelFolder):
58 terra_type = "Model/Folder/Task/Apps/RTM/Service"
60 empty_msg = "No tasks found"
62 def __init__(self, name, parent):
63 ModelFolder.__init__(self, name, parent)
65 self.client = Client('1e6e489de9374b43ba280ab9741d290c', 'c7197d30f722247d', '1f4c8846175f4bafcf70f7742f4670e41b0ab046')
73 for c in self.do_search():
74 self.children.append(c)
78 raise NotImplementedError("must be implemented by subclasses")
80 ##############################################################################
81 # Remember The Milk Remote Service Models
82 ##############################################################################
84 class TodayModelFolder(ServiceModelFolder):
85 """This model implements the Today option."""
86 terra_type = "Model/Folder/Task/Apps/RTM/Service/Today"
88 def __init__(self, name, parent):
89 ServiceModelFolder.__init__(self, name, parent)
93 self.client.tasks.getList(filter='dueBefore:tomorrow')
95 lst = [ RTMTaskModel("Task #1 (stub)"),
96 RTMTaskModel("Task #2 (stub)"),
97 RTMTaskModel("Task #3 (stub)") ]
102 ##############################################################################
103 # Main Remember The Milk Model
104 ##############################################################################
106 class MainModelFolder(ModelFolder, Task):
107 """Main Remember The Milk Model.
109 This is the main remember the milk model. It initializes all other models.
111 terra_type = "Model/Folder/Task/Apps/RTM"
112 terra_task_type = "Task/Folder/Task/Apps/RTM"
114 def __init__(self, parent):
116 ModelFolder.__init__(self, "Remember the milk", parent)
119 """Initialize base remember the milk models, like Today, Smart
120 lists, Search and others.
122 TodayModelFolder("Today", self);