You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
338 lines
7.7 KiB
338 lines
7.7 KiB
15 years ago
|
/***************************************************************************
|
||
|
mimeheader.h - description
|
||
|
-------------------
|
||
|
begin : Fri Oct 20 2000
|
||
|
copyright : (C) 2000 by Sven Carstens
|
||
|
email : s.carstens@gmx.de
|
||
|
***************************************************************************/
|
||
|
|
||
|
/***************************************************************************
|
||
|
* *
|
||
|
* This program is free software; you can redistribute it and/or modify *
|
||
|
* it under the terms of the GNU General Public License as published by *
|
||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||
|
* (at your option) any later version. *
|
||
|
* *
|
||
|
***************************************************************************/
|
||
|
|
||
|
#ifndef MIMEHEADER_H
|
||
|
#define MIMEHEADER_H
|
||
|
|
||
14 years ago
|
#include <tqptrlist.h>
|
||
|
#include <tqdict.h>
|
||
15 years ago
|
|
||
|
#include "mimehdrline.h"
|
||
|
#include "mimeio.h"
|
||
|
#include "rfcdecoder.h"
|
||
|
|
||
|
/**
|
||
|
*@author Sven Carstens
|
||
|
*/
|
||
|
|
||
|
class mimeHeader
|
||
|
{
|
||
|
public:
|
||
|
mimeHeader ();
|
||
|
virtual ~ mimeHeader ();
|
||
|
|
||
|
virtual void addHdrLine (mimeHdrLine *);
|
||
|
virtual void outputHeader (mimeIO &);
|
||
|
virtual void outputPart (mimeIO &);
|
||
|
|
||
|
|
||
14 years ago
|
TQCString outputParameter (TQDict < TQString > *);
|
||
15 years ago
|
|
||
14 years ago
|
int parsePart (mimeIO &, const TQString&);
|
||
|
int parseBody (mimeIO &, TQCString &, const TQString&, bool mbox = false);
|
||
15 years ago
|
|
||
|
// parse a header. returns true if it had a leading 'From ' line
|
||
|
bool parseHeader (mimeIO &);
|
||
|
|
||
14 years ago
|
TQString getDispositionParm (const TQCString&);
|
||
|
void setDispositionParm (const TQCString&, const TQString&);
|
||
|
TQDictIterator < TQString > getDispositionIterator ();
|
||
15 years ago
|
|
||
14 years ago
|
TQString getTypeParm (const TQCString&);
|
||
|
void setTypeParm (const TQCString&, const TQString&);
|
||
|
TQDictIterator < TQString > getTypeIterator ();
|
||
15 years ago
|
|
||
14 years ago
|
// recursively serialize all important contents to the TQDataStream
|
||
14 years ago
|
void serialize(TQDataStream& stream);
|
||
15 years ago
|
|
||
14 years ago
|
const TQCString& getType ()
|
||
15 years ago
|
{
|
||
|
return contentType;
|
||
|
}
|
||
14 years ago
|
void setType (const TQCString & _str)
|
||
15 years ago
|
{
|
||
|
contentType = _str;
|
||
|
}
|
||
|
|
||
14 years ago
|
const TQCString& getDescription ()
|
||
15 years ago
|
{
|
||
|
return _contentDescription;
|
||
|
}
|
||
14 years ago
|
void setDescription (const TQCString & _str)
|
||
15 years ago
|
{
|
||
|
_contentDescription = _str;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQCString getDisposition ()
|
||
15 years ago
|
{
|
||
|
return _contentDisposition;
|
||
|
}
|
||
14 years ago
|
void setDisposition (const TQCString & _str)
|
||
15 years ago
|
{
|
||
|
_contentDisposition = _str;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQCString getEncoding ()
|
||
15 years ago
|
{
|
||
|
return contentEncoding;
|
||
|
}
|
||
14 years ago
|
void setEncoding (const TQCString & _str)
|
||
15 years ago
|
{
|
||
|
contentEncoding = _str;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQCString getMD5 ()
|
||
15 years ago
|
{
|
||
|
return contentMD5;
|
||
|
}
|
||
14 years ago
|
void setMD5 (const TQCString & _str)
|
||
15 years ago
|
{
|
||
|
contentMD5 = _str;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQCString getID ()
|
||
15 years ago
|
{
|
||
|
return contentID;
|
||
|
}
|
||
14 years ago
|
void setID (const TQCString & _str)
|
||
15 years ago
|
{
|
||
|
contentID = _str;
|
||
|
}
|
||
|
|
||
|
unsigned long getLength ()
|
||
|
{
|
||
|
return contentLength;
|
||
|
}
|
||
|
void setLength (unsigned long _len)
|
||
|
{
|
||
|
contentLength = _len;
|
||
|
}
|
||
|
|
||
14 years ago
|
const TQString & getPartSpecifier ()
|
||
15 years ago
|
{
|
||
|
return partSpecifier;
|
||
|
}
|
||
14 years ago
|
void setPartSpecifier (const TQString & _str)
|
||
15 years ago
|
{
|
||
|
partSpecifier = _str;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQPtrListIterator < mimeHdrLine > getOriginalIterator ();
|
||
|
TQPtrListIterator < mimeHdrLine > getAdditionalIterator ();
|
||
|
void setContent (const TQCString &aContent)
|
||
15 years ago
|
{
|
||
|
mimeContent = aContent;
|
||
|
}
|
||
14 years ago
|
TQCString getContent ()
|
||
15 years ago
|
{
|
||
|
return mimeContent;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQCString getBody ()
|
||
15 years ago
|
{
|
||
|
return preMultipartBody + postMultipartBody;
|
||
|
}
|
||
14 years ago
|
TQCString getPreBody ()
|
||
15 years ago
|
{
|
||
|
return preMultipartBody;
|
||
|
}
|
||
14 years ago
|
void setPreBody (TQCString & inBody)
|
||
15 years ago
|
{
|
||
|
preMultipartBody = inBody;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQCString getPostBody ()
|
||
15 years ago
|
{
|
||
|
return postMultipartBody;
|
||
|
}
|
||
14 years ago
|
void setPostBody (TQCString & inBody)
|
||
15 years ago
|
{
|
||
|
postMultipartBody = inBody;
|
||
|
contentLength = inBody.length ();
|
||
|
}
|
||
|
|
||
|
mimeHeader *getNestedMessage ()
|
||
|
{
|
||
|
return nestedMessage;
|
||
|
}
|
||
|
void setNestedMessage (mimeHeader * inPart, bool destroy = true)
|
||
|
{
|
||
|
if (nestedMessage && destroy)
|
||
|
delete nestedMessage;
|
||
|
nestedMessage = inPart;
|
||
|
}
|
||
|
|
||
|
// mimeHeader *getNestedPart() { return nestedPart; };
|
||
|
void addNestedPart (mimeHeader * inPart)
|
||
|
{
|
||
|
nestedParts.append (inPart);
|
||
|
}
|
||
14 years ago
|
TQPtrListIterator < mimeHeader > getNestedIterator ()
|
||
15 years ago
|
{
|
||
14 years ago
|
return TQPtrListIterator < mimeHeader > (nestedParts);
|
||
15 years ago
|
}
|
||
|
|
||
|
// clears all parts and deletes them from memory
|
||
|
void clearNestedParts ()
|
||
|
{
|
||
|
nestedParts.clear ();
|
||
|
}
|
||
|
|
||
|
// clear all parameters to content-type
|
||
|
void clearTypeParameters ()
|
||
|
{
|
||
|
typeList.clear ();
|
||
|
}
|
||
|
|
||
|
// clear all parameters to content-disposition
|
||
|
void clearDispositionParameters ()
|
||
|
{
|
||
|
dispositionList.clear ();
|
||
|
}
|
||
|
|
||
|
// return the specified body part or NULL
|
||
14 years ago
|
mimeHeader *bodyPart (const TQString &);
|
||
15 years ago
|
|
||
|
#ifdef KMAIL_COMPATIBLE
|
||
|
ulong msgSize ()
|
||
|
{
|
||
|
return contentLength;
|
||
|
}
|
||
|
uint numBodyParts ()
|
||
|
{
|
||
|
return nestedParts.count ();
|
||
|
}
|
||
|
mimeHeader *bodyPart (int which, mimeHeader ** ret = NULL)
|
||
|
{
|
||
|
if (ret)
|
||
|
(*ret) = nestedParts.at (which);
|
||
|
return nestedParts.at (which);
|
||
|
}
|
||
14 years ago
|
void write (const TQString &)
|
||
15 years ago
|
{
|
||
|
}
|
||
14 years ago
|
TQString typeStr ()
|
||
15 years ago
|
{
|
||
13 years ago
|
return TQString (contentType.left (contentType.find ('/')));
|
||
15 years ago
|
}
|
||
14 years ago
|
void setTypeStr (const TQString & _str)
|
||
15 years ago
|
{
|
||
14 years ago
|
contentType = TQCString (_str.latin1 ()) + "/" + subtypeStr ().latin1 ();
|
||
15 years ago
|
}
|
||
14 years ago
|
TQString subtypeStr ()
|
||
15 years ago
|
{
|
||
14 years ago
|
return TQString (contentType.
|
||
13 years ago
|
right (contentType.length () - contentType.find ('/') -
|
||
15 years ago
|
1));
|
||
|
}
|
||
14 years ago
|
void setSubtypeStr (const TQString & _str)
|
||
15 years ago
|
{
|
||
14 years ago
|
contentType = TQCString (typeStr ().latin1 ()) + "/" + _str.latin1 ();
|
||
15 years ago
|
}
|
||
14 years ago
|
TQString cteStr ()
|
||
15 years ago
|
{
|
||
14 years ago
|
return TQString (getEncoding ());
|
||
15 years ago
|
}
|
||
14 years ago
|
void setCteStr (const TQString & _str)
|
||
15 years ago
|
{
|
||
|
setEncoding (_str.latin1 ());
|
||
|
}
|
||
14 years ago
|
TQString contentDisposition ()
|
||
15 years ago
|
{
|
||
14 years ago
|
return TQString (_contentDisposition);
|
||
15 years ago
|
}
|
||
14 years ago
|
TQString body ()
|
||
15 years ago
|
{
|
||
14 years ago
|
return TQString (postMultipartBody);
|
||
15 years ago
|
}
|
||
14 years ago
|
TQString charset ()
|
||
15 years ago
|
{
|
||
|
return getTypeParm ("charset");
|
||
|
}
|
||
14 years ago
|
TQString bodyDecoded ();
|
||
|
void setBodyEncoded (const TQByteArray &);
|
||
|
void setBodyEncodedBinary (const TQByteArray &);
|
||
|
TQByteArray bodyDecodedBinary ();
|
||
|
TQString name ()
|
||
15 years ago
|
{
|
||
14 years ago
|
return TQString (getTypeParm ("name"));
|
||
15 years ago
|
}
|
||
14 years ago
|
void setName (const TQString & _str)
|
||
15 years ago
|
{
|
||
|
setTypeParm ("name", _str);
|
||
|
}
|
||
14 years ago
|
TQString fileName ()
|
||
15 years ago
|
{
|
||
14 years ago
|
return TQString (getDispositionParm ("filename"));
|
||
15 years ago
|
}
|
||
14 years ago
|
TQString contentDescription ()
|
||
15 years ago
|
{
|
||
14 years ago
|
return TQString (rfcDecoder::decodeRFC2047String (_contentDescription));
|
||
15 years ago
|
}
|
||
14 years ago
|
void setContentDescription (const TQString & _str)
|
||
15 years ago
|
{
|
||
|
_contentDescription = rfcDecoder::encodeRFC2047String (_str).latin1 ();
|
||
|
}
|
||
14 years ago
|
TQString msgIdMD5 ()
|
||
15 years ago
|
{
|
||
14 years ago
|
return TQString (contentMD5);
|
||
15 years ago
|
}
|
||
14 years ago
|
TQString iconName ();
|
||
|
TQString magicSetType (bool aAutoDecode = true);
|
||
|
TQString headerAsString ();
|
||
15 years ago
|
ulong size ()
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
14 years ago
|
void fromString (const TQByteArray &)
|
||
15 years ago
|
{;
|
||
|
}
|
||
14 years ago
|
void setContentDisposition (const TQString & _str)
|
||
15 years ago
|
{
|
||
|
setDisposition (_str.latin1 ());
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
protected:
|
||
14 years ago
|
static void addParameter (const TQCString&, TQDict < TQString > *);
|
||
|
static TQString getParameter (const TQCString&, TQDict < TQString > *);
|
||
|
static void setParameter (const TQCString&, const TQString&, TQDict < TQString > *);
|
||
15 years ago
|
|
||
14 years ago
|
TQPtrList < mimeHdrLine > originalHdrLines;
|
||
15 years ago
|
|
||
|
private:
|
||
14 years ago
|
TQPtrList < mimeHdrLine > additionalHdrLines;
|
||
|
TQDict < TQString > typeList;
|
||
|
TQDict < TQString > dispositionList;
|
||
|
TQCString contentType;
|
||
|
TQCString _contentDisposition;
|
||
|
TQCString contentEncoding;
|
||
|
TQCString _contentDescription;
|
||
|
TQCString contentID;
|
||
|
TQCString contentMD5;
|
||
15 years ago
|
unsigned long contentLength;
|
||
14 years ago
|
TQCString mimeContent;
|
||
|
TQCString preMultipartBody;
|
||
|
TQCString postMultipartBody;
|
||
15 years ago
|
mimeHeader *nestedMessage;
|
||
14 years ago
|
TQPtrList < mimeHeader > nestedParts;
|
||
|
TQString partSpecifier;
|
||
15 years ago
|
|
||
|
};
|
||
|
|
||
|
#endif
|