--- /dev/null
+# Canola2 Remember The Milk Plugin
+# Authors: Andrey Popelo <andrey@popelo.com>
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+# Additional permission under GNU GPL version 3 section 7
+#
+# If you modify this Program, or any covered work, by linking or combining it
+# with Canola2 and its core components (or a modified version of any of those),
+# containing parts covered by the terms of Instituto Nokia de Tecnologia End
+# User Software Agreement, the licensors of this Program grant you additional
+# permission to convey the resulting work.
+
+import logging
+
+from terra.core.manager import Manager
+from terra.core.task import Task
+from terra.core.model import ModelFolder, Model
+
+from client import Client
+
+
+manager = Manager()
+PluginDefaultIcon = manager.get_class("Icon/Plugin")
+
+log = logging.getLogger("plugins.canola-rtm.model")
+
+
+class Icon(PluginDefaultIcon):
+ terra_type = "Icon/Folder/Task/Apps/RTM"
+ icon = "icon/main_item/rtm"
+ plugin = "rtm"
+
+# TODO more documentation
+class RTMTaskModel(Model):
+ """Base class for Remember The Milk task models.
+
+ """
+ terra_type = "Model/RTMTask"
+
+ def __init__(self, name, parent=None):
+ Model.__init__(self, name, parent)
+ self.duedate = ""
+ self.priority = ""
+
+class ServiceModelFolder(ModelFolder):
+ terra_type = "Model/Folder/Task/Apps/RTM/Service"
+
+ empty_msg = "No tasks found"
+
+ def __init__(self, name, parent):
+ ModelFolder.__init__(self, name, parent)
+ # TODO change token
+ self.client = Client('1e6e489de9374b43ba280ab9741d290c', 'c7197d30f722247d', '1f4c8846175f4bafcf70f7742f4670e41b0ab046')
+
+ def do_load(self):
+ self.search()
+
+ def search(self):
+ del self.children[:]
+
+ for c in self.do_search():
+ self.children.append(c)
+ return
+
+ def do_search(self):
+ raise NotImplementedError("must be implemented by subclasses")
+
+##############################################################################
+# Remember The Milk Remote Service Models
+##############################################################################
+
+class TodayModelFolder(ServiceModelFolder):
+ """This model implements the Today option."""
+ terra_type = "Model/Folder/Task/Apps/RTM/Service/Today"
+
+ def __init__(self, name, parent):
+ ServiceModelFolder.__init__(self, name, parent)
+
+ def do_search(self):
+ lst = []
+ self.client.tasks.getList(filter='dueBefore:tomorrow')
+ # TODO remove stubs
+ lst = [ RTMTaskModel("Task #1 (stub)"),
+ RTMTaskModel("Task #2 (stub)"),
+ RTMTaskModel("Task #3 (stub)") ]
+
+ return lst
+
+
+##############################################################################
+# Main Remember The Milk Model
+##############################################################################
+
+class MainModelFolder(ModelFolder, Task):
+ """Main Remember The Milk Model.
+
+ This is the main remember the milk model. It initializes all other models.
+ """
+ terra_type = "Model/Folder/Task/Apps/RTM"
+ terra_task_type = "Task/Folder/Task/Apps/RTM"
+
+ def __init__(self, parent):
+ Task.__init__(self)
+ ModelFolder.__init__(self, "Remember the milk", parent)
+
+ def do_load(self):
+ """Initialize base remember the milk models, like Today, Smart
+ lists, Search and others.
+ """
+ TodayModelFolder("Today", self);
+