skype_lock_logout 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/skype_lock_logout.rb +23 -6
- data/skype_lock_logout.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
data/lib/skype_lock_logout.rb
CHANGED
@@ -5,14 +5,22 @@ class Skype_lock_logout
|
|
5
5
|
#Spawns the object, starts to listen and blocks the thread.
|
6
6
|
def self.start
|
7
7
|
loop do
|
8
|
+
print "Starting Skype-lock-logout.\n"
|
9
|
+
|
8
10
|
begin
|
9
11
|
Skype_lock_logout.new.listen
|
10
12
|
rescue => e
|
11
|
-
|
12
|
-
|
13
|
+
if e.is_a?(DBus::Error) and e.message == "The name com.Skype.API was not provided by any .service files"
|
14
|
+
puts "Skype isnt running - trying again in 10 secs."
|
15
|
+
elsif e.is_a?(RuntimeError) and e.message == "Skype has stopped running."
|
16
|
+
puts "Skype stopped running - trying to reconnect in 10 secs."
|
17
|
+
else
|
18
|
+
puts e.inspect
|
19
|
+
puts e.backtrace
|
20
|
+
end
|
13
21
|
end
|
14
22
|
|
15
|
-
sleep
|
23
|
+
sleep 10
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
@@ -21,8 +29,8 @@ class Skype_lock_logout
|
|
21
29
|
@bus = DBus::SessionBus.instance
|
22
30
|
|
23
31
|
#Spawn Skype-DBus objects.
|
24
|
-
|
25
|
-
@skype_obj =
|
32
|
+
skype_service = @bus.service("com.Skype.API")
|
33
|
+
@skype_obj = skype_service.object("/com/Skype")
|
26
34
|
@skype_obj.introspect
|
27
35
|
@skype_obj.default_iface = "com.Skype.API"
|
28
36
|
|
@@ -30,13 +38,22 @@ class Skype_lock_logout
|
|
30
38
|
res = @skype_obj.Invoke("NAME SkypeLockLogout").first
|
31
39
|
raise "The application wasnt allowed use Skype: '#{res}'." if res != "OK"
|
32
40
|
|
33
|
-
#Set the protocol to 8 - could only find documentation on this protocol.
|
41
|
+
#Set the protocol to 8 - could only find documentation on this protocol. Are there any better ones???
|
34
42
|
res = @skype_obj.Invoke("PROTOCOL 8").first
|
35
43
|
raise "Couldnt set the protocol for Skype: '#{res}'." if res != "PROTOCOL 8"
|
36
44
|
|
37
45
|
#Listen for lock-events on the screensaver.
|
38
46
|
mr = DBus::MatchRule.new.from_s("interface='org.gnome.ScreenSaver',member='ActiveChanged'")
|
39
47
|
@bus.add_match(mr, &self.method(:gnome_screensaver_status))
|
48
|
+
|
49
|
+
#Listen for when Skype stops running to quit listening.
|
50
|
+
mr = DBus::MatchRule.new.from_s("path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged'")
|
51
|
+
@bus.add_match(mr, &self.method(:name_owner_changed))
|
52
|
+
end
|
53
|
+
|
54
|
+
#This method is being called on 'NameOwnerChanged', which helps us stop the app when Skype stops (a reconnect is needed after Skype restarts).
|
55
|
+
def name_owner_changed(msg)
|
56
|
+
raise "Skype has stopped running." if msg.params.first == "com.Skype.API" and msg.params[1].to_s.match(/^:\d\.\d+$/)
|
40
57
|
end
|
41
58
|
|
42
59
|
#This method is called, when the Gnome-Screensaver locks or unlocks.
|
data/skype_lock_logout.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: skype_lock_logout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kasper Johansen
|
@@ -115,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
115
|
requirements:
|
116
116
|
- - ">="
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
hash:
|
118
|
+
hash: 3428513175358633684
|
119
119
|
segments:
|
120
120
|
- 0
|
121
121
|
version: "0"
|