1 /* ============================================================================ |
|
2 * Name : isopresence.h |
|
3 * Part of : isolation server. |
|
4 * Version : %version: 7 % |
|
5 * |
|
6 * Copyright © 2007-2008 Nokia. All rights reserved. |
|
7 * All rights reserved. |
|
8 * Redistribution and use in source and binary forms, with or without modification, |
|
9 * are permitted provided that the following conditions are met: |
|
10 * Redistributions of source code must retain the above copyright notice, this list |
|
11 * of conditions and the following disclaimer.Redistributions in binary form must |
|
12 * reproduce the above copyright notice, this list of conditions and the following |
|
13 * disclaimer in the documentation and/or other materials provided with the distribution. |
|
14 * Neither the name of the Nokia Corporation nor the names of its contributors may be used |
|
15 * to endorse or promote products derived from this software without specific prior written |
|
16 * permission. |
|
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
|
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
|
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
|
20 * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
|
22 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
25 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
26 * ============================================================================ |
|
27 * Template version: 1.0 |
|
28 */ |
|
29 |
|
30 /*! |
|
31 * /def To avoid multiple inclusion of header |
|
32 */ |
|
33 |
|
34 #ifndef __ISOPRESENCE_H__ |
|
35 #define __ISOPRESENCE_H__ |
|
36 #include <glib.h> |
|
37 #include <gtypes.h> |
|
38 |
|
39 #include "isoservermain.h" |
|
40 #include "msg_enums.h" |
|
41 |
|
42 #include "tp-conn.h" |
|
43 #include "tp-connmgr.h" |
|
44 #include "tp-props-iface.h" |
|
45 #include "tp-interfaces.h" |
|
46 #include "tp-conn-iface-presence-gen.h" |
|
47 |
|
48 G_BEGIN_DECLS |
|
49 |
|
50 /*! /file |
|
51 * This file has interfaces for presence implimentation. |
|
52 * client anywhere in the documentation refers to anyone |
|
53 * using the isoserver |
|
54 */ |
|
55 |
|
56 /*! /typedef struct presence_msg_struct typedefed to presence_msg_struct |
|
57 */ |
|
58 typedef struct presence_msg_struct presence_msg_struct; |
|
59 |
|
60 /*! /struct presence_msg_struct isopresence |
|
61 * /brief |
|
62 * |
|
63 * /var hdr_req header request |
|
64 * /var useravailability availability, presence |
|
65 * /var statustext status text |
|
66 */ |
|
67 struct presence_msg_struct |
|
68 { |
|
69 message_hdr_req* hdr_req; |
|
70 char *useravailability; |
|
71 char *statustext; |
|
72 }; |
|
73 |
|
74 |
|
75 #define TELEPATHY_TYPE_PRESENCE (telepathy_presence_get_type ()) |
|
76 #define TELEPATHY_PRESENCE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TELEPATHY_TYPE_PRESENCE, TelepathyPresence)) |
|
77 #define TELEPATHY_PRESENCE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TELEPATHY_TYPE_PRESENCE, TelepathyPresenceClass)) |
|
78 #define TELEPATHY_IS_PRESENCE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TELEPATHY_TYPE_PRESENCE)) |
|
79 #define TELEPATHY_IS_PRESENCE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TELEPATHY_TYPE_PRESENCE)) |
|
80 #define TELEPATHY_PRESENCE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TELEPATHY_TYPE_PRESENCE, TelepathyPresenceClass)) |
|
81 |
|
82 /*! /typedef struct _TelepathyPresence typedefed to TelepathyPresence |
|
83 */ |
|
84 typedef struct _TelepathyPresence TelepathyPresence; |
|
85 |
|
86 /*! /typedef struct _TelepathyPresenceClass typedefed to TelepathyPresenceClass |
|
87 */ |
|
88 typedef struct _TelepathyPresenceClass TelepathyPresenceClass; |
|
89 |
|
90 /*! /struct _TelepathyPresence isopresence.h |
|
91 * /var parent |
|
92 */ |
|
93 struct _TelepathyPresence { |
|
94 GObject parent; |
|
95 }; |
|
96 |
|
97 /*! /struct _TelepathyPresenceClass isopresence.h |
|
98 * /var parent_class |
|
99 */ |
|
100 struct _TelepathyPresenceClass { |
|
101 GObjectClass parent_class; |
|
102 }; |
|
103 |
|
104 /*! /typedef struct _TelepathyPresenceClass typedefed to TelepathyPresenceClass |
|
105 */ |
|
106 |
|
107 /*! /enum presence states of the user |
|
108 */ |
|
109 typedef enum { |
|
110 TELEPATHY_PRESENCE_STATE_AVAILABLE, |
|
111 TELEPATHY_PRESENCE_STATE_BUSY, |
|
112 TELEPATHY_PRESENCE_STATE_AWAY, |
|
113 TELEPATHY_PRESENCE_STATE_EXT_AWAY, |
|
114 TELEPATHY_PRESENCE_STATE_HIDDEN, /* When you appear offline to others */ |
|
115 TELEPATHY_PRESENCE_STATE_UNAVAILABLE, |
|
116 } TelepathyPresenceState; |
|
117 |
|
118 GType telepathy_presence_get_type (void) G_GNUC_CONST; |
|
119 |
|
120 /*! /brief create a presence object instance |
|
121 * /return created presence object instance |
|
122 */ |
|
123 TelepathyPresence * |
|
124 telepathy_presence_new (void); |
|
125 |
|
126 /*! /brief get the presence state value |
|
127 * |
|
128 * /param presence : presence object |
|
129 * /return state : state as set in presence object |
|
130 */ |
|
131 TelepathyPresenceState |
|
132 telepathy_presence_get_state (TelepathyPresence *presence); |
|
133 |
|
134 |
|
135 /*! /brief get the presence status value |
|
136 * |
|
137 * /param presence : presence object |
|
138 * /return state : status as set in presence object |
|
139 */ |
|
140 const gchar * |
|
141 telepathy_presence_get_status (TelepathyPresence *presence); |
|
142 |
|
143 /*! /brief set the presence state value in presence gobject |
|
144 * |
|
145 * /param presence : presence object |
|
146 * /param state : state |
|
147 * /return : void |
|
148 */ |
|
149 void |
|
150 telepathy_presence_set_state (TelepathyPresence *presence, |
|
151 TelepathyPresenceState state); |
|
152 |
|
153 /*! /brief set the presence status text value in presence gobject |
|
154 * |
|
155 * /param presence : presence object |
|
156 * /param state : status |
|
157 * /return : void |
|
158 */ |
|
159 void |
|
160 telepathy_presence_set_status (TelepathyPresence *presence, |
|
161 const gchar *status); |
|
162 |
|
163 /*! /brief converts presence state value from enum to string |
|
164 * /param presence_state : presence state enum value |
|
165 * /return : presence state string value |
|
166 */ |
|
167 const gchar * |
|
168 telepathy_presence_state_to_str (TelepathyPresenceState presence_state); |
|
169 |
|
170 |
|
171 /*! /brief converts presence state value from string to enum |
|
172 * |
|
173 * /param str : presence state string value |
|
174 * /return : presence state enum value |
|
175 */ |
|
176 TelepathyPresenceState |
|
177 telepathy_telepathy_presence_state_from_str (const gchar *str); |
|
178 |
|
179 /*! /brief Registered as a signal for presence updates of |
|
180 * other users. This function will be called whenevr a contact |
|
181 * to whom this user has subscribed for presence changes his |
|
182 * presence state or status message. |
|
183 * |
|
184 * /param proxy : unused |
|
185 * /param handle_hash : hash table containing presence information |
|
186 * as hash value, contact handle as key |
|
187 * /return : void |
|
188 */ |
|
189 void |
|
190 telepathy_presence_handler(DBusGProxy *proxy, |
|
191 GHashTable *handle_hash); |
|
192 |
|
193 /*! /brief updates own presence to the n/w server. update_status_cb |
|
194 * is registered for the callback |
|
195 * |
|
196 * /param pres_iface : presence interface |
|
197 * /param presence : presence object |
|
198 * /param msg_hdr : presence info list to send presence_msg_struct |
|
199 * has state, status etc., |
|
200 * /return : void |
|
201 */ |
|
202 void |
|
203 telepathy_contacts_send_presence (DBusGProxy *pres_iface, |
|
204 TelepathyPresence *presence, |
|
205 presence_msg_struct* msg_hdr ); |
|
206 |
|
207 /*! /brief This function will be called for presence of each contact |
|
208 * key has got the state and value status |
|
209 * |
|
210 * /param key : hash table key ie presence state |
|
211 * /param value : hash table value ie presence information |
|
212 * /param presence : user data |
|
213 * /remark presence object is logically unused ? |
|
214 * |
|
215 * /return : void |
|
216 */ |
|
217 static void |
|
218 telepathy_presences_foreach (gpointer *key, |
|
219 gpointer *value, |
|
220 TelepathyPresence **presence); |
|
221 |
|
222 |
|
223 /*! /brief This function will be called for each contact. Contact name is |
|
224 * got from the contcat handle, telepathy_presences_foreach is called |
|
225 * to get the presence from value of the hash table |
|
226 * |
|
227 * @param key : hash table key ie contact handle id |
|
228 * @param value : hash table value ie presence |
|
229 * @return : void |
|
230 */ |
|
231 static void |
|
232 telepathy_presence_handle_foreach (gpointer *key, |
|
233 gpointer *value); |
|
234 |
|
235 |
|
236 /*! /brief callback for updating own presence. This function |
|
237 * sends response to client |
|
238 * |
|
239 * /param proxy : unused |
|
240 * /param error : error if any |
|
241 * /param message : message header |
|
242 * /return : void |
|
243 */ |
|
244 void |
|
245 update_status_cb(DBusGProxy *proxy, |
|
246 GError* error, |
|
247 gpointer message); |
|
248 |
|
249 |
|
250 /*! /brief Sends presence of conatct to the client. Forms |
|
251 * the proper presence message format and sends that to client |
|
252 * |
|
253 * /param : availability user availability |
|
254 * /param : text custom status message set by user |
|
255 * /return : error code on failure, 0 on success |
|
256 */ |
|
257 int |
|
258 send_presence_to_client( const gchar *availability, |
|
259 const gchar *text ); |
|
260 |
|
261 /*! /brief sends presence of the client to n/w server thru' gabble |
|
262 * calls telepathy_contacts_send_presence to send presence |
|
263 * |
|
264 * /param msghdr request header that will be passed back to client |
|
265 * /param message_type_err unused |
|
266 * /remark please remove this unused variable(why was this added?) |
|
267 * |
|
268 * /return : error code on failure, 0 on success |
|
269 */ |
|
270 void |
|
271 send_presence( presence_msg_struct* msg_hdr, |
|
272 gint message_type_err ) ; |
|
273 |
|
274 |
|
275 /*! /brief parses the message buffer. aPresenceStatus and aStatustext |
|
276 * pointers updated |
|
277 * |
|
278 * /param aMsgBuffer message buffer |
|
279 * /param aPresenceStatus after call to this function it will |
|
280 * have the presence status to be updated |
|
281 * /param aStatustext after call to this function it will |
|
282 * have the status text to be updated |
|
283 * |
|
284 * /param msg_len : msg_len no. of bytes in msg_buf |
|
285 * /return returns error code on failure, or 0 |
|
286 */ |
|
287 int |
|
288 parse_for_presence( gchar* aMsgBuffer, |
|
289 gchar** aPresenceStatus, |
|
290 gchar** aStatustext, |
|
291 gint msg_len ) ; |
|
292 |
|
293 /*! /brief Parses the message from client and sends the presence |
|
294 * to n/w server. A err is returned if there is any parse error |
|
295 * or out of memory condition |
|
296 * |
|
297 * /param buf : buffer to be parsed |
|
298 * /param buf_len : buffer length |
|
299 * /return : error code if any, 0 on success |
|
300 */ |
|
301 int |
|
302 action_parse_presence( gchar* buf, |
|
303 gint buf_len ) ; |
|
304 |
|
305 /*! /brief GObject finalize funtion |
|
306 * |
|
307 * /param object object to be finalized |
|
308 */ |
|
309 static void presence_finalize (GObject *object); |
|
310 |
|
311 /*! /brief GObject get property funtion |
|
312 * |
|
313 * /param object Gobject |
|
314 * /param param_id |
|
315 * /param value |
|
316 * /param pspec |
|
317 */ |
|
318 static void presence_get_property (GObject *object, |
|
319 guint param_id, |
|
320 GValue *value, |
|
321 GParamSpec *pspec); |
|
322 |
|
323 /*! /brief GObject set property funtion |
|
324 * |
|
325 * /param object Gobject |
|
326 * /param param_id |
|
327 * /param value |
|
328 * /param pspec |
|
329 */ |
|
330 static void presence_set_property (GObject *object, |
|
331 guint param_id, |
|
332 const GValue *value, |
|
333 GParamSpec *pspec); |
|
334 |
|
335 G_END_DECLS |
|
336 |
|
337 |
|
338 #endif //__ISOPRESENCE_H__ |
|