• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.14
  • kdepim
  • messageviewer
  • utils
util.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 **
3 ** Filename : util
4 ** Created on : 03 April, 2005
5 ** Copyright : (c) 2005 Till Adam
6 ** Email : <adam@kde.org>
7 **
8 *******************************************************************************/
9 
10 /*******************************************************************************
11 **
12 ** This program is free software; you can redistribute it and/or modify
13 ** it under the terms of the GNU General Public License as published by
14 ** the Free Software Foundation; either version 2 of the License, or
15 ** (at your option) any later version.
16 **
17 ** It is distributed in the hope that it will be useful, but
18 ** WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ** General Public License for more details.
21 **
22 ** You should have received a copy of the GNU General Public License
23 ** along with this program; if not, write to the Free Software
24 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 **
26 ** In addition, as a special exception, the copyright holders give
27 ** permission to link the code of this program with any edition of
28 ** the Qt library by Trolltech AS, Norway (or with modified versions
29 ** of Qt that use the same license as Qt), and distribute linked
30 ** combinations including the two. You must obey the GNU General
31 ** Public License in all respects for all of the code used other than
32 ** Qt. If you modify this file, you may extend this exception to
33 ** your version of the file, but you are not obligated to do so. If
34 ** you do not wish to do so, delete this exception statement from
35 ** your version.
36 **
37 *******************************************************************************/
38 
39 
40 #include "utils/util.h"
41 
42 #include "utils/iconnamecache.h"
43 #include "viewer/nodehelper.h"
44 
45 #include "messagecore/settings/globalsettings.h"
46 #include "messagecore/helpers/nodehelper.h"
47 #include "messagecore/utils/stringutil.h"
48 
49 #include "pimcommon/widgets/renamefiledialog.h"
50 
51 #include <akonadi/item.h>
52 
53 
54 #include <kmbox/mbox.h>
55 
56 #include <KMime/Message>
57 
58 #include <kcharsets.h>
59 #include <KFileDialog>
60 #include <kglobal.h>
61 #include <klocale.h>
62 #include <kmessagebox.h>
63 #include <kio/netaccess.h>
64 #include <kdebug.h>
65 #include <KMimeType>
66 #include <KTemporaryFile>
67 #include <ktoolinvocation.h>
68 #include <KAction>
69 
70 #include <QTextCodec>
71 #include <QWidget>
72 #include <QDBusInterface>
73 #include <QDBusConnectionInterface>
74 #include <QActionGroup>
75 #include <QPointer>
76 
77 using namespace MessageViewer;
78 
79 bool Util::checkOverwrite( const KUrl &url, QWidget *w )
80 {
81  if ( KIO::NetAccess::exists( url, KIO::NetAccess::DestinationSide, w ) ) {
82  if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(
83  w,
84  i18n( "A file named \"%1\" already exists. "
85  "Are you sure you want to overwrite it?", url.prettyUrl() ),
86  i18n( "Overwrite File?" ),
87  KStandardGuiItem::overwrite() ) )
88  return false;
89  }
90  return true;
91 }
92 
93 QString Util::fileNameForMimetype( const QString &mimeType, int iconSize,
94  const QString &fallbackFileName1,
95  const QString &fallbackFileName2 )
96 {
97  QString fileName;
98  QString tMimeType = mimeType;
99 
100  // convert non-registered types to registered types
101  if ( mimeType == QLatin1String( "application/x-vnd.kolab.contact" ) ) {
102  tMimeType = QLatin1String( "text/x-vcard" );
103  } else if ( mimeType == QLatin1String( "application/x-vnd.kolab.event" ) ) {
104  tMimeType = QLatin1String( "application/x-vnd.akonadi.calendar.event" );
105  } else if ( mimeType == QLatin1String( "application/x-vnd.kolab.task" ) ) {
106  tMimeType = QLatin1String( "application/x-vnd.akonadi.calendar.todo" );
107  } else if ( mimeType == QLatin1String( "application/x-vnd.kolab.journal" ) ) {
108  tMimeType = QLatin1String( "application/x-vnd.akonadi.calendar.journal" );
109  } else if ( mimeType == QLatin1String( "application/x-vnd.kolab.note" ) ) {
110  tMimeType = QLatin1String( "application/x-vnd.akonadi.note" );
111  }
112  KMimeType::Ptr mime = KMimeType::mimeType( tMimeType, KMimeType::ResolveAliases );
113  if ( mime ) {
114  fileName = mime->iconName();
115  } else {
116  fileName = QLatin1String( "unknown" );
117  if ( !tMimeType.isEmpty() ) {
118  kWarning() << "unknown mimetype" << tMimeType;
119  }
120  }
121  //WorkAround for #199083
122  if(fileName == QLatin1String("text-vcard")) {
123  fileName = QLatin1String("text-x-vcard");
124  }
125  if ( fileName.isEmpty() ) {
126  fileName = fallbackFileName1;
127  if ( fileName.isEmpty() ) {
128  fileName = fallbackFileName2;
129  }
130  if ( !fileName.isEmpty() ) {
131  fileName = KMimeType::findByPath( QLatin1String("/tmp/") + fileName, 0, true )->iconName();
132  }
133  }
134 
135  return IconNameCache::instance()->iconPath( fileName, iconSize );
136 }
137 
138 #if defined Q_WS_WIN || defined Q_WS_MACX
139 #include <QDesktopServices>
140 #endif
141 
142 bool Util::handleUrlWithQDesktopServices( const KUrl& url )
143 {
144 #if defined Q_WS_WIN || defined Q_WS_MACX
145  QDesktopServices::openUrl( url );
146  return true;
147 #else
148  Q_UNUSED( url );
149  return false;
150 #endif
151 }
152 
153 QList<KMime::Content*> Util::allContents( const KMime::Content *message )
154 {
155  KMime::Content::List result;
156  KMime::Content *child = MessageCore::NodeHelper::firstChild( message );
157  if ( child ) {
158  result += child;
159  result += allContents( child );
160  }
161  KMime::Content *next = MessageCore::NodeHelper::nextSibling( message );
162  if ( next ) {
163  result += next;
164  result += allContents( next );
165  }
166 
167  return result;
168 }
169 
170 QList<KMime::Content*> Util::extractAttachments( const KMime::Message *message )
171 {
172  const KMime::Content::List contents = allContents( message );
173  KMime::Content::List result;
174  for ( KMime::Content::List::const_iterator it = contents.constBegin();
175  it != contents.constEnd(); ) {
176  KMime::Content* content = *it;
177  if ( content->contentDisposition()->filename().trimmed().isEmpty() &&
178  ( content->contentType()->name().trimmed().isEmpty() ||
179  content == message ) ) {
180  ++it;
181  } else {
182  result <<( *it );
183  ++it;
184  }
185  }
186 
187  return result;
188 }
189 
190 bool Util::saveContents( QWidget *parent, const QList<KMime::Content*> &contents, KUrl &currentFolder )
191 {
192  KUrl url, dirUrl;
193  const bool multiple = (contents.count() > 1);
194  if ( multiple ) {
195  // get the dir
196  dirUrl = KFileDialog::getExistingDirectoryUrl( KUrl( QLatin1String("kfiledialog:///saveAttachment") ),
197  parent,
198  i18n( "Save Attachments To" ) );
199  if ( !dirUrl.isValid() ) {
200  return false;
201  }
202 
203  // we may not get a slash-terminated url out of KFileDialog
204  dirUrl.adjustPath( KUrl::AddTrailingSlash );
205  currentFolder = dirUrl;
206  } else {
207  // only one item, get the desired filename
208  KMime::Content *content = contents.first();
209  QString fileName = NodeHelper::fileName( content );
210  fileName = MessageCore::StringUtil::cleanFileName( fileName );
211  if ( fileName.isEmpty() ) {
212  fileName = i18nc( "filename for an unnamed attachment", "attachment.1" );
213  }
214  KUrl pathUrl = KUrl( QLatin1String("kfiledialog:///saveAttachment/"));
215  pathUrl.addPath(fileName);
216  url = KFileDialog::getSaveUrl( pathUrl ,
217  QString(),
218  parent,
219  i18n( "Save Attachment" ) );
220  if ( url.isEmpty() ) {
221  return false;
222  }
223  currentFolder = KUrl(url.upUrl());
224  }
225  QMap< QString, int > renameNumbering;
226 
227  bool globalResult = true;
228  int unnamedAtmCount = 0;
229  PimCommon::RenameFileDialog::RenameFileDialogResult result = PimCommon::RenameFileDialog::RENAMEFILE_IGNORE;
230  foreach( KMime::Content *content, contents ) {
231  KUrl curUrl;
232  if ( !dirUrl.isEmpty() ) {
233  curUrl = dirUrl;
234  QString fileName = MessageViewer::NodeHelper::fileName( content );
235  fileName = MessageCore::StringUtil::cleanFileName( fileName );
236  if ( fileName.isEmpty() ) {
237  ++unnamedAtmCount;
238  fileName = i18nc( "filename for the %1-th unnamed attachment",
239  "attachment.%1", unnamedAtmCount );
240  }
241  curUrl.setFileName( fileName );
242  } else {
243  curUrl = url;
244  }
245  if ( !curUrl.isEmpty() ) {
246  //Bug #312954
247  if (multiple && (curUrl.fileName() == QLatin1String("smime.p7s")) ) {
248  continue;
249  }
250  // Rename the file if we have already saved one with the same name:
251  // try appending a number before extension (e.g. "pic.jpg" => "pic_2.jpg")
252  QString origFile = curUrl.fileName();
253  QString file = origFile;
254 
255  while ( renameNumbering.contains(file) ) {
256  file = origFile;
257  int num = renameNumbering[file] + 1;
258  int dotIdx = file.lastIndexOf(QLatin1Char('.'));
259  file = file.insert( (dotIdx>=0) ? dotIdx : file.length(), QLatin1String("_") + QString::number(num) );
260  }
261  curUrl.setFileName(file);
262 
263  // Increment the counter for both the old and the new filename
264  if ( !renameNumbering.contains(origFile))
265  renameNumbering[origFile] = 1;
266  else
267  renameNumbering[origFile]++;
268 
269  if ( file != origFile ) {
270  if ( !renameNumbering.contains(file))
271  renameNumbering[file] = 1;
272  else
273  renameNumbering[file]++;
274  }
275 
276 
277  if( !(result == PimCommon::RenameFileDialog::RENAMEFILE_OVERWRITEALL ||
278  result == PimCommon::RenameFileDialog::RENAMEFILE_IGNOREALL )) {
279  if ( KIO::NetAccess::exists( curUrl, KIO::NetAccess::DestinationSide, parent ) ) {
280  PimCommon::RenameFileDialog *dlg = new PimCommon::RenameFileDialog(curUrl, multiple, parent);
281  result = static_cast<PimCommon::RenameFileDialog::RenameFileDialogResult>(dlg->exec());
282  if ( result == PimCommon::RenameFileDialog::RENAMEFILE_IGNORE ||
283  result == PimCommon::RenameFileDialog::RENAMEFILE_IGNOREALL)
284  {
285  delete dlg;
286  continue;
287  }
288  else if ( result == PimCommon::RenameFileDialog::RENAMEFILE_RENAME )
289  {
290  curUrl = dlg->newName();
291  }
292  delete dlg;
293  }
294  }
295  // save
296  if( result != PimCommon::RenameFileDialog::RENAMEFILE_IGNOREALL ) {
297  const bool result = saveContent( parent, content, curUrl );
298  if ( !result )
299  globalResult = result;
300  }
301  }
302  }
303 
304  return globalResult;
305 }
306 
307 bool Util::saveContent( QWidget *parent, KMime::Content* content, const KUrl& url )
308 {
309  // FIXME: This is all horribly broken. First of all, creating a NodeHelper and then immediatley
310  // reading out the encryption/signature state will not work at all.
311  // Then, topLevel() will not work for attachments that are inside encrypted parts.
312  // What should actually be done is either passing in an ObjectTreeParser that has already
313  // parsed the message, or creating an OTP here (which would have the downside that the
314  // password dialog for decrypting messages is shown twice)
315 #if 0 // totally broken
316  KMime::Content *topContent = content->topLevel();
317  MessageViewer::NodeHelper *mNodeHelper = new MessageViewer::NodeHelper;
318  bool bSaveEncrypted = false;
319  bool bEncryptedParts = mNodeHelper->encryptionState( content ) != MessageViewer::KMMsgNotEncrypted;
320  if( bEncryptedParts )
321  if( KMessageBox::questionYesNo( parent,
322  i18n( "The part %1 of the message is encrypted. Do you want to keep the encryption when saving?",
323  url.fileName() ),
324  i18n( "KMail Question" ), KGuiItem(i18n("Keep Encryption")), KGuiItem(i18n("Do Not Keep")) ) ==
325  KMessageBox::Yes )
326  bSaveEncrypted = true;
327 
328  bool bSaveWithSig = true;
329  if(mNodeHelper->signatureState( content ) != MessageViewer::KMMsgNotSigned )
330  if( KMessageBox::questionYesNo( parent,
331  i18n( "The part %1 of the message is signed. Do you want to keep the signature when saving?",
332  url.fileName() ),
333  i18n( "KMail Question" ), KGuiItem(i18n("Keep Signature")), KGuiItem(i18n("Do Not Keep")) ) !=
334  KMessageBox::Yes )
335  bSaveWithSig = false;
336 
337  QByteArray data;
338  if( bSaveEncrypted || !bEncryptedParts) {
339  KMime::Content *dataNode = content;
340  QByteArray rawDecryptedBody;
341  bool gotRawDecryptedBody = false;
342  if ( !bSaveWithSig ) {
343  if ( topContent->contentType()->mimeType() == "multipart/signed" ) {
344  // carefully look for the part that is *not* the signature part:
345  if ( ObjectTreeParser::findType( topContent, "application/pgp-signature", true, false ) ) {
346  dataNode = ObjectTreeParser::findTypeNot( topContent, "application", "pgp-signature", true, false );
347  } else if ( ObjectTreeParser::findType( topContent, "application/pkcs7-mime" , true, false ) ) {
348  dataNode = ObjectTreeParser::findTypeNot( topContent, "application", "pkcs7-mime", true, false );
349  } else {
350  dataNode = ObjectTreeParser::findTypeNot( topContent, "multipart", "", true, false );
351  }
352  } else {
353  EmptySource emptySource;
354  ObjectTreeParser otp( &emptySource, 0, 0, false, false );
355 
356  // process this node and all it's siblings and descendants
357  mNodeHelper->setNodeUnprocessed( dataNode, true );
358  otp.parseObjectTree( dataNode );
359 
360  rawDecryptedBody = otp.rawDecryptedBody();
361  gotRawDecryptedBody = true;
362  }
363  }
364  QByteArray cstr = gotRawDecryptedBody
365  ? rawDecryptedBody
366  : dataNode->decodedContent();
367  data = KMime::CRLFtoLF( cstr );
368  }
369 #else
370  const QByteArray data = content->decodedContent();
371  kWarning() << "Port the encryption/signature handling when saving a KMime::Content.";
372 #endif
373  QDataStream ds;
374  QFile file;
375  KTemporaryFile tf;
376  if ( url.isLocalFile() )
377  {
378  // save directly
379  file.setFileName( url.toLocalFile() );
380  if ( !file.open( QIODevice::WriteOnly ) )
381  {
382  KMessageBox::error( parent,
383  i18nc( "1 = file name, 2 = error string",
384  "<qt>Could not write to the file<br><filename>%1</filename><br><br>%2",
385  file.fileName(),
386  file.errorString() ),
387  i18n( "Error saving attachment" ) );
388  return false;
389  }
390 
391  const int permissions = MessageViewer::Util::getWritePermissions();
392  if ( permissions >= 0 )
393  fchmod( file.handle(), permissions );
394 
395  ds.setDevice( &file );
396  } else
397  {
398  // tmp file for upload
399  tf.open();
400  ds.setDevice( &tf );
401  }
402 
403  const int bytesWritten = ds.writeRawData( data.data(), data.size() );
404  if ( bytesWritten != data.size() ) {
405  QFile *f = static_cast<QFile *>( ds.device() );
406  KMessageBox::error( parent,
407  i18nc( "1 = file name, 2 = error string",
408  "<qt>Could not write to the file<br><filename>%1</filename><br><br>%2",
409  f->fileName(),
410  f->errorString() ),
411  i18n( "Error saving attachment" ) );
412  // Remove the newly created empty or partial file
413  f->remove();
414  return false;
415  }
416 
417  if ( !url.isLocalFile() )
418  {
419  // QTemporaryFile::fileName() is only defined while the file is open
420  QString tfName = tf.fileName();
421  tf.close();
422  if ( !KIO::NetAccess::upload( tfName, url, parent ) )
423  {
424  KMessageBox::error( parent,
425  i18nc( "1 = file name, 2 = error string",
426  "<qt>Could not write to the file<br><filename>%1</filename><br><br>%2",
427  url.prettyUrl(),
428  KIO::NetAccess::lastErrorString() ),
429  i18n( "Error saving attachment" ) );
430  return false;
431  }
432  }
433  else
434  file.close();
435 
436 #if 0
437  mNodeHelper->removeTempFiles();
438  delete mNodeHelper;
439 #endif
440  return true;
441 }
442 
443 
444 int Util::getWritePermissions()
445 {
446  // #79685, #232001 by default use the umask the user defined, but let it be configurable
447  if ( MessageCore::GlobalSettings::self()->disregardUmask() ) {
448  return S_IRUSR | S_IWUSR;
449  } else {
450  return -1;
451  }
452 }
453 
454 bool Util::saveAttachments( const KMime::Content::List& contents, QWidget *parent, KUrl &currentFolder )
455 {
456  if ( contents.isEmpty() ) {
457  KMessageBox::information( parent, i18n( "Found no attachments to save." ) );
458  return false;
459  }
460 
461  return Util::saveContents( parent, contents, currentFolder );
462 }
463 
464 bool Util::saveMessageInMbox( const QList<Akonadi::Item>& retrievedMsgs, QWidget *parent, bool appendMessages )
465 {
466 
467  QString fileName;
468  if ( retrievedMsgs.isEmpty() )
469  return true;
470  const Akonadi::Item msgBase = retrievedMsgs.first();
471 
472  if( msgBase.hasPayload<KMime::Message::Ptr>() )
473  fileName = MessageCore::StringUtil::cleanFileName(MessageViewer::NodeHelper::cleanSubject ( msgBase.payload<KMime::Message::Ptr>().get() ).trimmed() );
474  else
475  fileName = i18n("message");
476 
477  if ( !fileName.endsWith( QLatin1String( ".mbox" ) ) )
478  fileName += QLatin1String(".mbox");
479 
480  const QString filter = i18n( "*.mbox|email messages (*.mbox)\n*|all files (*)" );
481  QPointer<KFileDialog> dlg = new KFileDialog(KUrl::fromPath( fileName ), filter, parent);
482  dlg->setCaption(i18np("Save Message", "Save Messages", retrievedMsgs.count()));
483  dlg->setMode(KFile::File|KFile::LocalOnly);
484  dlg->setOperationMode(KFileDialog::Saving);
485  if( !appendMessages )
486  dlg->setConfirmOverwrite(true);
487  if (dlg->exec()) {
488  KUrl url = dlg->selectedUrl();
489  if ( url.isEmpty() ) {
490  delete dlg;
491  return true;
492  }
493 
494  const QString localFileName = url.toLocalFile();
495  if ( localFileName.isEmpty() ) {
496  delete dlg;
497  return true;
498  }
499 
500  if( !appendMessages ) {
501  QFile::remove(localFileName);
502  }
503 
504  KMBox::MBox mbox;
505  if ( !mbox.load( localFileName ) ) {
506  if( appendMessages ) {
507  KMessageBox::error( parent, i18n("File %1 could not be loaded.",localFileName) , i18n( "Error loading message" ) );
508  } else {
509  KMessageBox::error( parent, i18n("File %1 could not be created.",localFileName) , i18n( "Error saving message" ) );
510  }
511  delete dlg;
512  return false;
513  }
514  foreach ( const Akonadi::Item &item, retrievedMsgs ) {
515  if ( item.hasPayload<KMime::Message::Ptr>() ) {
516  mbox.appendMessage( item.payload<KMime::Message::Ptr>() );
517  }
518  }
519 
520  if ( !mbox.save() ) {
521  KMessageBox::error( parent, i18n("We cannot save message.") , i18n( "Error saving message" ) );
522  delete dlg;
523  return false;
524  }
525  }
526  delete dlg;
527  return true;
528 }
529 
530 
531 bool Util::speakSelectedText( const QString& text, QWidget *parent)
532 {
533  if(text.isEmpty())
534  return false;
535 
536  // If KTTSD not running, start it.
537  if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String("org.kde.kttsd")))
538  {
539  QString error;
540  if (KToolInvocation::startServiceByDesktopName(QLatin1String("kttsd"), QStringList(), &error))
541  {
542  KMessageBox::error(parent, i18n( "Starting Jovie Text-to-Speech Service Failed"), error );
543  return false;
544  }
545  }
546  QDBusInterface ktts(QLatin1String("org.kde.kttsd"), QLatin1String("/KSpeech"), QLatin1String("org.kde.KSpeech"));
547  ktts.asyncCall(QLatin1String("say"), text, 0);
548  return true;
549 }
550 
551 KAction* Util::createAppAction(const KService::Ptr& service, bool singleOffer, QActionGroup *actionGroup, QObject *parent )
552 {
553  QString actionName(service->name().replace(QLatin1Char('&'), QLatin1String("&&")));
554  if (singleOffer) {
555  actionName = i18n("Open &with %1", actionName);
556  } else {
557  actionName = i18nc("@item:inmenu Open With, %1 is application name", "%1", actionName);
558  }
559 
560  KAction *act = new KAction(parent);
561  act->setIcon(KIcon(service->icon()));
562  act->setText(actionName);
563  actionGroup->addAction( act );
564  act->setData(QVariant::fromValue(service));
565  return act;
566 }
567 
568 
569 KMimeType::Ptr Util::mimetype(const QString& name)
570 {
571  // consider the filename if mimetype cannot be found by content-type
572  KMimeType::Ptr mimeType = KMimeType::findByPath( name, 0, true /* no disk access */ );
573  if ( mimeType->name() == QLatin1String("application/octet-stream") ) {
574  // consider the attachment's contents if neither the Content-Type header
575  // nor the filename give us a clue
576  mimeType = KMimeType::findByFileContent( name );
577  }
578  return mimeType;
579 }
QWidget
MessageViewer::Util::fileNameForMimetype
QString MESSAGEVIEWER_EXPORT fileNameForMimetype(const QString &mimeType, int iconSize, const QString &fallbackFileName1=QString(), const QString &fallbackFileName2=QString())
Finds the filename of an icon based on the given mimetype or filenames.
Definition: util.cpp:93
iconnamecache.h
QMap::contains
bool contains(const Key &key) const
QActionGroup
QByteArray
QFile::remove
bool remove()
MessageViewer::Util::speakSelectedText
bool MESSAGEVIEWER_EXPORT speakSelectedText(const QString &text, QWidget *parent)
Definition: util.cpp:531
QIODevice::errorString
QString errorString() const
QDataStream
MessageViewer::Util::saveMessageInMbox
bool MESSAGEVIEWER_EXPORT saveMessageInMbox(const QList< Akonadi::Item > &retrievedMsgs, QWidget *parent, bool appendMessages=false)
Definition: util.cpp:464
QDBusConnection::interface
QDBusConnectionInterface * interface() const
QFile::handle
int handle() const
QMap
QDataStream::setDevice
void setDevice(QIODevice *d)
QFile::fileName
QString fileName() const
QPointer
QFile::setFileName
void setFileName(const QString &name)
MessageViewer::EmptySource
An ObjectTreeSource that does not work on anything.
Definition: objecttreeemptysource.h:31
QActionGroup::addAction
QAction * addAction(QAction *action)
QDBusConnection::sessionBus
QDBusConnection sessionBus()
nodehelper.h
QDBusConnectionInterface::isServiceRegistered
QDBusReply< bool > isServiceRegistered(const QString &serviceName) const
QFile
MessageViewer::Util::saveContents
bool MESSAGEVIEWER_EXPORT saveContents(QWidget *parent, const QList< KMime::Content * > &contents, KUrl &currentFolder)
Definition: util.cpp:190
MessageViewer::ObjectTreeParser::findTypeNot
static KMime::Content * findTypeNot(KMime::Content *content, const QByteArray &mediaType, const QByteArray &subType, bool deep=true, bool wide=true)
Definition: objecttreeparser.cpp:3508
QString::lastIndexOf
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
MessageViewer::KMMsgNotSigned
Definition: nodehelper.h:64
QString::number
QString number(int n, int base)
QList::count
int count(const T &value) const
QString::insert
QString & insert(int position, QChar ch)
MessageViewer::IconNameCache::instance
static IconNameCache * instance()
Definition: iconnamecache.cpp:28
QObject
MessageViewer::KMMsgNotEncrypted
Definition: nodehelper.h:54
QList::isEmpty
bool isEmpty() const
QString::isEmpty
bool isEmpty() const
MessageViewer::ObjectTreeParser::parseObjectTree
void parseObjectTree(KMime::Content *node)
Parse beginning at a given node and recursively parsing the children of that node and it's next sibli...
Definition: objecttreeparser.cpp:268
MessageViewer::Util::createAppAction
MESSAGEVIEWER_EXPORT KAction * createAppAction(const KService::Ptr &service, bool singleOffer, QActionGroup *actionGroup, QObject *parent)
Definition: util.cpp:551
QList::first
T & first()
QString
QList< KMime::Content * >
util.h
QFile::open
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
MessageViewer::ObjectTreeParser::rawDecryptedBody
KDE_DEPRECATED QByteArray rawDecryptedBody() const
The origin and purpose of this function is unknown, the ancient wisdom about it got lost during the c...
Definition: objecttreeparser.h:330
MessageViewer::Util::saveAttachments
bool MESSAGEVIEWER_EXPORT saveAttachments(const KMime::Content::List &contents, QWidget *parent, KUrl &currentFolder)
Definition: util.cpp:454
QStringList
MessageViewer::NodeHelper::encryptionState
KMMsgEncryptionState encryptionState(KMime::Content *node) const
Definition: nodehelper.cpp:193
MessageViewer::IconNameCache::iconPath
QString iconPath(const QString &name, int size) const
Definition: iconnamecache.cpp:42
QDBusInterface
QAction::setData
void setData(const QVariant &userData)
QLatin1Char
QVariant::fromValue
QVariant fromValue(const T &value)
QFile::close
virtual void close()
MessageViewer::Util::mimetype
MESSAGEVIEWER_EXPORT KMimeType::Ptr mimetype(const QString &name)
Search mimetype from filename when mimetype is empty or application/octet-stream. ...
Definition: util.cpp:569
MessageViewer::NodeHelper::cleanSubject
static QString cleanSubject(KMime::Message *message)
Return this mails subject, with all "forward" and "reply" prefixes removed.
Definition: nodehelper.cpp:528
MessageViewer::NodeHelper
Definition: nodehelper.h:74
MessageViewer::Util::saveContent
bool MESSAGEVIEWER_EXPORT saveContent(QWidget *parent, KMime::Content *content, const KUrl &url)
Definition: util.cpp:307
QLatin1String
MessageViewer::ObjectTreeParser::findType
static KMime::Content * findType(KMime::Content *content, const QByteArray &mimeType, bool deep, bool wide)
Definition: objecttreeparser.cpp:3474
MessageViewer::Util::checkOverwrite
bool MESSAGEVIEWER_EXPORT checkOverwrite(const KUrl &url, QWidget *w)
Definition: util.cpp:79
QDataStream::writeRawData
int writeRawData(const char *s, int len)
QString::length
int length() const
QByteArray::data
char * data()
MessageViewer::NodeHelper::setNodeUnprocessed
void setNodeUnprocessed(KMime::Content *node, bool recurse)
Definition: nodehelper.cpp:113
MessageViewer::NodeHelper::removeTempFiles
void removeTempFiles()
Cleanup the attachment temp files.
Definition: nodehelper.cpp:309
MessageViewer::NodeHelper::signatureState
KMMsgSignatureState signatureState(KMime::Content *node) const
Definition: nodehelper.cpp:203
MessageViewer::ObjectTreeParser
Parses messages and generates HTML display code out of them.
Definition: objecttreeparser.h:287
QDataStream::device
QIODevice * device() const
QDesktopServices::openUrl
bool openUrl(const QUrl &url)
MessageViewer::Util::allContents
QList< KMime::Content * > MESSAGEVIEWER_EXPORT allContents(const KMime::Content *message)
Definition: util.cpp:153
QByteArray::size
int size() const
QDBusAbstractInterface::asyncCall
QDBusPendingCall asyncCall(const QString &method, const QVariant &arg1, const QVariant &arg2, const QVariant &arg3, const QVariant &arg4, const QVariant &arg5, const QVariant &arg6, const QVariant &arg7, const QVariant &arg8)
MessageViewer::Util::handleUrlWithQDesktopServices
bool MESSAGEVIEWER_EXPORT handleUrlWithQDesktopServices(const KUrl &url)
Delegates opening a URL to the QDesktopServices mechanisms for that on Windows and MacOSX...
Definition: util.cpp:142
MessageViewer::Util::getWritePermissions
int MESSAGEVIEWER_EXPORT getWritePermissions()
evaluates GlobalSettings->disregardUmask() and returns resulting permissions for storing files ...
Definition: util.cpp:444
MessageViewer::Util::extractAttachments
QList< KMime::Content * > MESSAGEVIEWER_EXPORT extractAttachments(const KMime::Message *message)
Definition: util.cpp:170
MessageViewer::NodeHelper::fileName
static QString fileName(const KMime::Content *node)
Returns a usable filename for a node, that can be the filename from the content disposition header...
Definition: nodehelper.cpp:588
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:45 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal