Skip to content

Commit

Permalink
wingup 4.1 release
Browse files Browse the repository at this point in the history
Add option -pVALUE for custom parameter. The VALUE can be retieved from
"param" via GET method on the server side.
  • Loading branch information
donho committed Sep 19, 2016
1 parent 6ab334d commit a6c5a66
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/ConfigFiles/getDownLoadUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
$lastestVersionStr = "1.2.3"; // X.Y.Z
$DLURL = "http://download.my-software.com/my-software/1.2.3/mySoftware.1.2.3.Installer.exe";
$curentVersion = $_GET["version"];
$param = $_GET["param"]; // optional

if ($curentVersion >= $lastestVersion)
{
Expand Down
9 changes: 8 additions & 1 deletion src/ConfigFiles/gup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@
<GUPInput>
<!-- optional.
It's the current version of your program. WinGup will add "?version=versionNumber" at the end of InfoUrl.
This parameter will be ignored if you pass directly your version number to WinGup via command line.
This parameter will be ignored if you pass directly your version number to WinGup via command line "-v".
-->
<Version>4.6</Version>

<!-- optional.
It could be whatever you want.
If this node is present and the VALUE is not empty, WinGup will add "&param=VALUE" at the end of version param.
This parameter will be ignored if you pass directly your param VALUE to WinGup via command line "-p".
-->
<Param>x64</Param>

<!-- Mandatory.
This is the url (your web application, both http and https are supported) from where your WinGup gets the update information.
Expand Down
7 changes: 6 additions & 1 deletion src/change.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
GUP v4.1 new feature:

1. Add option -pVALUE for custom parameter. The VALUE can be retieved from "param" via GET method on the server side.


GUP v4 new feature:

1. 64 bits build.
1. 64-bit build.
4 changes: 2 additions & 2 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#ifndef RESOURCE_H
#define RESOURCE_H

#define VERSION_VALUE "4.0\0"
#define VERSION_DIGITALVALUE 4, 0, 0, 0
#define VERSION_VALUE "4.1\0"
#define VERSION_DIGITALVALUE 4, 1, 0, 0

#define IDD_PROGRESS_DLG 1001
#define IDD_PROXY_DLG 1002
Expand Down
26 changes: 23 additions & 3 deletions src/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static string winGupUserAgent = "WinGup/";
static string dlFileName = "";

const char FLAG_OPTIONS[] = "-options";
const char FLAG_VERSION[] = "-v";
//const char FLAG_VERSION[] = "-v";
const char FLAG_VERBOSE[] = "-verbose";
const char FLAG_HELP[] = "--help";

Expand All @@ -55,14 +55,17 @@ const char MSGID_HELP[] = "Usage :\r\
\r\
gup --help\r\
gup -options\r\
gup [-verbose] [-vVERSION_VALUE]\r\
gup [-verbose] [-vVERSION_VALUE] [-pCUSTOM_PARAM]\r\
\r\
--help : Show this help message (and quit program).\r\
-options : Show the proxy configuration dialog (and quit program).\r\
-v : Launch GUP with VERSION_VALUE.\r\
VERSION_VALUE is the current version number of program to update.\r\
If you pass the version number as the argument,\r\
then the version set in the gup.xml will be overrided.\r\
-p : Launch GUP with CUSTOM_PARAM.\r\
CUSTOM_PARAM will pass to destination by using GET method\r\
with argument name \"param\"\r\
-verbose : Show error/warning message if any.";

std::string thirdDoUpdateDlgButtonLabel;
Expand Down Expand Up @@ -359,13 +362,15 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int)
bool isVerbose = false;
bool isHelp = false;
string version = "";
string customParam = "";

if (lpszCmdLine && lpszCmdLine[0])
{
launchSettingsDlg = isInList(FLAG_OPTIONS, lpszCmdLine);
isVerbose = isInList(FLAG_VERBOSE, lpszCmdLine);
isHelp = isInList(FLAG_HELP, lpszCmdLine);
version = getParamVal('v', lpszCmdLine);
customParam = getParamVal('p', lpszCmdLine);
}

if (isHelp)
Expand Down Expand Up @@ -420,12 +425,27 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int)
if (curl)
{
std::string urlComplete = gupParams.getInfoLocation() + "?version=";
if (version != "")
if (!version.empty())
urlComplete += version;
else
urlComplete += gupParams.getCurrentVersion();

if (!customParam.empty())
{
string customParamPost = "&param=";
customParamPost += customParam;
urlComplete += customParamPost;
}
else if (!gupParams.getParam().empty())
{
string customParamPost = "&param=";
customParamPost += gupParams.getParam();
urlComplete += customParamPost;
}

curl_easy_setopt(curl, CURLOPT_URL, urlComplete.c_str());


curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, TRUE);

curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, getUpdateInfo);
Expand Down
17 changes: 15 additions & 2 deletions src/xmlTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

using namespace std;

GupParameters::GupParameters(const char * xmlFileName) : _currentVersion(""), _className2Close(""), _messageBoxTitle(""),\
_3rdButton_wm_cmd(0), _3rdButton_wParam(0), _3rdButton_lParam(0), _isSilentMode(true)
GupParameters::GupParameters(const char * xmlFileName)
{
_xmlDoc.LoadFile(xmlFileName);

Expand All @@ -43,6 +42,20 @@ GupParameters::GupParameters(const char * xmlFileName) : _currentVersion(""), _c
}
}
}

TiXmlNode *paramNode = root->FirstChildElement("Param");
if (paramNode)
{
TiXmlNode *n = paramNode->FirstChild();
if (n)
{
const char *val = n->Value();
if (val)
{
_param = val;
}
}
}

TiXmlNode *infoURLNode = root->FirstChildElement("InfoUrl");
if (!infoURLNode)
Expand Down
8 changes: 5 additions & 3 deletions src/xmlTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class GupParameters : public XMLTool {
GupParameters(const char * xmlFileName);

const std::string & getCurrentVersion() const { return _currentVersion;};
const std::string & getParam() const { return _param; };
const std::string & getInfoLocation() const {return _infoUrl;};
const std::string & getClassName() const {return _className2Close;};
const std::string & getMessageBoxTitle() const {return _messageBoxTitle;};
Expand All @@ -53,14 +54,15 @@ class GupParameters : public XMLTool {

private:
std::string _currentVersion;
std::string _param;
std::string _infoUrl;
std::string _className2Close;
std::string _messageBoxTitle;
std::string _softwareName;
bool _isMessageBoxModal = false;
int _3rdButton_wm_cmd;
int _3rdButton_wParam;
int _3rdButton_lParam;
int _3rdButton_wm_cmd = 0;
int _3rdButton_wParam = 0;
int _3rdButton_lParam = 0;
std::string _3rdButton_label;
bool _isSilentMode = true;
};
Expand Down

0 comments on commit a6c5a66

Please sign in to comment.