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
|
///
// Tizen C++ SDK
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Flora License, Version 1.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://floralicense.org/license/
//
// 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.
//
#include "FApp.h"
#include "AppResourceId.h"
#include "AddAccountForm.h"
using namespace Tizen::App;
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
using namespace Tizen::Social;
using namespace Tizen::Ui;
using namespace Tizen::Ui::Controls;
static const int IDA_BUTTON_ADD_ACCOUNT_CLICKED = 101;
static const wchar_t _ACCOUNT_ADD_OUTPUT_DATA_KEY[] = L"http://tizen.org/appcontrol/data/account/id";
AddAccountForm::AddAccountForm(void)
: __reqId(INVALID_REQUEST_ID)
, __accountId(INVALID_ACCOUNT_ID)
{
}
AddAccountForm::~AddAccountForm(void)
{
}
bool
AddAccountForm::Initialize()
{
Form::Construct(IDF_FORM_ADD_ACCOUNT);
return true;
}
result
AddAccountForm::OnInitializing(void)
{
Button *pButton1 = static_cast<Button *> (GetControl(IDC_BUTTON_ADD_ACCOUNT));
if (pButton1)
{
pButton1->SetActionId(IDA_BUTTON_ADD_ACCOUNT_CLICKED);
pButton1->AddActionEventListener(*this);
}
return E_SUCCESS;
}
result
AddAccountForm::OnTerminating(void)
{
return E_SUCCESS;
}
void
AddAccountForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
{
switch (actionId)
{
case IDA_BUTTON_ADD_ACCOUNT_CLICKED:
{
AccountManager* pAccountManager = AccountManager::GetInstance();
AppAssert(pAccountManager);
Account account(L"AccountExample");
account.SetExtendedData(L"ContactSync", L"enable");
account.SetExtendedData(L"CalendarSync", L"enable");
result r = pAccountManager->AddAccount(account);
if (IsFailed(r))
{
if (r == E_USER_NOT_CONSENTED)
{
MessageBox messageBox;
messageBox.Construct(L"Error", L"The account privacy should be enabled.", MSGBOX_STYLE_OK);
int modalResult;
messageBox.ShowAndWait(modalResult);
}
AppControlProviderManager::GetInstance()->SendAppControlResult(__reqId, APP_CTRL_RESULT_FAILED, null);
}
else
{
HashMap* pResultData = new (std::nothrow) HashMap();
pResultData->Construct();
String tempVal(L"");
tempVal.Append(__accountId);
String* pKey = new (std::nothrow) String(_ACCOUNT_ADD_OUTPUT_DATA_KEY);
String* pVal = new (std::nothrow) String(tempVal);
pResultData->Add(*pKey, *pVal);
AppControlProviderManager::GetInstance()->SendAppControlResult(__reqId, APP_CTRL_RESULT_SUCCEEDED, pResultData);
}
// Terminate the application
UiApp* pApp = UiApp::GetInstance();
AppAssert(pApp);
pApp->Terminate();
break;
}
default:
break;
}
}
void
AddAccountForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
{
AppLog("OnSceneActivatedN");
if (pArgs != null)
{
Integer* pReqId = static_cast<Integer*> (pArgs->GetAt(0));
__reqId = pReqId->ToInt();
pArgs->RemoveAll(true);
delete pArgs;
}
}
void
AddAccountForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
const Tizen::Ui::Scenes::SceneId& nextSceneId)
{
AppLog("OnSceneDeactivated");
}
|