/* * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * 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. * */ #include #include #include #include #include #include "WView.h" #include "WNaviframe.h" #include "WPopup.h" #include "WToastPopup.h" #include "ContactsDebug.h" #include "CtType.h" #include "CtListDataPerson.h" #include "CtCommon.h" #include "CtListView.h" #include "CtListModelVcard.h" #include "CtListLoadingPopup.h" #include "CtListUgVcardViewController.h" #include "CtImporter.h" #include "CtProgressBarPopup.h" CtListUgVcardViewController::CtListUgVcardViewController(const std::string& vcardPath, CtListView *listView, CtListModelVcard* listData) : __vcardPath(vcardPath) , __listView(listView) , __listModel(listData) , __popup(NULL) , __showLoadingPopup(false) { __getVcardPathFromUri(); __listModel->setOnLoadCompleteCb([this](int count, int total, bool showToast){ if (showToast) { ecore_job_add([](void* data){ WENTER(); CtListUgVcardViewController* self = static_cast(data); WToastPopup* popup = new WToastPopup("Only first 100 contacts displayed."); self->__listView->attachPopup(popup); WLEAVE(); }, this); } }); } CtListUgVcardViewController::~CtListUgVcardViewController() { WHIT(); } void CtListUgVcardViewController::onSelectItem(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) { WHIT(); elm_genlist_item_selected_set(selectedItem, EINA_FALSE); } void CtListUgVcardViewController::onSelectDone(void *data, Evas_Object *obj, void *event_info) { WHIT(); const int deviceAbId = 0; std::vector vcards; vcards.push_back(__vcardPath); CtImporter *contactImporter = new CtImporter(deviceAbId, std::move(vcards), __listModel->getContactsCount(LIST_QUERY_DEFAULT)); __listView->attachPopup(contactImporter->getProgressPopup()); __listView->attachHiddenPopup(contactImporter->getCancelPopup()); contactImporter->run(); } void CtListUgVcardViewController::onSelectCancel(void *data, Evas_Object *obj, void *event_info) { WHIT(); __listView->popOut(); } void CtListUgVcardViewController::onSelectBack(void *data, Evas_Object *obj, void *event_info) { WHIT(); } void CtListUgVcardViewController::onSwipeLeftItem(void *data, Evas_Object *obj, void *event_info) { WHIT(); } void CtListUgVcardViewController::onSwipeRightItem(void *data, Evas_Object *obj, void *event_info) { WHIT(); } void CtListUgVcardViewController::onSelectCheckAll(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) { WHIT(); } void CtListUgVcardViewController::moreManageFavoritesItemOperation() { WHIT(); } void CtListUgVcardViewController::onImportFinished(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) { WHIT(); CtListUgVcardViewController* c = static_cast(user_data); c->__listView->popOut(); } void CtListUgVcardViewController::__getVcardPathFromUri(void) { std::string prefix("file://"); size_t position = 0; if ((position = __vcardPath.find(prefix)) != std::string::npos) { __vcardPath.erase(position, prefix.length()); } WDEBUG("vcard path is %s", __vcardPath.c_str()); }