Ejemplo n.º 1
0
wxGISTask::wxGISTask(const wxXmlNode* pIniNode)
{
    //load
    m_nId = GetDecimalValue(pIniNode, wxT("id"), wxNOT_FOUND);
    m_sName = pIniNode->GetAttribute(wxT("name"), NONAME);
    m_sDescription = pIniNode->GetAttribute(wxT("desc"), NONAME);
    m_sCat = pIniNode->GetAttribute(wxT("cat"), NONAME);
    m_nState = (wxGISEnumTaskStateType)GetDecimalValue(pIniNode, wxT("state"), enumGISTaskUnk);
    m_nPriority = GetDecimalValue(pIniNode, wxT("prio"), wxNOT_FOUND);
    m_dtBeg = GetDateValue(pIniNode, wxT("beg"), wxDateTime::Now());
    m_dtEnd = GetDateValue(pIniNode, wxT("end"), wxDateTime::Now());
    long nVolumeHi = GetDecimalValue(pIniNode, wxT("vol_hi"), 0);
    long nVolumeLo = GetDecimalValue(pIniNode, wxT("vol_lo"), 0);
    m_nVolume = wxULongLong(nVolumeHi, nVolumeLo);
    m_dfDone = GetFloatValue(pIniNode, wxT("done"), 0.0);

    m_pParams = NULL;

    wxXmlNode *Children = pIniNode->GetChildren();
    while(Children)
    {
        if(Children->GetName().IsSameAs(wxT("params"), false))
        {
            if(m_pParams)
                wxDELETE(m_pParams);
            m_pParams = new wxXmlNode(*Children);
        }
        //else if(Children->GetName().IsSameAs(wxT("messages"), false))
        //{
        //    LoadMessages(Children);
        //}
        Children = Children->GetNext();
    }
}
Ejemplo n.º 2
0
void wxGISTask::ChangeTask(const wxXmlNode* pTaskNode)
{
    //load
    m_sName = pTaskNode->GetAttribute(wxT("name"), m_sName);
    m_sDescription = pTaskNode->GetAttribute(wxT("desc"), m_sDescription);
    m_sCat = pTaskNode->GetAttribute(wxT("cat"), m_sCat);
    m_nState = (wxGISEnumTaskStateType)GetDecimalValue(pTaskNode, wxT("state"), m_nState);
    m_nPriority = GetDecimalValue(pTaskNode, wxT("prio"), m_nPriority);
    m_dtBeg = GetDateValue(pTaskNode, wxT("beg"), m_dtBeg);
    m_dtEnd = GetDateValue(pTaskNode, wxT("end"), m_dtEnd);
    long nVolHi = GetDecimalValue(pTaskNode, wxT("vol_hi"), (long)m_nVolume.GetHi());
    long nVolLo = GetDecimalValue(pTaskNode, wxT("vol_lo"), (long)m_nVolume.GetLo());
    m_nVolume = wxULongLong(nVolHi, nVolLo);
    m_dfDone = GetFloatValue(pTaskNode, wxT("done"), m_dfDone);

    wxXmlNode *Children = pTaskNode->GetChildren();
    while(Children)
    {
        if(Children->GetName().IsSameAs(wxT("params"), false))
        {
            if(m_pParams)
                wxDELETE(m_pParams);
            m_pParams = new wxXmlNode(*Children);
        }
        //else if(Children->GetName().IsSameAs(wxT("messages"), false))
        //{
        //    LoadMessages(Children);
        //}
        Children = Children->GetNext();
    }
}
Ejemplo n.º 3
0
// From section 13.2.3 of RFC2616, we compute the current age of a cached
// response as follows:
//
//    currentAge = max(max(0, responseTime - dateValue), ageValue)
//               + now - requestTime
//
//    where responseTime == now
//
// This is typically a very small number.
//
nsresult
nsHttpResponseHead::ComputeCurrentAge(uint32_t now,
                                      uint32_t requestTime,
                                      uint32_t *result) const
{
    uint32_t dateValue;
    uint32_t ageValue;

    *result = 0;

    if (NS_FAILED(GetDateValue(&dateValue))) {
        LOG(("nsHttpResponseHead::ComputeCurrentAge [this=%p] "
             "Date response header not set!\n", this));
        // Assume we have a fast connection and that our clock
        // is in sync with the server.
        dateValue = now;
    }

    // Compute apparent age
    if (now > dateValue)
        *result = now - dateValue;

    // Compute corrected received age
    if (NS_SUCCEEDED(GetAgeValue(&ageValue)))
        *result = std::max(*result, ageValue);

    MOZ_ASSERT(now >= requestTime, "bogus request time");

    // Compute current age
    *result += (now - requestTime);
    return NS_OK;
}
// From section 13.2.3 of RFC2616, we compute the current age of a cached
// response as follows:
//
//    currentAge = max(max(0, responseTime - dateValue), ageValue)
//               + now - requestTime
//
//    where responseTime == now
//
// This is typically a very small number.
//
nsresult
nsHttpResponseHead::ComputeCurrentAge(PRUint32 now,
                                      PRUint32 requestTime,
                                      PRUint32 *result)
{
    PRUint32 dateValue;
    PRUint32 ageValue;

    *result = 0;

    if (NS_FAILED(GetDateValue(&dateValue))) {
        LOG(("nsHttpResponseHead::ComputeCurrentAge [this=%x] "
             "Date response header not set!\n", this));
        // Assume we have a fast connection and that our clock
        // is in sync with the server.
        dateValue = now;
    }

    // Compute apparent age
    if (now > dateValue)
        *result = now - dateValue;

    // Compute corrected received age
    if (NS_SUCCEEDED(GetAgeValue(&ageValue)))
        *result = PR_MAX(*result, ageValue);

    NS_ASSERTION(now >= requestTime, "bogus request time");

    // Compute current age
    *result += (now - requestTime);
    return NS_OK;
}
Ejemplo n.º 5
0
void wxGISTaskManager::AddMessage(const wxXmlNode* pIniNode)
{
    wxCHECK_RET(pIniNode, wxT("Input wxXmlNode pointer is null"));
    int nTaskId = GetDecimalValue(pIniNode, wxT("id"), wxNOT_FOUND);
    if(nTaskId == wxNOT_FOUND)
        return;
    wxGISTask* pTasks = m_moTasks[nTaskId];
    if(pTasks == NULL)
        return;

    long nMsgId = GetDecimalValue(pIniNode, wxT("msg_id"), wxNOT_FOUND);
    if(nMsgId == wxNOT_FOUND)
        return;

    wxGISEnumMessageType eType = (wxGISEnumMessageType)GetDecimalValue(pIniNode, wxT("msg_type"), enumGISMessageUnk);
    wxDateTime dt = GetDateValue(pIniNode, wxT("msg_dt"), wxDateTime::Now());
    wxString sInfoData = pIniNode->GetAttribute(wxT("msg"));

    if(!dt.IsValid() || sInfoData.IsEmpty())
        return;

    pTasks->AddMessage(new wxGISTaskMessage(nMsgId, sInfoData, eType, dt));

    //notify
    wxGISTaskEvent event(nTaskId, wxGISTASK_MESSAGEADDED, nMsgId);
    PostEvent(event);
}
Ejemplo n.º 6
0
PRBool
nsHttpResponseHead::ExpiresInPast()
{
    PRUint32 expiresVal, dateVal;
    return NS_SUCCEEDED(GetExpiresValue(&expiresVal)) &&
           NS_SUCCEEDED(GetDateValue(&dateVal)) &&
           expiresVal < dateVal;
}
Ejemplo n.º 7
0
bool
nsHttpResponseHead::ExpiresInPast() const
{
    uint32_t maxAgeVal, expiresVal, dateVal;

    // Bug #203271. Ensure max-age directive takes precedence over Expires
    if (NS_SUCCEEDED(GetMaxAgeValue(&maxAgeVal))) {
        return false;
    }

    return NS_SUCCEEDED(GetExpiresValue(&expiresVal)) &&
           NS_SUCCEEDED(GetDateValue(&dateVal)) &&
           expiresVal < dateVal;
}
Ejemplo n.º 8
0
// From section 13.2.4 of RFC2616, we compute the freshness lifetime of a cached
// response as follows:
//
//     freshnessLifetime = max_age_value
// <or>
//     freshnessLifetime = expires_value - date_value
// <or>
//     freshnessLifetime = (date_value - last_modified_value) * 0.10
// <or>
//     freshnessLifetime = 0
//
nsresult
nsHttpResponseHead::ComputeFreshnessLifetime(uint32_t *result) const
{
    *result = 0;

    // Try HTTP/1.1 style max-age directive...
    if (NS_SUCCEEDED(GetMaxAgeValue(result)))
        return NS_OK;

    *result = 0;

    uint32_t date = 0, date2 = 0;
    if (NS_FAILED(GetDateValue(&date)))
        date = NowInSeconds(); // synthesize a date header if none exists

    // Try HTTP/1.0 style expires header...
    if (NS_SUCCEEDED(GetExpiresValue(&date2))) {
        if (date2 > date)
            *result = date2 - date;
        // the Expires header can specify a date in the past.
        return NS_OK;
    }

    // Fallback on heuristic using last modified header...
    if (NS_SUCCEEDED(GetLastModifiedValue(&date2))) {
        LOG(("using last-modified to determine freshness-lifetime\n"));
        LOG(("last-modified = %u, date = %u\n", date2, date));
        if (date2 <= date) {
            // this only makes sense if last-modified is actually in the past
            *result = (date - date2) / 10;
            return NS_OK;
        }
    }

    // These responses can be cached indefinitely.
    if ((mStatus == 300) || nsHttp::IsPermanentRedirect(mStatus)) {
        *result = uint32_t(-1);
        return NS_OK;
    }

    LOG(("nsHttpResponseHead::ComputeFreshnessLifetime [this = %x] "
         "Insufficient information to compute a non-zero freshness "
         "lifetime!\n", this));

    return NS_OK;
}
Ejemplo n.º 9
0
QDate RDLog::purgeDate() const
{
  return GetDateValue("PURGE_DATE");
}
Ejemplo n.º 10
0
QDate RDLog::endDate() const
{
  return GetDateValue("END_DATE");
}
Ejemplo n.º 11
0
QDate RDLog::startDate() const
{
  return GetDateValue("START_DATE");
}
Ejemplo n.º 12
0
// -----------------------------------------------------------------------------
// CWPPushMessage::ParseContentType
// -----------------------------------------------------------------------------
//
void CWPPushMessage::ParseContentType( TLex8& aPointer )
    {
    // Go through the whole content type header.
    while( !aPointer.Eos() )
        {
        // Each parameter might be well-known (integer) or unknown (text)
        if( IsIntegerValue( aPointer ) )
            {
            // For well-known parameters, the token is an integer value
            TUint paramToken( I64LOW( GetIntegerValue( aPointer ) ) );

            // These are filled with results from parsing.
            TInt resultInteger( 0 );
            TPtrC8 resultString;
            
            // Make sure paramToken fits into KParameterTypes table
            if( paramToken 
                < sizeof(KParameterTypes)/sizeof(TParameterCodingType))
                {
                // Get the coding and use it to determine how we should decode 
                // the next parameter value. We actually ignore all results 
                // except short integer (SEC) and text-value (MAC), but the 
                // rest of the parameters have to be parsed anyway.
                TParameterCodingType coding( KParameterTypes[paramToken] );

                switch( coding )
                    {
                    case EQValue:
                        GetQValue( aPointer );
                        break;

                    case EWellKnownCharset:
                        GetWellKnownCharset( aPointer );
                        break;

                    case EVersionValue:
                        GetVersionValue( aPointer );
                        break;

                    case EIntegerValue:
                        GetIntegerValue( aPointer );
                        break;

                    case ETextString:
                        GetTextString( aPointer );
                        break;

                    case EFieldName:
                        GetFieldName( aPointer );
                        break;

                    case EShortInteger:
                        resultInteger = GetShortInteger( aPointer );
                        break;

                    case EConstrainedEncoding:
                        GetConstrainedEncoding( aPointer );
                        break;

                    case EDeltaSecondsValue:
                        GetDeltaSecondsValue( aPointer );
                        break;

                    case ENoValue:
                        GetNoValue( aPointer );
                        break;

                    case ETextValue:
                        resultString.Set( GetTextValue( aPointer ) );
                        break;

                    case EDateValue:
                        GetDateValue( aPointer );
                        break;

                    default:
                        break;
                    }

                // We have a result. We're actually only interested in
                // SEC and MAC parameters, so we save them here.
                switch( paramToken )
                    {
                    case KWSPHeaderSEC:
                        iSEC = resultInteger;
                        break;

                    case KWSPHeaderMAC:
                        iMAC.Set( resultString );
                        break;

                    default:
                        break;
                    }
                }
            }
        else
            {
            // Unknown parameter. Its name is in text, and the value
            // might be an integer or text.
            GetTokenText( aPointer );
            if( IsIntegerValue( aPointer ) )
                {
                GetIntegerValue( aPointer );
                }
            else
                {
                GetTextValue( aPointer );
                }
            }
        }
    }