void MyRadioProvider::addFavoriteStation( const vehicle::RadioStation& radioStation, std::function<void(const bool& returnValue)> onSuccess, std::function<void(const joynr::vehicle::Radio::AddFavoriteStationErrorEnum::Enum&)> onError) { std::lock_guard<std::mutex> locker(mutex); if (radioStation.getName().empty()) { throw joynr::exceptions::ProviderRuntimeException(MyRadioHelper::MISSING_NAME()); } bool duplicateFound = false; for (joynr::vehicle::RadioStation station : stationsList) { if (!duplicateFound && station.getName() == radioStation.getName()) { duplicateFound = true; onError(joynr::vehicle::Radio::AddFavoriteStationErrorEnum::DUPLICATE_RADIOSTATION); break; } } if (!duplicateFound) { MyRadioHelper::prettyLog(logger(), "addFavoriteStation(" + radioStation.toString() + ")"); stationsList.push_back(radioStation); onSuccess(true); } }
void MyRadioProvider::addFavouriteStation(const vehicle::RadioStation& radioStation, std::function<void(const bool& returnValue)> onSuccess) { QMutexLocker locker(&mutex); MyRadioHelper::prettyLog(logger, QString("addFavouriteStation(%1)") .arg(QString::fromStdString(radioStation.toString()))); stationsList.append(radioStation); onSuccess(true); }