void wxWebUpdateListCtrl::SetLocalVersionFor(int idx, const wxWebUpdatePackage &curr)
{
    // here we need some further work to find if this package
    // is already installed...
    const wxWebUpdateLocalPackage &local = GetLocalPackage(curr.GetName());

    if (!local.IsOk()) {

        // a matching local package does not exist...
        SetItem(idx, 2, _("not installed"));
        return;
    }

    SetItem(idx, 2, local.GetVersion());

    // compare versions
    if (curr.GetLatestVersion() > local.GetVersion()) {

        // build a bold font
        wxFont font(GetFont());
        font.SetWeight(wxFONTWEIGHT_BOLD);

        // and set it for this item
        wxListItem li;
        li.SetId(idx);
        li.SetFont(font);
        li.SetBackgroundColour(*wxWHITE);
        li.SetTextColour(*wxRED);
        SetItem(li);
    }
}
wxWebUpdateCheckFlag wxWebUpdateListCtrl::CompareVersion(const wxWebUpdatePackage &curr) const
{
    const wxWebUpdateLocalPackage &local = GetLocalPackage(curr.GetName());

    if (!local.IsOk())
        return wxWUCF_NOTINSTALLED;

    if (!local.GetVersion().IsOk() ||
        !curr.GetLatestVersion().IsOk())
        return wxWUCF_FAILED;

    if (local.GetVersion() < curr.GetLatestVersion())
        return wxWUCF_OUTOFDATE;

    wxASSERT(local.GetVersion() >= curr.GetLatestVersion());
    return wxWUCF_UPDATED;
}
Example #3
0
std::vector<GUID> DVLib::MsiProductInfo::GetUpgradeCodes() const
{
    std::vector<GUID> upgrade_codes;
    std::wstring local_package = GetLocalPackage();

    MsiHandlePtr h;
    MsiHandlePtr hView;

    MSIHANDLE _h = NULL;
    CHECK_WIN32_DWORD(::MsiOpenDatabase(local_package.c_str(), MSIDBOPEN_READONLY, & _h),
        L"MsiOpenDatabase (" << local_package << L")");

    reset(h, _h);

    MSIHANDLE _hView = NULL;
    CHECK_WIN32_DWORD(::MsiDatabaseOpenView(get(h), L"SELECT DISTINCT `UpgradeCode` FROM `Upgrade`", & _hView),
        L"MsiDatabaseOpenView (" << local_package << L")");

    reset(hView, _hView);

    CHECK_WIN32_DWORD(::MsiViewExecute(get(hView), NULL),
        L"MsiViewExecute (" << local_package << L")");

    while(true)
    {
        MsiHandlePtr hRow;

        MSIHANDLE _hRow = NULL;
        UINT rc = ::MsiViewFetch(get(hView), & _hRow);
        reset(hRow, _hRow);

        if (rc == ERROR_NO_MORE_ITEMS)
        {
            break;
        }
        else if (rc != ERROR_SUCCESS)
        {
            CHECK_WIN32_DWORD(rc,
                L"MsiViewFetch (" << local_package << L")");
        }

        // read upgrade code
        std::wstring data;
        DWORD cbRead = 0;
        CHECK_WIN32_DWORD(::MsiRecordGetString(get(hRow), 1, NULL, & cbRead),
            L"MsiRecordGetString (" << local_package << L")");

        if (cbRead > 0)
        {
            data.resize(cbRead++);
            CHECK_WIN32_DWORD(::MsiRecordGetString(get(hRow), 1, & * data.begin(), & cbRead), 
                L"MsiRecordGetString (" << local_package << L"/" << cbRead << L")");
            data.resize(cbRead);
        }

        GUID upgrade_code = DVLib::string2guid(data);
        upgrade_codes.push_back(upgrade_code);
    }

    return upgrade_codes;
}