TizenRefApp-7121 Implement support of several data types in the Chooser 55/88455/4
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Tue, 20 Sep 2016 10:51:06 +0000 (13:51 +0300)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Wed, 21 Sep 2016 10:55:15 +0000 (03:55 -0700)
Change-Id: I57003ba2dfce132f8c8a628b861dac6d57b73398
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
contacts-app/inc/OperationPickController.h
contacts-app/src/OperationPickController.cpp
lib-contacts/inc/Contacts/Chooser/ChooserView.h
lib-contacts/inc/Contacts/Common/ContactSelectTypes.h [deleted file]
lib-contacts/src/Contacts/Chooser/ChooserView.cpp
lib-contacts/src/Contacts/List/PersonItem.cpp

index e1149c0..f5b35fa 100644 (file)
 #define OPERATION_PICK_CONTROLLER_H
 
 #include "OperationController.h"
-#include "Common/Actions.h"
-#include "Contacts/Common/ContactSelectTypes.h"
+#include "Contacts/Chooser/ChooserView.h"
 
-#include <Evas.h>
-
-namespace Ui
-{
-       class Navigator;
-}
+using namespace Contacts;
 
 class OperationPickController : public OperationController
 {
@@ -40,15 +34,15 @@ private:
 
        void replyIds(Ux::SelectResults results);
        void replyPath(Ux::SelectResults results);
-       void replyResults(const char *resultType, const char **results, size_t count);
+       void replyResults(const char **types, const char **data, size_t count);
 
        static Ux::SelectMode getSelectMode(app_control_h request);
-       static Contacts::ResultType getResultType(app_control_h request);
-       static const char *getResultTypeString(Contacts::ResultType resultType);
-       static const char *getActionTypeString(Common::ActionType actionType);
+       static Chooser::ResultType getResultType(const char *dataType);
+       static int getFilterType(const char *dataType);
+       static const char *getDataTypeString(Chooser::ResultType resultType, int objectType);
 
-       Ux::SelectMode m_SelectMode;
-       Contacts::ResultType m_ResultType;
+       Chooser::ResultType m_ResultType;
+       bool m_IsMultiType;
 };
 
 #endif /* _OPERATION_PICK_CONTROLLER_H_ */
index 0f15276..654edd1 100644 (file)
 #include "OperationPickController.h"
 
 #include "MainApp.h"
-#include "Contacts/Chooser/ChooserView.h"
-
 #include "App/AppControlRequest.h"
-#include "Ui/Navigator.h"
+#include "Common/Actions.h"
 
-#define ID_BUFFER_SIZE 16
+#define BUFFER_SIZE 16
 
 using namespace Common;
 using namespace Contacts;
@@ -33,17 +31,37 @@ using namespace std::placeholders;
 
 OperationPickController::OperationPickController()
        : OperationController(OperationPick),
-         m_SelectMode(SelectSingle), m_ResultType(ResultPerson)
+         m_ResultType(ResultPersonId), m_IsMultiType(true)
 {
 }
 
 void OperationPickController::onRequest(Operation operation, app_control_h request)
 {
-       m_SelectMode = getSelectMode(request);
-       m_ResultType = getResultType(request);
+       char *dataType = nullptr;
+       char **dataTypes = &dataType;
+       int count = 1;
+
+       int err = app_control_get_extra_data_array(request, APP_CONTROL_DATA_TYPE, &dataTypes, &count);
+       if (err != APP_CONTROL_ERROR_NONE) {
+               app_control_get_extra_data(request, APP_CONTROL_DATA_TYPE, &dataType);
+               m_IsMultiType = false;
+       }
+
+       Ux::SelectMode selectMode = getSelectMode(request);
+       m_ResultType = getResultType(dataTypes[0]);
+
+       int filterType = 0;
+       for (int i = 0; i < count; ++i) {
+               filterType |= getFilterType(dataTypes[i]);
+               free(dataTypes[i]);
+       }
+
+       if (m_IsMultiType) {
+               free(dataTypes);
+       }
 
        int limit = App::getIntExtraData(request, APP_CONTROL_DATA_TOTAL_COUNT);
-       ChooserView *chooser = new ChooserView(m_SelectMode, m_ResultType, limit);
+       ChooserView *chooser = new ChooserView(selectMode, m_ResultType, filterType, limit);
        chooser->setSelectCallback(std::bind(&OperationPickController::onSelected, this, _1));
        getNavigator()->navigateTo(chooser);
 }
@@ -62,33 +80,36 @@ bool OperationPickController::onSelected(SelectResults results)
 void OperationPickController::replyIds(SelectResults results)
 {
        size_t count = results.size();
-       char **ids = App::createExtraDataArray(ID_BUFFER_SIZE, count);
+       char **types = App::createExtraDataArray(BUFFER_SIZE, count * 2);
+       char **ids = types + count;
 
        for (size_t i = 0; i < count; ++i) {
-               snprintf(ids[i], ID_BUFFER_SIZE, "%d", results[i].value.id);
+               snprintf(types[i], BUFFER_SIZE, "%s", getDataTypeString(m_ResultType, results[i].type));
+               snprintf(ids[i], BUFFER_SIZE, "%d", results[i].value.id);
        }
 
-       const char *type = (m_ResultType == ResultAction)
-                       ? getActionTypeString(ActionType(results.begin()->type))
-                       : getResultTypeString(m_ResultType);
-       replyResults(type, (const char **) ids, count);
-       free(ids);
+       replyResults((const char **) types, (const char **) ids, count);
+       free(types);
 }
 
 void OperationPickController::replyPath(SelectResults results)
 {
-       const char *type = getResultTypeString(m_ResultType);
+       const char *type = getDataTypeString(m_ResultType, results.begin()->type);
        const char *result = (const char *) results.front().value.data;
-       replyResults(type, &result, 1);
+       replyResults(&type, &result, 1);
 }
 
-void OperationPickController::replyResults(const char *resultType, const char **results, size_t count)
+void OperationPickController::replyResults(const char **types, const char **data, size_t count)
 {
        app_control_h reply = nullptr;
        app_control_create(&reply);
 
-       app_control_add_extra_data(reply, APP_CONTROL_DATA_TYPE, resultType);
-       app_control_add_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, results, count);
+       if (m_IsMultiType) {
+               app_control_add_extra_data_array(reply, APP_CONTROL_DATA_TYPE, types, count);
+       } else {
+               app_control_add_extra_data(reply, APP_CONTROL_DATA_TYPE, types[0]);
+       }
+       app_control_add_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, data, count);
 
        app_control_reply_to_launch_request(reply, getRequest(), APP_CONTROL_RESULT_SUCCEEDED);
        app_control_destroy(reply);
@@ -112,59 +133,68 @@ SelectMode OperationPickController::getSelectMode(app_control_h request)
        return SelectSingle;
 }
 
-ResultType OperationPickController::getResultType(app_control_h request)
+ResultType OperationPickController::getResultType(const char *dataType)
 {
-       char *resultType = nullptr;
-       app_control_get_extra_data(request, APP_CONTROL_DATA_TYPE, &resultType);
-
-       if (resultType) {
-               if (strcmp(resultType, APP_CONTROL_RESULT_ID) == 0) {
-                       return ResultPerson;
-               } else if (strcmp(resultType, APP_CONTROL_RESULT_PHONE) == 0) {
-                       return ResultNumber;
-               } else if (strcmp(resultType, APP_CONTROL_RESULT_EMAIL) == 0) {
-                       return ResultEmail;
-               } else if (strcmp(resultType, APP_CONTROL_RESULT_VCARD) == 0) {
+       if (dataType) {
+               if (strcmp(dataType, APP_CONTROL_RESULT_ID) == 0) {
+                       return ResultPersonId;
+               } else if (strcmp(dataType, APP_CONTROL_RESULT_PHONE) == 0) {
+                       return ResultDataId;
+               } else if (strcmp(dataType, APP_CONTROL_RESULT_EMAIL) == 0) {
+                       return ResultDataId;
+               } else if (strcmp(dataType, APP_CONTROL_RESULT_VCARD) == 0) {
                        return ResultVcard;
-               } else if (strcmp(resultType, APP_CONTROL_RESULT_ACTION) == 0) {
+               } else if (strcmp(dataType, APP_CONTROL_RESULT_ACTION) == 0) {
                        return ResultAction;
                }
+       }
+
+       return ResultPersonId;
+}
 
-               free(resultType);
+int OperationPickController::getFilterType(const char *dataType)
+{
+       if (dataType) {
+               if (strcmp(dataType, APP_CONTROL_RESULT_ID) == 0) {
+                       return FilterNone;
+               } else if (strcmp(dataType, APP_CONTROL_RESULT_PHONE) == 0) {
+                       return FilterNumber;
+               } else if (strcmp(dataType, APP_CONTROL_RESULT_EMAIL) == 0) {
+                       return FilterEmail;
+               } else if (strcmp(dataType, APP_CONTROL_RESULT_VCARD) == 0) {
+                       return FilterNone;
+               } else if (strcmp(dataType, APP_CONTROL_RESULT_ACTION) == 0) {
+                       return FilterNumber | FilterEmail;
+               }
        }
 
-       return ResultPerson;
+       return FilterNone;
 }
 
-const char *OperationPickController::getResultTypeString(ResultType resultType)
+const char *OperationPickController::getDataTypeString(ResultType resultType, int objectType)
 {
        switch (resultType) {
-               case ResultMyProfile:
-               case ResultPerson:
+               case ResultPersonId:
                        return APP_CONTROL_RESULT_ID;
-               case ResultNumber:
-                       return APP_CONTROL_RESULT_PHONE;
-               case ResultEmail:
-                       return APP_CONTROL_RESULT_EMAIL;
+               case ResultDataId:
+                       if (objectType == ObjectTypeNumber) {
+                               return APP_CONTROL_RESULT_PHONE;
+                       } else if (objectType == ObjectTypeEmail) {
+                               return APP_CONTROL_RESULT_EMAIL;
+                       }
+                       break;
                case ResultVcard:
                        return APP_CONTROL_RESULT_VCARD;
                case ResultAction:
-                       return APP_CONTROL_RESULT_ACTION;
-               default:
-                       return APP_CONTROL_RESULT_ID;
+                       if (objectType == ActionCall) {
+                               return APP_CONTROL_RESULT_CALL;
+                       } else if (objectType == ActionMessage) {
+                               return APP_CONTROL_RESULT_MESSAGE;
+                       } else if (objectType == ActionEmail) {
+                               return APP_CONTROL_RESULT_EMAIL;
+                       }
+                       break;
        }
-}
 
-const char *OperationPickController::getActionTypeString(ActionType actionType)
-{
-       switch (actionType) {
-               case ActionCall:
-                       return APP_CONTROL_RESULT_CALL;
-               case ActionMessage:
-                       return APP_CONTROL_RESULT_MESSAGE;
-               case ActionEmail:
-                       return APP_CONTROL_RESULT_EMAIL;
-               default:
-                       return APP_CONTROL_RESULT_CALL;
-       }
+       return nullptr;
 }
index 1054e7e..c15f7f9 100644 (file)
@@ -18,8 +18,9 @@
 #ifndef CONTACTS_CHOOSER_CHOOSER_VIEW_H
 #define CONTACTS_CHOOSER_CHOOSER_VIEW_H
 
-#include "Contacts/Common/ContactSelectTypes.h"
+#include "Common/DataTypes.h"
 #include "Ui/Naviframe.h"
+#include "Ux/SelectTypes.h"
 
 namespace Ux
 {
@@ -34,6 +35,18 @@ namespace Contacts
                class ContactsGroupsNavigator;
 
                /**
+                * @brief Determines what should be the result of selection.
+                */
+               enum ResultType
+               {
+                       ResultPersonId, /**< Person ID */
+                       ResultDataId,   /**< Person inner data ID (e.g. number record) */
+                       ResultAction,   /**< Same as #ResultDataId only with @ref ActionType
+                                            instead of @ref ObjectType */
+                       ResultVcard     /**< Person vCard file path */
+               };
+
+               /**
                 * @brief Controller and navigator for selecting different types of results
                 *        via ListView and GroupsView.
                 */
@@ -44,9 +57,10 @@ namespace Contacts
                         * @brief Create chooser
                         * @param[in]   selectMode  Selection mode
                         * @param[in]   resultType  Requested result type
+                        * @param[in]   filterType  Filter for person list and inner data
                         * @param[in]   selectLimit Selection limit for #SelectMulti mode
                         */
-                       ChooserView(Ux::SelectMode selectMode, ResultType resultType, size_t selectLimit);
+                       ChooserView(Ux::SelectMode selectMode, ResultType resultType, int filterType, size_t selectLimit);
 
                        /**
                         * @brief Set selection callback
@@ -67,20 +81,20 @@ namespace Contacts
 
                        bool onPersonChecked(Ux::SelectItem *item, bool isChecked, bool isSelectAll);
                        bool onPersonCheckedForData(Ux::SelectItem *item, bool isChecked, bool isSelectAll);
-                       bool onSingleResultSelected(Ux::SelectResults results, Ux::SelectItem *item);
+                       bool onDataSelected(Ux::SelectResults results, Ux::SelectItem *item);
 
                        bool onSelectedForData(Ux::SelectResults results);
-                       bool onSelectedForAction(Ux::SelectResults results);
                        bool onSelectedForVcard(Ux::SelectResults results);
                        bool onSelected(Ux::SelectResults results);
 
-                       bool selectSingleResult(Ux::SelectResult person, bool useDefault,
+                       bool selectData(Ux::SelectResults results, bool useDefault,
+                                       Ux::SelectCallback callback);
+                       bool selectAction(Ux::SelectResults results, bool useDefault,
                                        Ux::SelectCallback callback);
-                       Ux::SelectResult getSingleResult(int personId);
+                       Ux::SelectResult getSingleData(int personId);
 
-                       static int getResultCount(int personId, ResultType resultType, int *resultId);
-                       static std::string getResultValue(Ux::SelectResult result);
-                       static int getFilterType(ResultType resultType);
+                       static int getDataCount(int personId, Common::ObjectType dataType, int *dataId);
+                       static std::string getDataValue(Ux::SelectResult data);
 
                        Ux::SelectMode m_SelectMode;
                        ResultType m_ResultType;
diff --git a/lib-contacts/inc/Contacts/Common/ContactSelectTypes.h b/lib-contacts/inc/Contacts/Common/ContactSelectTypes.h
deleted file mode 100644 (file)
index 11c5059..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2015-2016 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.
- *
- */
-
-#ifndef CONTACTS_COMMON_CONTACT_SELECT_TYPES_H
-#define CONTACTS_COMMON_CONTACT_SELECT_TYPES_H
-
-#include "Common/DataTypes.h"
-#include "Ux/SelectTypes.h"
-
-namespace Contacts
-{
-       /**
-        * @brief Determines what should be the result of selection.
-        */
-       enum ResultType
-       {
-               ResultMyProfile = Common::ObjectTypeMyProfile, /**< My Profile ID is the result */
-               ResultPerson    = Common::ObjectTypeContact,   /**< Person ID is the result */
-               ResultNumber    = Common::ObjectTypeNumber,    /**< Number ID is the result */
-               ResultEmail     = Common::ObjectTypeEmail,     /**< Email ID is the result */
-               ResultVcard,    /**< vCard file path is the result */
-               ResultAction    /**< @ref ActionType is the result*/
-       };
-}
-
-#endif /* CONTACTS_COMMON_CONTACT_SELECT_TYPES_H */
index 6cb8bb1..06e4e11 100644 (file)
@@ -51,9 +51,9 @@ using namespace Contacts::Groups::Model;
 using namespace Ux;
 using namespace std::placeholders;
 
-ChooserView::ChooserView(SelectMode selectMode, ResultType resultType, size_t selectLimit)
+ChooserView::ChooserView(SelectMode selectMode, ResultType resultType, int filterType, size_t selectLimit)
        : m_SelectMode(selectMode), m_ResultType(resultType),
-         m_FilterType(getFilterType(m_ResultType)), m_SelectLimit(selectLimit),
+         m_FilterType(filterType), m_SelectLimit(selectLimit),
          m_ContactsView(nullptr), m_GroupsView(nullptr), m_ContactsGroups(nullptr)
 {
 }
@@ -92,33 +92,34 @@ SelectView *ChooserView::createContactsView()
                return false;
        });
 
-       switch (m_ResultType) {
-               case ResultPerson:
-                       view->setSelectCallback(std::bind(&ChooserView::onSelected, this, _1));
-                       break;
-               case ResultNumber:
-               case ResultEmail:
-                       if (m_SelectMode == SelectSingle) {
+       if (m_SelectMode == SelectSingle) {
+               switch (m_ResultType) {
+                       case ResultPersonId:
+                               view->setSelectCallback(std::bind(&ChooserView::onSelected, this, _1));
+                               break;
+                       case ResultDataId:
+                       case ResultAction:
                                view->setSelectCallback(std::bind(&ChooserView::onSelectedForData, this, _1));
-                       } else {
+                               break;
+                       case ResultVcard:
+                               view->setSelectCallback(std::bind(&ChooserView::onSelectedForVcard, this, _1));
+                               break;
+               }
+       } else {
+               switch (m_ResultType) {
+                       case ResultPersonId:
                                view->setSelectCallback(std::bind(&ChooserView::onSelected, this, _1));
-                       }
-                       break;
-               case ResultVcard:
-                       view->setSelectCallback(std::bind(&ChooserView::onSelectedForVcard, this, _1));
-                       break;
-               case ResultAction:
-                       view->setSelectCallback(std::bind(&ChooserView::onSelectedForAction, this, _1));
-                       break;
-               default:
-                       break;
-       }
-
-       if (m_SelectMode == SelectMulti) {
-               if (m_ResultType == ResultPerson || m_ResultType == ResultVcard) {
-                       view->setCheckCallback(std::bind(&ChooserView::onPersonChecked, this, _1, _2, _3));
-               } else {
-                       view->setCheckCallback(std::bind(&ChooserView::onPersonCheckedForData, this, _1, _2, _3));
+                               view->setCheckCallback(std::bind(&ChooserView::onPersonChecked, this, _1, _2, _3));
+                               break;
+                       case ResultDataId:
+                       case ResultAction:
+                               view->setSelectCallback(std::bind(&ChooserView::onSelected, this, _1));
+                               view->setCheckCallback(std::bind(&ChooserView::onPersonCheckedForData, this, _1, _2, _3));
+                               break;
+                       case ResultVcard:
+                               view->setSelectCallback(std::bind(&ChooserView::onSelectedForVcard, this, _1));
+                               view->setCheckCallback(std::bind(&ChooserView::onPersonChecked, this, _1, _2, _3));
+                               break;
                }
        }
 
@@ -159,10 +160,10 @@ SelectView *ChooserView::createMembersView(int groupId)
                }
        });
 
-       if (m_ResultType == ResultPerson || m_ResultType == ResultVcard) {
-               view->setCheckCallback(std::bind(&ChooserView::onMemberChecked, this, _1, _2, _3));
-       } else {
+       if (m_ResultType == ResultDataId || m_ResultType == ResultAction) {
                view->setCheckCallback(std::bind(&ChooserView::onMemberCheckedForData, this, _1, _2, _3));
+       } else {
+               view->setCheckCallback(std::bind(&ChooserView::onMemberChecked, this, _1, _2, _3));
        }
 
        return view;
@@ -213,9 +214,9 @@ bool ChooserView::onMemberCheckedForData(SelectItem *item, bool isChecked, bool
                return true;
        }
 
-       return selectSingleResult(personItem->getSelectResult(), isSelectAll,
+       return selectData({ personItem->getSelectResult() }, isSelectAll,
                [this, item, personItem](SelectResults results) {
-                       onSingleResultSelected(std::move(results), personItem);
+                       onDataSelected(std::move(results), personItem);
                        item->setChecked(true);
                        return true;
                });
@@ -242,11 +243,11 @@ bool ChooserView::onPersonCheckedForData(SelectItem *item, bool isChecked, bool
                return true;
        }
 
-       return selectSingleResult(item->getSelectResult(), isSelectAll,
-               std::bind(&ChooserView::onSingleResultSelected, this, _1, item));
+       return selectData({ item->getSelectResult() }, isSelectAll,
+               std::bind(&ChooserView::onDataSelected, this, _1, item));
 }
 
-bool ChooserView::onSingleResultSelected(SelectResults results, SelectItem *item)
+bool ChooserView::onDataSelected(SelectResults results, SelectItem *item)
 {
        item->setCustomResult(results.front());
        item->setChecked(true);
@@ -257,31 +258,7 @@ bool ChooserView::onSingleResultSelected(SelectResults results, SelectItem *item
 
 bool ChooserView::onSelectedForData(SelectResults results)
 {
-       return selectSingleResult(results.front(), false, std::bind(&ChooserView::onSelected, this, _1));
-}
-
-bool ChooserView::onSelectedForAction(SelectResults results)
-{
-       return selectSingleResult(results.front(), false, [this](SelectResults results) {
-               SelectResult result = results.front();
-               if (result.type == ResultEmail) {
-                       result.type = ActionEmail;
-                       return onSelected({ result });
-               }
-
-               Ui::ListPopup *popup = new Ui::ListPopup();
-               popup->create(getEvasObject());
-               popup->setTitle(getResultValue(result).c_str());
-               popup->addItem("IDS_PB_OPT_VOICE_CALL", (void *) ActionCall);
-               popup->addItem("IDS_PB_OPT_MESSAGE", (void *) ActionMessage);
-               popup->setSelectCallback([this, result] (void *data) mutable {
-                       result.type = (long) data;
-                       onSelected({ result });
-               });
-               popup->show();
-
-               return false;
-       });
+       return selectData(std::move(results), false, std::bind(&ChooserView::onSelected, this, _1));
 }
 
 bool ChooserView::onSelectedForVcard(SelectResults results)
@@ -314,17 +291,31 @@ bool ChooserView::onSelected(SelectResults results)
        return true;
 }
 
-bool ChooserView::selectSingleResult(SelectResult person, bool useDefault, SelectCallback callback)
+bool ChooserView::selectData(SelectResults results, bool useDefault, SelectCallback callback)
 {
-       SelectResult result = { m_ResultType, 0 };
+       SelectResult person = results.front();
+       if (m_ResultType == ResultAction) {
+               callback = std::bind(&ChooserView::selectAction, this, _1, useDefault, std::move(callback));
+       }
+
+       SelectResult result = { 0, 0 };
        if (useDefault) {
-               contacts_person_property_e property = (m_ResultType == ResultNumber) ?
-                               CONTACTS_PERSON_PROPERTY_NUMBER : CONTACTS_PERSON_PROPERTY_EMAIL;
-               contacts_person_get_default_property(property, person.value.id, &result.value.id);
-       } else {
-               result = getSingleResult(person.value.id);
+               if (m_FilterType & FilterNumber) {
+                       result.type = ObjectTypeNumber;
+                       contacts_person_get_default_property(CONTACTS_PERSON_PROPERTY_NUMBER,
+                                       person.value.id, &result.value.id);
+               }
+               if (result.value.id == 0) {
+                       if (m_FilterType & FilterEmail) {
+                               result.type = ObjectTypeEmail;
+                               contacts_person_get_default_property(CONTACTS_PERSON_PROPERTY_EMAIL,
+                                               person.value.id, &result.value.id);
+                       }
+               }
+               return result.value.id > 0 ? callback({ result }) : false;
        }
 
+       result = getSingleData(person.value.id);
        if (result.value.id > 0) {
                return callback({ result });
        }
@@ -337,45 +328,73 @@ bool ChooserView::selectSingleResult(SelectResult person, bool useDefault, Selec
        return false;
 }
 
-SelectResult ChooserView::getSingleResult(int personId)
+bool ChooserView::selectAction(SelectResults results, bool useDefault, Ux::SelectCallback callback)
+{
+       SelectResult data = results.front();
+       if (useDefault) {
+               if (data.type == ObjectTypeNumber) {
+                       data.type = ActionCall;
+                       return callback({ data });
+               }
+       }
+       if (data.type == ObjectTypeEmail) {
+               data.type = ActionEmail;
+               return callback({ data });
+       }
+
+       Ui::ListPopup *popup = new Ui::ListPopup();
+       popup->create(getEvasObject());
+       popup->setTitle(getDataValue(data).c_str());
+       popup->addItem("IDS_PB_OPT_VOICE_CALL", (void *) ActionCall);
+       popup->addItem("IDS_PB_OPT_MESSAGE", (void *) ActionMessage);
+       popup->setSelectCallback([this, data, callback] (void *userData) mutable {
+               data.type = (long) userData;
+               callback({ data });
+       });
+       popup->show();
+
+       return false;
+}
+
+SelectResult ChooserView::getSingleData(int personId)
 {
        int count = 0;
 
        int numberId = 0;
        if (m_FilterType & FilterNumber) {
-               count += getResultCount(personId, ResultNumber, &numberId);
+               count += getDataCount(personId, ObjectTypeNumber, &numberId);
        }
 
        int emailId = 0;
        if (m_FilterType & FilterEmail) {
-               count += getResultCount(personId, ResultEmail, &emailId);
+               count += getDataCount(personId, ObjectTypeEmail, &emailId);
        }
 
        SelectResult result = { 0, 0 };
        if (count == 1) {
                if (numberId) {
-                       result = { ResultNumber, numberId };
+                       result = { ObjectTypeNumber, numberId };
                } else if (emailId) {
-                       result = { ResultEmail, emailId };
+                       result = { ObjectTypeEmail, emailId };
                }
        }
 
        return result;
 }
 
-int ChooserView::getResultCount(int personId, ResultType resultType, int *resultId)
+int ChooserView::getDataCount(int personId, ObjectType dataType, int *dataId)
 {
        const char *uri = nullptr;
        unsigned personIdProp = 0;
        unsigned resultIdProp = 0;
 
-       switch (resultType) {
-               case ResultNumber:
+       switch (dataType) {
+               case ObjectTypeNumber:
                        uri = _contacts_person_number._uri;
                        personIdProp = _contacts_person_number.person_id;
                        resultIdProp = _contacts_person_number.number_id;
                        break;
-               case ResultEmail:
+               case ObjectTypeEmail:
                        uri = _contacts_person_email._uri;
                        personIdProp = _contacts_person_email.person_id;
                        resultIdProp = _contacts_person_email.email_id;
@@ -404,7 +423,7 @@ int ChooserView::getResultCount(int personId, ResultType resultType, int *result
                contacts_record_h record = nullptr;
                contacts_list_get_current_record_p(list, &record);
 
-               contacts_record_get_int(record, resultIdProp, resultId);
+               contacts_record_get_int(record, resultIdProp, dataId);
                contacts_list_destroy(list, true);
        }
 
@@ -414,29 +433,29 @@ int ChooserView::getResultCount(int personId, ResultType resultType, int *result
        return count;
 }
 
-std::string ChooserView::getResultValue(SelectResult result)
+std::string ChooserView::getDataValue(SelectResult data)
 {
        std::string value;
 
        const char *uri = nullptr;
        int propId = 0;
-       switch (result.type) {
-               case ResultPerson:
+       switch (data.type) {
+               case ObjectTypePerson:
                        uri = _contacts_person._uri;
                        propId = _contacts_person.display_name;
                        break;
-               case ResultNumber:
+               case ObjectTypeNumber:
                        uri = _contacts_number._uri;
                        propId = _contacts_number.number;
                        break;
-               case ResultEmail:
+               case ObjectTypeEmail:
                        uri = _contacts_email._uri;
                        propId = _contacts_email.email;
                        break;
        }
 
        contacts_record_h record = nullptr;
-       contacts_db_get_record(uri, result.value.id, &record);
+       contacts_db_get_record(uri, data.value.id, &record);
 
        char *str = nullptr;
        contacts_record_get_str_p(record, propId, &str);
@@ -447,17 +466,3 @@ std::string ChooserView::getResultValue(SelectResult result)
 
        return value;
 }
-
-int ChooserView::getFilterType(ResultType resultType)
-{
-       switch (resultType) {
-               case ResultNumber:
-                       return FilterNumber;
-               case ResultEmail:
-                       return FilterEmail;
-               case ResultAction:
-                       return FilterNumber | FilterEmail;
-               default:
-                       return FilterNone;
-       }
-}
index caec59e..428ed07 100644 (file)
@@ -17,9 +17,9 @@
 
 #include "Contacts/List/PersonItem.h"
 #include "Contacts/List/Model/Person.h"
-#include "Contacts/Common/ContactSelectTypes.h"
 #include "Contacts/Details/DetailsView.h"
 
+#include "Common/DataTypes.h"
 #include "Ui/Genlist.h"
 #include "Ui/Navigator.h"
 
@@ -38,7 +38,7 @@ Person &PersonItem::getPerson() const
 
 Ux::SelectResult PersonItem::getDefaultResult() const
 {
-       return { ResultPerson, getPerson().getId() };
+       return { Common::ObjectTypePerson, getPerson().getId() };
 }
 
 void PersonItem::onSelected()