This file is indexed.

/usr/share/amsn/trayicon.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
::Version::setSubversionId {$Id: trayicon.tcl 12271 2010-12-06 01:21:09Z kakaroto $}

if { $initialize_amsn == 1 } {
    global statusicon mailicon systemtray_exist iconmenu ishidden defaultbackground use_tktray

    set statusicon 0
    set mailicon 0
    set systemtray_exist 0
    set iconmenu 0
    set ishidden 0
    set use_tktray 0
}

proc iconify_proc {} {
	global statusicon systemtray_exist
	
	if { [WinDock] } {
		taskbar_icon_handler WM_LBUTTONDBLCLK 0 0
	} else {
		if { [winfo exists .bossmode] } {
			wm state .bossmode normal
			raise .bossmode
			focus -force .bossmode
			return
		}
		set focus [focus]
		if {[winfo exists $focus] } {
			set focus [winfo toplevel $focus]
		}
		if {  $focus == "." && [wm state .] != "iconic" && [wm state .] != "withdrawn"} {
			wm iconify .
			wm state . withdrawn
		} else {
			wm deiconify .
			wm state . normal
			raise .
			focus -force .
		}
	}
}


proc isWinicoLoaded {} {
	foreach lib [info loaded] {
		if {[lindex $lib 1] == "Winico" } {
			return 1
		}
	}
	return 0
}

# Load the needed library (platform dependent) and create the context-menu
proc trayicon_init {} {
	global systemtray_exist iconmenu wintrayicon statusicon use_tktray

	if { [WinDock] } {
		#added to stop creation of more than 1 icon
		if { $statusicon != 0 } {
			return
		}
		catch {package require Winico}
		if {![isWinicoLoaded] } {
			set ext "[file join utils windows winico05.dll]"
			if { [file exists $ext] != 1 } {
				msg_box "[trans needwinico2]"
				close_dock
				return
			}
			if { [catch {load $ext winico}] }	{
				close_dock
				return
			}
		}

		set systemtray_exist 1
		set wintrayicon [winico create [::skin::GetSkinFile winicons msn.ico]]
		#add the icon
		winico taskbar add $wintrayicon -text "[trans offline]" -callback "taskbar_icon_handler %m %x %y"
		set statusicon 1

		#workaround for bug with the popup not unposting on Windows
		destroy .trayiconwin
		toplevel .trayiconwin -class Amsn
		wm geometry .trayiconwin "+0+[expr {2 * [winfo screenheight .]}]"
		wm state .trayiconwin withdrawn
		destroy .trayiconwin.immain
		set iconmenu .trayiconwin.immain

	} elseif {[UnixDock]} {
               if { [catch {package require tktray} res] } {
		       if { [catch {package require libtray} res] } {
			       set systemtray_exist 0
			       status_log "[trans traynotcompiled] : $res"
			       close_dock
			       return
		       } else {
			       set use_tktray 0
		       }
	       } else {
		       set use_tktray 1
	       }

		if {$use_tktray} {
			set systemtray_exist 1
		} else {
			set systemtray_exist [systemtray_exist]; #a system tray exist?
		}

		destroy .immain
		set iconmenu .immain
	} elseif {[MacDock]} {
		if { [catch {package require statusicon} res] } {
			set systemtray_exist 0
			status_log "Mac statusicon package not found : $res"
			close_dock
			return
		}

		set systemtray_exist 1

		destroy .immain
		set iconmenu .immain
	}


	menu $iconmenu -tearoff 0 -type normal

	menu $iconmenu.imstatus -tearoff 0 -type normal
	$iconmenu.imstatus add command -label [trans online] -command "ChCustomState NLN"
	$iconmenu.imstatus add command -label [trans noactivity] -command "ChCustomState IDL"
	$iconmenu.imstatus add command -label [trans busy] -command "ChCustomState BSY"
	$iconmenu.imstatus add command -label [trans rightback] -command "ChCustomState BRB"
	$iconmenu.imstatus add command -label [trans away] -command "ChCustomState AWY"
	$iconmenu.imstatus add command -label [trans onphone] -command "ChCustomState PHN"
	$iconmenu.imstatus add command -label [trans gonelunch] -command "ChCustomState LUN"
	$iconmenu.imstatus add command -label [trans appearoff] -command "ChCustomState HDN"

	$iconmenu add command -label "[trans offline]" -command iconify_proc
	$iconmenu add separator

	$iconmenu add command -label "[trans sendmsg]..." -command [list ::amsn::ShowUserList [trans sendmsg] ::amsn::chatUser] 

       $iconmenu add separator         
 
       $iconmenu add cascade -label "[trans mystatus]" -menu $iconmenu.imstatus -state disabled        
 
       $iconmenu add separator
 
       $iconmenu add command -label "[trans changenick]..." -command cmsn_change_name -state disabled
       $iconmenu add command -label "[trans changepsm]..." -command cmsn_change_name -state disabled
       $iconmenu add checkbutton -label "[trans sound]" -onvalue 1 -offvalue 0 -variable [::config::getVar sound]
       $iconmenu add checkbutton -label "[trans shownotify]" -onvalue 1 -offvalue 0 -variable [::config::getVar shownotify]
 #     $iconmenu add command -label "[trans preferences]..." -command Preferences
 
       $iconmenu add separator         

       $iconmenu add command -label "[trans gotoinbox]" -command ::hotmail::hotmail_login
       $iconmenu add separator
 
 #the login/logout one, defined later on (see below)
       $iconmenu add command
       $iconmenu add command -label "[trans quit]" -command "exit"
       CreateStatesMenu .my_menu

       statusicon_proc [::MSN::myStatusIs]

       ## set icon to current status if added icon while already logged in
       if { [::MSN::myStatusIs] != "FLN" } {
               mailicon_proc [::hotmail::unreadMessages]
       }

}


proc taskbar_icon_handler { msg x y } {
	global iconmenu ishidden

	if { [winfo exists .bossmode] } {
		if { $msg=="WM_LBUTTONDBLCLK" } {
			wm state .bossmode normal
			focus -force .bossmode
		}
		return
	}

	if { $msg=="WM_RBUTTONUP" } {
		#tk_popup $iconmenu $x $y

		#workaround for bug with the popup not unposting
		# TODO: verify if this bug is only for old tk versions and/or if it happens on older windows versions
		# Tested with Win7 and Tk 8.5.7 and it seems just fine without the workaround!
		wm state .trayiconwin normal
		wm geometry .trayiconwin "+0+[expr {2 * [winfo screenheight .]}]"
		focus -force .trayiconwin

		tk_popup $iconmenu [expr "$x + 85"] [expr "$y - 11"] [$iconmenu index end]

		#workaround for bug with the popup not unposting
		wm state .trayiconwin withdrawn
	}
	if { $msg=="WM_LBUTTONDBLCLK" } {
		if { $ishidden == 0 } {
			#wm iconify .
			if { [wm state .] == "zoomed" } {
				set ishidden 2
			} else {
				set ishidden 1
			}
			wm state . withdrawn
			#set ishidden 1
		} else {
			#wm deiconify .
			#wm state . normal
			#raise .
			if { $ishidden == 2 } {
				wm state . zoomed
			} else {
				wm state . normal
			}
			focus -force .
			set ishidden 0
		}
	}
}

proc trayicon_callback {imgSrc imgDst width height} {
       $imgDst copy $imgSrc -compositingrule set
       if { [image width $imgSrc] > $width || [image height $imgSrc] > $height} {
               ::picture::ResizeWithRatio $imgDst $width $height
       }
}

proc trayicon_resize {w} {
	catch {
		set width [expr {[lindex [$w bbox] 2] - [lindex [$w bbox] 0] + 1}]
		set height [expr {[lindex [$w bbox] 2] - [lindex [$w bbox] 0] + 1}]
			
		set img [$w cget -image]
		if { [image width $img] != $width || [image height $img] != $height} {
			::picture::ResizeWithRatio $img $width $height
		}
	}
}

proc statusicon_callback { action } {
	global statusicon_callback_afterid

	if { [info exists statusicon_callback_afterid] } {
		catch { after cancel $statusicon_callback_afterid }
	}
	set statusicon_callback_afterid [after 250 [list statusicon_callback_delayed $action [winfo pointerx .] [winfo pointery .]]]
}

proc statusicon_callback_delayed { action x y} {
	global iconmenu

	if { $action == "ACTION" } {
		tk_popup $iconmenu $x $y
	}
	if { $action == "DOUBLE_ACTION" } {
		iconify_proc
	}
}

proc statusicon_proc {status} {
	global systemtray_exist statusicon list_states iconmenu wintrayicon defaultbackground use_tktray
	set cmdline ""

	if { [::config::getKey use_tray] == 0 && $status != "REMOVE"} { return }

	if { ![WinDock] } {

		if { $systemtray_exist == 1 && $statusicon == 0 && $status != "REMOVE" && [UnixDock]} {
			set pixmap "[::skin::GetSkinFile pixmaps doffline.png]"
			image create photo statustrayicon -file $pixmap
			set statusicon .si

			#add the icon
			if {$use_tktray} {
				tktray::icon .si -class "amsn-tray" -image statustrayicon
				after 1000 { trayicon_resize .si}
				bind $statusicon <<IconConfigure>> {trayicon_resize .si}
			} else {
				image create photo statustrayiconres
				set statusicon [newti .si -pixmap statustrayiconres -command "::trayicon_callback statustrayicon statustrayiconres"]
			}

			bind $statusicon <<Button1>> iconify_proc
			bind $statusicon <<Button3>> "tk_popup $iconmenu %X %Y"
		}
		if { $systemtray_exist == 1 && $statusicon == 0 && $status != "REMOVE" && [MacDock]} {
			set pixmap "[::skin::GetSkinFile pixmaps doffline.png]"
			#add the icon
			set statusicon [::statusicon::create statusicon_callback]
			::statusicon::setTooltip $statusicon "[trans offline]"
			::statusicon::setImage $statusicon $pixmap
		}
	} else {
		if { $systemtray_exist == 1 && $statusicon == 0 && $status != "REMOVE" } {
			trayicon_init
		}
	}

	set my_name [::abook::getPersonal MFN]
   	
	if { $systemtray_exist == 1 && $statusicon != 0 && $status == "REMOVE" } {
		if { [WinDock] } {
			winico taskbar delete $wintrayicon
		} else {
			remove_icon $statusicon
			if {[UnixDock] } {
				catch {
					image delete statustrayicon
					if {!$use_tktray} {
						image delete statustrayiconres
					}
				}
			}
		}
		set statusicon 0
	} elseif {$systemtray_exist == 1 && $statusicon != 0 && $status != "REMOVE"} {
		if { $status != "" } {
			if { $status == "FLN" } {
				# Send message 
				$iconmenu entryconfigure 2 -state disabled
				#Status submenu
				$iconmenu entryconfigure 4 -state disabled
				#Change nick/psm
				$iconmenu entryconfigure 6 -state disabled
				$iconmenu entryconfigure 7 -state disabled

				#Login/Logout
				$iconmenu entryconfigure 13 -label "[trans login]" -command "::MSN::connect" -state normal

			} else {

				$iconmenu entryconfigure 2 -state normal
				$iconmenu entryconfigure 4 -state normal
				$iconmenu entryconfigure 6 -state normal
				$iconmenu entryconfigure 7 -state normal

				$iconmenu entryconfigure 13 -label "[trans logout]" -command "preLogout \"::MSN::logout\""

				
			}
				
			switch $status {
			  "FLN" {
				set pixmap "[::skin::GetSkinFile pixmaps doffline.png]"
				set tooltip "[trans offline]"
				if { [WinDock] } {
					set trayicon [winico create [::skin::GetSkinFile winicons offline.ico]]
				}
			  }
			
			  "NLN" {
				set pixmap "[::skin::GetSkinFile pixmaps donline.png]"
				set tooltip "$my_name ([::config::getKey login]): [trans online]"
				if { [WinDock] } {
					set trayicon [winico create [::skin::GetSkinFile winicons online.ico]]
				}
			  }
			  
			  "IDL" {
				set pixmap "[::skin::GetSkinFile pixmaps dinactive.png]"
				set tooltip "$my_name ([::config::getKey login]): [trans noactivity]"
				if { [WinDock] } {
					set trayicon [winico create [::skin::GetSkinFile winicons inactive.ico]]
				}
			  }
			  "BSY" {
				set pixmap "[::skin::GetSkinFile pixmaps dbusy.png]"
				set tooltip "$my_name ([::config::getKey login]): [trans busy]"
				if { [WinDock] } {
					set trayicon [winico create [::skin::GetSkinFile winicons busy.ico]]
				}
			  }
			  "BRB" {
				set pixmap "[::skin::GetSkinFile pixmaps dbrb.png]"
				set tooltip "$my_name ([::config::getKey login]): [trans rightback]"
				if { [WinDock] } {
					set trayicon [winico create [::skin::GetSkinFile winicons brb.ico]]
				}
			  }
			  "AWY" {
				set pixmap "[::skin::GetSkinFile pixmaps daway.png]"
				set tooltip "$my_name ([::config::getKey login]): [trans away]"
				if { [WinDock] } {
					set trayicon [winico create [::skin::GetSkinFile winicons away.ico]]
				}
			  }
			  "PHN" {
				set pixmap "[::skin::GetSkinFile pixmaps dphone.png]"
				set tooltip "$my_name ([::config::getKey login]): [trans onphone]"
				if { [WinDock] } {
					set trayicon [winico create [::skin::GetSkinFile winicons phone.ico]]
				}
			  }
			  "LUN" {
				set pixmap "[::skin::GetSkinFile pixmaps dlunch.png]"
				set tooltip "$my_name ([::config::getKey login]): [trans gonelunch]"
				if { [WinDock] } {
					set trayicon [winico create [::skin::GetSkinFile winicons lunch.ico]]
				}
			  }
			  "HDN" {
				set pixmap "[::skin::GetSkinFile pixmaps dhidden.png]"
				set tooltip "$my_name ([::config::getKey login]): [trans appearoff]"
				if { [WinDock] } {
					set trayicon [winico create [::skin::GetSkinFile winicons hidden.ico]]
				}
			  }
			  "BOSS" {   
				#for bossmode
				set pixmap "[::skin::GetSkinFile pixmaps dboss.png]"
				set tooltip "[trans pass]"
				if { [WinDock] } {
					set trayicon [winico create [::skin::GetSkinFile winicons bossmode.ico]]
				}
			  }
			  default {
				set pixmap "null"
				set tooltip ""
				if { [WinDock] } {
					set trayicon [winico create [::skin::GetSkinFile winicons msn.ico]]
				}
			  }
			}

			$iconmenu entryconfigure 0 -label "[::config::getKey login]"
			if { [WinDock] } {
				if { ![winfo exists .bossmode] || $status == "BOSS" } {
					#skip if in bossmode and not setting to BOSS
					winico taskbar delete $wintrayicon
					set wintrayicon $trayicon
					winico taskbar add $wintrayicon -text $tooltip -callback "taskbar_icon_handler %m %x %y"
					set statusicon 1
				}

			} elseif {[UnixDock] } {
				if { $pixmap != "null"} {
					image create photo statustrayicon -file $pixmap
					if {!$use_tktray} {
						image create photo statustrayiconres
					}
				}
			} elseif {[MacDock] } {
				if { $pixmap == "null"} {
					::statusicon::setVisible $statusicon 0
				} else {
					::statusicon::setImage $statusicon $pixmap
					::statusicon::setTooltip $statusicon $tooltip
				}
			}

		}
	}
}

proc statusicon_blink_proc {status} {
    global systemtray_exist statusicon iconmenu wintrayicon use_tktray

    if { [::config::getKey use_tray] == 0 || $systemtray_exist == 0 || $statusicon == 0 } { return }

    set my_name [::abook::getPersonal MFN]
    
    if { $status != "" } {
        switch $status {
          "FLN" {
            set pixmap "[::skin::GetSkinFile pixmaps dofflineb.png]"
            set tooltip "[trans offline]"
            if { [WinDock] } {
                set trayicon [winico create [::skin::GetSkinFile winicons offlineb.ico]]
            }
          }
        
          "NLN" {
            set pixmap "[::skin::GetSkinFile pixmaps donlineb.png]"
            set tooltip "$my_name ([::config::getKey login]): [trans online]"
            if { [WinDock] } {
                set trayicon [winico create [::skin::GetSkinFile winicons onlineb.ico]]
            }
          }
          
          "IDL" {
            set pixmap "[::skin::GetSkinFile pixmaps dinactiveb.png]"
            set tooltip "$my_name ([::config::getKey login]): [trans noactivity]"
            if { [WinDock] } {
                set trayicon [winico create [::skin::GetSkinFile winicons inactiveb.ico]]
            }
          }
          "BSY" {
            set pixmap "[::skin::GetSkinFile pixmaps dbusyb.png]"
            set tooltip "$my_name ([::config::getKey login]): [trans busy]"
            if { [WinDock] } {
                set trayicon [winico create [::skin::GetSkinFile winicons busyb.ico]]
            }
          }
          "BRB" {
            set pixmap "[::skin::GetSkinFile pixmaps dbrbb.png]"
            set tooltip "$my_name ([::config::getKey login]): [trans rightback]"
            if { [WinDock] } {
                set trayicon [winico create [::skin::GetSkinFile winicons brbb.ico]]
            }
          }
          "AWY" {
            set pixmap "[::skin::GetSkinFile pixmaps dawayb.png]"
            set tooltip "$my_name ([::config::getKey login]): [trans away]"
            if { [WinDock] } {
                set trayicon [winico create [::skin::GetSkinFile winicons awayb.ico]]
            }
          }
          "PHN" {
            set pixmap "[::skin::GetSkinFile pixmaps dphoneb.png]"
            set tooltip "$my_name ([::config::getKey login]): [trans onphone]"
            if { [WinDock] } {
                set trayicon [winico create [::skin::GetSkinFile winicons phoneb.ico]]
            }
          }
          "LUN" {
            set pixmap "[::skin::GetSkinFile pixmaps dlunchb.png]"
            set tooltip "$my_name ([::config::getKey login]): [trans gonelunch]"
            if { [WinDock] } {
                set trayicon [winico create [::skin::GetSkinFile winicons lunchb.ico]]
            }
          }
          "HDN" {
            set pixmap "[::skin::GetSkinFile pixmaps dhiddenb.png]"
            set tooltip "$my_name ([::config::getKey login]): [trans appearoff]"
            if { [WinDock] } {
                set trayicon [winico create [::skin::GetSkinFile winicons hiddenb.ico]]
            }
          }
          "BOSS" {   
            #for bossmode
            set pixmap "[::skin::GetSkinFile pixmaps dboss.png]"
            set tooltip "[trans pass]"
            if { [WinDock] } {
                set trayicon [winico create [::skin::GetSkinFile winicons bossmode.ico]]
            }
          }
          default {
            set pixmap "null"
            set tooltip ""
            if { [WinDock] } {
                set trayicon [winico create [::skin::GetSkinFile winicons msn.ico]]
            }
          }
        }

	if {[::skin::getKey trayblink_by_status] == 0} {
            set pixmap "[::skin::GetSkinFile pixmaps trayblink.png]"
            if { [WinDock] } {
                set trayicon [winico create [::skin::GetSkinFile winicons trayblink.ico]]
            }
	}

        $iconmenu entryconfigure 0 -label "[::config::getKey login]"
        if { [WinDock] } {
            if { ![winfo exists .bossmode] || $status == "BOSS" } {
                #skip if in bossmode and not setting to BOSS
                winico taskbar delete $wintrayicon
                set wintrayicon $trayicon
                winico taskbar add $wintrayicon -text $tooltip -callback "taskbar_icon_handler %m %x %y"
                set statusicon 1
            }

        } elseif {[UnixDock] } {
            if { $pixmap != "null"} {
                image create photo statustrayicon -file $pixmap
		if {!$use_tktray} {
			image create photo statustrayiconres
		}
            }
        } elseif {[MacDock] } {
            if { $pixmap == "null"} {
                ::statusicon::setVisible $statusicon 0
            } else {
                ::statusicon::setImage $statusicon $pixmap
                ::statusicon::setTooltip $statusicon $tooltip
            }
        }

    }
}

proc taskbar_mail_icon_handler { msg x y } {
	if { $msg=="WM_LBUTTONUP" } {
		::hotmail::hotmail_login 
	}
}

proc mailicon_callback { action } {
	if { $action == "DOUBLE_ACTION" } {
		::hotmail::hotmail_login
	}   
}

proc mailicon_proc {num} {
	# Workaround for bug in the traydock-plugin - statusicon added - BEGIN
	global systemtray_exist mailicon statusicon winmailicon defaultbackground use_tktray
	# Workaround for bug in the traydock-plugin - statusicon added - END

	if { [::config::getKey showmailicon] == 0 } {
		return
	}

	if {$systemtray_exist == 1 && $mailicon == 0 && $num >0} {
		set pixmap "[::skin::GetSkinFile pixmaps unread_tray.gif]"
		if { $num == 1 } {
			set msg [trans onenewmail]
		} elseif { $num == 2 } {
			set msg [trans twonewmail 2]
		} else {
			set msg [trans newmail $num]
		}

		if { [WinDock] } {
			set winmailicon [winico create [::skin::GetSkinFile winicons unread.ico]]
			winico taskbar add $winmailicon -text $msg -callback "taskbar_mail_icon_handler %m %x %y"
			set mailicon 1
		} elseif {[UnixDock] } {
			image create photo mailtrayicon -file $pixmap
			if {$use_tktray} {
				catch {destroy .mi}
				set mailicon .mi
				tktray::icon .mi -image mailtrayicon
				after 1000 { trayicon_resize .mi}

				bind .mi <<IconConfigure>> {trayicon_resize .mi}
			} else {
				image create photo mailtrayiconres
				set mailicon [newti .mi -pixmap mailtrayiconres -command "::trayicon_callback mailtrayicon mailtrayiconres"]
			} 

			bind .mi <Button-1> "::hotmail::hotmail_login"
			bind .mi <Enter> [list balloon_enter %W %X %Y $msg]
			bind .mi <Motion> [list balloon_motion %W %X %Y $msg]
			bind .mi <Leave> "+set Bulle(first) 0; kill_balloon"
		} elseif {[MacDock] } {
			#add the icon
			set mailicon [::statusicon::create mailicon_callback]
			::statusicon::setTooltip $mailicon $msg
			::statusicon::setImage $mailicon $pixmap
		}

	} elseif {$systemtray_exist == 1 && $mailicon != 0 && $num == 0} {
		if { [WinDock] } {
			winico taskbar delete $winmailicon
		} else {
			remove_icon $mailicon
			if {[UnixDock] } {
				catch {
					image delete mailtrayicon
					if {!$use_tktray} {
						image delete mailtrayiconres
					}
				}
			}
		}
		set mailicon 0
	} elseif {$systemtray_exist == 1 && $mailicon != 0 && $num > 0} {
		set froms [::hotmail::getFroms]
		set fromsText ""
		foreach {from frommail} $froms {
			append fromsText "\n[trans newmailfrom $from $frommail]"
		}

		if { $num == 1 } {
			set msg "[trans onenewmail]\n$fromsText"
		} elseif { $num == 2 } {
			set msg "[trans twonewmail 2]\n$fromsText"
		} else {
			set msg "[trans newmail $num]\n$fromsText"
		}
		if { [WinDock] } {
			winico taskbar modify $winmailicon -text $msg
		} elseif {[UnixDock] } {
			bind $mailicon <Enter> [list balloon_enter %W %X %Y $msg]
			bind $mailicon <Motion> [list balloon_motion %W %X %Y $msg]
		} elseif {[MacDock] } {
			::statusicon::setTooltip $mailicon $msg
		}
	} 
}

proc remove_icon {icon} {
	global systemtray_exist use_tktray
	if {$icon != 0} {
		# Can't use UnixDock and MacDock because if we remove the icon
		# it might be because the user disabled the 'use_tray' option
		# so those functions would always return false...
		if {[OnLinux] || [OnBSD]} {
			if {$use_tktray} {
				catch {destroy $icon}
			} else {
				catch {removeti $icon}
			}
		} elseif {[OnMac] } {
			catch { ::statusicon::destroy $icon}
		}
	}
}

proc restart_tray { } {

    status_log "RESTARTING the traydock"

    statusicon_proc "REMOVE"
    statusicon_proc [::MSN::myStatusIs]
    
}