コード例 #1
0
ファイル: lhmail.cpp プロジェクト: Jmos/ftofsharing
LHMailBase* LHMail::attachMail(LHMail* mail)
{
	LHMailPart* mp = new LHMailPart(this);
	
	if (mp->setMail(mail))
	{
		if (attachPart(mp))
		{
			return mp;
		}
	}
	
	//not here if success
	delete mp;
	return 0;
}
コード例 #2
0
ファイル: lhmail.cpp プロジェクト: Jmos/ftofsharing
LHMailBase* LHMail::attachFile(const QString& fname, int flags)
{
	setSendDataValid( FALSE );

	LHMailPart* mp = new LHMailPart(this);
	
	if (mp->setFile(fname, flags)>0)
	{
		if (attachPart(mp))
		{
			return mp;
		}
	}
	
	//not here if success
	delete mp;
	return 0;
}
コード例 #3
0
ファイル: partcontainer.cpp プロジェクト: ruisleipa/kp2
void PartContainer::add(Part* part)
{
	for(Part* attachTo : *this)
	{
		int alreadyAttached = 0;

		for(Part* attachedPart : getAttachedParts(attachTo))
		{
			if(typeid(*attachedPart) == typeid(*part))
				alreadyAttached++;
		}

		if(attachTo->getAttachmentLimitOfType(part) > alreadyAttached)
		{
			attachPart(attachTo, part);
			Container::add(part);
			return;
		}
	}

	throw ExtraPartException();
}
コード例 #4
0
ファイル: lhmail.cpp プロジェクト: Jmos/ftofsharing
LHMailBase* LHMail::attachSignature (LHMailSignature &signature)
{
        qDebug ("*** %s,%d : %s", __FILE__, __LINE__, "12346789");

	LHMailPart* mp = new LHMailPart (this);

        if (getPartCount () > 1) {
                QString partsText = getSendData (DataToSign);
                QString newBoundary = LHMime::getBoundaryString ();
                QString oldBoundary = header ().getParameter ("Content-Type", "boundary");
                partsText.replace (oldBoundary, newBoundary);

#               if 1
                qDebug ("*** %s,%d : %s", __FILE__, __LINE__, "***********************************************");
                qDebug()<<partsText;
                qDebug ("*** %s,%d : %s", __FILE__, __LINE__, "***********************************************");
#               endif

                removePart (NULL);
		LHMailPart* mpb = new LHMailPart (this);
		addPart(mpb);

		mpb->header ().setData ("Content-Type", "Multipart/Mixed");
		mpb->header ().setParameter ("Content-Type", "boundary", newBoundary);
                mpb->setBodySendData (partsText);
		mpb->setEncoding (encoding());
                
        }

        /**
         *  Aply this LHMail object to the signature object. The body of mail
         *  is essntial when signing.
         */
         
	if (attachPart (mp))
	{

                // if (getPartCount () == 2 && body.isEmpty ())
                if (getPartCount () != 2) {
                        // qFatal ("*** %s,%d : %s", __FILE__, __LINE__, "!2");
                        return NULL;
                }

                QString body = getPart (0)->getSendData ();
        
                signature.setBody (body);
                signature.load ();

#               if 1
                qDebug ("*** %s,%d : %s", __FILE__, __LINE__, "***********************************************");
                qDebug()<<body;
                qDebug ("*** %s,%d : %s", __FILE__, __LINE__, "***********************************************");
#               endif

		header ().setData ("Content-Type", "multipart/signed");
                header ().setParameter ("Content-Type", "micalg", "sha1");
                header ().setParameter ("Content-Type", "protocol", "application/x-pkcs7-signature");
                
	        mp->setSignature (signature.getData ());
                
		return mp;
	}
	
	//not here if success
	delete mp;
	return 0;
}