File: dde.h

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (137 lines) | stat: -rw-r--r-- 4,057 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/////////////////////////////////////////////////////////////////////////////
// Name:        wx/msw/dde.h
// Purpose:     DDE class
// Author:      Julian Smart
// Modified by:
// Created:     01/02/97
// Copyright:   (c) Julian Smart
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#ifndef _WX_DDE_H_
#define _WX_DDE_H_

#include "wx/ipcbase.h"

/*
 * Mini-DDE implementation

   Most transactions involve a topic name and an item name (choose these
   as befits your application).

   A client can:

   - ask the server to execute commands (data) associated with a topic
   - request data from server by topic and item
   - poke data into the server
   - ask the server to start an advice loop on topic/item
   - ask the server to stop an advice loop

   A server can:

   - respond to execute, request, poke and advice start/stop
   - send advise data to client

   Note that this limits the server in the ways it can send data to the
   client, i.e. it can't send unsolicited information.
 *
 */

class WXDLLIMPEXP_FWD_BASE wxDDEServer;
class WXDLLIMPEXP_FWD_BASE wxDDEClient;

class WXDLLIMPEXP_BASE wxDDEConnection : public wxConnectionBase
{
public:
  wxDDEConnection(void *buffer, size_t size); // use external buffer
  wxDDEConnection(); // use internal buffer
  virtual ~wxDDEConnection();

  // implement base class pure virtual methods
  virtual const void *Request(const wxString& item,
                              size_t *size = NULL,
                              wxIPCFormat format = wxIPC_TEXT);
  virtual bool StartAdvise(const wxString& item);
  virtual bool StopAdvise(const wxString& item);
  virtual bool Disconnect();

protected:
  virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format);
  virtual bool DoPoke(const wxString& item, const void *data, size_t size,
                      wxIPCFormat format);
  virtual bool DoAdvise(const wxString& item, const void *data, size_t size,
                        wxIPCFormat format);

public:
  wxString      m_topicName;
  wxDDEServer*  m_server;
  wxDDEClient*  m_client;

  WXHCONV       m_hConv;
  const void*   m_sendingData;
  int           m_dataSize;
  wxIPCFormat   m_dataType;

  wxDECLARE_NO_COPY_CLASS(wxDDEConnection);
  DECLARE_DYNAMIC_CLASS(wxDDEConnection)
};

class WXDLLIMPEXP_BASE wxDDEServer : public wxServerBase
{
public:
    wxDDEServer();
    bool Create(const wxString& server_name);
    virtual ~wxDDEServer();

    virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);

    // Find/delete wxDDEConnection corresponding to the HCONV
    wxDDEConnection *FindConnection(WXHCONV conv);
    bool DeleteConnection(WXHCONV conv);
    wxString& GetServiceName() const { return (wxString&) m_serviceName; }

    wxDDEConnectionList& GetConnections() const
        { return (wxDDEConnectionList&) m_connections; }

protected:
    int       m_lastError;
    wxString  m_serviceName;
    wxDDEConnectionList m_connections;

    DECLARE_DYNAMIC_CLASS(wxDDEServer)
};

class WXDLLIMPEXP_BASE wxDDEClient: public wxClientBase
{
public:
    wxDDEClient();
    virtual ~wxDDEClient();

    bool ValidHost(const wxString& host);

    // Call this to make a connection. Returns NULL if cannot.
    virtual wxConnectionBase *MakeConnection(const wxString& host,
                                             const wxString& server,
                                             const wxString& topic);

    // Tailor this to return own connection.
    virtual wxConnectionBase *OnMakeConnection();

    // Find/delete wxDDEConnection corresponding to the HCONV
    wxDDEConnection *FindConnection(WXHCONV conv);
    bool DeleteConnection(WXHCONV conv);

    wxDDEConnectionList& GetConnections() const
        { return (wxDDEConnectionList&) m_connections; }

protected:
    int       m_lastError;
    wxDDEConnectionList m_connections;

    DECLARE_DYNAMIC_CLASS(wxDDEClient)
};

void WXDLLIMPEXP_BASE wxDDEInitialize();
void WXDLLIMPEXP_BASE wxDDECleanUp();

#endif // _WX_DDE_H_