]> git.saurik.com Git - wxWidgets.git/blame - samples/ipc/server.h
updated portability note for wxGetDiskSpace (patch 1682889)
[wxWidgets.git] / samples / ipc / server.h
CommitLineData
7921cf2b
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: server.h
3// Purpose: DDE sample: server
4// Author: Julian Smart
5// Modified by:
6// Created: 25/01/99
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
9d860992
JS
12#define ID_START 10000
13#define ID_DISCONNECT 10001
14#define ID_ADVISE 10002
15#define ID_LOG 10003
16#define ID_SERVERNAME 10004
17
7921cf2b 18// Define a new application
4b89c618 19class MyServer;
9d860992
JS
20class MyConnection;
21class MyFrame;
22
4b89c618 23class MyApp : public wxApp
7921cf2b 24{
4b89c618
VZ
25public:
26 virtual bool OnInit();
27 virtual int OnExit();
9d860992 28 MyFrame *GetFrame() { return m_frame; };
4b89c618 29
9d860992
JS
30protected:
31 MyFrame *m_frame;
7921cf2b
JS
32};
33
34DECLARE_APP(MyApp)
35
36// Define a new frame
4b89c618 37class MyFrame : public wxFrame
7921cf2b 38{
4b89c618
VZ
39public:
40 MyFrame(wxFrame *frame, const wxString& title);
7921cf2b 41
f6bcfd97 42 void OnExit(wxCommandEvent& event);
9d860992
JS
43 void OnClose(wxCloseEvent& event);
44
45 void Enable();
46 void Disconnect();
47
48protected:
49 wxButton* GetStart() { return (wxButton*) FindWindow( ID_START ); }
50 wxChoice* GetServername() { return (wxChoice*) FindWindow( ID_SERVERNAME ); }
51 wxButton* GetDisconnect() { return (wxButton*) FindWindow( ID_DISCONNECT ); }
52 wxButton* GetAdvise() { return (wxButton*) FindWindow( ID_ADVISE ); }
53 wxTextCtrl* GetLog() { return (wxTextCtrl*) FindWindow( ID_LOG ); }
4b89c618 54
9d860992
JS
55
56 MyServer *m_server;
57
58 void OnStart( wxCommandEvent &event );
59 void OnServerName( wxCommandEvent &event );
60 void OnDisconnect( wxCommandEvent &event );
61 void OnAdvise( wxCommandEvent &event );
4b89c618
VZ
62
63 DECLARE_EVENT_TABLE()
7921cf2b
JS
64};
65
4b89c618 66class MyConnection : public wxConnection
7921cf2b 67{
4b89c618 68public:
f010ad48 69 MyConnection();
4b89c618 70 ~MyConnection();
7921cf2b 71
9d860992
JS
72 virtual bool OnExecute(const wxString& topic, wxChar *data, int size, wxIPCFormat format);
73 virtual wxChar *OnRequest(const wxString& topic, const wxString& item, int *size, wxIPCFormat format);
74 virtual bool OnPoke(const wxString& topic, const wxString& item, wxChar *data, int size, wxIPCFormat format);
75 virtual bool OnStartAdvise(const wxString& topic, const wxString& item);
76 virtual bool OnStopAdvise(const wxString& topic, const wxString& item);
77 virtual bool Advise(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
78 virtual bool OnDisconnect();
79protected:
80 void Log(const wxString& command, const wxString& topic, const wxString& item, wxChar *data, int size, wxIPCFormat format);
81public:
82 wxString m_sAdvise;
83protected:
84 wxString m_sRequestDate;
85 char m_achRequestBytes[3];
7921cf2b
JS
86};
87
88class MyServer: public wxServer
89{
90public:
9d860992
JS
91 MyServer();
92 ~MyServer();
93 void Disconnect();
94 bool IsConnected() { return m_connection != NULL; };
95 MyConnection *GetConnection() { return m_connection; };
96 void Advise();
97 bool CanAdvise() { return m_connection != NULL && !m_connection->m_sAdvise.IsEmpty(); };
7921cf2b 98 wxConnectionBase *OnAcceptConnection(const wxString& topic);
7921cf2b 99
9d860992
JS
100protected:
101 MyConnection *m_connection;
7921cf2b
JS
102};
103