/usr/share/amsn/plugins/Nudge/Nudge.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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | ############################################
# ::Nudge => Nudges for aMSN #
# ====================================== #
# Nudge is a kind of notification #
# that was introduced in MSN 7 #
############################################
###########################
# All nudges related code #
###########################
namespace eval ::Nudge {
###############################################
# ::Nudge::Init (dir) #
# ------------------------------------------- #
# Registration & initialization of the plugin #
###############################################
variable plugindir
proc Init { dir } {
variable plugindir
::plugins::RegisterPlugin Nudge
#Register the events to the plugin system
::Nudge::RegisterEvent
#Get default value for config
::Nudge::config_array
#Loads language files
::Nudge::load_nudge_languages $dir
#Config to show in configuration window
::Nudge::configlist_values
#Load the pictures
::Nudge::setPixmap
#Wait 5 seconds after all the plugins are loaded to register
#the command /nudge to amsnplus plugin
after 5000 "catch {::Nudge::add_command 0 0}"
set plugindir $dir
}
#####################################
# ::Nudge::RegisterEvent #
# --------------------------------- #
# Register events to plugin system #
#####################################
proc RegisterEvent {} {
::plugins::RegisterEvent Nudge DataCastPacketReceived received
::plugins::RegisterEvent Nudge PacketReceived received
::plugins::RegisterEvent Nudge chatwindowbutton sendbutton
::plugins::RegisterEvent Nudge chatmenu itemmenu
::plugins::RegisterEvent Nudge right_menu clitemmenu
::plugins::RegisterEvent Nudge AllPluginsLoaded add_command
::plugins::RegisterEvent Nudge chatwindowbutton blockbutton
}
########################################
# ::Nudge::config_array #
# -------------------------------------#
# Add config array with default values #
########################################
proc config_array {} {
array set ::Nudge::config {
notify {1}
notsentinwin {1}
notrecdinwin {1}
soundnotsend {1}
soundnotrec {1}
shake {0}
shakes {10}
shaketoo {0}
addbutton {1}
addblockbutton {0}
addclmenuitem {0}
limit {1}
delay {60}
}
}
########################################
# ::Nudge::configlist_values #
# -------------------------------------#
# List of items for config window #
########################################
proc configlist_values {} {
set ::Nudge::configlist [list \
[list bool "$::Nudge::language(shake_receive)" shake] \
[list bool "$::Nudge::language(shake_send)" shaketoo] \
[list str "\t$::Nudge::language(shake_nudge):" shakes] \
[list bool "$::Nudge::language(popup_nudge)" notify] \
[list bool "$::Nudge::language(notify_send)" notsentinwin] \
[list bool "$::Nudge::language(notify_receive)" notrecdinwin] \
[list bool "$::Nudge::language(sound_send)" soundnotsend] \
[list bool "$::Nudge::language(sound_receive)" soundnotrec] \
[list bool "$::Nudge::language(add_button)" addbutton] \
[list bool "$::Nudge::language(add_blockbutton)" addblockbutton] \
[list bool "$::Nudge::language(add_clmenuitem)" addclmenuitem] \
[list bool "$::Nudge::language(limit)" limit] \
[list str "\t$::Nudge::language(delay):" delay] \
]
}
########################################
# ::Nudge::load_nudge_languages dir #
# -------------------------------------#
# Load languages files #
# Compatible with aMSN >0.94 #
########################################
proc load_nudge_languages {dir} {
#Verify if aMSN version is 0.94 or better
if { [::Nudge::version_094] } {
#If 0.94, use only english keys because 0.94 is not compatible with langfiles in plugins
::Nudge::language_array_094
} else {
#Load lang files
set langdir [file join $dir "lang"]
set lang [::config::getGlobalKey language]
load_lang en $langdir
load_lang $lang $langdir
#Create array ::Nudge::language
::Nudge::language_array
}
}
########################################
# ::Nudge::language_array_094 #
# -------------------------------------#
# Load default english keys in array #
# For aMSN 0.94 only #
########################################
proc language_array_094 {} {
array set ::Nudge::language [list shake_receive "Shake the window when receiving a nudge" \
shake_send "Shake the window when sending a nudge" \
shake_nudge "Shakes per nudge" \
popup_nudge "Notify nudges with popup-window" \
notify_send "Notify sent nudges in the chatwindow" \
notify_receive "Notify received nudges in the chatwindow" \
sound_send "Play a sound upon sending a nudge" \
sound_receive "Play a sound upon receiving a nudge." \
add_button "Add a button to send a nudge in the chatwindow" \
add_blockbutton "Add a button to block incoming nudges in the chatwindow" \
add_clmenuitem "Add an item to the contactlist popup-menu" \
send_nudge "Send nudge" \
no_nudge_support "You cannot sent a nudge to your contact because he or she doesn't use a client that supports nudges" \
nudge_sent "You have just sent a Nudge" \
limit "Activate Nudge receive limitation" \
delay "Minimum time between 2 nudge from the same contact (in seconds)" \
block_nudge "Block/Unblock Nudges" \
no_nudge_support "You cannot sent a nudge to your contact because he or she doesn't use a client that supports nudges" \
nudge_sent "You have just sent a Nudge" \
]
}
########################################
# ::Nudge::language_array #
# -------------------------------------#
# Create ::Nudge::language array #
# Compatible with lang files #
########################################
proc language_array {} {
array set ::Nudge::language [list shake_receive "[trans shake_receive]" \
shake_send "[trans shake_send]" shake_nudge "[trans shake_nudge]" \
popup_nudge "[trans popup_nudge]" notify_send "[trans notify_send]" \
notify_receive "[trans notify_receive]" sound_send "[trans sound_send]" \
sound_receive "[trans sound_receive]" add_button "[trans add_button]" \
add_blockbutton "[trans add_blockbutton]" \
add_clmenuitem "[trans add_clmenuitem]" send_nudge "[trans send_nudge]" \
no_nudge_support "[trans no_nudge_support]" nudge_sent "[trans nudge_sent]" \
limit "[trans limit]" delay "[trans delay]" block_nudge "[trans block_nudge]" \
]
}
###############################################
# ::Nudge::received event evpar #
# ------------------------------------------- #
# Is the event handler. Simply checks our #
# config and do what it says. #
###############################################
proc received { event evpar } {
upvar 2 $evpar args
upvar 2 $args(chatid) chatid
upvar 2 $args(nick) nick
upvar 2 $args(msg) msg
set timestamp [clock seconds]
set lastnudge [::abook::getVolatileData $chatid last_nudge]
set auth [::abook::getContactData $chatid auth_nudge]
if {$auth == ""} {
set auth 1
}
if {$lastnudge == ""} {
set lastnudge 0
}
set lastnudge [expr $timestamp-$lastnudge]
#The way to get headers change on 0.95
if {[::Nudge::version_094]} {
set header "[::MSN::GetHeaderValue $msg Content-Type]"
set ID "[::MSN::GetHeaderValue $msg ID]"
} else {
set header "[$msg getHeader Content-Type]"
set ID "[$msg getField ID]"
}
#If the user choosed to desactivate nudge receive limitation
if {$::Nudge::config(limit) == 0} {
set lastnudge [expr $lastnudge+$::Nudge::config(delay)]
set auth 1
}
if {$header == "text/x-msnmsgr-datacast" && $ID == "1" && $lastnudge > $::Nudge::config(delay) && $auth=="1"} {
::Nudge::log "Start receiving nudge from <[::abook::getDisplayNick $chatid]>"
#If the user choosed to have the nudge notified in the window
if { $::Nudge::config(notsentinwin) == 1 } {
::ChatWindow::MakeFor $chatid
::Nudge::winwrite $chatid "[trans nudge $nick]!" nudge
}
#If the user choosed to have a sound-notify
if { $::Nudge::config(soundnotrec) == 1 } {
::Nudge::sound
}
#If the user choosed to have a notify window
if { $::Nudge::config(notify) == 1 } {
::Nudge::notify $nick $chatid
}
#If the user choosed to make the window shake
if { $::Nudge::config(shake) == 1 } {
#Get the name of the window from the people who sent the nudge
set lowuser [string tolower $chatid]
set win_name [::ChatWindow::For $lowuser]
#Shake that window
::Nudge::shake ${win_name} $::Nudge::config(shakes)
}
#If Growl plugin is loaded, show the notification, Mac OS X only
if { [info commands ::growl::InitPlugin] != "" } {
catch {growl post Nudge Nudge [trans nudge $nick] [::growl::getpicture $chatid]}
::Nudge::log "Show growl notification"
}
::abook::setVolatileData $chatid last_nudge $timestamp
::Nudge::log "Receiving nudge from <[::abook::getDisplayNick $chatid]> is finished"
}
}
###############################################
# ::Nudge::notify nickname email #
# ------------------------------------------- #
# Pops-up a notification telling that #
# someone has sent you a nudge #
###############################################
proc notify { nick email } {
#Get a shorter nick-name for the notify window
set maxw [expr {[::skin::getKey notifwidth]-20}]
set nickname [trunc $nick . $maxw splainf]
#Show the notification
::amsn::notifyAdd [trans nudge $nickname] "::amsn::chatUser $email" "" plugins
::Nudge::log "Notify window created"
}
###############################################
# ::Nudge::shake window n #
# ------------------------------------------- #
# The window $window will 'shake' $n times. #
###############################################
proc shake { window n } {
#Tab support on 0.95
if {![::Nudge::version_094]} {
if {[::ChatWindow::GetContainerFromWindow $window] != ""} {
set window [::ChatWindow::GetContainerFromWindow $window]
}
}
#If a strange user decide to use a letter, nothing, or 0, as a number of shake
#Rechange the variable to 10 shakes
if {![string is digit -strict $n]} {
set n "10"
set ::Nudge::config(shakes) 10
}
#Avoid a bug if the user close the chat window just after pressing the button
if {[catch {set geometry [wm geometry $window]}]} {
return
}
set index11 [string first "+" $geometry]
set index12 [string first "-" $geometry]
if {[expr $index11 > $index12 && $index12 != -1] || $index11 == -1} {set index1 $index12} {set index1 $index11}
set index21 [string first "+" $geometry [expr $index1 + 1]]
set index22 [string first "-" $geometry [expr $index1 + 1]]
if {$index21 == -1} {set index2 $index22} {set index2 $index21}
#set index2 [string last "+" $geometry]
#Make the window shake until we have reached the number of times to shake
#I added catch to avoid bug if we close the chatwindow before the end of the nudge
#If catch is not called in the loop before functions dealing with the window then if
#the window is closed while the window is still vibrating an error will be produced
for {set i 0} {$i < $n && [winfo exists $window] } {incr i} {
catch {set geometry [wm geometry $window]}
set x [string range $geometry [expr $index1 + 1] [expr $index2 -1]]
set y [string range $geometry [expr $index2 + 1] end]
catch {wm geometry $window +[expr $x+10]+[expr $y +8]}
update
after 10
catch {set geometry [wm geometry $window]}
set x [string range $geometry [expr $index1 + 1] [expr $index2 -1]]
set y [string range $geometry [expr $index2 + 1] end]
catch {wm geometry $window +[expr $x +5 ]+[expr $y-7]}
update
after 10
catch {set geometry [wm geometry $window]}
set x [string range $geometry [expr $index1 + 1] [expr $index2 -1]]
set y [string range $geometry [expr $index2 + 1] end]
catch {wm geometry $window +[expr $x -15]+[expr $y -1]}
update
after 10
}
::Nudge::log "Window shook $n times"
}
################################################
# ::Nudge::sendbutton event epvar #
# ------------------------------------------- #
# Button to add in the chat window #
# When we click on that button, we send a nudge#
# to the other contact #
################################################
proc sendbutton { event evpar } {
if { $::Nudge::config(addbutton) == 1 } {
upvar 2 $evpar newvar
set nudgebutton $newvar(bottom).nudge
#Create the button with an actual Pixmal
#Use after 1 to avoid a bug on Mac OS X when we close the chatwindow before the end of the nudge
#Keep compatibility with 0.94 for the getColor
if {[::Nudge::version_094]} {
label $nudgebutton -image [::skin::loadPixmap nudgebutton] -relief flat -padx 0 \
-background [::skin::getColor background2] -highlightthickness 0 -borderwidth 0 \
-highlightbackground [::skin::getColor background2] -activebackground [::skin::getColor background2]\
} else {
button $nudgebutton -image [::skin::loadPixmap nudgebutton] -relief flat -padx 0 \
-background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0 \
-command "after 1 ::Nudge::send_via_queue $newvar(window_name)" \
-highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]\
}
if {[::Nudge::version_094]} {
bind $nudgebutton <<Button1>> "after 1 ::Nudge::send_via_queue $newvar(window_name)"
}
#Configure hover button
bind $nudgebutton <Enter> "$nudgebutton configure -image [::skin::loadPixmap nudgebutton_hover]"
bind $nudgebutton <Leave> "$nudgebutton configure -image [::skin::loadPixmap nudgebutton]"
#Define baloon info
set_balloon $nudgebutton "$::Nudge::language(send_nudge)"
#Pack the button in the right area
pack $nudgebutton -side right
::Nudge::log "Nudge button added the new window: $newvar(window_name)"
}
}
################################################
# ::Nudge::itemmenu event epvar #
# ------------------------------------------- #
# "Send nudge" item, in the menu Actions #
# If you click on that menu item, you will send#
# a nudge to the other contact #
################################################
proc itemmenu { event evpar } {
upvar 2 $evpar newvar
#Add a separator to the menu
# $newvar(menu_name).actions add separator
#Add label in the menu
$newvar(menu_name).actions add command -label "$::Nudge::language(send_nudge)" \
-command "::Nudge::send_via_queue \[::ChatWindow::getCurrentTab $newvar(window_name)\]"
::Nudge::log "Item Send Nudge added to actions menu of window $newvar(window_name)"
}
################################################
# ::Nudge::add_command #
# ------------------------------------------- #
# Add irc command /nudge for amsnplus users #
# Need last update of aMSNPlus plugin +/- 2.3 #
# Verify first if amsnplus plugin is loaded #
################################################
proc add_command {event evpar} {
#If amsnplus plugin is loaded, register the command
if { [info commands ::amsnplus::add_command] != "" } {
#Avoid a bug if someone use an older version of aMSNPlus
catch {::amsnplus::add_command nudge ::Nudge::SendNudge 0 1}
::Nudge::log "Register command nudge to amsnplus plugin"
}
}
################################################
# ::Nudge::clitemmenu event epvar #
# ------------------------------------------- #
# "Send nudge" item, in the rightclick-menu in #
# in the contact-list. #
# If you click on that menu item, you will send#
# a nudge to the other contact. #
################################################
proc clitemmenu { event evpar } {
upvar 2 $evpar newvar
if { $::Nudge::config(addclmenuitem) == 1 } {
#Add separator and label in the menu
if { [winfo exists ${newvar(menu_name)}.actions] } {
${newvar(menu_name)}.actions add separator
${newvar(menu_name)}.actions add command -label "$::Nudge::language(send_nudge)" \
-command "::Nudge::ClSendNudge $newvar(user_login)"
} else {
$newvar(menu_name) insert [trans viewprofile] command -label "$::Nudge::language(send_nudge)" \
-command "::Nudge::ClSendNudge $newvar(user_login)"
}
::Nudge::log "Create Send Nudge item in right click menu"
}
}
################################################
# ::Nudge::ClSendNudge username #
# ------------------------------------------- #
# Open the chatwindow to $username and send #
# this contact a Nudge #
################################################
proc ClSendNudge { username } {
set lowuser [string tolower $username]
set win_name [::ChatWindow::For $lowuser]
#Determine if a window with that user already exist (0=no window)
if { $win_name == 0 } {
::Nudge::log "We don't have any window with <[::abook::getDisplayNick $lowuser]> yet(via right-click menu)"
#Start the conversation
::amsn::chatUser $username
#Now that we have a window, find the name of this new window
set win_name [::ChatWindow::For $lowuser]
#Send the nudge via the ChatQueue (to wait that connection is etablished before sending)
::Nudge::send_via_queue $win_name
} else {
::Nudge::log "We already have a window with <[::abook::getDisplayNick $lowuser]> (via right click menu)"
#If the window with the contact was already open
#Send the nudge via the ChatQueue to reactive the conversation if it was closed
::Nudge::send_via_queue $win_name
}
}
############################################
# ::Nudge::send_via_queue window_name #
# -----------------------------------------#
# Send the Nudge via the ChatQueue #
# So, aMSN reconnect on user to send the #
# Nudge if the conversation was closed #
############################################
proc send_via_queue {window_name} {
set chatid [::ChatWindow::Name $window_name]
::MSN::ChatQueue $chatid [list ::Nudge::SendNudge $window_name]
}
################################################
# ::Nudge::SendNudge window_name #
# ------------------------------------------- #
# Protocole code to send a nudge to someone #
# via the button or the menu Actions #
################################################
proc SendNudge {window_name} {
#Find the SB
set chatid [::ChatWindow::Name $window_name]
::Nudge::log "\nStart sending Nudge to <[::abook::getDisplayNick $chatid]>\n"
#Check if the user can accept the nudge (MSN 7 protocol needed), if not, stop here.
set theysupport 0
set users [::MSN::usersInChat $chatid]
foreach chatid2 $users {
if {[::Nudge::check_clientid $chatid2]} {
#This is what the official client does...
#sends nudge to a multi-convo even when
#not everyone supports it
set theysupport 1
break
}
}
if { $theysupport == 0 } {
::Nudge::winwrite $chatid \
"$::Nudge::language(no_nudge_support)" nudgeoff red
::Nudge::log "Can't send a Nudge to <[::abook::getDisplayNick $chatid]> because he doesn't use MSN 7 protocol"
return
}
#If the user choosed to have the nudge notified in the window
if { $::Nudge::config(notrecdinwin) == 1 } {
::Nudge::winwrite $chatid "$::Nudge::language(nudge_sent)!" nudge
}
#If the user choosed to have a sound-notify
if { $::Nudge::config(soundnotsend) == 1 } {
::Nudge::sound
}
#Shake the window on sending if the user choosed it
if { $::Nudge::config(shaketoo) == 1 } {
::Nudge::shake $window_name $::Nudge::config(shakes)
}
#Send the packet of the nudge
::Nudge::SendPacket $chatid
}
################################################
# ::Nudge::SendPacket chatid #
# ------------------------------------------- #
# Protocole code to send a nudge to someone #
# via the button or the menu Actions #
################################################
proc SendPacket {chatid} {
set sbn [::MSN::SBFor $chatid]
#Write the packet
set msg "MIME-Version: 1.0\r\nContent-Type: text/x-msnmsgr-datacast\r\n\r\nID: 1\r\n\r\n\r\n"
set msg_len [string length $msg]
#Send the packet
::MSN::WriteSBNoNL $sbn "MSG" "U $msg_len\r\n$msg"
::Nudge::log "Nudge packet sent"
::Nudge::log "Finished sending Nudge to <[::abook::getDisplayNick $chatid]>"
}
######################################################
# ::Nudge::winwrite chatid text iconname (color) #
# ---------------------------------------------------#
# Use ::amsn::WinWrite to add text in a chat #
# window when we send/receive a nudge #
# Add a seperation of "-" before and & after the text#
# 0.95 use the skinnable separation instead of "--" #
######################################################
proc winwrite {chatid text iconname {color "green"} } {
#Look at the version of aMSN to know witch kind of separation we use
if {[::Nudge::version_094]} {
amsn::WinWrite $chatid "\n----------\n" $color
amsn::WinWriteIcon $chatid $iconname 3 2
amsn::WinWrite $chatid "[timestamp] $text\n----------" $color
} else {
SendMessageFIFO [list ::Nudge::winwriteWrapped $chatid $text $iconname $color] "::amsn::messages_stack($chatid)" "::amsn::messages_flushing($chatid)"
}
}
proc winwriteWrapped {chatid text iconname {color "green"} } {
amsn::WinWrite $chatid "\n" $color
amsn::WinWriteIcon $chatid greyline 3
amsn::WinWrite $chatid " \n" $color
amsn::WinWriteIcon $chatid $iconname 3 2
amsn::WinWrite $chatid "[timestamp] $text\n" $color
amsn::WinWriteIcon $chatid greyline 3
::Nudge::log "Seperation and message wrote in chatwindow"
}
############################################
# ::Nudge::check_clientid email #
# -----------------------------------------#
# Verify in abook if the other contact use #
# protocol MSN 7 #
# Boolean answer #
############################################
proc check_clientid {email} {
::Nudge::log "Verify if contact is using MSN 7.0 protocol"
set clientid [::abook::getContactData $email clientid]
::Nudge::log "Clientid is $clientid"
# If a user chats with you while being as "Appear offline", his client ID will be empty, and we don't want a crash in that case.
# We assume the user supports new nudge because only WLM 8.1+ allows you to chat while being as appear offline.
if { $clientid == [list] } {
::Nudge::log "Attempt to nudge offline user"
return 1
}
if { [::MSN::clientCapsVersion $clientid] < 4 } {
return 0
} else {
return 1
}
}
############################################
# ::Nudge::log message #
# -----------------------------------------#
# Add a log message to plugins-log window #
# Type Alt-P to get that window #
# Not compatible with 0.94 #
############################################
proc log {message} {
if {[::Nudge::version_094]} {
return
} else {
plugins_log Nudge $message
}
}
############################################
# ::Nudge::sound #
# -----------------------------------------#
# Play sound message #
# When we send and/or receive a nudge #
# Real sound from MSN 7 #
############################################
proc sound {} {
variable plugindir
set filename [::skin::GetSkinFile sounds nudge.wav "" $plugindir]
play_sound $filename 1
set dir [file dirname $filename]
::Nudge::log "Play sound for nudge, Directory: $dir"
}
############################################
# ::Nudge::version_094 #
# -----------------------------------------#
# Verify if the version of aMSN is 0.94 #
# Useful if we want to keep compatibility #
############################################
proc version_094 {} {
global version
scan $version "%d.%d" y1 y2;
if { $y2 == "94" } {
return 1
} else {
return 0
}
}
############################################
# ::Nudge::setPixmap #
# -----------------------------------------#
# Define the nudge pixmaps from the skin #
############################################
proc setPixmap {} {
::skin::setPixmap nudge nudge.gif
::skin::setPixmap nudgeoff nudgeoff.gif
::skin::setPixmap nudgebutton nudgebutton.gif
::skin::setPixmap nudgebutton_hover nudgebutton_hover.gif
}
################################################
# ::Nudge::blockbutton event epvar #
# ------------------------------------------- #
# Button to add in the chat window #
# When we click on that button,we block/deblock#
# Nudge ability for that contact #
################################################
proc blockbutton { event evpar } {
if { $::Nudge::config(addblockbutton) == 1 } {
upvar 2 $evpar newvar
set nudgebutton $newvar(bottom).nudgeblock
set chatid [::ChatWindow::Name $newvar(window_name)]
if {[::abook::getContactData $chatid auth_nudge] == "0"} {
set nudgeimg "nudgeoff"
} else {
set nudgeimg "nudge"
}
#Create the button with an actual Pixmap
#Use after 1 to avoid a bug on Mac OS X when we close the chatwindow before the end of the nudge
#Keep compatibility with 0.94 for the getColor
if {[::Nudge::version_094]} {
label $nudgebutton -image [::skin::loadPixmap $nudgeimg] -relief flat -padx 0 \
-background [::skin::getColor background2] -highlightthickness 0 -borderwidth 0 \
-highlightbackground [::skin::getColor background2] -activebackground [::skin::getColor background2]\
} else {
button $nudgebutton -image [::skin::loadPixmap $nudgeimg] -relief flat -padx 0 \
-background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0 \
-command "after 1 ::Nudge::blocknudge $chatid $nudgebutton" \
-highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]\
}
if {[::Nudge::version_094]} {
bind $nudgebutton <<Button1>> "after 1 ::Nudge::blocknudge $chatid $nudgebutton"
}
#Define baloon info
set_balloon $nudgebutton "$::Nudge::language(block_nudge)"
#Pack the button in the right area
pack $nudgebutton -side right
::Nudge::log "Nudge block button added the new window: $newvar(window_name)"
}
}
##############################################
# ::Nudge::blocknudge #
# -------------------------------------------#
# Set/Unset nudge authorization for a contact#
# Change picture in the chat window according#
# to the state. #
##############################################
proc blocknudge {chatid button} {
if {[::abook::getContactData $chatid auth_nudge] == "1"} {
::abook::setContactData $chatid auth_nudge 0
$button configure -image [::skin::loadPixmap nudgeoff]
} else {
::abook::setContactData $chatid auth_nudge 1
$button configure -image [::skin::loadPixmap nudge]
}
}
}
|