~verterok/ubuntuone-client/fix-776386

« back to all changes in this revision

Viewing changes to canonical/ubuntuone/storage/syncdaemon/interfaces.py

  • Committer: Rodney Dawes
  • Date: 2009-05-12 13:36:05 UTC
  • Revision ID: rodney.dawes@canonical.com-20090512133605-6aqs6e8xnnmp5u1p
        Import the code
        Hook up lint/trial tests in setup.py
        Use icontool now instead of including the render script
        Add missing python-gnome2-desktop to package dependencies
        Update debian/rules to fix the icon cache issue

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# canonical.ubuntuone.storage.syncdaemon.interfaces - ActionQueue interface
 
2
#
 
3
# Authors: John Lenton <john.lenton@canonical.com>
 
4
#          Lucio Torre <lucio.torre@canonical.com>
 
5
#
 
6
# Copyright 2009 Canonical Ltd.
 
7
#
 
8
# This program is free software: you can redistribute it and/or modify it
 
9
# under the terms of the GNU General Public License version 3, as published
 
10
# by the Free Software Foundation.
 
11
#
 
12
# This program is distributed in the hope that it will be useful, but
 
13
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
14
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
15
# PURPOSE.  See the GNU General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License along
 
18
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
"""
 
20
This is the interface of the ActionQueue
 
21
"""
 
22
 
 
23
from zope.interface import Interface, Attribute
 
24
 
 
25
# pylint: disable-msg=W0232,E0213,E0211
 
26
 
 
27
class IContentQueue(Interface):
 
28
    """
 
29
    The content queue is the part of access queue that manages uploads
 
30
    and downloads of content.
 
31
    """
 
32
 
 
33
    downloading = Attribute("The set of active downloads")
 
34
    uploading = Attribute("The set of active uploads")
 
35
 
 
36
    def cancel_download(share_id, node_id):
 
37
        """
 
38
        Try to cancel any download for the given node.
 
39
 
 
40
        The return value is whether we've been able to cancel a
 
41
        download.
 
42
        """
 
43
 
 
44
    def cancel_upload(share_id, node_id):
 
45
        """
 
46
        Try to cancel any upload for the given node.
 
47
 
 
48
        The return value is whether we're sure that we've been able to
 
49
        cancel an upload. We might succeed without knowing it,
 
50
        however.
 
51
        """
 
52
 
 
53
    def download(share_id, node_id, server_hash, fileobj):
 
54
        """
 
55
        Go get the content for the given node and dump it into
 
56
        file-like object fileobj.
 
57
        """
 
58
 
 
59
    def upload(share_id, node_id, previous_hash, hash, crc32,
 
60
               size, deflated_size, fileobj):
 
61
        """
 
62
        Put the content of file-like object fileobj up in the given
 
63
        node.
 
64
        """
 
65
 
 
66
class IMetaQueue(Interface):
 
67
    """
 
68
    The MetaQueue is the part of AccessQueue that manages transfers of
 
69
    metadata.
 
70
    """
 
71
 
 
72
    def make_file(share_id, parent_id, name, marker):
 
73
        """
 
74
        Ask the server to create a file called name in the given
 
75
        parent; and use marker as a marker in the ensuing
 
76
        notification.
 
77
        """
 
78
 
 
79
    def make_dir(share_id, parent_id, name, marker):
 
80
        """
 
81
        Ask the server to make a directory called name in the given
 
82
        parent, and use marker as a marker in the ensuing
 
83
        notification.
 
84
        """
 
85
 
 
86
    def move(share_id, node_id, old_parent_id, new_parent_id, new_name):
 
87
        """
 
88
        Ask the server to move a node to the given parent and name.
 
89
        """
 
90
 
 
91
    def unlink(share_id, parent_id, node_id):
 
92
        """
 
93
        Unlink the given node.
 
94
        """
 
95
 
 
96
    def query(items):
 
97
        """
 
98
        Gossip with the server about the freshness of the server hashes
 
99
 
 
100
        Items is a list of (hash_id, node_id, node_hash).
 
101
        """
 
102
 
 
103
    def listdir(share_id, node_id, server_hash, fileobj):
 
104
        """
 
105
        List (get the content of) the given directory.
 
106
        """
 
107
 
 
108
    def list_shares():
 
109
        """
 
110
        Get a list of the shares, and put the result on the event queue.
 
111
        """
 
112
 
 
113
    def create_share(node, share_to, name, access_level):
 
114
        """
 
115
        Ask the server to create a share.
 
116
        """
 
117
 
 
118
class IActionQueue(IContentQueue, IMetaQueue):
 
119
    """
 
120
    The access queue itself.
 
121
    """
 
122
    connection_state = Attribute('The connection state')
 
123
 
 
124
    def connect(host, port, use_ssl=False):
 
125
        """
 
126
        Open a (possibly SSL) connection to the API server on (host,
 
127
        port). Once you've connected, do the OAuth dance.
 
128
        """
 
129
 
 
130
    def disconnect():
 
131
        """
 
132
        Close the connection
 
133
        """
 
134
 
 
135
class IMarker(Interface):
 
136
    """
 
137
    A marker interface for telling server uuids apart from markers.
 
138
    """