OSDN Git Service

The text edit in MyListCtrl seems weird. Hopefully fixed.
[molby/Molby.git] / wxSources / MyIPCSupport.cpp
1 /*
2  *  MyIPCSupport.cpp
3  *  Molby
4  *
5  *  Created by Toshi Nagata on 12/10/10.
6  *  Copyright 2012 Toshi Nagata. All rights reserved.
7  *
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation version 2 of the License.
11  
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  GNU General Public License for more details.
16  */
17
18 // For compilers that support precompilation, includes "wx/wx.h".
19 #include "wx/wxprec.h"
20
21 #ifndef WX_PRECOMP
22 #include "wx/wx.h"
23 #endif
24
25
26 #if defined(__WXMSW__)
27
28 #include "MyIPCSupport.h"
29 #include "MyApp.h"
30
31 wxString *gIPCServiceName = NULL;
32
33 bool
34 MyClientConnection::OnDisconnect()
35 {
36         wxGetApp().m_client->Disconnect();
37 }
38
39 MyClient::MyClient()
40 {
41         m_clientConnection = NULL;
42 }
43
44 MyClient::~MyClient()
45 {
46         Disconnect();
47 }
48         
49 void
50 MyClient::Disconnect()
51 {
52         if (m_clientConnection != NULL) {
53                 m_clientConnection->Disconnect();
54                 m_clientConnection = NULL;
55         }
56 }
57
58 wxConnectionBase *
59 MyClient::OnMakeConnection()
60 {
61         if (m_clientConnection == NULL)
62                 m_clientConnection = new MyClientConnection;
63         return m_clientConnection;
64 }
65
66 bool
67 MyServerConnection::OnDisconnect()
68 {
69         wxGetApp().m_server->Disconnect();
70 }
71
72 bool
73 MyServerConnection::OnExecute(const wxString& topic, wxChar* data, int size, wxIPCFormat format)
74 {
75         if (topic == MOLBY_IPC_TOPIC) {
76                 wxString files(data);
77                 wxGetApp().RequestOpenFilesByIPC(files);
78                 return true;
79         } else return false;
80 }
81
82 MyServer::MyServer()
83 {
84         m_serverConnection = NULL;
85 }
86
87 MyServer::~MyServer()
88 {
89         Disconnect();
90 }
91
92 void
93 MyServer::Disconnect()
94 {
95         if (m_serverConnection != NULL) {
96                 m_serverConnection->Disconnect();
97                 m_serverConnection = NULL;
98         }
99 }
100
101 wxConnectionBase *
102 MyServer::OnAcceptConnection(const wxString &topic)
103 {
104     if (topic == MOLBY_IPC_TOPIC) {
105                 if (m_serverConnection == NULL)
106                         m_serverConnection = new MyServerConnection();
107         return m_serverConnection;
108     }
109     return NULL;
110 }
111
112 #endif  // defined(__WXMSW__)