|
KiCad PCB EDA Suite
|
#include <api_server.h>
Public Member Functions | |
| KICAD_API_SERVER (bool aAutoStart=true) | |
| ~KICAD_API_SERVER () | |
| void | Start () |
| void | Stop () |
| bool | Running () const |
| void | RegisterHandler (API_HANDLER *aHandler) |
| Adds a new request handler to the server. | |
| void | DeregisterHandler (API_HANDLER *aHandler) |
| void | SetReadyToReply (bool aReady=true) |
| void | SetSocketPath (const wxString &aSocketPath) |
| std::string | SocketPath () const |
| const std::string & | Token () const |
Static Public Member Functions | |
| static wxFileName | StandardSocketPath () |
| Return the default API socket path (without the ipc:// scheme). | |
| static std::string | StandardSocketUrl () |
| Return the default API socket URL (including the ipc:// scheme). | |
Private Member Functions | |
| void | onApiRequest (std::string *aRequest) |
| Callback that executes on the server thread and generates an event that will be handled by the wxWidgets event loop to process an incoming request. | |
| void | handleApiEvent (wxCommandEvent &aEvent) |
| Event handler that receives the event on the main thread sent by onApiRequest. | |
| void | handleApiRequestString (std::string &aRequestString) |
| void | log (const std::string &aOutput) |
Private Attributes | |
| std::unique_ptr< KINNG_REQUEST_SERVER > | m_server |
| std::set< API_HANDLER * > | m_handlers |
| std::string | m_token |
| std::atomic< bool > | m_readyToReply |
| wxString | m_socketPathOverride |
| wxFileName | m_logFilePath |
Static Private Attributes | |
| static wxString | s_logFileName = "api.log" |
Definition at line 42 of file api_server.h.
| KICAD_API_SERVER::KICAD_API_SERVER | ( | bool | aAutoStart = true | ) |
Definition at line 53 of file api_server.cpp.
References m_readyToReply, m_token, Pgm(), and Start().
| KICAD_API_SERVER::~KICAD_API_SERVER | ( | ) |
Definition at line 71 of file api_server.cpp.
References Stop().
| void KICAD_API_SERVER::DeregisterHandler | ( | API_HANDLER * | aHandler | ) |
Definition at line 209 of file api_server.cpp.
References m_handlers.
Referenced by PCB::IFACE::closeCurrentDocument(), SCH::IFACE::closeCurrentDocument(), FOOTPRINT_EDIT_FRAME::doCloseWindow(), PCB_EDIT_FRAME::doCloseWindow(), SCH_EDIT_FRAME::doCloseWindow(), PCB::IFACE::OnKifaceEnd(), and SCH::IFACE::OnKifaceEnd().
|
private |
Event handler that receives the event on the main thread sent by onApiRequest.
| aEvent | will contain a pointer to an incoming API request string in the client data |
Definition at line 243 of file api_server.cpp.
References handleApiRequestString().
|
private |
Definition at line 250 of file api_server.cpp.
References ADVANCED_CFG::GetCfg(), log(), m_handlers, m_server, m_token, and result.
Referenced by handleApiEvent().
|
private |
Definition at line 331 of file api_server.cpp.
References m_logFilePath, and TO_UTF8.
Referenced by handleApiRequestString(), onApiRequest(), and Start().
|
private |
Callback that executes on the server thread and generates an event that will be handled by the wxWidgets event loop to process an incoming request.
Temporarily takes ownership of the request pointer so that it can be passed through the event system.
| aRequest | is a pointer to a string containing bytes that came in over the wire |
Definition at line 221 of file api_server.cpp.
References log(), m_readyToReply, and m_server.
Referenced by Start().
| void KICAD_API_SERVER::RegisterHandler | ( | API_HANDLER * | aHandler | ) |
Adds a new request handler to the server.
Each handler maintains its own list of API messages that it knows how to handle, and the server will pass every incoming message to all handlers in succession until one of them handles it.
The caller is responsible for the lifetime of the handler and must call DeregisterHandler before the pointer is freed.
| aHandler | is a pointer (non-owned) to API_HANDLER |
Definition at line 202 of file api_server.cpp.
References m_handlers.
Referenced by EVT_UPDATE_UI_RANGE(), FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME(), SCH::IFACE::HandleApiOpenDocument(), PCB::IFACE::handleCreatePcb(), SCH::IFACE::handleCreateSchematic(), PCB::IFACE::handleOpenFootprint(), PCB::IFACE::handleOpenPcb(), PCB::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), PCB::IFACE::RegisterLibraryHandlers(), SCH::IFACE::RegisterLibraryHandlers(), and SCH_EDIT_FRAME::SCH_EDIT_FRAME().
| bool KICAD_API_SERVER::Running | ( | ) | const |
Definition at line 196 of file api_server.cpp.
References m_server.
Referenced by CROSS_PROBE_CLIENT::AnnounceToPrimary(), EDA_BASE_FRAME::CommonSettingsChanged(), CROSS_PROBE_CLIENT::IsOnStandardSocketPath(), CROSS_PROBE_CLIENT::SendToFrame(), Start(), and Stop().
|
inline |
Definition at line 69 of file api_server.h.
References m_readyToReply.
|
inline |
Definition at line 74 of file api_server.h.
References m_socketPathOverride.
| std::string KICAD_API_SERVER::SocketPath | ( | ) | const |
Definition at line 215 of file api_server.cpp.
References m_server.
Referenced by CROSS_PROBE_CLIENT::AnnounceToPrimary(), API_PLUGIN_MANAGER::doInvokeAction(), CROSS_PROBE_CLIENT::IsOnStandardSocketPath(), CROSS_PROBE_CLIENT::SendToFrame(), and Start().
|
static |
Return the default API socket path (without the ipc:// scheme).
Definition at line 77 of file api_server.cpp.
Referenced by StandardSocketUrl(), and Start().
|
static |
Return the default API socket URL (including the ipc:// scheme).
Definition at line 94 of file api_server.cpp.
References StandardSocketPath().
Referenced by CROSS_PROBE_CLIENT::AnnounceToPrimary(), CROSS_PROBE_CLIENT::IsOnStandardSocketPath(), and CROSS_PROBE_CLIENT::SendToFrame().
| void KICAD_API_SERVER::Start | ( | ) |
Definition at line 100 of file api_server.cpp.
References PATHS::EnsurePathExists(), ADVANCED_CFG::GetCfg(), PATHS::GetLogsPath(), handleApiEvent(), log(), m_logFilePath, m_server, m_socketPathOverride, onApiRequest(), Running(), s_logFileName, SocketPath(), StandardSocketPath(), and traceApi.
Referenced by EDA_BASE_FRAME::CommonSettingsChanged(), and KICAD_API_SERVER().
| void KICAD_API_SERVER::Stop | ( | ) |
Definition at line 183 of file api_server.cpp.
References handleApiEvent(), m_server, Running(), and traceApi.
Referenced by EDA_BASE_FRAME::CommonSettingsChanged(), and ~KICAD_API_SERVER().
|
inline |
Definition at line 81 of file api_server.h.
References m_token.
Referenced by CROSS_PROBE_CLIENT::AnnounceToPrimary(), and API_PLUGIN_MANAGER::doInvokeAction().
|
private |
Definition at line 116 of file api_server.h.
Referenced by DeregisterHandler(), handleApiRequestString(), and RegisterHandler().
|
private |
Definition at line 126 of file api_server.h.
|
private |
Definition at line 120 of file api_server.h.
Referenced by KICAD_API_SERVER(), onApiRequest(), and SetReadyToReply().
|
private |
Definition at line 114 of file api_server.h.
Referenced by handleApiRequestString(), onApiRequest(), Running(), SocketPath(), Start(), and Stop().
|
private |
Definition at line 122 of file api_server.h.
Referenced by SetSocketPath(), and Start().
|
private |
Definition at line 118 of file api_server.h.
Referenced by handleApiRequestString(), KICAD_API_SERVER(), and Token().
|
staticprivate |
Definition at line 124 of file api_server.h.
Referenced by Start().