This file is indexed.

/usr/share/amsn/plugins/Invisibility/Invisibility.tcl is in amsn-data 0.98.9-1.

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
################################################################
#        ::Invisibility by Anto Cvitic  #
#	 Version 0.5 by Kemal Ilgar Eroglu -- September 2008
#
# This code is released under the GNU Public License Version 3
#  =============================================================
# Invisibility will block contacts  when they go offline
# and unblock them when they change their state to online,
# with the exception of permanently allowed or blocked users.
################################################################


rename ::amsn::blockUser ::amsn::blockUserOrig
rename ::amsn::unblockUser ::amsn::unblockUserOrig
		
namespace eval ::Invisibility {

	proc Init { dir } {
		::plugins::RegisterPlugin "Invisibility"
		plugins_log "Invisibility"  "Registered plugin"

		::plugins::RegisterEvent "Invisibility" ChangeState blockContact
		::plugins::RegisterEvent "Invisibility" OnConnect dummy
		plugins_log "Invisibility"  "Registered events"

		set langdir [file join $dir "lang"]
		set lang [::config::getGlobalKey language]
		#It's important to load the english file and then the current language lang file
		load_lang en $langdir
		load_lang $lang $langdir
		
		array set ::Invisibility::config {
			iblocklist {}
			iallowlist {}
			win {}
			oldbehav {0}
			waitingtime {4000}
			automat {1}
		}

		set ::Invisibility::configlist [list \
			[list frame ::Invisibility::populateFrame ] \
			[list bool [trans old_behav] oldbehav] \
			[list bool [trans otomat] automat] \
			]				

	}

######################################
# The proc that does the (un)blocking
######################################	
	proc blockContact { event evpar } {

		upvar 2 user user
		upvar 2 substate substate
		#plugins_log "Invisibility" "user is: $user and substate is: $substate"

		if { $substate == "FLN" && [lsearch -exact $::Invisibility::config(iallowlist) $user] == -1} {

			::MSN::blockUser ${user}
			after 500 ::Event::fireEvent contactStateChange protocol $user
			plugins_log "Invisibility"  "blocked $user"
		}

		# Old behaviour: Contacts are unblocked only when 
		# they switch to "Online" state
		
		if { $::Invisibility::config(oldbehav) } {
			if { $substate == "NLN" && [lsearch -exact $::Invisibility::config(iblocklist) $user] == -1 }  {

				::MSN::unblockUser ${user}
				after 500 ::Event::fireEvent contactStateChange protocol $user
				plugins_log "Invisibility"  "unblocked $user"			
			}
		# New behavior: Unblock contacts when they become visible		
		} else {
			if { $substate != "FLN" && [lsearch -exact $::Invisibility::config(iblocklist) $user] == -1 }  {

				::MSN::unblockUser ${user}
				after 500 ::Event::fireEvent contactStateChange protocol $user
				plugins_log "Invisibility"  "unblocked $user"			
			}		
		}

	}

######################################
# Add a permanently blocked user
######################################	
	proc AddPermBlock { } {

		set wind $::Invisibility::config(win)
		set user [$wind.clistbox get]

		# If user exists in allow list, we romeve it from there first		
		set rmin [lsearch -exact $::Invisibility::config(iallowlist) $user]
		if { $rmin !=-1 } {
			set ::Invisibility::config(iallowlist) [lreplace $::Invisibility::config(iallowlist) $rmin $rmin]
			::Invisibility::GenerateList "allow"
		}

		# If not already in the block list, we add		
		if { [lsearch -exact $::Invisibility::config(iblocklist) $user] == -1} {
			lappend ::Invisibility::config(iblocklist) $user
			$wind.status.block.blist insert end $user
		}

		# And we unblock the user:
		::MSN::blockUser $user
				
	}

######################################
# Add a permanently allowed user
######################################	

	proc AddPermUnBlock { } {

		set wind $::Invisibility::config(win)
		set user [$wind.clistbox get]

		# If user exists in block list, we romeve it from there first
		set rmin [lsearch -exact $::Invisibility::config(iblocklist) $user]
		if { $rmin !=-1 } {
			set ::Invisibility::config(iblocklist) [lreplace $::Invisibility::config(iblocklist) $rmin $rmin]
			::Invisibility::GenerateList "block"
		}

		# If not already in the allow list, we add
		if { [lsearch -exact $::Invisibility::config(iallowlist) $user] == -1} {
			lappend ::Invisibility::config(iallowlist) $user
			$wind.status.allow.alist insert end $user
		}
		
		# And we unblock the user:
		::MSN::unblockUser $user
		
		#puts "\n $user --> [::abook::getVolatileData $user state]"	
	}

######################################
# Remove a permanently blocked user
######################################	

	proc RemPermBlock { } {

		set wind $::Invisibility::config(win)
		
		set rm [$wind.status.block.blist curselection]
		
		if { [llength $rm] != 0 } {
			set rmin [lindex $rm 0]
			set user [$wind.status.block.blist get $rmin]
			$wind.status.block.blist delete $rmin $rmin
			set rmin2 [lsearch -exact $::Invisibility::config(iblocklist) $user]
			if { $rmin2 != -1 } {
				set ::Invisibility::config(iblocklist) [lreplace $::Invisibility::config(iblocklist) $rmin2 $rmin2]
			}
		}
		
	}

######################################
# Remove a permanently allowed user
######################################	

	proc RemPermUnBlock { } {

		set wind $::Invisibility::config(win)
		
		set rm [$wind.status.allow.alist curselection]
		
		if { [llength $rm] != 0 } {
			set rmin [lindex $rm 0]
			set user [$wind.status.allow.alist get $rmin]
			$wind.status.allow.alist delete $rmin $rmin
			set rmin2 [lsearch -exact $::Invisibility::config(iallowlist) $user]
			if { $rmin2 != -1 } {
				set ::Invisibility::config(iallowlist) [lreplace $::Invisibility::config(iallowlist) $rmin2 $rmin2]
			}
		}
		
	}		

######################################
# Generate the permanent allow/block
# listboxes in the config window.
######################################	

	proc GenerateList { listname } {
	
		set wind $::Invisibility::config(win)
		
		if { $listname eq "allow" } {
			$wind.status.allow.alist delete 0 end
			foreach entry [lsort -dictionary $::Invisibility::config(iallowlist)] {
				$wind.status.allow.alist insert end $entry
			}			
		} elseif { $listname eq "block" } {
			$wind.status.block.blist delete 0 end
			foreach entry [lsort -dictionary $::Invisibility::config(iblocklist)] {
				$wind.status.block.blist insert end $entry
			}
		}
			
	}
######################################
# The proc to populate the frame
# in the config window
######################################	

	proc populateFrame { win } {
		variable win_path
		set win_path $win
		set ::Invisibility::config(win) $win

		frame $win.status -class Degt
		pack $win.status -anchor w
		
		frame $win.status.block
		pack $win.status.block -anchor w
		label $win.status.block.blocklabel -text "[trans pblist]"
		listbox $win.status.block.blist -selectmode single -width 32 -yscrollcommand "$win.status.block.sb set"
		scrollbar $win.status.block.sb -command "$win.status.block.blist yview"
		
		
		button $win.status.block.rempb -text "[trans rempb]" -command ::Invisibility::RemPermBlock
		
		grid $win.status.block.blocklabel -row 1 -column 1 -columnspan 2 -sticky w
		grid $win.status.block.sb -row 2 -column 2 -sticky e
		grid $win.status.block.blist -row 2 -column 1 -sticky wns
		grid $win.status.block.rempb -row 3 -column 1 -columnspan 2 -sticky ew
	
		frame $win.status.allow -padx 15
		pack $win.status.allow -anchor w
		
		label $win.status.allow.allowlabel -text "[trans palist]"
		listbox $win.status.allow.alist -selectmode single -width 32 -yscrollcommand "$win.status.allow.sb set"
		scrollbar $win.status.allow.sb -command "$win.status.allow.alist yview"
		button $win.status.allow.rempa -text "[trans rempa]" -command ::Invisibility::RemPermUnBlock
		
		grid $win.status.allow.allowlabel -row 1 -column 1 -columnspan 2 -sticky w
		grid $win.status.allow.sb -row 2 -column 2 -sticky e
		grid $win.status.allow.alist -row 2 -column 1 -sticky wns
		grid $win.status.allow.rempa -row 3 -column 1 -columnspan 2 -sticky ew
		
		grid $win.status.allow -row 1 -column 2
		grid $win.status.block -row 1 -column 1	
		
		::Invisibility::GenerateList "allow"
		::Invisibility::GenerateList "block"
		
		label $win.clist -text "[trans allcont]" -pady 5
		combobox::combobox $win.clistbox -width 30 -editable 0
		$win.clistbox list delete 0 end
		set conlist [::abook::getAllContacts]
		set rem_ind [lsearch -exact $conlist "myself"]
		set conlist [lreplace $conlist $rem_ind $rem_ind]
		set rem_ind [lsearch -exact $conlist "contactlist"]
		set conlist [lreplace $conlist $rem_ind $rem_ind]
		foreach entry [lsort -dictionary $conlist] {
			$win.clistbox list insert end $entry
		}
		$win.clistbox select 0
		
		button $win.addpb -text "[trans addpb]" -command ::Invisibility::AddPermBlock 
		button $win.addpa -text "[trans addpa]" -command ::Invisibility::AddPermUnBlock
		
		pack $win.clist -anchor c
		pack $win.clistbox -anchor n -pady 5
		pack $win.addpb -anchor n -pady 5
		pack $win.addpa -anchor n
		
		frame $win.waittime
		pack $win.waittime -anchor c
		label $win.waittime.waittext -text "[trans waittext]"
		spinbox $win.waittime.spin -from 2000 -to 30000 -increment 500 -textvariable ::Invisibility::config(waitingtime)
		grid $win.waittime.waittext -row 1 -column 1
		grid $win.waittime.spin -row 1 -column 2
	}

#####################################
# dummy proc. Very useful :).
#####################################	

	proc dummy {event evpar} {
		after $::Invisibility::config(waitingtime) ::Invisibility::unblockNeutrals $event $evpar
	}
######################################
# The proc that unblocks neutral users
# at login time.
######################################	
	proc unblockNeutrals { event evpar } {

		
		plugins_log "Invisibility" "unblocking neutrals"

		set conlist [::abook::getAllContacts]
		set rem_ind [lsearch -exact $conlist "myself"]
		set conlist [lreplace $conlist $rem_ind $rem_ind]
		set rem_ind [lsearch -exact $conlist "contactlist"]
		set conlist [lreplace $conlist $rem_ind $rem_ind]
		
		foreach user $conlist {
		
			set userstate [::abook::getVolatileData $user state]
			
			if { $::Invisibility::config(oldbehav) } {
				if { $userstate == "NLN" && [lsearch -exact $::Invisibility::config(iblocklist) $user] == -1 } {
					after 25
					::MSN::unblockUser ${user}
					after 25 ::Event::fireEvent contactStateChange protocol $user
					plugins_log "Invisibility"  "unblocked $user"			
				}							
			} else {
				if { $userstate != "" && $userstate != "FLN" && [lsearch -exact $::Invisibility::config(iblocklist) $user] == -1 } {
					after 25
					::MSN::unblockUser ${user}
					after 25 ::Event::fireEvent contactStateChange protocol $user
					plugins_log "Invisibility"  "unblocked $user"			
				}
			}
		#plugins_log "Invisibility" "\n $user --> [::abook::getVolatileData $user state]"
		}
	}	

######################################
# We need this so that when trans is 
# called in the new lock/unblock 
# procs (created in ::amsn) it returns
# the translated keys defined in this
# plugin.
######################################

	proc localtrans {key} {
		return [trans $key]
	}
######################################
# Restore the original block/unblock
# and say bye-bye.
######################################
	proc deInit { } {
		plugins_log "Invisibility" "deleting new definitions"
		rename ::amsn::unblockUser ""
		rename ::amsn::blockUser ""
		plugins_log "Invisibility" "restoring definitions"
		rename ::amsn::unblockUserOrig ::amsn::unblockUser
		rename ::amsn::blockUserOrig ::amsn::blockUser
		plugins_log "Invisibility" "restored definitions"
		::plugins::UnRegisterEvents "Invisibility"
		plugins_log "Invisibility" "plugin unregistered"
	}



######################################
# The new block proc.
######################################

	proc ::amsn::blockUser {user_login} {
		
		set answer [::amsn::messageBox "[trans confirmbl] ($user_login)" yesno question [trans block]]
		if { $answer == "yes"} {

			::MSN::blockUser ${user_login}
		
		
			if { $::Invisibility::config(automat) } {
				set answer "yes"
			} else {
				set answer [::amsn::messageBox "[::Invisibility::localtrans invconfirmbl] ($user_login)" yesno question [::Invisibility::localtrans invblock]]
			}
			
			if { $answer == "yes"} {
				
				# If user exists in allow list, we romeve it from there first		
				set rmin [lsearch -exact $::Invisibility::config(iallowlist) $user_login]
				if { $rmin !=-1 } {
					set ::Invisibility::config(iallowlist) [lreplace $::Invisibility::config(iallowlist) $rmin $rmin]
				}

				# If not already in the block list, we add		
				if { [lsearch -exact $::Invisibility::config(iblocklist) $user_login] == -1} {
					lappend ::Invisibility::config(iblocklist) $user_login
				}

			}
		}	
	}
	######################################
	# The new unblock proc.
	######################################

	proc ::amsn::unblockUser {user_login} {
		
		::MSN::unblockUser ${user_login}

		set rmin2 [lsearch -exact $::Invisibility::config(iblocklist) $user_login]
		if { $rmin2 != -1 } {	
			if { $::Invisibility::config(automat) } {
				set answer "yes"
			} else {
				set answer [::amsn::messageBox "[::Invisibility::localtrans invconfirmunbl] ($user_login)" yesno question [::Invisibility::localtrans invblock]]
			}
			
			if { $answer == "yes"} {
				set ::Invisibility::config(iblocklist) [lreplace $::Invisibility::config(iblocklist) $rmin2 $rmin2]
			}
		}
	}

}