* src/mimeview.c
[claws.git] / src / ldapquery.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2003 Match Grun
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Functions necessary to define an LDAP query.
22  */
23
24 #ifndef __LDAPQUERY_H__
25 #define __LDAPQUERY_H__
26
27 #ifdef USE_LDAP
28
29 #include <glib.h>
30 #include <stdio.h>
31 #include <sys/time.h>
32 #include <pthread.h>
33
34 #include "ldapctrl.h"
35 #include "ldapserver.h"
36 #include "addritem.h"
37 #include "addrcache.h"
38
39 /*
40  * Constants.
41  */
42 #define LDAPQUERY_NONE     0
43 #define LDAPQUERY_STATIC   1
44 #define LDAPQUERY_DYNAMIC  2
45
46 /* Error codes */
47 #define LDAPRC_SUCCESS    0
48 #define LDAPRC_CONNECT    -1
49 #define LDAPRC_INIT       -2
50 #define LDAPRC_BIND       -3
51 #define LDAPRC_SEARCH     -4
52 #define LDAPRC_TIMEOUT    -5
53 #define LDAPRC_CRITERIA   -6
54 #define LDAPRC_NOENTRIES  -7
55
56 typedef struct _LdapQuery LdapQuery;
57 struct _LdapQuery {
58         LdapControl *control;
59         gint        retVal;
60         gint        queryType;
61         gchar       *queryName;
62         gchar       *searchValue;
63         gint        queryID;
64         gint        entriesRead;
65         gint        elapsedTime;
66         gboolean    stopFlag;
67         gboolean    busyFlag;
68         gboolean    agedFlag;
69         gboolean    completed;
70         time_t      touchTime;
71         pthread_t   *thread;
72         pthread_mutex_t *mutexStop;
73         pthread_mutex_t *mutexBusy;
74         pthread_mutex_t *mutexEntry;
75         void        (*callBackStart)( void * );
76         void        (*callBackEntry)( void *, void * );
77         void        (*callBackEnd)( void * );
78         ItemFolder  *folder;            /* Reference to folder in cache */
79         LdapServer  *server;            /* Reference to (parent) LDAP server */
80 };
81
82 /* Function prototypes */
83 void ldapqry_initialize         ( void );
84 LdapQuery *ldapqry_create       ( void );
85 void ldapqry_set_control        ( LdapQuery *qry, LdapControl *ctl );
86 void ldapqry_set_name           ( LdapQuery* qry, const gchar *value );
87 void ldapqry_set_search_value   ( LdapQuery *qry, const gchar *value );
88 void ldapqry_set_error_status   ( LdapQuery* qry, const gint value );
89 void ldapqry_set_query_type     ( LdapQuery* qry, const gint value );
90 void ldapqry_set_query_id       ( LdapQuery* qry, const gint value );
91 void ldapqry_set_entries_read   ( LdapQuery* qry, const gint value );
92 void ldapqry_set_callback_start ( LdapQuery *qry, void *func );
93 void ldapqry_set_callback_entry ( LdapQuery *qry, void *func );
94 void ldapqry_set_callback_end   ( LdapQuery *qry, void *func );
95 void ldapqry_clear              ( LdapQuery *qry );
96 void ldapqry_free               ( LdapQuery *qry );
97 void ldapqry_print              ( const LdapQuery *qry, FILE *stream );
98 void ldapqry_set_stop_flag      ( LdapQuery *qry, const gboolean value );
99 gboolean ldapqry_get_stop_flag  ( LdapQuery *qry );
100 void ldapqry_set_busy_flag      ( LdapQuery *qry, const gboolean value );
101 gboolean ldapqry_get_busy_flag  ( LdapQuery *qry );
102 void ldapqry_set_aged_flag      ( LdapQuery *qry, const gboolean value );
103 gboolean ldapqry_get_aged_flag  ( LdapQuery *qry );
104
105 gboolean ldapqry_check_search   ( LdapQuery *qry );
106 void ldapqry_touch              ( LdapQuery *qry );
107 gint ldapqry_search             ( LdapQuery *qry );
108 gint ldapqry_read_data_th       ( LdapQuery *qry );
109 void ldapqry_join_thread        ( LdapQuery *qry );
110 void ldapqry_cancel             ( LdapQuery *qry );
111 void ldapqry_age                ( LdapQuery *qry, gint maxAge );
112 void ldapqry_delete_folder      ( LdapQuery *qry );
113
114 #endif  /* USE_LDAP */
115
116 #endif /* __LDAPQUERY_H__ */