~michihenning/storage-framework/check-server-side-metadata

« back to all changes in this revision

Viewing changes to src/qt/client/internal/remote_client/ItemImpl.cpp

  • Committer: Tarmac
  • Author(s): Michi Henning
  • Date: 2016-08-11 06:28:04 UTC
  • mfrom: (10.12.7 marshal-metadata)
  • Revision ID: tarmac-20160811062804-xdb4d33u2fiqcydv
Marshal known metadata, with sanity checks on the client side.

Approved by unity-api-1-bot, James Henstridge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include <unity/storage/qt/client/internal/remote_client/ItemImpl.h>
20
20
 
21
21
#include "ProviderInterface.h"
 
22
#include <unity/storage/provider/metadata_keys.h>
22
23
#include <unity/storage/qt/client/Account.h>
23
24
#include <unity/storage/qt/client/internal/remote_client/AccountImpl.h>
24
25
#include <unity/storage/qt/client/internal/remote_client/FileImpl.h>
25
26
#include <unity/storage/qt/client/internal/remote_client/Handler.h>
26
27
#include <unity/storage/qt/client/internal/remote_client/RootImpl.h>
 
28
#include <unity/storage/qt/client/internal/remote_client/validate.h>
27
29
 
28
30
#include <cassert>
29
31
 
70
72
QDateTime ItemImpl::last_modified_time() const
71
73
{
72
74
    throw_if_destroyed("Item::last_modified_time()");
73
 
    // TODO: need to agree on metadata representation
74
 
    return QDateTime();
 
75
    return QDateTime::fromString(md_.metadata.value(provider::LAST_MODIFIED_TIME).toString(), Qt::ISODate);
75
76
}
76
77
 
77
78
QFuture<shared_ptr<Item>> ItemImpl::copy(shared_ptr<Folder> const& new_parent, QString const& new_name)
106
107
        }
107
108
 
108
109
        auto md = reply.value();
 
110
        try
 
111
        {
 
112
            validate("Item::copy()", md);
 
113
        }
 
114
        catch (StorageException const& e)
 
115
        {
 
116
            make_exceptional_future(qf, e);
 
117
            return;
 
118
        }
109
119
        if (md.type == ItemType::root)
110
120
        {
111
121
            // TODO: log server error here
158
168
        }
159
169
 
160
170
        auto md = reply.value();
 
171
        try
 
172
        {
 
173
            validate("Item::move()", md);
 
174
        }
 
175
        catch (StorageException const& e)
 
176
        {
 
177
            make_exceptional_future(qf, e);
 
178
            return;
 
179
        }
161
180
        if (md.type == ItemType::root)
162
181
        {
163
182
            // TODO: log server error here
220
239
QDateTime ItemImpl::creation_time() const
221
240
{
222
241
    throw_if_destroyed("Item::creation_time()");
223
 
    // TODO: need to agree on metadata representation
224
 
    return QDateTime();
 
242
    return QDateTime::fromString(md_.metadata.value(provider::CREATION_TIME).toString(), Qt::ISODate);
225
243
}
226
244
 
227
245
MetadataMap ItemImpl::native_metadata() const