summaryrefslogtreecommitdiff
path: root/decorators/libdecorator/duirmiserver.h
blob: 9530a3f7a8493193254394ddb2442f5486b29266 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of duicompositor.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
// -*- C++ -*-

#ifndef DUIRMISERVER_H
#define DUIRMISERVER_H

#include <QObject>

#include "duiexport.h"

class DuiRmiServerPrivate;
class DuiRmiServerPrivateSocket;

/*!
 * \class DuiRmiServer
 * \brief The DuiRmiServer provides a way for member functions of QObject-based
 * classes to be directly invoked from another process without relying on an
 * external transport such as d-bus.
 *
 * To make a QObject-based class remotely callable from another process,
 * ensure that the object has Q_OBJECT macro and the member functions you want
 * to export are public slots themselves.
 *
 * The types of the arguments of those member functions need to be supported
 * by QVariant as well. Most Qt types are supported. This include from plain
 * old data types to complex GUI types such as QRect, QColor, QImages, and more.
 * Container types such as QList are even supported.
 *
 * If needed, custom complex classes can also be sent across the wire
 * provided the operator QVariant(), operator<<() and
 * operator>>() are overloaded, and the class is declared in Qt's metaobject
 * system using qRegisterMetaType(). Qt uses this class internally for
 * mashalling/unmarshalling types (see QMetaType for details).
 */
class DUI_EXPORT DuiRmiServer: public QObject
{
  Q_OBJECT

public:
    /*!
     * Creates a DuiRmiServer
     *
     * \param key a unique key that identifies this server
     * \param parent QObject.
     */
    explicit DuiRmiServer(const QString& key, QObject* parent = 0);

    /*!
     * Disconnects all connections and destroys this object
     */
    virtual ~DuiRmiServer();

    /*!
     * Export a QObject for remote invocation. Currently only one QObject per
     * DuiRmiServer is supported.
     *
     * \param object QObject to be exported.
     */
    void exportObject(QObject* object);

private:
    Q_DISABLE_COPY(DuiRmiServer)
    Q_DECLARE_PRIVATE(DuiRmiServer)
    Q_PRIVATE_SLOT(d_func(), void _q_incoming())
    Q_PRIVATE_SLOT(d_func(), void _q_readData())

    DuiRmiServerPrivate * const d_ptr;
    friend class DuiRmiServerPrivateSocket;
};

#endif