~amsn-daily/amsn/amsn-packaging

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
#!/bin/bash
# \
exec wish $0

###
###
################################################################
###                                              ###############
###        Alvaro's Messenger - amsn             ###############
###                                              ###############
###       http://www.amsn-project.net            ###############
###     amsn-users@lists.sourceforge.net         ###############
###                                              ###############
################################################################
### airadier at users.sourceforge.net (airadier) ###############
### Universidad de Zaragoza                      ###############
### http://aim.homelinux.com                     ###############
################################################################
### grimaldo@panama.iaehv.nl (LordOfScripts)     ###############
### http://www.coralys.com/linux/                ###############
################################################################
### Original ccmsn                               ###############
### http://msn.CompuCreations.com/               ###############
### Dave Mifsud <dave at CompuCreations dot com> ###############
################################################################
###
###
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; version 2 of the License
###
### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
### GNU General Public License for more details.
###
### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
###
###



############################################################
### Try to load tk and make sure tcl/tk is new enough for us
############################################################
package require Tk

if {$::tcl_version <= 8.3} {
	tk_messageBox -default ok -message "You need TCL/TK 8.4\
	 or better to run aMSN. Please upgrade."  -icon warning
	exit
}
#Q: can't this be done in 1 check like "[package require Tk] > 8.3" ?
#A: not on windows because you want any version of Tk to be loaded to show the messagebox

############################################################
### Hide the main window until it has been fully displayed
############################################################
wm state . withdrawn


############################################################
### Some global variables
############################################################
# variable rcversion so autoupdate has no problems, version is used to be easier for users
# rcversion major.minor.patch, patch is 91,92 for RC's and after a release we put .svn
# behind the version (after 0.95.90 comes 0.95.90.svn, after 0.96 comes 0.96.90.svn)
set version "0.97b"
set rcversion "0.96.90.svn"
set date "06/16/2006"
set weburl "http://www.amsn-project.net"
set program_dir "."
set HOME ""
set HOME2 ""
# distributions can change vendor if they provide a patched version of amsn so we
# can filter out bug reports only occuring with a particular vendor
set vendor "aMSN"

#=======================================================================


############################################################
### Look if we are launched from a link
### and set the correct working dir
############################################################

#Fixed by Tomasz Nguyen
set program_dir [file dirname [info script]]
set program [file tail [info script]]

while {[catch {file readlink [file join $program_dir $program]} program]== 0} {
	if {[file pathtype $program] == "absolute"} {
		set program_dir [file dirname $program]
	} else {
		set program_dir [file join $program_dir [file dirname $program]]
	}

	set program [file tail $program]
}

set starting_dir [pwd]
cd $program_dir
set program_dir [pwd]
unset program
#unset program_dir

############################################################
### From here we need amsncore, for platform checks etc
###  so we load it.  Don't use anything that depends on 
###  utils packages yet though!
############################################################

source amsncore.tcl

############################################################
### Setup other important directory paths
### depending on the platform
############################################################

if { [OnDarwin] } {
   set HOME "[file join $env(HOME) Library/Application\ Support/amsn]"
} elseif { [OnUnix] } {
   set HOME "[file join $env(HOME) .amsn]"
} elseif { [OnWin] } {
  if {[info exists env(USERPROFILE)]} {
     set HOME "[file join $env(USERPROFILE) amsn]"
  } else {
   set HOME "[file join [pwd] amsn_config]"
  }
} else {
   set HOME "[file join [pwd] amsn_config]"
}
set HOME2 $HOME

############################################################
### And setup where to find optional packages
############################################################

lappend auto_path [file join ${HOME} plugins]
#Specific folder to check for package on platforms
if { [OnDarwin] } {
	lappend auto_path [file join utils macosx]
} elseif { [OnWin] } {
	lappend auto_path [file join utils windows]
} elseif { [OnLinux] } {
	lappend auto_path [file join utils linux]
}
lappend auto_path [file join utils]

set libtls ""

catch { source [file join $HOME tlsconfig.tcl] }

if { $libtls != "" && [lsearch $auto_path $libtls] == -1 } {
    lappend auto_path $libtls
}

#TODO: Move this from here ??
#///////////////////////////////////////////////////////////////////////
#Notebook Pages (Buddies,News,Calendar,etc.)
set pgBuddy ""
set pgNews  ""
#///////////////////////////////////////////////////////////////////////


############################################################
#### Load program modules
############################################################
set initialize_amsn 1

proc load_console {} {
	if { [info proc console] == "" && [info command console] == "" } {
		if { [file exists console.tcl] && [file readable console.tcl] } {
			uplevel \#0 {source console.tcl}
			console show
		}
	} else {
		console show
	}
}


proc reload_files { } {
    uplevel \#0 {

	# amsncore.tcl is already loaded but we'll re-source it here in case we manually do reload_files
	source amsncore.tcl
	source audio.tcl;	#audio API

	source ctthemes.tcl
	source progressbar.tcl	;# Progressbar Megawidget
	source migmd5.tcl
	source des.tcl		;# DES encryption
	source sxml.tcl   	;# Simple XML parser
	package require combobox 2.3
	source mutex.tcl
	source lang.tcl
	source automsg.tcl
	source smileys.tcl
	source skins.tcl	;# Used for skinning purposes
	source remote.tcl	;# The remote control procedures
	source assistant.tcl
	source chatwindow.tcl	;# Abstracted Chat Window code (::ChatWindow namespace)
	source picture.tcl ; #Tkcximage procs
	source login_screen.tcl ;# WLM style login screen
	source gui.tcl		;#gui.tcl must be at the beginning to make msg_box procedure available for errors
	source abook.tcl	;# Handle buddy address book    
	source protocol.tcl
	source plugins.tcl	;# Plugins system must be loaded before config
	source pluginslog.tcl
	source config.tcl	;# config needs to be loaded before pluginslog for translations
	source proxy.tcl
	source msnp2p.tcl
	source msncam.tcl
	source preferences.tcl
	source hotmail.tcl
	source groups.tcl	;# Handle buddy groups
	source soap.tcl

	if { [OnDarwin] } {
		source [file join utils macosx applescript ae.tcl];#AppleEvent support
	}
	
	source alarm.tcl	;# Alarms code (Burger)
	source dock.tcl		;# Docking routines
	source trayicon.tcl	;# Docking routines for freedesktop system tray compliant docks
	source loging.tcl	;# Euh yeh it's for loging :P
	source searchdialog.tcl ;# Search dialog widget

	source balloon.tcl	;# For the balloons tooltip
	source autoupdate.tcl   ;# AUTOUPDATE!!!!!!!!!! :@
	source notes.tcl
	
	source guicontactlist.tcl ;# New contact list (uses canvas)
	source bugs.tcl 	  ;# bug reporting
	source spaces.tcl         ;# MSN Space handling functions
    }
    #As we reloaded amsncore, the version has been resetted and maybe amsn is the newest file
    ::Version::setSubversionId {$Id$}
}

proc after_info { } {
	foreach f [after info] {
		status_log "After $f : [after info $f]\n" red
	}
}

reload_files

set initialize_amsn 0
#///////////////////////////////////////////////////////////////////////

if { [catch {package require tls}] } {
    # Either tls is not installed, or $auto_path does not point to it.
    # Should now never happen; the check for the presence of tls is made
    # before this point.
#    status_log "Could not find the package tls on this system.\n"
    set tlsinstalled 0
} else {
    set tlsinstalled 1
}

#create_dir $HOME
set log_dir "[file join ${HOME} logs]"
set webcam_dir "[file join ${HOME} webcam]"
create_dir $log_dir
create_dir $webcam_dir

NS create ns -stat d -server [split [::config::getKey start_ns_server] ":"]

set family [lindex [::config::getGlobalKey basefont] 0]
set size [lindex [::config::getGlobalKey basefont] 1]

::themes::Init
if { $family == "" } { set family "Helvetica"}
if { $size == "" } { set size "11"}
::amsn::initLook $family $size [::config::getKey backgroundcolor]
foreach font [font families] {
	set allfonts([string tolower $font]) $font
}

# Bye bye hidden files in file dialogs (works fine with Mac even without this).
if {[OnLinux]} {
	catch { tk_getOpenFile -w00t } ;# start file dialog with unknown option
	set ::tk::dialog::file::showHiddenVar 0
	set ::tk::dialog::file::showHiddenBtn 1
}

set ::auto_encoding [encoding system]

if { [::config::getKey encoding] != "auto" } {
  set_encoding [::config::getKey encoding]
}

cmsn_draw_main

bind all <KeyPress> "set idletime 0"

idleCheck

degt_protocol_win
degt_ns_command_win

#after 500 proc_ns
#after 750 proc_sb

if {$version != [::config::getGlobalKey last_client_version]} {
   ::amsn::aboutWindow
   catch {file delete [file join $HOME2 bugreport.amsn]}
   #Force to change to Lucida Grande 12 on OS X, just one time when we switch version
   if { [OnMac] } {
      ::config::setGlobalKey basefont [list {Lucida Grande} 12 normal]
      ::config::setKey browser "open \$url"
   }
}

update idletasks

init_dock

if {[::config::getKey startontray]} {
	if { ![catch {package require libtray}] && $::systemtray_exist == 1 } {
		wm state . withdrawn
		set ishidden 1
	} else {
		wm state . iconic
	}
} else {
	wm state . normal
}

if { [::config::getKey autoconnect] == 1 } {
  ::MSN::connect
}

if { [::config::getKey autocheckver] == 1 } {
    set new [::autoupdate::check_version_silent]
}


# This is a temporary proc to test amsn2 code while still being able to use the amsn1 code base... 
# keep it until amsn2 is stable enough to stand on its own feet...
proc reload_amsn2 { } {
    lappend ::auto_path [file join [pwd] .. amsn2]

    package forget aMSN2_Core
    package forget aMSN2_Protocols
    package forget MSNP

    package require aMSN2_Core
}






vwait events

# DO NOT WRITE ANY CODE BELOW THESE LINESSSSSSSSSS FOR ANY CODE TO BE ADDED, WRITE IT BEFORE THE 'vwait events' BECAUSE THAT LINE HANGS THE SCRIPT THERE FOREVER...