1 /*
2 * tp-handle-repo-dynamic.h - mechanism to store and retrieve handles on
3 * a connection - implementation for "normal" dynamically-created handles
4 *
5 * Copyright (C) 2005, 2007 Collabora Ltd.
6 * Copyright (C) 2005, 2007 Nokia Corp.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #if defined (TP_DISABLE_SINGLE_INCLUDE) && !defined (_TP_IN_META_HEADER) && !defined (_TP_COMPILATION)
24 #error "Only <telepathy-glib/telepathy-glib.h> and <telepathy-glib/telepathy-glib-dbus.h> can be included directly."
25 #endif
26
27 #ifndef __TP_HANDLE_REPO_DYNAMIC_H__
28 #define __TP_HANDLE_REPO_DYNAMIC_H__
29
30 #include <telepathy-glib/handle-repo.h>
31
32 G_BEGIN_DECLS
33
34 typedef struct _TpDynamicHandleRepo TpDynamicHandleRepo;
35 typedef struct _TpDynamicHandleRepoClass TpDynamicHandleRepoClass;
36
37 typedef gchar *(*TpDynamicHandleRepoNormalizeFunc)(TpHandleRepoIface *repo,
38 const gchar *id, gpointer context, GError **error);
39
40 typedef void (*TpDynamicHandleRepoNormalizeAsync) (TpHandleRepoIface *repo,
41 TpBaseConnection *connection,
42 const gchar *id,
43 gpointer context,
44 GAsyncReadyCallback callback,
45 gpointer user_data);
46 typedef gchar * (*TpDynamicHandleRepoNormalizeFinish) (TpHandleRepoIface *repo,
47 GAsyncResult *result,
48 GError **error);
49
50 GType tp_dynamic_handle_repo_get_type (void);
51
52 #define TP_TYPE_DYNAMIC_HANDLE_REPO \
53 (tp_dynamic_handle_repo_get_type ())
54 #define TP_DYNAMIC_HANDLE_REPO(obj) \
55 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TP_TYPE_DYNAMIC_HANDLE_REPO,\
56 TpDynamicHandleRepo))
57 #define TP_DYNAMIC_HANDLE_REPO_CLASS(klass) \
58 (G_TYPE_CHECK_CLASS_CAST ((klass), TP_TYPE_DYNAMIC_HANDLE_REPO,\
59 TpDynamicHandleRepo))
60 #define TP_IS_DYNAMIC_HANDLE_REPO(obj) \
61 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TP_TYPE_DYNAMIC_HANDLE_REPO))
62 #define TP_IS_DYNAMIC_HANDLE_REPO_CLASS(klass) \
63 (G_TYPE_CHECK_CLASS_TYPE ((klass), TP_TYPE_DYNAMIC_HANDLE_REPO))
64 #define TP_DYNAMIC_HANDLE_REPO_GET_CLASS(obj) \
65 (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_DYNAMIC_HANDLE_REPO,\
66 TpDynamicHandleRepoClass))
67
68 TpHandle tp_dynamic_handle_repo_lookup_exact (TpHandleRepoIface *irepo,
69 const char *id);
70
71 static inline
72 /* spacer so gtkdoc documents this function as though not static */
73 TpHandleRepoIface *tp_dynamic_handle_repo_new (TpHandleType handle_type,
74 TpDynamicHandleRepoNormalizeFunc normalize_func,
75 gpointer default_normalize_context);
76
77 static inline TpHandleRepoIface *
tp_dynamic_handle_repo_new(TpHandleType handle_type,TpDynamicHandleRepoNormalizeFunc normalize_func,gpointer default_normalize_context)78 tp_dynamic_handle_repo_new (TpHandleType handle_type,
79 TpDynamicHandleRepoNormalizeFunc normalize_func,
80 gpointer default_normalize_context)
81 {
82 return (TpHandleRepoIface *) g_object_new (TP_TYPE_DYNAMIC_HANDLE_REPO,
83 "handle-type", (guint)handle_type,
84 "normalize-function", (gpointer)normalize_func,
85 "default-normalize-context", default_normalize_context,
86 NULL);
87 }
88
89 _TP_AVAILABLE_IN_0_20
90 void tp_dynamic_handle_repo_set_normalize_async (TpDynamicHandleRepo *self,
91 TpDynamicHandleRepoNormalizeAsync normalize_async,
92 TpDynamicHandleRepoNormalizeFinish normalize_finish);
93
94 G_END_DECLS
95
96 #endif
97
98