Commit 89e04f60 authored by Cornelius Schumacher's avatar Cornelius Schumacher
Browse files

Move libakonadi to akonadi.

svn path=/trunk/KDE/kdepim/libakonadi/; revision=559105
parent 3b7a42ab
add_subdirectory( tests )
include_directories(
${CMAKE_SOURCE_DIR}/
${CMAKE_SOURCE_DIR}/libakonadi
${CMAKE_SOURCE_DIR}/libkmime
${QT_QTDBUS_INCLUDE_DIR}
)
########### next target ###############
set( akonadi_LIB_SRC
datarequest.cpp
query.cpp
collection.cpp
collectionattribute.cpp
collectioncreatejob.cpp
collectionlistjob.cpp
collectionmodel.cpp
collectionrenamejob.cpp
collectionselectjob.cpp
collectionstatusjob.cpp
collectionview.cpp
imapparser.cpp
item.cpp
itemappendjob.cpp
job.cpp
jobqueue.cpp
messagecollectionattribute.cpp
messagecollectionmodel.cpp
message.cpp
messagefetchjob.cpp
messagemodel.cpp
messagequery.cpp
monitor.cpp
)
qt4_add_dbus_interfaces(akonadi_LIB_SRC ${CMAKE_SOURCE_DIR}/akonadi/server/interfaces/org.kde.Akonadi.NotificationManager.xml)
kde4_automoc( ${akonadi_LIB_SRC} )
kde4_add_library( akonadi SHARED ${akonadi_LIB_SRC} )
target_link_libraries( akonadi ${QT_QTNETWORK_LIBRARY} ${QT_QTDBUS_LIBRARIES} ${KDE4_KDECORE_LIBS} kmime )
set_target_properties( akonadi PROPERTIES VERSION 1.0.0 SOVERSION 1 )
install(TARGETS akonadi DESTINATION ${LIB_INSTALL_DIR})
########### install files ###############
install( FILES
datarequest.h
query.h
collection.h
collectionattribute.h
collectioncreatejob.h
collectionlistjob.h
collectionmodel.h
collectionrenamejob.h
collectionselectjob.h
collectionstatusjob.h
collectionview.h
imapparser.h
item.h
itemappendjob.h
job.h
jobqueue.h
messagecollectionattribute.h
messagecollectionmodel.h
message.h
messagefetchjob.h
messagemodel.h
messagequery.h
monitor.h
DESTINATION ${INCLUDE_INSTALL_DIR}/libakonadi
)
/** @mainpage libakonadi
This library contains the access methods for the KDE PIM Storage Service Akonadi.
*/
// DOXYGEN_REFERENCES = libkmime
libakonadi is the client access library for using the Akonadi PIM data server. All processes that access Akonadi, including those which communicate only with a remote server, are considered clients.
See libakonadi.xmi for UML documentation generated with Umbrello.
/*
Copyright (c) 2006 Volker Krause <volker.krause@rwth-aachen.de>
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 "collection.h"
#include <QHash>
#include <QString>
#include <QStringList>
using namespace PIM;
class Collection::Private
{
public:
QByteArray path;
QByteArray parent;
QString name;
Type type;
QHash<QByteArray, CollectionAttribute*> attributes;
};
PIM::Collection::Collection( const QByteArray &path ) :
d( new Collection::Private() )
{
d->path = path;
d->type = Unknown;
}
PIM::Collection::~Collection( )
{
qDeleteAll( d->attributes );
delete d;
d = 0;
}
QByteArray PIM::Collection::path() const
{
return d->path;
}
QString PIM::Collection::name( ) const
{
if ( d->name.isEmpty() && d->path != root() ) {
QByteArray name = d->path.mid( d->path.lastIndexOf( delimiter() ) + 1 );
// TODO decode to utf-8
d->name = QString::fromLatin1( name );
}
return d->name;
}
void PIM::Collection::setName( const QString & name )
{
d->name = name;
}
Collection::Type PIM::Collection::type() const
{
return d->type;
}
void PIM::Collection::setType( Type type )
{
d->type = type;
}
QList<QByteArray> PIM::Collection::contentTypes() const
{
CollectionContentTypeAttribute *attr = const_cast<Collection*>( this )->attribute<CollectionContentTypeAttribute>();
if ( attr )
return attr->contentTypes();
return QList<QByteArray>();
}
void PIM::Collection::setContentTypes( const QList<QByteArray> & types )
{
CollectionContentTypeAttribute* attr = attribute<CollectionContentTypeAttribute>( true );
attr->setContentTypes( types );
}
QByteArray PIM::Collection::parent( ) const
{
return d->parent;
}
void PIM::Collection::setParent( const QByteArray &parent )
{
d->parent = parent;
}
QByteArray PIM::Collection::delimiter()
{
return QByteArray( "/" );
}
QByteArray PIM::Collection::root( )
{
return QByteArray();
}
QByteArray PIM::Collection::searchFolder( )
{
return root() + QByteArray( "Search" );
}
QByteArray PIM::Collection::prefix()
{
return QByteArray( "/" );
}
QByteArray PIM::Collection::collectionMimeType( )
{
return QByteArray( "directory/inode" );
}
void PIM::Collection::addAttribute( CollectionAttribute * attr )
{
if ( d->attributes.contains( attr->type() ) )
delete d->attributes.take( attr->type() );
d->attributes.insert( attr->type(), attr );
}
CollectionAttribute * PIM::Collection::attribute( const QByteArray & type ) const
{
if ( d->attributes.contains( type ) )
return d->attributes.value( type );
return 0;
}
bool PIM::Collection::hasAttribute( const QByteArray & type ) const
{
return d->attributes.contains( type );
}
/*
Copyright (c) 2006 Volker Krause <volker.krause@rwth-aachen.de>
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 PIM_COLLECTION_H
#define PIM_COLLECTION_H
#include <libakonadi/collectionattribute.h>
#include <libakonadi/job.h>
#include <kdepim_export.h>
namespace PIM {
/**
This class represents a collection of PIM objects, such as a folder on a mail- or
groupware-server.
Collections are hierarchical, i.e. they may have a parent collection.
*/
class AKONADI_EXPORT Collection
{
public:
/**
Collection types.
*/
enum Type {
Folder, /**< 'Real' folder on eg. an IMAP server. */
Virtual, /**< Virtual collection (aka search folder). */
Resource, /**< Resource or account. */
VirtualParent, /**< The parent collection of all virtual collections. */
Unknown /**< Unknown collection type. */
};
typedef QList<Collection*> List;
/**
Create a new collection.
@param path The unique IMAP path of this collection.
*/
Collection( const QByteArray &path );
/**
Destroys this collection.
*/
virtual ~Collection();
/**
Returns the unique IMAP path of this collection.
*/
QByteArray path() const;
/**
Returns the name of this collection usable for display.
*/
QString name() const;
/**
Sets the collection name. Note that this does not change path()!
This is used during renaming to fake immediate changes.
@param name The new collection name;
*/
void setName( const QString &name );
/**
Returns the type of this collection (e.g. virtual folder, folder on an
IMAP server, etc.).
*/
Type type() const;
/**
Sets the type of this collection.
*/
void setType( Type type );
/**
Returns a list of possible content mimetypes,
e.g. message/rfc822, x-akonadi/collection for a mail folder that
supports sub-folders.
*/
QList<QByteArray> contentTypes() const;
/**
Sets the list of possible content mimetypes.
*/
void setContentTypes( const QList<QByteArray> &types );
/**
Returns the IMAP path to the parent collection.
*/
QByteArray parent() const;
/**
Sets the path of the parent collection.
*/
void setParent( const QByteArray &parent );
/**
Adds a collection attribute. An already existing attribute of the same
type is deleted.
@param attr The new attribute. The collection takes the ownership of this
object.
*/
void addAttribute( CollectionAttribute *attr );
/**
Returns true if the collection has the speciefied attribute.
@param type The attribute type.
*/
bool hasAttribute( const QByteArray &type ) const;
/**
Returns the attribute of the given type if available, 0 otherwise.
@param type The attribute type.
*/
CollectionAttribute* attribute( const QByteArray &type ) const;
/**
Returns the attribute of the requested type or 0 if not available.
@param create Creates the attribute if it doesn't exist.
*/
template <typename T> inline T* attribute( bool create = false )
{
T dummy;
if ( hasAttribute( dummy.type() ) )
return static_cast<T*>( attribute( dummy.type() ) );
if ( !create )
return 0;
T* attr = new T();
addAttribute( attr );
return attr;
}
/**
Returns the collection path delimiter.
*/
static QByteArray delimiter();
/**
Returns the root path.
*/
static QByteArray root();
/**
Returns the Akonadi IMAP collection prefix.
*/
static QByteArray prefix();
/**
Returns the path of the top-level search folder.
*/
static QByteArray searchFolder();
/**
Returns the mimetype used for collections.
*/
static QByteArray collectionMimeType();
private:
class Private;
Private *d;
};
}
#endif
/*
Copyright (c) 2006 Volker Krause <volker.krause@rwth-aachen.de>
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 "collectionattribute.h"
using namespace PIM;
PIM::CollectionAttribute::~ CollectionAttribute( )
{
}
PIM::CollectionContentTypeAttribute::CollectionContentTypeAttribute( const QList< QByteArray > & contentTypes )
{
mContentTypes = contentTypes;
}
QByteArray PIM::CollectionContentTypeAttribute::type() const
{
return QByteArray( "ContentTypes" );
}
QList< QByteArray > PIM::CollectionContentTypeAttribute::contentTypes( ) const
{
return mContentTypes;
}
void PIM::CollectionContentTypeAttribute::setContentTypes( const QList< QByteArray > & contentTypes )
{
mContentTypes = contentTypes;
}
/*
Copyright (c) 2006 Volker Krause <volker.krause@rwth-aachen.de>
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 PIM_COLLECTIONATTRIBUTE_H
#define PIM_COLLECTIONATTRIBUTE_H
#include <QtCore/QByteArray>
#include <QtCore/QList>
namespace PIM {
/**
Stores specific collection attributes (ACLs, unread counts, quotas, etc.).
Every collection can have zero ore one attribute of every type.
*/
class CollectionAttribute
{
public:
typedef QList<CollectionAttribute*> List;
/**
Returns the attribute name of this collection.
*/
virtual QByteArray type() const = 0;
/**
Destroys this attribute.
*/
virtual ~CollectionAttribute();
};
/**
Content mimetypes collection attribute. Contains a list of allowed content
types of a collection.
*/
class CollectionContentTypeAttribute : public CollectionAttribute
{
public:
/**
Creates a new content mimetype attribute.
@param contentTypes Allowed content types.
*/
CollectionContentTypeAttribute( const QList<QByteArray> &contentTypes = QList<QByteArray>() );
virtual QByteArray type() const;
/**
Returns the allowed content mimetypes.
*/
QList<QByteArray> contentTypes() const;
/**
Sets the allowed content mimetypes.
@param contentTypes Allowed content types.
*/
void setContentTypes( const QList<QByteArray> &contentTypes );
private:
QList<QByteArray> mContentTypes;
};
}
#endif
/*
Copyright (c) 2006 Volker Krause <volker.krause@rwth-aachen.de>
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 "collectioncreatejob.h"
#include <QDebug>
using namespace PIM;
class PIM::CollectionCreateJobPrivate {
public:
QByteArray path;
};
PIM::CollectionCreateJob::CollectionCreateJob( const QByteArray & path, QObject * parent ) :
Job( parent ),
d( new CollectionCreateJobPrivate )
{
d->path = path;
}
PIM::CollectionCreateJob::~ CollectionCreateJob( )
{
delete d;
}
void PIM::CollectionCreateJob::doStart( )
{
writeData( newTag() + " CREATE \"" + d->path + "\"" );
}
void PIM::CollectionCreateJob::doHandleResponse( const QByteArray & tag, const QByteArray & data )
{
qDebug() << "unhandled response in collection create job: " << tag << data;
}
QByteArray PIM::CollectionCreateJob::path( ) const
{
return d->path;
}
#include "collectioncreatejob.moc"
/*
Copyright (c) 2006 Volker Krause <volker.krause@rwth-aachen.de>
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