filemorph

Check-in [679025187c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Tweak version check
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:679025187ca2f8a8e341902c2aa4554f8b3823f5
User & Date: kevin 2017-01-16 02:30:48
Context
2017-01-16
03:01
Tweak version check check-in: d0287b1faa user: kevin tags: trunk
02:30
Tweak version check check-in: 679025187c user: kevin tags: trunk
01:30
Update to installer check-in: d6928c2ee5 user: kevin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to scriptlibs/softwareupdate/softwareupdate.tcl.

    22     22       variable tmpdir
    23     23       variable currentinstall
    24     24       variable versionnumber
    25     25       
    26     26       switch [tk windowingsystem] {
    27     27   	"aqua" {
    28     28   	    set tmpdir $::env(TMPDIR)
    29         -
    30     29   	}
    31     30   	
    32     31   	"win32" {
    33     32   	    set tmpdir $::env(TMP)
    34     33   	}
    35     34   	
    36     35   	"x11" {
................................................................................
    71     70   
    72     71   	if [catch {http::geturl $versionurl} msg] {
    73     72   	    puts "error: $msg"
    74     73   	    tk_messageBox -icon warning -title "Unable to Connect to Server" -message "Unable to Connect to Server" -detail "Unable to connect to www.codebykevin.com to check for updates. Please make sure you are connected to the Internet." -parent .
    75     74   	    return
    76     75   	} 
    77     76   
    78         -	set versionnumber [http::data [http::geturl $versionurl]]
           77  +	set versionnumber [string trim [http::data [http::geturl $versionurl]]]
    79     78   	if {$currentversion < $versionnumber} {
    80     79   	    softwareupdate::updatePitch
    81     80   	} else {
    82     81   	    softwareupdate::upToDate
    83     82   	}
    84         -}
           83  +    }
    85     84   
    86         -#define the current version of the software
    87         -proc setVersion {app number} {
    88         -    variable currentversion
    89         -    variable appname
    90         -    set currentversion $number
    91         -    set appname $app
    92         -    
    93         -}
    94         -
    95         -
    96         -#get the current installation path
    97         -proc findCurrentInstallation {} {
    98         -    variable currentinstall
    99         -    variable appname 
   100         -    switch [tk windowingsystem] {
   101         -
   102         -	"aqua" {
   103         -	    set approot [info nameofexecutable]
   104         -	    set apppath [split $approot /]
   105         -	    set currentinstall [join [lrange $apppath 0 [lsearch $apppath "*.app"]] / ]
   106         -	}
           85  +    #define the current version of the software
           86  +    proc setVersion {app number} {
           87  +	variable currentversion
           88  +	variable appname
           89  +	set currentversion $number
           90  +	set appname $app
   107     91   	
   108         -	"win32" {
   109         -	    set currentinstall [file join $::env(APPDATA) ${appname}_App]  
           92  +    }
           93  +
           94  +
           95  +    #get the current installation path
           96  +    proc findCurrentInstallation {} {
           97  +	variable currentinstall
           98  +	variable appname 
           99  +	switch [tk windowingsystem] {
          100  +
          101  +	    "aqua" {
          102  +		set approot [info nameofexecutable]
          103  +		set apppath [split $approot /]
          104  +		set currentinstall [join [lrange $apppath 0 [lsearch $apppath "*.app"]] / ]
          105  +	    }
          106  +	    
          107  +	    "win32" {
          108  +		set currentinstall [file join $::env(APPDATA) ${appname}_App]  
          109  +	    }
          110  +	    
          111  +	    "x11" {
          112  +		return
          113  +	    }
   110    114   	}
   111    115   	
   112         -	"x11" {
   113         -	    return
   114         -	}
          116  +	return $currentinstall
          117  +
   115    118       }
   116         -    
   117         -    return $currentinstall
   118         -
   119         -}
   120    119   
   121    120   
   122    121   
   123         -#prompt user to update
   124         -proc updatePitch {} {
   125         -    variable appname
   126         -    variable icon
   127         -    variable changedata
   128         -    variable currentversion
   129         -    variable versionnumber
          122  +    #prompt user to update
          123  +    proc updatePitch {} {
          124  +	variable appname
          125  +	variable icon
          126  +	variable changedata
          127  +	variable currentversion
          128  +	variable versionnumber
   130    129   
   131         -    catch {destroy .updateprogress}
          130  +	catch {destroy .updateprogress}
   132    131   
   133         -    catch {destroy .update}
   134         -    
          132  +	catch {destroy .update}
          133  +	
   135    134   	variable appname
   136    135   
   137    136   	set changeurl https://www.codebykevin.com/$appname-changes.tcl
   138    137   
   139    138           if [catch {http::geturl $changeurl} msg] {
   140    139   	    puts "error: $msg"
   141    140   	    tk_messageBox -icon warning -title "Unable to Connect to Server" -message "Unable to Connect to Server" -detail "Unable to connect to www.codebykevin.com to check for updates. Please make sure you are connected to the Internet." -parent .
................................................................................
   153    152   	    no {
   154    153   		destroy $updateanswer
   155    154   		return
   156    155   	    }
   157    156   	    
   158    157   	}
   159    158   
   160         -}
          159  +    }
   161    160   
   162         -proc winPitch {name newversion oldversion} {
   163         -    set answer [tk_messageBox  -icon info -title "New Version Available" -message "New Version Available" -detail "$name $newversion is available--you have $oldversion. Would you like to download it now?" -type yesno
   164         -	       ]
          161  +    proc winPitch {name newversion oldversion} {
          162  +	set answer [tk_messageBox  -icon info -title "New Version Available" -message "New Version Available" -detail "$name $newversion is available--you have $oldversion. Would you like to download it now?" -type yesno
          163  +		   ]
   165    164   
   166         -    switch -- $answer {
   167         -	yes {
          165  +	switch -- $answer {
          166  +	    yes {
   168    167   
   169         -	    xplat::launch https://www.codebykevin.com/$name.html
   170         -	}
   171         -	no {
   172         -	    return
          168  +		xplat::launch https://www.codebykevin.com/$name.html
          169  +	    }
          170  +	    no {
          171  +		return
          172  +	    }
   173    173   	}
   174    174       }
   175         -}
   176         -#"busy" dialog
   177         -proc checkingForUpdates {} {
   178         -
   179         -    variable appname
   180         -    variable icon
   181         -
   182         -    catch {destroy .updateprogress}
   183         -
   184         -    toplevel .updateprogress 
   185         -    wm title .updateprogress "Updating $appname"
   186         -
   187         -    wm withdraw .updateprogress
   188         -    update idletasks
   189         -
   190         -    ttk::frame .updateprogress.f -padding 5
   191         -    pack .updateprogress.f -fill both -expand yes
   192         -
   193         -    label .updateprogress.f.l -bg gray95 -image $icon -bd 0 -relief flat -highlightthickness 0 -width [image width $icon] -height [image height $icon]
   194         -    pack .updateprogress.f.l -side left -fill both -expand yes
   195         -
   196         -    frame .updateprogress.f.r -bg gray95 -bd 0 -highlightcolor gray95
   197         -    pack .updateprogress.f.r -side right -fill both -expand yes
   198         -    
   199         -    
   200         -    ttk::label .updateprogress.f.r.t -text "Checking for updates..." -padding 5
   201         -    pack .updateprogress.f.r.t -side top -fill both -expand yes
   202         -
   203         -    ttk::frame .updateprogress.f.r.f -padding 5
   204         -    pack .updateprogress.f.r.f -side top -fill both -expand yes
   205         -    
   206         -    ttk::progressbar .updateprogress.f.r.f.progress -mode indeterminate -orient horizontal
   207         -    pack .updateprogress.f.r.f.progress -fill both -expand yes -side top
   208         -
   209         -    .updateprogress.f.r.f.progress start
   210         -
   211         -    ttk::button .updateprogress.f.r.f.b -text "Cancel" -command {destroy .updateprogress}
   212         -
   213         -    pack .updateprogress.f.r.f.b -side bottom -fill both -expand no
   214         -
   215         -    wm geometry .updateprogress 400x100
   216         -    wm resizable .updateprogress 0 0
   217         -
   218         -    wm deiconify .updateprogress
   219         -    raise .updateprogress
   220         -
   221         -    wm transient .updateprogress .
   222         -
   223         -}
   224         -
   225         -#dialog if current version is installed
   226         -proc upToDate {} {
   227         -    variable appname
   228         -    variable currentversion
   229         -
   230         -    catch {destroy .updateprogress}
   231         -
   232         -    tk_messageBox  -icon info -title "Up to Date" -message "You're up to date!" -detail "$appname $currentversion is the currently the newest version available."
   233         -
   234         -}
   235         -
   236         -#show progress of installation
   237         -proc progressDialog {} {
   238         -
   239         -    variable appname
   240         -    variable status
   241         -    variable icon
   242         -
   243         -    catch {destroy .downloadprogress}
   244         -
   245         -    toplevel .downloadprogress
   246         -    wm title .downloadprogress "Updating $appname"
   247         -
   248         -    wm transient .downloadprogress .
   249         -
   250         -    label .downloadprogress.label -image $icon  -anchor w -bg gray95 -highlightthickness 0
   251         -
   252         -    pack .downloadprogress.label -side left -fill both -expand yes
   253         -
   254         -
   255         -    ttk::frame .downloadprogress.frame -padding 5
   256         -    pack .downloadprogress.frame -side right -fill both -expand yes
   257         -
   258         -    ttk::label .downloadprogress.frame.l -textvariable softwareupdate::status -width 40 -text ""
   259         -    pack .downloadprogress.frame.l -side top -fill both -expand yes
   260         -
   261         -    ttk::progressbar .downloadprogress.frame.bar -mode indeterminate -orient horizontal  -maximum 100
   262         -    pack .downloadprogress.frame.bar -side top -fill both -expand yes
   263         -
   264         -    .downloadprogress.frame.bar start
   265         -    update
   266         -
   267         -    ttk::button .downloadprogress.frame.b -text "Cancel" -command {destroy .updateprogress}
   268         -    pack .downloadprogress.frame.b -side right -fill both -expand no
   269         -
   270         -    wm geometry .downloadprogress 400x100
   271         -    wm resizable .downloadprogress 0 0
   272         -    
   273         -}
   274         -
   275         -#download and install the update
   276         -proc installUpdate {} {
   277         -    variable currentinstall
   278         -    variable status
   279         -    variable appname
   280         -    variable tmpdir
   281         -
   282         -    catch {destroy .update}
   283         -
   284         -    softwareupdate::findCurrentInstallation
   285         -
   286         -    softwareupdate::progressDialog
   287         -    set status "Downloading update for $appname"
   288         -    
   289         -    switch [tk windowingsystem] {
   290         -
   291         -	"aqua" {
   292         -	    http::geturl https://www.codebykevin.com/updates/[list $appname].dmg -channel [open $tmpdir/[list $appname].dmg w] 
   293         -	    update
   294         -	    after 1000
   295         -	    cd $tmpdir
   296         -	    set status "Attaching [list $appname].dmg"
   297         -	    update
   298         -	    exec hdiutil attach [list $appname].dmg
          175  +    #"busy" dialog
          176  +    proc checkingForUpdates {} {
          177  +
          178  +	variable appname
          179  +	variable icon
          180  +
          181  +	catch {destroy .updateprogress}
          182  +
          183  +	toplevel .updateprogress 
          184  +	wm title .updateprogress "Updating $appname"
          185  +
          186  +	wm withdraw .updateprogress
          187  +	update idletasks
          188  +
          189  +	ttk::frame .updateprogress.f -padding 5
          190  +	pack .updateprogress.f -fill both -expand yes
          191  +
          192  +	label .updateprogress.f.l -bg gray95 -image $icon -bd 0 -relief flat -highlightthickness 0 -width [image width $icon] -height [image height $icon]
          193  +	pack .updateprogress.f.l -side left -fill both -expand yes
          194  +
          195  +	frame .updateprogress.f.r -bg gray95 -bd 0 -highlightcolor gray95
          196  +	pack .updateprogress.f.r -side right -fill both -expand yes
          197  +	
          198  +	
          199  +	ttk::label .updateprogress.f.r.t -text "Checking for updates..." -padding 5
          200  +	pack .updateprogress.f.r.t -side top -fill both -expand yes
          201  +
          202  +	ttk::frame .updateprogress.f.r.f -padding 5
          203  +	pack .updateprogress.f.r.f -side top -fill both -expand yes
          204  +	
          205  +	ttk::progressbar .updateprogress.f.r.f.progress -mode indeterminate -orient horizontal
          206  +	pack .updateprogress.f.r.f.progress -fill both -expand yes -side top
          207  +
          208  +	.updateprogress.f.r.f.progress start
          209  +
          210  +	ttk::button .updateprogress.f.r.f.b -text "Cancel" -command {destroy .updateprogress}
          211  +
          212  +	pack .updateprogress.f.r.f.b -side bottom -fill both -expand no
          213  +
          214  +	wm geometry .updateprogress 400x100
          215  +	wm resizable .updateprogress 0 0
          216  +
          217  +	wm deiconify .updateprogress
          218  +	raise .updateprogress
          219  +
          220  +	wm transient .updateprogress .
          221  +
          222  +    }
          223  +
          224  +    #dialog if current version is installed
          225  +    proc upToDate {} {
          226  +	variable appname
          227  +	variable currentversion
          228  +
          229  +	catch {destroy .updateprogress}
          230  +
          231  +	tk_messageBox  -icon info -title "Up to Date" -message "You're up to date!" -detail "$appname $currentversion is the currently the newest version available."
          232  +
          233  +    }
          234  +
          235  +    #show progress of installation
          236  +    proc progressDialog {} {
          237  +
          238  +	variable appname
          239  +	variable status
          240  +	variable icon
          241  +
          242  +	catch {destroy .downloadprogress}
          243  +
          244  +	toplevel .downloadprogress
          245  +	wm title .downloadprogress "Updating $appname"
          246  +
          247  +	wm transient .downloadprogress .
          248  +
          249  +	label .downloadprogress.label -image $icon  -anchor w -bg gray95 -highlightthickness 0
          250  +
          251  +	pack .downloadprogress.label -side left -fill both -expand yes
          252  +
          253  +
          254  +	ttk::frame .downloadprogress.frame -padding 5
          255  +	pack .downloadprogress.frame -side right -fill both -expand yes
          256  +
          257  +	ttk::label .downloadprogress.frame.l -textvariable softwareupdate::status -width 40 -text ""
          258  +	pack .downloadprogress.frame.l -side top -fill both -expand yes
          259  +
          260  +	ttk::progressbar .downloadprogress.frame.bar -mode indeterminate -orient horizontal  -maximum 100
          261  +	pack .downloadprogress.frame.bar -side top -fill both -expand yes
          262  +
          263  +	.downloadprogress.frame.bar start
          264  +	update
          265  +
          266  +	ttk::button .downloadprogress.frame.b -text "Cancel" -command {destroy .updateprogress}
          267  +	pack .downloadprogress.frame.b -side right -fill both -expand no
          268  +
          269  +	wm geometry .downloadprogress 400x100
          270  +	wm resizable .downloadprogress 0 0
          271  +	
          272  +    }
          273  +
          274  +    #download and install the update
          275  +    proc installUpdate {} {
          276  +	variable currentinstall
          277  +	variable status
          278  +	variable appname
          279  +	variable tmpdir
          280  +
          281  +	catch {destroy .update}
          282  +
          283  +	softwareupdate::findCurrentInstallation
          284  +
          285  +	softwareupdate::progressDialog
          286  +	set status "Downloading update for $appname"
          287  +	
          288  +	switch [tk windowingsystem] {
          289  +
          290  +	    "aqua" {
          291  +		http::geturl https://www.codebykevin.com/updates/[list $appname].dmg -channel [open $tmpdir/[list $appname].dmg w] 
          292  +		update
          293  +		after 1000
          294  +		cd $tmpdir
          295  +		set status "Attaching [list $appname].dmg"
          296  +		update
          297  +		exec hdiutil attach [list $appname].dmg
          298  +	    }
          299  +	    
          300  +	    "win32" {
          301  +		
          302  +		http::geturl https://www.codebykevin.com/updates/[list $appname]_Setup.exe -channel [open $tmpdir/[list $appname]_Setup.exe w]
          303  +
          304  +	    }
          305  +	    
          306  +	    "x11" {
          307  +		tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
          308  +		return
          309  +	    }
   299    310   	}
   300    311   	
   301         -	"win32" {
   302         -	    
   303         -	    http::geturl https://www.codebykevin.com/updates/[list $appname]_Setup.exe -channel [open $tmpdir/[list $appname]_Setup.exe w]
   304         -
   305         -	}
   306    312   	
   307         -	"x11" {
   308         -	    tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
   309         -	    return
   310         -	}
          313  +	set status "Ready to install"
          314  +	.downloadprogress.frame.bar configure -mode determinate
          315  +	.downloadprogress.frame.bar configure -value 100
          316  +	.downloadprogress.frame.bar stop
          317  +	destroy .downloadprogress.frame.b 
          318  +	pack [ttk::button .downloadprogress.frame.b -text "Install and Relaunch" -command softwareupdate::launchUpdate] -side right -fill both -expand no
          319  +	return
   311    320       }
   312         -    
   313         -    
   314         -    set status "Ready to install"
   315         -    .downloadprogress.frame.bar configure -mode determinate
   316         -    .downloadprogress.frame.bar configure -value 100
   317         -    .downloadprogress.frame.bar stop
   318         -    destroy .downloadprogress.frame.b 
   319         -    pack [ttk::button .downloadprogress.frame.b -text "Install and Relaunch" -command softwareupdate::launchUpdate] -side right -fill both -expand no
   320         -    return
   321         -}
   322    321   
   323    322   
   324         -#launch the update
   325         -proc launchUpdate {}  {
          323  +    #launch the update
          324  +    proc launchUpdate {}  {
   326    325   
   327         -    variable currentinstall
   328         -    variable appname
   329         -    variable tmpdir
   330         -    
   331         -    switch [tk windowingsystem] {
          326  +	variable currentinstall
          327  +	variable appname
          328  +	variable tmpdir
          329  +	
          330  +	switch [tk windowingsystem] {
   332    331   
   333         -	"aqua" {
          332  +	    "aqua" {
   334    333   
   335    334   		file rename -force $currentinstall [file join /Users [exec whoami] .Trash [file tail $currentinstall]]
   336    335   
   337    336   		file copy -force /Volumes/[list $appname]/[list $appname].app $currentinstall
   338    337   
   339    338   		exec $currentinstall/Contents/MacOS/$appname &
   340    339   
   341    340   		exec hdiutil detach /Volumes/[list $appname]
   342    341   
   343    342   		exit
   344    343   	    }
   345         -	
   346         -	"win32" {
          344  +	    
          345  +	    "win32" {
          346  +		
          347  +		eval exec [auto_execok start] $tmpdir/[list $appname]_Setup.exe &
          348  +		exit
          349  +	    }
   347    350   	    
   348         -	    eval exec [auto_execok start] $tmpdir/[list $appname]_Setup.exe &
   349         -	    exit
   350         -	}
   351         -	
   352         -	"x11" {
   353         -	    tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
   354         -	    return
          351  +	    "x11" {
          352  +		tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
          353  +		return
          354  +	    }
   355    355   	}
   356         -    }
          356  +
          357  +	catch {destroy .downloadprogress}
   357    358   
   358         -    catch {destroy .downloadprogress}
          359  +	
   359    360   
   360         -    
   361         -
   362         -}
          361  +    }
   363    362   
   364    363   
   365    364   
   366    365   
   367         -namespace export *
          366  +    namespace export *
   368    367   
   369    368   }