-
Notifications
You must be signed in to change notification settings - Fork 3
/
DDEServer.hpp
144 lines (118 loc) · 3.97 KB
/
DDEServer.hpp
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
138
139
140
141
142
143
144
/******************************************************************************
** (C) Chris Oldwood
**
** MODULE: DDESERVER.HPP
** COMPONENT: Network & Comms Library
** DESCRIPTION: The CDDEServer class declaration.
**
*******************************************************************************
*/
// Check for previous inclusion
#ifndef DDESERVER_HPP
#define DDESERVER_HPP
#if _MSC_VER > 1000
#pragma once
#endif
#include "DDEFwd.hpp"
#include "IDDEServer.hpp"
#include "DDEInst.hpp"
#include <vector>
// Forward declarations.
class CBuffer;
// Template shorthands.
typedef std::vector<CDDESvrConv*> CDDESvrConvs;
/******************************************************************************
**
** This class provides DDE Server services.
**
*******************************************************************************
*/
class CDDEServer : public DDE::IDDEServer
, public CDDEInst
{
public:
//! The default configuration flags.
static const DWORD DEFAULT_FLAGS = CBF_SKIP_REGISTRATIONS | CBF_SKIP_UNREGISTRATIONS;
public:
//! Constructor.
CDDEServer(DWORD dwFlags = DEFAULT_FLAGS);
//! Destructor.
virtual ~CDDEServer();
//
// Methods.
//
void Register(const tchar* pszService);
void Unregister(const tchar* pszService);
//
// Conversation methods.
//
void DestroyConversation(CDDESvrConv* pConv);
CDDESvrConv* FindConversation(const tchar* pszService, const tchar* pszTopic) const;
CDDESvrConv* FindConversation(HCONV hConv) const;
size_t GetNumConversations() const;
size_t GetAllConversations(CDDESvrConvs& aoConvs) const;
//
// Event listener methods.
//
void AddListener(IDDEServerListener* pListener);
void RemoveListener(IDDEServerListener* pListener);
//
// Utility methods (initially public for testing)
//
static uint GuessTextFormat(const CBuffer& buffer);
protected:
// Template shorthands.
typedef std::vector<IDDEServerListener*> CListeners;
//
// Members.
//
CDDESvrConvs m_aoConvs; // The list of conversations.
CListeners m_aoListeners; // The list of event listeners.
//
// Initialisation methods.
//
void Initialise(DWORD dwFlags);
void Uninitialise();
//
// DDECallback handlers.
//
bool OnWildConnect(CStrArray& astrServices, CStrArray& astrTopics);
bool OnWildConnectService(const tchar* pszService, CStrArray& astrTopics);
bool OnWildConnectTopic(const tchar* pszTopic, CStrArray& astrServices);
bool OnConnect(const tchar* pszService, const tchar* pszTopic);
void OnConnectConfirm(HCONV hConv, const tchar* pszService, const tchar* pszTopic);
void OnDisconnect(HCONV hConv);
bool OnRequest(HCONV hConv, const tchar* pszItem, uint nFormat, CDDEData& oData);
bool OnAdviseStart(HCONV hConv, const tchar* pszItem, uint nFormat);
bool OnAdviseRequest(HCONV hConv, const tchar* pszItem, uint nFormat, CDDEData& oData);
void OnAdviseStop(HCONV hConv, const tchar* pszItem, uint nFormat);
bool OnExecute(HCONV hConv, const CDDEData& oData, uint nFormat);
bool OnPoke(HCONV hConv, const tchar* pszItem, uint nFormat, const CDDEData& oData);
//! The real DDE Callback function.
static HDDEDATA CALLBACK DDECallbackProc(UINT uType, UINT uFormat, HCONV hConv, HSZ hsz1, HSZ hsz2, HDDEDATA hData, ULONG_PTR dwData1, ULONG_PTR dwData2);
//! The DDE Callback function implementation.
static HDDEDATA DDECallbackProcImpl(UINT uType, UINT uFormat, HCONV hConv, HSZ hsz1, HSZ hsz2, HDDEDATA hData);
// The single DDE Client object.
static CDDEServer* g_pDDEServer;
};
namespace DDE
{
//! The default CDDEServer smart-pointer type.
typedef Core::SharedPtr<CDDEServer> ServerPtr;
}
/******************************************************************************
**
** Implementation of inline functions.
**
*******************************************************************************
*/
inline size_t CDDEServer::GetNumConversations() const
{
return m_aoConvs.size();
}
inline size_t CDDEServer::GetAllConversations(CDDESvrConvs& aoConvs) const
{
aoConvs = m_aoConvs;
return aoConvs.size();
}
#endif // DDESERVER_HPP