@@ -109,9 +109,6 @@ wxString g_SQLiteObjTypeName[5] =
109109IMPLEMENT_DYNAMIC_CLASS (wxSQLitePlusFrame, wxFrame)
110110
111111BEGIN_EVENT_TABLE(wxSQLitePlusFrame, wxFrame)
112- EVT_SOCKET(ID_IPC_SERVER, wxSQLitePlusFrame::OnServerEvent)
113- EVT_SOCKET(ID_IPC_SRV_SOCK, wxSQLitePlusFrame::OnSrvSocketEvent)
114-
115112 EVT_CLOSE(wxSQLitePlusFrame::OnCloseWindow)
116113 EVT_TREE_ITEM_RIGHT_CLICK(ID_DBTREE, wxSQLitePlusFrame::OnDbtreeItemRightClick)
117114 EVT_TREE_SEL_CHANGED(ID_DBTREE, wxSQLitePlusFrame::OnDbtreeItemSelChanged)
@@ -248,21 +245,16 @@ bool wxSQLitePlusFrame::Create(wxWindow* parent, wxWindowID id,
248245 m_MnuTransact->Check (ID_MNU_AUTOTRANSACT, (autotransact == 1 ));
249246 m_TbTransact->ToggleTool (ID_MNU_AUTOTRANSACT, (autotransact == 1 ));
250247
251- LaunchServer ();
252-
253248 return true ;
254249}
255250/* ---------------------------------------------------------------------------*/
256251wxSQLitePlusFrame::~wxSQLitePlusFrame ()
257252{
258- if (m_Server)
259- delete m_Server;
260253 GetAuiManager ().UnInit ();
261254}
262255/* ---------------------------------------------------------------------------*/
263256void wxSQLitePlusFrame::Init ()
264257{
265- m_Server = NULL ;
266258 m_TreeCtrl = NULL ;
267259 m_CenterNotebook = NULL ;
268260 m_MnuFile = NULL ;
@@ -769,65 +761,6 @@ void wxSQLitePlusFrame::InitNodeParams()
769761 }
770762}
771763/* ---------------------------------------------------------------------------*/
772- void wxSQLitePlusFrame::OnServerEvent (wxSocketEvent& event)
773- {
774- wxSocketBase *sock;
775-
776- if (event.GetSocketEvent () == wxSOCKET_CONNECTION)
777- {
778- sock = m_Server->Accept (false );
779- if (sock)
780- {
781- // On indique que le gestionnaire d'évènement est La fenêtre
782- sock->SetEventHandler (*this , ID_IPC_SRV_SOCK);
783- // Spécification des évènements à générer
784- sock->SetNotify (wxSOCKET_INPUT_FLAG | wxSOCKET_OUTPUT_FLAG | wxSOCKET_LOST_FLAG);
785- // les évènements peuvent être générés
786- sock->Notify (true );
787- }
788- }
789- }
790- /* ---------------------------------------------------------------------------*/
791- void wxSQLitePlusFrame::OnSrvSocketEvent (wxSocketEvent& event)
792- {
793- wxSocketBase* ev_sock;
794- wxChar buffer[1024 ];
795- wxUint32 len;
796- wxString str, verb;
797-
798- if (event.GetSocketEvent () == wxSOCKET_INPUT)
799- {
800- ev_sock = event.GetSocket ();
801- ev_sock->SetFlags (wxSOCKET_BLOCK|wxSOCKET_WAITALL);
802- if (!ev_sock->Error ())
803- {
804- len = ev_sock->ReadMsg (buffer, 1024 * sizeof (wxChar)).LastCount ();
805- if (len > 0 )
806- {
807- str.Printf ((" %s" ), buffer);
808- // wxLogMessage(str);
809- verb = str.BeforeFirst ((' ' ));
810- if (verb == IPC_VERB_SHOW)
811- {
812- Raise ();
813- }
814- else if (verb == IPC_VERB_OPEN)
815- {
816- str = str.AfterFirst ((' ' ));
817- if (!str.IsEmpty ())
818- CmdOpen (str);
819- }
820- else
821- {
822- verb = wxString::Format (_ (" [%s]\n is not a correct IPC action." ),
823- str.c_str ());
824- wxMessageBox (verb, _ (" Internal Error" ));
825- }
826- }
827- }
828- }
829- }
830- /* ---------------------------------------------------------------------------*/
831764void wxSQLitePlusFrame::OnDbtreeItemRightClick (wxTreeEvent& event)
832765{
833766 wxTreeItemId item = event.GetItem ();
@@ -2700,31 +2633,3 @@ bool wxSQLitePlusFrame::DoFinishTransaction()
27002633 }
27012634}
27022635/* ---------------------------------------------------------------------------*/
2703- void wxSQLitePlusFrame::LaunchServer ()
2704- {
2705- wxIPV4address addr;
2706-
2707- addr.Service (0 ); // pick an open port number.
2708- // Création du serveur
2709- m_Server = new wxSocketServer (addr);
2710-
2711- // On teste si le serveur écoute
2712- if (m_Server->Ok ())
2713- {
2714- // Gets the new address, actually it is just the port number
2715- m_Server->GetLocal (addr);
2716- wxGetApp ().SetService ((unsigned int )addr.Service ());
2717- // On indique que le gestionnaire d'évènement est La fenêtre
2718- m_Server->SetEventHandler (*this , ID_IPC_SERVER);
2719- // Spécification des évènements à générer
2720- m_Server->SetNotify (wxSOCKET_CONNECTION_FLAG);
2721- // les évènements peuvent être générés
2722- m_Server->Notify (true );
2723- }
2724- else
2725- {
2726- delete m_Server;
2727- m_Server = NULL ;
2728- }
2729- }
2730- /* ---------------------------------------------------------------------------*/
0 commit comments