KiCad PCB EDA Suite
Loading...
Searching...
No Matches
remote_login_server.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/gpl-3.0.html
19 * or you may write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23#pragma once
24#include <wx/event.h>
25#include <wx/socket.h>
26#include <wx/string.h>
27#include <wx/timer.h>
28
29#include <memory>
30
31wxDECLARE_EVENT( EVT_REMOTE_SYMBOL_LOGIN_RESULT, wxCommandEvent );
32
33class REMOTE_LOGIN_SERVER : public wxEvtHandler
34{
35public:
36 REMOTE_LOGIN_SERVER( wxEvtHandler* aOwner, const wxString& aRedirectUrl );
37 ~REMOTE_LOGIN_SERVER() override;
38
39 bool Start();
40 unsigned short GetPort() const { return m_port; }
41
42private:
43 void OnSocketEvent( wxSocketEvent& aEvent );
44 void OnTimeout( wxTimerEvent& aEvent );
45 void HandleClient( wxSocketBase* aClient );
46 wxString ExtractUserId( const wxString& aRequestLine ) const;
47 void SendHttpResponse( wxSocketBase* aClient );
48 void Finish( bool aSuccess, const wxString& aUserId );
49 void Shutdown();
50
51 wxEvtHandler* m_owner;
52 wxString m_redirectUrl;
53 std::unique_ptr<wxSocketServer> m_server;
54 wxTimer m_timeout;
55 unsigned short m_port;
56 bool m_done;
57};
REMOTE_LOGIN_SERVER(wxEvtHandler *aOwner, const wxString &aRedirectUrl)
unsigned short GetPort() const
std::unique_ptr< wxSocketServer > m_server
void SendHttpResponse(wxSocketBase *aClient)
void HandleClient(wxSocketBase *aClient)
void Finish(bool aSuccess, const wxString &aUserId)
void OnSocketEvent(wxSocketEvent &aEvent)
wxString ExtractUserId(const wxString &aRequestLine) const
void OnTimeout(wxTimerEvent &aEvent)
wxDECLARE_EVENT(EVT_REMOTE_SYMBOL_LOGIN_RESULT, wxCommandEvent)