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

akonadi/kmime

  • sources
  • kde-4.14
  • kdepimlibs
  • akonadi
  • kmime
specialmailcollectionsrequestjob.cpp
1 /*
2  Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "specialmailcollectionsrequestjob.h"
21 
22 #include "specialmailcollections.h"
23 
24 #include <kglobal.h>
25 #include <klocalizedstring.h>
26 #include <kstandarddirs.h>
27 
28 using namespace Akonadi;
29 
30 #ifndef KDE_USE_FINAL
31 static inline QByteArray enumToType(SpecialMailCollections::Type type)
32 {
33  switch (type) {
34  case SpecialMailCollections::Root:
35  return "local-mail";
36  break;
37  case SpecialMailCollections::Inbox:
38  return "inbox";
39  break;
40  case SpecialMailCollections::Outbox:
41  return "outbox";
42  break;
43  case SpecialMailCollections::SentMail:
44  return "sent-mail";
45  break;
46  case SpecialMailCollections::Trash:
47  return "trash";
48  break;
49  case SpecialMailCollections::Drafts:
50  return "drafts";
51  break;
52  case SpecialMailCollections::Templates:
53  return "templates";
54  break;
55  case SpecialMailCollections::LastType: // fallthrough
56  default:
57  return QByteArray();
58  break;
59  }
60 }
61 #endif
62 
63 SpecialMailCollectionsRequestJob::SpecialMailCollectionsRequestJob(QObject *parent)
64  : SpecialCollectionsRequestJob(SpecialMailCollections::self(), parent)
65  , d(0)
66 {
67  static QMap<QByteArray, QString> displayNameMap;
68  displayNameMap.insert("local-mail", i18nc("local mail folder", "Local Folders"));
69  displayNameMap.insert("inbox", /*i18nc( "local mail folder",*/QLatin1String("inbox"));
70  displayNameMap.insert("outbox", /*i18nc( "local mail folder",*/ QLatin1String("outbox"));
71  displayNameMap.insert("sent-mail", /*i18nc( "local mail folder",*/QLatin1String("sent-mail"));
72  displayNameMap.insert("trash", /*i18nc( "local mail folder", */QLatin1String("trash"));
73  displayNameMap.insert("drafts", /*i18nc( "local mail folder", */QLatin1String("drafts"));
74  displayNameMap.insert("templates", /*i18nc( "local mail folder", */QLatin1String("templates"));
75 
76  static QMap<QByteArray, QString> iconNameMap;
77  iconNameMap.insert("local-mail", QLatin1String("folder"));
78  iconNameMap.insert("inbox", QLatin1String("mail-folder-inbox"));
79  iconNameMap.insert("outbox", QLatin1String("mail-folder-outbox"));
80  iconNameMap.insert("sent-mail", QLatin1String("mail-folder-sent"));
81  iconNameMap.insert("trash", QLatin1String("user-trash"));
82  iconNameMap.insert("drafts", QLatin1String("document-properties"));
83  iconNameMap.insert("templates", QLatin1String("document-new"));
84 
85  QVariantMap options;
86  options.insert(QLatin1String("Name"), displayNameMap.value("local-mail"));
87  options.insert(QLatin1String("TopLevelIsContainer"), true);
88  options.insert(QLatin1String("Path"), QString(KGlobal::dirs()->localxdgdatadir() + QLatin1String("local-mail")));
89 
90  setDefaultResourceType(QLatin1String("akonadi_maildir_resource"));
91  setDefaultResourceOptions(options);
92 
93  setTypes(displayNameMap.keys());
94  setNameForTypeMap(displayNameMap);
95  setIconForTypeMap(iconNameMap);
96 }
97 
98 SpecialMailCollectionsRequestJob::~SpecialMailCollectionsRequestJob()
99 {
100 }
101 
102 void SpecialMailCollectionsRequestJob::requestDefaultCollection(SpecialMailCollections::Type type)
103 {
104  return SpecialCollectionsRequestJob::requestDefaultCollection(enumToType(type));
105 }
106 
107 void SpecialMailCollectionsRequestJob::requestCollection(SpecialMailCollections::Type type, const AgentInstance &instance)
108 {
109  return SpecialCollectionsRequestJob::requestCollection(enumToType(type), instance);
110 }
Akonadi::SpecialMailCollections::Trash
The trash collection.
Definition: specialmailcollections.h:84
Akonadi::SpecialMailCollectionsRequestJob::requestDefaultCollection
void requestDefaultCollection(SpecialMailCollections::Type type)
Requests a special mail collection of the given type in the default resource.
Definition: specialmailcollectionsrequestjob.cpp:102
QByteArray
Akonadi::SpecialMailCollections::Templates
The templates collection.
Definition: specialmailcollections.h:86
Akonadi::SpecialMailCollectionsRequestJob::~SpecialMailCollectionsRequestJob
~SpecialMailCollectionsRequestJob()
Destroys the special mail collections request job.
Definition: specialmailcollectionsrequestjob.cpp:98
QMap
Akonadi::SpecialMailCollectionsRequestJob::requestCollection
void requestCollection(SpecialMailCollections::Type type, const AgentInstance &instance)
Requests a special mail collection of the given type in the given resource instance.
Definition: specialmailcollectionsrequestjob.cpp:107
Akonadi::SpecialMailCollections::Root
The root collection containing the local folders.
Definition: specialmailcollections.h:80
Akonadi::SpecialMailCollections::Inbox
The inbox collection.
Definition: specialmailcollections.h:81
QMap::keys
QList< Key > keys() const
Akonadi::SpecialMailCollections::Outbox
The outbox collection.
Definition: specialmailcollections.h:82
Akonadi::SpecialMailCollections::SentMail
The sent-mail collection.
Definition: specialmailcollections.h:83
QObject
Akonadi::SpecialMailCollections
Interface to special mail collections such as inbox, outbox etc.
Definition: specialmailcollections.h:67
QString
Akonadi::SpecialMailCollections::Type
Type
Describes the possible types of special mail collections.
Definition: specialmailcollections.h:78
QLatin1String
Akonadi::SpecialMailCollections::Drafts
The drafts collection.
Definition: specialmailcollections.h:85
Akonadi::SpecialMailCollectionsRequestJob::SpecialMailCollectionsRequestJob
SpecialMailCollectionsRequestJob(QObject *parent=0)
Creates a new special mail collections request job.
Definition: specialmailcollectionsrequestjob.cpp:63
QMap::insert
iterator insert(const Key &key, const T &value)
QMap::value
const T value(const Key &key) const
Akonadi::SpecialMailCollections::LastType
Definition: specialmailcollections.h:87
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:24 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi/kmime

Skip menu "akonadi/kmime"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

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