/usr/share/amsn/plugins/keepalive/keepaliveplus.tcl is in amsn-data 0.98.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | namespace eval ::keepalive {
variable config
variable configlist
variable monitoredChatIds
proc init { dir } {
::plugins::RegisterPlugin KeepAlivePlus
plugins_log KeepAlivePlus "Registered plugin"
::plugins::RegisterEvent KeepAlivePlus chat_msg_sent message_sent
::plugins::RegisterEvent KeepAlivePlus chat_msg_received message_received
::plugins::RegisterEvent KeepAlivePlus chatwindow_closed cw_closed
::plugins::RegisterEvent KeepAlivePlus user_leaves_chat keepalive_plus_stop
array set ::keepalive::config {
only_fln {0}
}
set ::keepalive::configlist [ list [ list bool "Only keep SBs alive when we (or the other party) are or appear Offline" only_fln ] ]
}
proc keepalive_plus_init {event epvar} {
upvar 2 usr_name usr_name ;#is the user that joins email
upvar 2 chatid chatid ;# is the chat name
upvar 2 win_name win_name ;#
if {![info exists ::keepalive::nickalive($chatid)]} {
set ::keepalive::nickalive($chatid) [list 1]
set chat_temp $::keepalive::nickalive($chatid)
monitor_chatid $chatid
plugins_log KeepAlivePlus "NEW: $chatid - [lindex $chat_temp {}]"
}
}
proc send_keepalive_msg {sb} {
set msg "MIME-Version: 1.0\r\nContent-Type: text/x-keepalive\r\n\r\n\r\n\r\n"
set msg_len [string bytelength $msg]
::MSN::WriteSBNoNL $sb "MSG" "U $msg_len\r\n$msg"
return
}
proc message_sent {event evpar} {
upvar 2 nick nick
upvar 2 msg msg
upvar 2 chatid chatid
upvar 2 win_name win_name
upvar 2 fontfamily fontfamily
upvar 2 fontstyle fontstyle
upvar 2 fontcolor fontcolor
monitor_chatid $chatid
}
proc message_received {event evpar} {
upvar 2 user user
upvar 2 msg msg
upvar 2 chatid chatid
upvar 2 fontformat fontformat
upvar 2 message message
monitor_chatid $chatid
}
proc monitor_chatid {chatid} {
variable monitoredChatIds
# Only start the timer if one isn't already in place.
if {[info exists monitoredChatIds($chatid)] == 0} {
set monitoredChatIds($chatid) 1
# Check to send the keepalive again.
after 50000 "::keepalive::keepalive_timer $chatid"
}
}
proc stop_monitoring_chatid {chatid} {
variable monitoredChatIds
if {[info exists monitoredChatIds($chatid)]} {
unset monitoredChatIds($chatid)
}
after cancel "::keepalive::keepalive_timer $chatid"
}
proc keepalive_timer {chatid} {
# Assume this is the last call of the timer.
stop_monitoring_chatid $chatid
if { ! [::MSN::chatReady $chatid] } {
# Maybe the SB died in the meantine...
# for example, only_fln is 1 and we haven't chatted for a while
plugins_log KeepAlivePlus "Chat not ready for $chatid"
return
}
set sb [::MSN::SBFor $chatid]
if {$sb == 0} {
plugins_log KeepAlivePlus "YOU HAVE CLOSED THE CHAT"
return
}
# Send the keepalive message...
if { $::keepalive::config(only_fln) == 0 || [::MSN::myStatusIs] == "FLN" || [::MSN::myStatusIs] == "HDN" || [::abook::getVolatileData $chatid state] == "FLN" } {
# Fires a new after.
monitor_chatid $chatid
::keepalive::send_keepalive_msg $sb
}
}
proc cw_closed {event evpar} {
upvar 2 chatid chatid
stop_monitoring_chatid $chatid
}
proc keepalive_plus_stop {event evpar} {
upvar 2 usr_name usr_name
upvar 2 chatid chatid
upvar 2 win_name win_name
stop_monitoring_chatid $chatid
}
proc deinit { } {
variable monitoredChatIds
foreach chatid [array names monitoredChatIds] {
stop_monitoring_chatid $chatid
}
}
}
|