From: <vi...@us...> - 2010-07-28 06:53:57
|
Revision: 12090 http://amsn.svn.sourceforge.net/amsn/?rev=12090&view=rev Author: vivia Date: 2010-07-28 06:53:48 +0000 (Wed, 28 Jul 2010) Log Message: ----------- DPs are successfully fetched using new code Modified Paths: -------------- branches/p2p/gui.tcl branches/p2p/msnp2p/message.tcl branches/p2p/msnp2p/msnobject.tcl branches/p2p/msnp2p/p2p.tcl branches/p2p/msnp2p/session.tcl branches/p2p/msnp2p/session_manager.tcl branches/p2p/msnp2p/slp.tcl branches/p2p/msnp2p/transport/TLP.tcl branches/p2p/msnp2p/transport/TLPv1.tcl branches/p2p/msnp2p/transport/base.tcl branches/p2p/msnp2p/transport/switchboard.tcl branches/p2p/msnp2p/transport/transport_manager.tcl branches/p2p/msnp2p.tcl branches/p2p/protocol.tcl Modified: branches/p2p/gui.tcl =================================================================== --- branches/p2p/gui.tcl 2010-07-27 20:33:17 UTC (rev 12089) +++ branches/p2p/gui.tcl 2010-07-28 06:53:48 UTC (rev 12090) @@ -844,6506 +844,6562 @@ set buttons [list [list "ok" [trans ok]]] } okcancel { - set buttons [list [list "ok" [trans ok]] [list "cancel" [trans cancel]]] + set buttons [list [list "ok" [trans ok]] [list "cancel" [trans cancel]]] + } + retrycancel { + set buttons [list [list "retry" [trans retry]] [list "cancel" [trans cancel]]] + } + yesno { + set buttons [list [list "yes" [trans yes]] [list "no" [trans no]]] + } + yesnocancel { + set buttons [list [list "yes" [trans yes]] [list "no" [trans no]] [list "cancel" [trans cancel]]] + } + deletecancel { + set buttons [list [list "delete" [trans delete]] [list "cancel" [trans cancel]]] + } + deleteblockcancel { + set buttons [list [list "delete" [trans delete]] [list "deleteblock" [trans deleteblock]] [list "cancel" [trans cancel]]] + } + default { + set buttons [list [list "ok" [trans ok]]] + } } - retrycancel { - set buttons [list [list "retry" [trans retry]] [list "cancel" [trans cancel]]] + + set customMessageBoxAnswerTracker($uniqueId) "" + + #Create the buttons + foreach button $buttons { + set buttonName [lindex $button 0] + set buttonLabel [lindex $button 1] + button $w.buttons.$buttonName -text $buttonLabel -command [list set customMessageBoxAnswerTracker($uniqueId) $buttonName] + pack $w.buttons.$buttonName -pady 0 -padx 0 -side right } - yesno { - set buttons [list [list "yes" [trans yes]] [list "no" [trans no]]] - } - yesnocancel { - set buttons [list [list "yes" [trans yes]] [list "no" [trans no]] [list "cancel" [trans cancel]]] - } - deletecancel { - set buttons [list [list "delete" [trans delete]] [list "cancel" [trans cancel]]] - } - deleteblockcancel { - set buttons [list [list "delete" [trans delete]] [list "deleteblock" [trans deleteblock]] [list "cancel" [trans cancel]]] - } - default { - set buttons [list [list "ok" [trans ok]]] - } - } - set customMessageBoxAnswerTracker($uniqueId) "" + #Pack frames + pack $w.top -pady 12 -padx 12 -side top + pack $w.buttons -pady 12 -padx 12 -fill x - #Create the buttons - foreach button $buttons { - set buttonName [lindex $button 0] - set buttonLabel [lindex $button 1] - button $w.buttons.$buttonName -text $buttonLabel -command [list set customMessageBoxAnswerTracker($uniqueId) $buttonName] - pack $w.buttons.$buttonName -pady 0 -padx 0 -side right - } + moveinscreen $w 30 + bind $w <<Escape>> "destroy $w" + wm protocol $w WM_DELETE_WINDOW [list set customMessageBoxAnswerTracker($uniqueId) ""] - #Pack frames - pack $w.top -pady 12 -padx 12 -side top - pack $w.buttons -pady 12 -padx 12 -fill x + set oldgrab "" + if { $modal } { + set oldgrab [grab current] + grab set $w + } - moveinscreen $w 30 - bind $w <<Escape>> "destroy $w" - wm protocol $w WM_DELETE_WINDOW [list set customMessageBoxAnswerTracker($uniqueId) ""] + tkwait variable customMessageBoxAnswerTracker($uniqueId) - set oldgrab "" - if { $modal } { - set oldgrab [grab current] - grab set $w - } + if { $oldgrab != "" } { + grab set $oldgrab + } - tkwait variable customMessageBoxAnswerTracker($uniqueId) + catch { destroy $w } + if {$askRememberAnswer != 0} { + set answer [list $customMessageBoxAnswerTracker($uniqueId) $customMessageBoxRememberTracker($uniqueId)] + unset customMessageBoxAnswerTracker($uniqueId) + unset customMessageBoxRememberTracker($uniqueId) + } else { + set answer $customMessageBoxAnswerTracker($uniqueId) + unset customMessageBoxAnswerTracker($uniqueId) + } - if { $oldgrab != "" } { - grab set $oldgrab + return $answer } + #/////////////////////////////////////////////////////////////////////////////// - catch { destroy $w } - if {$askRememberAnswer != 0} { - set answer [list $customMessageBoxAnswerTracker($uniqueId) $customMessageBoxRememberTracker($uniqueId)] - unset customMessageBoxAnswerTracker($uniqueId) - unset customMessageBoxRememberTracker($uniqueId) - } else { - set answer $customMessageBoxAnswerTracker($uniqueId) - unset customMessageBoxAnswerTracker($uniqueId) + #/////////////////////////////////////////////////////////////////////////////// + # Shows the error message specified by "msg" + proc errorMsg { msg } { + ::amsn::messageBox $msg ok error "[trans title] Error" } + #/////////////////////////////////////////////////////////////////////////////// - return $answer - } - #/////////////////////////////////////////////////////////////////////////////// + #/////////////////////////////////////////////////////////////////////////////// + # Shows the error message specified by "msg" + proc infoMsg { msg {icon "info"} } { + ::amsn::messageBox $msg ok $icon [trans title] + } + #/////////////////////////////////////////////////////////////////////////////// - #/////////////////////////////////////////////////////////////////////////////// - # Shows the error message specified by "msg" - proc errorMsg { msg } { - ::amsn::messageBox $msg ok error "[trans title] Error" - } - #/////////////////////////////////////////////////////////////////////////////// - - #/////////////////////////////////////////////////////////////////////////////// - # Shows the error message specified by "msg" - proc infoMsg { msg {icon "info"} } { - ::amsn::messageBox $msg ok $icon [trans title] - } - #/////////////////////////////////////////////////////////////////////////////// - - #/////////////////////////////////////////////////////////////////////////////// - proc blockUnblockUser { user_login } { - if { [::MSN::userIsBlocked $user_login] } { - unblockUser $user_login - } else { - blockUser $user_login + #/////////////////////////////////////////////////////////////////////////////// + proc blockUnblockUser { user_login } { + if { [::MSN::userIsBlocked $user_login] } { + unblockUser $user_login + } else { + blockUser $user_login + } } - } - #/////////////////////////////////////////////////////////////////////////////// + #/////////////////////////////////////////////////////////////////////////////// - #/////////////////////////////////////////////////////////////////////////////// - proc blockUser {user_login} { - set answer [::amsn::messageBox "[trans confirmbl] ($user_login)" yesno question [trans block]] - if { $answer == "yes"} { - set name [::abook::getNick ${user_login}] - ::MSN::blockUser ${user_login} + #/////////////////////////////////////////////////////////////////////////////// + proc blockUser {user_login} { + set answer [::amsn::messageBox "[trans confirmbl] ($user_login)" yesno question [trans block]] + if { $answer == "yes"} { + set name [::abook::getNick ${user_login}] + ::MSN::blockUser ${user_login} + } } - } - #/////////////////////////////////////////////////////////////////////////////// + #/////////////////////////////////////////////////////////////////////////////// - #/////////////////////////////////////////////////////////////////////////////// - proc unblockUser {user_login} { - set name [::abook::getNick ${user_login}] - ::MSN::unblockUser ${user_login} - } - #/////////////////////////////////////////////////////////////////////////////// - - - #/////////////////////////////////////////////////////////////////////////////// - proc removeUserFromGroup {user_login grId} { - ::MSN::removeUserFromGroup $user_login $grId - } - #/////////////////////////////////////////////////////////////////////////////// - - - #/////////////////////////////////////////////////////////////////////////////// - #Delete user window, user can choose to delete user, cancel the action or block and delete the user - proc deleteUser { user_login } { - if {[lsearch [::abook::getLists $user_login] BL] == -1} { - # User is not blocked. - set type deleteblockcancel - } else { - # User is already blocked. - set type deletecancel - } - if {[::MSN::userIsNotIM $user_login] } { - set answer [customMessageBox [trans confirmdu] $type "" "[trans delete] - $user_login" "." 0] - set fulldelete 1 - } else { - set answer [customMessageBox [trans confirmdu] $type "" "[trans delete] - $user_login" "." confirmfulldelete] - foreach {answer fulldelete} $answer break - } - if {$answer == "deleteblock"} { - # Delete the user and block. - ::amsn::deleteUserAction $user_login 1 $fulldelete - } elseif {$answer == "delete"} { - # Only delete the user. - ::amsn::deleteUserAction $user_login 0 $fulldelete - } - } - - #/////////////////////////////////////////////////////////////////////////////// - # deleteUserAction {user_login answer grId block} - # Action to do when someone click delete a user - proc deleteUserAction {user_login {block 0} {full 0}} { - #If the user wants to delete AND block a user - if { $block == 1 } { + #/////////////////////////////////////////////////////////////////////////////// + proc unblockUser {user_login} { set name [::abook::getNick ${user_login}] - ::MSN::blockUser ${user_login} + ::MSN::unblockUser ${user_login} } + #/////////////////////////////////////////////////////////////////////////////// - ::MSN::deleteUser ${user_login} $full - ::abook::setContactData $user_login alarms "" - - return - } - - - proc InkSend { win_name filename {friendlyname ""}} { - set chatid [::ChatWindow::Name $win_name] - - if { $chatid == 0 } { - status_log "VERY BAD ERROR in ::amsn::InkSend!!!\n" red - return 0 + + #/////////////////////////////////////////////////////////////////////////////// + proc removeUserFromGroup {user_login grId} { + ::MSN::removeUserFromGroup $user_login $grId } + #/////////////////////////////////////////////////////////////////////////////// - #Blank ink - if {$filename == ""} { return 0 } - if { $friendlyname != "" } { - set nick $friendlyname - set p4c 1 - } elseif { [::abook::getContactData [::ChatWindow::Name $win_name] cust_p4c_name] != ""} { - set friendlyname [::abook::parseCustomNick [::abook::getContactData [::ChatWindow::Name $win_name] cust_p4c_name] [::abook::getPersonal MFN] [::abook::getPersonal login] "" [::abook::getpsmmedia] ] - set nick $friendlyname - set p4c 1 - } elseif { [::config::getKey p4c_name] != ""} { - set nick [::config::getKey p4c_name] - set p4c 1 - } else { - set nick [::abook::getPersonal MFN] - set p4c 0 + #/////////////////////////////////////////////////////////////////////////////// + #Delete user window, user can choose to delete user, cancel the action or block and delete the user + proc deleteUser { user_login } { + if {[lsearch [::abook::getLists $user_login] BL] == -1} { + # User is not blocked. + set type deleteblockcancel + } else { + # User is already blocked. + set type deletecancel + } + if {[::MSN::userIsNotIM $user_login] } { + set answer [customMessageBox [trans confirmdu] $type "" "[trans delete] - $user_login" "." 0] + set fulldelete 1 + } else { + set answer [customMessageBox [trans confirmdu] $type "" "[trans delete] - $user_login" "." confirmfulldelete] + foreach {answer fulldelete} $answer break + } + if {$answer == "deleteblock"} { + # Delete the user and block. + ::amsn::deleteUserAction $user_login 1 $fulldelete + } elseif {$answer == "delete"} { + # Only delete the user. + ::amsn::deleteUserAction $user_login 0 $fulldelete + } } - #Postevent when we send a message - set evPar(nick) nick - set evPar(ink) filename - set evPar(chatid) chatid - set evPar(win_name) win_name - ::plugins::PostEvent chat_ink_send evPar - #Draw our own message - #Does this image ever gets destroyed ? When destroying the chatwindow it's embeddeed in it should I guess ? This is not the leak I'm searching for though as I'm not sending inks... - # don't try to display it if the image is considered as invalid - if {[catch {set img [image create photo [TmpImgName] -file $filename]}]} { - status_log "(::amsn::InkSend) trying to display an invalid image, but keep sending it." red - } else { - SendMessageFIFO [list ::amsn::ShowInk $chatid [::abook::getPersonal login] $nick $img ink $p4c] "::amsn::messages_stack($chatid)" "::amsn::messages_flushing($chatid)" - } - ::MSN::ChatQueue $chatid [list ::MSN::SendInk $chatid $filename] + #/////////////////////////////////////////////////////////////////////////////// + # deleteUserAction {user_login answer grId block} + # Action to do when someone click delete a user + proc deleteUserAction {user_login {block 0} {full 0}} { + #If the user wants to delete AND block a user + if { $block == 1 } { + set name [::abook::getNick ${user_login}] + ::MSN::blockUser ${user_login} + } - ::plugins::PostEvent chat_ink_sent evPar - } + ::MSN::deleteUser ${user_login} $full + ::abook::setContactData $user_login alarms "" - proc InviteCallFromCW {win_name video} { - if {![winfo exists $win_name] } { - set win_name [::amsn::chatUser $win_name] + return } - set chatid [::ChatWindow::Name $win_name] - status_log "chatid:=$chatid" red + + proc WriteNewData { msnobj } { - set users [::MSN::usersInChat $chatid] + #@@@@@@@@@@@@@ + global HOME + set user_login [$msnobj cget -creator] + set type [$msnobj cget -type] + set data [$msnobj cget -data] + set filename2 [$msnobj cget -location] + status_log "Got data from $user_login in $filename2" + set filename [::abook::getContactData $user_login displaypicfile ""] + if { $filename != $filename2 } { + create_dir [file join $HOME displaypic cache] + create_dir [file join $HOME displaypic cache $user_login] + set fd [open "[file join $HOME displaypic cache $user_login ${filename}.png]" w] + fconfigure $fd -translation {binary binary} + puts -nonewline $fd $data + close $fd + ::skin::getDisplayPicture $user_login 1 + ::amsn::UpdateAllPictures + set desc_file "[file join $HOME displaypic cache $user_login ${filename}.dat]" + create_dir [file join $HOME displaypic] + set fd [open [file join $HOME displaypic $desc_file] w] + status_log "Writing description to $desc_file\n" + puts $fd "[clock seconds]\n$user_login" + close $fd + ::Event::fireEvent contactDPChange protocol $user_login + } else { + create_dir [file join $HOME smileys cache] + set fd [open "[file join $HOME smileys cache ${filename}.png]" w] + fconfigure $fd -translation {binary binary} + puts -nonewline $fd $data + close $fd + image create photo emoticonCustom_std_$filename -file "[file join $HOME smileys cache ${filename}].png" -format cximage + } - if {[llength $users] > 1} { - #TODO: add a new key? - ::amsn::errorMsg [trans sipcallyouarebusy2] - } elseif {[llength $users] == 1} { - ::amsn::SIPCallInviteUser $video [lindex $users 0] - } else { - ::amsn::SIPCallInviteUser $video $chatid } - } - proc FileTransferSend { win_name {filename ""} } { - if {![winfo exists $win_name] } { - set win_name [::amsn::chatUser $win_name] - } - - global starting_dir + proc InkSend { win_name filename {friendlyname ""}} { + set chatid [::ChatWindow::Name $win_name] -# set filename [ $w.top.fields.file get ] - if { $filename == "" } { - set filename [chooseFileDialog "" [trans sendfile] $win_name] - status_log $filename - } + if { $chatid == 0 } { + status_log "VERY BAD ERROR in ::amsn::InkSend!!!\n" red + return 0 + } - if { $filename == "" } { return } + #Blank ink + if {$filename == ""} { return 0 } - #Remember last directory - set starting_dir [file dirname $filename] + if { $friendlyname != "" } { + set nick $friendlyname + set p4c 1 + } elseif { [::abook::getContactData [::ChatWindow::Name $win_name] cust_p4c_name] != ""} { + set friendlyname [::abook::parseCustomNick [::abook::getContactData [::ChatWindow::Name $win_name] cust_p4c_name] [::abook::getPersonal MFN] [::abook::getPersonal login] "" [::abook::getpsmmedia] ] + set nick $friendlyname + set p4c 1 + } elseif { [::config::getKey p4c_name] != ""} { + set nick [::config::getKey p4c_name] + set p4c 1 + } else { + set nick [::abook::getPersonal MFN] + set p4c 0 + } + #Postevent when we send a message + set evPar(nick) nick + set evPar(ink) filename + set evPar(chatid) chatid + set evPar(win_name) win_name + ::plugins::PostEvent chat_ink_send evPar - if {![file readable $filename]} { - msg_box "[trans invalidfile [trans filename] $filename]" - return - } + #Draw our own message + #Does this image ever gets destroyed ? When destroying the chatwindow it's embeddeed in it should I guess ? This is not the leak I'm searching for though as I'm not sending inks... + # don't try to display it if the image is considered as invalid + if {[catch {set img [image create photo [TmpImgName] -file $filename]}]} { + status_log "(::amsn::InkSend) trying to display an invalid image, but keep sending it." red + } else { + SendMessageFIFO [list ::amsn::ShowInk $chatid [::abook::getPersonal login] $nick $img ink $p4c] "::amsn::messages_stack($chatid)" "::amsn::messages_flushing($chatid)" + } + ::MSN::ChatQueue $chatid [list ::MSN::SendInk $chatid $filename] - if { [::config::getKey autoftip] } { - set ipaddr [::config::getKey myip] - } else { - set ipaddr [::config::getKey manualip] + ::plugins::PostEvent chat_ink_sent evPar } - if { [catch {set filesize [file size $filename]} res]} { - ::amsn::errorMsg "[trans filedoesnotexist]" - #::amsn::fileTransferProgress c $cookie -1 -1 - return 1 + proc InviteCallFromCW {win_name video} { + if {![winfo exists $win_name] } { + set win_name [::amsn::chatUser $win_name] + } + set chatid [::ChatWindow::Name $win_name] + status_log "chatid:=$chatid" red + + set users [::MSN::usersInChat $chatid] + + if {[llength $users] > 1} { + #TODO: add a new key? + ::amsn::errorMsg [trans sipcallyouarebusy2] + } elseif {[llength $users] == 1} { + ::amsn::SIPCallInviteUser $video [lindex $users 0] + } else { + ::amsn::SIPCallInviteUser $video $chatid + } } - set chatid [::ChatWindow::Name $win_name] - status_log "chatid:=$chatid" red + proc FileTransferSend { win_name {filename ""} } { + if {![winfo exists $win_name] } { + set win_name [::amsn::chatUser $win_name] + } + + global starting_dir - set users [::MSN::usersInChat $chatid] + # set filename [ $w.top.fields.file get ] + if { $filename == "" } { + set filename [chooseFileDialog "" [trans sendfile] $win_name] + status_log $filename + } + if { $filename == "" } { return } - foreach chatid $users { - chatUser $chatid + #Remember last directory + set starting_dir [file dirname $filename] - #Calculate a random cookie - set cookie [expr {([clock clicks]) % (65536 * 8)}] - set txt "[trans ftsendinvitation [::abook::getDisplayNick $chatid] $filename [::amsn::sizeconvert $filesize]]" - + if {![file readable $filename]} { + msg_box "[trans invalidfile [trans filename] $filename]" + return + } - status_log "Random generated cookie: $cookie\n" - SendMessageFIFO [list ::amsn::WinWriteFTSend $chatid $txt $cookie] "::amsn::messages_stack($chatid)" "::amsn::messages_flushing($chatid)" + if { [::config::getKey autoftip] } { + set ipaddr [::config::getKey myip] + } else { + set ipaddr [::config::getKey manualip] + } - ::MSN::ChatQueue $chatid [list ::MSNFT::sendFTInvitation $chatid $filename $filesize $ipaddr $cookie] - #::MSNFT::sendFTInvitation $chatid $filename $filesize $ipaddr $cookie + if { [catch {set filesize [file size $filename]} res]} { + ::amsn::errorMsg "[trans filedoesnotexist]" + #::amsn::fileTransferProgress c $cookie -1 -1 + return 1 + } - ::log::ftlog $chatid $txt + set chatid [::ChatWindow::Name $win_name] + status_log "chatid:=$chatid" red - # Postevent when we send a file transfer invitation - set evPar(chatid) $chatid - set evPar(filename) $filename - ::plugins::PostEvent sent_ft_invite evPar - } - return 0 - } + set users [::MSN::usersInChat $chatid] - proc WinWriteFTSend { chatid txt cookie } { - WinWrite $chatid "\n" green - WinWriteIcon $chatid greyline 3 - WinWrite $chatid "\n" green - WinWriteIcon $chatid fticon 3 2 - WinWrite $chatid "$txt " green - WinWriteClickable $chatid "[trans cancel]" \ - "::amsn::CancelFTInvitation $chatid $cookie" ftno$cookie - WinWrite $chatid "\n" green - WinWriteIcon $chatid greyline 3 - } - proc DisableCancelText { cookie chatid } { + foreach chatid $users { + chatUser $chatid - set win_name [::ChatWindow::For $chatid] - if { [winfo exists $win_name] } { - [::ChatWindow::GetOutText ${win_name}] tag configure ftno$cookie \ - -foreground #808080 -font bplainf -underline false - [::ChatWindow::GetOutText ${win_name}] tag bind ftno$cookie <Enter> "" - [::ChatWindow::GetOutText ${win_name}] tag bind ftno$cookie <Leave> "" - [::ChatWindow::GetOutText ${win_name}] tag bind ftno$cookie <<Button1>> "" + #Calculate a random cookie + set cookie [expr {([clock clicks]) % (65536 * 8)}] + set txt "[trans ftsendinvitation [::abook::getDisplayNick $chatid] $filename [::amsn::sizeconvert $filesize]]" + - [::ChatWindow::GetOutText ${win_name}] conf -cursor xterm - } + status_log "Random generated cookie: $cookie\n" + SendMessageFIFO [list ::amsn::WinWriteFTSend $chatid $txt $cookie] "::amsn::messages_stack($chatid)" "::amsn::messages_flushing($chatid)" - } + ::MSN::ChatQueue $chatid [list ::MSNFT::sendFTInvitation $chatid $filename $filesize $ipaddr $cookie] + #::MSNFT::sendFTInvitation $chatid $filename $filesize $ipaddr $cookie - proc CancelFTInvitation { chatid cookie } { - #::MSNFT::acceptFT $chatid $cookie + ::log::ftlog $chatid $txt - set win_name [::ChatWindow::For $chatid] - if { [::ChatWindow::For $chatid] == 0} { + # Postevent when we send a file transfer invitation + set evPar(chatid) $chatid + set evPar(filename) $filename + ::plugins::PostEvent sent_ft_invite evPar + } return 0 } - ::MSNFT::cancelFTInvitation $chatid $cookie - DisableCancelText $cookie $chatid + proc WinWriteFTSend { chatid txt cookie } { + WinWrite $chatid "\n" green + WinWriteIcon $chatid greyline 3 + WinWrite $chatid "\n" green + WinWriteIcon $chatid fticon 3 2 + WinWrite $chatid "$txt " green + WinWriteClickable $chatid "[trans cancel]" \ + "::amsn::CancelFTInvitation $chatid $cookie" ftno$cookie + WinWrite $chatid "\n" green + WinWriteIcon $chatid greyline 3 + } - set txt [trans invitationcancelled] + proc DisableCancelText { cookie chatid } { - SendMessageFIFO [list ::amsn::WinWriteCancelFT $chatid $txt] "::amsn::messages_stack($chatid)" "::amsn::messages_flushing($chatid)" + set win_name [::ChatWindow::For $chatid] + if { [winfo exists $win_name] } { + [::ChatWindow::GetOutText ${win_name}] tag configure ftno$cookie \ + -foreground #808080 -font bplainf -underline false + [::ChatWindow::GetOutText ${win_name}] tag bind ftno$cookie <Enter> "" + [::ChatWindow::GetOutText ${win_name}] tag bind ftno$cookie <Leave> "" + [::ChatWindow::GetOutText ${win_name}] tag bind ftno$cookie <<Button1>> "" - set email [::MSN::usersInChat $chatid] - ::log::ftlog $email $txt - } + [::ChatWindow::GetOutText ${win_name}] conf -cursor xterm + } - proc WinWriteCancelFT {chatid txt} { - WinWrite $chatid "\n" green - WinWriteIcon $chatid greyline 3 - WinWrite $chatid "\n" green - WinWriteIcon $chatid ftreject 3 2 - WinWrite $chatid " $txt\n" green - WinWriteIcon $chatid greyline 3 - } - - proc acceptedFT { chatid who filename } { - set win_name [::ChatWindow::For $chatid] - if { [::ChatWindow::For $chatid] == 0} { - return 0 } - set txt [trans ftacceptedby [::abook::getDisplayNick $chatid] $filename] - WinWrite $chatid "\n" green - WinWriteIcon $chatid greyline 3 - WinWrite $chatid "\n" green - WinWriteIcon $chatid fticon 3 2 - WinWrite $chatid " $txt\n" green - WinWriteIcon $chatid greyline 3 + proc CancelFTInvitation { chatid cookie } { + #::MSNFT::acceptFT $chatid $cookie - set email [::MSN::usersInChat $chatid] - ::log::ftlog $email $txt - } + set win_name [::ChatWindow::For $chatid] + if { [::ChatWindow::For $chatid] == 0} { + return 0 + } - proc rejectedFT { chatid who filename } { - set win_name [::ChatWindow::For $chatid] - if { [::ChatWindow::For $chatid] == 0} { - return 0 + ::MSNFT::cancelFTInvitation $chatid $cookie + DisableCancelText $cookie $chatid + + set txt [trans invitationcancelled] + + SendMessageFIFO [list ::amsn::WinWriteCancelFT $chatid $txt] "::amsn::messages_stack($chatid)" "::amsn::messages_flushing($chatid)" + + set email [::MSN::usersInChat $chatid] + ::log::ftlog $email $txt } - set txt [trans ftrejectedby [::abook::getDisplayNick $chatid] $filename] - WinWrite $chatid "\n" green - WinWriteIcon $chatid greyline 3 - WinWrite $chatid " \n" green - WinWriteIcon $chatid ftreject 3 2 - WinWrite $chatid " $txt\n" green - WinWriteIcon $chatid greyline 3 + proc WinWriteCancelFT {chatid txt} { + WinWrite $chatid "\n" green + WinWriteIcon $chatid greyline 3 + WinWrite $chatid "\n" green + WinWriteIcon $chatid ftreject 3 2 + WinWrite $chatid " $txt\n" green + WinWriteIcon $chatid greyline 3 + } - set email [::MSN::usersInChat $chatid] - ::log::ftlog $email $txt - } + proc acceptedFT { chatid who filename } { + set win_name [::ChatWindow::For $chatid] + if { [::ChatWindow::For $chatid] == 0} { + return 0 + } + set txt [trans ftacceptedby [::abook::getDisplayNick $chatid] $filename] - #//////////////////////////////////////////////////////////////////////////////// - # GotFileTransferRequest ( chatid dest branchuid cseq uid sid filename filesize) - # This procedure is called when we receive an MSN6 File Transfer Request - proc GotFileTransferRequest { chatid dest branchuid cseq uid sid filename filesize} { - set win_name [::ChatWindow::For $chatid] + WinWrite $chatid "\n" green + WinWriteIcon $chatid greyline 3 + WinWrite $chatid "\n" green + WinWriteIcon $chatid fticon 3 2 + WinWrite $chatid " $txt\n" green + WinWriteIcon $chatid greyline 3 - if { [::ChatWindow::For $chatid] == 0} { - return 0 + set email [::MSN::usersInChat $chatid] + ::log::ftlog $email $txt } - set semic [string first ";" $dest] - if { $semic > 0 } { - set dest [string range $dest 0 [expr {$semic - 1}]] - } + proc rejectedFT { chatid who filename } { + set win_name [::ChatWindow::For $chatid] + if { [::ChatWindow::For $chatid] == 0} { + return 0 + } + set txt [trans ftrejectedby [::abook::getDisplayNick $chatid] $filename] - set fromname [::abook::getDisplayNick $dest] - set txt [trans ftgotinvitation $fromname '$filename' [::amsn::sizeconvert $filesize] [::config::getKey receiveddir]] - set win_name [::ChatWindow::MakeFor $chatid $txt $dest] - WinWrite $chatid "\n" green - WinWriteIcon $chatid greyline 3 - WinWrite $chatid " \n" green + WinWrite $chatid "\n" green + WinWriteIcon $chatid greyline 3 + WinWrite $chatid " \n" green + WinWriteIcon $chatid ftreject 3 2 + WinWrite $chatid " $txt\n" green + WinWriteIcon $chatid greyline 3 - if { [::skin::loadPixmap "FT_preview_${sid}"] != "" } { - WinWriteIcon $chatid FT_preview_${sid} 5 5 - WinWrite $chatid "\n" green + set email [::MSN::usersInChat $chatid] + ::log::ftlog $email $txt } - WinWriteIcon $chatid fticon 3 2 - WinWrite $chatid $txt green - WinWrite $chatid " - (" green - WinWriteClickable $chatid "[trans accept]" [list ::amsn::AcceptFT $chatid -1 [list $dest $branchuid $cseq $uid $sid $filename]] ftyes$sid - WinWrite $chatid " / " green - WinWriteClickable $chatid "[trans saveas]" [list ::amsn::SaveAsFT $chatid -1 [list $dest $branchuid $cseq $uid $sid $filename]] ftsaveas$sid - WinWrite $chatid " / " green - WinWriteClickable $chatid "[trans reject]" [list ::amsn::RejectFT $chatid -1 [list $sid $branchuid $uid]] ftno$sid - WinWrite $chatid ")\n" green - WinWriteIcon $chatid greyline 3 + #//////////////////////////////////////////////////////////////////////////////// + # GotFileTransferRequest ( chatid dest branchuid cseq uid sid filename filesize) + # This procedure is called when we receive an MSN6 File Transfer Request + proc GotFileTransferRequest { chatid dest branchuid cseq uid sid filename filesize} { + set win_name [::ChatWindow::For $chatid] - ::log::ftlog $dest $txt + if { [::ChatWindow::For $chatid] == 0} { + return 0 + } - if { ![file writable [::config::getKey receiveddir]]} { - WinWrite $chatid "\n[trans readonlywarn [::config::getKey receiveddir]]\n" red + set semic [string first ";" $dest] + if { $semic > 0 } { + set dest [string range $dest 0 [expr {$semic - 1}]] + } + + set fromname [::abook::getDisplayNick $dest] + set txt [trans ftgotinvitation $fromname '$filename' [::amsn::sizeconvert $filesize] [::config::getKey receiveddir]] + set win_name [::ChatWindow::MakeFor $chatid $txt $dest] + WinWrite $chatid "\n" green WinWriteIcon $chatid greyline 3 + WinWrite $chatid " \n" green + + if { [::skin::loadPixmap "FT_preview_${sid}"] != "" } { + WinWriteIcon $chatid FT_preview_${sid} 5 5 + WinWrite $chatid "\n" green } - if { [::config::getKey ftautoaccept] == 1 || [::abook::getContactData $dest autoacceptft] == 1 } { - WinWrite $chatid "\n[trans autoaccepted]" green - ::amsn::AcceptFT $chatid -1 [list $dest $branchuid $cseq $uid $sid $filename] - } - } + WinWriteIcon $chatid fticon 3 2 + WinWrite $chatid $txt green + WinWrite $chatid " - (" green + WinWriteClickable $chatid "[trans accept]" [list ::amsn::AcceptFT $chatid -1 [list $dest $branchuid $cseq $uid $sid $filename]] ftyes$sid + WinWrite $chatid " / " green + WinWriteClickable $chatid "[trans saveas]" [list ::amsn::SaveAsFT $chatid -1 [list $dest $branchuid $cseq $uid $sid $filename]] ftsaveas$sid + WinWrite $chatid " / " green + WinWriteClickable $chatid "[trans reject]" [list ::amsn::RejectFT $chatid -1 [list $sid $branchuid $uid]] ftno$sid + WinWrite $chatid ")\n" green + WinWriteIcon $chatid greyline 3 - #Message shown when receiving a file - proc fileTransferRecv {filename filesize cookie chatid fromlogin} { - set win_name [::ChatWindow::For $chatid] - if { [::ChatWindow::For $chatid] == 0} { - return 0 - } + ::log::ftlog $dest $txt - set semic [string first ";" $fromlogin] - if { $semic > 0 } { - set fromlogin [string range $fromlogin 0 [expr {$semic - 1}]] + if { ![file writable [::config::getKey receiveddir]]} { + WinWrite $chatid "\n[trans readonlywarn [::config::getKey receiveddir]]\n" red + WinWriteIcon $chatid greyline 3 + } + + if { [::config::getKey ftautoaccept] == 1 || [::abook::getContactData $dest autoacceptft] == 1 } { + WinWrite $chatid "\n[trans autoaccepted]" green + ::amsn::AcceptFT $chatid -1 [list $dest $branchuid $cseq $uid $sid $filename] + } } - set fromname [::abook::getDisplayNick $fromlogin] - set txt [trans ftgotinvitation $fromname '$filename' [::amsn::sizeconvert $filesize] [::config::getKey receiveddir]] + #Message shown when receiving a file + proc fileTransferRecv {filename filesize cookie chatid fromlogin} { + set win_name [::ChatWindow::For $chatid] + if { [::ChatWindow::For $chatid] == 0} { + return 0 + } - set win_name [::ChatWindow::MakeFor $chatid $txt $fromlogin] + set semic [string first ";" $fromlogin] + if { $semic > 0 } { + set fromlogin [string range $fromlogin 0 [expr {$semic - 1}]] + } - WinWrite $chatid "\n" green - WinWriteIcon $chatid greyline 3 - WinWrite $chatid "\n" green - WinWriteIcon $chatid fticon 3 2 - WinWrite $chatid $txt green - WinWrite $chatid " - (" green - WinWriteClickable $chatid "[trans accept]" \ - "::amsn::AcceptFT $chatid $cookie" ftyes$cookie - WinWrite $chatid " / " green - WinWriteClickable $chatid "[trans saveas]" \ - "::amsn::SaveAsFT $chatid $cookie" ftsaveas$cookie - WinWrite $chatid " / " green - WinWriteClickable $chatid "[trans reject]" \ - "::amsn::RejectFT $chatid $cookie" ftno$cookie - WinWrite $chatid ")\n" green - WinWriteIcon $chatid greyline 3 + set fromname [::abook::getDisplayNick $fromlogin] + set txt [trans ftgotinvitation $fromname '$filename' [::amsn::sizeconvert $filesize] [::config::getKey receiveddir]] - ::log::ftlog $fromlogin $txt + set win_name [::ChatWindow::MakeFor $chatid $txt $fromlogin] - if { ![file writable [::config::getKey receiveddir]]} { - WinWrite $chatid "\n[trans readonlywarn [::config::getKey receiveddir]]\n" red + WinWrite $chatid "\n" green WinWriteIcon $chatid greyline 3 - } + WinWrite $chatid "\n" green + WinWriteIcon $chatid fticon 3 2 + WinWrite $chatid $txt green + WinWrite $chatid " - (" green + WinWriteClickable $chatid "[trans accept]" \ + "::amsn::AcceptFT $chatid $cookie" ftyes$cookie + WinWrite $chatid " / " green + WinWriteClickable $chatid "[trans saveas]" \ + "::amsn::SaveAsFT $chatid $cookie" ftsaveas$cookie + WinWrite $chatid " / " green + WinWriteClickable $chatid "[trans reject]" \ + "::amsn::RejectFT $chatid $cookie" ftno$cookie + WinWrite $chatid ")\n" green + WinWriteIcon $chatid greyline 3 - if { [::config::getKey ftautoaccept] == 1 || [::abook::getContactData $fromlogin autoacceptft] == 1 } { - WinWrite $chatid "\n[trans autoaccepted]" green - ::amsn::AcceptFT $chatid $cookie - } - } + ::log::ftlog $fromlogin $txt - proc AcceptFTOpenSB { chatid cookie {varlist ""} } { - #::amsn::RecvWin $cookie - if { $cookie != -1 } { - ::MSNFT::acceptFT $chatid $cookie - } else { - ::MSN6FT::AcceptFT $chatid [lindex $varlist 0] [lindex $varlist 1] [lindex $varlist 2] [lindex $varlist 3] [lindex $varlist 4] [lindex $varlist 5] - set cookie [lindex $varlist 4] + if { ![file writable [::config::getKey receiveddir]]} { + WinWrite $chatid "\n[trans readonlywarn [::config::getKey receiveddir]]\n" red + WinWriteIcon $chatid greyline 3 + } + + if { [::config::getKey ftautoaccept] == 1 || [::abook::getContactData $fromlogin autoacceptft] == 1 } { + WinWrite $chatid "\n[trans autoaccepted]" green + ::amsn::AcceptFT $chatid $cookie + } } - } - proc AcceptFT { chatid cookie {varlist ""} } { - foreach var $varlist { - status_log "Var: $var\n" red + proc AcceptFTOpenSB { chatid cookie {varlist ""} } { + #::amsn::RecvWin $cookie + if { $cookie != -1 } { + ::MSNFT::acceptFT $chatid $cookie + } else { + ::MSN6FT::AcceptFT $chatid [lindex $varlist 0] [lindex $varlist 1] [lindex $varlist 2] [lindex $varlist 3] [lindex $varlist 4] [lindex $varlist 5] + set cookie [lindex $varlist 4] + } } - set chatid [::MSN::chatTo $chatid] + proc AcceptFT { chatid cookie {varlist ""} } { + foreach var $varlist { + status_log "Var: $var\n" red + } - ::MSN::ChatQueue $chatid [list ::amsn::AcceptFTOpenSB $chatid $cookie $varlist] + set chatid [::MSN::chatTo $chatid] - set win_name [::ChatWindow::For $chatid] - if { [::ChatWindow::For $chatid] == 0} { - return 0 - } + ::MSN::ChatQueue $chatid [list ::amsn::AcceptFTOpenSB $chatid $cookie $varlist] - if { $cookie == -1 } { - set cookie [lindex $varlist 4] - } + set win_name [::ChatWindow::For $chatid] + if { [::ChatWindow::For $chatid] == 0} { + return 0 + } - [::ChatWindow::GetOutText ${win_name}] tag configure ftyes$cookie \ - -foreground #808080 -font bplainf -underline false - [::ChatWindow::GetOutText ${win_name}] tag bind ftyes$cookie <Enter> "" - [::ChatWindow::GetOutText ${win_name}] tag bind ftyes$cookie <Leave> "" - [::ChatWindow::GetOutText ${win_name}] tag bind ftyes$cookie <<Button1>> "" + if { $cookie == -1 } { + set cookie [lindex $varlist 4] + } - [::ChatWindow::GetOutText ${win_name}] tag configure ftsaveas$cookie \ - -foreground #808080 -font bplainf -underline false - [::ChatWindow::GetOutText ${win_name}] tag bind ftsaveas$cookie <Enter> "" - [::ChatWindow::GetOutText ${win_name}] tag bind ftsaveas$cookie <Leave> "" - [::ChatWindow::GetOutText ${win_name}] tag bind ftsaveas$cookie <<Button1>> "" + [::ChatWindow::GetOutText ${win_name}] tag configure ftyes$cookie \ + -foreground #808080 -font bplainf -underline false + [::ChatWindow::GetOutText ${win_name}] tag bind ftyes$cookie <Enter> "" + [::ChatWindow::GetOutText ${win_name}] tag bind ftyes$cookie <Leave> "" + [::ChatWindow::GetOutText ${win_name}] tag bind ftyes$cookie <<Button1>> "" - DisableCancelText $cookie $chatid - - set txt [trans ftaccepted] + [::ChatWindow::GetOutText ${win_name}] tag configure ftsaveas$cookie \ + -foreground #808080 -font bplainf -underline false + [::ChatWindow::GetOutText ${win_name}] tag bind ftsaveas$cookie <Enter> "" + [::ChatWindow::GetOutText ${win_name}] tag bind ftsaveas$cookie <Leave> "" + [::ChatWindow::GetOutText ${win_name}] tag bind ftsaveas$cookie <<Button1>> "" - SendMessageFIFO [list ::amsn::WinWriteAcceptFT $chatid $txt] "::amsn::messages_stack($chatid)" "::amsn::messages_flushing($chatid)" + DisableCancelText $cookie $chatid + + set txt [trans ftaccepted] - set email [::MSN::usersInChat $chatid] - ::log::ftlog $email $txt - } + SendMessageFIFO [list ::amsn::WinWriteAcceptFT $chatid $txt] "::amsn::messages_stack($chatid)" "::amsn::messages_flushing($chatid)" - proc WinWriteAcceptFT {chatid txt} { - WinWrite $chatid "\n" green - WinWriteIcon $chatid greyline 3 - WinWrite $chatid "\n" green - WinWriteIcon $chatid fticon 3 2 - WinWrite $chatid " $txt\n" green - WinWriteIcon $chatid greyline 3 - } + set email [::MSN::usersInChat $chatid] + ::log::ftlog $email $txt + } - - proc SaveAsFT {chatid cookie {varlist ""} } { - global HOME - if {$cookie != -1} { - set initialfile [::MSNFT::getFilename $cookie] - } { - set initialfile [lindex $varlist 5] + proc WinWriteAcceptFT {chatid txt} { + WinWrite $chatid "\n" green + WinWriteIcon $chatid greyline 3 + WinWrite $chatid "\n" green + WinWriteIcon $chatid fticon 3 2 + WinWrite $chatid " $txt\n" green + WinWriteIcon $chatid greyline 3 } - if {[catch {set filename [tk_getSaveFile -initialfile $initialfile -initialdir [::config::getKey receiveddir]]} res]} { - status_log "Error in SaveAsFT: $res \n" - set filename [tk_getSaveFile -initialfile $initialfile -initialdir [set HOME]] - - } - if {$filename != ""} { - AcceptFT $chatid $cookie [list [lindex $varlist 0] [lindex $varlist 1] [lindex $varlist 2] [lindex $varlist 3] [lindex $varlist 4] "$filename"] - } {return} - } - proc RejectFT {chatid cookie {varlist ""} } { - if { $cookie != -1 && $cookie != -2 } { - ::MSNFT::rejectFT $chatid $cookie - } elseif { $cookie == - 1 } { - ::MSN6FT::RejectFT $chatid [lindex $varlist 0] [lindex $varlist 1] [lindex $varlist 2] - set cookie [lindex $varlist 0] - } elseif { $cookie == -2 } { - set cookie [lindex $varlist 0] - set txt [trans filetransfercancelled] + proc SaveAsFT {chatid cookie {varlist ""} } { + global HOME + if {$cookie != -1} { + set initialfile [::MSNFT::getFilename $cookie] + } { + set initialfile [lindex $varlist 5] + } + if {[catch {set filename [tk_getSaveFile -initialfile $initialfile -initialdir [::config::getKey receiveddir]]} res]} { + status_log "Error in SaveAsFT: $res \n" + set filename [tk_getSaveFile -initialfile $initialfile -initialdir [set HOME]] + + } + if {$filename != ""} { + AcceptFT $chatid $cookie [list [lindex $varlist 0] [lindex $varlist 1] [lindex $varlist 2] [lindex $varlist 3] [lindex $varlist 4] "$filename"] + } {return} } - set win_name [::ChatWindow::For $chatid] - if { [::ChatWindow::For $chatid] == 0} { - return 0 - } - [::ChatWindow::GetOutText ${win_name}] tag configure ftyes$cookie \ - -foreground #808080 -font bplainf -underline false - [::ChatWindow::GetOutText ${win_name}] tag bind ftyes$cookie <Enter> "" - [::ChatWindow::GetOutText ${win_name}] tag bind ftyes$cookie <Leave> "" - [::ChatWindow::GetOutText ${win_name}] tag bind ftyes$cookie <<Button1>> "" + proc RejectFT {chatid cookie {varlist ""} } { + if { $cookie != -1 && $cookie != -2 } { + ::MSNFT::rejectFT $chatid $cookie + } elseif { $cookie == - 1 } { + ::MSN6FT::RejectFT $chatid [lindex $varlist 0] [lindex $varlist 1] [lindex $varlist 2] + set cookie [lindex $varlist 0] + } elseif { $cookie == -2 } { + set cookie [lindex $varlist 0] + set txt [trans filetransfercancelled] + } - [::ChatWindow::GetOutText ${win_name}] tag configure ftsaveas$cookie \ - -foreground #808080 -font bplainf -underline false - [::ChatWindow::GetOutText ${win_name}] tag bind ftsaveas$cookie <Enter> "" - [::ChatWindow::GetOutText ${win_name}] tag bind ftsaveas$cookie <Leave> "" - [::ChatWindow::GetOutText ${win_name}] tag bind ftsaveas$cookie <<Button1>> "" + set win_name [::ChatWindow::For $chatid] + if { [::ChatWindow::For $chatid] == 0} { + return 0 + } - DisableCancelText $cookie $chatid + [::ChatWindow::GetOutText ${win_name}] tag configure ftyes$cookie \ + -foreground #808080 -font bplainf -underline false + [::ChatWindow::GetOutText ${win_name}] tag bind ftyes$cookie <Enter> "" + [::ChatWindow::GetOutText ${win_name}] tag bind ftyes$cookie <Leave> "" + [::ChatWindow::GetOutText ${win_name}] tag bind ftyes$cookie <<Button1>> "" - [::ChatWindow::GetOutText ${win_name}] conf -cursor xterm + [::ChatWindow::GetOutText ${win_name}] tag configure ftsaveas$cookie \ + -foreground #808080 -font bplainf -underline false + [::ChatWindow::GetOutText ${win_name}] tag bind ftsaveas$cookie <Enter> "" + [::ChatWindow::GetOutText ${win_name}] tag bind ftsaveas$cookie <Leave> "" + [::ChatWindow::GetOutText ${win_name}] tag bind ftsaveas$cookie <<Button1>> "" - if { [info exists txt] == 0 } { - set txt [trans ftrejected] - } + DisableCancelText $cookie $chatid - SendMessageFIFO [list ::amsn::WinWriteRejectFT $chatid $txt] "::amsn::messages_stack($chatid)" "::amsn::messages_flushing($chatid)" + [::ChatWindow::GetOutText ${win_name}] conf -cursor xterm - set email [::MSN::usersInChat $chatid] - ::log::ftlog $email $txt - } + if { [info exists txt] == 0 } { + set txt [trans ftrejected] + } - proc WinWriteRejectFT {chatid txt} { - WinWrite $chatid "\n" green - WinWriteIcon $chatid greyline 3 - WinWrite $chatid "\n" green - WinWriteIcon $chatid ftreject 3 2 - WinWrite $chatid "$txt\n" green - WinWriteIcon $chatid greyline 3 - } + SendMessageFIFO [list ::amsn::WinWriteRejectFT $chatid $txt] "::amsn::messages_stack($chatid)" "::amsn::messages_flushing($chatid)" - # TODO it would be best to make it "[$extratitle] - $file - [trans filetranser]" - proc setFTWinTitle { w cookie filename {extratitle ""} } { - variable ftwin_filename - - if { ![info exists ftwin_filename($w,$cookie)] } { - set file "" - if { $filename != ""} { - set file [getfilename $filename] - set ftwin_filename($w,$cookie) $file - } - } else { - set file [set ftwin_filename($w,$cookie)] + set email [::MSN::usersInChat $chatid] + ::log::ftlog $email $txt } - set title "$extratitle" - - if {$title != "" } { - append title " - " + proc WinWriteRejectFT {chatid txt} { + WinWrite $chatid "\n" green + WinWriteIcon $chatid greyline 3 + WinWrite $chatid "\n" green + WinWriteIcon $chatid ftreject 3 2 + WinWrite $chatid "$txt\n" green + WinWriteIcon $chatid greyline 3 } - - append title "$file - [trans filetransfer]" - if { [string compare [wm title $w] "$title" ] } { - wm title $w "$title" - } + # TODO it would be best to make it "[$extratitle] - $file - [trans filetranser]" + proc setFTWinTitle { w cookie filename {extratitle ""} } { + variable ftwin_filename + + if { ![info exists ftwin_filename($w,$cookie)] } { + set file "" + if { $filename != ""} { + set file [getfilename $filename] + set ftwin_filename($w,$cookie) $file + } + } else { + set file [set ftwin_filename($w,$cookie)] + } -# if { [::MSNFT::getTransferType $cookie] == "received" } { -# wm title $w "$filename - [trans receivefile]" -# } else { -# wm title $w "$filename - [trans sendfile]" -# } + set title "$extratitle" + + if {$title != "" } { + append title " - " + } + + append title "$file - [trans filetransfer]" - } + if { [string compare [wm title $w] "$title" ] } { + wm title $w "$title" + } - #PRIVATE: Opens Receiving Window - proc FTWin {cookie filename user {chatid 0}} { - status_log "Creating receive progress window\n" + # if { [::MSNFT::getTransferType $cookie] == "received" } { + # wm title $w "$filename - [trans receivefile]" + # } else { + # wm title $w "$filename - [trans sendfile]" + # } - if { [string range $filename [expr {[string length $filename] - 11}] [string length $filename]] == ".incomplete" } { - set filename [filenoext $filename] } - # Set appropriate Cancel command - if { [::MSNP2P::SessionList get $cookie] == 0 } { - set cancelcmd "::MSNFT::cancelFT $cookie" - } else { - set cancelcmd "::MSN6FT::CancelFT $chatid $cookie" - } + #PRIVATE: Opens Receiving Window + proc FTWin {cookie filename user {chatid 0}} { + status_log "Creating receive progress window\n" - set w .ft$cookie + if { [string range $filename [expr {[string length $filename] - 11}] [string length $filename]] == ".incomplete" } { + set filename [filenoext $filename] + } - set lastfocus [focus] - toplevel $w - wm group $w . - #wm geometry $w 360x170 + # Set appropriate Cancel command + if { [::MSNP2P::SessionList get $cookie] == 0 } { + set cancelcmd "::MSNFT::cancelFT $cookie" + } else { + set cancelcmd "::MSN6FT::CancelFT $chatid $cookie" + } - #frame $w.f -class amsnChatFrame -background [::skin::getKey chatwindowbg] -borderwidth 0 -relief flat - #set w $ww.f + set w .ft$cookie - label $w.user -text "[trans user]: $user" -font splainf - pack $w.user -side top -anchor w - label $w.file -text "[trans filename]: $filename" -font splainf - pack $w.file -side top -anchor w + set lastfocus [focus] + toplevel $w + wm group $w . + #wm geometry $w 360x170 - pack [::dkfprogress::Progress $w.prbar] -fill x -expand 0 -padx 5 -pady 5 -side top + #frame $w.f -class amsnChatFrame -background [::skin::getKey chatwindowbg] -borderwidth 0 -relief flat + #set w $ww.f - label $w.progress -text "" -font splainf - label $w.time -text "" -font splainf - pack $w.progress $w.time -side top + label $w.user -text "[trans user]: $user" -font splainf + pack $w.user -side top -anchor w + label $w.file -text "[trans filename]: $filename" -font splainf + pack $w.file -side top -anchor w - checkbutton $w.ftautoclose -text "[trans ftautoclose]" -onvalue 1 -offvalue 0 -variable [::config::getVar ftautoclose] - pack $w.ftautoclose -side top - #Specify the path to the file - set filepath [file join [::config::getKey receiveddir] $filename] - set filedir [file dirname $filepath] + pack [::dkfprogress::Progress $w.prbar] -fill x -expand 0 -padx 5 -pady 5 -side top - #Open directory and Open picture button - button $w.close -text "[trans cancel]" -command $cancelcmd - button $w.open -text "[trans opendir]" -state normal -command [list launch_filemanager $filedir] - button $w.openfile -text "[trans openfile]" -state disable -command [list open_file $filepath] - pack $w.close $w.open $w.openfile -side right -pady 5 -padx 10 + label $w.progress -text "" -font splainf + label $w.time -text "" -font splainf + pack $w.progress $w.time -side top - setFTWinTitle $w $cookie $filename + checkbutton $w.ftautoclose -text "[trans ftautoclose]" -onvalue 1 -offvalue 0 -variable [::config::getVar ftautoclose] + pack $w.ftautoclose -side top + #Specify the path to the file + set filepath [file join [::config::getKey receiveddir] $filename] + set filedir [file dirname $filepath] - bind $w <<Escape>> $cancelcmd - wm protocol $w WM_DELETE_WINDOW $cancelcmd - moveinscreen $w 30 + #Open directory and Open picture button + button $w.close -text "[trans cancel]" -command $cancelcmd + button $w.open -text "[trans opendir]" -state normal -command [list launch_filemanager $filedir] + button $w.openfile -text "[trans openfile]" -state disable -command [list open_file $filepath] + pack $w.close $w.open $w.openfile -side right -pady 5 -padx 10 - ::dkfprogress::SetProgress $w.prbar 0 - update idletasks - catch {focus $lastfocus} - } + setFTWinTitle $w $cookie $filename + bind $w <<Escape>> $cancelcmd + wm protocol $w WM_DELETE_WINDOW $cancelcmd + moveinscreen $w 30 - #Updates filetransfer progress window/Bar - #fileTransferProgress mode cookie filename bytes filesize - # mode: a=Accepting invitation - # c=Connecting - # w=Waiting for connection - # e=Connect error - # i=Identifying/negotiating - # l=Connection lost - # ca=Cancel - # s=Sending - # r=Receiving - # fr=finish receiving - # fs=finish sending - # cookie: ID for the filetransfer - # bytes: bytes sent/received ( > filesize if finished / -1 if cancelling ) - # filesize: total bytes in the file - # chatid: used for through server transfers - ##### - proc FTProgress {mode cookie filename {bytes 0} {filesize 1000} {chatid 0}} { + ::dkfprogress::SetProgress $w.prbar 0 + update idletasks + catch {focus $lastfocus} + } - variable firsttimes ;# Array. Times in ms when the FT started. - variable ratetimer - if { [info exists ratetimer($cookie)] } { - after cancel $ratetimer($cookie) - } + #Updates filetransfer progress window/Bar + #fileTransferProgress mode cookie filename bytes filesize + # mode: a=Accepting invitation + # c=Connecting + # w=Waiting for connection + # e=Connect error + # i=Identifying/negotiating + # l=Connection lost + # ca=Cancel + # s=Sending + # r=Receiving + # fr=finish receiving + # fs=finish sending + # cookie: ID for the filetransfer + # bytes: bytes sent/received ( > filesize if finished / -1 if cancelling ) + # filesize: total bytes in the file + # chatid: used for through server transfers + ##### + proc FTProgress {mode cookie filename {bytes 0} {filesize 1000} {chatid 0}} { - set w .ft$cookie + variable firsttimes ;# Array. Times in ms when the FT started. + variable ratetimer - if { ([winfo exists $w] == 0) && ($mode != "ca")} { - #set filename2 [::MSNFT::getFilename $cookie] - if { $filename == "" } { - FTWin $cookie [::MSNFT::getFilename $cookie] [::MSNFT::getUsername $cookie] $chatid - } else { - FTWin $cookie $filename $bytes $chatid + if { [info exists ratetimer($cookie)] } { + after cancel $ratetimer($cookie) } - } - if {[winfo exists $w] == 0} { - return -1 - } + set w .ft$cookie - switch $mode { - a { - $w.progress configure -text "[trans ftaccepting]..." - setFTWinTitle $w $cookie $filename - ::dkfprogress::SetProgress $w.prbar 0 1000 - } - c { - $w.progress configure -text "[trans ftconnecting $bytes $filesize]..." - setFTWinTitle $w $cookie $filename - ::dkfprogress::SetProgress $w.prbar 0 1000 - } - w { - $w.progress configure -text "[trans listeningon $bytes]..." - setFTWinTitle $w $cookie $filename - ::dkfprogress::SetProgress $w.prbar 0 1000 - } - e { - $w.progress configure -text "[trans ftconnecterror]" - $w.close configure -text "[trans close]" -command "destroy $w" - wm protocol $w WM_DELETE_WINDOW "destroy $w" - setFTWinTitle $w $cookie $filename "[trans error]" - } - i { - # This means it's connected and it tries to authenticate the user... - #$w.progress configure -text "[trans ftconnecting]" - setFTWinTitle $w $cookie $filename - } - l { - $w.progress configure -text "[trans ftconnectionlost]" - $w.close configure -text "[trans close]" -command "destroy $w" - wm protocol $w WM_DELETE_WINDOW "destroy $w" - bind $w <<Escape>> "destroy $w" - setFTWinTitle $w $cookie $filename "[trans error]" - } - r - - s { - #Calculate how many seconds has transmission lasted - if {![info exists firsttimes] || ![info exists firsttimes($cookie)]} { - set firsttimes($cookie) [clock seconds] - set difftime 0 + if { ([winfo exists $w] == 0) && ($mode != "ca")} { + #set filename2 [::MSNFT::getFilename $cookie] + if { $filename == "" } { + FTWin $cookie [::MSNFT::getFilename $cookie] [::MSNFT::getUsername $cookie] $chatid } else { - set difftime [expr {[clock seconds] - $firsttimes($cookie)}] + FTWin $cookie $filename $bytes $chatid } + } - if { $difftime == 0 || $bytes == 0} { - set rate "???" - set timeleft "-" - } else { - #Calculate rate and time - set rate [format "%.1f" [expr {(1.0*$bytes / $difftime) / 1024.0 } ]] - set secleft [expr {int(((1.0*($filesize - $bytes)) / $bytes) * $difftime)} ] - set t1 [expr {$secleft % 60 }] ;#Seconds - set secleft [expr {int($secleft / 60)}] - set t2 [expr {$secleft % 60 }] ;#Minutes - set secleft [expr {int($secleft / 60)}] - set t3 $secleft ;#Hours - set timeleft [format "%02i:%02i:%02i" $t3 $t2 $t1] - } + if {[winfo exists $w] == 0} { + return -1 + } - if {$mode == "r"} { - $w.progress configure -text \ - "[trans receivedbytes [::amsn::sizeconvert $bytes] [::amsn::sizeconvert $filesize]] ($rate KB/s)" - } elseif {$mode == "s"} { - $w.progress configure -text \ - "[trans sentbytes [::amsn::sizeconvert $bytes] [::amsn::sizeconvert $filesize]] ($rate KB/s)" + switch $mode { + a { + $w.progress configure -text "[trans ftaccepting]..." + setFTWinTitle $w $cookie $filename + ::dkfprogress::SetProgress $w.prbar 0 1000 } - $w.time configure -text "[trans timeremaining] : $timeleft" - set percent [expr {int(double($bytes)/ (double($filesize)/100.0))}] + c { + $w.progress configure -text "[trans ftconnecting $bytes $filesize]..." + setFTWinTitle $w $cookie $filename + ::dkfprogress::SetProgress $w.prbar 0 1000 + } + w { + $w.progress configure -text "[trans listeningon $bytes]..." + setFTWinTitle $w $cookie $filename + ::dkfprogress::SetProgress $w.prbar 0 1000 + } + e { + $w.progress configure -text "[trans ftconnecterror]" + $w.close configure -text "[trans close]" -command "destroy $w" + wm protocol $w WM_DELETE_WINDOW "destroy $w" + setFTWinTitle $w $cookie $filename "[trans error]" + } + i { + # This means it's connected and it tries to authenticate the user... + #$w.progress configure -text "[trans ftconnecting]" + setFTWinTitle $w $cookie $filename + } + l { + $w.progress configure -text "[trans ftconnectionlost]" + $w.close configure -text "[trans close]" -command "destroy $w" + wm protocol $w WM_DELETE_WINDOW "destroy $w" + bind $w <<Escape>> "destroy $w" + setFTWinTitle $w $cookie $filename "[trans error]" + } + r - + s { + #Calculate how many seconds has transmission lasted + if {![info exists firsttimes] || ![info exists firsttimes($cookie)]} { + set firsttimes($cookie) [clock seconds] + set difftime 0 + } else { + set difftime [expr {[clock seconds] - $firsttimes($cookie)}] + } - set ratetimer($cookie) [after 1000 [list ::amsn::FTProgress $mode $cookie $filename $bytes $filesize $chatid]] + if { $difftime == 0 || $bytes == 0} { + set rate "???" + set timeleft "-" + } else { + #Calculate rate and time + set rate [format "%.1f" [expr {(1.0*$bytes / $difftime) / 1024.0 } ]] + set secleft [expr {int(((1.0*($filesize - $bytes)) / $bytes) * $difftime)} ] + set t1 [expr {$secleft % 60 }] ;#Seconds + set secleft [expr {int($secleft / 60)}] + set t2 [expr {$secleft % 60 }] ;#Minutes + set secleft [expr {int($secleft / 60)}] + set t3 $secleft ;#Hours + set timeleft [format "%02i:%02i:%02i" $t3 $t2 $t1] + } - setFTWinTitle $w $cookie $filename "${percent}%" - if { $filesize != 0 } { - ::dkfprogress::SetProgress $w.prbar $bytes $filesize + if {$mode == "r"} { + $w.progress configure -text \ + "[trans receivedbytes [::amsn::sizeconvert $bytes] [::amsn::sizeconvert $filesize]] ($rate KB/s)" + } elseif {$mode == "s"} { + $w.progress configure -text \ + "[trans sentbytes [::amsn::sizeconvert $bytes] [::amsn::sizeconvert $filesize]] ($rate KB/s)" + } + $w.time configure -text "[trans timeremaining] : $timeleft" + set percent [expr {int(double($bytes)/ (double($filesize)/100.0))}] + + set ratetimer($cookie) [after 1000 [list ::amsn::FTProgress $mode $cookie $filename $bytes $filesize $chatid]] + + setFTWinTitle $w $cookie $filename "${percent}%" + if { $filesize != 0 } { + ::dkfprogress::SetProgress $w.prbar $bytes $filesize + } } + ca { + $w.progress configure -text "[trans filetransfercancelled]" + $w.close configure -text "[trans close]" -command "destroy $w" + wm protocol $w WM_DELETE_WINDOW "destroy $w" + bind $w <<Escape>> "destroy $w" + setFTWinTitle $w $cookie $filename "[trans cancelled]" + } + fs - + fr { + ::dkfprogress::SetProgress $w.prbar 100 + $w.progress configure -text "[trans filetransfercomplete]" + $w.close configure -text "[trans close]" -command "destroy $w" + $w.openfile configure -state normal + wm protocol $w WM_DELETE_WINDOW "destroy $w" + bind $w <<Escape>> "destroy $w" + setFTWinTitle $w $cookie $filename "[trans done]" + ::dkfprogress::SetProgress $w.prbar 1000 1000 + } } - ca { - $w.progress configure -text "[trans filetransfercancelled]" - $w.close configure -text "[trans close]" -command "destroy $w" - wm protocol $w WM_DELETE_WINDOW "destroy $w" - bind $w <<Escape>> "destroy $w" - setFTWinTitle $w $cookie $filename "[trans cancelled]" + + switch $mode { + e - + l - + ca - + fs - + fr { + # Whenever a file transfer is terminated in a way or in another, + # remove the counters for this cookie. + if {[info exists firsttimes($cookie)]} { unset firsttimes($cookie) } + if {[info exists ratetimer($cookie)]} { unset ratetimer($cookie) } + variable ftwin_filename + if {[info exists ftwin_filename($w,$cookie)]} { unset ftwin_filename($w,$cookie) } + } } - fs - - fr { - ::dkfprogress::SetProgress $w.prbar 100 - $w.progress configure -text "[trans filetransfercomplete]" - $w.close configure -text "[trans close]" -command "destroy $w" - $w.openfile configure -state normal - wm protocol $w WM_DELETE_WINDOW "destroy $w" - bind $w <<Escape>> "destroy $w" - setFTWinTitle $w $cookie $filename "[trans done]" - ::dkfprogress::SetProgress $w.prbar 1000 1000 + + + # Close the window if the filetransfer is finished + if {($mode == "fr" || $mode == "fs") && [::config::getKey ftautoclose]} { + destroy $w } + } - switch $mode { - e - - l - - ca - - fs - - fr { - # Whenever a file ... [truncated message content] |