Fix bug #3574: Template addressing
[claws.git] / src / addritem.h
blob82fbaf3edfde546b856de979fcae61b4c66dab30
1 /*
2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2001-2012 Match Grun and the Claws Mail team
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 3 of the License, or
8 * (at your option) any later version.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * Address item data.
24 #ifndef __ADDRITEM_H__
25 #define __ADDRITEM_H__
27 #include <stdio.h>
28 #include <glib.h>
30 #define ADDRITEM_OBJECT(obj) ((AddrItemObject *)obj)
31 #define ADDRITEM_TYPE(obj) (ADDRITEM_OBJECT(obj)->type)
32 #define ADDRITEM_NAME(obj) (ADDRITEM_OBJECT(obj)->name)
33 #define ADDRITEM_ID(obj) (ADDRITEM_OBJECT(obj)->uid)
34 #define ADDRITEM_PARENT(obj) (ADDRITEM_OBJECT(obj)->parent)
35 #define ADDRITEM_SUBTYPE(obj) (ADDRITEM_OBJECT(obj)->subType)
37 typedef enum {
38 ITEMTYPE_NONE,
39 ITEMTYPE_PERSON,
40 ITEMTYPE_EMAIL,
41 ITEMTYPE_FOLDER,
42 ITEMTYPE_GROUP,
43 ITEMTYPE_INDEX,
44 ITEMTYPE_INTERFACE,
45 ITEMTYPE_DATASOURCE
46 } ItemObjectType;
48 typedef enum {
49 ADDRFOLDER_NONE,
50 ADDRFOLDER_ROOT,
51 ADDRFOLDER_REGULAR,
52 ADDRFOLDER_CATEGORY,
53 ADDRFOLDER_QUERY_RESULTS
54 } AddressFolderType;
56 typedef enum {
57 NONE,
58 ADD_ENTRY,
59 UPDATE_ENTRY,
60 DELETE_ENTRY
61 } ContactStatus;
63 typedef struct _AddrItemObject AddrItemObject;
64 struct _AddrItemObject {
65 ItemObjectType type;
66 gchar *name;
67 gchar *uid;
68 AddrItemObject *parent;
69 gint subType;
72 typedef struct _ItemPerson ItemPerson;
73 struct _ItemPerson {
74 AddrItemObject obj;
75 gchar *picture;
76 gchar *firstName;
77 gchar *lastName;
78 gchar *nickName;
79 gchar *externalID;
80 GList *listEMail;
81 GList *listAttrib;
82 gboolean isOpened;
83 ContactStatus status;
86 typedef struct _ItemEMail ItemEMail;
87 struct _ItemEMail {
88 AddrItemObject obj;
89 gchar *address;
90 gchar *remarks;
93 typedef struct _UserAttribute UserAttribute;
94 struct _UserAttribute {
95 gchar *uid;
96 gchar *name;
97 gchar *value;
100 typedef struct _ItemFolder ItemFolder;
101 struct _ItemFolder {
102 AddrItemObject obj;
103 gchar *remarks;
104 gboolean isRoot; /* TRUE if root folder */
105 GList *listItems; /* Used for temporary items only */
106 GList *listFolder; /* List of contained (child) folders */
107 GList *listPerson; /* List of contained persons */
108 GList *listGroup; /* List of contained (child) groups */
109 AddressFolderType folderType; /* Folder type */
110 gpointer *folderData; /* Pointer to folder's data */
111 gboolean isHidden; /* TRUE if folder is hidden */
114 typedef struct _ItemGroup ItemGroup;
115 struct _ItemGroup {
116 AddrItemObject obj;
117 gchar *remarks;
118 GList *listEMail;
121 /* Function prototypes */
122 ItemEMail *addritem_create_item_email ( void );
123 ItemEMail *addritem_copy_item_email ( ItemEMail *item );
124 ItemEMail *addritem_copyfull_item_email ( ItemEMail *item );
125 void addritem_email_set_alias ( ItemEMail *email, const gchar *value );
126 void addritem_email_set_address ( ItemEMail *email, const gchar *value );
127 void addritem_email_set_remarks ( ItemEMail *email, const gchar *value );
128 void addritem_free_item_email ( ItemEMail *item );
130 UserAttribute *addritem_create_attribute( void );
131 UserAttribute *addritem_copy_attribute ( UserAttribute *item );
132 void addritem_attrib_set_id ( UserAttribute *item, const gchar *value );
133 void addritem_attrib_set_name ( UserAttribute *item, const gchar *value );
134 void addritem_attrib_set_value ( UserAttribute *item, const gchar *value );
135 void addritem_free_attribute ( UserAttribute *item );
137 ItemPerson *addritem_create_item_person ( void );
138 ItemPerson *addritem_copy_item_person ( ItemPerson *item );
139 void addritem_person_set_picture ( ItemPerson *person, const gchar *value );
140 gchar *addritem_person_get_picture ( ItemPerson *person);
141 void addritem_person_set_first_name ( ItemPerson *person, const gchar *value );
142 void addritem_person_set_last_name ( ItemPerson *person, const gchar *value );
143 void addritem_person_set_nick_name ( ItemPerson *person, const gchar *value );
144 void addritem_person_set_common_name ( ItemPerson *person, const gchar *value );
145 void addritem_person_set_external_id ( ItemPerson *person, const gchar *value );
146 void addritem_person_set_opened ( ItemPerson *person, const gboolean value );
147 void addritem_free_item_person ( ItemPerson *person );
148 void addritem_free_list_email ( GList *list );
149 void addritem_free_list_attribute ( GList *list );
151 ItemGroup *addritem_create_item_group ( void );
152 ItemGroup *addritem_copy_item_group ( ItemGroup *item );
153 void addritem_free_item_group ( ItemGroup *group );
154 void addritem_group_set_name ( ItemGroup *group, const gchar *value );
156 void addritem_print_item_email ( ItemEMail *item, FILE *stream );
157 void addritem_print_item_person ( ItemPerson *person, FILE *stream );
158 void addritem_print_item_group ( ItemGroup *group, FILE *stream );
159 void addritem_print_item_folder ( ItemFolder *folder, FILE *stream );
161 gboolean addritem_person_add_email ( ItemPerson *person, ItemEMail *email );
162 ItemEMail *addritem_person_remove_email ( ItemPerson *person, ItemEMail *email );
164 void addritem_person_add_attribute ( ItemPerson *person, UserAttribute *attrib );
165 void addritem_person_remove_attribute ( ItemPerson *person, const gchar *attrib );
167 ItemFolder *addritem_create_item_folder ( void );
168 ItemFolder *addritem_copy_item_folder ( ItemFolder *item );
169 void addritem_folder_set_name ( ItemFolder *folder, const gchar *value );
170 void addritem_folder_set_remarks ( ItemFolder *folder, const gchar *value );
171 void addritem_folder_set_hidden ( ItemFolder *folder, const gboolean value );
172 void addritem_free_item_folder ( ItemFolder *folder );
174 gboolean addritem_group_add_email ( ItemGroup *group, ItemEMail *email );
176 gboolean addritem_folder_add_person ( ItemFolder *folder, ItemPerson *item );
177 ItemPerson *addritem_folder_remove_person( ItemFolder *group, ItemPerson *person );
179 gboolean addritem_folder_add_folder ( ItemFolder *folder, ItemFolder *item );
180 gboolean addritem_folder_add_group ( ItemFolder *folder, ItemGroup *item );
181 GList *addritem_folder_get_person_list ( ItemFolder *folder );
182 GList *addritem_folder_get_group_list ( ItemFolder *folder );
184 void addritem_parse_first_last ( ItemPerson *person );
185 GList *addritem_folder_path ( const ItemFolder *folder,
186 const gboolean seq );
187 gchar *addritem_format_email ( ItemEMail *email );
189 #endif /* __ADDRITEM_H__ */