Commit a9fb309c authored by Volker Krause's avatar Volker Krause
Browse files

Name the runtime part of kdepim actually "runtime", and move stuff out

of it that belongs in the apps part.

svn path=/branches/work/akonadi-ports/kdepim/akonadi/; revision=1061292
parent 6f8bc458
project(kdepim-runtime)
# where to look first for cmake modules. This line must be the first one or cmake will use the system's FindFoo.cmake
set(CMAKE_MODULE_PATH ${kdepim-runtime_SOURCE_DIR}/cmake/modules)
############### search packages used by KDE ###############
find_package(KDE4 REQUIRED)
include(KDE4Defaults)
find_package(KdepimLibs 4.2.87 REQUIRED)
find_package(Boost 1.34.0)
macro_log_feature(Boost_FOUND "Boost" "Boost C++ Libraries" "http://www.boost.org" TRUE "1.34.0" "Required by Akonadi.")
find_package(Akonadi)
macro_log_feature(Akonadi_FOUND "Akonadi" "Akonadi server libraries" "http://pim.kde.org/akonadi" TRUE "" "Akonadi is required to build kdepim-runtime.")
set(SHARED_MIME_INFO_MINIMUM_VERSION "0.30")
find_package(SharedMimeInfo)
macro_log_feature(SHARED_MIME_INFO_FOUND "SMI" "SharedMimeInfo" "http://freedesktop.org/wiki/Software/shared-mime-info" TRUE "0.30" "SharedMimeInfo is required.")
find_package(LibXml2)
macro_log_feature(LIBXML2_FOUND "LibXML2" "Libraries used to develop XML applications" "http://xmlsoft.org" FALSE "" "Needed for building the knut Akonadi resource.")
macro_optional_find_package(Soprano)
macro_log_feature(Soprano_FOUND "Soprano" "Semantic Desktop Storing" "http://soprano.sourceforge.net" FALSE "" "Soprano is needed for Nepomuk")
macro_optional_find_package(Nepomuk)
macro_log_feature(Nepomuk_FOUND "Nepomuk" "The Nepomuk libraries" "http://www.kde.org" FALSE "" "Nepomuk extends the search and tagging functionalities in KMail and Akonadi")
find_package(Strigi)
macro_log_feature(STRIGI_FOUND "Strigi" "Index metadata of files" "http://strigi.sourceforge.net" FALSE "" "")
############### search programs & libraries used by kdepim-runtime ###############
find_program(XSLTPROC_EXECUTABLE xsltproc)
macro_log_feature(XSLTPROC_EXECUTABLE "xsltproc" "The command line XSLT processor from libxslt" "http://xmlsoft.org/XSLT/" TRUE "" "Required for building Akonadi.")
find_library(STRIGIQTDBUSCLIENT_LIBRARY NAMES strigiqtdbusclient
PATHS
/usr/lib
/usr/local/lib
${LIB_INSTALL_DIR}
$ENV{STRIGI_HOME}/lib
)
macro_log_feature(STRIGIQTDBUSCLIENT_LIBRARY "strigi indexing" "Strigi built with indexing" "http://strigi.sourceforge.net/" FALSE "" "For Akonadi tools such as the message searchprovider")
############### Needed commands before building anything ###############
include_directories(${kdepim-runtime_SOURCE_DIR} ${kdepim-runtime_BINARY_DIR} ${AKONADI_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${KDE4_INCLUDES} ${KDEPIMLIBS_INCLUDE_DIRS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}")
############### Generate akonadi-config.h ###############
configure_file(akonadi-version.h.cmake "${kdepim-runtime_BINARY_DIR}/akonadi-version.h" @ONLY)
############### Macros ###############
# generates a D-Bus interface description from a KConfigXT file
macro(kcfg_generate_dbus_interface _kcfg _name)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
COMMAND ${XSLTPROC_EXECUTABLE} --stringparam interfaceName ${_name}
${KDEPIMLIBS_DATA_DIR}/akonadi-kde/kcfg2dbus.xsl
${_kcfg}
> ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
DEPENDS ${KDEPIMLIBS_DATA_DIR}/akonadi-kde/kcfg2dbus.xsl
${_kcfg}
)
endmacro(kcfg_generate_dbus_interface)
# resource tests
macro( akonadi_add_resourcetest _testname _script )
if ( ${EXECUTABLE_OUTPUT_PATH} )
set( _exepath ${EXECUTABLE_OUTPUT_PATH} )
else ( ${EXECUTABLE_OUTPUT_PATH} )
set( _exepath ${kdepim-runtime_BINARY_DIR}/resourcetester )
endif ( ${EXECUTABLE_OUTPUT_PATH} )
if (WIN32)
set(_resourcetester ${_exepath}/resourcetester.bat)
else (WIN32)
set(_resourcetester ${_exepath}/resourcetester)
endif (WIN32)
if (UNIX)
set(_resourcetester ${_resourcetester}.shell)
endif (UNIX)
add_test( akonadi-mysql-db-${_testname} akonaditest -c ${kdepim-runtime_SOURCE_DIR}/resourcetester/tests/unittestenv/config-mysql-db.xml ${_resourcetester} -c ${CMAKE_CURRENT_SOURCE_DIR}/${_script} )
endmacro( akonadi_add_resourcetest )
############### Now, we add the components ###############
add_subdirectory(libkdepim-copy)
add_subdirectory(xml)
add_subdirectory(resourcetester)
add_subdirectory(clients)
add_subdirectory(resources)
add_subdirectory(agents)
add_subdirectory(kioslave)
add_subdirectory(plugins)
add_subdirectory(kcal)
add_subdirectory(kcm)
add_subdirectory(tray)
add_subdirectory(migration)
add_subdirectory(defaultsetup)
add_subdirectory(akonadi_next)
add_subdirectory(kresources)
add_subdirectory(akonadiconsole)
add_subdirectory(accountwizard)
#if(OPENSYNC_FOUND)
# add_subdirectory(opensync)
#endif(OPENSYNC_FOUND)
############### Here we install some extra stuff ###############
## install the MIME type spec file for KDEPIM specific MIME types
install(FILES kdepim-mime.xml DESTINATION ${XDG_MIME_INSTALL_DIR})
update_xdg_mimetypes(${XDG_MIME_INSTALL_DIR})
if(CMAKE_SOURCE_DIR STREQUAL "${kdepim-runtime_SOURCE_DIR}")
macro_display_feature_log()
endif(CMAKE_SOURCE_DIR STREQUAL "${kdepim-runtime_SOURCE_DIR}")
add_subdirectory( maildispatcher )
add_subdirectory( invitations )
add_subdirectory( calendarsearch )
if( Nepomuk_FOUND AND STRIGI_FOUND )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/nepomukfeeder ${CMAKE_CURRENT_BINARY_DIR}/ontologies ${STRIGI_INCLUDE_DIR})
set( NEPOMUKFEEDER_SHARED_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/nepomukfeeder/nepomukfeederagentbase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nepomukfeeder/sparqlbuilder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nepomukfeeder/selectsparqlbuilder.cpp
)
set( NEPOMUKFEEDER_SHARED_LIBS
niefast
${SOPRANO_LIBRARIES}
${KDE4_KDEUI_LIBRARY}
${KDE4_KDECORE_LIBS}
${KDEPIMLIBS_AKONADI_LIBS}
${QT_QTCORE_LIBRARY}
${QT_QTDBUS_LIBRARY}
${NEPOMUK_LIBRARIES}
${STRIGI_STREAMANALYZER_LIBRARY}
${STRIGI_STREAMS_LIBRARY}
)
include( SopranoAddOntology )
add_subdirectory( ontologies )
add_subdirectory( nepomukfeeder )
add_subdirectory( nepomuk_contact_feeder )
add_subdirectory( nepomuk_calendar_feeder )
endif( Nepomuk_FOUND AND STRIGI_FOUND )
include_directories(
${kdepim-runtime_SOURCE_DIR}
${Boost_INCLUDE_DIR}
)
set( CALENDARSEARCHAGENT_SRCS calendarsearchagent.cpp )
qt4_add_dbus_adaptor(CALENDARSEARCHAGENT_SRCS org.freedesktop.Akonadi.CalendarSearchAgent.xml calendarsearchagent.h CalendarSearchAgent )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}" )
kde4_add_executable(akonadi_calendarsearch_agent ${CALENDARSEARCHAGENT_SRCS})
target_link_libraries(akonadi_calendarsearch_agent
${KDEPIMLIBS_KCAL_LIBS}
${KDEPIMLIBS_AKONADI_LIBS}
)
install(TARGETS akonadi_calendarsearch_agent ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES calendarsearchagent.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/share/akonadi/agents")
/*
Copyright 2009 KDAB; Author: Frank Osterfeld <osterfeld@kde.org>
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 "calendarsearchagent.h"
#include "calendarsearchagentadaptor.h"
#include <KDateTime>
#include <KDebug>
using namespace Akonadi;
class CalendarSearchAgent::Private
{
CalendarSearchAgent* const q;
public:
explicit Private( CalendarSearchAgent* qq ) : q( qq )
{
}
~Private()
{
}
};
CalendarSearchAgent::CalendarSearchAgent( const QString &id )
: AgentBase( id ),
d( new Private( this ) )
{
new CalendarSearchAgentAdaptor( this );
if ( !QDBusConnection::sessionBus().registerObject( QLatin1String( "/CalendarSearchAgent" ),
this, QDBusConnection::ExportAdaptors ) ) {
kWarning() << "Couldn't register a D-Bus service";
kWarning() << QDBusConnection::sessionBus().lastError().message();
}
}
CalendarSearchAgent::~CalendarSearchAgent()
{
delete d;
}
QVariantMap CalendarSearchAgent::createSearch( const QString& startDateStr, const QString& endDateStr )
{
const KDateTime startDate = KDateTime::fromString( startDateStr );
const KDateTime endDate = KDateTime::fromString( endDateStr );
//setDelayedReply( true );
//TODO start job
return QVariantMap();
}
void CalendarSearchAgent::doSetOnline( bool )
{
}
void CalendarSearchAgent::configure( WId )
{
}
AKONADI_AGENT_MAIN( CalendarSearchAgent )
#include "calendarsearchagent.moc"
[Desktop Entry]
Name=Calendar Search Agent
Type=AkonadiAgent
Exec=akonadi_calendarsearch_agent
Icon=text-calendar
X-Akonadi-MimeTypes=text/calendar
X-Akonadi-Capabilities=Unique,Autostart,NoConfig
X-Akonadi-Identifier=akonadi_calendarsearch_agent
/*
Copyright 2009 KDAB; Author: Frank Osterfeld <osterfeld@kde.org>
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 CALENDARSEARCHAGENT_H
#define CALENDARSEARCHAGENT_H
#include <Akonadi/AgentBase>
#include <QVariantMap>
class CalendarSearchAgent : public Akonadi::AgentBase
{
Q_OBJECT
public:
explicit CalendarSearchAgent( const QString &id );
~CalendarSearchAgent();
QVariantMap createSearch( const QString& startDate, const QString& endDate );
public Q_SLOTS:
/* reimp */
void configure( WId windowId );
protected:
/* reimp */
void doSetOnline( bool online );
private:
class Private;
Private* const d;
};
#endif // CALENDARSEARCHAGENT_H
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.Akonadi.CalendarSearchAgent">
<method name="createSearch">
<arg type="a{sv}" direction="out">
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
</arg>
<arg name="startDate" type="s" direction="in"/>
<arg name="endDate" type="s" direction="in"/>
</method>
</interface>
</node>
set( invitationsagent_SRCS
invitationsagent.cpp
#outboxqueue.cpp
#sendjob.cpp
#storeresultjob.cpp
##configdialog.cpp
)
#kde4_add_ui_files(invitationsagent_SRCS settings.ui)
#kde4_add_kcfg_files(invitationsagent_SRCS settings.kcfgc)
#kcfg_generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/invitationsagent.kcfg org.kde.Akonadi.MailDispatcher.Settings)
#qt4_add_dbus_adaptor(invitationsagent_SRCS
# ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Akonadi.MailDispatcher.Settings.xml settings.h Settings
#)
## qt4_add_dbus_adaptor( invitationsagent_SRCS
## ${KDE4_DBUS_INTERFACES_DIR}/org.kde.Akonadi.MailDispatcher.xml invitationsagent.h MailDispatcherAgent
## )
kde4_add_executable(akonadi_invitations_agent ${invitationsagent_SRCS})
target_link_libraries(akonadi_invitations_agent
${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS}
${KDEPIMLIBS_AKONADI_LIBS}
${KDEPIMLIBS_AKONADI_KMIME_LIBS}
${KDEPIMLIBS_KMIME_LIBS}
${KDEPIMLIBS_MAILTRANSPORT_LIBS}
${KDEPIMLIBS_KCAL_LIBS}
akonadi-kcal
)
install(TARGETS akonadi_invitations_agent ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES invitationsagent.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/share/akonadi/agents")
#! /bin/sh
$XGETTEXT *.cpp -o $podir/akonadi_invitations_agent.pot
/*
Copyright 2009 Sebastian Sauer <sebsauer@kdab.net>
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 "invitationsagent.h"
#include "invitationsagent.moc"
#include <kcal/incidence.h>
#include <kcal/event.h>
#include <kcal/todo.h>
#include <kcal/journal.h>
#include <kcal/calendarlocal.h>
#include <kcal/icalformat.h>
#include <KMime/Message>
#include <KMime/Content>
//#include <kemailsettings.h>
#include <Akonadi/ChangeRecorder>
#include <Akonadi/ItemFetchJob>
#include <Akonadi/ItemFetchScope>
#include <Akonadi/ItemModifyJob>
#include <Akonadi/CollectionFetchJob>
#include <Akonadi/CollectionFetchScope>
#include <Akonadi/CollectionCreateJob>
#include <Akonadi/AgentManager>
#include <Akonadi/AgentInstance>
#include <Akonadi/AgentInstanceCreateJob>
#include <akonadi/resourcesynchronizationjob.h>
#include <akonadi/kcal/incidenceattribute.h>
#include <akonadi/specialcollections.h>
#include <akonadi/specialcollectionsrequestjob.h>
#include <QDBusInterface>
#include <QDBusReply>
#include <QFileInfo>
#include <QTimer>
#include <KDebug>
#include <KSystemTimeZones>
#include <KJob>
#include <KLocale>
#include <KStandardDirs>
#include <KConfig>
#include <KConfigSkeleton>
#include <kpimidentities/identitymanager.h>
AKONADI_AGENT_MAIN( InvitationsAgent )
using namespace Akonadi;
class InvitationsCollectionRequestJob : public SpecialCollectionsRequestJob
{
public:
InvitationsCollectionRequestJob( SpecialCollections* collection, InvitationsAgent *agent ) : SpecialCollectionsRequestJob( collection, agent ) {
setDefaultResourceType( QLatin1String( "akonadi_ical_resource" ) );
QVariantMap options;
options.insert( QLatin1String( "Path" ), KGlobal::dirs()->localxdgdatadir() + "akonadi_invitations" );
options.insert( QLatin1String( "Name" ), i18n("Invitations") );
setDefaultResourceOptions( options );
QMap<QByteArray, QString> displayNameMap;
displayNameMap.insert( "invitations", i18n("Invitations") );
setTypes( displayNameMap.keys() );
setNameForTypeMap( displayNameMap );
QMap<QByteArray, QString> iconNameMap;
iconNameMap.insert( "invitations", QLatin1String( "folder" ) );
setIconForTypeMap( iconNameMap );
}
virtual ~InvitationsCollectionRequestJob() {}
};
class InvitationsCollection : public SpecialCollections
{
public:
class Settings : public KCoreConfigSkeleton
{
public:
Settings() : KCoreConfigSkeleton() {
setCurrentGroup("Invitations");
addItemString("DefaultResourceId", m_id, QString());
}
virtual ~Settings() {}
private:
QString m_id;
};
InvitationsCollection( InvitationsAgent *agent ) : Akonadi::SpecialCollections( new Settings ), m_agent( agent ), sInvitationsType( "invitations" ) {}
virtual ~InvitationsCollection() {}
/*
bool registerCollection( const Collection &collection ) {
return SpecialCollections::registerCollection( sInvitationsType, collection );
}
*/
void clear() {
m_collection = Collection();
}
bool hasDefaultCollection() const {
return SpecialCollections::hasDefaultCollection( sInvitationsType );
}
Collection defaultCollection() const {
if( ! m_collection.isValid() )
m_collection = SpecialCollections::defaultCollection( sInvitationsType );
return m_collection;
}
void registerDefaultCollection() {
// Q_ASSERT( m_collection.isValid() );
defaultCollection();
registerCollection( sInvitationsType, m_collection );
}
SpecialCollectionsRequestJob* reguestJob() const {
InvitationsCollectionRequestJob *j = new InvitationsCollectionRequestJob( const_cast<InvitationsCollection*>(this), m_agent );
j->requestDefaultCollection( sInvitationsType );
return j;
}
private:
InvitationsAgent *m_agent;
const QByteArray sInvitationsType;
mutable Collection m_collection;
};
InvitationsAgentItem::InvitationsAgentItem(InvitationsAgent *a, const Item &originalItem)
: QObject(a), a(a), originalItem(originalItem)
{
}
InvitationsAgentItem::~InvitationsAgentItem()
{
}
void InvitationsAgentItem::add(const Item &newItem)
{
kDebug();
Collection c = a->collection();
Q_ASSERT( c.isValid() );
ItemCreateJob *j = new ItemCreateJob( newItem, c, this );
jobs << j;
connect( j, SIGNAL( result( KJob* ) ), this, SLOT( createItemResult( KJob* ) ) );
j->start();
}
void InvitationsAgentItem::createItemResult( KJob *job )
{
ItemCreateJob *j = static_cast<ItemCreateJob*>( job );
jobs.removeAll( j );
if( j->error() ) {
kWarning() << "Failed to create new Item in invitations collection." << j->errorText();
return;
}
if( ! jobs.isEmpty() ) {
return;
}
ItemFetchJob *fj = new ItemFetchJob( originalItem, this );
connect( fj, SIGNAL( result( KJob* ) ), this, SLOT( fetchItemDone( KJob* ) ) );
fj->start();
}
void InvitationsAgentItem::fetchItemDone( KJob *job )
{
if( job->error() ) {
kWarning() << "Failed to fetch Item in invitations collection." << job->errorText();
return;
}
ItemFetchJob *fj = static_cast<ItemFetchJob*>( job );
Q_ASSERT( fj->items().count() == 1 );
Item modifiedItem = fj->items().first();
Q_ASSERT( modifiedItem.isValid() );
modifiedItem.setFlag( "invitation" );
ItemModifyJob *mj = new ItemModifyJob( modifiedItem, this );
connect( mj, SIGNAL( result( KJob* ) ), this, SLOT( modifyItemDone( KJob* ) ) );
mj->start();
}
void InvitationsAgentItem::modifyItemDone( KJob *job )
{
if( job->error() ) {
kWarning() << "Failed to modify Item in invitations collection." << job->errorText();
return;
}
//ItemModifyJob *mj = static_cast<ItemModifyJob*>( job );
//kDebug()<<"Job successful done.";
}
InvitationsAgent::InvitationsAgent( const QString &id )
: AgentBase( id ), AgentBase::ObserverV2()
, m_InvitationsCollection( new InvitationsCollection(this) )
{
kDebug();
KGlobal::locale()->insertCatalog( "akonadi_invitations_agent" );
changeRecorder()->setChangeRecordingEnabled( false ); // behave like Monitor
changeRecorder()->itemFetchScope().fetchFullPayload();
changeRecorder()->setMimeTypeMonitored( "message/rfc822", true );
//changeRecorder()->setCollectionMonitored( Collection::root(), true );
connect( this, SIGNAL(reloadConfiguration()), this, SLOT(initStart()) );
QTimer::singleShot( 0, this, SLOT(initStart()) );
}