Commit c90b946d authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Wrap all classes in /server to Akonadi::Server namespace

Since we now support loading of plugins, having only Akonadi namespace
might not be enough, as plugins can easily clash (like Akonadi::TagAttribute
from Akonadi and from kdepimlibs). It will also make it easier to differentiate
classes once both server and client libs are in the same repo in KF5.
parent 63bae3b1
......@@ -218,16 +218,16 @@ endif()
qt4_generate_dbus_interface(src/debuginterface.h org.freedesktop.Akonadi.DebugInterface.xml)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.TracerNotification.xml dbustracer.h Akonadi::DBusTracer)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.Tracer.xml tracer.h Akonadi::Tracer)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.NotificationManager.xml notificationmanager.h Akonadi::NotificationManager)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.Server.xml akonadi.h Akonadi::AkonadiServer)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.NotificationSource.xml notificationsource.h Akonadi::NotificationSource)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.StorageDebugger.xml storage/storagedebugger.h Akonadi::StorageDebugger)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Akonadi.DebugInterface.xml debuginterface.h DebugInterface)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.ResourceManager.xml resourcemanager.h Akonadi::ResourceManager)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.PreprocessorManager.xml preprocessormanager.h Akonadi::PreprocessorManager)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.SearchManager.xml search/searchmanager.h Akonadi::SearchManager)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.TracerNotification.xml dbustracer.h Akonadi::Server::DBusTracer)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.Tracer.xml tracer.h Akonadi::Server::Tracer)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.NotificationManager.xml notificationmanager.h Akonadi::Server::NotificationManager)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.Server.xml akonadi.h Akonadi::Server::AkonadiServer)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.NotificationSource.xml notificationsource.h Akonadi::Server::NotificationSource)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.StorageDebugger.xml storage/storagedebugger.h Akonadi::Server::StorageDebugger)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Akonadi.DebugInterface.xml debuginterface.h Akonadi::Server::DebugInterface)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.ResourceManager.xml resourcemanager.h Akonadi::Server::ResourceManager)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.PreprocessorManager.xml preprocessormanager.h Akonadi::Server::PreprocessorManager)
qt4_add_dbus_adaptor(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.SearchManager.xml search/searchmanager.h Akonadi::Server::SearchManager)
qt4_add_dbus_interfaces(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.AgentManager.xml ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.Resource.xml)
qt4_add_dbus_interface(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.Preprocessor.xml preprocessorinterface)
qt4_add_dbus_interface(libakonadiprivate_SRCS ${Akonadi_SOURCE_DIR}/interfaces/org.freedesktop.Akonadi.Agent.Control.xml agentcontrolinterface)
......
......@@ -64,6 +64,7 @@
#endif
using namespace Akonadi;
using namespace Akonadi::Server;
static AkonadiServer *s_instance = 0;
......@@ -83,7 +84,7 @@ AkonadiServer::AkonadiServer( QObject *parent )
void AkonadiServer::init()
{
qRegisterMetaType<Akonadi::Response>();
qRegisterMetaType<Akonadi::Server::Response>();
const QString serverConfigFile = AkStandardDirs::serverConfigFile( XdgBaseDirs::ReadWrite );
QSettings settings( serverConfigFile, QSettings::IniFormat );
......
......@@ -25,17 +25,18 @@
#include <QtNetwork/QLocalServer>
class StorageJanitorThread;
class QProcess;
class IntervalCheck;
namespace Akonadi {
namespace Server {
class AkonadiConnection;
class CacheCleaner;
class SearchManager;
class ItemRetrievalThread;
class SearchTaskManagerThread;
class StorageJanitorThread;
class IntervalCheck;
class AkonadiServer : public QLocalServer
{
......@@ -78,5 +79,6 @@ class AkonadiServer : public QLocalServer
bool mAlreadyShutdown;
};
}
} // namespace Server
} // namespace Akonadi
#endif
......@@ -40,7 +40,7 @@
#define AKONADI_PROTOCOL_VERSION "36"
using namespace Akonadi;
using namespace Akonadi::Server;
AkonadiConnection::AkonadiConnection( quintptr socketDescriptor, QObject *parent )
: QThread( parent )
......@@ -60,7 +60,7 @@ AkonadiConnection::AkonadiConnection( quintptr socketDescriptor, QObject *parent
m_verifyCacheOnRetrieval = settings.value( QLatin1String( "Cache/VerifyOnRetrieval" ), m_verifyCacheOnRetrieval ).toBool();
}
DataStore *Akonadi::AkonadiConnection::storageBackend()
DataStore *AkonadiConnection::storageBackend()
{
if ( !m_backend ) {
m_backend = DataStore::self();
......@@ -111,7 +111,9 @@ void AkonadiConnection::run()
// don't send before the event loop is active, since waitForBytesWritten() can cause interesting reentrancy issues
// TODO should be QueueConnection, but unfortunately that doesn't work (yet), since
// "this" belongs to the wrong thread, but that requires a slightly larger refactoring
QMetaObject::invokeMethod( this, "slotResponseAvailable", Qt::DirectConnection, Q_ARG( Akonadi::Response, greeting ) );
QMetaObject::invokeMethod( this, "slotResponseAvailable",
Qt::DirectConnection,
Q_ARG( Akonadi::Server::Response, greeting ) );
exec();
delete m_socket;
......@@ -141,13 +143,13 @@ void AkonadiConnection::slotNewData()
}
const QByteArray command = m_streamParser->readString();
if ( command.isEmpty() ) {
throw Akonadi::Exception("empty command");
throw Akonadi::Server::Exception("empty command");
}
Tracer::self()->connectionInput( m_identifier, ( tag + ' ' + command + ' ' + m_streamParser->readRemainingData() ) );
m_currentHandler = findHandlerForCommand( command );
assert( m_currentHandler );
connect( m_currentHandler, SIGNAL(responseAvailable(Akonadi::Response)),
this, SLOT(slotResponseAvailable(Akonadi::Response)), Qt::DirectConnection );
connect( m_currentHandler, SIGNAL(responseAvailable(Akonadi::Server::Response)),
this, SLOT(slotResponseAvailable(Akonadi::Server::Response)), Qt::DirectConnection );
connect( m_currentHandler, SIGNAL(connectionStateChange(ConnectionState)),
this, SLOT(slotConnectionStateChange(ConnectionState)),
Qt::DirectConnection );
......@@ -156,12 +158,12 @@ void AkonadiConnection::slotNewData()
if ( !m_currentHandler->parseStream() ) {
m_streamParser->skipCurrentCommand();
}
} catch ( const Akonadi::HandlerException &e ) {
} catch ( const Akonadi::Server::HandlerException &e ) {
m_currentHandler->failureResponse( e.what() );
try {
m_streamParser->skipCurrentCommand();
} catch ( ... ) {}
} catch ( const Akonadi::Exception &e ) {
} catch ( const Akonadi::Server::Exception &e ) {
if ( m_currentHandler ) {
m_currentHandler->failureResponse( QByteArray( e.type() ) + QByteArray( ": " ) + QByteArray( e.what() ) );
}
......@@ -225,7 +227,7 @@ Handler *AkonadiConnection::findHandlerForCommand( const QByteArray &command )
return handler;
}
void AkonadiConnection::slotResponseAvailable( const Akonadi::Response &response )
void AkonadiConnection::slotResponseAvailable( const Response &response )
{
// FIXME handle reentrancy in the presence of continuation. Something like:
// "if continuation pending, queue responses, once continuation is done, replay them"
......@@ -252,27 +254,27 @@ void AkonadiConnection::slotConnectionStateChange( ConnectionState state )
}
}
qint64 Akonadi::AkonadiConnection::selectedCollectionId() const
qint64 AkonadiConnection::selectedCollectionId() const
{
return m_selectedConnection;
}
void Akonadi::AkonadiConnection::setSelectedCollection( qint64 collection )
void AkonadiConnection::setSelectedCollection( qint64 collection )
{
m_selectedConnection = collection;
}
const Collection Akonadi::AkonadiConnection::selectedCollection()
const Collection AkonadiConnection::selectedCollection()
{
return Collection::retrieveById( selectedCollectionId() );
}
void Akonadi::AkonadiConnection::addStatusMessage( const QByteArray &msg )
void AkonadiConnection::addStatusMessage( const QByteArray &msg )
{
m_statusMessageQueue.append( msg );
}
void Akonadi::AkonadiConnection::flushStatusMessageQueue()
void AkonadiConnection::flushStatusMessageQueue()
{
for ( int i = 0; i < m_statusMessageQueue.count(); ++i ) {
Response response;
......@@ -301,7 +303,7 @@ QByteArray AkonadiConnection::sessionId() const
return m_sessionId;
}
Resource Akonadi::AkonadiConnection::resourceContext() const
Resource AkonadiConnection::resourceContext() const
{
return m_resourceContext;
}
......
......@@ -28,11 +28,13 @@
#include "clientcapabilities.h"
namespace Akonadi {
class Handler;
class Response;
class DataStore;
class Collection;
class ImapStreamParser;
namespace Server {
class Handler;
class Response;
class DataStore;
class Collection;
class ImapStreamParser;
/**
An AkonadiConnection represents one connection of a client to the server.
......@@ -77,7 +79,7 @@ protected Q_SLOTS:
* New data arrived from the client. Creates a handler for it and passes the data to the handler.
*/
void slotNewData();
void slotResponseAvailable( const Akonadi::Response &response );
void slotResponseAvailable( const Akonadi::Server::Response &response );
void slotConnectionStateChange( ConnectionState );
protected:
......@@ -101,6 +103,7 @@ private:
bool m_verifyCacheOnRetrieval;
};
}
} // namespace Server
} // namespace Akonadi
#endif
......@@ -28,7 +28,7 @@
#include <QDebug>
#include <QTimer>
using namespace Akonadi;
using namespace Akonadi::Server;
CacheCleaner::CacheCleaner( QObject *parent )
: QThread( parent )
......
......@@ -23,6 +23,7 @@
#include <QtCore/QThread>
namespace Akonadi {
namespace Server {
/**
Cache cleaner thread.
......@@ -52,6 +53,7 @@ class CacheCleaner : public QThread
};
}
} // namespace Server
} // namespace Akonadi
#endif
......@@ -19,6 +19,8 @@
#include "clientcapabilities.h"
using namespace Akonadi::Server;
ClientCapabilities::ClientCapabilities()
: m_notificationMessageVersion( 0 )
, m_noPayloadPath( false )
......
......@@ -19,8 +19,12 @@
#include "capability.h"
#ifndef CLIENTCAPABILITIES_H
#define CLIENTCAPABILITIES_H
#ifndef AKONADI_CLIENTCAPABILITIES_H
#define AKONADI_CLIENTCAPABILITIES_H
namespace Akonadi {
namespace Server {
/** Describes the capabilities of a specific session.
Filled by the CAPABILITY command.
......@@ -54,4 +58,7 @@ private:
int m_akAppendStreaming : 1;
};
} // namespace Server
} // namespace Akonadi
#endif // CLIENTCAPABILITIES_H
......@@ -20,6 +20,9 @@
#include "clientcapabilityaggregator.h"
#include <QVector>
#include <QMutex>
using namespace Akonadi::Server;
struct ClientCapabilityAggregatorData
{
......
......@@ -22,7 +22,8 @@
#include "clientcapabilities.h"
#include <QMutex>
namespace Akonadi {
namespace Server {
/** Aggregates client capabilities of all active sessions. */
namespace ClientCapabilityAggregator
......@@ -39,4 +40,7 @@ namespace ClientCapabilityAggregator
int maximumNotificationMessageVersion();
}
} // namespace Server
} // namespace Akonadi
#endif // CLIENTCAPABILITYAGGREGATOR_H
......@@ -20,7 +20,7 @@
#include "dbustracer.h"
#include "tracernotificationadaptor.h"
using namespace Akonadi;
using namespace Akonadi::Server;
DBusTracer::DBusTracer()
: QObject( 0 )
......
......@@ -25,6 +25,7 @@
#include "tracerinterface.h"
namespace Akonadi {
namespace Server {
/**
* A tracer which forwards all tracing information as dbus signals.
......@@ -55,6 +56,7 @@ class DBusTracer : public QObject, public TracerInterface
void errorEmitted( const QString &componentName, const QString &msg );
};
}
} // namespace Server
} // namespace Akonadi
#endif
......@@ -20,10 +20,10 @@
#include "debuginterface.h"
#include "debuginterfaceadaptor.h"
#include "tracer.h"
using Akonadi::Tracer;
#include <QtDBus>
using namespace Akonadi::Server;
DebugInterface::DebugInterface( QObject *parent )
: QObject( parent )
{
......
......@@ -22,6 +22,9 @@
#include <QObject>
namespace Akonadi {
namespace Server {
/**
* Interface to configure and query debugging options.
*/
......@@ -39,4 +42,7 @@ class DebugInterface : public QObject
};
} // namespace Server
} // namespace Akonadi
#endif
......@@ -25,6 +25,7 @@
#include <exception>
namespace Akonadi {
namespace Server {
/**
Base class for exception used internally by the Akonadi server.
......@@ -59,19 +60,19 @@ class Exception : public std::exception
};
#define AKONADI_EXCEPTION_MAKE_INSTANCE( classname ) \
class classname : public Akonadi::Exception \
class classname : public Akonadi::Server::Exception \
{ \
public: \
classname ( const char *what ) throw() \
: Akonadi::Exception( what ) \
: Akonadi::Server::Exception( what ) \
{ \
} \
classname ( const QByteArray &what ) throw() \
: Akonadi::Exception( what ) \
: Akonadi::Server::Exception( what ) \
{ \
} \
classname ( const QString &what ) throw() \
: Akonadi::Exception( what ) \
: Akonadi::Server::Exception( what ) \
{ \
} \
const char *type() const throw() \
......@@ -80,6 +81,7 @@ class classname : public Akonadi::Exception \
} \
}
}
} // namespace Server
} // namespace Akonadi
#endif
......@@ -21,7 +21,7 @@
#include <QtCore/QFile>
#include <QtCore/QTime>
using namespace Akonadi;
using namespace Akonadi::Server;
FileTracer::FileTracer( const QString &fileName )
{
......
......@@ -25,6 +25,7 @@
class QFile;
namespace Akonadi {
namespace Server {
/**
* A tracer which forwards all tracing information to a
......@@ -50,6 +51,7 @@ class FileTracer : public TracerInterface
QFile *m_file;
};
}
} // namespace Server
} // namespace Akonadi
#endif
......@@ -20,6 +20,7 @@
#define GLOBAL_H
namespace Akonadi {
namespace Server {
// rfc1730 section 3
/** The state of the client
......@@ -31,6 +32,7 @@ namespace Akonadi {
LoggingOut
};
}
} // namespace Server
} // namespace Akonadi
#endif
......@@ -61,7 +61,7 @@
#include "storage/querybuilder.h"
#include "imapstreamparser.h"
using namespace Akonadi;
using namespace Akonadi::Server;
Handler::Handler()
: QObject()
......@@ -216,17 +216,17 @@ Handler *Handler::findHandlerForCommandAuthenticated( const QByteArray &_command
return 0;
}
void Akonadi::Handler::setConnection( AkonadiConnection *connection )
void Handler::setConnection( AkonadiConnection *connection )
{
m_connection = connection;
}
AkonadiConnection *Akonadi::Handler::connection() const
AkonadiConnection *Handler::connection() const
{
return m_connection;
}
bool Akonadi::Handler::failureResponse( const QByteArray &failureMessage )
bool Handler::failureResponse( const QByteArray &failureMessage )
{
Response response;
response.setTag( tag() );
......@@ -236,7 +236,7 @@ bool Akonadi::Handler::failureResponse( const QByteArray &failureMessage )
return false;
}
bool Akonadi::Handler::failureResponse( const char *failureMessage )
bool Handler::failureResponse( const char *failureMessage )
{
return failureResponse( QByteArray( failureMessage ) );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment