dde 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ misc
20
+ pkg
21
+
22
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 arvicco
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = dde
2
+
3
+ Server that mimics Excel receiving XLTable data via DDE protocol
4
+
5
+ Work in progress, don't use it just yet...
6
+
7
+ == Note on Patches/Pull Requests
8
+
9
+ * Fork the project.
10
+ * Make your feature addition or bug fix.
11
+ * Add tests for it. This is important so I don't break it in a
12
+ future version unintentionally.
13
+ * Commit, do not mess with rakefile, version, or history.
14
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
15
+ * Send me a pull request. Bonus points for topic branches.
16
+
17
+ == Copyright
18
+
19
+ Copyright (c) 2010 arvicco. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,60 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "dde"
8
+ gem.summary = %Q{DDE server for Ruby}
9
+ gem.description = %Q{Server that mimics Excel receiving XLTable data via DDE protocol}
10
+ gem.email = "arvitallian@gmail.com"
11
+ gem.homepage = "http://github.com/arvicco/dde"
12
+ gem.authors = ["arvicco"]
13
+ gem.add_dependency "win_gui", ">= 0.1.0"
14
+ gem.add_development_dependency "rspec", ">= 1.2.9"
15
+ gem.add_development_dependency "cucumber", ">= 0"
16
+ gem.files.reject! { |fn| fn.include? "misc" }
17
+
18
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
+ end
20
+ Jeweler::GemcutterTasks.new
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
23
+ end
24
+
25
+ require 'spec/rake/spectask'
26
+ Spec::Rake::SpecTask.new(:spec) do |spec|
27
+ spec.libs << 'lib' << 'spec'
28
+ spec.spec_files = FileList['spec/**/*_spec.rb']
29
+ end
30
+
31
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
32
+ spec.libs << 'lib' << 'spec'
33
+ spec.pattern = 'spec/**/*_spec.rb'
34
+ spec.rcov = true
35
+ end
36
+
37
+ task :spec => :check_dependencies
38
+
39
+ begin
40
+ require 'cucumber/rake/task'
41
+ Cucumber::Rake::Task.new(:features)
42
+
43
+ task :features => :check_dependencies
44
+ rescue LoadError
45
+ task :features do
46
+ abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
47
+ end
48
+ end
49
+
50
+ task :default => :spec
51
+
52
+ require 'rake/rdoctask'
53
+ Rake::RDocTask.new do |rdoc|
54
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
55
+
56
+ rdoc.rdoc_dir = 'rdoc'
57
+ rdoc.title = "dde #{version}"
58
+ rdoc.rdoc_files.include('README*')
59
+ rdoc.rdoc_files.include('lib/**/*.rb')
60
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.2
data/bin/dde_main ADDED
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.join(File.dirname(__FILE__), '..', 'lib')
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include? lib
5
+
6
+ require 'dde'
7
+
8
+ # console output redirection (may need to wrap it in synchronization code, etc)
9
+ def cout *args
10
+ print *args
11
+ end
12
+
13
+ cout "Starting script\n"
14
+
15
+ require 'win/gui/message'
16
+
17
+ include Win::GUI::Message
18
+ include Win::DDE
19
+
20
+ server = DDE::XlServer.new # create server
21
+
22
+ # std::queue<XlTable> q; // Queue contains the tables to output
23
+
24
+ # HDDEDATA CALLBACK DdeCallback(UINT uType, UINT uFmt, HCONV hConv, HSZ hsz1, HSZ hsz2,
25
+ # HDDEDATA hData, DWORD dwData1, DWORD dwData2)
26
+
27
+ dde_callback = lambda do |type, format, conv, hsz1, hsz2, data_handle, data1, data2|
28
+ case type
29
+ when XTYP_CONNECT # Request to connect from client, creating data exchange channel
30
+ # hsz1:: Handle to the topic name.
31
+ # hsz2:: Handle to the service name.
32
+ # dwData1:: Pointer to a CONVCONTEXT structure that contains context information for the conversation.
33
+ # If the client is not a Dynamic Data Exchange Management Library (DDEML) application,
34
+ # this parameter is 0.
35
+ # dwData2:: Specifies whether the client is the same application instance as the server. If the
36
+ # parameter is 1, the client is the same instance. If the parameter is 0, the client
37
+ # is a different instance.
38
+ # *Returns*:: A server callback function should return TRUE(1) to allow the client to establish a
39
+ # conversation on the specified service name and topic name pair, or the function
40
+ # should return FALSE to deny the conversation. If the callback function returns TRUE(1)
41
+ # and a conversation is successfully established, the system passes the conversation
42
+ # todo: handle to the server by issuing an XTYP_CONNECT_CONFIRM transaction to the server's
43
+ # callback function (unless the server specified the CBF_SKIP_CONNECT_CONFIRMS flag
44
+ # in the DdeInitialize function).
45
+
46
+ if hsz2 == server.service.handle
47
+ 1 # instead of true # Yes, this server supports requested (name) handle
48
+ else
49
+ cout "Unable to process connection request for #{hsz2}, service handle is #{server.service}\n"
50
+ DDE_FNOTPROCESSED # 0 instead of false # No, server does not support requested (name) handle
51
+ end
52
+
53
+ when XTYP_POKE # Client initiated XTYP_POKE transaction to push unsolicited data to the server
54
+ # format:: Specifies the format of the data sent from the server.
55
+ # conv:: Handle to the conversation.
56
+ # hsz1:: Handle to the topic name. (Excel: [topic]item ?!)
57
+ # hsz2:: Handle to the item name.
58
+ # data_handle:: Handle to the data that the client is sending to the server.
59
+ # *Returns*:: A server callback function should return the DDE_FACK flag if it processes this
60
+ # transaction, the DDE_FBUSY flag if it is too busy to process this transaction,
61
+ # or the DDE_FNOTPROCESSED flag if it rejects this transaction.
62
+ #
63
+ # # CHAR buf[200];
64
+
65
+ flag = server.table.get_data(data_handle) # extract client's DDE data into server's xltable
66
+ if flag
67
+ # Converting hsz1 into "[topic]item" string and
68
+ server.table.topic_item = dde_query_string(server.id, hsz1)
69
+ server.table.draw # Simply printing it for now, no queues
70
+ # // Placing table into print queue
71
+ # WaitForSingleObject(hMutex1,INFINITE);
72
+ # q.push(server.xltable);
73
+ # ReleaseMutex(hMutex1);
74
+ # // Allowing the table output thread to start...
75
+ # ReleaseSemaphore(hSemaphore,1,NULL);
76
+ #
77
+ cout "Transaction finished"
78
+ DDE_FACK # Transaction successful
79
+ else
80
+ cout "Unable to receive dataprocess connection request for #{hsz2}, server handle is #{server.handle}\n"
81
+ DDE_FNOTPROCESSED # 0 Transaction NOT successful - return (HDDEDATA)TRUE; ?!(why TRUE, not FALSE)
82
+ end
83
+
84
+ when XTYP_DISCONNECT # DDE client disconnects
85
+ # server.xltable.Delete();
86
+ # break;
87
+ DDE_FNOTPROCESSED # 0 - return((HDDEDATA)NULL);// is it the same as 0 ?!
88
+
89
+ when XTYP_ERROR # DDE Error
90
+ # WaitForSingleObject(hMutex, INFINITE);
91
+ # std::cerr<<"DDE error.\n";
92
+ # ReleaseMutex(hMutex);
93
+ # break;
94
+ DDE_FNOTPROCESSED # 0 - return((HDDEDATA)NULL);// is it the same as 0 ?!
95
+
96
+ else
97
+ DDE_FNOTPROCESSED # 0 - return((HDDEDATA)NULL);// is it the same as 0 ?!
98
+ end
99
+ end
100
+
101
+ # Staring service with default name 'excel'
102
+ cout "Starting DDE service 'excel'\n"
103
+ server.start_service &dde_callback
104
+
105
+ msg = Msg.new # pointer to Msg FFI struct
106
+
107
+ # Starting message loop (necessary for DDE processing)
108
+ cout "Starting message loop\n"
109
+ while msg = get_message(msg)
110
+ translate_message(msg);
111
+ dispatch_message(msg);
112
+ end
data/dde.gemspec ADDED
@@ -0,0 +1,94 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{dde}
8
+ s.version = "0.2.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["arvicco"]
12
+ s.date = %q{2010-02-26}
13
+ s.default_executable = %q{dde_main}
14
+ s.description = %q{Server that mimics Excel receiving XLTable data via DDE protocol}
15
+ s.email = %q{arvitallian@gmail.com}
16
+ s.executables = ["dde_main"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/dde_main",
29
+ "dde.gemspec",
30
+ "doc/XLTable_format.doc",
31
+ "doc/dde_formats.doc",
32
+ "doc/ddeml.d.txt",
33
+ "doc/types.txt",
34
+ "doc/~$Table_format.doc",
35
+ "doc/~$e_formats.doc",
36
+ "features/dde.feature",
37
+ "features/step_definitions/dde_steps.rb",
38
+ "features/support/env.rb",
39
+ "lib/dde.rb",
40
+ "lib/dde/app.rb",
41
+ "lib/dde/client.rb",
42
+ "lib/dde/dde_string.rb",
43
+ "lib/dde/monitor.rb",
44
+ "lib/dde/server.rb",
45
+ "lib/dde/xl_server.rb",
46
+ "lib/dde/xl_table.rb",
47
+ "spec/dde/app_spec.rb",
48
+ "spec/dde/client_spec.rb",
49
+ "spec/dde/dde_string_spec.rb",
50
+ "spec/dde/monitor_spec.rb",
51
+ "spec/dde/server_shared.rb",
52
+ "spec/dde/server_spec.rb",
53
+ "spec/dde/xl_server_spec.rb",
54
+ "spec/dde/xl_table_spec.rb",
55
+ "spec/spec.opts",
56
+ "spec/spec_helper.rb"
57
+ ]
58
+ s.homepage = %q{http://github.com/arvicco/dde}
59
+ s.rdoc_options = ["--charset=UTF-8"]
60
+ s.require_paths = ["lib"]
61
+ s.rubygems_version = %q{1.3.5}
62
+ s.summary = %q{DDE server for Ruby}
63
+ s.test_files = [
64
+ "spec/dde/app_spec.rb",
65
+ "spec/dde/client_spec.rb",
66
+ "spec/dde/dde_string_spec.rb",
67
+ "spec/dde/monitor_spec.rb",
68
+ "spec/dde/server_shared.rb",
69
+ "spec/dde/server_spec.rb",
70
+ "spec/dde/xl_server_spec.rb",
71
+ "spec/dde/xl_table_spec.rb",
72
+ "spec/spec_helper.rb"
73
+ ]
74
+
75
+ if s.respond_to? :specification_version then
76
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
77
+ s.specification_version = 3
78
+
79
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
80
+ s.add_runtime_dependency(%q<win_gui>, [">= 0.1.0"])
81
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
82
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
83
+ else
84
+ s.add_dependency(%q<win_gui>, [">= 0.1.0"])
85
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
86
+ s.add_dependency(%q<cucumber>, [">= 0"])
87
+ end
88
+ else
89
+ s.add_dependency(%q<win_gui>, [">= 0.1.0"])
90
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
91
+ s.add_dependency(%q<cucumber>, [">= 0"])
92
+ end
93
+ end
94
+
Binary file
Binary file