forked from meganz/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMRequest.cpp
More file actions
256 lines (199 loc) · 6.1 KB
/
Copy pathMRequest.cpp
File metadata and controls
256 lines (199 loc) · 6.1 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
/**
* @file MRequest.cpp
* @brief Provides information about an asynchronous request.
*
* (c) 2013-2014 by Mega Limited, Auckland, New Zealand
*
* This file is part of the MEGA SDK - Client Access Engine.
*
* Applications using the MEGA API must present a valid application key
* and comply with the the rules set forth in the Terms of Service.
*
* The MEGA SDK 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.
*
* @copyright Simplified (2-clause) BSD License.
*
* You should have received a copy of the license along with this
* program.
*/
#include "MRequest.h"
using namespace mega;
using namespace Platform;
MRequest::MRequest(MegaRequest *megaRequest, bool cMemoryOwn)
{
this->megaRequest = megaRequest;
this->cMemoryOwn = cMemoryOwn;
}
MRequest::~MRequest()
{
if (cMemoryOwn)
delete megaRequest;
}
MegaRequest* MRequest::getCPtr()
{
return megaRequest;
}
MRequest^ MRequest::copy()
{
return megaRequest ? ref new MRequest(megaRequest->copy(), true) : nullptr;
}
MRequestType MRequest::getType()
{
return (MRequestType) (megaRequest ? megaRequest->getType() : -1);
}
String^ MRequest::getRequestString()
{
if (!megaRequest) return nullptr;
std::string utf16request;
const char *utf8request = megaRequest->getRequestString();
MegaApi::utf8ToUtf16(utf8request, &utf16request);
return utf8request ? ref new String((wchar_t *)utf16request.data()) : nullptr;
}
String^ MRequest::toString()
{
return getRequestString();
}
uint64 MRequest::getNodeHandle()
{
return megaRequest ? megaRequest->getNodeHandle() : ::mega::INVALID_HANDLE;
}
String^ MRequest::getLink()
{
if (!megaRequest) return nullptr;
std::string utf16link;
const char *utf8link = megaRequest->getLink();
MegaApi::utf8ToUtf16(utf8link, &utf16link);
return utf8link ? ref new String((wchar_t *)utf16link.data()) : nullptr;
}
uint64 MRequest::getParentHandle()
{
return megaRequest ? megaRequest->getParentHandle() : ::mega::INVALID_HANDLE;
}
String^ MRequest::getSessionKey()
{
if (!megaRequest) return nullptr;
std::string utf16session;
const char *utf8session = megaRequest->getSessionKey();
MegaApi::utf8ToUtf16(utf8session, &utf16session);
return utf8session ? ref new String((wchar_t *)utf16session.data()) : nullptr;
}
String^ MRequest::getName()
{
if (!megaRequest) return nullptr;
std::string utf16name;
const char *utf8name = megaRequest->getName();
MegaApi::utf8ToUtf16(utf8name, &utf16name);
return utf8name ? ref new String((wchar_t *)utf16name.data()) : nullptr;
}
String^ MRequest::getEmail()
{
if (!megaRequest) return nullptr;
std::string utf16email;
const char *utf8email = megaRequest->getEmail();
MegaApi::utf8ToUtf16(utf8email, &utf16email);
return utf8email ? ref new String((wchar_t *)utf16email.data()) : nullptr;
}
String^ MRequest::getPassword()
{
if (!megaRequest) return nullptr;
std::string utf16password;
const char *utf8password = megaRequest->getPassword();
MegaApi::utf8ToUtf16(utf8password, &utf16password);
return utf8password ? ref new String((wchar_t *)utf16password.data()) : nullptr;
}
String^ MRequest::getNewPassword()
{
if (!megaRequest) return nullptr;
std::string utf16password;
const char *utf8password = megaRequest->getNewPassword();
MegaApi::utf8ToUtf16(utf8password, &utf16password);
return utf8password ? ref new String((wchar_t *)utf16password.data()) : nullptr;
}
String^ MRequest::getPrivateKey()
{
if (!megaRequest) return nullptr;
std::string utf16privateKey;
const char *utf8privateKey = megaRequest->getPrivateKey();
MegaApi::utf8ToUtf16(utf8privateKey, &utf16privateKey);
return utf8privateKey ? ref new String((wchar_t *)utf16privateKey.data()) : nullptr;
}
int MRequest::getAccess()
{
return megaRequest ? megaRequest->getAccess() : -1;
}
String^ MRequest::getFile()
{
if (!megaRequest) return nullptr;
std::string utf16file;
const char *utf8file = megaRequest->getFile();
MegaApi::utf8ToUtf16(utf8file, &utf16file);
return utf8file ? ref new String((wchar_t *)utf16file.data()) : nullptr;
}
int MRequest::getNumRetry()
{
return megaRequest ? megaRequest->getNumRetry() : 0;
}
MNode^ MRequest::getPublicMegaNode()
{
if (megaRequest == nullptr) return nullptr;
MegaNode *node = megaRequest->getPublicMegaNode();
return node ? ref new MNode(node, true) : nullptr;
}
int MRequest::getParamType()
{
return megaRequest ? megaRequest->getParamType() : 0;
}
String^ MRequest::getText()
{
if (!megaRequest) return nullptr;
std::string utf16text;
const char *utf8text = megaRequest->getText();
MegaApi::utf8ToUtf16(utf8text, &utf16text);
return utf8text ? ref new String((wchar_t *)utf16text.data()) : nullptr;
}
uint64 MRequest::getNumber()
{
return megaRequest ? megaRequest->getNumber() : 0;
}
bool MRequest::getFlag()
{
return megaRequest ? megaRequest->getFlag() : 0;
}
uint64 MRequest::getTransferredBytes()
{
return megaRequest ? megaRequest->getTransferredBytes() : 0;
}
uint64 MRequest::getTotalBytes()
{
return megaRequest ? megaRequest->getTotalBytes() : 0;
}
MAccountDetails^ MRequest::getMAccountDetails()
{
return megaRequest ? ref new MAccountDetails(megaRequest->getMegaAccountDetails(), true) : nullptr;
}
int MRequest::getTransferTag()
{
return megaRequest ? megaRequest->getTransferTag() : 0;
}
int MRequest::getNumDetails()
{
return megaRequest ? megaRequest->getNumDetails() : 0;
}
int MRequest::getTag()
{
return megaRequest ? megaRequest->getTag() : 0;
}
MPricing^ MRequest::getPricing()
{
return megaRequest ? ref new MPricing(megaRequest->getPricing(), true) : nullptr;
}
MAchievementsDetails^ MRequest::getMAchievementsDetails()
{
return megaRequest ? ref new MAchievementsDetails(megaRequest->getMegaAchievementsDetails(), true) : nullptr;
}
MTimeZoneDetails^ MRequest::getMTimeZoneDetails()
{
return megaRequest ? ref new MTimeZoneDetails(megaRequest->getMegaTimeZoneDetails(), true) : nullptr;
}