File indexing completed on 2024-06-16 04:50:34

0001 /***************************************************************************
0002  *   SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org>            *
0003  *                                                                         *
0004  *   SPDX-License-Identifier: LGPL-2.0-or-later                            *
0005  ***************************************************************************/
0006 
0007 #pragma once
0008 
0009 #include <QtGlobal>
0010 
0011 class QByteArray;
0012 class QString;
0013 
0014 namespace Akonadi
0015 {
0016 namespace Server
0017 {
0018 /**
0019  * This interface can be reimplemented to deliver tracing information
0020  * of the akonadi server to the outside.
0021  *
0022  * Possible implementations:
0023  *   - log file
0024  *   - dbus signals
0025  *   - live gui
0026  */
0027 class TracerInterface
0028 {
0029 public:
0030     enum ConnectionFormat {
0031         DebugString,
0032         Json,
0033     };
0034 
0035     virtual ~TracerInterface() = default;
0036 
0037     /**
0038      * This method is called whenever a new data (imap) connection to the akonadi server
0039      * is established.
0040      *
0041      * @param identifier The unique identifier for this connection. All input and output
0042      *                   messages for this connection will have the same identifier.
0043      *
0044      * @param msg A message specific string.
0045      */
0046     virtual void beginConnection(const QString &identifier, const QString &msg) = 0;
0047 
0048     /**
0049      * This method is called whenever a data (imap) connection to akonadi server is
0050      * closed.
0051      *
0052      * @param identifier The unique identifier of this connection.
0053      * @param msg A message specific string.
0054      */
0055     virtual void endConnection(const QString &identifier, const QString &msg) = 0;
0056 
0057     /**
0058      * This method is called whenever the akonadi server retrieves some data from the
0059      * outside.
0060      *
0061      * @param identifier The unique identifier of the connection on which the data
0062      *                   is retrieved.
0063      * @param msg A message specific string.
0064      */
0065     virtual void connectionInput(const QString &identifier, const QByteArray &msg) = 0;
0066 
0067     /**
0068      * This method is called whenever the akonadi server sends some data out to a client.
0069      *
0070      * @param identifier The unique identifier of the connection on which the
0071      *                   data is send.
0072      * @param msg A message specific string.
0073      */
0074     virtual void connectionOutput(const QString &identifier, const QByteArray &msg) = 0;
0075 
0076     /**
0077      * This method is called whenever a dbus signal is emitted on the bus.
0078      *
0079      * @param signalName The name of the signal being sent.
0080      * @param msg A message specific string.
0081      */
0082     virtual void signal(const QString &signalName, const QString &msg) = 0;
0083 
0084     /**
0085      * This method is called whenever a component wants to output a warning.
0086      */
0087     virtual void warning(const QString &componentName, const QString &msg) = 0;
0088 
0089     /**
0090      * This method is called whenever a component wants to output an error.
0091      */
0092     virtual void error(const QString &componentName, const QString &msg) = 0;
0093 
0094     virtual ConnectionFormat connectionFormat() const
0095     {
0096         return DebugString;
0097     }
0098 
0099 protected:
0100     explicit TracerInterface() = default;
0101 
0102 private:
0103     Q_DISABLE_COPY_MOVE(TracerInterface)
0104 };
0105 
0106 } // namespace Server
0107 } // namespace Akonadi