diff --git a/akonadi/kmime/CMakeLists.txt b/akonadi/kmime/CMakeLists.txt index f5765ea12..8be70a7e1 100644 --- a/akonadi/kmime/CMakeLists.txt +++ b/akonadi/kmime/CMakeLists.txt @@ -1,44 +1,46 @@ include_directories( ${CMAKE_SOURCE_DIR}/ ${QT_QTDBUS_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ) add_subdirectory( tests ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII ${KDE4_ENABLE_EXCEPTIONS}" ) ########### next target ############### set( kmimeakonadi_LIB_SRC addressattribute.cpp localfolders.cpp localfoldersbuildjob.cpp + messagefolderattribute.cpp messagemodel.cpp messageparts.cpp messagethreadingattribute.cpp messagethreaderproxymodel.cpp resourcesynchronizationjob.cpp # copied from playground/pim/akonaditest/resourcetester ) kde4_add_kcfg_files( kmimeakonadi_LIB_SRC localfolderssettings.kcfgc ) install( FILES localfolders.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) kde4_add_library( akonadi-kmime SHARED ${kmimeakonadi_LIB_SRC} ) target_link_libraries( akonadi-kmime akonadi-kde kmime ${QT_QTGUI_LIBRARY} ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ) set_target_properties( akonadi-kmime PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) install(TARGETS akonadi-kmime EXPORT kdepimlibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS}) ########### install files ############### install( FILES addressattribute.h localfolders.h akonadi-kmime_export.h + messagefolderattribute.h messagemodel.h messageparts.h messagethreadingattribute.h messagethreaderproxymodel.h DESTINATION ${INCLUDE_INSTALL_DIR}/akonadi/kmime COMPONENT Devel ) diff --git a/akonadi/kmime/messagefolderattribute.cpp b/akonadi/kmime/messagefolderattribute.cpp new file mode 100644 index 000000000..f99410a43 --- /dev/null +++ b/akonadi/kmime/messagefolderattribute.cpp @@ -0,0 +1,90 @@ +/* + Copyright (c) 2009 Kevin Ottens + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#include "messagefolderattribute.h" + +using namespace Akonadi; + +class Akonadi::MessageFolderAttribute::Private +{ + public: + Private() + : isOutboundFolder( false ) { } + + bool isOutboundFolder; +}; + +MessageFolderAttribute::MessageFolderAttribute() : + d( new Private ) +{ +} + +MessageFolderAttribute::MessageFolderAttribute(const MessageFolderAttribute & other) : + Attribute( other ), + d( new Private( *(other.d) ) ) +{ +} + +MessageFolderAttribute::~MessageFolderAttribute() +{ + delete d; +} + +QByteArray MessageFolderAttribute::type() const +{ + return "MESSAGEFOLDER"; +} + +MessageFolderAttribute * MessageFolderAttribute::clone() const +{ + return new MessageFolderAttribute( *this ); +} + +QByteArray MessageFolderAttribute::serialized() const +{ + QByteArray rv; + + if ( d->isOutboundFolder ) { + rv+= "outbound"; + } else { + rv+= "inbound"; + } + + return rv; +} + +void MessageFolderAttribute::deserialize(const QByteArray &data) +{ + if ( data == "outbound" ) { + d->isOutboundFolder = true; + } else { + d->isOutboundFolder = false; + } +} + +bool MessageFolderAttribute::isOutboundFolder() const +{ + return d->isOutboundFolder; +} + +void MessageFolderAttribute::setOutboundFolder(bool outbound) +{ + d->isOutboundFolder = outbound; +} + diff --git a/akonadi/kmime/messagefolderattribute.h b/akonadi/kmime/messagefolderattribute.h new file mode 100644 index 000000000..d640d5900 --- /dev/null +++ b/akonadi/kmime/messagefolderattribute.h @@ -0,0 +1,78 @@ +/* + Copyright (c) 2009 Kevin Ottens + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef AKONADI_MESSAGEFOLDERATTRIBUTE_H +#define AKONADI_MESSAGEFOLDERATTRIBUTE_H + +#include "akonadi-kmime_export.h" +#include + +#include + +namespace Akonadi { + +/** + Message folder information. Used eg. by mail clients to decide how to display the content of such collections +*/ +class AKONADI_KMIME_EXPORT MessageFolderAttribute : public Attribute +{ + public: + /** + Creates an empty folder attribute. + */ + MessageFolderAttribute(); + + /** + Copy constructor. + */ + MessageFolderAttribute( const MessageFolderAttribute &other ); + + /** + Destructor. + */ + ~MessageFolderAttribute(); + + /** + Indicates if the folder is supposed to contain mostly outbound messages. + In such a case mail clients display the recipient address, otherwise they + display the sender address. + + @return true if the folder contains outbound messages + */ + bool isOutboundFolder() const; + + /** + Set if the folder should be considered as containing mostly outbound messages. + */ + void setOutboundFolder(bool outbound); + + // reimpl. + QByteArray type() const; + MessageFolderAttribute* clone() const; + QByteArray serialized() const; + void deserialize( const QByteArray &data ); + + private: + class Private; + Private * const d; +}; + +} + +#endif