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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
//
// Copyright (c) 2013 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/**
* @file FScl_AccountProviderImpl.cpp
* @brief This is the implementation for _AccountProviderImpl class.
*
* This file contains definitions of @e _AccountProviderImpl class.
*/
#include <FBaseColIList.h>
#include <FBaseResult.h>
#include <FBaseString.h>
#include <FBaseSysLog.h>
#include <FSclAccountProvider.h>
#include "FScl_AccountProviderImpl.h"
using namespace Tizen::App;
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
namespace Tizen { namespace Social
{
_AccountProviderImpl::_AccountProviderImpl(void)
: __isMultipleAccountSupported(false)
{
std::unique_ptr<ArrayList, AllElementsDeleter> pCapabilityList(new (std::nothrow) ArrayList());
SysTryReturnVoidResult(NID_SCL, pCapabilityList != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
result r = pCapabilityList->Construct();
SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pCapabilityList.", GetErrorMessage(r));
__pCapabilityList = std::move(pCapabilityList);
}
_AccountProviderImpl::_AccountProviderImpl(const _AccountProviderImpl& rhs)
{
std::unique_ptr<ArrayList, AllElementsDeleter> pCapabilityList(new (std::nothrow) ArrayList());
SysTryReturnVoidResult(NID_SCL, pCapabilityList != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
result r = pCapabilityList->Construct();
SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pCapabilityList.", GetErrorMessage(r));
std::unique_ptr<IEnumerator> pEnum(rhs.__pCapabilityList->GetEnumeratorN());
SysTryReturnVoidResult(NID_SCL, pEnum != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
std::unique_ptr<String> pCapability(null);
String* pTempCapability = null;
while (pEnum->MoveNext() == E_SUCCESS)
{
pTempCapability = static_cast<String*> (pEnum->GetCurrent());
pCapability.reset(new (std::nothrow) String(*pTempCapability));
SysTryReturnVoidResult(NID_SCL, pCapability != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pCapabilityList->Add(pCapability.get());
SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
pCapability.release();
}
__pCapabilityList = std::move(pCapabilityList);
__appId = rhs.__appId;
__displayName = rhs.__displayName;
__iconPath = rhs.__iconPath;
__smallIconPath = rhs.__smallIconPath;
__isMultipleAccountSupported = rhs.__isMultipleAccountSupported;
}
_AccountProviderImpl::~_AccountProviderImpl(void)
{
// empty body
}
_AccountProviderImpl&
_AccountProviderImpl::operator =(const _AccountProviderImpl& rhs)
{
if (this == &rhs)
{
return *this;
}
std::unique_ptr<ArrayList, AllElementsDeleter> pCapabilityList(new (std::nothrow) ArrayList());
SysTryReturn(NID_SCL, pCapabilityList != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
result r = pCapabilityList->Construct();
SysTryReturn(NID_SCL, !IsFailed(r), *this, r, "[%s] Failed to construct pCapabilityList.", GetErrorMessage(r));
result prevResult = GetLastResult();
std::unique_ptr<IEnumerator> pEnum(rhs.__pCapabilityList->GetEnumeratorN());
SysTryReturn(NID_SCL, pEnum != null, *this, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
SetLastResult(prevResult);
std::unique_ptr<String> pCapability(null);
String* pTempCapability = null;
while (pEnum->MoveNext() == E_SUCCESS)
{
pTempCapability = static_cast<String*> (pEnum->GetCurrent());
pCapability.reset(new (std::nothrow) String(*pTempCapability));
SysTryReturn(NID_SCL, pCapability != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pCapabilityList->Add(pCapability.get());
SysTryReturn(NID_SCL, !IsFailed(r), *this, r, "[%s] Propagating.", GetErrorMessage(r));
pCapability.release();
}
__pCapabilityList = std::move(pCapabilityList);
__appId = rhs.__appId;
__displayName = rhs.__displayName;
__iconPath = rhs.__iconPath;
__smallIconPath = rhs.__smallIconPath;
__isMultipleAccountSupported = rhs.__isMultipleAccountSupported;
return *this;
}
bool
_AccountProviderImpl::operator ==(const _AccountProviderImpl& rhs) const
{
if ((__appId == rhs.__appId) &&
(__displayName == rhs.__displayName) &&
(__iconPath == rhs.__iconPath) &&
(__smallIconPath == rhs.__smallIconPath) &&
(__isMultipleAccountSupported == rhs.__isMultipleAccountSupported) &&
(__pCapabilityList->Equals(*(rhs.__pCapabilityList))))
{
return true;
}
return false;
}
bool
_AccountProviderImpl::operator !=(const _AccountProviderImpl& rhs) const
{
return !(*this == rhs);
}
bool
_AccountProviderImpl::Equals(const Object& rhs) const
{
const _AccountProviderImpl* pAccountProviderImpl = dynamic_cast<const _AccountProviderImpl*> (&rhs);
if (pAccountProviderImpl == null)
{
return false;
}
if ((__appId != pAccountProviderImpl->__appId) ||
(__displayName != pAccountProviderImpl->__displayName) ||
(__iconPath != pAccountProviderImpl->__iconPath) ||
(__smallIconPath != pAccountProviderImpl->__smallIconPath) ||
(__isMultipleAccountSupported != pAccountProviderImpl->__isMultipleAccountSupported) ||
!(__pCapabilityList->Equals(*(pAccountProviderImpl->__pCapabilityList))))
{
return false;
}
return true;
}
int
_AccountProviderImpl::GetHashCode(void) const
{
int hashCode = 0;
hashCode += __appId.GetHashCode();
hashCode += __displayName.GetHashCode();
return hashCode;
}
result
_AccountProviderImpl::AddCapability(const String& capability)
{
std::unique_ptr<IEnumerator> pEnum(__pCapabilityList->GetEnumeratorN());
SysTryReturnResult(NID_SCL, pEnum != null, GetLastResult(), "Propagating.");
String* pTempCapability = null;
bool alreadyExist = false;
while (pEnum->MoveNext() == E_SUCCESS)
{
pTempCapability = static_cast<String*> (pEnum->GetCurrent());
if (*pTempCapability == capability)
{
alreadyExist = true;
break;
}
}
SysTryReturnResult(NID_SCL, !alreadyExist, E_OBJ_ALREADY_EXIST, "The capability already exists.");
std::unique_ptr<String> pCapability(new (std::nothrow) String(capability));
SysTryReturnResult(NID_SCL, pCapability != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
result r = __pCapabilityList->Add(pCapability.get());
SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
pCapability.release();
return E_SUCCESS;
}
AppId
_AccountProviderImpl::GetAppId(void) const
{
return __appId;
}
IList*
_AccountProviderImpl::GetCapabilitiesN(void) const
{
ClearLastResult();
std::unique_ptr<ArrayList, AllElementsDeleter> pCapabilityList(new (std::nothrow) ArrayList());
SysTryReturn(NID_SCL, pCapabilityList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
result r = pCapabilityList->Construct();
SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Failed to construct pCapabilityList.", GetErrorMessage(r));
std::unique_ptr<IEnumerator> pEnum(__pCapabilityList->GetEnumeratorN());
SysTryReturn(NID_SCL, pEnum != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
std::unique_ptr<String> pCapability(null);
String* pTempCapability = null;
while (pEnum->MoveNext() == E_SUCCESS)
{
pTempCapability = static_cast<String*> (pEnum->GetCurrent());
pCapability.reset(new (std::nothrow) String(*pTempCapability));
SysTryReturn(NID_SCL, pCapability != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pCapabilityList->Add(pCapability.get());
SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
pCapability.release();
}
return pCapabilityList.release();
}
String
_AccountProviderImpl::GetDisplayName(void) const
{
return __displayName;
}
String
_AccountProviderImpl::GetIconPath(void) const
{
return __iconPath;
}
String
_AccountProviderImpl::GetSmallIconPath(void) const
{
return __smallIconPath;
}
bool
_AccountProviderImpl::IsMultipleAccountSupported(void) const
{
return __isMultipleAccountSupported;
}
void
_AccountProviderImpl::SetAppId(const AppId& appId)
{
__appId = appId;
}
void
_AccountProviderImpl::SetDisplayName(const String& displayName)
{
__displayName = displayName;
}
void
_AccountProviderImpl::SetIconPath(const String& iconPath)
{
__iconPath = iconPath;
}
void
_AccountProviderImpl::SetSmallIconPath(const String& smallIconPath)
{
__smallIconPath = smallIconPath;
}
void
_AccountProviderImpl::SetMultipleAccountsSupport(bool isSupported)
{
__isMultipleAccountSupported = isSupported;
}
const _AccountProviderImpl*
_AccountProviderImpl::GetInstance(const AccountProvider& accountProvider)
{
return accountProvider.__pAccountProviderImpl;
}
_AccountProviderImpl*
_AccountProviderImpl::GetInstance(AccountProvider& accountProvider)
{
return accountProvider.__pAccountProviderImpl;
}
}} //Tizen::Social
|