summaryrefslogtreecommitdiff
path: root/src/vcard-manager.h
blob: c81f9038fe710b56b34da69662037af5f4fd8219 (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
/*
 * vcard-manager.h - vCard lookup helper for Gabble connections
 *
 * Copyright (C) 2006 Collabora Ltd.
 * Copyright (C) 2006 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_VCARD_MANAGER_H__
#define __GABBLE_VCARD_MANAGER_H__

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

#include "gabble-types.h"

G_BEGIN_DECLS

typedef struct _GabbleVCardManagerClass GabbleVCardManagerClass;
typedef struct _GabbleVCardManagerRequest GabbleVCardManagerRequest;

/**
 * GabbleVCardManagerError:
 * @GABBLE_VCARD_MANAGER_ERROR_CANCELLED: The vCard request was cancelled
 * @GABBLE_VCARD_MANAGER_ERROR_TIMEOUT: The vCard request timed out
 * @GABBLE_VCARD_MANAGER_ERROR_UNKNOWN: An unknown error occured
 */
typedef enum
{
  GABBLE_VCARD_MANAGER_ERROR_CANCELLED,
  GABBLE_VCARD_MANAGER_ERROR_TIMEOUT,
  GABBLE_VCARD_MANAGER_ERROR_UNKNOWN
} GabbleVCardManagerError;

GQuark gabble_vcard_manager_error_quark (void);
#define GABBLE_VCARD_MANAGER_ERROR gabble_vcard_manager_error_quark ()

GType gabble_vcard_manager_get_type (void);

/* TYPE MACROS */
#define GABBLE_TYPE_VCARD_MANAGER \
  (gabble_vcard_manager_get_type ())
#define GABBLE_VCARD_MANAGER(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_VCARD_MANAGER, GabbleVCardManager))
#define GABBLE_VCARD_MANAGER_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_VCARD_MANAGER, GabbleVCardManagerClass))
#define GABBLE_IS_VCARD_MANAGER(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_VCARD_MANAGER))
#define GABBLE_IS_VCARD_MANAGER_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_VCARD_MANAGER))
#define GABBLE_VCARD_MANAGER_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_VCARD_MANAGER, GabbleVCardManagerClass))

struct _GabbleVCardManagerClass {
    GObjectClass parent_class;
};

struct _GabbleVCardManager {
    GObject parent;
    gpointer priv;
};

typedef void (*GabbleVCardManagerCb)(GabbleVCardManager *self,
                                    GabbleVCardManagerRequest *request,
                                    TpHandle handle,
                                    LmMessageNode *vcard,
                                    GError *error,
                                    gpointer user_data);

GabbleVCardManager *gabble_vcard_manager_new (GabbleConnection *);

GQuark gabble_vcard_manager_cache_quark (void);

GabbleVCardManagerRequest *gabble_vcard_manager_request (GabbleVCardManager *,
                                                       TpHandle,
                                                       guint timeout,
                                                       GabbleVCardManagerCb,
                                                       gpointer user_data,
                                                       GObject *object,
                                                       GError **error);

GabbleVCardManagerRequest *gabble_vcard_manager_replace (GabbleVCardManager *,
                                                       LmMessageNode *,
                                                       guint timeout,
                                                       GabbleVCardManagerCb,
                                                       gpointer user_data,
                                                       GObject *object,
                                                       GError **error);

GabbleVCardManagerRequest *gabble_vcard_manager_edit (GabbleVCardManager *,
                                                    guint timeout,
                                                    GabbleVCardManagerCb,
                                                    gpointer user_data,
                                                    GObject *object,
                                                    GError **error,
                                                    ...)
                                                   G_GNUC_NULL_TERMINATED;

void gabble_vcard_manager_cancel_request (GabbleVCardManager *manager,
                                          GabbleVCardManagerRequest *request);

const gchar *gabble_vcard_manager_get_cached_alias (GabbleVCardManager *,
                                                   TpHandle);
gboolean gabble_vcard_manager_has_cached_alias (GabbleVCardManager *manager,
                                                TpHandle handle);

gboolean gabble_vcard_manager_get_cached (GabbleVCardManager *,
                                          TpHandle,
                                          LmMessageNode **);
void gabble_vcard_manager_invalidate_cache (GabbleVCardManager *, TpHandle);

G_END_DECLS

#endif