示例#1
0
void HTTPRequest::AppendDateField()
{
    Assert(OSThread::GetCurrent() != NULL);
    DateBuffer* theDateBuffer = OSThread::GetCurrent()->GetDateBuffer();
    theDateBuffer->InexactUpdate(); // Update the date buffer to the current date & time
    StrPtrLen theDate(theDateBuffer->GetDateBuffer(), DateBuffer::kDateBufferLen);
  
    // Append date
    this->AppendResponseHeader(httpDateHeader, &theDate);
}
示例#2
0
void HTTPRequest::AppendDateAndExpiresFields()
{
    Assert(OSThread::GetCurrent() != NULL);
    DateBuffer* theDateBuffer = OSThread::GetCurrent()->GetDateBuffer();
    theDateBuffer->InexactUpdate(); // Update the date buffer to the current date & time
    StrPtrLen theDate(theDateBuffer->GetDateBuffer(), DateBuffer::kDateBufferLen);
  
    // Append dates, and have this response expire immediately
    this->AppendResponseHeader(httpDateHeader, &theDate);
    this->AppendResponseHeader(httpExpiresHeader, &theDate);
}
void RTSPRequestInterface::AppendDateAndExpires()
{
    if (!fStandardHeadersWritten)
        this->WriteStandardHeaders();

    Assert(OSThread::GetCurrent() != NULL);
    DateBuffer* theDateBuffer = OSThread::GetCurrent()->GetDateBuffer();
    theDateBuffer->InexactUpdate(); // Update the date buffer to the current date & time
    StrPtrLen theDate(theDateBuffer->GetDateBuffer(), DateBuffer::kDateBufferLen);
    
    // Append dates, and have this response expire immediately
    this->AppendHeader(qtssDateHeader, &theDate);
    this->AppendHeader(qtssExpiresHeader, &theDate);
}
示例#4
0
void DocDigestDetailView::documentListing( TextTemplate *tmpl, int year, int month )
{

    QString minDate;
    QString maxDate;
    if( month > -1 ) {
        QDate theDate(year, month, 1);
        // not a year
        minDate = theDate.toString("yyyy-MM-dd");
        int lastDay = theDate.daysInMonth();
        theDate.setDate(year, month, lastDay);
        maxDate = theDate.toString("yyyy-MM-dd");
    } else {
        // is is a year
        minDate = QString::number(year)+"-01-01";
        maxDate = QString::number(year)+"-12-31";
    }

    // read data in the given timeframe from database
    QSqlQuery q;
    const QString query = QString("SELECT archDocID, ident, MAX(printDate) FROM archdoc WHERE "
                                  "date BETWEEN date('%1') AND date('%2') "
                                  "GROUP BY ident").arg(minDate, maxDate);

    // qDebug() << "***" << query;
    QMap<QString, QPair<int, Geld> > docMatrix;
    q.prepare(query);
    q.exec();
    while( q.next() ) {
       dbID archDocId(q.value(0).toInt());

       const ArchDoc doc(archDocId);
       const QString docType = doc.docType();
       Geld g;
       int n = 0;
       if( docMatrix.contains(docType)) {
           g = docMatrix[docType].second;
           n = docMatrix[docType].first;
       }
       Geld g1 = doc.nettoSum();
       g += g1;
       docMatrix[docType].first = n+1;
       docMatrix[docType].second = g;
     }

    // now create the template

    tmpl->setValue("I18N_AMOUNT", i18n("Amount"));
    tmpl->setValue("I18N_TYPE",   i18n("Type"));
    tmpl->setValue("I18N_SUM",    i18n("Sum"));

    QStringList doctypes = docMatrix.keys();
    doctypes.sort();

    foreach( const QString dtype, doctypes ) {
        qDebug() << "creating doc list for "<<dtype;
        tmpl->createDictionary( "DOCUMENTS" );
        tmpl->setValue("DOCUMENTS", "DOCTYPE", dtype);
        const QString am = QString::number(docMatrix[dtype].first);
        tmpl->setValue("DOCUMENTS", "AMOUNT", am);
        const QString sm = docMatrix[dtype].second.toString(DefaultProvider::self()->locale());
        tmpl->setValue("DOCUMENTS", "SUM", sm);
    }
示例#5
0
TVerdict CTPKCS7ValidTest::doTestStepL()
	{
	if (TestStepResult() != EPass)
		{
		return TestStepResult();
		}

	__UHEAP_MARK;
	TBool expectedValid;
	if (GetBoolFromConfig(ConfigSection(),_L("IsValid"), expectedValid) == EFalse)
		{
		expectedValid = ETrue;
		}
	
	TInt err;

	CPKCS7ContentInfo * contentInfo = NULL;
	TRAP (err, contentInfo = CPKCS7ContentInfo::NewL(iRawData->Des()));
	
	if(err == KErrNone)
		{
		CPKCS7SignedObject * p7 = NULL;
		if( contentInfo->ContentType() == KPkcs7SignedData)
			{
			TRAP (err, p7 = CPKCS7SignedObject::NewL(*contentInfo));
			//expired, and the case where certificate chain root is not on the device	
			if (!expectedValid)
				{
				if (err != KErrNone)
					{
					SetTestStepResult(EPass);
					INFO_PRINTF2(_L("Got %d building PKCS7 object"), err);
					return TestStepResult();
					}
				}

			if (err != KErrNone)
				{
				SetTestStepResult(EFail);
				INFO_PRINTF2(_L("Got %d building PKCS7 object"), err);
				}
			else
				{
				CleanupStack::PushL (p7);
		
				const RPointerArray<CPKCS7SignerInfo>& signers = p7->SignerInfo();
				TBool isValid = EFalse;
				HBufC8* certificateEncoding = NULL;
				if(!p7->ValidateSignerL(*signers[0], certificateEncoding))
					{
					INFO_PRINTF1(_L("Couldn't validate signer"));
					}
				else
					{
					CActiveScheduler* sched = NULL;
					if (CActiveScheduler::Current() == NULL)
						{
						INFO_PRINTF1(_L("Installing scheduler"));
						sched = new (ELeave) CActiveScheduler();
						CleanupStack::PushL (sched);
						__UHEAP_MARK;
						CActiveScheduler::Install (sched);
						}
					RPointerArray<CX509Certificate> roots (&iRootCertificate, 1);
					CPKIXCertChain * chain = CPKIXCertChain::NewLC(iFs, *certificateEncoding, roots);
					TTime tm;
					_LIT(KDateCorrect1,"20040801:"); 
					TBuf <24> theDate(KDateCorrect1); 
					TInt err=tm.Set(theDate); 
					if(err)
						{
						tm.HomeTime();
						}
					CPKIXValidationResult* result = CPKIXValidationResult::NewLC();
					CTPKCS7Validator* validator = new (ELeave) CTPKCS7Validator (chain, result, &tm);
					CleanupStack::PushL (validator);
					validator->doValidate ();
					sched->Start ();
					if (result->Error().iReason == EValidatedOK)
						{
						isValid = ETrue;
						INFO_PRINTF1(_L("Validation success"));
						}
					else
						{
						INFO_PRINTF2(_L("Validation failed: %d"), result->Error().iReason);
						}
            				
					CleanupStack::PopAndDestroy(validator);
					CleanupStack::PopAndDestroy(result);
					CleanupStack::PopAndDestroy(chain);
					if (sched)
						{
						CActiveScheduler::Install (NULL);
						CleanupStack::PopAndDestroy (sched);
						}
					}
				if (certificateEncoding)
					{
					CleanupStack::PopAndDestroy(certificateEncoding);
					}
				CleanupStack::PopAndDestroy (p7);
				if (isValid != expectedValid)
					{
					SetTestStepResult(EFail);
					if (expectedValid)
						{
						INFO_PRINTF1(_L("Expected valid, got invalid"));
						}
					else
						{
						INFO_PRINTF1(_L("Expected invalid, got valid"));
						}
					}
				}

			}
		}
	else
		{
		SetTestStepResult(EFail);
		}

	
	__UHEAP_MARKEND;
	return TestStepResult();
	}
TVerdict CT_LbsStep_ClearLog::doTestStepL()
	{
	SetTestStepResult(EPass);

	// Create necessary variables for Log reading
	RFs theFs;
	CLogClient* client;
	CLogViewEvent* view;
	CT_LbsAsyncWaiter* activeWaiter;
		
	//	Initialise variables
	TInt ErrorCode = theFs.Connect();
	if(ErrorCode)
		{
		INFO_PRINTF1(_L("\t Error: Open FileServer failed."));
		SetTestStepResult(EFail);
		}
		

    client = CLogClient::NewL(theFs, CActive::EPriorityStandard);
	view = CLogViewEvent::NewL(*client, CActive::EPriorityStandard);
	activeWaiter = CT_LbsAsyncWaiter::NewL();			// NEW activeWaiter
	
	
	// Setup a time in the future, before which all events will be deleted
 	_LIT(KDateCorrect1,"20900101:"); 
 	TTime time;
	TBuf <10> theDate(KDateCorrect1);
	TInt err=time.Set(theDate); 
	
	// Ensure time has been set correctly
	if(err != KErrNone)
		{
		INFO_PRINTF1(_L("Failed to set time"));
		}
		
	if(err == KErrGeneral)
		{
		INFO_PRINTF1(_L("Time syntax is incorrect"));
		}
	
	// Set the filter to view ALL logs
	CLogFilter* filter = CLogFilter::NewL();			// NEW FILTER
	CleanupStack::PushL(filter);
	TBool res = view->SetFilterL(*filter, activeWaiter->iStatus);
	if (res == EFalse)
		{
		INFO_PRINTF1(_L("\t No such events to filter in the view."));
		client->Cancel();
		}
	else
		{
		// else If there are logs, flush them
			
		// Cancel outstanding requests
		client->Cancel();	
		activeWaiter->StartAndWait();
		if (activeWaiter->iStatus != KErrNone)
			{
			INFO_PRINTF2(_L("\t Error: Cancel returned error %d."),activeWaiter->iStatus.Int());
			SetTestStepResult(EFail);
			}

		// Clear ALL logs
		client->ClearLog(time, activeWaiter->iStatus);
		activeWaiter->StartAndWait();
		if (activeWaiter->iStatus != KErrNone)
			{
			INFO_PRINTF2(_L("\t Error: Clear log returned error %d."),activeWaiter->iStatus.Int());
			SetTestStepResult(EFail);
			}	
			
		//Confirm log is cleared
		if(view->CountL() != 0)
			{
			INFO_PRINTF2(_L("<FONT><B>ERROR: Log still has %d entries</B></FONT>"),view->CountL());
			SetTestStepResult(EFail);
			}
				
		}
	
	CleanupStack::PopAndDestroy(filter);	
		
	// Cleanup everything
	view->Cancel();
	client->Cancel();

	delete view;
	delete client;
	theFs.Close();
	delete activeWaiter;

	return TestStepResult();
	}