예제 #1
0
void DwDispositionType::_PrintDebugInfo(std::ostream &aStrm) const
{
    DwFieldBody::_PrintDebugInfo(aStrm);
    aStrm << "Disposition Type: " << mDispositionTypeStr
          << " (" << mDispositionType    << ")\n";
    aStrm << "Filename:         " << mFilenameStr << "\n";
    aStrm << "Parameters:       ";
    DwParameter *param = mFirstParameter;
    if(param)
    {
        int count = 0;
        while(param)
        {
            if(count) aStrm << ' ';
            aStrm << param->ObjectId();
            param = param->Next();
            ++count;
        }
        aStrm << '\n';
    }
    else
    {
        aStrm << "(none)\n";
    }
}
예제 #2
0
void DwDispositionType::CopyParameterList(DwParameter *aFirst)
{
    DwParameter *param = aFirst;
    while(param)
    {
        DwParameter *newParam = (DwParameter *) param->Clone();
        AddParameter(newParam);
        param = param->Next();
    }
}
예제 #3
0
void DwDispositionType::DeleteParameterList()
{
    DwParameter *param = mFirstParameter;
    while(param)
    {
        DwParameter *nextParam = param->Next();
        delete param;
        param = nextParam;
    }
    mFirstParameter = 0;
    SetModified();
}
예제 #4
0
void DwDispositionType::CheckInvariants() const
{
#if defined(DW_DEBUG_VERSION)
    mDispositionTypeStr.CheckInvariants();
    mFilenameStr.CheckInvariants();
    DwParameter *param = mFirstParameter;
    while(param)
    {
        param->CheckInvariants();
        assert((DwMessageComponent *) this == param->Parent());
        param = param->Next();
    }
#endif // defined(DW_DEBUG_VERSION)
}
예제 #5
0
QString partNode::contentTypeParameter( const char * name ) const {
  if ( !mDwPart || !mDwPart->hasHeaders() )
    return QString::null;
  DwHeaders & headers = mDwPart->Headers();
  if ( !headers.HasContentType() )
    return QString::null;
  DwString attr = name;
  attr.ConvertToLowerCase();
  for ( DwParameter * param = headers.ContentType().FirstParameter() ; param ; param = param->Next() ) {
    DwString this_attr = param->Attribute();
    this_attr.ConvertToLowerCase(); // what a braindead design!
    if ( this_attr == attr )
      return QString::fromLatin1( param->Value().data(), param->Value().size() );
    // warning: misses rfc2231 handling!
  }
  return QString::null;
}
예제 #6
0
void DwDispositionType::PrintDebugInfo(std::ostream &aStrm, int aDepth) const
{
    aStrm <<
          "------------ Debug info for DwDispositionType class ------------\n";
    _PrintDebugInfo(aStrm);
    int depth = aDepth - 1;
    depth = (depth >= 0) ? depth : 0;
    if(aDepth == 0 || depth > 0)
    {
        DwParameter *param = mFirstParameter;
        while(param)
        {
            param->PrintDebugInfo(aStrm, depth);
            param = param->Next();
        }
    }
}
예제 #7
0
const DwString &DwDispositionType::Filename() const
{
    DwParameter *param = mFirstParameter;
    while(param)
    {
        if(DwStrcasecmp(param->Attribute(), "filename") == 0)
        {
            // Filename parameter found. Return its value.
            // Implementation note: this member function is const, which
            // forbids us from assigning to mFilenameStr.  The following
            // trick gets around this.  (ANSI implementations could use the
            // "mutable" declaration).
            DwDispositionType *_this = (DwDispositionType *) this;
            _this->mFilenameStr = param->Value();
            break;
        }
        param = param->Next();
    }
    return mFilenameStr;
}
예제 #8
0
static bool messageIsDispositionNotificationReport(KMMessage *msg)
{
    if(msg->type() == DwMime::kTypeMessage &&
            msg->subtype() == DwMime::kSubtypeDispositionNotification)
        return true;

    if(msg->type() != DwMime::kTypeMultipart ||
            msg->subtype() != DwMime::kSubtypeReport)
        return false;

    DwMediaType &ct = msg->dwContentType();
    DwParameter *param = ct.FirstParameter();
    while(param)
    {
        if(!qstricmp(param->Attribute().c_str(), "report-type")
                && !qstricmp(param->Value().c_str(), "disposition-notification"))
            return true;
        else
            param = param->Next();
    }
    return false;
}
예제 #9
0
void DwDispositionType::_AddParameter(DwParameter *aParam)
{
    if(!mFirstParameter)
    {
        mFirstParameter = aParam;
    }
    else
    {
        DwParameter *cur = mFirstParameter;
        if(cur)
        {
            DwParameter *next = cur->Next();
            while(next)
            {
                cur = next;
                next = cur->Next();
            }
            cur->SetNext(aParam);
        }
    }
    aParam->SetParent(this);
}
예제 #10
0
void DwDispositionType::Assemble()
{
    if(!mIsModified) return;
    mString = "";
    if(mDispositionTypeStr.length() == 0)
        return;
    mString += mDispositionTypeStr;
    DwParameter *param = FirstParameter();
    while(param)
    {
        param->Assemble();
        if(IsFolding())
        {
            mString += ";" DW_EOL "  ";
        }
        else
        {
            mString += "; ";
        }
        mString += param->AsString();
        param = param->Next();
    }
    mIsModified = 0;
}
예제 #11
0
void DwDispositionType::SetFilename(const DwString &aStr)
{
    mFilenameStr = aStr;
    // Search for filename parameter in parameter list.  If found, set its
    // value.
    DwParameter *param = mFirstParameter;
    while(param)
    {
        if(DwStrcasecmp(param->Attribute(), "filename") == 0)
        {
            param->SetValue(mFilenameStr);
            return;
        }
        param = param->Next();
    }
    // Boundary parameter not found. Add it.
    param = DwParameter::NewParameter("", 0);
    param->SetAttribute("Filename");
    param->SetValue(aStr);
    AddParameter(param);
}
예제 #12
0
void DwDispositionType::Parse()
{
    mIsModified = 0;
    mDispositionType = DwMime::kDispTypeNull;
    mDispositionTypeStr = "";
    if(mFirstParameter)
    {
        DeleteParameterList();
    }
    if(mString.length() == 0) return;
    DwRfc1521Tokenizer tokenizer(mString);
    int found = 0;
    while(!found && tokenizer.Type() != eTkNull)
    {
        if(tokenizer.Type() == eTkToken)
        {
            mDispositionTypeStr = tokenizer.Token();
            found = 1;
        }
        ++tokenizer;
    }
    // Get parameters
    DwTokenString tokenStr(mString);
    while(1)
    {
        // Get ';'
        found = 0;
        while(!found && tokenizer.Type() != eTkNull)
        {
            if(tokenizer.Type() == eTkTspecial
                    && tokenizer.Token()[0] == ';')
            {
                found = 1;
            }
            ++tokenizer;
        }
        if(tokenizer.Type() == eTkNull)
        {
            // No more parameters
            break;
        }
        tokenStr.SetFirst(tokenizer);
        // Get attribute
        DwString attrib;
        int attribFound = 0;
        while(!attribFound && tokenizer.Type() != eTkNull)
        {
            if(tokenizer.Type() == eTkToken)
            {
                attrib = tokenizer.Token();
                attribFound = 1;
            }
            ++tokenizer;
        }
        // Get '='
        found = 0;
        while(!found && tokenizer.Type() != eTkNull)
        {
            if(tokenizer.Type() == eTkTspecial
                    && tokenizer.Token()[0] == '=')
            {
                found = 1;
            }
            ++tokenizer;
        }
        // Get value
        int valueFound = 0;
        while(!valueFound && tokenizer.Type() != eTkNull)
        {
            if(tokenizer.Type() == eTkToken
                    || tokenizer.Type() == eTkQuotedString)
            {
                valueFound = 1;
            }
            ++tokenizer;
        }
        if(attribFound && valueFound)
        {
            tokenStr.ExtendTo(tokenizer);
            DwParameter *param =
                DwParameter::NewParameter(tokenStr.Tokens(), this);
            param->Parse();
            _AddParameter(param);
        }
    }
    StrToEnum();
}