bool onSinglePersonSelected(SelectResults personResults);
bool onMultiPersonSelected(SelectResults personResults);
bool onSelected(SelectResults results);
+ bool onSelectedForVcard(SelectResults results);
static int getSingleResultId(int personId, ResultType resultType);
static int getFilterType(ResultType resultType);
ResultMyProfile = Model::ObjectTypeMyProfile, /**< My Profile ID is the result */
ResultPerson = Model::ObjectTypeContact, /**< Person ID is the result */
ResultNumber = Model::ObjectTypeNumber, /**< Number ID is the result */
- ResultEmail = Model::ObjectTypeEmail /**< Email ID is the result */
+ ResultEmail = Model::ObjectTypeEmail, /**< Email ID is the result */
+ ResultVcard
};
}
#include "Contacts/Common/Chooser.h"
#include "Contacts/Details/DetailsView.h"
#include "Contacts/List/ListView.h"
+#include "Contacts/Settings/ExportController.h"
#include "Contacts/Utils.h"
#include "Utils/Logger.h"
view->setSelectCallback(std::bind(&Chooser::onMultiPersonSelected, this, _1));
}
break;
+ case ResultVcard:
+ view->setSelectCallback(std::bind(&Chooser::onSelectedForVcard, this, _1));
+ break;
default:
break;
}
return false;
}
+bool Chooser::onSelectedForVcard(SelectResults results)
+{
+ using namespace Settings;
+
+ std::vector<int> ids;
+ ids.reserve(results.count());
+ for (auto &&result : results) {
+ ids.push_back(result.value.id);
+ }
+
+ auto exporter = new ExportController(getEvasObject(), "IDS_PB_HEADER_EXPORT_CONTACTS_ABB",
+ std::move(ids), StorageInternalOther);
+ exporter->setFinishCallback([this, exporter] {
+ SelectResult result = { ResultVcard, (void *) exporter->getVcardPath().c_str() };
+ if (!m_OnSelected || m_OnSelected({ &result, 1 })) {
+ getPage()->close();
+ }
+ });
+ exporter->run();
+
+ return false;
+}
+
int Chooser::getSingleResultId(int personId, ResultType resultType)
{
int resultId = 0;
const char *ListView::getPageTitle() const
{
- if (getSelectMode() == SelectNone) {
- return "IDS_PB_TAB_CONTACTS";
+ switch (getSelectMode()) {
+ case SelectNone:
+ return "IDS_PB_TAB_CONTACTS";
+ case SelectSingle:
+ return "IDS_PB_HEADER_SELECT_CONTACT_ABB2";
+ default:
+ return SelectView::getPageTitle();
}
-
- return SelectView::getPageTitle();
}
void ListView::onSelectAllInsert(Ui::GenlistItem *item)
virtual void onRequest(Operation operation, app_control_h request) override;
bool onSelected(Contacts::SelectResults results);
+ void replyIds(Contacts::SelectResults results);
+ void replyPath(Contacts::SelectResults results);
+ void replyResults(const char **results, size_t count);
+
static Contacts::SelectMode getSelectMode(app_control_h request);
static Contacts::ResultType getResultType(app_control_h request);
static const char *getResultTypeString(Contacts::ResultType resultType);
bool OperationPickController::onSelected(SelectResults results)
{
+ if (m_ResultType == ResultVcard) {
+ replyPath(results);
+ } else {
+ replyIds(results);
+ }
+
+ return true;
+}
+
+void OperationPickController::replyIds(Contacts::SelectResults results)
+{
size_t count = results.count();
std::vector<char[ID_BUFFER_SIZE]> buffers(count);
std::vector<const char *> ids(count);
ids[i] = buffers[i];
}
+ replyResults(ids.data(), ids.size());
+}
+
+void OperationPickController::replyPath(Contacts::SelectResults results)
+{
+ auto &result = *results.begin();
+ replyResults((const char **) &result.value.data, 1);
+}
+
+void OperationPickController::replyResults(const char **results, size_t count)
+{
app_control_h reply = nullptr;
app_control_create(&reply);
app_control_add_extra_data(reply, APP_CONTROL_DATA_TYPE, getResultTypeString(m_ResultType));
- app_control_add_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, ids.data(), ids.size());
+ app_control_add_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, results, count);
app_control_reply_to_launch_request(reply, getRequest(), APP_CONTROL_RESULT_SUCCEEDED);
app_control_destroy(reply);
-
- return true;
}
SelectMode OperationPickController::getSelectMode(app_control_h request)
return ResultNumber;
} else if (strcmp(resultType, APP_CONTROL_RESULT_EMAIL) == 0) {
return ResultEmail;
+ } else if (strcmp(resultType, APP_CONTROL_RESULT_VCARD) == 0) {
+ return ResultVcard;
}
free(resultType);
return APP_CONTROL_RESULT_PHONE;
case ResultEmail:
return APP_CONTROL_RESULT_EMAIL;
+ case ResultVcard:
+ return APP_CONTROL_RESULT_VCARD;
}
return APP_CONTROL_RESULT_ID;