skype_lock_logout 0.0.0

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
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "ruby-dbus"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "rspec", "~> 2.8.0"
12
+ gem "rdoc", "~> 3.12"
13
+ gem "bundler", ">= 1.0.0"
14
+ gem "jeweler", "~> 1.8.4"
15
+ gem "rcov", ">= 0"
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ git (1.2.5)
6
+ jeweler (1.8.4)
7
+ bundler (~> 1.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rdoc
11
+ json (1.7.4)
12
+ rake (0.9.2.2)
13
+ rcov (0.9.11)
14
+ rdoc (3.12)
15
+ json (~> 1.4)
16
+ rspec (2.8.0)
17
+ rspec-core (~> 2.8.0)
18
+ rspec-expectations (~> 2.8.0)
19
+ rspec-mocks (~> 2.8.0)
20
+ rspec-core (2.8.0)
21
+ rspec-expectations (2.8.0)
22
+ diff-lcs (~> 1.1.2)
23
+ rspec-mocks (2.8.0)
24
+ ruby-dbus (0.7.2)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ bundler (>= 1.0.0)
31
+ jeweler (~> 1.8.4)
32
+ rcov
33
+ rdoc (~> 3.12)
34
+ rspec (~> 2.8.0)
35
+ ruby-dbus
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Kasper Johansen
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
+ = skype_lock_logout
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to skype_lock_logout
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Kasper Johansen. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "skype_lock_logout"
18
+ gem.homepage = "http://github.com/kaspernj/skype_lock_logout"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A small application which logs out of Skype, when the screen is locked and logs back in, when the screen is unlocked.}
21
+ gem.description = %Q{A small application which logs out of Skype, when the screen is locked and logs back in, when the screen is unlocked.}
22
+ gem.email = "k@spernj.org"
23
+ gem.authors = ["Kasper Johansen"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "skype_lock_logout #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,77 @@
1
+ require "dbus"
2
+
3
+ #A class that connects to the Gnome-Screensaver and listens for locks. When locking the app will log out of Skype. When unlocking the app will lock back into Skype.
4
+ class Skype_lock_logout
5
+ #Spawns the object, starts to listen and blocks the thread.
6
+ def self.start
7
+ loop do
8
+ begin
9
+ Skype_lock_logout.new.listen
10
+ rescue => e
11
+ puts e.inspect
12
+ puts e.backtrace
13
+ end
14
+
15
+ sleep 1
16
+ end
17
+ end
18
+
19
+ def initialize
20
+ #Spawn the session-DBus.
21
+ @bus = DBus::SessionBus.instance
22
+
23
+ #Spawn Skype-DBus objects.
24
+ @skype_service = @bus.service("com.Skype.API")
25
+ @skype_obj = @skype_service.object("/com/Skype")
26
+ @skype_obj.introspect
27
+ @skype_obj.default_iface = "com.Skype.API"
28
+
29
+ #Register the application with Skype.
30
+ res = @skype_obj.Invoke("NAME SkypeLockLogout").first
31
+ raise "The application wasnt allowed use Skype: '#{res}'." if res != "OK"
32
+
33
+ #Set the protocol to 8 - could only find documentation on this protocol.
34
+ res = @skype_obj.Invoke("PROTOCOL 8").first
35
+ raise "Couldnt set the protocol for Skype: '#{res}'." if res != "PROTOCOL 8"
36
+
37
+ #Listen for lock-events on the screensaver.
38
+ mr = DBus::MatchRule.new.from_s("interface='org.gnome.ScreenSaver',member='ActiveChanged'")
39
+ @bus.add_match(mr, &self.method(:gnome_screensaver_status))
40
+ end
41
+
42
+ #This method is called, when the Gnome-Screensaver locks or unlocks.
43
+ def gnome_screensaver_status(msg)
44
+ val = msg.params.first
45
+
46
+ if val == true
47
+ puts "Detected screenlock by Gnome Screensaver - logging out of Skype."
48
+ self.skype_status_offline
49
+ else
50
+ puts "Detected screenlock unlock by Gnome Screensaver - going online on Skype."
51
+ self.skype_status_online
52
+ end
53
+ end
54
+
55
+ #This listens for the connected events and blocks the thread calling it.
56
+ def listen
57
+ main = DBus::Main.new
58
+ main << @bus
59
+ main.run
60
+
61
+ nil
62
+ end
63
+
64
+ #Tells Skype to go offline.
65
+ def skype_status_offline
66
+ ret = @skype_obj.Invoke("SET USERSTATUS OFFLINE").first
67
+ raise "Couldnt go offline: '#{ret}'." if ret != "USERSTATUS OFFLINE"
68
+ nil
69
+ end
70
+
71
+ #Tells skype to go online.
72
+ def skype_status_online
73
+ ret = @skype_obj.Invoke("SET USERSTATUS ONLINE").first
74
+ raise "Couldnt go online: '#{ret}'." if ret != "USERSTATUS ONLINE"
75
+ nil
76
+ end
77
+ end
@@ -0,0 +1,66 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{skype_lock_logout}
8
+ s.version = "0.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kasper Johansen"]
12
+ s.date = %q{2012-08-03}
13
+ s.description = %q{A small application which logs out of Skype, when the screen is locked and logs back in, when the screen is unlocked.}
14
+ s.email = %q{k@spernj.org}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/skype_lock_logout.rb",
29
+ "skype_lock_logout.gemspec",
30
+ "spec/skype_lock_logout_spec.rb",
31
+ "spec/spec_helper.rb"
32
+ ]
33
+ s.homepage = %q{http://github.com/kaspernj/skype_lock_logout}
34
+ s.licenses = ["MIT"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.6.2}
37
+ s.summary = %q{A small application which logs out of Skype, when the screen is locked and logs back in, when the screen is unlocked.}
38
+
39
+ if s.respond_to? :specification_version then
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_runtime_dependency(%q<ruby-dbus>, [">= 0"])
44
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
45
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
46
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
47
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
48
+ s.add_development_dependency(%q<rcov>, [">= 0"])
49
+ else
50
+ s.add_dependency(%q<ruby-dbus>, [">= 0"])
51
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
52
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
53
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
54
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
55
+ s.add_dependency(%q<rcov>, [">= 0"])
56
+ end
57
+ else
58
+ s.add_dependency(%q<ruby-dbus>, [">= 0"])
59
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
60
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
61
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
62
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
63
+ s.add_dependency(%q<rcov>, [">= 0"])
64
+ end
65
+ end
66
+
@@ -0,0 +1,8 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "SkypeLockLogout" do
4
+ it "should work" do
5
+ sll = Skype_lock_logout.new
6
+ sll.listen
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'skype_lock_logout'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: skype_lock_logout
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Kasper Johansen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-08-03 00:00:00 +02:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: ruby-dbus
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 2.8.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rdoc
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: "3.12"
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: bundler
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.0.0
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: jeweler
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 1.8.4
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: rcov
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: *id006
82
+ description: A small application which logs out of Skype, when the screen is locked and logs back in, when the screen is unlocked.
83
+ email: k@spernj.org
84
+ executables: []
85
+
86
+ extensions: []
87
+
88
+ extra_rdoc_files:
89
+ - LICENSE.txt
90
+ - README.rdoc
91
+ files:
92
+ - .document
93
+ - .rspec
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - LICENSE.txt
97
+ - README.rdoc
98
+ - Rakefile
99
+ - VERSION
100
+ - lib/skype_lock_logout.rb
101
+ - skype_lock_logout.gemspec
102
+ - spec/skype_lock_logout_spec.rb
103
+ - spec/spec_helper.rb
104
+ has_rdoc: true
105
+ homepage: http://github.com/kaspernj/skype_lock_logout
106
+ licenses:
107
+ - MIT
108
+ post_install_message:
109
+ rdoc_options: []
110
+
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: -2047674363038107880
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: "0"
128
+ requirements: []
129
+
130
+ rubyforge_project:
131
+ rubygems_version: 1.6.2
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: A small application which logs out of Skype, when the screen is locked and logs back in, when the screen is unlocked.
135
+ test_files: []
136
+