p2ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +27 -0
- data/HISTORY +7 -0
- data/LICENSE +20 -0
- data/README.rdoc +24 -0
- data/Rakefile +42 -0
- data/VERSION +1 -0
- data/bin/olegen.rb +368 -0
- data/features/p2ruby.feature +9 -0
- data/features/step_definitions/p2ruby_steps.rb +0 -0
- data/features/support/env.rb +10 -0
- data/features/support/world.rb +12 -0
- data/lib/extension.rb +19 -0
- data/lib/ole20110223-013209.rb +1677 -0
- data/lib/p2ruby/application.rb +111 -0
- data/lib/p2ruby/base.rb +59 -0
- data/lib/p2ruby/connection.rb +250 -0
- data/lib/p2ruby/data_stream.rb +215 -0
- data/lib/p2ruby/library.rb +24 -0
- data/lib/p2ruby/message.rb +150 -0
- data/lib/p2ruby/message_factory.rb +70 -0
- data/lib/p2ruby/record.rb +104 -0
- data/lib/p2ruby/router.rb +45 -0
- data/lib/p2ruby/table_set.rb +166 -0
- data/lib/p2ruby.rb +156 -0
- data/lib/version.rb +8 -0
- data/lib/win32ole-pr.rb +5540 -0
- data/spec/encoding_spec.rb +15 -0
- data/spec/p2ruby/application_spec.rb +35 -0
- data/spec/p2ruby/connection_spec.rb +293 -0
- data/spec/p2ruby/data_stream_spec.rb +218 -0
- data/spec/p2ruby/library_spec.rb +42 -0
- data/spec/p2ruby/message_factory_spec.rb +69 -0
- data/spec/p2ruby/message_spec.rb +159 -0
- data/spec/p2ruby/record_spec.rb +85 -0
- data/spec/p2ruby/router_spec.rb +54 -0
- data/spec/p2ruby/table_set_spec.rb +132 -0
- data/spec/p2ruby_spec.rb +46 -0
- data/spec/spec_helper.rb +78 -0
- data/tasks/common.rake +18 -0
- data/tasks/doc.rake +14 -0
- data/tasks/gem.rake +40 -0
- data/tasks/git.rake +34 -0
- data/tasks/spec.rake +16 -0
- data/tasks/version.rake +71 -0
- metadata +149 -0
@@ -0,0 +1,111 @@
|
|
1
|
+
module P2
|
2
|
+
# Represents P2 client application
|
3
|
+
# �������� ������ ���������� P2ClientGate, ��������������� ��� �� �������������.
|
4
|
+
# �� ��������� �������� ��������� �������������, �������� �� ���������� �� ���������
|
5
|
+
# (���������������� ini-����), � ����� ������������� ��� �������, ������������� ���
|
6
|
+
# ��������-������ ������. ��� ������� � Plaza ��� Plaza-II (��������� ��� ���������
|
7
|
+
# �������� ���������� �������� ���� Body).
|
8
|
+
# � ���������������� ini-����� ����� ������ ���� � ����� ������� ������ ����������
|
9
|
+
# Plaza-II � ����� ����������, � ����� ���� � �trace-����� � ����� � ������� �����������,
|
10
|
+
# ����� ��������� ������ � ������ ������, � ����� � ���. ������������� ��������� ��������
|
11
|
+
# ����������������� � ������� ����������������� ini-�����, ����������� � ����������� �����.
|
12
|
+
# ��� ����, ����� ������ ��������� �������������, �������� �� ���������� �� ���������
|
13
|
+
# ������� ���� ������� ������ Application � � ������ ������ StartUp ������� ���
|
14
|
+
# ����������������� ini-����� � ���� � ����. ��� ������� �������� ��� �������� �������
|
15
|
+
# � ���������� � ������� ����������� ������� get � put.
|
16
|
+
# ������ ��� ���������� �� ������ ������ � ������� ��������� ����������.
|
17
|
+
#
|
18
|
+
class Application < Base
|
19
|
+
CLSID = '{08A95064-05C2-4EF4-8B5D-D6211C2C9880}'
|
20
|
+
PROGID = 'P2ClientGate.P2Application.1'
|
21
|
+
|
22
|
+
attr_accessor :ini
|
23
|
+
|
24
|
+
# Application should not be used directly in client code, Connection.new
|
25
|
+
# tries to obtain/create Application instance implicitly.
|
26
|
+
#
|
27
|
+
def initialize ini
|
28
|
+
@ini = Pathname(ini || "./P2ClientGate.ini").expand_path
|
29
|
+
error "Wrong ini file #{@ini}" unless @ini.exist?
|
30
|
+
|
31
|
+
super(:ini => @ini) { StartUp @ini }
|
32
|
+
end
|
33
|
+
|
34
|
+
# Application is a Resettable Singleton:
|
35
|
+
# Normally, you use Application.instance to create/obtain its instance;
|
36
|
+
# However, when Application.reset is called, this resets the instance.
|
37
|
+
#
|
38
|
+
def self.reset ini = nil
|
39
|
+
@instance = new ini
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns Application instance unless explicitly given different ini file
|
43
|
+
#
|
44
|
+
def self.instance ini = nil
|
45
|
+
if @instance && ini && @instance.ini != Pathname(ini).expand_path
|
46
|
+
error "Attempt to obtain #{@instance} for different ini: #{ini}"
|
47
|
+
end
|
48
|
+
@instance ||= new ini
|
49
|
+
end
|
50
|
+
|
51
|
+
# Auto-generated OLE methods:
|
52
|
+
|
53
|
+
# property UI4 ParserType
|
54
|
+
# Get Parser type: � 1 � Plaza; � 2 � Plaza-II (default)
|
55
|
+
def ParserType()
|
56
|
+
@ole._getproperty(3, [], [])
|
57
|
+
end
|
58
|
+
|
59
|
+
# property VOID ParserType
|
60
|
+
# Set Parser type: � 1 � Plaza; � 2 � Plaza-II (default)
|
61
|
+
def ParserType=(val)
|
62
|
+
@ole._setproperty(3, [val], [VT_UI4])
|
63
|
+
end
|
64
|
+
|
65
|
+
# method VOID StartUp
|
66
|
+
# ������������� ���������� P2ClientGate � �����������, ��������� � ���������������� ini-�����.
|
67
|
+
# BSTR ini_file_name [IN]
|
68
|
+
def StartUp(ini_file) # May be given as a Pathname, call #to_s
|
69
|
+
@ole._invoke(1, [ini_file.to_s], [VT_BSTR])
|
70
|
+
end
|
71
|
+
|
72
|
+
# method VOID CleanUp
|
73
|
+
# ��������������� ���������� P2ClientGate.
|
74
|
+
def CleanUp()
|
75
|
+
@ole._invoke(2, [], [])
|
76
|
+
end
|
77
|
+
|
78
|
+
# method IP2Connection CreateP2Connection
|
79
|
+
def CreateP2Connection()
|
80
|
+
@ole._invoke(4, [], [])
|
81
|
+
end
|
82
|
+
|
83
|
+
# method IP2BLMessage CreateP2BLMessage
|
84
|
+
def CreateP2BLMessage()
|
85
|
+
@ole._invoke(5, [], [])
|
86
|
+
end
|
87
|
+
|
88
|
+
# method IP2BLMessageFactory CreateP2BLMessageFactory
|
89
|
+
def CreateP2BLMessageFactory()
|
90
|
+
@ole._invoke(6, [], [])
|
91
|
+
end
|
92
|
+
|
93
|
+
# method IP2DataBuffer CreateP2DataBuffer
|
94
|
+
def CreateP2DataBuffer()
|
95
|
+
@ole._invoke(7, [], [])
|
96
|
+
end
|
97
|
+
|
98
|
+
# method IP2DataStream CreateP2DataStream
|
99
|
+
def CreateP2DataStream()
|
100
|
+
@ole._invoke(8, [], [])
|
101
|
+
end
|
102
|
+
|
103
|
+
# method IP2TableSet CreateP2TableSet
|
104
|
+
def CreateP2TableSet()
|
105
|
+
@ole._invoke(9, [], [])
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end # module P2
|
110
|
+
|
111
|
+
|
data/lib/p2ruby/base.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
module P2
|
2
|
+
|
3
|
+
# This is P2 Base class that defines common functionality.
|
4
|
+
# All Ruby P2 classes serve as transparent proxy for OLE objects in P2ClientGate library.
|
5
|
+
#
|
6
|
+
class Base
|
7
|
+
include P2
|
8
|
+
include WIN32OLE::VARIANT
|
9
|
+
|
10
|
+
attr_reader :opts, :ole, :lastargs
|
11
|
+
|
12
|
+
def initialize opts = {}
|
13
|
+
@opts = opts.dup
|
14
|
+
|
15
|
+
# OLE object may be provided directly (Message)
|
16
|
+
@ole = @opts[:ole]
|
17
|
+
@ole ||= WIN32OLE.new clsid # (@opts[:lib] || Library.default).find name
|
18
|
+
|
19
|
+
# Yields self to given block before setting properties (for initialization, etc...)
|
20
|
+
yield self if block_given?
|
21
|
+
|
22
|
+
@opts.each do |key, val|
|
23
|
+
# OLE object set properties may be given as options
|
24
|
+
setter = "#{key.to_s.camel_case}="
|
25
|
+
send(setter, val) if respond_to? setter
|
26
|
+
|
27
|
+
# OLE object NAMED properties may be given as options (Message#Field)
|
28
|
+
prop = key.to_s.camel_case
|
29
|
+
if respond_to?(prop) && val.is_a?(Hash)
|
30
|
+
val.each do |k, v|
|
31
|
+
property = send prop
|
32
|
+
property[k.to_s] = v
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# All unknown methods are routed to composed OLE object
|
39
|
+
#
|
40
|
+
def method_missing *args
|
41
|
+
@ole.send *args
|
42
|
+
end
|
43
|
+
|
44
|
+
# Keeps [OUT] args sent by reference into OLE method
|
45
|
+
# s
|
46
|
+
def keep_lastargs(return_value)
|
47
|
+
@lastargs = WIN32OLE::ARGV
|
48
|
+
return_value
|
49
|
+
end
|
50
|
+
|
51
|
+
def clsid
|
52
|
+
self.class::CLSID
|
53
|
+
end
|
54
|
+
|
55
|
+
def progid
|
56
|
+
self.class::PROGID
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end # module P2
|
@@ -0,0 +1,250 @@
|
|
1
|
+
module P2
|
2
|
+
|
3
|
+
# Represents Connection to local P2 Router.
|
4
|
+
# Several connections may exist per one Application.
|
5
|
+
# �������� ��������� �������, ������� ������������ ����������� ��� �������� � ������
|
6
|
+
# � ������������, � ����� ������ � ��������� ���������.
|
7
|
+
#
|
8
|
+
# Notes: �������� AppName, NodeName, Host, Port, Password � Timeout ������ ���� ������ ��
|
9
|
+
# ������� ������ ������ Connect. � ������ ��������� ������ ������� ��� ����, �����
|
10
|
+
# ��������� �������� � ���� ���������� �������� ���������������� ����� �������
|
11
|
+
# Disconnect � Connect. ��������� �������������� ������� (LoginStr) ������ ����
|
12
|
+
# ������ �� ������� ������ ������ Login.
|
13
|
+
#
|
14
|
+
class Connection < Base
|
15
|
+
CLSID = '{CCD42082-33E0-49EA-AED3-9FE39978EB56}'
|
16
|
+
PROGID = 'P2ClientGate.P2Connection.1'
|
17
|
+
|
18
|
+
def initialize opts = {}
|
19
|
+
|
20
|
+
# First we need to obtain Application singleton (for a given ini file)...
|
21
|
+
# Yes, it IS weird - ini file used by Connection is manipulated in Application.
|
22
|
+
@app = P2::Application.instance opts[:ini]
|
23
|
+
|
24
|
+
super opts
|
25
|
+
end
|
26
|
+
|
27
|
+
# Connection and Router status in text format
|
28
|
+
#
|
29
|
+
def status_text status = @ole.status
|
30
|
+
P2::CS_MESSAGES.map { |k, v| (k & status).zero? ? nil : v }.compact.join(', ')
|
31
|
+
end
|
32
|
+
|
33
|
+
# Tests if connection to local Router exists
|
34
|
+
#
|
35
|
+
def connected?
|
36
|
+
@ole.status & P2::CS_CONNECTION_CONNECTED != 0
|
37
|
+
end
|
38
|
+
|
39
|
+
# Tests if local Router is authenticated with RTS server
|
40
|
+
#
|
41
|
+
def logged?
|
42
|
+
@ole.status & P2::CS_ROUTER_CONNECTED != 0
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns Win32OLE event wrapper for IP2ConnectionEvent event interface
|
46
|
+
#
|
47
|
+
def events(event_interface = 'IP2ConnectionEvent')
|
48
|
+
@events ||= WIN32OLE_EVENT.new(@ole, event_interface)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Auto-generated OLE methods:
|
52
|
+
|
53
|
+
# property I4 Status
|
54
|
+
# ��� ��������� ���������� ��� �������.
|
55
|
+
def Status()
|
56
|
+
@ole._getproperty(1, [], [])
|
57
|
+
end
|
58
|
+
|
59
|
+
# property BSTR AppName
|
60
|
+
# ��� ����������, ��� �������� ���������� ���������� ����������. ��� ����������
|
61
|
+
# ������ ���� ���������� � ������ ������ �������.
|
62
|
+
def AppName()
|
63
|
+
@ole._getproperty(2, [], [])
|
64
|
+
end
|
65
|
+
|
66
|
+
alias Name AppName
|
67
|
+
alias name AppName
|
68
|
+
|
69
|
+
# property BSTR NodeName
|
70
|
+
# ��� �������
|
71
|
+
def NodeName()
|
72
|
+
@ole._getproperty(3, [], [])
|
73
|
+
end
|
74
|
+
|
75
|
+
# property BSTR Host
|
76
|
+
# IP-����� ���� ���� UNC-���.
|
77
|
+
def Host()
|
78
|
+
@ole._getproperty(4, [], [])
|
79
|
+
end
|
80
|
+
|
81
|
+
# property UI4 Port
|
82
|
+
# ����� ����� TCP/IP.
|
83
|
+
def Port()
|
84
|
+
@ole._getproperty(5, [], [])
|
85
|
+
end
|
86
|
+
|
87
|
+
# property UI4 Timeout
|
88
|
+
# �������, � ������� �������� ��������� ��������� ���������� ����������.
|
89
|
+
def Timeout()
|
90
|
+
@ole._getproperty(7, [], [])
|
91
|
+
end
|
92
|
+
|
93
|
+
# property BSTR LoginStr
|
94
|
+
# ������ � ������������������ ����������� ������� (�����/������).
|
95
|
+
# ������ ������: USERNAME=;PASSWORD=. ��������, USERNAME=3@ivanov;PASSWORD=qwerty.
|
96
|
+
def LoginStr()
|
97
|
+
@ole._getproperty(8, [], [])
|
98
|
+
end
|
99
|
+
|
100
|
+
# property VOID AppName
|
101
|
+
# ��� ����������, ��� �������� ���������� ���������� ����������. ��� ����������
|
102
|
+
# ������ ���� ���������� � ������ ������ �������.
|
103
|
+
def AppName=(val)
|
104
|
+
@ole._setproperty(2, [val], [VT_BSTR])
|
105
|
+
end
|
106
|
+
|
107
|
+
alias Name= AppName=
|
108
|
+
alias name= AppName=
|
109
|
+
|
110
|
+
# property VOID Host
|
111
|
+
# IP-����� ���� ���� UNC-���.
|
112
|
+
def Host=(val)
|
113
|
+
@ole._setproperty(4, [val], [VT_BSTR])
|
114
|
+
end
|
115
|
+
|
116
|
+
# property VOID Port
|
117
|
+
# ����� ����� TCP/IP.
|
118
|
+
def Port=(val)
|
119
|
+
@ole._setproperty(5, [val], [VT_UI4])
|
120
|
+
end
|
121
|
+
|
122
|
+
# property VOID Password
|
123
|
+
# ������ ��� ���������� ����������.
|
124
|
+
def Password=(val)
|
125
|
+
@ole._setproperty(6, [val], [VT_VARIANT])
|
126
|
+
end
|
127
|
+
|
128
|
+
# property VOID Timeout
|
129
|
+
# �������, � ������� �������� ��������� ��������� ���������� ����������.
|
130
|
+
def Timeout=(val)
|
131
|
+
@ole._setproperty(7, [val], [VT_UI4])
|
132
|
+
end
|
133
|
+
|
134
|
+
# property VOID LoginStr
|
135
|
+
# ������ � ������������������ ����������� ������� (�����/������).
|
136
|
+
# ������ ������: USERNAME=;PASSWORD=. ��������, USERNAME=3@ivanov;PASSWORD=qwerty.
|
137
|
+
def LoginStr=(val)
|
138
|
+
@ole._setproperty(8, [val], [VT_BSTR])
|
139
|
+
end
|
140
|
+
|
141
|
+
# method UI4 Connect ([out, retval] ULONG* errClass);
|
142
|
+
# �������� ���������� ���������� ���������� � ��������.
|
143
|
+
# errClass � ����� ������ � ��� ������, ���� ������� ������ ��������� �������� �� P2ERR_OK.
|
144
|
+
# ������������ ��������� ������ ������:
|
145
|
+
# � 0 (��������� P2MQ_ERRORCLASS_OK) � ����� ����� �������� ���������� ����������
|
146
|
+
# ���������� � ���� �� ����������� (��������, ������� ��������� ������� � ������
|
147
|
+
# ��������� ���� � �.�.).
|
148
|
+
# � 1 (��������� P2MQ_ERRORCLASS_IS_USELESS) � �������� ��������� ������� ����������
|
149
|
+
# ���������� �������� � ��� �� �����������, ���������� �������� ��������� �������.
|
150
|
+
def Connect()
|
151
|
+
@ole._invoke(9, [], [])
|
152
|
+
end
|
153
|
+
|
154
|
+
# method UI4 Connect2
|
155
|
+
# �������� ���������� ���������� ���������� � ��������. ������� � ���������� � ������ Connection#Connect.
|
156
|
+
# BSTR conn_str [IN]
|
157
|
+
def Connect2(conn_str)
|
158
|
+
@ole._invoke(18, [conn_str], [VT_BSTR])
|
159
|
+
end
|
160
|
+
|
161
|
+
# method VOID DisconnecT
|
162
|
+
# ������ ���������� ����������
|
163
|
+
def Disconnect()
|
164
|
+
@ole._invoke(10, [], [])
|
165
|
+
end
|
166
|
+
|
167
|
+
# method VOID Login
|
168
|
+
# ������������� ����� ������� � ����. ������ ������� ��������� ��������� ����������
|
169
|
+
# � ����������� �������� � ����������������� � ����. ��������� ��������������
|
170
|
+
# (USERNAME=;PASSWORD=) �������� ��������� LoginStr..
|
171
|
+
def Login()
|
172
|
+
@ole._invoke(11, [], [])
|
173
|
+
end
|
174
|
+
|
175
|
+
# method VOID Logout
|
176
|
+
# ������ ���� ��������� ���������� �������.
|
177
|
+
def Logout()
|
178
|
+
@ole._invoke(12, [], [])
|
179
|
+
end
|
180
|
+
|
181
|
+
# method VOID ProcessMessage
|
182
|
+
# ����� � ��������� ���������, � ��� ����� � ��������������.
|
183
|
+
# UI4 cookie [OUT] � ������� � �������������, � ������� �������� ��������� ��������� ���������;
|
184
|
+
# UI4 poll_timeout [IN] � ���������� ������������� ����������.
|
185
|
+
def ProcessMessage(cookie, poll_timeout)
|
186
|
+
keep_lastargs @ole._invoke(13, [cookie, poll_timeout], [VT_BYREF|VT_UI4, VT_UI4])
|
187
|
+
end
|
188
|
+
|
189
|
+
# method UI4 ProcessMessage2 ( [in] ULONG pollTimeout, [out, retval] ULONG* cookie);
|
190
|
+
# ����� � ��������� ���������. ������� � ���������� � ������ Connection.ProcessMessage,
|
191
|
+
# ��� ��� ��� �� �������� � ������������������ ������ (JScript) �������� ��������� ������ ������� (cookie).
|
192
|
+
# UI4 poll_timeout [IN]
|
193
|
+
# [out, retval] ULONG* cookie);???????????????????????
|
194
|
+
def ProcessMessage2(poll_timeout)
|
195
|
+
@ole._invoke(17, [poll_timeout], [VT_UI4])
|
196
|
+
end
|
197
|
+
|
198
|
+
# method UI4 ProcessMessage3
|
199
|
+
# ???
|
200
|
+
# UI4 poll_timeout [IN]
|
201
|
+
def ProcessMessage3(poll_timeout)
|
202
|
+
@ole._invoke(19, [poll_timeout], [VT_UI4])
|
203
|
+
end
|
204
|
+
|
205
|
+
# method UI4 RegisterReceiver ( [in] IP2MessageReceiver* newReceiver, [out,retval] ULONG* cookie);
|
206
|
+
# ����������� ����������.
|
207
|
+
# � cookie � ���������� ������������� ����������. ������������ ��� ����, ����� �����
|
208
|
+
# ���� �������� ��������, � ����� ������ �� ���� � ������ Connection.ProcessMessage
|
209
|
+
# ������������ ���������� ���������.
|
210
|
+
# IP2MessageReceiver new_receiver [IN] � ��������� �� ��������� ��������� ������;
|
211
|
+
def RegisterReceiver(new_receiver)
|
212
|
+
@ole._invoke(14, [new_receiver], [VT_BYREF|VT_DISPATCH])
|
213
|
+
end
|
214
|
+
|
215
|
+
# method VOID UnRegisterReceiver ([in] ULONG cookie);
|
216
|
+
# ������ ����������� ���������� �� �������������� (cookie).
|
217
|
+
# UI4 cookie [IN]
|
218
|
+
def UnRegisterReceiver(cookie)
|
219
|
+
@ole._invoke(15, [cookie], [VT_UI4])
|
220
|
+
end
|
221
|
+
|
222
|
+
# method BSTR ResolveService ( [in] BSTR service, [out,retval] BSTR* address);
|
223
|
+
# ��������� ������� ������ ���������� �� ����� �������, ������� ��� �������������.
|
224
|
+
# BSTR service [IN] - � ��� �������;
|
225
|
+
def ResolveService(service)
|
226
|
+
@ole._invoke(16, [service], [VT_BSTR])
|
227
|
+
end
|
228
|
+
|
229
|
+
# HRESULT GetConn
|
230
|
+
# OLE_HANDLE p_val [OUT]
|
231
|
+
def GetConn(p_val)
|
232
|
+
keep_lastargs @ole._invoke(1610678272, [p_val], [VT_BYREF|VT_BYREF|VT_DISPATCH])
|
233
|
+
end
|
234
|
+
|
235
|
+
# HRESULT GetConnPtr
|
236
|
+
# OLE_HANDLE p_val [OUT]
|
237
|
+
def GetConnPtr(p_val)
|
238
|
+
keep_lastargs @ole._invoke(1610678273, [p_val], [VT_BYREF|VT_BYREF|VT_DISPATCH])
|
239
|
+
end
|
240
|
+
|
241
|
+
# method VOID ConnectionStatusChanged - EVENT in IP2ConnectionEvent
|
242
|
+
# IP2Connection conn [IN]
|
243
|
+
# TConnectionStatus new_status [IN]
|
244
|
+
def ConnectionStatusChanged(conn, new_status)
|
245
|
+
@ole._invoke(1, [conn, new_status], [VT_BYREF|VT_DISPATCH, VT_DISPATCH])
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end # module P2
|
249
|
+
|
250
|
+
|
@@ -0,0 +1,215 @@
|
|
1
|
+
module P2
|
2
|
+
|
3
|
+
# Represents P2 replication Data Stream.
|
4
|
+
# �������� ��������� ������� ������������ ��� ����������� ��������� �������������� ������.
|
5
|
+
#
|
6
|
+
class DataStream < Base
|
7
|
+
CLSID = '{914893CB-0864-4FBB-856A-92C3A1D970F8}'
|
8
|
+
PROGID = 'P2ClientGate.P2DataStream.1'
|
9
|
+
|
10
|
+
def initialize opts = {}
|
11
|
+
super opts
|
12
|
+
end
|
13
|
+
|
14
|
+
# Connection and Router status in text format
|
15
|
+
#
|
16
|
+
def state_text state = self.State
|
17
|
+
P2::DS_MESSAGES[state]
|
18
|
+
end
|
19
|
+
|
20
|
+
# Tests if replication stream is in error state
|
21
|
+
#
|
22
|
+
def error?
|
23
|
+
self.State == P2::DS_STATE_ERROR
|
24
|
+
end
|
25
|
+
|
26
|
+
# Tests if replication stream is closed (or un-opened)
|
27
|
+
#
|
28
|
+
def closed?
|
29
|
+
self.State == P2::DS_STATE_CLOSE
|
30
|
+
end
|
31
|
+
|
32
|
+
# Tests if replication stream is opened (please note, it may still be in error state!)
|
33
|
+
#
|
34
|
+
def opened?
|
35
|
+
!closed?
|
36
|
+
end
|
37
|
+
|
38
|
+
alias open? opened?
|
39
|
+
|
40
|
+
# Returns Win32OLE event wrapper for IP2DataStreamEvents event interface
|
41
|
+
#
|
42
|
+
def events(event_interface = 'IP2DataStreamEvents')
|
43
|
+
@events ||= WIN32OLE_EVENT.new(@ole, event_interface)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Auto-generated OLE methods:
|
47
|
+
|
48
|
+
# property IP2TableSet TableSet
|
49
|
+
# - ����� ������ � ����� ����������. �������� �������� ������� ���������� ����� ��
|
50
|
+
# ini-����� (��. �������� COM-������� TableSet) ��� ������������� ��� ���������
|
51
|
+
# ����� �� ������� ����������.
|
52
|
+
def TableSet()
|
53
|
+
table_set = @ole._getproperty(1, [], [])
|
54
|
+
P2::TableSet.new :ole => table_set if table_set
|
55
|
+
end
|
56
|
+
|
57
|
+
# property BSTR StreamName � ��� ������ ����������.
|
58
|
+
def StreamName()
|
59
|
+
@ole._getproperty(2, [], [])
|
60
|
+
end
|
61
|
+
|
62
|
+
alias Name StreamName
|
63
|
+
alias name StreamName
|
64
|
+
|
65
|
+
# property BSTR DBConnString
|
66
|
+
# � ������ ���������� � ��. �������� ���������� ��� ���������� � �� ������� �� ����,
|
67
|
+
# ����� ������� ������������ ��� ��������� ����������: P2DBSQLite.dll ��� P2DBODBC.dll.
|
68
|
+
# ������� � ������ ��������� ������ ������ ��������� ������������� �������
|
69
|
+
# ����������� ������� ����������. ����� ������ � �� ������ �� �����, � ����
|
70
|
+
# �������� ������ �� ������� ����������. � ���������� ������� �����������
|
71
|
+
# IP2DataStreamEvents::StreamDataUpdated �� ����������.
|
72
|
+
#
|
73
|
+
# ������� �����:
|
74
|
+
# 'P2DBSQLite.dll;dbTest.ini;�:\dbTest'
|
75
|
+
# 'P2DBODBC.dll;crypto.ini;DRIVER={SQLServer};SERVER=TEST1;DATABASE=crypto;UID=autotest; PWD=autotest'
|
76
|
+
#
|
77
|
+
def DBConnString()
|
78
|
+
@ole._getproperty(3, [], [])
|
79
|
+
end
|
80
|
+
|
81
|
+
# TRequestType type: property Type
|
82
|
+
# � ��� ������ ����������. ��� ������ ���������� �������� � ������ ��������� ������
|
83
|
+
# (�������/������), � ����� ����� �������� ��������� �� ������� ������� � ���������
|
84
|
+
# �� �������.
|
85
|
+
#
|
86
|
+
def Type()
|
87
|
+
@ole._getproperty(4, [], [])
|
88
|
+
end
|
89
|
+
|
90
|
+
# property TDataStreamState State � ��������� ������ ����������.
|
91
|
+
def State()
|
92
|
+
@ole._getproperty(5, [], [])
|
93
|
+
end
|
94
|
+
|
95
|
+
# property VOID TableSet - ����� ������ � ����� ����������
|
96
|
+
def TableSet=(val)
|
97
|
+
table = val.respond_to?(:ole) ? val.ole : val
|
98
|
+
@ole._setproperty(1, [table], [VT_BYREF|VT_DISPATCH])
|
99
|
+
end
|
100
|
+
|
101
|
+
# property VOID StreamName � ��� ������ ����������.
|
102
|
+
def StreamName=(val)
|
103
|
+
@ole._setproperty(2, [val], [VT_BSTR])
|
104
|
+
end
|
105
|
+
|
106
|
+
alias Name= StreamName=
|
107
|
+
alias name= StreamName=
|
108
|
+
|
109
|
+
# property VOID DBConnString � ������ ���������� � ��. See DBConnString().
|
110
|
+
def DBConnString=(val)
|
111
|
+
@ole._setproperty(3, [val], [VT_BSTR])
|
112
|
+
end
|
113
|
+
|
114
|
+
# VOID type: property Type � ��� ������ ����������
|
115
|
+
# ???????? Changed signature from Dispatch to Int manually, possible problems?
|
116
|
+
# ???????? Also changed name from type to Type, reserved in OLE?
|
117
|
+
#
|
118
|
+
def Type=(val)
|
119
|
+
@ole._setproperty(4, [val], [VT_I4]) #VT_DISPATCH])
|
120
|
+
end
|
121
|
+
|
122
|
+
# method VOID Open
|
123
|
+
# �������� ������ �������������� ������.
|
124
|
+
# IP2Connection conn [IN] � ��������� �� ��������� ����������.
|
125
|
+
def Open(conn)
|
126
|
+
conn = conn.respond_to?(:ole) ? conn.ole : conn
|
127
|
+
@ole._invoke(6, [conn], [VT_BYREF|VT_DISPATCH])
|
128
|
+
end
|
129
|
+
|
130
|
+
# method VOID Close - �������� ������ �������������� ������.
|
131
|
+
def Close()
|
132
|
+
@ole._invoke(7, [], [])
|
133
|
+
end
|
134
|
+
|
135
|
+
# HRESULT GetScheme
|
136
|
+
# OLE_HANDLE p_val [OUT]
|
137
|
+
def GetScheme(p_val)
|
138
|
+
keep_lastargs @ole._invoke(1610678272, [p_val], [VT_BYREF|VT_BYREF|VT_DISPATCH])
|
139
|
+
end
|
140
|
+
|
141
|
+
# HRESULT LinkDataBuffer
|
142
|
+
# IP2DataStreamEvents data_buff [IN]
|
143
|
+
def LinkDataBuffer(data_buff)
|
144
|
+
@ole._invoke(1610678273, [data_buff], [VT_BYREF|VT_DISPATCH])
|
145
|
+
end
|
146
|
+
|
147
|
+
# method VOID StreamStateChanged - EVENT in IP2DataStreamEvents
|
148
|
+
# IP2DataStream stream [IN]
|
149
|
+
# TDataStreamState new_state [IN]
|
150
|
+
def StreamStateChanged(stream, new_state)
|
151
|
+
@ole._invoke(1, [stream, new_state], [VT_BYREF|VT_DISPATCH, VT_DISPATCH])
|
152
|
+
end
|
153
|
+
|
154
|
+
# method VOID StreamDataInserted - EVENT in IP2DataStreamEvents
|
155
|
+
# IP2DataStream stream [IN]
|
156
|
+
# BSTR table_name [IN]
|
157
|
+
# IP2Record rec [IN]
|
158
|
+
def StreamDataInserted(stream, table_name, rec)
|
159
|
+
@ole._invoke(2, [stream, table_name, rec], [VT_BYREF|VT_DISPATCH, VT_BSTR, VT_BYREF|VT_DISPATCH])
|
160
|
+
end
|
161
|
+
|
162
|
+
# method VOID StreamDataUpdated - EVENT in IP2DataStreamEvents
|
163
|
+
# IP2DataStream stream [IN]
|
164
|
+
# BSTR table_name [IN]
|
165
|
+
# I8 id [IN]
|
166
|
+
# IP2Record rec [IN]
|
167
|
+
def StreamDataUpdated(stream, table_name, id, rec)
|
168
|
+
@ole._invoke(3, [stream, table_name, id, rec], [VT_BYREF|VT_DISPATCH, VT_BSTR, VT_I8, VT_BYREF|VT_DISPATCH])
|
169
|
+
end
|
170
|
+
|
171
|
+
# method VOID StreamDataDeleted - EVENT in IP2DataStreamEvents
|
172
|
+
# IP2DataStream stream [IN]
|
173
|
+
# BSTR table_name [IN]
|
174
|
+
# I8 id [IN]
|
175
|
+
# IP2Record rec [IN]
|
176
|
+
def StreamDataDeleted(stream, table_name, id, rec)
|
177
|
+
@ole._invoke(4, [stream, table_name, id, rec], [VT_BYREF|VT_DISPATCH, VT_BSTR, VT_I8, VT_BYREF|VT_DISPATCH])
|
178
|
+
end
|
179
|
+
|
180
|
+
# method VOID StreamDatumDeleted - EVENT in IP2DataStreamEvents
|
181
|
+
# IP2DataStream stream [IN]
|
182
|
+
# BSTR table_name [IN]
|
183
|
+
# I8 rev [IN]
|
184
|
+
def StreamDatumDeleted(stream, table_name, rev)
|
185
|
+
@ole._invoke(5, [stream, table_name, rev], [VT_BYREF|VT_DISPATCH, VT_BSTR, VT_I8])
|
186
|
+
end
|
187
|
+
|
188
|
+
# method VOID StreamDBWillBeDeleted - EVENT in IP2DataStreamEvents
|
189
|
+
# IP2DataStream stream [IN]
|
190
|
+
def StreamDBWillBeDeleted(stream)
|
191
|
+
@ole._invoke(6, [stream], [VT_BYREF|VT_DISPATCH])
|
192
|
+
end
|
193
|
+
|
194
|
+
# method VOID StreamLifeNumChanged - EVENT in IP2DataStreamEvents
|
195
|
+
# IP2DataStream stream [IN]
|
196
|
+
# I4 life_num [IN]
|
197
|
+
def StreamLifeNumChanged(stream, life_num)
|
198
|
+
@ole._invoke(7, [stream, life_num], [VT_BYREF|VT_DISPATCH, VT_I4])
|
199
|
+
end
|
200
|
+
|
201
|
+
# method VOID StreamDataBegin - EVENT in IP2DataStreamEvents
|
202
|
+
# IP2DataStream stream [IN]
|
203
|
+
def StreamDataBegin(stream)
|
204
|
+
@ole._invoke(8, [stream], [VT_BYREF|VT_DISPATCH])
|
205
|
+
end
|
206
|
+
|
207
|
+
# method VOID StreamDataEnd - EVENT in IP2DataStreamEvents
|
208
|
+
# IP2DataStream stream [IN]
|
209
|
+
def StreamDataEnd(stream)
|
210
|
+
@ole._invoke(9, [stream], [VT_BYREF|VT_DISPATCH])
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end # module P2
|
214
|
+
|
215
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module P2
|
2
|
+
# Represents P2ClientGate OLE type library.
|
3
|
+
# Only works with STA version ( Ruby WIN32OLE limitation ).
|
4
|
+
class Library < WIN32OLE_TYPELIB
|
5
|
+
include P2
|
6
|
+
|
7
|
+
# Returns default lib if not explicitely instantiated
|
8
|
+
#
|
9
|
+
def self.default
|
10
|
+
@library ||= new
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
p2lib = WIN32OLE_TYPELIB.typelibs.find { |t| t.name =~ /P2ClientGate / }
|
15
|
+
error "No registered STA P2ClientGate, please register P2ClientGate.dll" unless p2lib
|
16
|
+
super p2lib.name
|
17
|
+
end
|
18
|
+
|
19
|
+
def find name
|
20
|
+
self.ole_types.map(&:progid).compact.find { |progid| progid[name] }
|
21
|
+
end
|
22
|
+
|
23
|
+
end # class Library
|
24
|
+
end # module P2
|