group: refactor add buddy to group code
[siplcs.git] / src / core / sipe-group.h
blobad2530680e8ce871c0f92589d27efe5db3b80ed7
1 /**
2 * @file sipe-group.h
4 * pidgin-sipe
6 * Copyright (C) 2011-2013 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 /* Forward declarations */
24 struct sipe_buddy;
25 struct sipe_core_private;
27 struct sipe_group {
28 gchar *name;
29 gchar *exchange_key;
30 gchar *change_key;
31 guint id;
32 gboolean is_obsolete;
35 struct sipe_group *sipe_group_find_by_id(struct sipe_core_private *sipe_private,
36 guint id);
38 struct sipe_group *sipe_group_find_by_name(struct sipe_core_private *sipe_private,
39 const gchar * name);
41 void sipe_group_create(struct sipe_core_private *sipe_private,
42 const gchar *name,
43 const gchar *who);
45 gboolean sipe_group_rename(struct sipe_core_private *sipe_private,
46 struct sipe_group *group,
47 const gchar *name);
49 /**
50 * Creates @c sipe_group structure for a new group and adds it into the group
51 * list of given account. If buddy is already in the list, its existing
52 * structure is returned.
54 * @param sipe_private SIPE core data
55 * @param name name of group (may be @c NULL)
56 * @param exchange_key Exchange key (may be @c NULL)
57 * @param change_key Change key (may be @c NULL)
58 * @param id numeric ID of group
60 * @return @c sipe_group structure or @c NULL if group creation failed
62 struct sipe_group *sipe_group_add(struct sipe_core_private *sipe_private,
63 const gchar *name,
64 const gchar *exchange_key,
65 const gchar *change_key,
66 guint id);
68 /* remove group from core & backend */
69 void sipe_group_remove(struct sipe_core_private *sipe_private,
70 struct sipe_group *group);
72 /* update alias/group list for a buddy on the server */
73 void sipe_group_update_buddy(struct sipe_core_private *sipe_private,
74 struct sipe_buddy *buddy);
76 /**
77 * Prepare group list for an update
79 * @param sipe_private SIPE core data
81 void sipe_group_update_start(struct sipe_core_private *sipe_private);
83 /**
84 * Finish group list update. This will remove obsolete groups.
86 * NOTE: this must be call after sipe_buddy_update_finish(), i.e. it
87 * assumes that the group is no longer associated with any buddy.
89 * @param sipe_private SIPE core data
91 void sipe_group_update_finish(struct sipe_core_private *sipe_private);
93 /**
94 * Return first group
96 * @param sipe_private SIPE core data
98 * @return sipe_group structure or @c NULL if there are no groups
100 struct sipe_group *sipe_group_first(struct sipe_core_private *sipe_private);
103 * Number of groups
105 * @param sipe_private SIPE core data
107 guint sipe_group_count(struct sipe_core_private *sipe_private);
110 * Initialize group data
112 * @param sipe_private SIPE core data
114 void sipe_group_init(struct sipe_core_private *sipe_private);
117 * Free group data
119 * @param sipe_private SIPE core data
121 void sipe_group_free(struct sipe_core_private *sipe_private);