author | Myhailo Danylenko <isbear@ukrpost.net> |
Sun, 14 Mar 2010 22:10:17 +0200 | |
changeset 95 | f2f4c7810a72 |
parent 58 | aa3376776cf2 |
child 99 | ed4676536ed9 |
permissions | -rw-r--r-- |
58
aa3376776cf2
Cosmetic comment changes
Myhailo Danylenko <isbear@ukrpost.net>
parents:
32
diff
changeset
|
1 |
|
8 | 2 |
-- TRANSPORTED BUDDIES AVAILABILITY INDICATION |
3 |
||
9 | 4 |
-- XXX: to option? |
8 | 5 |
transport_jids = { 'icq.jabber.kiev.ua', 'mrim.unixzone.org.ua' } |
6 |
||
32 | 7 |
function online ( jid ) |
8 |
local info = main.buddy_info ( jid ) |
|
9 |
if not info then |
|
10 |
return false |
|
11 |
end |
|
12 |
for resource, params in pairs ( info.resources ) do |
|
13 |
if params.status ~= '_' then |
|
14 |
return true |
|
15 |
end |
|
16 |
end |
|
17 |
return false |
|
18 |
end |
|
19 |
||
8 | 20 |
hooks_d['hook-status-change'].transports = |
21 |
function ( args ) |
|
22 |
for k, jid in pairs ( transport_jids ) do |
|
23 |
if args.jid == jid then |
|
24 |
if args.new_status == '_' then |
|
25 |
main.run ( ("color roster * *@%s red"):format ( jid ) ) |
|
26 |
main.run ( ("color roster dn_? *@%s red"):format ( jid ) ) |
|
27 |
else |
|
28 |
main.run ( ("color roster * *@%s white"):format ( jid ) ) |
|
29 |
main.run ( ("color roster dn_? *@%s brightblack"):format ( jid ) ) |
|
30 |
end |
|
31 |
end |
|
32 |
end |
|
33 |
end |
|
34 |
||
35 |
hooks_d['hook-start'].transports = |
|
36 |
function ( args ) |
|
37 |
for k, jid in pairs ( transport_jids ) do |
|
38 |
if not online ( jid ) then |
|
39 |
main.run ( ("color roster * *@%s red"):format ( jid ) ) |
|
40 |
main.run ( ("color roster dn_? *@%s red"):format ( jid ) ) |
|
41 |
else |
|
42 |
main.run ( ("color roster * *@%s white"):format ( jid ) ) |
|
43 |
main.run ( ("color roster dn_? *@%s brightblack"):format ( jid ) ) |
|
44 |
end |
|
45 |
end |
|
46 |
end |
|
47 |
||
9 | 48 |
hooks_d['hook-post-connect'].transports = hooks_d['hook-start'].transports |
49 |
||
50 |
hooks_d['hook-pre-disconnect'].transports = |
|
51 |
function ( args ) |
|
52 |
for k, jid in pairs ( transport_jids ) do |
|
53 |
-- when disconnected, all buddies are inaccessible, so, make them the same |
|
54 |
main.run ( ("color roster * *@%s white"):format ( jid ) ) |
|
55 |
main.run ( ("color roster dn_? *@%s brightblack"):format ( jid ) ) |
|
56 |
end |
|
57 |
end |
|
58 |
||
8 | 59 |
-- vim: se ts=4: -- |