Ejemplo n.º 1
0
BOOL VersionInRange(LARGE_INTEGER lVersion, LPCTSTR lpszLowerVersion, LPCTSTR lpszUpperVersion )
{
	BOOL bResult = FALSE;
	if( _tcslen(lpszLowerVersion)>0 
		&& !(CompareVersion(lVersion, ParseVersion(lpszLowerVersion), _T(">="), bResult ) && bResult) )
		return FALSE;

	if( _tcslen(lpszUpperVersion)>0 
		&& !(CompareVersion( lVersion, ParseVersion(lpszUpperVersion), _T("<"), bResult ) && bResult) )
		return FALSE;
	return TRUE;
}
Ejemplo n.º 2
0
static void versioncheck_test() {
    utassert(IsValidProgramVersion("1"));
    utassert(IsValidProgramVersion("1.1"));
    utassert(IsValidProgramVersion("1.1.1\r\n"));
    utassert(IsValidProgramVersion("2662"));

    utassert(!IsValidProgramVersion("1.1b"));
    utassert(!IsValidProgramVersion("1..1"));
    utassert(!IsValidProgramVersion("1.1\r\n.1"));

    utassert(CompareVersion(L"0.9.3.900", L"0.9.3") > 0);
    utassert(CompareVersion(L"1.09.300", L"1.09.3") > 0);
    utassert(CompareVersion(L"1.9.1", L"1.09.3") < 0);
    utassert(CompareVersion(L"1.2.0", L"1.2") == 0);
    utassert(CompareVersion(L"1.3.0", L"2662") < 0);
}
Ejemplo n.º 3
0
CookStatus SkModelCooker::Status(int flags) {
	if (CompareVersion(flags) || 
		CompareModifiedTime(flags) || 
		CompareCachedFileTimeKey(flags, "Mesh.Source.File"))
		return CS_NeedRebuild;
	return CS_UpToDate;
}
Ejemplo n.º 4
0
/**
\todo document this function
*/
bool GCF::UpdateInfo::recentThan(const UpdateInfo& other) const
{
    if(d->name == other.d->name)
        return (CompareVersion(d->version, other.d->version) > 0);

    return false;
}
Ejemplo n.º 5
0
bool wxWebUpdateListCtrl::CanBeChecked(int n)
{
    if (m_bLocked) return FALSE;        // discard user interaction in any case.

    // cannot check packages which are already up-to-date...
    wxWebUpdateCheckFlag f = CompareVersion(m_arrRemotePackages[GetPackageIndexForItem(n)]);
    if (f == wxWUCF_UPDATED || f == wxWUCF_FAILED)
        return FALSE;
    return TRUE;
}
Ejemplo n.º 6
0
CookStatus FontCooker::Status(int flags) {

	if (CompareVersion(flags) ||
		CompareModifiedTime(flags) ||
		CompareCachedFileTimeKey(flags, "Source.File"))
	{
		return CS_NeedRebuild;
	}

	return CS_Ignore;
}
Ejemplo n.º 7
0
bool wxWebUpdateListCtrl::IsReadyForInstallation(int n)
{
    wxArrayString str = m_arrRemotePackages[n].GetParsedPrerequisites();
    if (str.GetCount() == 0) return TRUE;

    // are all packages installed & up2date ?
    for (int i=0; i < (int)str.GetCount(); i++)
        if (CompareVersion(str[i]) != wxWUCF_UPDATED)
            return FALSE;

    return TRUE;
}
Ejemplo n.º 8
0
CookStatus MapCooker::Status(int flags) {
	
	if (CompareVersion(flags) ||
		CompareModifiedTime(flags) ||
		CompareCachedFileTimeKey(flags, "Source.File") ||
		CompareCachedFileTime(flags, "Meshes/World/common.3dx", "Meshes/World/common.3dx")) {
		return CS_NeedRebuild;
	}

	// Check 3DX timestamp

	const String *mapPath = asset->entry->KeyValue<String>("Source.File", flags);
	if (!mapPath || mapPath->empty)
		return CS_NeedRebuild;

	String actorPath = file::SetFileExtension(mapPath->c_str, ".actors");
	if (CompareCachedFileTime(flags, "Source.File.Actors", actorPath.c_str, true, true))
		return CS_NeedRebuild;

	file::MMFileInputBuffer::Ref ib = engine->sys->files->OpenInputBuffer(mapPath->c_str, ZTools);
	if (!ib)
		return CS_NeedRebuild;

	m_script.Bind(ib);
	ib.reset();

	int r;
	CookStatus status = CS_UpToDate;
	tools::map_builder::EntSpawn spawn;

	while ((r=MapParser::ParseEntity(m_script, spawn))==SR_Success) {
		const char *sz = spawn.keys.StringForKey("classname");
		if (!sz)
			continue;
		if (!string::cmp(sz, "static_mesh_scene")) {
			sz = spawn.keys.StringForKey("file");
			if (sz) {
				String path(sz);
				path += ".3dx";
				if (CompareCachedFileTime(flags, path.c_str, path.c_str)) {
					status = CS_NeedRebuild;
					break;
				}
			}
		}
	}

	if (r != SR_Success && r != SR_End)
		status = CS_NeedRebuild; // force error

	return status;
}
Ejemplo n.º 9
0
bool wxWebUpdateListCtrl::CanBeUnchecked(int n)
{
    if (m_bLocked)
        return FALSE;       // discard user interaction in any case.

#ifdef __WXDEBUG__
    wxWebUpdateCheckFlag f =
#endif
        CompareVersion(m_arrRemotePackages[GetPackageIndexForItem(n)]);
    wxASSERT_MSG(f != wxWUCF_UPDATED && f != wxWUCF_FAILED,
                wxS("That item should not have been checked !"));
    return TRUE;
}
Ejemplo n.º 10
0
int FontCooker::Compile(int flags) {
	// Make sure these get updated (Status may have not called them all)
	CompareVersion(flags);
	CompareModifiedTime(flags);
	CompareCachedFileTimeKey(flags, "Source.File");

	const String *s = asset->entry->KeyValue<String>("Source.File", flags);
	if (!s || s->empty)
		return SR_MetaError;

	if (!CopyOutputBinFile(s->c_str))
		return SR_IOError;
	return SR_Success;
}
Ejemplo n.º 11
0
void wxWebUpdateListCtrl::UpdatePackagesVersions(wxWebUpdateListCtrlFilter filter)
{
    for (int j=0; j < GetItemCount(); j++) {

        const wxWebUpdatePackage &curr = m_arrRemotePackages[GetPackageIndexForItem(j)];
        SetLocalVersionFor(j, curr);

        wxWebUpdateCheckFlag f = CompareVersion(curr);
        if (IsToDiscard(filter, j, curr, f)) {

            DeleteItem(j);
            j--;
            continue;           // continue with next package
        }
    }
}
Ejemplo n.º 12
0
void VerifyVersionFile ()
{
	CFileBuffer Buffer (VERSION_PATH, true);
	CParser Parser (Buffer.GetBuffer<char> (), PSP_COMMENT_LINE);

	String prefix;
	Parser.ParseToken (PSF_ALLOW_NEWLINES, prefix);

	uint8 minor;
	uint16 major;
	uint32 build;
	Parser.ParseDataType<uint16> (PSF_ALLOW_NEWLINES, &major, 1);
	Parser.ParseDataType<uint8> (PSF_ALLOW_NEWLINES, &minor, 1);
	Parser.ParseDataType<uint32> (PSF_ALLOW_NEWLINES, &build, 1);

	if (CompareVersion (prefix.CString(), major, minor, build))
	{
		ServerPrint ("Version file out of date; updating...\n");
		WriteVersion ();
	}
}
Ejemplo n.º 13
0
BOOL IsVistaOrLater()
{
	return 0 <= CompareVersion(em_OS_MajorVer_Vista, 0);
}
Ejemplo n.º 14
0
void CheckVersionReturnance ()
{
#if defined(WIN32) && !defined(NO_MULTITHREAD_VERSION_CHECK)
	if (VersionCheckReady)
	{
		if (!receiveBuffer.IsNullOrEmpty() && (receiveBuffer[0] != '<'))
		{
			CParser Parser (receiveBuffer.CString(), PSP_COMMENT_LINE);

			String prefix;
			Parser.ParseToken (PSF_ALLOW_NEWLINES, prefix);

			uint8 minor;
			uint16 major;
			uint32 build;
			Parser.ParseDataType<uint16> (PSF_ALLOW_NEWLINES, &major, 1);
			Parser.ParseDataType<uint8> (PSF_ALLOW_NEWLINES, &minor, 1);
			Parser.ParseDataType<uint32> (PSF_ALLOW_NEWLINES, &build, 1);

	#if defined(WIN32) && !defined(NO_MULTITHREAD_VERSION_CHECK)
			VersionReturnance = CompareVersion (prefix.CString(), major, minor, build);
			VersionPrefix = prefix;
			VersionMinor = minor;
			VersionMajor = major;
			VersionBuild = build;
			VersionCheckReady = true;
	#else
			if (CompareVersion (prefix.CString(), minor, major, build) == VERSION_NEWER)
				ServerPrintf (
				"==================================\n"
				"*****************************\n"
				"There is an update available for CleanCode!\n"
				"Please go to http://code.google.com/p/cleancodequake2 and update accordingly.\n"
				"Your version:   "CLEANCODE_VERSION_PRINT"\n"
				"Update version: "CLEANCODE_VERSION_PRINT"\n"
				"*****************************\n"
				"==================================\n",
				CLEANCODE_VERSION_PRINT_ARGS,
				prefix.CString(), major, minor, build);
			else
				ServerPrint ("Your version of CleanCode is up to date.\n");
	#endif
		}

		if (VersionReturnance == VERSION_NEWER)
			ServerPrintf (
			"==================================\n"
			"*****************************\n"
			"There is an update available for CleanCode!\n"
			"Please go to http://code.google.com/p/cleancodequake2 and update accordingly\nor run the auto updater."
			"Your version:   "CLEANCODE_VERSION_PRINT"\n"
			"Update version: "CLEANCODE_VERSION_PRINT"\n"
			"*****************************\n"
			"==================================\n",
			CLEANCODE_VERSION_PRINT_ARGS,
			VersionPrefix.CString(), VersionMajor, VersionMinor, VersionBuild);
		else
			ServerPrint ("Your version of CleanCode is up to date.\n");

		VersionReturnance = VERSION_SAME;
		VersionCheckReady = false;

		CloseHandle (hThread);

		hThread = NULL;
		iID = 0;
	}
#endif
}
Ejemplo n.º 15
0
int SkModelCooker::Compile(int flags) {
	// Make sure these get updated
	CompareVersion(flags);
	CompareModifiedTime(flags);
	CompareCachedFileTimeKey(flags, "Mesh.Source.File");

	const String *s = asset->entry->KeyValue<String>("AnimSet.Source", flags);
	if (!s || s->empty)
		return SR_MetaError;

	// CompileSkmData needs the ska info, so load it.

	Asset::Ref skaRef = engine->sys->packages->Resolve(s->c_str, asset->zone);
	if (!skaRef)
		return SR_FileNotFound;

	int r = skaRef->Process(
		xtime::TimeSlice::Infinite,
		flags|P_Parse|P_TargetDefault
	);

	if (r != SR_Success)
		return r;

	SkAnimSetParser *ska = SkAnimSetParser::Cast(skaRef);
	if (!ska || !ska->valid)
		return SR_ParseError;

	// AnimSet import index
	AddImport(s->c_str);

	s = asset->entry->KeyValue<String>("AnimStates.Source", flags);
	if (!s)
		return SR_MetaError;

	// AnimStates import index
	AddImport(s->c_str);

	// Load 3DX Mesh file
	s = asset->entry->KeyValue<String>("Mesh.Source.File", flags);
	if (!s)
		return SR_MetaError;

	file::MMFileInputBuffer::Ref ib = engine->sys->files->OpenInputBuffer(s->c_str, ZTools);
	if (!ib)
		return SR_FileNotFound;
	
	stream::InputStream is (*ib);

	tools::SceneFile mesh;
	if (!tools::LoadSceneFile(is, mesh, true))
		return SR_ParseError;

	ib.reset();

	if (mesh.worldspawn->models.size() != 1) {
		COut(C_Error) << "ERROR: 3DX file should only contain 1 model, it contains " << mesh.worldspawn->models.size() << ". File: '" << *s << "'" << std::endl;
		return SR_ParseError;
	}

	tools::SkmData::Ref skmd = tools::CompileSkmData(
		asset->name,
		mesh,
		0,
		ska::kSkinType_CPU,
		*ska->dska.get()
	);

	if (!skmd) {
		COut(C_Error) << "ERROR: " << asset->name.get() << " does not contain a skeletal animated mesh." << std::endl;
		return SR_CompilerError;
	}

	String path(CStr(asset->path));
	String path2(path);
	path2 += ".0.bin";

	// File 0 (discardable after load)
	{
		BinFile::Ref skmFile = OpenWrite(path2.c_str);
		if (!skmFile)
			return SR_IOError;

		stream::OutputStream skmOut(skmFile->ob);
		if (skmOut.Write(skmd->skmData[0], (stream::SPos)skmd->skmSize[0], 0) != (stream::SPos)skmd->skmSize[0])
			return SR_IOError;
	}

	path2 = path;
	path2 += ".1.bin";

	// File 1 (persisted)
	{
		BinFile::Ref skmFile = OpenWrite(path2.c_str);
		if (!skmFile)
			return SR_IOError;

		stream::OutputStream skmOut(skmFile->ob);
		if (skmOut.Write(skmd->skmData[1], (stream::SPos)skmd->skmSize[1], 0) != (stream::SPos)skmd->skmSize[1])
			return SR_IOError;
	}

	// add material imports

	for (ska::DSkMesh::Vec::const_iterator it = skmd->dskm.meshes.begin(); it != skmd->dskm.meshes.end(); ++it) {
		AddImport((*it).material);
	}

	return SR_Success;
}
Ejemplo n.º 16
0
void CheckNewVersion ()
#endif
{
	CURL *curl_handle;

	struct MemoryStruct chunk;

	chunk.memory=NULL; /* we expect realloc(NULL, size) to work */
	chunk.size = 0;    /* no data at this point */

	curl_global_init(CURL_GLOBAL_ALL);

	/* init the curl session */
	curl_handle = curl_easy_init();

	/* specify URL to get */
	curl_easy_setopt(curl_handle, CURLOPT_URL, "http://cleancodequake2.googlecode.com/svn/trunk/version.ver");

	/* send all data to this function  */
	curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);

	/* we pass our 'chunk' struct to the callback function */
	curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);

	/* some servers don't like requests that are made without a user-agent
	field, so we provide one */
	curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");

	/* get it! */
	curl_easy_perform(curl_handle);

	/* cleanup curl stuff */
	curl_easy_cleanup(curl_handle);

	/*
	* Now, our chunk.memory points to a memory block that is chunk.size
	* bytes big and contains the remote file.
	*
	* Do something nice with it!
	*
	* You should be aware of the fact that at this point we might have an
	* allocated data block, and nothing has yet deallocated that data. So when
	* you're done with it, you should free() it as a nice application.
	*/

	if(chunk.memory)
	{
		CParser Parser (chunk.memory, PSP_COMMENT_LINE);

		const char *token;

		String prefix;
		Parser.ParseToken (PSF_ALLOW_NEWLINES, &token);
		prefix = token;

		uint8 minor;
		uint16 major;
		uint32 build;
		Parser.ParseDataType<uint16> (PSF_ALLOW_NEWLINES, &major, 1);
		Parser.ParseDataType<uint8> (PSF_ALLOW_NEWLINES, &minor, 1);
		Parser.ParseDataType<uint32> (PSF_ALLOW_NEWLINES, &build, 1);

#if defined(WIN32) && !defined(NO_MULTITHREAD_VERSION_CHECK)
		VersionReturnance = CompareVersion (prefix.CString(), major, minor, build);
		VersionPrefix = prefix;
		VersionMinor = minor;
		VersionMajor = major;
		VersionBuild = build;
		VersionCheckReady = true;
#else
		if (CompareVersion (prefix.CString(), minor, major, build) == VERSION_NEWER)
			ServerPrintf (
			"==================================\n"
			"*****************************\n"
			"There is an update available for CleanCode!\n"
			"Please go to http://code.google.com/p/cleancodequake2 and update accordingly.\n"
			"Your version:   "CLEANCODE_VERSION_PRINT"\n"
			"Update version: "CLEANCODE_VERSION_PRINT"\n"
			"*****************************\n"
			"==================================\n",
			CLEANCODE_VERSION_PRINT_ARGS,
			prefix.CString(), major, minor, build);
		else
			ServerPrint ("Your version of CleanCode is up to date.\n");
#endif

		Mem_Free (chunk.memory);
	}

	/* we're done with libcurl, so clean it up */
	curl_global_cleanup();

	return 0;
}
NS_IMETHODIMP
nsPluginDirServiceProvider::GetFile(const char *charProp, PRBool *persistant,
                                    nsIFile **_retval)
{
  nsCOMPtr<nsILocalFile>  localFile;
  nsresult rv = NS_ERROR_FAILURE;

  NS_ENSURE_ARG(charProp);

  *_retval = nsnull;
  *persistant = PR_FALSE;

  nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
  if (!prefs)
    return NS_ERROR_FAILURE;

  if (nsCRT::strcmp(charProp, NS_WIN_4DOTX_SCAN_KEY) == 0) {
    // Check our prefs to see if scanning the 4.x folder has been
    // explictly overriden failure to get the pref is okay, we'll do
    // what we've been doing -- a filtered scan
    PRBool bScan4x;
    if (NS_SUCCEEDED(prefs->GetBoolPref(NS_WIN_4DOTX_SCAN_KEY, &bScan4x)) &&
        !bScan4x) {
      return NS_ERROR_FAILURE;
    }

    // Look for the plugin folder that the user has in their
    // Communicator 4x install
    HKEY keyloc;
    long result;
    DWORD type;
    WCHAR szKey[_MAX_PATH] = L"Software\\Netscape\\Netscape Navigator";
    WCHAR path[_MAX_PATH];

    result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc);

    if (result == ERROR_SUCCESS) {
      WCHAR current_version[80];
      DWORD length = NS_ARRAY_LENGTH(current_version);

      result = ::RegQueryValueExW(keyloc, L"CurrentVersion", NULL, &type,
                                  (LPBYTE)&current_version, &length);

      ::RegCloseKey(keyloc);
      wcscat(szKey, L"\\");
      wcscat(szKey, current_version);
      wcscat(szKey, L"\\Main");
      result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc);

      if (result == ERROR_SUCCESS) {
        DWORD pathlen = NS_ARRAY_LENGTH(path);

        result = ::RegQueryValueExW(keyloc, L"Plugins Directory", NULL, &type,
                                   (LPBYTE)&path, &pathlen);
        if (result == ERROR_SUCCESS) {
          rv = NS_NewLocalFile(nsDependentString(path),
                               PR_TRUE, getter_AddRefs(localFile));
        }

        ::RegCloseKey(keyloc);
      }
    }
  } else if (nsCRT::strcmp(charProp, NS_WIN_JRE_SCAN_KEY) == 0) {
    nsXPIDLCString strVer;
    if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer))))
      return NS_ERROR_FAILURE;
    verBlock minVer;
    TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);

    // Look for the Java OJI plugin via the JRE install path
    HKEY baseloc;
    HKEY keyloc;
    HKEY entryloc;
    FILETIME modTime;
    DWORD type;
    DWORD index = 0;
    DWORD numChars = _MAX_PATH;
    DWORD pathlen;
    verBlock maxVer;
    ClearVersion(&maxVer);
    WCHAR curKey[_MAX_PATH] = L"Software\\JavaSoft\\Java Runtime Environment";
    WCHAR path[_MAX_PATH];
    // Add + 15 to prevent buffer overrun when adding \bin (+ optionally
    // \new_plugin)
#define JAVA_PATH_SIZE _MAX_PATH + 15
    WCHAR newestPath[JAVA_PATH_SIZE];
    const WCHAR mozPath[_MAX_PATH] = L"Software\\mozilla.org\\Mozilla";
    WCHAR browserJavaVersion[_MAX_PATH];

    newestPath[0] = 0;
    LONG result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ,
                                  &baseloc);
    if (ERROR_SUCCESS != result)
      return NS_ERROR_FAILURE;

    // Look for "BrowserJavaVersion"
    if (ERROR_SUCCESS != ::RegQueryValueExW(baseloc, L"BrowserJavaVersion", NULL,
                                            NULL, (LPBYTE)&browserJavaVersion,
                                            &numChars))
      browserJavaVersion[0] = 0;

    // We must enumerate through the keys because what if there is
    // more than one version?
    do {
      path[0] = 0;
      numChars = _MAX_PATH;
      pathlen = NS_ARRAY_LENGTH(path);
      result = ::RegEnumKeyExW(baseloc, index, curKey, &numChars, NULL, NULL,
                               NULL, &modTime);
      index++;

      // Skip major.minor as it always points to latest in its family
      numChars = 0;
      for (WCHAR *p = curKey; *p; p++) {
        if (*p == '.') {
          numChars++;
        }
      }
      if (numChars < 2)
        continue;

      if (ERROR_SUCCESS == result) {
        if (ERROR_SUCCESS == ::RegOpenKeyExW(baseloc, curKey, 0,
                                             KEY_QUERY_VALUE, &keyloc)) {
          // We have a sub key
          if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, L"JavaHome", NULL,
                                                  &type, (LPBYTE)&path,
                                                  &pathlen)) {
            verBlock curVer;
            TranslateVersionStr(curKey, &curVer);
            if (CompareVersion(curVer, minVer) >= 0) {
              if (!wcsncmp(browserJavaVersion, curKey, _MAX_PATH)) {
                wcscpy(newestPath, path);
                ::RegCloseKey(keyloc);
                break;
              }

              if (CompareVersion(curVer, maxVer) >= 0) {
                wcscpy(newestPath, path);
                CopyVersion(&maxVer, &curVer);
              }
            }
          }
          ::RegCloseKey(keyloc);
        }
      }
    } while (ERROR_SUCCESS == result);

    ::RegCloseKey(baseloc);

    static const WCHAR kMozillaVersion[] = NS_L(MOZILLA_VERSION);

    // If nothing is found, then don't add \bin dir and don't set
    // CurrentVersion for Mozilla
    if (newestPath[0] != 0) {
      if (ERROR_SUCCESS == ::RegCreateKeyExW(HKEY_LOCAL_MACHINE, mozPath, 0,
                                             NULL, REG_OPTION_NON_VOLATILE,
                                             KEY_SET_VALUE|KEY_QUERY_VALUE,
                                             NULL, &entryloc, NULL)) {
        if (ERROR_SUCCESS != ::RegQueryValueExW(entryloc, L"CurrentVersion", 0,
                                               NULL, NULL, NULL)) {
          ::RegSetValueExW(entryloc, L"CurrentVersion", 0, REG_SZ,
                           (const BYTE*) kMozillaVersion,
                           NS_ARRAY_LENGTH(kMozillaVersion));
        }
        ::RegCloseKey(entryloc);
      }

      wcscat(newestPath, L"\\bin");

      // See whether the "new_plugin" directory exists
      WCHAR tmpPath[JAVA_PATH_SIZE];
      nsCOMPtr<nsILocalFile> tmpFile;

      wcscpy(tmpPath, newestPath);
      wcscat(tmpPath, L"\\new_plugin");
      rv = NS_NewLocalFile(nsDependentString(tmpPath),
                           PR_TRUE, getter_AddRefs(tmpFile));
      if (NS_SUCCEEDED(rv) && tmpFile) {
        PRBool exists = PR_FALSE;
        PRBool isDir = PR_FALSE;
        if (NS_SUCCEEDED(tmpFile->Exists(&exists)) && exists &&
            NS_SUCCEEDED(tmpFile->IsDirectory(&isDir)) && isDir) {
          // Assume we're supposed to use this as the search
          // directory for the Java Plug-In instead of the normal
          // one
          wcscpy(newestPath, tmpPath);
        }
      }

      rv = NS_NewLocalFile(nsDependentString(newestPath),
                           PR_TRUE, getter_AddRefs(localFile));
    }
  } else if (nsCRT::strcmp(charProp, NS_WIN_QUICKTIME_SCAN_KEY) == 0) {
    nsXPIDLCString strVer;
    if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer))))
      return NS_ERROR_FAILURE;
    verBlock minVer;
    TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);

    // Look for the Quicktime system installation plugins directory
    HKEY keyloc;
    long result;
    DWORD type;
    verBlock qtVer;
    ClearVersion(&qtVer);
    WCHAR path[_MAX_PATH];
    DWORD pathlen = NS_ARRAY_LENGTH(path);

    // First we need to check the version of Quicktime via checking
    // the EXE's version table
    if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                                         L"software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\QuickTimePlayer.exe",
                                         0, KEY_READ, &keyloc)) {
      if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type,
                                              (LPBYTE)&path, &pathlen)) {
        GetFileVersion(path, &qtVer);
      }
      ::RegCloseKey(keyloc);
    }
    if (CompareVersion(qtVer, minVer) < 0)
      return rv;

    if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                                         L"software\\Apple Computer, Inc.\\QuickTime",
                                        0, KEY_READ, &keyloc)) {
      DWORD pathlen = NS_ARRAY_LENGTH(path);

      result = ::RegQueryValueExW(keyloc, L"InstallDir", NULL, &type,
                                  (LPBYTE)&path, &pathlen);
      wcscat(path, L"\\Plugins");
      if (result == ERROR_SUCCESS)
        rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE,
                             getter_AddRefs(localFile));
      ::RegCloseKey(keyloc);
    }
  } else if (nsCRT::strcmp(charProp, NS_WIN_WMP_SCAN_KEY) == 0) {
    nsXPIDLCString strVer;
    if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer))))
      return NS_ERROR_FAILURE;
    verBlock minVer;
    TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);

    // Look for Windows Media Player system installation plugins directory
    HKEY keyloc;
    DWORD type;
    verBlock wmpVer;
    ClearVersion(&wmpVer);
    WCHAR path[_MAX_PATH];
    DWORD pathlen = NS_ARRAY_LENGTH(path);

    // First we need to check the version of WMP
    if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                                         L"software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\wmplayer.exe",
                                         0, KEY_READ, &keyloc)) {
      if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type,
                                              (LPBYTE)&path, &pathlen)) {
        GetFileVersion(path, &wmpVer);
      }
      ::RegCloseKey(keyloc);
    }
    if (CompareVersion(wmpVer, minVer) < 0)
      return rv;

    if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                                         L"software\\Microsoft\\MediaPlayer", 0,
                                         KEY_READ, &keyloc)) {
      if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, L"Installation Directory",
                                             NULL, &type, (LPBYTE)&path,
                                             &pathlen)) {
        rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE,
                             getter_AddRefs(localFile));
      }

      ::RegCloseKey(keyloc);
    }
  } else if (nsCRT::strcmp(charProp, NS_WIN_ACROBAT_SCAN_KEY) == 0) {
    nsXPIDLCString strVer;
    if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) {
      return NS_ERROR_FAILURE;
    }

    verBlock minVer;
    TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);

    // Look for Adobe Acrobat system installation plugins directory
    HKEY baseloc;
    HKEY keyloc;
    FILETIME modTime;
    DWORD type;
    DWORD index = 0;
    DWORD numChars = _MAX_PATH;
    DWORD pathlen;
    verBlock maxVer;
    ClearVersion(&maxVer);
    WCHAR curKey[_MAX_PATH] = L"software\\Adobe\\Acrobat Reader";
    WCHAR path[_MAX_PATH];
    // Add + 8 to prevent buffer overrun when adding \browser
    WCHAR newestPath[_MAX_PATH + 8];

    newestPath[0] = 0;
    if (ERROR_SUCCESS != ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0,
                                         KEY_READ, &baseloc)) {
      wcscpy(curKey, L"software\\Adobe\\Adobe Acrobat");
      if (ERROR_SUCCESS != ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0,
                                           KEY_READ, &baseloc)) {
        return NS_ERROR_FAILURE;
      }
    }

    // We must enumerate through the keys because what if there is
    // more than one version?
    LONG result = ERROR_SUCCESS;
    while (ERROR_SUCCESS == result) {
      path[0] = 0;
      numChars = _MAX_PATH;
      pathlen = NS_ARRAY_LENGTH(path);
      result = ::RegEnumKeyExW(baseloc, index, curKey, &numChars, NULL, NULL,
                               NULL, &modTime);
      index++;

      if (ERROR_SUCCESS == result) {
        verBlock curVer;
        TranslateVersionStr(curKey, &curVer);
        wcscat(curKey, L"\\InstallPath");
        if (ERROR_SUCCESS == ::RegOpenKeyExW(baseloc, curKey, 0,
                                             KEY_QUERY_VALUE, &keyloc)) {
          // We have a sub key
          if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type,
                                                  (LPBYTE)&path, &pathlen)) {
            if (CompareVersion(curVer, maxVer) >= 0 &&
                CompareVersion(curVer, minVer) >= 0) {
              wcscpy(newestPath, path);
              CopyVersion(&maxVer, &curVer);
            }
          }

          ::RegCloseKey(keyloc);
        }
      }
    }

    ::RegCloseKey(baseloc);

    if (newestPath[0] != 0) {
      wcscat(newestPath, L"\\browser");
      rv = NS_NewLocalFile(nsDependentString(newestPath), PR_TRUE,
                           getter_AddRefs(localFile));
    }

  }

  if (localFile && NS_SUCCEEDED(rv))
    return CallQueryInterface(localFile, _retval);

  return rv;
}
NS_IMETHODIMP
nsPluginDirServiceProvider::GetFile(const char *charProp, PRBool *persistant,
                                    nsIFile **_retval)
{
  nsCOMPtr<nsILocalFile>  localFile;
  nsresult rv = NS_ERROR_FAILURE;

  NS_ENSURE_ARG(charProp);

  *_retval = nsnull;
  *persistant = PR_FALSE;

  nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
  if (!prefs)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIWindowsRegKey> regKey =
    do_CreateInstance("@mozilla.org/windows-registry-key;1");
  NS_ENSURE_TRUE(regKey, NS_ERROR_FAILURE);

  if (nsCRT::strcmp(charProp, NS_WIN_4DOTX_SCAN_KEY) == 0) {
    // Check our prefs to see if scanning the 4.x folder has been
    // explictly overriden failure to get the pref is okay, we'll do
    // what we've been doing -- a filtered scan
    PRBool bScan4x;
    if (NS_SUCCEEDED(prefs->GetBoolPref(NS_WIN_4DOTX_SCAN_KEY, &bScan4x)) &&
        !bScan4x) {
      return NS_ERROR_FAILURE;
    }

    // Look for the plugin folder that the user has in their
    // Communicator 4x install
    rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
                      NS_LITERAL_STRING("Software\\Netscape\\Netscape Navigator"),
                      nsIWindowsRegKey::ACCESS_READ);
    if (NS_SUCCEEDED(rv)) {
      nsAutoString currentVersion;
      rv = regKey->ReadStringValue(NS_LITERAL_STRING("CurrentVersion"),
                                   currentVersion);
      if (NS_SUCCEEDED(rv)) {
        nsAutoString childName = currentVersion;
        childName.Append(NS_LITERAL_STRING("\\Main"));
        nsCOMPtr<nsIWindowsRegKey> childKey;

        rv = regKey->OpenChild(childName, nsIWindowsRegKey::ACCESS_READ,
                               getter_AddRefs(childKey));
        if (NS_SUCCEEDED(rv) && childKey) {
          nsAutoString pluginsDirectory;
          rv = childKey->ReadStringValue(NS_LITERAL_STRING("Plugins Directory"),
                                         pluginsDirectory);
          if (NS_SUCCEEDED(rv)) {
            rv = NS_NewLocalFile(pluginsDirectory, PR_TRUE,
                                 getter_AddRefs(localFile));
          }
        }
      }
    }
  } else if (nsCRT::strcmp(charProp, NS_WIN_JRE_SCAN_KEY) == 0) {
    nsXPIDLCString strVer;
    if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer))))
      return NS_ERROR_FAILURE;
    verBlock minVer;
    TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);

    rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
                      NS_LITERAL_STRING("Software\\JavaSoft\\Java Runtime Environment"),
                      nsIWindowsRegKey::ACCESS_READ);
    NS_ENSURE_SUCCESS(rv, rv);

    verBlock maxVer;
    ClearVersion(&maxVer);

    nsAutoString newestPath;
    nsAutoString browserJavaVersion;
    regKey->ReadStringValue(NS_LITERAL_STRING("BrowserJavaVersion"),
                            browserJavaVersion);

    PRUint32 childCount = 0;
    regKey->GetChildCount(&childCount);

    // We must enumerate through the keys because what if there is
    // more than one version?
    for (PRUint32 index = 0; index < childCount; ++index) {
      nsAutoString childName;
      rv = regKey->GetChildName(index, childName);
      if (NS_SUCCEEDED(rv)) {
        // Skip major.minor as it always points to latest in its family
        PRUint32 numChars = 0;
        PRInt32 offset = 0;
        while ((offset = childName.FindChar(L'.', offset + 1)) >= 0) {
          ++numChars;
        }
        if (numChars < 2)
          continue;

        nsCOMPtr<nsIWindowsRegKey> childKey;
        rv = regKey->OpenChild(childName, nsIWindowsRegKey::ACCESS_QUERY_VALUE,
                               getter_AddRefs(childKey));
        if (NS_SUCCEEDED(rv) && childKey) {
          nsAutoString path;
          rv = childKey->ReadStringValue(NS_LITERAL_STRING("JavaHome"), path);
          if (NS_SUCCEEDED(rv)) {
            verBlock curVer;
            TranslateVersionStr(PromiseFlatString(childName).get(), &curVer);
            if (CompareVersion(curVer, minVer) >= 0) {
              if (browserJavaVersion == childName) {
                newestPath = path;
                break;
              }

              if (CompareVersion(curVer, maxVer) >= 0) {
                newestPath = path;
                CopyVersion(&maxVer, &curVer);
              }
            }
          }
        }
      }
    }

    if (newestPath.IsEmpty()) {
      return NS_ERROR_FAILURE;
    }

    // We require the newer NPAPI Java plugin.
    newestPath += NS_LITERAL_STRING("\\bin\\new_plugin");

    rv = NS_NewLocalFile(newestPath,
                         PR_TRUE, getter_AddRefs(localFile));

    if (NS_SUCCEEDED(rv)) {
      nsCOMPtr<nsIWindowsRegKey> newKey =
        do_CreateInstance("@mozilla.org/windows-registry-key;1");
      NS_ENSURE_TRUE(newKey, NS_ERROR_FAILURE);

      rv = newKey->Create(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
                          NS_LITERAL_STRING("Software\\mozilla.org\\Mozilla"),
                          nsIWindowsRegKey::ACCESS_QUERY_VALUE |
                          nsIWindowsRegKey::ACCESS_SET_VALUE);
      if (NS_SUCCEEDED(rv)) {
        PRBool currentVersionExists = PR_FALSE;
        newKey->HasValue(NS_LITERAL_STRING("CurrentVersion"),
                         &currentVersionExists);
        if (!currentVersionExists) {
          newKey->WriteStringValue(NS_LITERAL_STRING("CurrentVersion"),
                                   NS_LITERAL_STRING(MOZILLA_VERSION));
        }
      }
    }
  } else if (nsCRT::strcmp(charProp, NS_WIN_QUICKTIME_SCAN_KEY) == 0) {
    nsXPIDLCString strVer;
    if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer))))
      return NS_ERROR_FAILURE;
    verBlock minVer;
    TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);

    // Look for the Quicktime system installation plugins directory
    verBlock qtVer;
    ClearVersion(&qtVer);

    // First we need to check the version of Quicktime via checking
    // the EXE's version table
    rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
                      NS_LITERAL_STRING("software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\QuickTimePlayer.exe"),
                      nsIWindowsRegKey::ACCESS_READ);
    if (NS_SUCCEEDED(rv)) {
      nsAutoString path;
      rv = regKey->ReadStringValue(NS_LITERAL_STRING(""), path);
      if (NS_SUCCEEDED(rv)) {
        GetFileVersion(PromiseFlatString(path).get(), &qtVer);
      }
      regKey->Close();
    }
    if (CompareVersion(qtVer, minVer) < 0)
      return rv;

    rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
                      NS_LITERAL_STRING("software\\Apple Computer, Inc.\\QuickTime"),
                      nsIWindowsRegKey::ACCESS_READ);
    if (NS_SUCCEEDED(rv)) {
      nsAutoString path;
      rv = regKey->ReadStringValue(NS_LITERAL_STRING("InstallDir"), path);
      if (NS_SUCCEEDED(rv)) {
        path += NS_LITERAL_STRING("\\Plugins");
        rv = NS_NewLocalFile(path, PR_TRUE,
                             getter_AddRefs(localFile));
      }
    }
  } else if (nsCRT::strcmp(charProp, NS_WIN_WMP_SCAN_KEY) == 0) {
    nsXPIDLCString strVer;
    if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer))))
      return NS_ERROR_FAILURE;
    verBlock minVer;
    TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);

    // Look for Windows Media Player system installation plugins directory
    verBlock wmpVer;
    ClearVersion(&wmpVer);

    // First we need to check the version of WMP
    rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
                      NS_LITERAL_STRING("software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\wmplayer.exe"),
                      nsIWindowsRegKey::ACCESS_READ);
    if (NS_SUCCEEDED(rv)) {
      nsAutoString path;
      rv = regKey->ReadStringValue(NS_LITERAL_STRING(""), path);
      if (NS_SUCCEEDED(rv)) {
        GetFileVersion(PromiseFlatString(path).get(), &wmpVer);
      }
      regKey->Close();
    }
    if (CompareVersion(wmpVer, minVer) < 0)
      return rv;

    rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
                      NS_LITERAL_STRING("software\\Microsoft\\MediaPlayer"),
                      nsIWindowsRegKey::ACCESS_READ);
    if (NS_SUCCEEDED(rv)) {
      nsAutoString path;
      rv = regKey->ReadStringValue(NS_LITERAL_STRING("Installation Directory"),
                                   path);
      if (NS_SUCCEEDED(rv)) {
        rv = NS_NewLocalFile(path, PR_TRUE,
                             getter_AddRefs(localFile));
      }
    }
  } else if (nsCRT::strcmp(charProp, NS_WIN_ACROBAT_SCAN_KEY) == 0) {
    nsXPIDLCString strVer;
    if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) {
      return NS_ERROR_FAILURE;
    }

    verBlock minVer;
    TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);

    // Look for Adobe Acrobat system installation plugins directory
    verBlock maxVer;
    ClearVersion(&maxVer);

    nsAutoString newestPath;

    rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
                      NS_LITERAL_STRING("software\\Adobe\\Acrobat Reader"),
                      nsIWindowsRegKey::ACCESS_READ);
    if (NS_FAILED(rv)) {
      rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
                        NS_LITERAL_STRING("software\\Adobe\\Adobe Acrobat"),
                        nsIWindowsRegKey::ACCESS_READ);
      if (NS_FAILED(rv)) {
        return NS_ERROR_FAILURE;
      }
    }

    // We must enumerate through the keys because what if there is
    // more than one version?
    PRUint32 childCount = 0;
    regKey->GetChildCount(&childCount);

    for (PRUint32 index = 0; index < childCount; ++index) {
      nsAutoString childName;
      rv = regKey->GetChildName(index, childName);
      if (NS_SUCCEEDED(rv)) {
        verBlock curVer;
        TranslateVersionStr(PromiseFlatString(childName).get(), &curVer);

        childName += NS_LITERAL_STRING("\\InstallPath");

        nsCOMPtr<nsIWindowsRegKey> childKey;
        rv = regKey->OpenChild(childName, nsIWindowsRegKey::ACCESS_QUERY_VALUE,
                               getter_AddRefs(childKey));
        if (NS_SUCCEEDED(rv)) {
          // We have a sub key
          nsAutoString path;
          rv = childKey->ReadStringValue(NS_LITERAL_STRING(""), path);
          if (NS_SUCCEEDED(rv)) {
            if (CompareVersion(curVer, maxVer) >= 0 &&
                CompareVersion(curVer, minVer) >= 0) {
              newestPath = path;
              CopyVersion(&maxVer, &curVer);
            }
          }
        }
      }
    }

    if (!newestPath.IsEmpty()) {
      newestPath += NS_LITERAL_STRING("\\browser");
      rv = NS_NewLocalFile(newestPath, PR_TRUE,
                           getter_AddRefs(localFile));
    }
  }

  if (localFile && NS_SUCCEEDED(rv))
    return CallQueryInterface(localFile, _retval);

  return rv;
}
Ejemplo n.º 19
0
int MapCooker::TickCompile(int flags) {
	
	if (m_parsing) {
		int r = m_mapBuilder->result;
		if (r != SR_Success)
			return r;

		tools::map_builder::EntSpawn spawn;
		r = MapParser::ParseEntity(m_script, spawn);
		if ((r != SR_Success) && (r != SR_End))
			return r;

		if (r == SR_End) {
			m_parsing = false;
			r = ParseCinematicCompressionMap(flags);
			if (r != SR_Success)
				return r;
			m_mapBuilder->SetCinematicActorCompression(m_caMap);
			if (!m_mapBuilder->SpawnCompile())
				return SR_ParseError;
			m_script.Reset();
		} else {
			RAD_ASSERT(r == SR_Success);
			// For static_mesh_scene, cache the 3DX filetime
			const char *sz = spawn.keys.StringForKey("classname");
			if (sz && !string::cmp(sz, "static_mesh_scene")) {
				sz = spawn.keys.StringForKey("file");
				if (sz) {
					String path(sz);
					path += ".3dx";
					CompareCachedFileTime(flags, path.c_str, path.c_str);
				}
			}

			if (!m_mapBuilder->LoadEntSpawn(spawn))
				return SR_ParseError;

			return SR_Pending;
		}
	}

	if (m_mapBuilder) {
		int r = m_mapBuilder->result;
		if (r != SR_Success)
			return r;

		String path(CStr(asset->path));
		path += ".bsp";
		BinFile::Ref fp = OpenWrite(path.c_str);
		if (!fp)
			return SR_IOError;

		stream::OutputStream os(fp->ob);
		if (m_mapBuilder->bspFileBuilder->Write(os) != pkg::SR_Success)
			return SR_IOError;

		world::bsp_file::BSPFile::Ref bspFile = m_mapBuilder->bspFile;
		RAD_ASSERT(bspFile);

		for (U32 i = 0; i < bspFile->numMaterials; ++i) { 
			// import materials.
			AddImport(bspFile->String((bspFile->Materials()+i)->string));
		}

		return SR_Success;
	}

	m_parsing = true;
	
	// Make sure these get updated
	CompareVersion(flags);
	CompareModifiedTime(flags);
	CompareCachedFileTimeKey(flags, "Source.File");
	CompareCachedFileTime(flags, "Meshes/World/common.3dx", "Meshes/World/common.3dx");

	const String *mapPath = asset->entry->KeyValue<String>("Source.File", flags);
	if (!mapPath || mapPath->empty)
		return SR_MetaError;

	String actorPath = file::SetFileExtension(mapPath->c_str, ".actors");
	CompareCachedFileTime(flags, "Source.File.Actors", actorPath.c_str, true, true);

	//	cout.get() << "********" << std::endl << "Loading :" << mapPath->c_str() << std::endl;

	file::MMFileInputBuffer::Ref ib = engine->sys->files->OpenInputBuffer(mapPath->c_str, ZTools);
	if (!ib)
		return SR_FileNotFound;
	
	m_script.Bind(ib);
	ib.reset();
		
	m_mapBuilder.reset(new (ZTools) tools::map_builder::MapBuilder(*engine.get()));
	m_mapBuilder->SetProgressIndicator(m_ui);

	return SR_Pending;
}
Ejemplo n.º 20
0
void wxWebUpdateListCtrl::RebuildPackageList(wxWebUpdateListCtrlFilter filter)
{
    // remove old contents
    DeleteAllItems();

    int idx = 0;        // could go out of synch with 'i' because
                        // some packages could not be added to the list....
    for (int i=0; i < (int)m_arrRemotePackages.GetCount(); i++, idx++) {

        wxWebUpdatePackage &curr = m_arrRemotePackages[i];
        wxLogAdvMsg(wxS("wxWebUpdateListCtrl::RebuildPackageList - Adding the '") +
            curr.GetName() + wxS("' package..."));


        // set the properties for the first column (NAME)
        // ----------------------------------------------
        InsertItem(idx, curr.GetName());



        // set the properties for the second column (LATEST VERSION)
        // ---------------------------------------------------------
        SetItem(idx, 1, curr.GetLatestVersion());



        // set the properties for the third column (LOCAL VERSION)
        // -------------------------------------------------------

        SetLocalVersionFor(idx, curr);

        // tocheck will be TRUE for outdated items:
        wxWebUpdateCheckFlag f = CompareVersion(curr);
        bool tocheck = (f == wxWUCF_OUTOFDATE || f == wxWUCF_NOTINSTALLED);

        if (IsToDiscard(filter, idx, curr, f)) {

            DeleteItem(idx);
            idx--;
            continue;           // continue with next package
        }



        // set the properties for the fourth column (SIZE)
        // -----------------------------------------------

        // we'll leave the task of updating this field to the
        // wxSizeCacherThread that has been launched by wxWebUpdateDlg
        unsigned long bytesize = 0;
        wxWebUpdateDownload &d = curr.GetDownload();
        if (d.IsDownloadSizeCached())
            bytesize = d.GetDownloadSize();
        SetItem(idx, 3, wxGetSizeStr(bytesize));



        // set the properties for the fifth column (IMPORTANCE)
        // ----------------------------------------------------
        switch (curr.GetImportance()) {
        case wxWUPI_HIGH:
            SetItem(idx, 4, _("high!"));
            Check(idx, tocheck);
            break;
        case wxWUPI_NORMAL:
            SetItem(idx, 4, _("normal"));
            Check(idx, tocheck);
            break;
        case wxWUPI_LOW:
            SetItem(idx, 4, _("low"));
            Check(idx, FALSE);
            break;
        default:
            wxASSERT_MSG(0, wxS("Invalid package !"));
        }


        // set the properties for the sixth column (REQUIRES)
        // ----------------------------------------------------

        wxString str(curr.GetPrerequisites());
        SetItem(idx, 5, str.IsEmpty() ? _("none") : str.c_str());


        // set as item data the index in our remote package array
        SetItemData(idx, i);
    }

    // select the first item of the list
    if (GetItemCount() > 0)
        SetItemState(0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
Ejemplo n.º 21
0
Update_Status UpdateChecker::IsUpdateAvailable(const Version& currentVersion)
{
    Update_Status updateAvailable = UPDATER_LATEST_STABLE;

    try {
        CInternetSession internet;

        OSVERSIONINFOEX osVersion = SysVersion::GetFullVersion();
        CString osVersionStr;
        osVersionStr.Format(_T("Windows %1u.%1u"), osVersion.dwMajorVersion, osVersion.dwMinorVersion);
        if (SysVersion::Is64Bit()) {
            osVersionStr += _T(" x64");
        }

        CString headersFmt = _T("User-Agent: MPC-HC");
        if (VersionInfo::Is64Bit()) {
            headersFmt += _T(" (64-bit)");
        }
#ifdef MPCHC_LITE
        headersFmt += _T(" Lite");
#endif
        headersFmt += _T(" (%s)/");
        headersFmt += VersionInfo::GetFullVersionString();
        headersFmt += _T("\r\n");

        CString headers;
        headers.Format(headersFmt, osVersionStr);

        CHttpFile* versionFile = (CHttpFile*) internet.OpenURL(versionFileURL,
                                                               1,
                                                               INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD,
                                                               headers,
                                                               DWORD(-1));

        if (versionFile) {
            CString latestVersionStr;
            char buffer[101];
            UINT br = 0;

            while ((br = versionFile->Read(buffer, 50)) > 0) {
                buffer[br] = '\0';
                latestVersionStr += buffer;
            }

            if (!ParseVersion(latestVersionStr, latestVersion)) {
                updateAvailable = UPDATER_ERROR;
            } else {
                time_t lastCheck = time(nullptr);
                AfxGetApp()->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_UPDATER_LAST_CHECK, (LPBYTE)&lastCheck, sizeof(time_t));

                int comp = CompareVersion(currentVersion, latestVersion);

                if (comp < 0) {
                    CString ignoredVersionStr = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_UPDATER_IGNORE_VERSION, _T("0.0.0.0"));
                    Version ignoredVersion;
                    bool ignored = false;

                    if (ParseVersion(ignoredVersionStr, ignoredVersion)) {
                        ignored = (CompareVersion(ignoredVersion, latestVersion) >= 0);
                    }

                    updateAvailable = ignored ? UPDATER_UPDATE_AVAILABLE_IGNORED : UPDATER_UPDATE_AVAILABLE;
                } else if (comp > 0) {
                    updateAvailable = UPDATER_NEWER_VERSION;
                }
            }

            versionFile->Close(); // Close() isn't called by the destructor
            delete versionFile;
        } else {
            updateAvailable = UPDATER_ERROR;
        }
    } catch (CInternetException* pEx) {
        updateAvailable = UPDATER_ERROR;
        pEx->Delete();
    }

    return updateAvailable;
}
Ejemplo n.º 22
0
void ResolveSupersedeGre(siC *siCObject, greInfo *aGre)
{
  grever  *greSupersedeListTmp = NULL;
  grever  *greInstalledListTmp = NULL;
  char    versionStr[MAX_BUF_TINY];
  siC     *siCTmp = NULL;
  BOOL    foundVersionWithinRange = FALSE;
  BOOL    minVerRead = FALSE;
  BOOL    maxVerRead = FALSE;
  BOOL    stillInRange = FALSE;

  if(GetGreSupersedeVersionList(siCObject, &aGre->greSupersedeList))
    return;
  if(GetGreInstalledVersionList(siCObject, &aGre->greInstalledList))
    return;
  if(!aGre->greSupersedeList || !aGre->greInstalledList)
    // nothing to compare, return
    return;

  GetConfigIniProfileString(siCObject->szReferenceName, "SupersedeMinVersion", "",
			    versionStr, sizeof(versionStr));
  if(*versionStr != '\0')
  {
    TranslateVersionStr(versionStr, &aGre->minVersion);
    minVerRead = TRUE;
  }

  GetConfigIniProfileString(siCObject->szReferenceName, "SupersedeMaxVersion", "",
			    versionStr, sizeof(versionStr));
  if(*versionStr != '\0')
  {
    TranslateVersionStr(versionStr, &aGre->maxVersion);
    maxVerRead = TRUE;
  }


  // do the version comparison here.
  greInstalledListTmp = aGre->greInstalledList;
  while(greInstalledListTmp)
  {
    greSupersedeListTmp = aGre->greSupersedeList;
    while(greSupersedeListTmp)
    {
      if(CompareVersion(greInstalledListTmp->version, greSupersedeListTmp->version) == 0)
      {
        SaveGreInfo(greInstalledListTmp, aGre);
        siCObject->bSupersede = TRUE;
        aGre->siCGreComponent = siCObject;
        break;
      }
      else if(!foundVersionWithinRange && (minVerRead || maxVerRead))
      {
        stillInRange = TRUE;

        if(minVerRead)
          stillInRange = CompareVersion(greInstalledListTmp->version, aGre->minVersion) >= 0;

        if(stillInRange && maxVerRead)
          stillInRange = CompareVersion(greInstalledListTmp->version, aGre->maxVersion) <= 0;

        if(stillInRange)
        {
          // Find the first version within the range.
          SaveGreInfo(greInstalledListTmp, aGre);
          foundVersionWithinRange = TRUE;
        }
      }
      greSupersedeListTmp = greSupersedeListTmp->next;
    }

    if(siCObject->bSupersede)
      break;

    greInstalledListTmp = greInstalledListTmp->next;
  }

  if(!siCObject->bSupersede && foundVersionWithinRange)
    siCObject->bSupersede = TRUE;

  if(siCObject->bSupersede)
  {
    siCObject->dwAttributes &= ~SIC_SELECTED;
    siCObject->dwAttributes |= SIC_DISABLED;
    siCObject->dwAttributes |= SIC_INVISIBLE;
  }
  else
    /* Make sure to unset the DISABLED bit.  If the Setup Type is other than
     * Custom, then we don't care if it's DISABLED or not because this flag
     * is only used in the Custom dialogs.
     *
     * If the Setup Type is Custom and this component is DISABLED by default
     * via the config.ini, it's default value will be restored in the
     * SiCNodeSetItemsSelected() function that called ResolveSupersede(). */
    siCObject->dwAttributes &= ~SIC_DISABLED;
}
Ejemplo n.º 23
0
/*
** CIilinkApp initialization
*/
BOOL
CIilinkApp::InitInstance()
{
    INT_PTR		nResponse;
    CString		Message, Message2;
    char		CompilerLoc[1024];
    HKEY		hKeyVC9, hWinSDK6;
    int			rc;
    BOOL		bDefault=0;

    /*
    ** Make sure II_SYSTEM is set.
    */
    if (!strcmp(getenv("II_SYSTEM"), ""))
    {
	Message.LoadString(IDS_NO_IISYSTEM);
	Message2.LoadString(IDS_TITLE);
	MessageBox(NULL, Message, Message2, MB_OK | MB_ICONEXCLAMATION);
	return FALSE;
    }

    rc = GetEnvironmentVariable("PATH", NULL, 0);
    if (rc > 0)
    {
	char *szBuf, *pdest;
	int result1=0, result2=0;

	szBuf = (char *)malloc(rc);
	GetEnvironmentVariable("PATH", szBuf, rc);
	_tcslwr(szBuf);
	pdest=_tcsstr(szBuf, "9.0\\vc");
	if (pdest != NULL) result1=pdest-szBuf+1;
	pdest=_tcsstr(szBuf, "8\\vc");
	if (pdest != NULL) result2=pdest-szBuf+1;
	if (result1 && result2 && result1 < result2 || result1 && !result2)
	    bDefault=1;
	
	free(szBuf);
    }

	/* Find SDK 6.0 that goes along with VC9.0 */
	if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, 
			"SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v6.0A",
			0,
			KEY_READ,
			&hWinSDK6) != ERROR_SUCCESS && bDefault)
	{
		Message.LoadString(IDS_NO_SDK6);
		Message2.LoadString(IDS_TITLE);
		MessageBox(NULL, Message, Message2, MB_OK | MB_ICONEXCLAMATION);
	}
    /*
    ** Let's find out if Visual Studio 9.0 is installed, and set up the environment to it.
    */
    if (RegOpenKeyEx (
	    HKEY_LOCAL_MACHINE,
	    "SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VS",
	    0,
	    KEY_READ,
	    &hKeyVC9) == ERROR_SUCCESS)
    {
	if (SearchPath(NULL, "cl.exe", NULL, sizeof(CompilerLoc), CompilerLoc,
			NULL) != 0 && !bDefault)
	{
	    Message.LoadString(IDS_VC9_EXISTS);
	    Message2.LoadString(IDS_TITLE);
	    rc = MessageBox(NULL, Message, Message2, MB_YESNO | MB_ICONQUESTION);
	    if (rc == IDYES)
	    {
			if (hWinSDK6 == NULL)
			{
			Message.LoadString(IDS_NO_SDK6);
			Message2.LoadString(IDS_TITLE);
			MessageBox(NULL, Message, Message2, MB_OK | MB_ICONEXCLAMATION);
			}
			/*
			** Set up our environment to point to the 9.0 compiler.
			*/
			SetupVC9Environment(hKeyVC9, hWinSDK6);
	    }
	}
	else
	{
	    /*
	    ** Set up our environment to point to the VC .NET compiler.
	    */
	    SetupVC9Environment(hKeyVC9, hWinSDK6);
	}

	RegCloseKey(hKeyVC9);
	RegCloseKey(hWinSDK6);
    }

    /*
    ** Make sure we can find the compiler.
    */
    if (!SearchPath(NULL, "cl.exe", NULL, sizeof(CompilerLoc), CompilerLoc,
		    NULL))
    {
	Message.LoadString(IDS_NO_COMPILER);
	Message2.LoadString(IDS_TITLE);
	MessageBox(NULL, Message, Message2, MB_OK | MB_ICONEXCLAMATION);
	return FALSE;
    }

    /*
    ** Make sure the compiler version is at least at the version that
    ** the product was built with.
    */
    if (!CompareVersion(CompilerLoc))
	return FALSE;

    /*
    ** Make sure the installation is down.
    */
    if (ping_iigcn()!=1)
    {
	int	status;

	Message.LoadString(IDS_INGRES_RUNNING);
	Message2.LoadString(IDS_TITLE);
	status = MessageBox(NULL, Message, Message2, MB_YESNO | MB_ICONINFORMATION);
	if (status == IDNO)
	    return FALSE;
	else
	    IngresUp = TRUE;
    }

    AfxEnableControlContainer();

    hSystemPalette=0;
/*  // InitCommonControlsEx() is required on Windows XP if an application
    // manifest specifies use of ComCtl32.dll version 6 or later to enable
    // visual styles.  Otherwise, any window creation will fail.
    INITCOMMONCONTROLSEX InitCtrls;
    InitCtrls.dwSize = sizeof(InitCtrls);
    // Set this to include all the common control classes you want to use
    // in your application.
    InitCtrls.dwICC = ICC_WIN95_CLASSES;
    InitCommonControlsEx(&InitCtrls);
*/
    InitCommonControls();
    CWinApp::InitInstance();

    AfxEnableControlContainer();

    FileSrcList = FileObjList = NULL;
    UserLoc = "";
    BackupExt = "BAK";
    PropSheet psDlg("Ingres User Defined Data Type Linker");
    m_pMainWnd = &psDlg;
    nResponse = psDlg.DoModal();
    if (nResponse == IDOK)
    {
    }
    else if (nResponse == IDCANCEL)
    {
    }

    if (hSystemPalette)
    {
	HDC hDC=::GetDC(NULL);
	::SelectPalette(hDC,hSystemPalette,FALSE);
	::SelectPalette(hDC,hSystemPalette,TRUE);
	::RealizePalette(hDC);
	::ReleaseDC(NULL,hDC);
    }

    /*
    ** Since the dialog has been closed, return FALSE so that we exit the
    ** application, rather than start the application's message pump.
    */
    return FALSE;
}
Ejemplo n.º 24
0
BOOL ResolveSupersede(siC *siCObject, greInfo *aGre)
{
  DWORD dwIndex;
  char  szFilePath[MAX_BUF];
  char  szSupersedeFile[MAX_BUF];
  char  szSupersedeVersion[MAX_BUF];
  char  szType[MAX_BUF_TINY];
  char  szKey[MAX_BUF_TINY];
  verBlock  vbVersionNew;
  verBlock  vbFileVersion;

  siCObject->bSupersede = FALSE;
  if(siCObject->dwAttributes & SIC_SUPERSEDE)
  {
    dwIndex = 0;
    GetConfigIniProfileString(siCObject->szReferenceName, "SupersedeType", "", szType, sizeof(szType));
    if(*szType !='\0')
    {
      if(lstrcmpi(szType, "File Exists") == 0)
      {
        wsprintf(szKey, "SupersedeFile%d", dwIndex);        
        GetConfigIniProfileString(siCObject->szReferenceName, szKey, "", szSupersedeFile, sizeof(szSupersedeFile));
        while(*szSupersedeFile != '\0')
        {
          DecryptString(szFilePath, szSupersedeFile);
          if(FileExists(szFilePath))
          {
            wsprintf(szKey, "SupersedeMinVersion%d",dwIndex);
            GetConfigIniProfileString(siCObject->szReferenceName, szKey, "", szSupersedeVersion, sizeof(szSupersedeVersion));
            if(*szSupersedeVersion != '\0')
            {
              if(GetFileVersion(szFilePath,&vbFileVersion))
              {
                /* If we can get the version, and it is greater than or equal to the SupersedeVersion
                 * set supersede.  If we cannot get the version, do not supersede the file. */
                TranslateVersionStr(szSupersedeVersion, &vbVersionNew);
                if(CompareVersion(vbFileVersion,vbVersionNew) >= 0)
                {  
                  siCObject->bSupersede = TRUE;
                  break;  /* Found at least one file, so break out of while loop */
                }
              }
            }
            else
            { /* The file exists, and there's no version to check.  set Supersede */
              siCObject->bSupersede = TRUE;
              break;  /* Found at least one file, so break out of while loop */
            }
          }
          wsprintf(szKey, "SupersedeFile%d", ++dwIndex);        
          GetConfigIniProfileString(siCObject->szReferenceName, szKey, "", szSupersedeFile, sizeof(szSupersedeFile));
        }
      }
      else if(lstrcmpi(szType, "GRE") == 0)
      {
        /* save the GRE component */
        aGre->siCGreComponent = siCObject;

        /* If -fgre is passed in, and the current product to install is !GRE,
         * and the current component is 'Component GRE' then select and
         * disable it to force it to be installed regardless of supersede
         * rules.
         *
         * If the product is GRE, then it won't have a 'Component GRE', but
         * rather a 'Component XPCOM', in which case it will always get
         * installed */
        if((gbForceInstallGre) && (lstrcmpi(sgProduct.szProductNameInternal, "GRE") != 0))
        {
          siCObject->dwAttributes |= SIC_SELECTED;
          siCObject->dwAttributes |= SIC_DISABLED;
        }
        else
          ResolveSupersedeGre(siCObject, aGre);
      }
    }

    if(siCObject->bSupersede)
    {
      siCObject->dwAttributes &= ~SIC_SELECTED;
      siCObject->dwAttributes |= SIC_DISABLED;
      siCObject->dwAttributes |= SIC_INVISIBLE;
    }
    else
      /* Make sure to unset the DISABLED bit.  If the Setup Type is other than
       * Custom, then we don't care if it's DISABLED or not because this flag
       * is only used in the Custom dialogs.
       *
       * If the Setup Type is Custom and this component is DISABLED by default
       * via the config.ini, it's default value will be restored in the
       * SiCNodeSetItemsSelected() function that called ResolveSupersede(). */
      siCObject->dwAttributes &= ~SIC_DISABLED;
  }
  return(siCObject->bSupersede);
}