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

109 lines
2.5 KiB
C++
Raw Normal View History

2008-01-06 23:13:01 +01:00
/*
* Copyright 2005-2007 Gerald Schmidt.
2008-01-06 23:13:01 +01:00
*
* This file is part of Xml Copy Editor.
2008-01-06 23:13:01 +01:00
*
* 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.
2008-01-06 23:13:01 +01:00
*
* 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.
2008-01-06 23:13:01 +01:00
*
* 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
{
2008-01-06 23:13:01 +01:00
if ( topic == IPC_TOPIC )
return new MyServerConnection();
2007-09-07 23:17:30 +02:00
2008-01-06 23:13:01 +01:00
// unknown topic
return NULL;
2007-09-07 23:17:30 +02:00
}
MyServerConnection::MyServerConnection() : wxConnection()
{
2008-01-06 23:13:01 +01:00
server_connection = this;
2007-09-07 23:17:30 +02:00
}
MyServerConnection::~MyServerConnection()
{
2008-01-06 23:13:01 +01: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
{
2008-01-06 23:13:01 +01: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 ) )
{
if ( frame->activateTab ( item ) )
frame->reloadTab();
}
else
{
frame->openFile ( ( wxString& ) item );
2009-01-17 23:52:54 +01:00
//frame->addToFileQueue ( ( wxString& ) item ); // prevent event loop problems
2008-01-06 23:13:01 +01:00
}
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
{
2008-01-06 23:13:01 +01:00
return true;
2007-09-07 23:17:30 +02:00
}
MyClientConnection::MyClientConnection()
2007-09-08 00:25:30 +02:00
{}
2007-09-07 23:17:30 +02:00
wxConnectionBase *MyClient::OnMakeConnection()
{
2008-01-06 23:13:01 +01:00
return new MyClientConnection;
2007-09-07 23:17:30 +02:00
}
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
{
2008-01-06 23:13:01 +01:00
return true;
2007-09-07 23:17:30 +02:00
}
bool MyClientConnection::OnDisconnect()
{
2008-01-06 23:13:01 +01:00
client_connection = NULL;
return wxConnection::OnDisconnect();
2007-09-07 23:17:30 +02:00
}
MyServer::MyServer()
{ }
MyClient::MyClient()
{ }