summaryrefslogtreecommitdiff
path: root/gabble/plugin.h
blob: 59ca1fddc4e51af66edbaf76306dc80e627457f7 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
 * plugin.h — plugin API for telepathy-gabble plugins
 * Copyright © 2009 Collabora Ltd.
 * Copyright © 2009 Nokia Corporation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef __GABBLE_PLUGINS_PLUGIN_H__
#define __GABBLE_PLUGINS_PLUGIN_H__

#include <glib-object.h>
#include <gio/gio.h>

#include <telepathy-glib/base-connection.h>
#include <wocky/wocky-session.h>

#include <gabble/connection.h>
#include <gabble/sidecar.h>
#include <gabble/types.h>

G_BEGIN_DECLS

#define GABBLE_TYPE_PLUGIN (gabble_plugin_get_type ())
#define GABBLE_PLUGIN(obj) \
    (G_TYPE_CHECK_INSTANCE_CAST ((obj), GABBLE_TYPE_PLUGIN, GabblePlugin))
#define GABBLE_IS_PLUGIN(obj) \
    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GABBLE_TYPE_PLUGIN))
#define GABBLE_PLUGIN_GET_INTERFACE(obj) \
    (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GABBLE_TYPE_PLUGIN, \
        GabblePluginInterface))

typedef struct _GabblePluginInterface GabblePluginInterface;

typedef void (*GabblePluginCreateSidecarImpl) (
    GabblePlugin *plugin,
    const gchar *sidecar_interface,
    GabbleConnection *connection,
    WockySession *session,
    GAsyncReadyCallback callback,
    gpointer user_data);

struct _GabblePluginInterface {
    GTypeInterface parent;

    /**
     * An arbitrary human-readable name identifying this plugin.
     */
    const gchar *name;

    /**
     * A %NULL-terminated array of strings listing the sidecar D-Bus interfaces
     * implemented by this plugin.
     */
    const gchar * const *sidecar_interfaces;

    /**
     * An implementation of gabble_plugin_create_sidecar().
     */
    GabblePluginCreateSidecarImpl create_sidecar;

    /**
     * The plugin's version, conventionally a "."-separated sequence of
     * numbers.
     */
    const gchar *version;
};

GType gabble_plugin_get_type (void);

const gchar *gabble_plugin_get_name (
    GabblePlugin *plugin);
const gchar *gabble_plugin_get_version (
    GabblePlugin *plugin);
const gchar * const *gabble_plugin_get_sidecar_interfaces (
    GabblePlugin *plugin);

gboolean gabble_plugin_implements_sidecar (
    GabblePlugin *plugin,
    const gchar *sidecar_interface);

void gabble_plugin_create_sidecar (
    GabblePlugin *plugin,
    const gchar *sidecar_interface,
    GabbleConnection *connection,
    WockySession *session,
    GAsyncReadyCallback callback,
    gpointer user_data);

GabbleSidecar *gabble_plugin_create_sidecar_finish (
    GabblePlugin *plugin,
    GAsyncResult *result,
    GError **error);

/**
 * gabble_plugin_create:
 *
 * Prototype for the plugin entry point.
 *
 * Returns: a new instance of this plugin, which must not be %NULL.
 */
GabblePlugin *gabble_plugin_create (void);

typedef GabblePlugin *(*GabblePluginCreateImpl) (void);

G_END_DECLS

#endif