fix folder update stats (I hope)
[claws.git] / src / addressbook.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999,2000 Hiroyuki Yamamoto
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 #ifndef __ADDRESSBOOK_H__
21 #define __ADDRESSBOOK_H__
22
23 #include <glib.h>
24 #include <gtk/gtkwidget.h>
25 #include <gtk/gtkitemfactory.h>
26 #include <gtk/gtkctree.h>
27
28 #include "addressitem.h"
29 #include "vcard.h"
30
31 #ifdef USE_JPILOT
32 #include "jpilot.h"
33 #endif
34
35 #ifdef USE_LDAP
36 #include "syldap.h"
37 #endif
38
39 #define ADDRESS_GROUP(obj)              ((AddressGroup *)obj)
40 #define ADDRESS_FOLDER(obj)             ((AddressFolder *)obj)
41 #define ADDRESS_VCARD(obj)              ((AddressVCard *)obj)
42 #define ADDRESS_JPILOT(obj)             ((AddressJPilot *)obj)
43 #define ADDRESS_CATEGORY(obj)           ((AddressCategory *)obj)
44 #define ADDRESS_LDAP(obj)               ((AddressLDAP *)obj)
45
46
47 #include "compose.h"
48
49 typedef struct _AddressBook     AddressBook;
50 struct _AddressBook
51 {
52         GtkWidget *window;
53         GtkWidget *menubar;
54         GtkWidget *ctree;
55         GtkWidget *clist;
56         GtkWidget *entry;
57         GtkWidget *statusbar;
58
59         GtkWidget *del_btn;
60         GtkWidget *reg_btn;
61         GtkWidget *lup_btn;
62         GtkWidget *to_btn;
63         GtkWidget *cc_btn;
64         GtkWidget *bcc_btn;
65
66         GtkWidget *tree_popup;
67         GtkWidget *list_popup;
68         GtkItemFactory *tree_factory;
69         GtkItemFactory *list_factory;
70         GtkItemFactory *menu_factory;
71
72         GtkCTreeNode *common;
73         GtkCTreeNode *personal;
74         GtkCTreeNode *vcard;
75         GtkCTreeNode *jpilot;
76         GtkCTreeNode *ldap;
77         GtkCTreeNode *selected;
78         GtkCTreeNode *opened;
79
80         gboolean open_folder;
81
82         Compose *target_compose;
83         gint status_cid;
84 };
85
86 typedef struct _AddressGroup    AddressGroup;
87 struct _AddressGroup
88 {
89         AddressObject obj;
90
91         gchar *name;
92
93         /* Group contains only Items */
94         GList *items;
95 };
96
97 typedef struct _AddressFolder   AddressFolder;
98 struct _AddressFolder
99 {
100         AddressObject obj;
101
102         gchar *name;
103
104         /* Folder contains Groups and Items */
105         GList *items;
106 };
107
108 typedef struct _AddressVCard    AddressVCard;
109 struct _AddressVCard
110 {
111         AddressObject obj;
112
113         gchar *name;
114         VCardFile *cardFile;
115
116         /* Folder contains only VCards */
117         GList *items;
118 };
119
120 #ifdef USE_JPILOT
121 typedef struct _AddressJPilot   AddressJPilot;
122 struct _AddressJPilot
123 {
124         AddressObject obj;
125
126         gchar *name;
127         JPilotFile *pilotFile;
128
129         /* Folder contains only JPilotFiles */
130         /* Folder contains only Items for each category */
131         GList *items;
132 };
133
134 typedef struct _AddressCategory AddressCategory;
135 struct _AddressCategory
136 {
137         AddressObject obj;
138
139         gchar *name;
140         JPilotFile *pilotFile;
141         AddressItem *category;
142
143         /* Category contains only Items */
144         GList *items;
145 };
146 #endif
147
148 #ifdef USE_LDAP
149 typedef struct _AddressLDAP     AddressLDAP;
150 struct _AddressLDAP
151 {
152         AddressObject obj;
153
154         gchar *name;
155         SyldapServer *ldapServer;
156
157         /* Folder contains only SyldapServers */
158         GList *items;
159 };
160 #endif
161
162 struct _AddressFileSelection {
163         GtkWidget *fileSelector;
164         gboolean cancelled;
165 };
166 typedef struct _AddressFileSelection AddressFileSelection;
167
168 void addressbook_open                   (Compose        *target);
169 void addressbook_set_target_compose     (Compose        *target);
170 Compose *addressbook_get_target_compose (void);
171 void addressbook_export_to_file         (void);
172
173 /* provisional API for accessing the address book */
174
175 void addressbook_access (void);
176 void addressbook_unaccess (void);
177
178 const gchar *addressbook_get_personal_folder_name (void);
179 const gchar *addressbook_get_common_folder_name (void);
180
181 AddressObject *addressbook_find_group_by_name (const gchar *name);
182 AddressObject *addressbook_find_contact (const gchar *name, const gchar *address);
183 GList *addressbook_get_group_list (void);
184 gint addressbook_add_contact  (const gchar *group, const gchar *name, 
185                                const gchar *address, const gchar *remarks); 
186
187 gboolean addressbook_add_contact_by_menu(GtkWidget   *submenu,
188                                          const gchar *name, 
189                                          const gchar *address, 
190                                          const gchar *remarks);
191
192 #endif /* __ADDRESSBOOK_H__ */