/usr/share/amsn/plugins/countdown/countdown.tcl is in amsn-data 0.98.9-1ubuntu3.
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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | #######################################################
# COUNTDOWN PLUGIN #
#######################################################
#######################################################
namespace eval ::countdown {
variable config
variable configlist
variable language
proc InitPlugin { dir } {
variable config
variable language
variable configlist
variable old_psm
::plugins::RegisterPlugin Countdown
::plugins::RegisterEvent Countdown PluginConfigured ConfigChanged
::plugins::RegisterEvent Countdown contactlistLoaded Connected
array set config [list date "1/1/2009" \
days {1} \
hours {1} \
minutes {1} \
prefixm {} \
suffixm { hours remaining to 2009!} \
prefixm {} \
suffixm { minutes remaining to 2009!} \
prefixd {J-} \
suffixd { days to 2009!} \
after {HAPPY NEW YEAR!!!} \
valid 1]
set langdir [file join $dir "lang"]
set lang [::config::getGlobalKey language]
load_lang en $langdir
load_lang $lang $langdir
set configlist [list \
[list str "[trans date]" date] \
[list label "[trans howtoshow1]"] \
[list label "[trans howtoshow2]"] \
[list bool "[trans showdays]" days] \
[list bool "[trans showhours]" hours] \
[list bool "[trans showminutes]" minutes] \
[list str "[trans prefixd]" prefixd] \
[list str "[trans suffixd]" suffixd] \
[list str "[trans prefixh]" prefixh] \
[list str "[trans suffixh]" suffixh] \
[list str "[trans prefixm]" prefixm] \
[list str "[trans suffixm]" suffixm] \
[list str "[trans after]" after] \
]
set old_psm [::abook::getPersonal PSM]
ValidateDate
AddAfter
after idle ::countdown::DoCountdown
}
proc DeInit { } {
variable old_psm
after cancel ::countdown::DoCountdown
::MSN::changePSM $old_psm
}
proc ConfigChanged { event evpar } {
ValidateDate
AddAfter
after idle ::countdown::DoCountdown
}
proc Connected { event evpar } {
::countdown::DoCountdown
}
proc ValidateDate {} {
variable config
if {[catch {clock scan $config(date)}] } {
msg_box [trans invaliddate]
set config(valid) 0
} else {
set config(valid) 1
}
if { $config(days) == 0 && $config(hours) == 0 && $config(minutes) == 0 } {
msg_box [trans invalidshow]
set config(days) 1
set config(hours) 1
set config(minutes) 1
}
plugins_log Countdown "Validated new date \"$config(date)\" : $config(valid)"
}
proc AddAfter { } {
after cancel ::countdown::DoCountdown
set remaining_secs [expr [clock scan "next minute" -base [clock scan [clock format [clock seconds] -format "%m/%d/%y %H:%M"]]] - [clock seconds]]
set next_minute [expr $remaining_secs * 1000]
plugins_log Countdown "Next minute in $remaining_secs seconds"
after $next_minute ::countdown::DoCountdown
}
proc DoCountdown { } {
variable config
# Invalid date, don't even bother.
if {$config(valid) == 0} {
plugins_log Countdown "Invalid date so returning"
return
}
set dest [clock scan $config(date)]
set seconds [expr $dest - [clock seconds]]
plugins_log Countdown "$seconds seconds remaining for countdown date"
if {$seconds < 0 } {
plugins_log Countdown "Countdown expired"
::MSN::changePSM $config(after)
} else {
set minutes [expr $seconds / 60]
if { $seconds % 60 > 30 } {
incr minutes
}
plugins_log Countdown "$minutes minutes remaining for countdown date"
set hours [expr $minutes / 60]
if { $minutes % 60 > 0 } {
incr hours
}
plugins_log Countdown "$hours hours remaining for countdown date"
set days [expr $hours / 24]
if { $hours % 24 > 0 } {
incr days
}
plugins_log Countdown "$days days remaining for countdown date"
if {$config(days) && ($days > 1 || !$config(hours) && !$config(minutes)) } {
set msg $config(prefixd)
append msg $days
append msg $config(suffixd)
::MSN::changePSM $msg
} elseif {$config(hours) && ($hours > 1 || !$config(minutes))} {
set msg $config(prefixh)
append msg $hours
append msg $config(suffixh)
::MSN::changePSM $msg
} elseif { $config(minutes) } {
set msg $config(prefixm)
append msg $minutes
append msg $config(suffixm)
::MSN::changePSM $msg
}
}
AddAfter
}
}
|