Ejemplo n.º 1
0
PGPError PGPclExport 
PGPclIsExpired(HWND hwnd)
{
	PGPError err = kPGPError_NoErr;
#if BETA_TIMEOUT > 0
	unsigned short month, day, year;
	struct tm tm, *ptm;
	time_t TimeNow, TimeoutTime;

	//Get the compile date, in usable form:
	TranslateDate(&month, &day, &year, __DATE__);

	//Seed the tm structure with the current time:
	time(&TimeNow);
	ptm = localtime(&TimeNow);
	memcpy(&tm, ptm, sizeof(tm));

	//Set the dates to the compile time:
	tm.tm_mon = month - 1;
	tm.tm_mday = day;
	tm.tm_year = year - 1900;

	//Turn the compile time into number of secs since 1/1/1970:
	TimeoutTime = mktime(&tm);

	//Increment it plus the number of days in the beta timeout times the 
	TimeoutTime += BETA_TIMEOUT * (60 * 60 * 24); //number of seconds in a day

	if(TimeoutTime < TimeNow)
	{
		err = kPGPError_FeatureNotAvailable;
		DisplayTimeoutMessage(hwnd);
	}
#endif	// BETA_TIMEOUT > 0

#if PGP_DEMO

	// The timeout starts at 30 days, which only disables encrypt and sign
	// After 30 days, display nag screen
	// After 60 days (TimeOut + 30 days), time out everything and 
	//										delete library DLL's
	
	err = PGPclEvalExpired(hwnd, PGPCOMDLG_ALLEXPIRED);
	if (IsPGPError (err))
	{
		pgpFixBeforeShip ("eval version file deletion");
///???		DeleteTimeoutFile("pgpsdk.dll");
///???		DeleteTimeoutFile("pgp.dll");
		DisplayTimeoutMessage(hwnd);
	}

	if (IsPGPError(PGPclEvalExpired(hwnd, PGPCOMDLG_ENCRYPTSIGNEXPIRED)) && 
			!IsntPGPError (err))
		PGPclNag(hwnd, NULL, NULL);

#endif	// PGP_DEMO

	return err;
}
Ejemplo n.º 2
0
// test parsing dates in free format
void DateTimeTestCase::TestDateParse()
{
    static const struct ParseTestData
    {
        const char *str;
        Date date;              // NB: this should be in UTC
        bool good;
    } parseTestDates[] =
    {
        { "21 Mar 2006", { 21, wxDateTime::Mar, 2006 }, true },
        { "29 Feb 1976", { 29, wxDateTime::Feb, 1976 }, true },
        { "Feb 29 1976", { 29, wxDateTime::Feb, 1976 }, true },
        { "31/03/06",    { 31, wxDateTime::Mar,    6 }, true },
        { "31/03/2006",  { 31, wxDateTime::Mar, 2006 }, true },

        // some invalid ones too
        { "29 Feb 2006" },
        { "31/04/06" },
        { "bloordyblop" },
        { "2 .  .    " },
    };

    // special cases
    wxDateTime dt;
    CPPUNIT_ASSERT( dt.ParseDate(wxT("today")) );
    CPPUNIT_ASSERT_EQUAL( wxDateTime::Today(), dt );

    for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ )
    {
        const wxString datestr = TranslateDate(parseTestDates[n].str);

        const char * const end = dt.ParseDate(datestr);
        if ( end && !*end )
        {
            WX_ASSERT_MESSAGE(
                ("Erroneously parsed \"%s\"", datestr),
                parseTestDates[n].good
            );

            CPPUNIT_ASSERT_EQUAL( parseTestDates[n].date.DT(), dt );
        }
        else // failed to parse
        {
            WX_ASSERT_MESSAGE(
                ("Failed to parse \"%s\"", datestr),
                !parseTestDates[n].good
            );
        }
    }

    // Check that incomplete parse works correctly.
    const char* p = dt.ParseFormat("2012-03-23 12:34:56", "%Y-%m-%d");
    CPPUNIT_ASSERT_EQUAL( " 12:34:56", wxString(p) );
}
Ejemplo n.º 3
0
void DateTimeTestCase::TestDateTimeParse()
{
    static const struct ParseTestData
    {
        const char *str;
        Date date;              // NB: this should be in UTC
        bool good;
    } parseTestDates[] =
    {
        {
            "Thu 22 Nov 2007 07:40:00 PM",
            { 22, wxDateTime::Nov, 2007, 19, 40,  0 },
            true
        },

        {
            "2010-01-04 14:30",
            {  4, wxDateTime::Jan, 2010, 14, 30,  0 },
            true
        },

        {
            "bloordyblop",
            {  1, wxDateTime::Jan, 9999,  0,  0,  0},
            false
        },

        {
            "2012-01-01 10:12:05 +0100",
            {  1, wxDateTime::Jan, 2012,  10,  12,  5, -1 },
            false // ParseDateTime does know yet +0100
        },
    };

    // the test strings here use "PM" which is not available in all locales so
    // we need to use "C" locale for them
    CLocaleSetter cloc;

    wxDateTime dt;
    for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ )
    {
        const wxString datestr = TranslateDate(parseTestDates[n].str);

        const char * const end = dt.ParseDateTime(datestr);
        if ( end && !*end )
        {
            WX_ASSERT_MESSAGE(
                ("Erroneously parsed \"%s\"", datestr),
                parseTestDates[n].good
            );

            CPPUNIT_ASSERT_EQUAL( parseTestDates[n].date.DT(), dt );
        }
        else // failed to parse
        {
            WX_ASSERT_MESSAGE(
                ("Failed to parse \"%s\"", datestr),
                !parseTestDates[n].good
            );

            CPPUNIT_ASSERT( !parseTestDates[n].good );
        }
    }
}