summaryrefslogtreecommitdiffstats
path: root/module/api
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-23 21:56:42 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-23 21:56:42 +0100
commit6e8a0f79f5ad7182a0bc35308ae06c63222667ed (patch)
tree0026179d34f19b64bc689c63af85b949ce57fb83 /module/api
parentshow button when files are selected (diff)
downloadpyload-6e8a0f79f5ad7182a0bc35308ae06c63222667ed.tar.xz
implemented interactions for multi user, show waiting queries on webui
Diffstat (limited to 'module/api')
-rw-r--r--module/api/CoreApi.py5
-rw-r--r--module/api/UserInteractionApi.py32
2 files changed, 16 insertions, 21 deletions
diff --git a/module/api/CoreApi.py b/module/api/CoreApi.py
index d75fe6ad6..e5c5e8b41 100644
--- a/module/api/CoreApi.py
+++ b/module/api/CoreApi.py
@@ -1,13 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from module.Api import Api, RequirePerm, Permission, ServerStatus
+from module.Api import Api, RequirePerm, Permission, ServerStatus, Interaction
from module.utils.fs import join, free_space
from module.utils import compare_time
from ApiComponent import ApiComponent
-
class CoreApi(ApiComponent):
""" This module provides methods for general interaction with the core, like status or progress retrieval """
@@ -34,7 +33,7 @@ class CoreApi(ApiComponent):
serverStatus = ServerStatus(0,
total[0], queue[0],
total[1], queue[1],
- 0,
+ self.isInteractionWaiting(Interaction.All),
not self.core.threadManager.pause and self.isTimeDownload(),
self.core.threadManager.pause,
self.core.config['reconnect']['activated'] and self.isTimeReconnect())
diff --git a/module/api/UserInteractionApi.py b/module/api/UserInteractionApi.py
index ded305c30..b95b7c468 100644
--- a/module/api/UserInteractionApi.py
+++ b/module/api/UserInteractionApi.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from module.Api import Api, RequirePerm, Permission, InteractionTask
+from module.Api import Api, RequirePerm, Permission, Interaction
from ApiComponent import ApiComponent
@@ -15,40 +15,36 @@ class UserInteractionApi(ApiComponent):
:param mode: binary or'ed output type
:return: boolean
"""
- return self.core.interactionManager.isTaskWaiting(mode)
+ return self.core.interactionManager.isTaskWaiting(self.primaryUID, mode)
@RequirePerm(Permission.Interaction)
- def getInteractionTask(self, mode):
+ def getInteractionTasks(self, mode):
"""Retrieve task for specific mode.
- :param mode: binary or'ed output type
- :return: :class:`InteractionTask`
+ :param mode: binary or'ed interaction types which should be retrieved
+ :rtype list of :class:`InteractionTask`
"""
- task = self.core.interactionManager.getTask(mode)
- return InteractionTask(-1) if not task else task
+ tasks = self.core.interactionManager.getTasks(self.primaryUID, mode)
+ # retrieved tasks count as seen
+ for t in tasks:
+ t.seen = True
+ if t.type == Interaction.Notification:
+ t.setWaiting(self.core.interactionManager.CLIENT_THRESHOLD)
+ return tasks
@RequirePerm(Permission.Interaction)
def setInteractionResult(self, iid, result):
"""Set Result for a interaction task. It will be immediately removed from task queue afterwards
:param iid: interaction id
- :param result: result as string
+ :param result: result as json string
"""
task = self.core.interactionManager.getTaskByID(iid)
- if task:
+ if task and self.primaryUID == task.owner:
task.setResult(result)
@RequirePerm(Permission.Interaction)
- def getNotifications(self):
- """List of all available notifcations. They stay in queue for some time, client should\
- save which notifications it already has seen.
-
- :return: list of :class:`InteractionTask`
- """
- return self.core.interactionManager.getNotifications()
-
- @RequirePerm(Permission.Interaction)
def getAddonHandler(self):
pass