1
####################################################
2
# This plugin makes aMSN remember any chats open #
3
# so after a crash, your chatwindows state will #
5
# =========================================== #
6
# Karel Demeyer, 2008 #
7
# ============================================ #
8
####################################################
11
namespace eval ::restore {
13
##############################
14
# ::restore::InitPlugin dir #
15
# ---------------------------#
16
# Load proc of restore Plugin #
17
##############################
19
proc initPlugin { dir } {
20
variable chatslist [list ]
24
set filename [file join $HOME storedchats]
27
::plugins::RegisterPlugin "Restore Chats"
28
::plugins::RegisterEvent "Restore Chats" new_conversation addChat
29
::plugins::RegisterEvent "Restore Chats" chatwindow_closed delChat
30
::plugins::RegisterEvent "Restore Chats" contactlistLoaded restoreChats
35
proc addChat { event evpar } {
39
# upvar 2 $newvar(chatid) chat
40
#somehow we can get the value like this without upvar'ing again .. I don't get it :| .. in chatwindow.tcl, the name of the var is passed/stored in the array, not the value. When upvarring, the proc is not further evaluated
41
set chat $newvar(chatid)
42
set chatusers [::MSN::usersInChat $chat]
43
if { $chatusers == "" } {
48
#Don't support groupchats
49
if { [llength $chatusers] != 1 || $chatusers == "chatid"} {
53
lappend chatslist $chatusers
60
proc delChat { event evpar } {
64
upvar 2 $newvar(chatid) chat
65
set chatusers [::MSN::usersInChat $chat]
66
if { $chatusers == "" } {
72
#Don't support groupchats
73
if { [llength $chatusers] != 1 } {
77
set userindex [lsearch $chatslist $chatusers]
78
set chatslist [lreplace $chatslist $userindex $userindex]
84
proc updateOnDiskCopy { } {
90
if { $chatslist == [list ] } {
94
set diskcopy [open $filename w+]
95
puts $diskcopy $chatslist
100
proc restoreChats { { event ""} { evpar ""} } {
105
if { [file exists $filename] } {
106
set diskcopy [open $filename r]
107
set chatslist [read -nonewline $diskcopy]
110
file delete $filename
111
foreach chat $chatslist {
112
::amsn::chatUser $chat