aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend/ebook/e-book.h
blob: 48756ff00ca7e0a6b70d40bd6c3e98f50dbc2103 (plain) (blame)
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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * The Evolution addressbook client object.
 *
 * Author:
 *   Nat Friedman (nat@helixcode.com)
 *
 * Copyright 1999, 2000, Helix Code, Inc.
 */

#ifndef __E_BOOK_H__
#define __E_BOOK_H__

#include <libgnome/gnome-defs.h>

#include <e-card.h>

typedef struct _EBook        EBook;

#include <e-card-cursor.h>

BEGIN_GNOME_DECLS

typedef enum {
    E_BOOK_STATUS_SUCCESS,
    E_BOOK_STATUS_UNKNOWN,
    E_BOOK_STATUS_REPOSITORY_OFFLINE,
    E_BOOK_STATUS_PERMISSION_DENIED,
    E_BOOK_STATUS_CARD_NOT_FOUND
} EBookStatus;

typedef struct _EBookClass   EBookClass;
typedef struct _EBookPrivate EBookPrivate;

struct _EBook {
    GtkObject     parent;
    EBookPrivate *priv;
};

struct _EBookClass {
    GtkObjectClass parent;

    /*
     * Signals.
     */
    void (* open_progress) (const char *msg, short percent);
    void (* link_status)   (gboolean connected);
    void (* card_changed)  (const char *id);
    void (* card_removed)  (const char *id);
    void (* card_added)    (const char *id);
};

/* Callbacks for asynchronous functions. */
typedef void (*EBookCallback) (EBook *book, EBookStatus status, gpointer closure);
typedef void (*EBookOpenProgressCallback)     (EBook          *book,
                           const char     *status_message,
                           short           percent,
                           gpointer        closure);
typedef void (*EBookIdCallback) (EBook *book, EBookStatus status, const char *id, gpointer closure);
typedef void (*EBookCursorCallback) (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closure);


/* Creating a new addressbook. */
EBook    *e_book_new                (void);
gboolean  e_book_load_uri           (EBook         *book,
                     const char    *uri,
                     EBookCallback  open_response,
                     gpointer       closure);
void      e_book_unload_uri         (EBook         *book);

/* Fetching cards. */
ECard    *e_book_get_card           (EBook         *book,
                     const char    *id);
char     *e_book_get_vcard          (EBook         *book,
                     const char    *id);

/* Deleting cards. */
gboolean  e_book_remove_card        (EBook         *book,
                     ECard         *card,
                     EBookCallback  cb,
                     gpointer       closure);
gboolean  e_book_remove_card_by_id  (EBook         *book,
                     const char    *id,
                     EBookCallback  cb,
                     gpointer       closure);

/* Adding cards. */
gboolean  e_book_add_card           (EBook           *book,
                     ECard           *card,
                     EBookIdCallback  cb,
                     gpointer         closure);
gboolean  e_book_add_vcard          (EBook           *book,
                     const char      *vcard,
                     EBookIdCallback  cb,
                     gpointer         closure);

/* Modifying cards. */
gboolean  e_book_commit_card        (EBook         *book,
                     ECard         *card,
                     EBookCallback  cb,
                     gpointer       closure);
gboolean  e_book_commit_vcard       (EBook         *book,
                     const char    *vcard,
                     EBookCallback  cb,
                     gpointer       closure);

/* Checking to see if we're connected to the card repository. */
gboolean  e_book_check_connection   (EBook         *book);

gboolean e_book_get_all_cards       (EBook         *book,
                     EBookCursorCallback  cb,
                     gpointer       closure);

/* Getting the name of the repository. */
char     *e_book_get_name           (EBook         *book);

GtkType   e_book_get_type           (void);

#define E_BOOK_TYPE        (e_book_get_type ())
#define E_BOOK(o)          (GTK_CHECK_CAST ((o), E_BOOK_TYPE, EBook))
#define E_BOOK_CLASS(k)    (GTK_CHECK_CLASS_CAST((k), E_BOOK_TYPE, EBookClass))
#define E_IS_BOOK(o)       (GTK_CHECK_TYPE ((o), E_BOOK_TYPE))
#define E_IS_BOOK_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_BOOK_TYPE))

END_GNOME_DECLS

#endif /* ! __E_BOOK_H__ */