2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file ClSharePopup.cpp
19 * @brief This is the implementation file for the SharePopup class.
24 #include <FGraphics.h>
26 #include "ClCalendarApp.h"
27 #include "ClSharePopup.h"
28 #include "ClResourceManager.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Io;
36 using namespace Tizen::Social;
37 using namespace Tizen::Ui;
38 using namespace Tizen::Ui::Controls;
46 static const int IDA_SHARE_POPUP_CLOSE = 63010;
47 static const int IDA_SHARE_ITEM = 63020;
49 static const int H_ITEM = 110;
50 static const int W_ITEM_MARGIN = 45;
52 SharePopup::SharePopup(void)
54 , __eventId(INVALID_RECORD_ID)
58 SharePopup::~SharePopup(void)
63 SharePopup::Initialize(void)
65 return Construct(L"IDL_SHARE_POPUP");
69 SharePopup::RequestShare(RecordId eventId)
77 SharePopup::OnInitializing(void)
79 __pListView = dynamic_cast<ListView*>(GetControl(L"IDC_LISTVIEW_SHARE"));
80 AppAssertf(__pListView != null, "[E_FAILURE] Unable to get listview.");
81 __pListView->SetItemProvider(*this);
82 __pListView->AddListViewItemEventListener(*this);
83 // TBD : Below code will be deleted.(Tizen SDK 2.0 has a defect on first drawing.)
84 __pListView->UpdateList();
86 Button* pButtonCancel = dynamic_cast<Button*>(GetControl(L"IDC_BUTTON_CLOSE"));
87 AppAssertf(pButtonCancel != null, "[E_FAILURE] Unable to get button.");
88 pButtonCancel->SetActionId(IDA_SHARE_POPUP_CLOSE);
89 pButtonCancel->AddActionEventListener(*this);
95 SharePopup::OnTerminating(void)
101 SharePopup::GetItemCount(void)
107 SharePopup::CreateItem(int index, int itemWidth)
109 CustomItem* pItem = new (std::nothrow) CustomItem();
110 pItem->Construct(Dimension(itemWidth, H_ITEM), LIST_ANNEX_STYLE_NORMAL);
115 pItem->AddElement(Rectangle(W_ITEM_MARGIN, 0, itemWidth - (W_ITEM_MARGIN << 1), H_ITEM),
116 IDA_SHARE_ITEM, ResourceManager::GetString(IDS_CLD_OPT_SENDVIA_EMAIL));
119 pItem->AddElement(Rectangle(W_ITEM_MARGIN, 0, itemWidth - (W_ITEM_MARGIN << 1), H_ITEM),
120 IDA_SHARE_ITEM, ResourceManager::GetString(IDS_CLD_OPT_MESSAGE_SEND_VIA));
128 SharePopup::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
134 SharePopup::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
136 if (status == LIST_ITEM_STATUS_SELECTED)
143 operationId = L"http://tizen.org/appcontrol/operation/compose";
147 operationId = L"http://tizen.org/appcontrol/operation/compose";
151 AppLogDebug("[E_FAILURE] Invalid condition.");
155 Calendarbook calendarbook;
156 calendarbook.Construct();
157 CalEvent* pEvent = calendarbook.GetEventN(__eventId);
158 TryReturnVoid(pEvent != null, "[E_FAILURE] Unable to get event.(ID=%d)", __eventId);
160 HashMap* pArgs = new (std::nothrow) HashMap(SingleObjectDeleter);
163 String* pPath = new (std::nothrow) String(CalendarApp::GetExportVcsFilePath());
164 LinkedList events(SingleObjectDeleter);
165 events.Add(calendarbook.GetEventN(__eventId));
166 calendarbook.ExportEventsToVcalendar(events, *pPath);
168 ArrayList* pPaths = new (std::nothrow) ArrayList(SingleObjectDeleter);
169 pPaths->Construct(1);
171 pArgs->Add(new (std::nothrow) String(KEY_DATA_PATH), pPaths);
173 AppControl::FindAndStart(operationId, &uri, null, null, pArgs, null);
181 SharePopup::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
186 SharePopup::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus status)
191 SharePopup::OnListViewItemLongPressed(ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
196 SharePopup::OnListViewItemReordered(ListView& listView, int indexFrom, int indexTo)
201 SharePopup::OnActionPerformed(const Control& source, int actionId)
203 if (actionId == IDA_SHARE_POPUP_CLOSE)