kmail

mailserviceimpl.cpp
1 /*
2  *
3  * This file is part of KMail, the KDE mail client.
4  * Copyright (c) 2003 Zack Rusin <zack@kde.org>
5  *
6  * KMail is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License, version 2, as
8  * published by the Free Software Foundation.
9  *
10  * KMail is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * In addition, as a special exception, the copyright holders give
20  * permission to link the code of this program with any edition of
21  * the TQt library by Trolltech AS, Norway (or with modified versions
22  * of TQt that use the same license as TQt), and distribute linked
23  * combinations including the two. You must obey the GNU General
24  * Public License in all respects for all of the code used other than
25  * TQt. If you modify this file, you may extend this exception to
26  * your version of the file, but you are not obligated to do so. If
27  * you do not wish to do so, delete this exception statement from
28  * your version.
29  */
30 
31 #ifdef HAVE_CONFIG_H
32 #include <config.h>
33 #endif
34 
35 #include "mailserviceimpl.h"
36 
37 #include "composer.h"
38 
39 #include "kmmessage.h"
40 #include "kmmsgpart.h"
41 
42 #include <dcopobject.h>
43 #include <kurl.h>
44 #include <kdebug.h>
45 #include <tqstring.h>
46 
47 namespace KMail {
48 
49 
50 MailServiceImpl::MailServiceImpl()
51  : DCOPObject( "MailTransportServiceIface" )
52 {
53 }
54 
55 bool MailServiceImpl::sendMessage( const TQString& from, const TQString& to,
56  const TQString& cc, const TQString& bcc,
57  const TQString& subject, const TQString& body,
58  const KURL::List& attachments )
59 {
60  if ( to.isEmpty() && cc.isEmpty() && bcc.isEmpty() )
61  return false;
62 
63  KMMessage *msg = new KMMessage;
64  msg->initHeader();
65 
66  msg->setCharset( "utf-8" );
67 
68  if ( !from.isEmpty() ) msg->setFrom( from );
69  if ( !to.isEmpty() ) msg->setTo( to );
70  if ( !cc.isEmpty() ) msg->setCc( cc );
71  if ( !bcc.isEmpty() ) msg->setBcc( bcc );
72  if ( !subject.isEmpty() ) msg->setSubject( subject );
73  if ( !body.isEmpty() ) msg->setBody( body.utf8() );
74 
75  KMail::Composer * cWin = KMail::makeComposer( msg );
76  cWin->setCharset("", TRUE);
77 
78  cWin->addAttachmentsAndSend(attachments, "", 1);//send now
79  return true;
80 }
81 
82 bool MailServiceImpl::sendMessage( const TQString& to,
83  const TQString& cc, const TQString& bcc,
84  const TQString& subject, const TQString& body,
85  const KURL::List& attachments )
86 {
87  kdDebug(5006) << "DCOP call MailTransportServiceIface bool sendMessage(TQString to,TQString cc,TQString bcc,TQString subject,TQString body,KURL::List attachments)" << endl;
88  kdDebug(5006) << "This DCOP call is deprecated. Use the corresponding DCOP call with the additional parameter TQString from instead." << endl;
89  return sendMessage( TQString(), to, cc, bcc, subject, body, attachments );
90 }
91 
92 
93 bool MailServiceImpl::sendMessage( const TQString& from, const TQString& to,
94  const TQString& cc, const TQString& bcc,
95  const TQString& subject, const TQString& body,
96  const TQByteArray& attachment )
97 {
98  if ( to.isEmpty() && cc.isEmpty() && bcc.isEmpty() )
99  return false;
100 
101  KMMessage *msg = new KMMessage;
102  msg->initHeader();
103 
104  msg->setCharset( "utf-8" );
105 
106  if ( !from.isEmpty() ) msg->setFrom( from );
107  if ( !to.isEmpty() ) msg->setTo( to );
108  if ( !cc.isEmpty() ) msg->setCc( cc );
109  if ( !bcc.isEmpty() ) msg->setBcc( bcc );
110  if ( !subject.isEmpty() ) msg->setSubject( subject );
111  if ( !body.isEmpty() ) msg->setBody( body.utf8() );
112 
113  KMMessagePart *part = new KMMessagePart;
114  part->setCteStr( "base64" );
115  part->setBodyEncodedBinary( attachment );
116  msg->addBodyPart( part );
117 
118  KMail::Composer * cWin = KMail::makeComposer( msg );
119  cWin->setCharset("", TRUE);
120  return true;
121 }
122 
123 
124 bool MailServiceImpl::sendMessage( const TQString& to,
125  const TQString& cc, const TQString& bcc,
126  const TQString& subject, const TQString& body,
127  const TQByteArray& attachment )
128 {
129  kdDebug(5006) << "DCOP call MailTransportServiceIface bool sendMessage(TQString to,TQString cc,TQString bcc,TQString subject,TQString body,TQByteArray attachment)" << endl;
130  kdDebug(5006) << "This DCOP call is deprecated. Use the corresponding DCOP call with the additional parameter TQString from instead." << endl;
131  return sendMessage( TQString(), to, cc, bcc, subject, body, attachment );
132 }
133 
134 }//end namespace KMail
135 
This is a Mime Message.
Definition: kmmessage.h:68
void setBody(const TQCString &aStr)
Set the message body.
Definition: kmmessage.cpp:2774
void setCharset(const TQCString &charset, DwEntity *entity=0)
Sets the charset of the message or a subpart of the message.
Definition: kmmessage.cpp:4114
void addBodyPart(const KMMessagePart *aPart)
Append a body part to the message.
Definition: kmmessage.cpp:3356
void initHeader(uint identity=0)
Initialize header fields.
Definition: kmmessage.cpp:1715
folderdiaquotatab.h
Definition: aboutdata.cpp:40