forked from meganz/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMUserAlert.cpp
More file actions
197 lines (154 loc) · 4.41 KB
/
Copy pathMUserAlert.cpp
File metadata and controls
197 lines (154 loc) · 4.41 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
/**
* @file MUserAlert.cpp
* @brief Represents a user alert in MEGA.
*
* (c) 2013-2018 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 "MUserAlert.h"
using namespace mega;
using namespace Platform;
MUserAlert::MUserAlert(MegaUserAlert *megaUserAlert, bool cMemoryOwn)
{
this->megaUserAlert = megaUserAlert;
this->cMemoryOwn = cMemoryOwn;
}
MUserAlert::~MUserAlert()
{
if (cMemoryOwn)
delete megaUserAlert;
}
MegaUserAlert* MUserAlert::getCPtr()
{
return megaUserAlert;
}
MUserAlert^ MUserAlert::copy()
{
return megaUserAlert ? ref new MUserAlert(megaUserAlert->copy(), true) : nullptr;
}
unsigned int MUserAlert::getId()
{
return megaUserAlert ? megaUserAlert->getId() : (unsigned)-1;
}
bool MUserAlert::getSeen()
{
return megaUserAlert ? megaUserAlert->getSeen() : false;
}
bool MUserAlert::getRelevant()
{
return megaUserAlert ? megaUserAlert->getRelevant() : false;
}
int MUserAlert::getType()
{
return megaUserAlert ? megaUserAlert->getType() : -1;
}
String^ MUserAlert::getTypeString()
{
if (!megaUserAlert) return nullptr;
std::string utf16type;
const char *utf8type = megaUserAlert->getTypeString();
if (!utf8type)
return nullptr;
MegaApi::utf8ToUtf16(utf8type, &utf16type);
delete[] utf8type;
return ref new String((wchar_t *)utf16type.data());
}
uint64 MUserAlert::getUserHandle()
{
return megaUserAlert ? megaUserAlert->getUserHandle() : ::mega::INVALID_HANDLE;
}
uint64 MUserAlert::getNodeHandle()
{
return megaUserAlert ? megaUserAlert->getNodeHandle() : ::mega::INVALID_HANDLE;
}
String^ MUserAlert::getEmail()
{
if (!megaUserAlert) return nullptr;
std::string utf16email;
const char *utf8email = megaUserAlert->getEmail();
if (!utf8email)
return nullptr;
MegaApi::utf8ToUtf16(utf8email, &utf16email);
delete[] utf8email;
return ref new String((wchar_t *)utf16email.data());
}
String^ MUserAlert::getPath()
{
if (!megaUserAlert) return nullptr;
std::string utf16path;
const char *utf8path = megaUserAlert->getPath();
if (!utf8path)
return nullptr;
MegaApi::utf8ToUtf16(utf8path, &utf16path);
delete[] utf8path;
return ref new String((wchar_t *)utf16path.data());
}
String^ MUserAlert::getName()
{
if (!megaUserAlert) return nullptr;
std::string utf16name;
const char *utf8name = megaUserAlert->getName();
if (!utf8name)
return nullptr;
MegaApi::utf8ToUtf16(utf8name, &utf16name);
delete[] utf8name;
return ref new String((wchar_t *)utf16name.data());
}
String^ MUserAlert::getHeading()
{
if (!megaUserAlert) return nullptr;
std::string utf16heading;
const char *utf8heading = megaUserAlert->getHeading();
if (!utf8heading)
return nullptr;
MegaApi::utf8ToUtf16(utf8heading, &utf16heading);
delete[] utf8heading;
return ref new String((wchar_t *)utf16heading.data());
}
String^ MUserAlert::getTitle()
{
if (!megaUserAlert) return nullptr;
std::string utf16title;
const char *utf8title = megaUserAlert->getTitle();
if (!utf8title)
return nullptr;
MegaApi::utf8ToUtf16(utf8title, &utf16title);
delete[] utf8title;
return ref new String((wchar_t *)utf16title.data());
}
uint64 MUserAlert::getNumber(unsigned int index)
{
return megaUserAlert ? megaUserAlert->getNumber(index) : -1;
}
uint64 MUserAlert::getTimestamp(unsigned int index)
{
return megaUserAlert ? megaUserAlert->getTimestamp(index) : -1;
}
String^ MUserAlert::getString(unsigned int index)
{
if (!megaUserAlert) return nullptr;
std::string utf16string;
const char *utf8string = megaUserAlert->getString(index);
if (!utf8string)
return nullptr;
MegaApi::utf8ToUtf16(utf8string, &utf16string);
delete[] utf8string;
return ref new String((wchar_t *)utf16string.data());
}
bool MUserAlert::isOwnChange()
{
return megaUserAlert ? megaUserAlert->isOwnChange() : false;
}