00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifdef HAVE_CONFIG_H
00032 #include <config.h>
00033 #endif
00034
00035 #include "mailserviceimpl.h"
00036
00037 #include "composer.h"
00038
00039 #include "kmmessage.h"
00040 #include "kmmsgpart.h"
00041
00042 #include <dcopobject.h>
00043 #include <kurl.h>
00044 #include <kdebug.h>
00045 #include <qstring.h>
00046
00047 namespace KMail {
00048
00049
00050 MailServiceImpl::MailServiceImpl()
00051 : DCOPObject( "MailTransportServiceIface" )
00052 {
00053 }
00054
00055 bool MailServiceImpl::sendMessage( const QString& from, const QString& to,
00056 const QString& cc, const QString& bcc,
00057 const QString& subject, const QString& body,
00058 const KURL::List& attachments )
00059 {
00060 if ( to.isEmpty() && cc.isEmpty() && bcc.isEmpty() )
00061 return false;
00062
00063 KMMessage *msg = new KMMessage;
00064 msg->initHeader();
00065
00066 msg->setCharset( "utf-8" );
00067
00068 if ( !from.isEmpty() ) msg->setFrom( from );
00069 if ( !to.isEmpty() ) msg->setTo( to );
00070 if ( !cc.isEmpty() ) msg->setCc( cc );
00071 if ( !bcc.isEmpty() ) msg->setBcc( bcc );
00072 if ( !subject.isEmpty() ) msg->setSubject( subject );
00073 if ( !body.isEmpty() ) msg->setBody( body.utf8() );
00074
00075 KMail::Composer * cWin = KMail::makeComposer( msg );
00076 cWin->setCharset("", TRUE);
00077
00078 for( KURL::List::ConstIterator itr = attachments.begin();
00079 itr != attachments.end(); ++itr ) {
00080 cWin->addAttachment( *itr, "" );
00081 }
00082
00083 cWin->send( 1 );
00084 return true;
00085 }
00086
00087 bool MailServiceImpl::sendMessage( const QString& to,
00088 const QString& cc, const QString& bcc,
00089 const QString& subject, const QString& body,
00090 const KURL::List& attachments )
00091 {
00092 kdDebug(5006) << "DCOP call MailTransportServiceIface bool sendMessage(QString to,QString cc,QString bcc,QString subject,QString body,KURL::List attachments)" << endl;
00093 kdDebug(5006) << "This DCOP call is deprecated. Use the corresponding DCOP call with the additional parameter QString from instead." << endl;
00094 return sendMessage( QString::null, to, cc, bcc, subject, body, attachments );
00095 }
00096
00097
00098 bool MailServiceImpl::sendMessage( const QString& from, const QString& to,
00099 const QString& cc, const QString& bcc,
00100 const QString& subject, const QString& body,
00101 const QByteArray& attachment )
00102 {
00103 if ( to.isEmpty() && cc.isEmpty() && bcc.isEmpty() )
00104 return false;
00105
00106 KMMessage *msg = new KMMessage;
00107 msg->initHeader();
00108
00109 msg->setCharset( "utf-8" );
00110
00111 if ( !from.isEmpty() ) msg->setFrom( from );
00112 if ( !to.isEmpty() ) msg->setTo( to );
00113 if ( !cc.isEmpty() ) msg->setCc( cc );
00114 if ( !bcc.isEmpty() ) msg->setBcc( bcc );
00115 if ( !subject.isEmpty() ) msg->setSubject( subject );
00116 if ( !body.isEmpty() ) msg->setBody( body.utf8() );
00117
00118 KMMessagePart *part = new KMMessagePart;
00119 part->setCteStr( "base64" );
00120 part->setBodyEncodedBinary( attachment );
00121 msg->addBodyPart( part );
00122
00123 KMail::Composer * cWin = KMail::makeComposer( msg );
00124 cWin->setCharset("", TRUE);
00125 return true;
00126 }
00127
00128
00129 bool MailServiceImpl::sendMessage( const QString& to,
00130 const QString& cc, const QString& bcc,
00131 const QString& subject, const QString& body,
00132 const QByteArray& attachment )
00133 {
00134 kdDebug(5006) << "DCOP call MailTransportServiceIface bool sendMessage(QString to,QString cc,QString bcc,QString subject,QString body,QByteArray attachment)" << endl;
00135 kdDebug(5006) << "This DCOP call is deprecated. Use the corresponding DCOP call with the additional parameter QString from instead." << endl;
00136 return sendMessage( QString::null, to, cc, bcc, subject, body, attachment );
00137 }
00138
00139 }
00140