xml-copy-editor-code/src/myipc.cpp

107 lines
2.5 KiB
C++
Raw Normal View History

/*
* Copyright 2005-2007 Gerald Schmidt.
*
* This file is part of Xml Copy Editor.
*
* Xml Copy Editor is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* Xml Copy Editor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xml Copy Editor; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
2007-09-07 23:17:30 +02:00
#include "myipc.h"
#include "xmlcopyeditor.h"
MyServerConnection *server_connection = 0;
MyClientConnection *client_connection = 0;
2007-09-08 00:25:30 +02:00
wxConnectionBase *MyServer::OnAcceptConnection ( const wxString& topic )
2007-09-07 23:17:30 +02:00
{
if ( topic == IPC_TOPIC )
return new MyServerConnection();
// unknown topic
return NULL;
}
MyServerConnection::MyServerConnection() : wxConnection()
{
2007-09-08 00:25:30 +02:00
server_connection = this;
2007-09-07 23:17:30 +02:00
}
MyServerConnection::~MyServerConnection()
{
2007-09-08 00:25:30 +02:00
if ( server_connection )
{
server_connection = NULL;
}
2007-09-07 23:17:30 +02:00
}
2007-09-08 00:25:30 +02:00
bool MyServerConnection::OnPoke (
const wxString& WXUNUSED ( topic ),
const wxString& item,
wxChar *data,
int size,
wxIPCFormat WXUNUSED ( format ) )
2007-09-07 23:17:30 +02:00
{
2007-09-08 00:25:30 +02:00
if ( !wxTheApp )
return false;
MyFrame *frame;
frame = ( MyFrame * ) wxTheApp->GetTopWindow();
if ( !frame )
return false;
if ( item == ( wxString ) IPC_NO_FILE )
{
;
}
else if ( frame->isOpen ( item ) )
{
frame->activateTab ( item );
}
else
{
frame->openFile ( ( wxString& ) item );
}
frame->Raise();
return true;
2007-09-07 23:17:30 +02:00
}
2007-09-08 00:25:30 +02:00
bool MyServerConnection::OnStartAdvise ( const wxString& WXUNUSED ( topic ),
const wxString& WXUNUSED ( item ) )
2007-09-07 23:17:30 +02:00
{
return true;
}
MyClientConnection::MyClientConnection()
2007-09-08 00:25:30 +02:00
{}
2007-09-07 23:17:30 +02:00
wxConnectionBase *MyClient::OnMakeConnection()
{
return new MyClientConnection;
}
2007-09-08 00:25:30 +02:00
bool MyClientConnection::OnAdvise ( const wxString& WXUNUSED ( topic ), const wxString& WXUNUSED ( item ), wxChar *data, int WXUNUSED ( size ), wxIPCFormat WXUNUSED ( format ) )
2007-09-07 23:17:30 +02:00
{
2007-09-08 00:25:30 +02:00
return true;
2007-09-07 23:17:30 +02:00
}
bool MyClientConnection::OnDisconnect()
{
2007-09-08 00:25:30 +02:00
client_connection = NULL;
return wxConnection::OnDisconnect();
2007-09-07 23:17:30 +02:00
}
MyServer::MyServer()
{ }
MyClient::MyClient()
{ }