return (plugin::plugin_s *) maps_service->plugin;
}
+int __run_cmd(session::command* cmd)
+{
+ int ret = MAPS_ERROR_INVALID_PARAMETER;
+ if (cmd) {
+ if (cmd->plugin()) ret = cmd->run();
+ else delete cmd;
+ }
+ if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
+ return ret;
+}
+
/*----------------------------------------------------------------------------*/
/* */
/* Maps Service & Preference */
session::command *cmd = new (std::nothrow) session::command_geocode(maps, address, preference,
callback, user_data, request_id);
- int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
- if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
- return ret;
+ return __run_cmd(cmd);
}
EXPORT_API int maps_service_geocode_inside_area(const maps_service_h maps,
session::command *cmd = new (std::nothrow) session::command_geocode_inside_bounds(maps,
address, bounds, preference, callback, user_data, request_id);
- int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
- if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
- return ret;
+ return __run_cmd(cmd);
}
EXPORT_API int maps_service_geocode_by_structured_address(const maps_service_h maps,
session::command *cmd = new (std::nothrow) session::command_reverse_geocode(maps, latitude,
longitude, preference, callback, user_data, request_id);
- int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
- if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
- return ret;
+ return __run_cmd(cmd);
}
/*----------------------------------------------------------------------------*/
session::command *cmd = new (std::nothrow) session::command_search_place(maps, position,
distance, preference, filter, callback, user_data, request_id);
- int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
- if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
- return ret;
+ return __run_cmd(cmd);
}
EXPORT_API int maps_service_search_place_by_area(const maps_service_h maps,
session::command *cmd = new (std::nothrow) session::command_search_by_area_place(maps,
boundary, preference, filter, callback, user_data, request_id);
- int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
- if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
- return ret;
+ return __run_cmd(cmd);
}
EXPORT_API int maps_service_search_place_by_address(const maps_service_h maps,
session::command *cmd = new (std::nothrow) session::command_search_by_address_place(maps,
address, boundary, preference, filter, callback, user_data, request_id);
- int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
- if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
- return ret;
+ return __run_cmd(cmd);
}
EXPORT_API int maps_service_search_place_list(const maps_service_h maps,
session::command *cmd = new (std::nothrow) session::command_search_place_list(maps,
boundary, preference, filter, callback, user_data, request_id);
- int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
- if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
- return ret;
+ return __run_cmd(cmd);
}
EXPORT_API int maps_service_get_place_details(const maps_service_h maps,
session::command *cmd = new (std::nothrow) session::command_get_place_details(maps,
url, callback, user_data, request_id);
- int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
- if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
- return ret;
+ return __run_cmd(cmd);
}
/*----------------------------------------------------------------------------*/
session::command *cmd = new (std::nothrow) session::command_search_route(maps, preference,
origin, destination, callback, user_data, request_id);
- int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
- if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
- return ret;
+ return __run_cmd(cmd);
}
EXPORT_API int maps_service_search_route_waypoints(const maps_service_h maps,
session::command *cmd = new (std::nothrow) session::command_search_route_waypoints(maps,
preference, waypoint_list, waypoint_num, callback, user_data, request_id);
- int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
- if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
- return ret;
+ return __run_cmd(cmd);
}
/*----------------------------------------------------------------------------*/
session::command *cmd = new (std::nothrow) session::command_cancel_request(maps, request_id);
- int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
- if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
- return ret;
+ return __run_cmd(cmd);
}
/*----------------------------------------------------------------------------*/
session::command *cmd = new (std::nothrow) session::command_multi_reverse_geocode(maps,
coordinates_list, preference, callback, user_data, request_id);
- int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
- if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
- return ret;
+ return __run_cmd(cmd);
}