summaryrefslogtreecommitdiff
path: root/salut/plugin.h
blob: 038afa5fa563962e8dff78e451d29abb1ffaa20f (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
 * plugin.h — plugin API for telepathy-salut plugins
 * Copyright © 2009-2011 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 SALUT_PLUGINS_PLUGIN_H
#define SALUT_PLUGINS_PLUGIN_H

#include <glib-object.h>

#include <telepathy-glib/telepathy-glib.h>

#include <wocky/wocky.h>

#include <salut/plugin-connection.h>
#include <salut/sidecar.h>

G_BEGIN_DECLS

#define SALUT_TYPE_PLUGIN (salut_plugin_get_type ())
#define SALUT_PLUGIN(obj) \
    (G_TYPE_CHECK_INSTANCE_CAST ((obj), SALUT_TYPE_PLUGIN, SalutPlugin))
#define SALUT_IS_PLUGIN(obj) \
    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SALUT_TYPE_PLUGIN))
#define SALUT_PLUGIN_GET_INTERFACE(obj) \
    (G_TYPE_INSTANCE_GET_INTERFACE ((obj), SALUT_TYPE_PLUGIN, \
        SalutPluginInterface))

typedef struct _SalutPlugin SalutPlugin;
typedef struct _SalutPluginInterface SalutPluginInterface;

typedef void (*SalutPluginCreateSidecarImpl) (
    SalutPlugin *plugin,
    const gchar *sidecar_interface,
    SalutPluginConnection *connection,
    WockySession *session,
    GAsyncReadyCallback callback,
    gpointer user_data);

typedef SalutSidecar * (*SalutPluginCreateSidecarFinishImpl) (
    SalutPlugin *plugin,
    GAsyncResult *result,
    GError **error);

/* The caller of this function takes ownership of the returned
 * GPtrArray and the channel managers inside the array. This has the
 * same semantics as TpBaseConnectionCreateChannelManagersImpl. */
typedef GPtrArray * (*SalutPluginCreateChannelManagersImpl) (
    SalutPlugin *plugin,
    SalutPluginConnection *plugin_connection);

typedef struct _SalutPluginInitializeCallbacks SalutPluginInitializeCallbacks;

typedef TpBaseProtocol * (*SalutCreateProtocolImpl) (GType backend_type,
    const gchar *dnssd_name,
    const gchar *protocol_name,
    const gchar *english_name,
    const gchar *icon_name);

struct _SalutPluginInitializeCallbacks {
  SalutCreateProtocolImpl create_protocol;
  GCallback _padding[7];
};

typedef void (*SalutPluginInitializeImpl) (
    SalutPlugin *plugin,
    TpBaseConnectionManager *connection_manager,
    const SalutPluginInitializeCallbacks *callbacks);

#define SALUT_PLUGIN_CURRENT_VERSION 1

struct _SalutPluginInterface
{
  GTypeInterface parent;

  /**
   * The version of the SalutPluginInterface struct design. The
   * current version is at %SALUT_PLUGIN_CURRENT_VERSION.
   */
  guint api_version;

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

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

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

  /**
   * An implementation of salut_plugin_create_sidecar_async().
   */
  SalutPluginCreateSidecarImpl create_sidecar_async;

  /**
   * An implementation of salut_plugin_create_sidecar_async_finish().
   */
  SalutPluginCreateSidecarFinishImpl create_sidecar_finish;

  /**
   * An implementation of salut_plugin_initialize().
   */
  SalutPluginInitializeImpl initialize;

  /**
   * An implementation of salut_plugin_create_channel_managers().
   */
  SalutPluginCreateChannelManagersImpl create_channel_managers;

  GCallback _padding[7];
};

GType salut_plugin_get_type (void);

const gchar * salut_plugin_get_name (
    SalutPlugin *plugin);
const gchar * salut_plugin_get_version (
    SalutPlugin *plugin);
const gchar * const *salut_plugin_get_sidecar_interfaces (
    SalutPlugin *plugin);

gboolean salut_plugin_implements_sidecar (
    SalutPlugin *plugin,
    const gchar *sidecar_interface);

void salut_plugin_create_sidecar_async (
    SalutPlugin *plugin,
    const gchar *sidecar_interface,
    SalutPluginConnection *connection,
    WockySession *session,
    GAsyncReadyCallback callback,
    gpointer user_data);

SalutSidecar * salut_plugin_create_sidecar_finish (
    SalutPlugin *plugin,
    GAsyncResult *result,
    GError **error);

void salut_plugin_initialize (
    SalutPlugin *plugin,
    TpBaseConnectionManager *connection_manager,
    const SalutPluginInitializeCallbacks *callbacks);

GPtrArray * salut_plugin_create_channel_managers (
    SalutPlugin *plugin,
    SalutPluginConnection *plugin_connection);

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

typedef SalutPlugin * (*SalutPluginCreateImpl) (void);

G_END_DECLS

#endif