21#ifndef KICAD_API_SERVER_H
22#define KICAD_API_SERVER_H
31#include <wx/filename.h>
34#include <api/common/types/base_types.pb.h>
45 wxCommandEvent( aEventType )
92 std::string SocketPath()
const;
99 static wxFileName StandardSocketPath();
104 static std::string StandardSocketUrl();
111 void NotifyNetSettingsChanged();
117 void NotifyDocumentRenamed( kiapi::common::types::DocumentType aType,
const wxString& aOldPath,
118 const wxString& aNewPath );
124 const wxString&,
const wxString& )> aListener )
138 void onApiRequest( std::string* aRequest );
144 void handleApiEvent( wxCommandEvent& aEvent );
146 void handleApiRequestString( std::string& aRequestString );
148 void log(
const std::string& aOutput );
158 std::function<void( kiapi::common::types::DocumentType,
const wxString&,
const wxString& )>
m_renameListener;
wxDECLARE_EVENT(API_REQUEST_EVENT, KICAD_API_REQUEST_EVENT)
Event carrying an incoming API request from the listener thread to the main thread.
KICAD_API_REQUEST_EVENT(wxEventType aEventType=wxEVT_NULL)
wxEvent * Clone() const override
wxEventCategory GetEventCategory() const override
std::function< void(kiapi::common::types::DocumentType, const wxString &, const wxString &)> m_renameListener
static wxString s_logFileName
void RegisterHandler(API_HANDLER *aHandler)
Adds a new request handler to the server.
wxString m_socketPathOverride
std::set< API_HANDLER * > m_handlers
std::atomic< bool > m_readyToReply
const std::string & Token() const
void SetReadyToReply(bool aReady=true)
void SetRenameListener(std::function< void(kiapi::common::types::DocumentType, const wxString &, const wxString &)> aListener)
Installs a callback to be invoked by NotifyDocumentRenamed.
void SetSocketPath(const wxString &aSocketPath)
KICAD_API_SERVER(bool aAutoStart=true)
void DeregisterHandler(API_HANDLER *aHandler)
std::unique_ptr< KINNG_REQUEST_SERVER > m_server