specialmailcollectionsrequestjob.cpp
00001 /* 00002 Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 00018 */ 00019 00020 #include "specialmailcollectionsrequestjob.h" 00021 00022 #include "specialmailcollections.h" 00023 00024 #include <kglobal.h> 00025 #include <klocale.h> 00026 #include <kstandarddirs.h> 00027 00028 using namespace Akonadi; 00029 00030 #ifndef KDE_USE_FINAL 00031 static inline QByteArray enumToType( SpecialMailCollections::Type type ) 00032 { 00033 switch ( type ) { 00034 case SpecialMailCollections::Root: return "local-mail"; break; 00035 case SpecialMailCollections::Inbox: return "inbox"; break; 00036 case SpecialMailCollections::Outbox: return "outbox"; break; 00037 case SpecialMailCollections::SentMail: return "sent-mail"; break; 00038 case SpecialMailCollections::Trash: return "trash"; break; 00039 case SpecialMailCollections::Drafts: return "drafts"; break; 00040 case SpecialMailCollections::Templates: return "templates"; break; 00041 case SpecialMailCollections::LastType: // fallthrough 00042 default: return QByteArray(); break; 00043 } 00044 } 00045 #endif 00046 00047 SpecialMailCollectionsRequestJob::SpecialMailCollectionsRequestJob( QObject *parent ) 00048 : SpecialCollectionsRequestJob( SpecialMailCollections::self(), parent ), 00049 d( 0 ) 00050 { 00051 static QMap<QByteArray, QString> displayNameMap; 00052 displayNameMap.insert( "local-mail", i18nc( "local mail folder", "Local Folders" ) ); 00053 displayNameMap.insert( "inbox", i18nc( "local mail folder", "inbox" ) ); 00054 displayNameMap.insert( "outbox", i18nc( "local mail folder", "outbox" ) ); 00055 displayNameMap.insert( "sent-mail", i18nc( "local mail folder", "sent-mail" ) ); 00056 displayNameMap.insert( "trash", i18nc( "local mail folder", "trash" ) ); 00057 displayNameMap.insert( "drafts", i18nc( "local mail folder", "drafts" ) ); 00058 displayNameMap.insert( "templates", i18nc( "local mail folder", "templates" ) ); 00059 00060 static QMap<QByteArray, QString> iconNameMap; 00061 iconNameMap.insert( "local-mail", QLatin1String( "folder" ) ); 00062 iconNameMap.insert( "inbox", QLatin1String( "mail-folder-inbox" ) ); 00063 iconNameMap.insert( "outbox", QLatin1String( "mail-folder-outbox" ) ); 00064 iconNameMap.insert( "sent-mail", QLatin1String( "mail-folder-sent" ) ); 00065 iconNameMap.insert( "trash", QLatin1String( "user-trash" ) ); 00066 iconNameMap.insert( "drafts", QLatin1String( "document-properties" ) ); 00067 iconNameMap.insert( "templates", QLatin1String( "document-new" ) ); 00068 00069 QVariantMap options; 00070 options.insert( QLatin1String( "Name" ), displayNameMap.value( "local-mail" ) ); 00071 options.insert( QLatin1String( "Path" ), QString(KGlobal::dirs()->localxdgdatadir() + QLatin1String( "local-mail" )) ); 00072 00073 setDefaultResourceType( QLatin1String( "akonadi_maildir_resource" ) ); 00074 setDefaultResourceOptions( options ); 00075 00076 setTypes( displayNameMap.keys() ); 00077 setNameForTypeMap( displayNameMap ); 00078 setIconForTypeMap( iconNameMap ); 00079 } 00080 00081 SpecialMailCollectionsRequestJob::~SpecialMailCollectionsRequestJob() 00082 { 00083 } 00084 00085 void SpecialMailCollectionsRequestJob::requestDefaultCollection( SpecialMailCollections::Type type ) 00086 { 00087 return SpecialCollectionsRequestJob::requestDefaultCollection( enumToType( type ) ); 00088 } 00089 00090 void SpecialMailCollectionsRequestJob::requestCollection( SpecialMailCollections::Type type, const AgentInstance &instance ) 00091 { 00092 return SpecialCollectionsRequestJob::requestCollection( enumToType( type ), instance ); 00093 } 00094 00095 #include "specialmailcollectionsrequestjob.moc"