Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Aug 18, 2017 9:39 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 34 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Update checker
PostPosted: Sun Feb 05, 2012 5:46 pm 
Offline

Joined: Fri Nov 25, 2011 3:14 am
Posts: 27
Location: Serbia
Very usefull, thanks :-)

_________________
Dr Boris Tadić
Medical Software Development
www.digitsoft.rs


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Thu Mar 01, 2012 5:33 pm 
Offline

Joined: Wed Mar 10, 2010 4:46 am
Posts: 27
I have taken serd83's solution and created a simple ons-step window that incorporates all of the coding he has made. It can be downloaded from here:

http://dl.dropbox.com/u/10747116/RealSt ... Window.rbw

Just drop this window onto your project tab. Double click it to open it in the editor and change the CheckForUpdate method with your reference pointers. This is shown in the code snippet below:

#if TargetMacOS then
DownloadPath = "YourDMG.dmg"
DownloadURL = "http://www.domain.com/YourDMG.dmg"
#else
DownloadPath = "YourDMG.zip"
DownloadURL = "http://www.domain.com/YourDMG.zip"
#endif

SoftwareName = "Your Cool Program Name"
VersionURL = "http://www.domain.com/YourDMG/version.txt"


As I have MacOS and Windows requirements I made the window generic for either.

Now, just add the following code in your App.Open event:

wUpdateWindow.CheckForUpdate


That's it. It works like a dream.

Thank you, serd83, for the start.

Simon.

_________________
Simon
RealStudio Professional 2011 R4.3
Mac Mountain Lion 10.8


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Thu Mar 01, 2012 9:19 pm 
Offline

Joined: Wed Jul 09, 2008 10:46 pm
Posts: 193
Location: Minneapolis
simberr wrote:
I have taken serd83's solution and created a simple ons-step window that incorporates all of the coding he has made. It can be downloaded from here:
Thanks to both of you.

I found one issue - the following line in the UpdateAvailable method,
LatestVersion = arr(UBound(arr))
fails if your text editor, like mine, puts a LF/CR at the end of the line. The array is created by splitting on end of lines - the extra end of line creates an extra, empty row in the array.

One fix is to use the existing information to construct the LatestVersion:
LatestVersion = s     //arr(MajorRelease)

_________________
http://www.miscjunk.org


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Thu Mar 01, 2012 9:48 pm 
Offline

Joined: Wed Jul 09, 2008 10:46 pm
Posts: 193
Location: Minneapolis
I also changed the following line in the UpdateAvailable method from
if ubound(arr) < 0 then return false
to
if ubound(arr) < MajorRelease then return false
Otherwise a newer version of the program would crash on an older (not updated) version.txt file.

_________________
http://www.miscjunk.org


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Thu Mar 01, 2012 10:00 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Indy wrote:
I found one issue - the following line in the UpdateAvailable method,
LatestVersion = arr(UBound(arr))
fails if your text editor, like mine, puts a LF/CR at the end of the line. The array is created by splitting on end of lines - the extra end of line creates an extra, empty row in the array.

Use Trim() before you Split(). It will remove the extra EOL.
updateversion = h.get(VersionURL, 5) // get the lines
arr = Trim(ReplaceLineEndings(updateversion, endofline)).split(endofline) // add each line to the array arr()


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Fri Mar 02, 2012 12:16 am 
Offline

Joined: Wed Jul 09, 2008 10:46 pm
Posts: 193
Location: Minneapolis
This was brought up earlier in the thread, if my version.txt file is as follows:

1.0.5
2.1.3
3.0.0

and my apps major/minor/bug versions are set to 2.1.3 the functions will indicate that no update is available.

It seems to only check for updates within the same major release number. (For my purposes I will have it check for any major or minor updates.)

_________________
http://www.miscjunk.org


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Sat Mar 03, 2012 9:27 am 
Offline

Joined: Wed Mar 10, 2010 4:46 am
Posts: 27
The window now handles major updates. It now incorporates a major change method that will allow you to send the user elsewhere or make further decisions.

The new method is: MajorChangeUpgrade

The code has now been changed in UpdateAvailable to:

if major > app.majorversion or minor > app.minorversion or bug > app.bugversion then // check if any value is greater
LatestVersion = arr(UBound(arr))
Return True
elseif UBound(arr) > MajorRelease Then
' The Major Release has changed.
LatestVersion = arr(UBound(arr))
Return MajorChangeUpgrade
else
LatestVersion = CurrentVersion
Return False
end if

In addition, I have changed the loading routine to allow for CRLF etc.
updateversion = h.get(VersionURL, 5) // get the lines
updateversion = Trim(updateversion)
updateversion = ReplaceAll(updateversion, Chr(10), "|")
updateversion = ReplaceAll(updateversion, Chr(13), "|")
updateversion = ReplaceAll(updateversion, "||", "|")

arr = Split(updateversion, "|")


The download URL is as follows:
http://dl.dropbox.com/u/10747116/RealSt ... Window.rbw

Thank you for the feedback.

_________________
Simon
RealStudio Professional 2011 R4.3
Mac Mountain Lion 10.8


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Mon Mar 05, 2012 9:03 am 
Offline

Joined: Tue Dec 27, 2011 8:54 am
Posts: 139
Location: India
Hi All,

Thanks for your time.

I have one doubt about the "Launch the new version" .

I run/lunch my old desktop application after that i clicked a button for check the new version of that software is exists or not. If i am getting any new version then i want to replace the old one with new one and invoke the latest exe for open the App.

So how could i run the newer version and delete/replace the old one ?
Note : Old exe is running.

Thanks,
Prakash

_________________
PK Pothal
Software Developer in REAL STUDIO 2011r4.3, ASP.NET, VB.NET, C# AND SQL SERVER 2005/08
OS:WINDOWS N MAC


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Wed Mar 07, 2012 12:45 pm 
Offline

Joined: Wed Mar 10, 2010 4:46 am
Posts: 27
In the implementation that I have posted here following the download the current running program quits and the downloaded file is launched.

On the Mac there are two types of downloadable files, the DMG and a PKG. A DMG will open and allow the user to drag and drop the latest version where he wants and the PKG will run an installer similar in use to the Windows installer.

On the Windows platform there are ZIP and EXE files. Typically an EXE file is an installer that will run and install the program over the last version.

I assume your question is coming from the Windows area. If you are deploying an app on that platform you should be using either an executable zip file that will place the files in the right places automatically or an installer. I assume that you don't want your users to manually install the application. This means that you should invest some time (and maybe some money) in a good installer. The best free installer that I used to use when I worked on the Windows platform was Inno Setup. Do a web search for this.

Hope this helps.

Simon.

_________________
Simon
RealStudio Professional 2011 R4.3
Mac Mountain Lion 10.8


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Thu Mar 08, 2012 12:46 am 
Offline

Joined: Tue Dec 27, 2011 8:54 am
Posts: 139
Location: India
Hi Simon,

Thank you for responding my issue.

Quote:
In the implementation that I have posted here following the download the current running program quits and the downloaded file is launched.


I used the above or same logic for software updation. I used the monkeyrealsoftware for download the zip file from the ftp server and Unzip that file and quit the old exe and launch the new one. But My problem is while i Unzipping the file using the monkeyrealsoftware component, it's unzip the file after that the below line of code is not executed.

Could you please tell me what is the problems behind this.

Note : In Run time its working fine but when create a exe then run that app its not working :(


Thanks,
Prakash

_________________
PK Pothal
Software Developer in REAL STUDIO 2011r4.3, ASP.NET, VB.NET, C# AND SQL SERVER 2005/08
OS:WINDOWS N MAC


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Tue Mar 13, 2012 2:22 pm 
Offline

Joined: Wed Mar 10, 2010 4:46 am
Posts: 27
Quote:
I used the above or same logic for software updation. I used the monkeyrealsoftware for download the zip file from the ftp server and Unzip that file and quit the old exe and launch the new one. But My problem is while i Unzipping the file using the monkeyrealsoftware component, it's unzip the file after that the below line of code is not executed.


I do not use the monkeybread components so I would suggest that you contact them.

Simon.

_________________
Simon
RealStudio Professional 2011 R4.3
Mac Mountain Lion 10.8


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Thu Mar 15, 2012 1:54 am 
Offline

Joined: Tue Dec 27, 2011 8:54 am
Posts: 139
Location: India
Hi Simon,

Thanks for your time.

Is there any other component present for communicate with Ftp server. If YES please send me some link.


Thanks,
Prakash

_________________
PK Pothal
Software Developer in REAL STUDIO 2011r4.3, ASP.NET, VB.NET, C# AND SQL SERVER 2005/08
OS:WINDOWS N MAC


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Thu Mar 15, 2012 8:26 am 
Offline

Joined: Tue Feb 14, 2012 8:11 am
Posts: 12
Just some changes I made..

In the CheckForUpdate Routine:
TargetFile = SpecialFolder.UserHome.Child("Downloads").child(DownloadPath)

if TargetFile.Exists then
TargetFile.Delete
if TargetFile.LastErrorCode <> 0 then
// there is an error

An example is the case that you have downloaded the installer file and it has opened but not yet installed. You then restart the program and restart the download you have a locked existing file which can not be deleted nor overwritten. Without checking for an error, the software will hang unless a cancel download is implemented.

I modified the check for version:
// now check for updates being available:
if major> app.MajorVersion then
// major update available
canupdate = true
else
// no major update, so check that at least major version is the same before checking for minor version
if major > app.majorversion then
// check for minor version is valid
canupdate = true
else
// no minor update, so check that at least minor version is the same before checking for bug fix version
if minor = app.minorversion then
// check for bug fix version is valid
if bug > app.bugversion then
canupdate = true
end if
end if
end if
end if

This is not necessary, but useful if you are developing: for example if your development version is 3.1.0 and the version on the web server is 3.0.6, then the old code would indicate that 3.0.6 is newer than 3.1.0.

I did not disable the Cancel button when a download was started and changed the Action method to the following:
UpdateSocket.Close

Close

This terminates the download and closes the socket first to prevent an exception.

For UpdateSocket.DownloadDone I changed the following:
//dim f as FolderItem = SpecialFolder.UserHome.Child("Downloads").child(DownloadPath)
dim msg as MessageDialog
dim b as MessageDialogButton

if httpStatus = 200 then
// download successful
if file <> nil and file.exists then
file.Launch
Quit
end if
else
msg = New MessageDialog
msg.Icon = msg.GraphicCaution
msg.ActionButton.Caption = mDownloadFailedActionButton
msg.ActionButton.Visible = true
msg.Message = mDownloadFailedActionMessage
msg.Explanation= mDownloadFailedActionExplanation1

b = msg.ShowModal
wUpdateWindow.Close
end

First, I use the "file" folder item as it is safer. Secondly, I check for HttpStatus = 200, which means download successful. A wrong filename for example will complete the download with HTTPStatus = 404 and an empty targetfile.


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Tue Apr 03, 2012 11:59 am 
Offline

Joined: Wed Mar 10, 2010 4:46 am
Posts: 27
Thank you, major help.

I have incorporated these changes.

_________________
Simon
RealStudio Professional 2011 R4.3
Mac Mountain Lion 10.8


Top
 Profile  
Reply with quote  
 Post subject: Re: Update checker
PostPosted: Wed Apr 04, 2012 1:14 am 
Offline

Joined: Thu Dec 01, 2011 2:13 pm
Posts: 288
I have a new update of simberrs one - with more mac compatibility. I will upload it soon.

_________________
Mac OS X 10.3-10.8
Windows 2000 (I know it sucks)
Windows Server 2007

You want a bunch of new classes and web styles? realstudiodevspot.com (search there for Web Styles Plugin)
Folderitem is too hard? File Bin Class
I hate cows.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 34 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group