1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _CONNECTIVITY_EVOAB_EVOLUTION_API_HXX_
25 #define _CONNECTIVITY_EVOAB_EVOLUTION_API_HXX_
26 #include <glib-object.h>
27 
28 // Initializes the API below, returns false if not available
29 bool EApiInit();
30 
31 G_BEGIN_DECLS
32 
33 // This header defined all the API methods as
34 // function pointers instead of real functions
35 // this will all evaporate as it is compiled generating
36 // no symbol lookups or relocations, but giving code
37 // clarity.
38 
39 // We attempt to define a minimum API that we use:
40 
41 // e-contact.h
42 #ifdef DECLARE_FN_POINTERS
43 #define EAPI_EXTERN
44 #else
45 #define EAPI_EXTERN extern
46 #endif
47 
48 
49 typedef void EContact;
50 #define E_CONTACT(a) ((EContact *)(a))
51 #define E_TYPE_CONTACT (e_contact_get_type())
52 typedef int EContactField;
53 
54 EAPI_EXTERN const char      *(*e_contact_field_name)   ( EContactField field_id);
55 EAPI_EXTERN gpointer      	(*e_contact_get)   (EContact *contact, EContactField field_id);
56 EAPI_EXTERN gconstpointer  (*e_contact_get_const)   (EContact *contact, EContactField field_id);
57 // e-source.h
58 typedef void ESource;
59 #define E_SOURCE(a) ((ESource *)(a))
60 EAPI_EXTERN const char  *(*e_source_peek_name)    (ESource *source);
61 EAPI_EXTERN const gchar *(*e_source_get_property) (ESource *source,
62 				       const gchar *property);
63 
64 EAPI_EXTERN GType         (*e_contact_get_type) (void);
65 EAPI_EXTERN EContactField (*e_contact_field_id) (const char *field_name);
66 
67 // e-source-list.h
68 typedef void ESourceList;
69 EAPI_EXTERN GSList *(*e_source_list_peek_groups) (ESourceList *list);
70 
71 // e-source-group.h
72 typedef void ESourceGroup;
73 #define E_SOURCE_GROUP(a) ((ESourceGroup *)(a))
74 
75 EAPI_EXTERN GSList  *(*e_source_group_peek_sources) (ESourceGroup *group);
76 EAPI_EXTERN const char *(*e_source_group_peek_base_uri)  (ESourceGroup *group);
77 // e-book.h
78 typedef enum {
79   E_BOOK_QUERY_IS,
80   E_BOOK_QUERY_CONTAINS,
81   E_BOOK_QUERY_BEGINS_WITH,
82   E_BOOK_QUERY_ENDS_WITH,
83 } EBookQueryTest;
84 
85 typedef void EBook;
86 typedef void EBookQuery;
87 
88 EAPI_EXTERN EBook      *(*e_book_new) 		(ESource      *source,
89 								       		 GError      **error);
90 
91 EAPI_EXTERN gboolean    (*e_book_open)		(EBook       *book,
92 					       				 	 gboolean     only_if_exists,
93 				                         	 GError     **error);
94 
95 EAPI_EXTERN const char *(*e_book_get_uri)	(EBook        *book);
96 EAPI_EXTERN ESource    *(*e_book_get_source)(EBook        *book);
97 
98 EAPI_EXTERN gboolean    (*e_book_get_addressbooks)        (ESourceList **addressbook_sources,
99 													       GError      **error);
100 
101 EAPI_EXTERN gboolean    (*e_book_get_contacts)            (EBook        *book,
102 													       EBookQuery   *query,
103 													       GList       **contacts,
104 													       GError      **error);
105 
106 EAPI_EXTERN gboolean    (*e_book_authenticate_user)       (EBook        *book,
107 													       const char   *user,
108 													       const char   *passwd,
109 													       const char   *auth_method,
110 													       GError      **error);
111 
112 // e-book-query.h
113 EAPI_EXTERN EBookQuery* (*e_book_query_field_exists) (EContactField   field);
114 EAPI_EXTERN EBookQuery* (*e_book_query_field_test)   (EContactField   field,
115 					  								  EBookQueryTest     test,
116 													  const char        *value);
117 EAPI_EXTERN EBookQuery* (*e_book_query_and)          (int nqs, EBookQuery **qs, gboolean unref);
118 EAPI_EXTERN EBookQuery* (*e_book_query_or)           (int nqs, EBookQuery **qs, gboolean unref);
119 EAPI_EXTERN EBookQuery* (*e_book_query_not)          (EBookQuery *q, gboolean unref);
120 EAPI_EXTERN EBookQuery* (*e_book_query_ref)          (EBookQuery *q);
121 EAPI_EXTERN void        (*e_book_query_unref)        (EBookQuery *q);
122 EAPI_EXTERN char*       (*e_book_query_to_string)    (EBookQuery *q);
123 EAPI_EXTERN EBookQuery* (*e_book_query_from_string)   (const char *query_string);
124 
125 typedef struct {
126         char *address_format; /* the two letter country code that
127                                  determines the format/meaning of the
128                                  following fields */
129         char *po;
130         char *ext;
131         char *street;
132         char *locality;
133         char *region;
134         char *code;
135         char *country;
136 } EContactAddress;
137 G_END_DECLS
138 #endif
139 
140