2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004 Kimmo Pekkola
|
|
|
|
|
|
|
|
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; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
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
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-02-10 18:37:48 +00:00
|
|
|
*/
|
|
|
|
|
2009-10-07 16:45:14 +00:00
|
|
|
#include "StdAfx.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
#include "Litestep.h"
|
|
|
|
#include "Rainmeter.h"
|
2011-02-07 08:02:12 +00:00
|
|
|
#include "../Version.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-06-21 16:00:19 +00:00
|
|
|
extern CRainmeter* Rainmeter;
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
void CheckVersion(void* dummy)
|
|
|
|
{
|
2012-04-05 10:27:34 +00:00
|
|
|
HINTERNET hRootHandle = InternetOpen(
|
|
|
|
L"Rainmeter",
|
|
|
|
INTERNET_OPEN_TYPE_PRECONFIG,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0);
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
if (hRootHandle == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-05 10:27:34 +00:00
|
|
|
HINTERNET hUrlDump = InternetOpenUrl(hRootHandle, L"http://rainmeter.github.com/rainmeter/release", NULL, NULL, INTERNET_FLAG_RESYNCHRONIZE, 0);
|
2009-02-10 18:37:48 +00:00
|
|
|
if (hUrlDump)
|
|
|
|
{
|
|
|
|
DWORD dwSize;
|
2009-07-27 20:32:33 +00:00
|
|
|
char buffer[16] = {0}; // 16 should be enough for the version number
|
|
|
|
if (InternetReadFile(hUrlDump, (LPVOID)buffer, 15, &dwSize))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-04-06 17:54:45 +00:00
|
|
|
int version = atoi(buffer) * 1000000;
|
|
|
|
char* pos = strchr(buffer, '.');
|
|
|
|
if (pos)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-04-06 17:54:45 +00:00
|
|
|
++pos; // Skip .
|
|
|
|
version += atoi(pos) * 1000;
|
2009-08-02 11:32:12 +00:00
|
|
|
|
2012-04-06 17:54:45 +00:00
|
|
|
pos = strchr(pos, '.');
|
|
|
|
if (pos)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-04-06 17:54:45 +00:00
|
|
|
++pos; // Skip .
|
|
|
|
version += atoi(pos);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
if (version > RAINMETER_VERSION)
|
|
|
|
{
|
2012-04-06 17:54:45 +00:00
|
|
|
Rainmeter->SetNewVersion();
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
InternetCloseHandle(hUrlDump);
|
|
|
|
}
|
|
|
|
|
|
|
|
InternetCloseHandle(hRootHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CheckUpdate()
|
|
|
|
{
|
2012-04-06 17:54:45 +00:00
|
|
|
_beginthread(CheckVersion, 0, NULL);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|