|
1 /* |
|
2 * ============================================================================ |
|
3 * Name : isoim.h |
|
4 * Part of : isolation server instant messaing componenet. |
|
5 * Version : %version: 14 % |
|
6 * |
|
7 * Copyright © 2007-2008 Nokia. All rights reserved. |
|
8 * All rights reserved. |
|
9 * Redistribution and use in source and binary forms, with or without modification, |
|
10 * are permitted provided that the following conditions are met: |
|
11 * Redistributions of source code must retain the above copyright notice, this list |
|
12 * of conditions and the following disclaimer.Redistributions in binary form must |
|
13 * reproduce the above copyright notice, this list of conditions and the following |
|
14 * disclaimer in the documentation and/or other materials provided with the distribution. |
|
15 * Neither the name of the Nokia Corporation nor the names of its contributors may be used |
|
16 * to endorse or promote products derived from this software without specific prior written |
|
17 * permission. |
|
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
|
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
|
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
|
21 * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
|
23 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
27 * ============================================================================ |
|
28 * Template version: 1.0 |
|
29 */ |
|
30 |
|
31 /*! |
|
32 * /def To avoid multiple inclusion of header |
|
33 */ |
|
34 |
|
35 #ifndef _ISOIM_H_ |
|
36 #define _ISOIM_H_ |
|
37 |
|
38 #include <glib.h> |
|
39 #include <gtypes.h> |
|
40 |
|
41 #include "isoservermain.h" |
|
42 #include "msg_enums.h" |
|
43 |
|
44 /*! /file |
|
45 * Interfaces for the send / recieve of messages. |
|
46 * client anywhere in the documentation refers to anyone |
|
47 * using the isoserver |
|
48 */ |
|
49 |
|
50 /*! /typedef struct send_msg_struct typedefed to send_msg_struct. |
|
51 */ |
|
52 typedef struct send_msg_struct send_msg_struct; |
|
53 |
|
54 /*! /struct send_msg_struct isoim.h |
|
55 * /brief This struct is used to pass multiple pointers as userdata to callbacks |
|
56 * |
|
57 * /var hdr_req header request |
|
58 * /var msg character string(message) |
|
59 */ |
|
60 struct send_msg_struct |
|
61 { |
|
62 message_hdr_req* hdr_req; |
|
63 char *msg; |
|
64 }; |
|
65 |
|
66 /*! /typedef struct _Received_UserData typedefed to Received_UserData. |
|
67 */ |
|
68 typedef struct _Received_UserData Received_UserData; |
|
69 |
|
70 /*! /struct Received_UserData isoim.h |
|
71 * /brief This struct is used to pass multiple pointers as userdata to callbacks |
|
72 * |
|
73 * /var message_body message |
|
74 * /var proxy proxy This is used for acknowledging the recieved message |
|
75 * /var message_id This is used for acknowledging the recieved message |
|
76 */ |
|
77 struct _Received_UserData |
|
78 { |
|
79 gchar *message_body; |
|
80 DBusGProxy *proxy; |
|
81 guint message_id; |
|
82 }; |
|
83 |
|
84 /*! /typedef struct send_error_struct typedefed to send_error_struct. |
|
85 */ |
|
86 typedef struct send_error_struct send_error_struct; |
|
87 |
|
88 /*! /struct send_error_struct isoim.h |
|
89 * /brief This struct is used to pass multiple pointers as userdata to callbacks |
|
90 * |
|
91 * /var hdr_resp response header |
|
92 * /var msg_type |
|
93 * /var timestamp |
|
94 * /var msg_body |
|
95 */ |
|
96 struct send_error_struct |
|
97 { |
|
98 message_hdr_resp hdr_resp; |
|
99 guint msg_type; |
|
100 guint timestamp; |
|
101 gchar* msg_body; |
|
102 }; |
|
103 |
|
104 /*! /brief requests the handles for the contacts to which message should be sent. |
|
105 * request_handles_cb is registered as a callback. necessary data to be sent is |
|
106 * passed as userdata |
|
107 * |
|
108 * /param msghdr request header that will be passed back to client |
|
109 * /param contact_id all contacts |
|
110 * /param message |
|
111 * /param no_cntcts no. of contacts the msg shld be sent to |
|
112 * /return : error code on failure, 0 on success |
|
113 */ |
|
114 void send_message( send_msg_struct* msg_hdr, const gchar **contact_id ) ; |
|
115 |
|
116 /*! /brief handles for contacts are recieved and text channel created (if already |
|
117 * there same is used) message is sent to those contacts. |
|
118 * |
|
119 * |
|
120 * /param proxy unused |
|
121 * /param handles contact handles |
|
122 * /param error error if any in getting the handles for contact |
|
123 * /param userdata Has request header and message to be sent to reciever |
|
124 * The request header is used for mapping of response to correct request |
|
125 * |
|
126 */ |
|
127 void request_handles_cb( DBusGProxy *proxy, GArray *handles, GError* error, |
|
128 gpointer userdata ) ; |
|
129 |
|
130 |
|
131 /*! /brief parse the params for send and validates them |
|
132 * |
|
133 * /param aMsgBuffer message buffer to be parsed |
|
134 * /param aContactId pointer to an array of strings, After this function this |
|
135 * arg wil have the contacts to which message should be sent to |
|
136 * /param aSendMsg message to be sent |
|
137 * /param len : msg_len no. of bytes in aMsgBuffer |
|
138 * /param contact_count : no. of contacts |
|
139 * /return returns error code on failure, or 0 |
|
140 */ |
|
141 int parse_for_send( gchar* aMsgBuffer, gchar*** aContactId, |
|
142 gchar** aSendMsg, gint msg_len, gint* contact_count ) ; |
|
143 |
|
144 |
|
145 /*! /brief calls parse_for_send to parse the parameters, and calls |
|
146 * send_message for sending the message |
|
147 * |
|
148 * /param buf : message buffer to be parsed |
|
149 * /param len : msg_len no. of bytes in msg_buf |
|
150 * |
|
151 * /return gint : parse error code if any |
|
152 */ |
|
153 int action_parse_send( gchar* buf, gint msg_len ) ; |
|
154 |
|
155 /*! /brief Function to check if the channel is already present in the maintained hash |
|
156 * text_channels_find_func. |
|
157 * |
|
158 * /param key unused |
|
159 * /param text_channel hash table element |
|
160 * /param contact_handle to be searched item |
|
161 * /return boolean |
|
162 */ |
|
163 gboolean text_channels_find_func( gchar *key, |
|
164 TpChan *text_channel, |
|
165 guint *contact_handle ); |
|
166 |
|
167 /*! /brief Once the send request is sent to n/w server this callback is called |
|
168 * |
|
169 * /param proxy unused |
|
170 * /param error n/w error if any |
|
171 * /param userdata message header from which a response is formed |
|
172 * /return void |
|
173 */ |
|
174 void sendreply_cb( DBusGProxy *proxy, GError *error, gpointer userdata ) ; |
|
175 |
|
176 /*! /brief This function is called by tg to as a response to request for the |
|
177 * handles from the text channel. If there is no error, sent message( |
|
178 * which has failed ) with its deatils is then sent to client |
|
179 * |
|
180 * /param proxy unused |
|
181 * /param handles_names contac names (sender name) |
|
182 * /param error error if any |
|
183 * /param userdata send_error_struct |
|
184 * /return void |
|
185 */ |
|
186 static void inspect_handles_for_error_cb( DBusGProxy *proxy,char **handles_names, |
|
187 GError *error, gpointer userdata ); |
|
188 |
|
189 /*! /brief This function on registered for "senderror" signal is called when the message |
|
190 * sending is failed. Calls tp_conn_inspect_handles_async to get the contact name |
|
191 * from text channel |
|
192 * |
|
193 * /param proxy : unused |
|
194 * /param error : error code |
|
195 * /param timestamp : sent to inspect_handles_for_error_cb thru' send_error_struct |
|
196 * /param message_type : sent to inspect_handles_for_error_cb thru' send_error_struct |
|
197 * /param message_body : sent to inspect_handles_for_error_cb thru' send_error_struct |
|
198 * /param user_data text_chan from where to get the contatc name of reciepien |
|
199 * /return void |
|
200 */ |
|
201 static void senderror_cb ( DBusGProxy *proxy, |
|
202 guint error, |
|
203 guint timestamp, |
|
204 guint message_type, |
|
205 gchar *message_body, |
|
206 gpointer user_data ); |
|
207 |
|
208 /*! /brief called as a callback to acknowledge the msg ack. |
|
209 * |
|
210 * /param proxy unused |
|
211 * /param error error if any |
|
212 * /param userdata unused |
|
213 * /return void |
|
214 */ |
|
215 void msg_ack_pending_cb( DBusGProxy *proxy, GError *error, gpointer userdata ) ; |
|
216 |
|
217 /*! /brief This function is a callback for to get the contact name from handles. |
|
218 * This function acknowledges the recieved message and send that to client(adap) |
|
219 * |
|
220 * /param proxy unused |
|
221 * /param handles_names 2D array of message sender(one contact ended with a NULL string) |
|
222 * /param error error if any |
|
223 * /param userdata Received_UserData that has message body, response header etc., |
|
224 * /return void |
|
225 */ |
|
226 static void getting_sender_cb( DBusGProxy *proxy,char **handles_names, |
|
227 GError *error, gpointer userdata ) ; |
|
228 |
|
229 /*! /brief when a message is recieved this function is called by |
|
230 * telepathygabble(by emitting signal). This function then requests tg |
|
231 * to get the contact names corresponding to handles. |
|
232 * |
|
233 * /param proxy sent to getting_sender_cb as param in userdata |
|
234 * /param timestamp unused |
|
235 * /param handles_names |
|
236 * /param message_type unused |
|
237 * /param message_flags unused |
|
238 * /param message_body recieved message |
|
239 * /param userdata unused |
|
240 */ |
|
241 void receivedMessage_cb ( DBusGProxy *proxy, |
|
242 guint message_id, |
|
243 guint timestamp, |
|
244 guint from_handle, |
|
245 guint message_type, |
|
246 guint message_flags, |
|
247 gchar *message_body, |
|
248 gpointer user_data ); |
|
249 /*! /brief whenevr a new channel handler for text is created, this function is called. This |
|
250 * function also registers that channel for Received and SendError signals. Also the pending |
|
251 * messages are also retrieved in this function |
|
252 * |
|
253 * /param tp_chan new channel created |
|
254 */ |
|
255 void text_channel_init ( TpChan *text_chan ); |
|
256 |
|
257 /*! /brief called by getting_sender_cb to send the recieved message to client |
|
258 * |
|
259 * /param msg message recieved |
|
260 * /param sender message from whom recieved |
|
261 */ |
|
262 int send_message_to_client( const gchar *msg , const gchar *sender); |
|
263 |
|
264 #endif |