~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to messageviewer/util.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#ifndef MAILVIEWERUTIL_H
39
39
#define MAILVIEWERUTIL_H
40
40
 
 
41
#include "messageviewer_export.h"
 
42
 
 
43
#include <QString>
 
44
 
41
45
class KUrl;
42
46
class QWidget;
43
47
class QStringList;
44
 
class QString;
45
 
 
46
 
    /**
47
 
     * The Util namespace contains a collection of helper functions use in
48
 
     * various places.
49
 
     */
 
48
 
 
49
namespace KMime {
 
50
  class Content;
 
51
  class Message;
 
52
}
 
53
 
 
54
namespace MessageViewer {
 
55
 
 
56
/**
 
57
 * The Util namespace contains a collection of helper functions use in
 
58
 * various places.
 
59
 */
50
60
namespace Util {
51
61
 
 
62
    /**
 
63
      * Describes the type of the displayed message. This depends on the MIME structure
 
64
      * of the mail and on whether HTML mode is enabled (which is decided by htmlMail())
 
65
      */
 
66
    enum HtmlMode {
 
67
      Normal,         ///< A normal plaintext message, non-multipart
 
68
      Html,           ///< A HTML message, non-multipart
 
69
      MultipartPlain, ///< A multipart/alternative message, the plain text part is currently displayed
 
70
      MultipartHtml   ///< A multipart/altervative message, the HTML part is currently displayed
 
71
    };
 
72
 
52
73
    // return true if we should proceed, false if we should abort
53
 
    bool checkOverwrite( const KUrl &url, QWidget *w );
54
 
 
55
 
    /**
56
 
     * Delegates opening a URL to the Max OSX mechanisms for that.
57
 
     * Returns false if it did nothing (such as on other platforms.
58
 
     */
59
 
    bool handleUrlOnMac( const KUrl& url );
60
 
 
61
 
    /**
62
 
    * Return a list of the supported encodings
63
 
    * @param usAscii if true, US-Ascii encoding will be prepended to the list.
64
 
    */
65
 
    QStringList supportedEncodings( bool usAscii );
66
 
 
67
 
    /**
68
 
    * Fixes an encoding received by a KDE function and returns the proper,
69
 
    * MIME-compilant encoding name instead.
70
 
    * @see encodingForName
71
 
    */
72
 
    QString fixEncoding( const QString &encoding );
73
 
 
74
 
    /**
75
 
    * Drop-in replacement for KCharsets::encodingForName(). The problem with
76
 
    * the KCharsets function is that it returns "human-readable" encoding names
77
 
    * like "ISO 8859-15" instead of valid encoding names like "ISO-8859-15".
78
 
    * This function fixes this by replacing whitespace with a hyphen.
79
 
    */
80
 
    QString encodingForName( const QString &descriptiveName );
 
74
    bool MESSAGEVIEWER_EXPORT checkOverwrite( const KUrl &url, QWidget *w );
 
75
 
 
76
    /**
 
77
     * Delegates opening a URL to the QDesktopServices mechanisms for that
 
78
     * on Windows and MacOSX.
 
79
     * Returns false if it did nothing (such as on other platforms).
 
80
     */
 
81
    bool MESSAGEVIEWER_EXPORT handleUrlWithQDesktopServices( const KUrl& url );
 
82
 
 
83
    /**
 
84
     * evaluates GlobalSettings->disregardUmask()
 
85
     * and returns resulting permissions for storing files
 
86
     * @return specific file permissions or -1 for default permissions
 
87
     */
 
88
    int MESSAGEVIEWER_EXPORT getWritePermissions();
 
89
 
 
90
    QList<KMime::Content*> MESSAGEVIEWER_EXPORT allContents( const KMime::Content *message );
 
91
    QList<KMime::Content*> MESSAGEVIEWER_EXPORT extractAttachments( const KMime::Message *message );
 
92
    bool MESSAGEVIEWER_EXPORT saveContents( QWidget *parent,
 
93
                                            const QList<KMime::Content*> &contents );
 
94
    bool MESSAGEVIEWER_EXPORT saveContent( QWidget *parent, KMime::Content* content,
 
95
                                           const KUrl& url );
 
96
 
 
97
    /**
 
98
     * Finds the filename of an icon based on the given mimetype or filenames.
 
99
     *
 
100
     * Always use this functions when looking up icon names for mime types, don't use
 
101
     * KMimeType directly.
 
102
     *
 
103
     * Uses the IconNameCache internally to speed things up.
 
104
     *
 
105
     * @param mimeType The primary mime type used to find the icon, e.g. "application/zip". Alias
 
106
     *                 mimetypes are resolved.
 
107
     * @param size Size of the requested icon, e.g. KIconLoader::Desktop
 
108
     * @param fallbackFileName(1|2) When the icon is not found by the given mime type, use the file
 
109
     *                              name extensions of these file names to look the icon up.
 
110
     *                              Example: "test.zip"
 
111
     * @return the full file name of the icon file
 
112
     */
 
113
    QString MESSAGEVIEWER_EXPORT fileNameForMimetype( const QString &mimeType, int iconSize,
 
114
                                 const QString &fallbackFileName1 = QString(),
 
115
                                 const QString &fallbackFileName2 = QString() );
 
116
 
 
117
}
 
118
 
81
119
}
82
120
 
83
121
#endif