Add ClientOptions to be able to pass around client name and version (#365)
* ClientOptions and Qt user agent * Update CHANGELOG.md Co-authored-by: Oliver Wipfli <oliver.wipfli@leichteralsluft.ch> Co-authored-by: Oliver Wipfli <oliver.wipfli@leichteralsluft.ch>
This commit is contained in:
@@ -194,7 +194,7 @@ void NodeMap::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
||||
info.This()->SetInternalField(1, options);
|
||||
|
||||
mbgl::FileSourceManager::get()->registerFileSourceFactory(
|
||||
mbgl::FileSourceType::ResourceLoader, [](const mbgl::ResourceOptions& resourceOptions) {
|
||||
mbgl::FileSourceType::ResourceLoader, [](const mbgl::ResourceOptions& resourceOptions, const mbgl::ClientOptions& clientOptions) {
|
||||
return std::make_unique<node_mbgl::NodeFileSource>(
|
||||
reinterpret_cast<node_mbgl::NodeMap*>(resourceOptions.platformContext()));
|
||||
});
|
||||
@@ -644,7 +644,8 @@ void NodeMap::cancel() {
|
||||
.withPixelRatio(pixelRatio)
|
||||
.withMapMode(mbgl::MapMode::Static)
|
||||
.withCrossSourceCollisions(crossSourceCollisions),
|
||||
mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this)));
|
||||
mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this)),
|
||||
mbgl::ClientOptions());
|
||||
|
||||
// FIXME: Reload the style after recreating the map. We need to find
|
||||
// a better way of canceling an ongoing rendering on the core level
|
||||
@@ -1422,7 +1423,8 @@ NodeMap::NodeMap(v8::Local<v8::Object> options)
|
||||
.withPixelRatio(pixelRatio)
|
||||
.withMapMode(mbgl::MapMode::Static)
|
||||
.withCrossSourceCollisions(crossSourceCollisions),
|
||||
mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this))))
|
||||
mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this)),
|
||||
mbgl::ClientOptions()))
|
||||
, async(new uv_async_t) {
|
||||
async->data = this;
|
||||
uv_async_init(uv_default_loop(), async, [](uv_async_t* h) {
|
||||
@@ -1477,4 +1479,12 @@ mbgl::ResourceOptions NodeFileSource::getResourceOptions() {
|
||||
return this->_resourceOptions.clone();
|
||||
}
|
||||
|
||||
void NodeFileSource::setClientOptions(mbgl::ClientOptions options) {
|
||||
this->_clientOptions = std::move(options);
|
||||
}
|
||||
|
||||
mbgl::ClientOptions NodeFileSource::getClientOptions() {
|
||||
return this->_clientOptions.clone();
|
||||
}
|
||||
|
||||
} // namespace node_mbgl
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <mbgl/storage/file_source.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
#include <mbgl/util/async_request.hpp>
|
||||
#include <mbgl/util/client_options.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
|
||||
#include <exception>
|
||||
@@ -103,8 +104,11 @@ struct NodeFileSource : public mbgl::FileSource {
|
||||
bool canRequest(const mbgl::Resource&) const override;
|
||||
void setResourceOptions(mbgl::ResourceOptions) override;
|
||||
mbgl::ResourceOptions getResourceOptions() override;
|
||||
void setClientOptions(mbgl::ClientOptions) override;
|
||||
mbgl::ClientOptions getClientOptions() override;
|
||||
NodeMap* nodeMap;
|
||||
mbgl::ResourceOptions _resourceOptions;
|
||||
mbgl::ClientOptions _clientOptions;
|
||||
};
|
||||
|
||||
} // namespace node_mbgl
|
||||
|
||||
Reference in New Issue
Block a user