2
* Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
3
* Author: Patrick Keroulas <patrick.keroulas@savoirfairelinux.com>
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, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
* Additional permission under GNU GPL version 3 section 7:
21
* If you modify this program, or any covered work, by linking or
22
* combining it with the OpenSSL project's OpenSSL library (or a
23
* modified version of that library), containing parts covered by the
24
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
25
* grants you additional permission to convey the resulting work.
26
* Corresponding Source for a non-source form of such a combination
27
* shall include the source code for the parts of OpenSSL used as well
28
* as that of the covered work.
31
#ifndef __PRESENCE_H__
32
#define __PRESENCE_H__
36
#include "sflphone_client.h"
37
#include "accountlist.h"
38
#include "callable_obj.h"
40
//#define PRESENCE_DEBUG // allow for exhaustive description of the buddies
44
gchar * alias; // persistent
45
gchar * group; // persistent
46
gchar * uri; // persistent
47
gchar * acc; // persistent
48
gboolean subscribed; // is subscription active
49
gboolean status; // Online/Offline
50
gchar * note; // more detailed status
54
* This function inits the buddy list from the client's gsettings schema.
55
* @param client The given client which provide the schema
57
void presence_buddy_list_init(SFLPhoneClient *client);
60
* This function clears the buddy list.
62
void presence_buddy_list_flush();
65
* This function saved a modified buddy and resubscribes if necessary.
66
* @param buddy A known buddy but with new information to be saved.
67
* @param backup A backup of this buddy before it was changed
69
void presence_buddy_list_edit_buddy(buddy_t * buddy, buddy_t *backup);
72
* This function adds a buddy in the list.
73
* @param buddy The buddy structure to be added.
75
void presence_buddy_list_add_buddy(buddy_t * buddy);
78
* This function removes a buddy from the list.
79
* @param buddy The buddy structure to be removed.
81
void presence_buddy_list_remove_buddy(buddy_t * buddy);
84
* This function returns the number of buddies in list.
85
* @return guint The size of the buddy list.
87
guint presence_buddy_list_get_size();
90
* This function returns a pointer to the buddy list.
91
* @return Glist * The pointer to the list.
93
GList * presence_buddy_list_get();
96
* This function returns the nth buddy of the list.
97
* @return buddy_t * The pointer to the nth buddy.
99
buddy_t * presence_buddy_list_get_nth(guint n);
102
* This function returns a buddy which matches with params.
103
* @param accID The account ID associated to the buddy.
104
* @param uri The buddy's uri.
105
* @return Glist * The pointer to the found buddy.
107
buddy_t * presence_buddy_list_buddy_get_by_string(const gchar *accID, const gchar *uri);
110
* This function returns a buddy which matches with params.
111
* @param uri The buddy's uri.
112
* @return Glist * The pointer to the found buddy.
114
buddy_t * presence_buddy_list_buddy_get_by_uri(const gchar *uri);
117
* This function detects if the buddy already exists, based
118
* on its accountID and URI and return the pointer to the real element
120
* @param buddy The buddy to be found in the list.
121
* @return buddy_t * The pointer to the buddy if it exist and NULL if not.
123
buddy_t * presence_buddy_list_get_buddy(buddy_t * buddy);
126
* This function detects if the buddy already exists, based
127
* on its accountID and URI and return the pointer to the real element
129
* @param buddy The buddy to be found in the list.
130
* @return GList* The pointer to the link in the list if it exist and NULL if not.
132
GList * presence_buddy_list_get_link(buddy_t * buddy);
135
* This function create a new buddy with default value.
136
* @return buddy_t The pointer to the new buddy.
138
buddy_t * presence_buddy_create();
141
* This function deep-copies a given buddy.
142
* @param b_src The source buddy.
143
* @return buddy_t The pointer to the dest buddy.
145
buddy_t * presence_buddy_copy(buddy_t * b_src);
148
* This function frees completely a given buddy.
149
* @param b The given buddy to be deleted.
151
void presence_buddy_delete(buddy_t *buddy);
154
* This function print the entire list for debugging purpose.
156
void presence_buddy_list_print();
159
* This function calls the dbus method to subscribe to a buddy.
160
* of a given account.
161
* @param buddy The buddy pointer
162
* @param flag True to subscribe and False to unsubscribe
164
void presence_buddy_subscribe(buddy_t * buddy, gboolean flag);
167
* This function grabs data from a callable object and copies it
168
* into a given buddy.
169
* @param c The input callable object.
170
* @param b The output buddy.
172
void presence_callable_to_buddy(callable_obj_t *c, buddy_t *b);
175
* This function the group list based on the existing group fields of the buddies.
177
void presence_group_list_init();
180
* This function edit a group in the list and the associated buddies.
181
* @param new_group The new group name.
182
* @param old_group The old group pointer to be edited.
184
void presence_group_list_edit_group(gchar *new_group, gchar *old_group);
187
* This function adds a group in the list.
188
* @param group The group structure to be added.
190
void presence_group_list_add_group(const gchar * group);
193
* This function removes a group from the list and all
194
* associated buddies.
195
* @param group The group structure to be removed.
197
void presence_group_list_remove_group(const gchar * group);
200
* This function returns the number of groups in list.
201
* @return guint The size of the group list.
203
guint presence_group_list_get_size();
206
* This function returns a pointer to the group list.
207
* @return Glist * The pointer to the list.
209
GList * presence_group_list_get();
212
* This function returns the nth group of the list.
213
* @return gchar * The pointer to the nth group.
215
gchar * presence_group_list_get_nth(guint n);
218
* This function detects if the group already exists, based
219
* on its accountID and URI and return the pointer to the real element
221
* @param group The group to be found in the list.
222
* @return group * The pointer to the group if it exist and NULL if not.
224
gchar * presence_group_list_get_group(const gchar *group);
227
* This function detects if the group already exists, based
228
* on its accountID and URI and return the pointer to the real element
230
* @param group The group to be found in the list.
231
* @return GList * The pointer to the group if it exist and NULL if not.
233
GList * presence_group_list_get_link(const gchar *group);
236
* Flush the group list;
238
void presence_group_list_flush();
241
* This function print the entire list for debugging purpose.
243
void presence_group_list_print();
245
static const char *const PRESENCE_STATUS_ONLINE = "Online";
246
static const char *const PRESENCE_STATUS_OFFLINE = "Offline";