akonadi
specialmailcollections.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 "specialmailcollections.h" 00021 00022 #include "specialmailcollectionssettings.h" 00023 00024 #include <KGlobal> 00025 00026 #include "akonadi/agentinstance.h" 00027 00028 using namespace Akonadi; 00029 00030 class Akonadi::SpecialMailCollectionsPrivate 00031 { 00032 public: 00033 SpecialMailCollectionsPrivate(); 00034 ~SpecialMailCollectionsPrivate(); 00035 00036 SpecialMailCollections *mInstance; 00037 }; 00038 00039 typedef SpecialMailCollectionsSettings Settings; 00040 00041 K_GLOBAL_STATIC( SpecialMailCollectionsPrivate, sInstance ) 00042 00043 static inline QByteArray enumToType( SpecialMailCollections::Type type ) 00044 { 00045 switch ( type ) { 00046 case SpecialMailCollections::Root: return "local-mail"; break; 00047 case SpecialMailCollections::Inbox: return "inbox"; break; 00048 case SpecialMailCollections::Outbox: return "outbox"; break; 00049 case SpecialMailCollections::SentMail: return "sent-mail"; break; 00050 case SpecialMailCollections::Trash: return "trash"; break; 00051 case SpecialMailCollections::Drafts: return "drafts"; break; 00052 case SpecialMailCollections::Templates: return "templates"; break; 00053 case SpecialMailCollections::LastType: // fallthrough 00054 default: return QByteArray(); break; 00055 } 00056 } 00057 00058 SpecialMailCollectionsPrivate::SpecialMailCollectionsPrivate() 00059 : mInstance( new SpecialMailCollections( this ) ) 00060 { 00061 } 00062 00063 SpecialMailCollectionsPrivate::~SpecialMailCollectionsPrivate() 00064 { 00065 delete mInstance; 00066 } 00067 00068 SpecialMailCollections::SpecialMailCollections( SpecialMailCollectionsPrivate *dd ) 00069 : SpecialCollections( Settings::self() ), 00070 d( dd ) 00071 { 00072 } 00073 00074 SpecialMailCollections *SpecialMailCollections::self() 00075 { 00076 return sInstance->mInstance; 00077 } 00078 00079 bool SpecialMailCollections::hasCollection( Type type, const AgentInstance &instance ) const 00080 { 00081 return SpecialCollections::hasCollection( enumToType( type ), instance ); 00082 } 00083 00084 Collection SpecialMailCollections::collection( Type type, const AgentInstance &instance ) const 00085 { 00086 return SpecialCollections::collection( enumToType( type ), instance ); 00087 } 00088 00089 bool SpecialMailCollections::registerCollection( Type type, const Collection &collection ) 00090 { 00091 return SpecialCollections::registerCollection( enumToType( type ), collection ); 00092 } 00093 00094 bool SpecialMailCollections::hasDefaultCollection( Type type ) const 00095 { 00096 return SpecialCollections::hasDefaultCollection( enumToType( type ) ); 00097 } 00098 00099 Collection SpecialMailCollections::defaultCollection( Type type ) const 00100 { 00101 return SpecialCollections::defaultCollection( enumToType( type ) ); 00102 } 00103 00104 #include "specialmailcollections.moc"