diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmServer.cxx | 20 | ||||
-rw-r--r-- | Source/cmServer.h | 2 | ||||
-rw-r--r-- | Source/cmServerProtocol.h | 8 |
3 files changed, 25 insertions, 5 deletions
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index c0575af..8fb452b 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -134,8 +134,13 @@ void cmServer::PopOne() return; } - this->WriteResponse(this->Protocol ? this->Protocol->Process(request) - : this->SetProtocolVersion(request)); + if (this->Protocol) { + this->Protocol->CMakeInstance()->SetProgressCallback( + reportProgress, const_cast<cmServerRequest*>(&request)); + this->WriteResponse(this->Protocol->Process(request)); + } else { + this->WriteResponse(this->SetProtocolVersion(request)); + } } void cmServer::handleData(const std::string& data) @@ -210,6 +215,17 @@ void cmServer::PrintHello() const this->WriteJsonObject(hello); } +void cmServer::reportProgress(const char* msg, float progress, void* data) +{ + const cmServerRequest* request = static_cast<const cmServerRequest*>(data); + assert(request); + if (progress < 0.0 || progress > 1.0) { + request->ReportProgress(0, 0, 0, msg); + } else { + request->ReportProgress(0, static_cast<int>(progress * 1000), 1000, msg); + } +} + cmServerResponse cmServer::SetProtocolVersion(const cmServerRequest& request) { if (request.Type != "handshake") diff --git a/Source/cmServer.h b/Source/cmServer.h index 4a9c3f5..031ab64 100644 --- a/Source/cmServer.h +++ b/Source/cmServer.h @@ -43,6 +43,8 @@ public: private: void RegisterProtocol(cmServerProtocol* protocol); + static void reportProgress(const char* msg, float progress, void* data); + // Handle requests: cmServerResponse SetProtocolVersion(const cmServerRequest& request); diff --git a/Source/cmServerProtocol.h b/Source/cmServerProtocol.h index e95c2f1..03d4300 100644 --- a/Source/cmServerProtocol.h +++ b/Source/cmServerProtocol.h @@ -57,9 +57,6 @@ private: class cmServerRequest { public: - void ReportProgress(int min, int current, int max, - const std::string& message) const; - cmServerResponse Reply(const Json::Value& data) const; cmServerResponse ReportError(const std::string& message) const; @@ -71,6 +68,9 @@ private: cmServerRequest(cmServer* server, const std::string& t, const std::string& c, const Json::Value& d); + void ReportProgress(int min, int current, int max, + const std::string& message) const; + cmServer* m_Server; friend class cmServer; @@ -95,6 +95,8 @@ protected: private: std::unique_ptr<cmake> m_CMakeInstance; + + friend class cmServer; }; class cmServerProtocol1_0 : public cmServerProtocol |