blob: 8fec59e6554823c4b5659e1986b55ecb0e68e251 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/*
* Copyright (c) 2014 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
#include <string>
#include <vector>
#include <map>
#include <boost/optional.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <Swiften/Elements/HashElement.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
/**
* @brief This class represents the file info used in XEP-0234.
*/
class JingleFileTransferFileInfo : public Payload {
typedef boost::shared_ptr<JingleFileTransferFileInfo> ref;
public:
JingleFileTransferFileInfo(const std::string& name = "", const std::string& description = "", unsigned long long size = 0, const boost::posix_time::ptime &date = boost::posix_time::ptime()) :
name_(name), description_(description), size_(size), date_(date), supportsRangeRequests_(false), rangeOffset_(0) {
}
public:
typedef std::map<std::string, ByteArray> HashElementMap;
public:
void setName(const std::string& name) {
name_ = name;;
}
const std::string& getName() const {
return name_;
}
void setDescription(const std::string& description) {
description_ = description;
}
const std::string& getDescription() const {
return description_;
}
void setMediaType(const std::string& mediaType) {
mediaType_ = mediaType;
}
const std::string& getMediaType() const {
return mediaType_;
}
void setSize(const boost::uintmax_t size) {
size_ = size;
}
boost::uintmax_t getSize() const {
return size_;
}
void setDate(const boost::posix_time::ptime& date) {
date_ = date;
}
const boost::posix_time::ptime& getDate() const {
return date_;
}
void setSupportsRangeRequests(const bool supportsIt) {
supportsRangeRequests_ = supportsIt;
}
bool getSupportsRangeRequests() const {
return supportsRangeRequests_;
}
void setRangeOffset(const boost::uintmax_t offset) {
supportsRangeRequests_ = true;
rangeOffset_ = offset;
}
boost::uintmax_t getRangeOffset() const {
return rangeOffset_;
}
void addHash(const HashElement& hash) {
hashes_[hash.getAlgorithm()] = hash.getHashValue();
}
const std::map<std::string, ByteArray>& getHashes() const {
return hashes_;
}
boost::optional<ByteArray> getHash(const std::string& algorithm) const {
boost::optional<ByteArray> ret;
if (hashes_.find(algorithm) != hashes_.end()) {
ret = boost::optional<ByteArray>(hashes_.find(algorithm)->second);
}
return ret;
}
private:
std::string name_;
std::string description_;
std::string mediaType_;
boost::uintmax_t size_;
boost::posix_time::ptime date_;
bool supportsRangeRequests_;
boost::uintmax_t rangeOffset_;
HashElementMap hashes_;
};
}
|