Mercurial > pidgin
annotate src/protocols/novell/novell.c @ 13020:72300c551dc2
[gaim-migrate @ 15373]
More whitespace from the tree.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Mon, 23 Jan 2006 11:41:51 +0000 |
parents | 17901f14d46d |
children | 5926f73d5437 |
rev | line source |
---|---|
8675 | 1 /* |
2 * novell.c | |
3 * | |
8933 | 4 * Copyright (c) 2004 Novell, Inc. All Rights Reserved. |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; version 2 of the License. | |
8675 | 9 * |
8933 | 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. | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
14 * |
8933 | 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
8675 | 18 * |
19 */ | |
20 | |
21 #include "internal.h" | |
22 #include "accountopt.h" | |
23 #include "debug.h" | |
24 #include "prpl.h" | |
25 #include "server.h" | |
26 #include "nmuser.h" | |
27 #include "notify.h" | |
28 #include "util.h" | |
29 #include "sslconn.h" | |
30 #include "request.h" | |
31 #include "network.h" | |
8933 | 32 #include "privacy.h" |
10762 | 33 #include "status.h" |
9943 | 34 #include "version.h" |
8675 | 35 |
36 #define DEFAULT_PORT 8300 | |
37 #define NOVELL_CONNECT_STEPS 4 | |
9651 | 38 #define NM_ROOT_FOLDER_NAME "GroupWise Messenger" |
8675 | 39 |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
40 #define NOVELL_STATUS_TYPE_AVAILABLE "available" |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
41 #define NOVELL_STATUS_TYPE_AWAY "away" |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
42 #define NOVELL_STATUS_TYPE_BUSY "busy" |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
43 #define NOVELL_STATUS_TYPE_OFFLINE "offline" |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
44 #define NOVELL_STATUS_TYPE_IDLE "idle" |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
45 #define NOVELL_STATUS_TYPE_APPEAR_OFFLINE "appearoffline" |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
46 |
8675 | 47 static GaimPlugin *my_protocol = NULL; |
48 | |
49 static gboolean | |
50 _is_disconnect_error(NMERR_T err); | |
51 | |
52 static gboolean | |
53 _check_for_disconnect(NMUser * user, NMERR_T err); | |
54 | |
55 static void | |
56 _send_message(NMUser * user, NMMessage * message); | |
57 | |
58 static void | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
59 _update_buddy_status(NMUser *user, GaimBuddy * buddy, int status, int gmt); |
8675 | 60 |
61 static void | |
62 _remove_gaim_buddies(NMUser * user); | |
63 | |
64 static void | |
65 _add_contacts_to_gaim_blist(NMUser * user, NMFolder * folder); | |
66 | |
67 static void | |
68 _add_gaim_buddies(NMUser * user); | |
69 | |
70 static void | |
8933 | 71 _sync_contact_list(NMUser *user); |
72 | |
73 static void | |
74 _sync_privacy_lists(NMUser *user); | |
75 | |
76 static void | |
8675 | 77 _show_info(GaimConnection * gc, NMUserRecord * user_record); |
78 | |
8933 | 79 const char * |
80 _get_conference_name(int id); | |
81 | |
8675 | 82 /******************************************************************************* |
83 * Response callbacks | |
84 *******************************************************************************/ | |
85 | |
86 /* Handle login response */ | |
87 static void | |
88 _login_resp_cb(NMUser * user, NMERR_T ret_code, | |
89 gpointer resp_data, gpointer user_data) | |
90 { | |
91 GaimConnection *gc; | |
92 const char *alias; | |
93 NMERR_T rc; | |
94 | |
95 if (user == NULL) | |
96 return; | |
97 | |
98 gc = gaim_account_get_connection(user->client_data); | |
99 if (gc == NULL) | |
100 return; | |
101 | |
102 if (ret_code == NM_OK) { | |
103 | |
104 /* Set alias for user if not set (use Full Name) */ | |
105 alias = gaim_account_get_alias(user->client_data); | |
106 if (alias == NULL || *alias == '\0') { | |
107 alias = nm_user_record_get_full_name(user->user_record); | |
108 | |
109 if (alias) | |
110 gaim_account_set_alias(user->client_data, alias); | |
111 } | |
112 | |
113 /* Tell Gaim that we are connected */ | |
114 gaim_connection_set_state(gc, GAIM_CONNECTED); | |
115 | |
9360 | 116 _sync_contact_list(user); |
117 | |
8675 | 118 rc = nm_send_set_status(user, NM_STATUS_AVAILABLE, NULL, NULL, NULL, |
119 NULL); | |
120 _check_for_disconnect(user, rc); | |
121 | |
122 } else { | |
123 | |
8933 | 124 char *err = g_strdup_printf(_("Login failed (%s)."), |
125 nm_error_to_string (ret_code)); | |
8675 | 126 |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
127 /* Clear the password if it was invalid ... don't want to retry |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
128 * and get ourselves locked out. |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
129 */ |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
130 if (ret_code == NMERR_AUTHENTICATION_FAILED || |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
131 ret_code == NMERR_CREDENTIALS_MISSING || |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
132 ret_code == NMERR_PASSWORD_INVALID) { |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
133 gaim_account_set_password((GaimAccount*)user->client_data, NULL); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
134 } |
8675 | 135 gaim_connection_error(gc, err); |
136 g_free(err); | |
137 } | |
138 } | |
139 | |
140 /* Handle getstatus response*/ | |
141 static void | |
142 _get_status_resp_cb(NMUser * user, NMERR_T ret_code, | |
143 gpointer resp_data, gpointer user_data) | |
144 { | |
145 GaimBuddy *buddy; | |
146 GSList *buddies; | |
147 GSList *bnode; | |
148 NMUserRecord *user_record = (NMUserRecord *) resp_data; | |
149 int status; | |
150 | |
151 if (user == NULL || user_record == NULL) | |
152 return; | |
153 | |
154 if (ret_code == NM_OK) { | |
155 | |
156 /* Find all Gaim buddies and update their statuses */ | |
157 const char *name = nm_user_record_get_display_id(user_record); | |
158 | |
159 if (name) { | |
160 buddies = gaim_find_buddies((GaimAccount *) user->client_data, name); | |
161 for (bnode = buddies; bnode; bnode = bnode->next) { | |
162 buddy = (GaimBuddy *) bnode->data; | |
163 if (buddy) { | |
164 status = nm_user_record_get_status(user_record); | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
165 _update_buddy_status(user, buddy, status, time(0)); |
8675 | 166 } |
167 } | |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
11972
diff
changeset
|
168 g_slist_free(buddies); |
8675 | 169 } |
170 | |
171 } else { | |
172 | |
173 gaim_debug(GAIM_DEBUG_INFO, "novell", | |
174 "_get_status_resp_cb(): rc = 0x%X\n", ret_code); | |
175 | |
176 } | |
177 } | |
178 | |
179 /* Show an error if the rename failed */ | |
180 static void | |
181 _rename_contact_resp_cb(NMUser * user, NMERR_T ret_code, | |
182 gpointer resp_data, gpointer user_data) | |
183 { | |
184 if (ret_code != NM_OK) { | |
185 gaim_debug(GAIM_DEBUG_INFO, "novell", | |
186 "_rename_contact_resp_cb(): rc = 0x%X\n", ret_code); | |
187 } | |
188 } | |
189 | |
190 /* Handle the getdetails response and send the message */ | |
191 static void | |
192 _get_details_resp_send_msg(NMUser * user, NMERR_T ret_code, | |
193 gpointer resp_data, gpointer user_data) | |
194 { | |
195 GaimConversation *gconv; | |
196 GaimConnection *gc; | |
197 NMUserRecord *user_record = NULL; | |
198 NMContact *cntct = NULL; | |
199 NMConference *conf; | |
200 NMMessage *msg = user_data; | |
201 const char *dn = NULL; | |
202 const char *name; | |
203 | |
204 if (user == NULL || msg == NULL) | |
205 return; | |
206 | |
207 if (ret_code == NM_OK) { | |
208 user_record = (NMUserRecord *) resp_data; | |
209 if (user_record) { | |
210 | |
211 /* Set the title for the conversation */ | |
11338 | 212 /* XXX - Should this be GAIM_CONV_TYPE_IM? */ |
213 gconv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, | |
10246 | 214 nm_user_record_get_display_id(user_record), |
8675 | 215 (GaimAccount *) user->client_data); |
216 if (gconv) { | |
217 | |
218 dn = nm_user_record_get_dn(user_record); | |
219 if (dn) { | |
220 cntct = nm_find_contact(user, dn); | |
221 } | |
222 | |
223 if (cntct) { | |
224 gaim_conversation_set_title(gconv, | |
225 nm_contact_get_display_name(cntct)); | |
226 } else { | |
227 | |
228 /* Not in the contact list, try to user full name */ | |
229 name = (char *) nm_user_record_get_full_name(user_record); | |
230 if (name) | |
231 gaim_conversation_set_title(gconv, name); | |
232 } | |
233 } | |
234 | |
235 /* Add the user record to particpant list */ | |
236 conf = nm_message_get_conference(msg); | |
237 if (conf) { | |
238 nm_conference_add_participant(conf, user_record); | |
239 _send_message(user, msg); | |
240 } | |
241 } | |
242 | |
243 } else { | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
244 |
8675 | 245 gc = gaim_account_get_connection(user->client_data); |
246 if (gc != NULL) { | |
247 char *err = g_strdup_printf(_("Unable to send message." | |
8933 | 248 " Could not get details for user (%s)."), |
249 nm_error_to_string (ret_code)); | |
8675 | 250 |
251 gaim_notify_error(gc, NULL, err, NULL); | |
252 g_free(err); | |
253 } | |
254 | |
255 if (msg) | |
256 nm_release_message(msg); | |
257 } | |
258 } | |
259 | |
260 /* Set up the new GaimBuddy based on the response from getdetails */ | |
261 static void | |
262 _get_details_resp_setup_buddy(NMUser * user, NMERR_T ret_code, | |
263 gpointer resp_data, gpointer user_data) | |
264 { | |
265 NMUserRecord *user_record; | |
266 NMContact *contact; | |
267 GaimBuddy *buddy; | |
268 const char *alias; | |
269 NMERR_T rc = NM_OK; | |
270 | |
271 if (user == NULL || resp_data == NULL || user_data == NULL) | |
272 return; | |
273 | |
274 contact = user_data; | |
275 | |
276 if (ret_code == NM_OK) { | |
277 user_record = resp_data; | |
278 | |
279 buddy = nm_contact_get_data(contact); | |
280 | |
281 nm_contact_set_user_record(contact, user_record); | |
282 | |
283 /* Set the display id */ | |
284 gaim_blist_rename_buddy(buddy, | |
285 nm_user_record_get_display_id(user_record)); | |
286 | |
9620 | 287 alias = gaim_buddy_get_alias(buddy); |
9679 | 288 if (alias == NULL || *alias == '\0' || (strcmp(alias, buddy->name) == 0)) { |
8675 | 289 gaim_blist_alias_buddy(buddy, |
290 nm_user_record_get_full_name(user_record)); | |
291 | |
292 /* Tell the server about the new display name */ | |
293 rc = nm_send_rename_contact(user, contact, | |
294 nm_user_record_get_full_name(user_record), | |
295 NULL, NULL); | |
296 _check_for_disconnect(user, rc); | |
297 | |
298 } | |
299 | |
300 | |
301 /* Get initial status for the buddy */ | |
302 rc = nm_send_get_status(user, resp_data, _get_status_resp_cb, NULL); | |
303 _check_for_disconnect(user, rc); | |
304 | |
305 /* nm_release_contact(contact);*/ | |
306 | |
307 } | |
308 | |
309 if (contact) | |
310 nm_release_contact(contact); | |
311 } | |
312 | |
313 /* Add the new contact into the GaimBuddy list */ | |
314 static void | |
315 _create_contact_resp_cb(NMUser * user, NMERR_T ret_code, | |
316 gpointer resp_data, gpointer user_data) | |
317 { | |
318 NMContact *tmp_contact = (NMContact *) user_data; | |
319 NMContact *new_contact = NULL; | |
320 NMFolder *folder = NULL; | |
321 GaimGroup *group; | |
322 GaimBuddy *buddy; | |
323 const char *folder_name = NULL; | |
324 NMERR_T rc = NM_OK; | |
325 | |
326 if (user == NULL) | |
327 return; | |
328 | |
329 if (ret_code == NM_OK) { | |
330 | |
331 new_contact = (NMContact *) resp_data; | |
332 if (new_contact == NULL || tmp_contact == NULL) | |
333 return; | |
334 | |
335 /* Get the userid and folder name for the new contact */ | |
336 folder = nm_find_folder_by_id(user, | |
337 nm_contact_get_parent_id(new_contact)); | |
338 if (folder) { | |
339 folder_name = nm_folder_get_name(folder); | |
340 } | |
341 | |
9651 | 342 if (*folder_name == '\0') |
343 folder_name = NM_ROOT_FOLDER_NAME; | |
344 | |
8675 | 345 /* Re-add the buddy now that we got the okay from the server */ |
346 if (folder_name && (group = gaim_find_group(folder_name))) { | |
347 | |
348 const char *alias = nm_contact_get_display_name(tmp_contact); | |
349 const char *display_id = nm_contact_get_display_id(new_contact); | |
350 | |
351 if (display_id == NULL) | |
352 display_id = nm_contact_get_dn(new_contact); | |
353 | |
354 if (alias && strcmp(alias, display_id)) { | |
355 | |
356 /* The user requested an alias, tell the server about it. */ | |
357 rc = nm_send_rename_contact(user, new_contact, alias, | |
358 _rename_contact_resp_cb, NULL); | |
359 _check_for_disconnect(user, rc); | |
360 | |
361 } else { | |
362 | |
363 alias = ""; | |
364 | |
365 } | |
366 | |
367 /* Add it to the gaim buddy list if it is not there */ | |
368 buddy = gaim_find_buddy_in_group(user->client_data, display_id, group); | |
369 if (buddy == NULL) { | |
370 buddy = gaim_buddy_new(user->client_data, display_id, alias); | |
371 gaim_blist_add_buddy(buddy, NULL, group, NULL); | |
372 } | |
373 | |
374 /* Save the new buddy as part of the contact object */ | |
375 nm_contact_set_data(new_contact, (gpointer) buddy); | |
376 | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
377 /* We need details for the user before we can setup the |
8675 | 378 * new Gaim buddy. We always call this because the |
379 * 'createcontact' response fields do not always contain | |
380 * everything that we need. | |
381 */ | |
382 nm_contact_add_ref(new_contact); | |
383 | |
384 rc = nm_send_get_details(user, nm_contact_get_dn(new_contact), | |
385 _get_details_resp_setup_buddy, new_contact); | |
386 _check_for_disconnect(user, rc); | |
387 | |
388 } | |
389 | |
390 } else { | |
391 GaimConnection *gc = gaim_account_get_connection(user->client_data); | |
392 const char *name = nm_contact_get_dn(tmp_contact); | |
393 char *err; | |
394 | |
395 err = | |
8933 | 396 g_strdup_printf(_("Unable to add %s to your buddy list (%s)."), |
397 name, nm_error_to_string (ret_code)); | |
8675 | 398 gaim_notify_error(gc, NULL, err, NULL); |
399 g_free(err); | |
400 | |
401 } | |
402 | |
403 if (tmp_contact) | |
404 nm_release_contact(tmp_contact); | |
405 } | |
406 | |
407 /* Show an error if we failed to send the message */ | |
408 static void | |
409 _send_message_resp_cb(NMUser * user, NMERR_T ret_code, | |
410 gpointer resp_data, gpointer user_data) | |
411 { | |
412 GaimConnection *gc; | |
413 char *err = NULL; | |
414 | |
415 if (user == NULL) | |
416 return; | |
417 | |
418 if (ret_code != NM_OK) { | |
419 gc = gaim_account_get_connection(user->client_data); | |
420 | |
421 /* TODO: Improve this! message to who or for what conference? */ | |
8933 | 422 err = g_strdup_printf(_("Unable to send message (%s)."), |
423 nm_error_to_string (ret_code)); | |
8675 | 424 gaim_notify_error(gc, NULL, err, NULL); |
425 g_free(err); | |
426 } | |
427 } | |
428 | |
429 /* Show an error if the remove failed */ | |
430 static void | |
431 _remove_contact_resp_cb(NMUser * user, NMERR_T ret_code, | |
432 gpointer resp_data, gpointer user_data) | |
433 { | |
434 if (ret_code != NM_OK) { | |
435 /* TODO: Display an error? */ | |
436 | |
437 gaim_debug(GAIM_DEBUG_INFO, "novell", | |
438 "_remove_contact_resp_cb(): rc = 0x%x\n", ret_code); | |
439 } | |
440 } | |
441 | |
442 /* Show an error if the remove failed */ | |
443 static void | |
444 _remove_folder_resp_cb(NMUser * user, NMERR_T ret_code, | |
445 gpointer resp_data, gpointer user_data) | |
446 { | |
447 if (ret_code != NM_OK) { | |
448 /* TODO: Display an error? */ | |
449 | |
450 gaim_debug(GAIM_DEBUG_INFO, "novell", | |
451 "_remove_folder_resp_cb(): rc = 0x%x\n", ret_code); | |
452 } | |
453 } | |
454 | |
455 /* Show an error if the move failed */ | |
456 static void | |
457 _move_contact_resp_cb(NMUser * user, NMERR_T ret_code, | |
458 gpointer resp_data, gpointer user_data) | |
459 { | |
460 if (ret_code != NM_OK) { | |
461 /* TODO: Display an error? */ | |
462 | |
463 gaim_debug(GAIM_DEBUG_INFO, "novell", | |
464 "_move_contact_resp_cb(): rc = 0x%x\n", ret_code); | |
465 } | |
466 } | |
467 | |
468 /* Show an error if the rename failed */ | |
469 static void | |
470 _rename_folder_resp_cb(NMUser * user, NMERR_T ret_code, | |
471 gpointer resp_data, gpointer user_data) | |
472 { | |
473 if (ret_code != NM_OK) { | |
474 /* TODO: Display an error? */ | |
475 | |
476 gaim_debug(GAIM_DEBUG_INFO, "novell", | |
477 "_rename_folder_resp_cb(): rc = 0x%x\n", ret_code); | |
478 } | |
479 } | |
480 | |
8933 | 481 static void |
482 _sendinvite_resp_cb(NMUser *user, NMERR_T ret_code, | |
483 gpointer resp_data, gpointer user_data) | |
484 { | |
485 char *err; | |
486 GaimConnection *gc; | |
487 | |
488 if (user == NULL) | |
489 return; | |
490 | |
491 if (ret_code != NM_OK) { | |
492 gc = gaim_account_get_connection(user->client_data); | |
493 err = g_strdup_printf(_("Unable to invite user (%s)."), nm_error_to_string(ret_code)); | |
494 gaim_notify_error(gc, NULL, err, NULL); | |
495 g_free(err); | |
496 | |
497 gaim_debug(GAIM_DEBUG_INFO, "novell", | |
498 "_sendinvite_resp_cb(): rc = 0x%x\n", ret_code); | |
499 } | |
500 | |
501 } | |
502 | |
8675 | 503 /* If the createconf was successful attempt to send the message, |
504 * otherwise display an error message to the user. | |
505 */ | |
506 static void | |
507 _createconf_resp_send_msg(NMUser * user, NMERR_T ret_code, | |
508 gpointer resp_data, gpointer user_data) | |
509 { | |
510 NMConference *conf; | |
511 NMMessage *msg = user_data; | |
512 | |
513 if (user == NULL || msg == NULL) | |
514 return; | |
515 | |
516 if (ret_code == NM_OK) { | |
517 _send_message(user, msg); | |
518 } else { | |
519 | |
520 if ((conf = nm_message_get_conference(msg))) { | |
521 | |
522 GaimConnection *gc = gaim_account_get_connection(user->client_data); | |
523 const char *name = NULL; | |
524 char *err; | |
525 NMUserRecord *ur; | |
526 | |
527 ur = nm_conference_get_participant(conf, 0); | |
528 if (ur) | |
529 name = nm_user_record_get_userid(ur); | |
530 | |
531 if (name) | |
532 err = g_strdup_printf(_("Unable to send message to %s." | |
8933 | 533 " Could not create the conference (%s)."), |
534 name, | |
535 nm_error_to_string (ret_code)); | |
8675 | 536 else |
537 err = g_strdup_printf(_("Unable to send message." | |
8933 | 538 " Could not create the conference (%s)."), |
539 nm_error_to_string (ret_code)); | |
8675 | 540 |
541 gaim_notify_error(gc, NULL, err, NULL); | |
542 g_free(err); | |
543 } | |
544 | |
545 if (msg) | |
546 nm_release_message(msg); | |
547 } | |
548 } | |
549 | |
550 /* Move contact to newly created folder */ | |
551 static void | |
552 _create_folder_resp_move_contact(NMUser * user, NMERR_T ret_code, | |
553 gpointer resp_data, gpointer user_data) | |
554 { | |
555 NMContact *contact = user_data; | |
556 NMFolder *new_folder; | |
557 char *folder_name = resp_data; | |
558 NMERR_T rc = NM_OK; | |
559 | |
560 if (user == NULL || folder_name == NULL || contact == NULL) { | |
561 | |
562 if (folder_name) | |
563 g_free(folder_name); | |
564 | |
565 return; | |
566 } | |
567 | |
8933 | 568 if (ret_code == NM_OK || ret_code == NMERR_DUPLICATE_FOLDER) { |
8675 | 569 new_folder = nm_find_folder(user, folder_name); |
570 if (new_folder) { | |
571 | |
572 /* Tell the server to move the contact to the new folder */ | |
573 /* rc = nm_send_move_contact(user, contact, new_folder, | |
574 _move_contact_resp_cb, NULL); */ | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
575 |
8675 | 576 rc = nm_send_create_contact(user, new_folder, contact, |
577 NULL, NULL); | |
578 | |
579 _check_for_disconnect(user, rc); | |
580 | |
581 } | |
582 } else { | |
583 GaimConnection *gc = gaim_account_get_connection(user->client_data); | |
584 char *err = g_strdup_printf(_("Unable to move user %s" | |
585 " to folder %s in the server side list." | |
8933 | 586 " Error while creating folder (%s)."), |
587 nm_contact_get_dn(contact), | |
588 folder_name, | |
589 nm_error_to_string (ret_code)); | |
8675 | 590 |
591 gaim_notify_error(gc, NULL, err, NULL); | |
592 g_free(err); | |
593 } | |
594 | |
595 if (folder_name) | |
596 g_free(folder_name); | |
597 } | |
598 | |
599 /* Add contact to newly create folder */ | |
600 static void | |
601 _create_folder_resp_add_contact(NMUser * user, NMERR_T ret_code, | |
602 gpointer resp_data, gpointer user_data) | |
603 { | |
604 NMContact *contact = (NMContact *) user_data; | |
605 NMFolder *folder; | |
606 char *folder_name = (char *) resp_data; | |
607 NMERR_T rc = NM_OK; | |
608 | |
609 if (user == NULL || folder_name == NULL || contact == NULL) { | |
610 | |
611 if (contact) | |
612 nm_release_contact(contact); | |
613 | |
614 if (folder_name) | |
615 g_free(folder_name); | |
616 | |
617 return; | |
618 } | |
619 | |
8933 | 620 if (ret_code == NM_OK || ret_code == NMERR_DUPLICATE_FOLDER) { |
8675 | 621 folder = nm_find_folder(user, folder_name); |
622 if (folder) { | |
623 | |
624 rc = nm_send_create_contact(user, folder, contact, | |
625 _create_contact_resp_cb, contact); | |
626 _check_for_disconnect(user, rc); | |
627 } | |
628 } else { | |
629 GaimConnection *gc = gaim_account_get_connection(user->client_data); | |
630 const char *name = nm_contact_get_dn(contact); | |
631 char *err = | |
632 g_strdup_printf(_("Unable to add %s to your buddy list." | |
8933 | 633 " Error creating folder in server side list (%s)."), |
634 name, nm_error_to_string (ret_code)); | |
8675 | 635 |
636 gaim_notify_error(gc, NULL, err, NULL); | |
637 | |
638 nm_release_contact(contact); | |
639 g_free(err); | |
640 } | |
641 | |
642 g_free(folder_name); | |
643 } | |
644 | |
645 static void | |
646 _join_conf_resp_cb(NMUser * user, NMERR_T ret_code, | |
647 gpointer resp_data, gpointer user_data) | |
648 { | |
649 GaimConversation *chat; | |
650 GaimConnection *gc; | |
651 NMUserRecord *ur; | |
652 NMConference *conference = user_data; | |
8933 | 653 const char *name, *conf_name; |
8675 | 654 int i, count; |
655 | |
656 if (user == NULL || conference == NULL) | |
657 return; | |
658 | |
659 gc = gaim_account_get_connection(user->client_data); | |
660 | |
661 if (ret_code == NM_OK) { | |
8933 | 662 conf_name = _get_conference_name(++user->conference_count); |
8675 | 663 chat = serv_got_joined_chat(gc, user->conference_count, conf_name); |
664 if (chat) { | |
665 | |
666 nm_conference_set_data(conference, (gpointer) chat); | |
667 | |
668 count = nm_conference_get_participant_count(conference); | |
669 for (i = 0; i < count; i++) { | |
670 ur = nm_conference_get_participant(conference, i); | |
671 if (ur) { | |
672 name = nm_user_record_get_display_id(ur); | |
9846 | 673 gaim_conv_chat_add_user(GAIM_CONV_CHAT(chat), name, NULL, |
674 GAIM_CBFLAGS_NONE, TRUE); | |
8675 | 675 } |
676 } | |
677 } | |
678 } | |
679 } | |
680 | |
681 /* Show info returned by getdetails */ | |
682 static void | |
683 _get_details_resp_show_info(NMUser * user, NMERR_T ret_code, | |
684 gpointer resp_data, gpointer user_data) | |
685 { | |
686 GaimConnection *gc; | |
687 NMUserRecord *user_record; | |
688 char *name; | |
689 char *err; | |
690 | |
691 if (user == NULL) | |
692 return; | |
693 | |
694 name = user_data; | |
695 | |
696 if (ret_code == NM_OK) { | |
697 user_record = (NMUserRecord *) resp_data; | |
698 if (user_record) { | |
699 _show_info(gaim_account_get_connection(user->client_data), | |
700 user_record); | |
701 } | |
702 } else { | |
703 gc = gaim_account_get_connection(user->client_data); | |
704 err = | |
8933 | 705 g_strdup_printf(_("Could not get details for user %s (%s)."), |
706 name, nm_error_to_string (ret_code)); | |
8675 | 707 gaim_notify_error(gc, NULL, err, NULL); |
708 g_free(err); | |
709 } | |
710 | |
711 if (name) | |
712 g_free(name); | |
713 } | |
714 | |
8933 | 715 /* Handle get details response add to privacy list */ |
716 static void | |
717 _get_details_resp_add_privacy_item(NMUser *user, NMERR_T ret_code, | |
718 gpointer resp_data, gpointer user_data) | |
719 { | |
720 GaimConnection *gc; | |
721 NMUserRecord *user_record = resp_data; | |
722 char *err; | |
10112 | 723 gboolean allowed = GPOINTER_TO_INT(user_data); |
8933 | 724 const char *display_id; |
725 | |
726 if (user == NULL) | |
727 return; | |
728 | |
729 gc = gaim_account_get_connection(user->client_data); | |
730 display_id = nm_user_record_get_display_id(user_record); | |
731 | |
732 if (ret_code == NM_OK) { | |
733 | |
734 if (allowed) { | |
735 | |
736 if (!g_slist_find_custom(gc->account->permit, | |
737 display_id, (GCompareFunc)nm_utf8_strcasecmp)) { | |
738 gaim_privacy_permit_add(gc->account, display_id, TRUE); | |
739 } | |
740 | |
741 } else { | |
742 | |
743 if (!g_slist_find_custom(gc->account->permit, | |
744 display_id, (GCompareFunc)nm_utf8_strcasecmp)) { | |
745 gaim_privacy_deny_add(gc->account, display_id, TRUE); | |
746 } | |
747 } | |
748 | |
749 } else { | |
750 | |
751 err = g_strdup_printf(_("Unable to add user to privacy list (%s)."), | |
752 nm_error_to_string(ret_code)); | |
753 gaim_notify_error(gc, NULL, err, NULL); | |
754 g_free(err); | |
755 | |
756 } | |
757 } | |
758 | |
759 /* Handle response to create privacy item request */ | |
760 static void | |
761 _create_privacy_item_deny_resp_cb(NMUser *user, NMERR_T ret_code, | |
762 gpointer resp_data, gpointer user_data) | |
763 { | |
764 GaimConnection *gc; | |
765 NMUserRecord *user_record; | |
766 char *who = user_data; | |
767 char *err; | |
768 NMERR_T rc = NM_OK; | |
769 const char *display_id = NULL; | |
770 | |
771 if (user == NULL) | |
772 return; | |
773 | |
774 gc = gaim_account_get_connection(user->client_data); | |
775 | |
776 if (ret_code == NM_OK) { | |
777 | |
778 user_record = nm_find_user_record(user, who); | |
779 if (user_record) | |
780 display_id = nm_user_record_get_display_id(user_record); | |
781 | |
782 if (display_id) { | |
783 | |
784 if (!g_slist_find_custom(gc->account->deny, | |
785 display_id, (GCompareFunc)nm_utf8_strcasecmp)) { | |
786 | |
787 gaim_privacy_deny_add(gc->account, display_id, TRUE); | |
788 } | |
789 | |
790 } else { | |
791 rc = nm_send_get_details(user, who, | |
792 _get_details_resp_add_privacy_item, | |
793 (gpointer)FALSE); | |
794 _check_for_disconnect(user, rc); | |
795 } | |
796 } else { | |
797 | |
798 err = g_strdup_printf(_("Unable to add %s to deny list (%s)."), | |
799 who, nm_error_to_string(ret_code)); | |
800 gaim_notify_error(gc, NULL, err, NULL); | |
801 g_free(err); | |
802 | |
803 } | |
804 | |
805 if (who) | |
806 g_free(who); | |
807 | |
808 } | |
809 | |
810 /* Handle response to create privacy item request */ | |
811 static void | |
812 _create_privacy_item_permit_resp_cb(NMUser *user, NMERR_T ret_code, | |
813 gpointer resp_data, gpointer user_data) | |
814 { | |
815 GaimConnection *gc; | |
816 NMUserRecord *user_record; | |
817 char *who = user_data; | |
818 char *err; | |
819 NMERR_T rc = NM_OK; | |
820 const char *display_id = NULL; | |
821 | |
822 if (user == NULL) | |
823 return; | |
824 | |
825 gc = gaim_account_get_connection(user->client_data); | |
826 | |
827 if (ret_code == NM_OK) { | |
828 | |
829 user_record = nm_find_user_record(user, who); | |
830 if (user_record) | |
831 display_id = nm_user_record_get_display_id(user_record); | |
832 | |
833 if (display_id) { | |
834 | |
835 if (!g_slist_find_custom(gc->account->permit, | |
836 display_id, | |
837 (GCompareFunc)nm_utf8_strcasecmp)) { | |
838 | |
839 gaim_privacy_permit_add(gc->account, display_id, TRUE); | |
840 } | |
841 | |
842 } else { | |
843 rc = nm_send_get_details(user, who, | |
844 _get_details_resp_add_privacy_item, | |
845 (gpointer)TRUE); | |
846 _check_for_disconnect(user, rc); | |
847 } | |
848 | |
849 } else { | |
850 | |
851 err = g_strdup_printf(_("Unable to add %s to permit list (%s)."), who, | |
852 nm_error_to_string(ret_code)); | |
853 gaim_notify_error(gc, NULL, err, NULL); | |
854 g_free(err); | |
855 | |
856 } | |
857 | |
858 if (who) | |
859 g_free(who); | |
860 } | |
861 | |
862 static void | |
863 _get_details_send_privacy_create(NMUser *user, NMERR_T ret_code, | |
864 gpointer resp_data, gpointer user_data) | |
865 { | |
866 NMERR_T rc = NM_OK; | |
867 GaimConnection *gc; | |
868 NMUserRecord *user_record = resp_data; | |
869 char *err; | |
10112 | 870 gboolean allowed = GPOINTER_TO_INT(user_data); |
8933 | 871 const char *dn, *display_id; |
872 | |
873 if (user == NULL) | |
874 return; | |
875 | |
876 gc = gaim_account_get_connection(user->client_data); | |
877 dn = nm_user_record_get_dn(user_record); | |
878 display_id = nm_user_record_get_display_id(user_record); | |
879 | |
880 if (ret_code == NM_OK) { | |
881 | |
882 if (allowed) { | |
883 rc = nm_send_create_privacy_item(user, dn, TRUE, | |
884 _create_privacy_item_permit_resp_cb, | |
885 g_strdup(display_id)); | |
886 _check_for_disconnect(user, rc); | |
887 | |
888 } else { | |
889 rc = nm_send_create_privacy_item(user, dn, FALSE, | |
890 _create_privacy_item_deny_resp_cb, | |
891 g_strdup(display_id)); | |
892 _check_for_disconnect(user, rc); | |
893 } | |
894 | |
895 } else { | |
896 | |
897 err = g_strdup_printf(_("Unable to add user to privacy list (%s)."), | |
898 nm_error_to_string(ret_code)); | |
899 gaim_notify_error(gc, NULL, err, NULL); | |
900 g_free(err); | |
901 | |
902 } | |
903 } | |
904 | |
905 static void | |
906 _remove_privacy_item_resp_cb(NMUser *user, NMERR_T ret_code, | |
907 gpointer resp_data, gpointer user_data) | |
908 { | |
909 GaimConnection *gc; | |
910 char *who = user_data; | |
911 char *err; | |
912 | |
913 if (user == NULL) | |
914 return; | |
915 | |
916 if (ret_code != NM_OK) { | |
917 | |
918 gc = gaim_account_get_connection(user->client_data); | |
919 err = g_strdup_printf(_("Unable to remove %s from privacy list (%s)."), who, | |
920 nm_error_to_string(ret_code)); | |
921 gaim_notify_error(gc, NULL, err, NULL); | |
922 g_free(err); | |
923 } | |
924 | |
925 if (who) | |
926 g_free(who); | |
927 } | |
928 | |
929 static void | |
930 _set_privacy_default_resp_cb(NMUser *user, NMERR_T ret_code, | |
931 gpointer resp_data, gpointer user_data) | |
932 { | |
933 GaimConnection *gc; | |
934 char *err; | |
935 | |
936 if (user == NULL) | |
937 return; | |
938 | |
939 if (ret_code != NM_OK) { | |
940 | |
941 gc = gaim_account_get_connection(user->client_data); | |
942 err = g_strdup_printf(_("Unable to change server side privacy settings (%s)."), | |
943 nm_error_to_string(ret_code)); | |
944 gaim_notify_error(gc, NULL, err, NULL); | |
945 g_free(err); | |
946 | |
947 } | |
948 } | |
949 | |
950 /* Handle get details response add to privacy list */ | |
951 static void | |
952 _get_details_resp_send_invite(NMUser *user, NMERR_T ret_code, | |
953 gpointer resp_data, gpointer user_data) | |
954 { | |
955 NMERR_T rc = NM_OK; | |
956 GaimConnection *gc; | |
957 NMUserRecord *user_record = resp_data; | |
958 char *err; | |
959 const char *display_id; | |
960 GSList *cnode; | |
961 NMConference *conference; | |
962 gpointer chat; | |
963 long id = (long) user_data; | |
964 | |
965 if (user == NULL) | |
966 return; | |
967 | |
968 gc = gaim_account_get_connection(user->client_data); | |
969 display_id = nm_user_record_get_display_id(user_record); | |
970 | |
971 if (ret_code == NM_OK) { | |
972 | |
973 for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) { | |
974 conference = cnode->data; | |
975 if (conference && (chat = nm_conference_get_data(conference))) { | |
976 if (gaim_conv_chat_get_id(GAIM_CONV_CHAT(chat)) == id) { | |
977 rc = nm_send_conference_invite(user, conference, user_record, | |
978 NULL, _sendinvite_resp_cb, NULL); | |
979 _check_for_disconnect(user, rc); | |
980 break; | |
981 } | |
982 } | |
983 } | |
984 | |
985 } else { | |
986 | |
987 err = g_strdup_printf(_("Unable to invite user (%s)."), nm_error_to_string(ret_code)); | |
988 gaim_notify_error(gc, NULL, err, NULL); | |
989 g_free(err); | |
990 | |
991 } | |
992 } | |
993 | |
994 static void | |
995 _createconf_resp_send_invite(NMUser * user, NMERR_T ret_code, | |
996 gpointer resp_data, gpointer user_data) | |
997 { | |
998 NMERR_T rc = NM_OK; | |
999 NMConference *conference = resp_data; | |
1000 NMUserRecord *user_record = user_data; | |
1001 GaimConnection *gc; | |
1002 char *err; | |
1003 | |
1004 if (user == NULL) | |
1005 return; | |
1006 | |
1007 | |
1008 | |
1009 if (ret_code == NM_OK) { | |
1010 rc = nm_send_conference_invite(user, conference, user_record, | |
1011 NULL, _sendinvite_resp_cb, NULL); | |
1012 _check_for_disconnect(user, rc); | |
1013 } else { | |
1014 err = g_strdup_printf(_("Unable to create conference (%s)."), nm_error_to_string(ret_code)); | |
1015 gc = gaim_account_get_connection(user->client_data); | |
1016 gaim_notify_error(gc, NULL, err, NULL); | |
1017 g_free(err); | |
1018 } | |
1019 } | |
1020 | |
8675 | 1021 /******************************************************************************* |
1022 * Helper functions | |
1023 ******************************************************************************/ | |
1024 | |
1025 static char * | |
1026 _user_agent_string() | |
1027 { | |
1028 | |
1029 #if !defined(_WIN32) | |
1030 | |
1031 const char *sysname = ""; | |
1032 const char *release = ""; | |
1033 struct utsname u; | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1034 |
8675 | 1035 if (uname(&u) == 0) { |
1036 sysname = u.sysname; | |
1037 release = u.release; | |
1038 } else { | |
1039 sysname = "Linux"; | |
1040 release = "Unknown"; | |
1041 } | |
1042 | |
12408
3d297efa70bb
[gaim-migrate @ 14715]
Richard Laager <rlaager@wiktel.com>
parents:
12222
diff
changeset
|
1043 return g_strdup_printf("Gaim/%s (%s; %s)", VERSION, sysname, release); |
8675 | 1044 |
1045 #else | |
1046 | |
1047 const char *sysname = ""; | |
1048 OSVERSIONINFO os_info; | |
1049 SYSTEM_INFO sys_info; | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1050 |
8675 | 1051 os_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
1052 GetVersionEx(&os_info); | |
1053 GetSystemInfo(&sys_info); | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1054 |
8675 | 1055 if (os_info.dwPlatformId == VER_PLATFORM_WIN32_NT) { |
1056 switch (os_info.dwMajorVersion) { | |
1057 case 3: | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1058 case 4: |
8675 | 1059 sysname = "Windows NT"; |
1060 break; | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1061 case 5: |
8675 | 1062 switch (os_info.dwMinorVersion) { |
1063 case 0: | |
1064 sysname = "Windows 2000"; | |
1065 break; | |
1066 case 1: | |
1067 sysname = "Windows XP"; | |
1068 break; | |
1069 case 2: | |
1070 sysname = "Windows Server 2003"; | |
1071 break; | |
1072 default: | |
1073 sysname = "Windows"; | |
1074 break; | |
1075 } | |
1076 break; | |
1077 default: | |
1078 sysname = "Windows"; | |
1079 break; | |
1080 } | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1081 |
8675 | 1082 } else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { |
1083 switch (os_info.dwMinorVersion) { | |
1084 case 0: | |
1085 sysname = "Windows 95"; | |
1086 break; | |
1087 case 10: | |
1088 sysname = "Windows 98"; | |
1089 break; | |
1090 case 90: | |
1091 sysname = "Windows ME"; | |
1092 break; | |
1093 default: | |
1094 sysname = "Windows"; | |
1095 break; | |
1096 } | |
1097 } else { | |
1098 sysname = "Windows"; | |
1099 } | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1100 |
12715
3dedbe04a684
[gaim-migrate @ 15059]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12658
diff
changeset
|
1101 return g_strdup_printf("Gaim/%s (%s; %ld.%ld)", VERSION, sysname, |
8675 | 1102 os_info.dwMajorVersion, os_info.dwMinorVersion); |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1103 |
8675 | 1104 #endif |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1105 |
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1106 |
8675 | 1107 } |
1108 | |
1109 static gboolean | |
1110 _is_disconnect_error(NMERR_T err) | |
1111 { | |
1112 return (err == NMERR_TCP_WRITE || | |
1113 err == NMERR_TCP_READ || err == NMERR_PROTOCOL); | |
1114 } | |
1115 | |
1116 static gboolean | |
1117 _check_for_disconnect(NMUser * user, NMERR_T err) | |
1118 { | |
1119 GaimConnection *gc = gaim_account_get_connection(user->client_data); | |
1120 | |
1121 if (_is_disconnect_error(err)) { | |
1122 | |
1123 gaim_connection_error(gc, _("Error communicating with server." | |
1124 " Closing connection.")); | |
1125 return TRUE; | |
1126 | |
1127 } | |
1128 | |
1129 return FALSE; | |
1130 } | |
1131 | |
1132 /* Check to see if the conference is instantiated, if so send the message. | |
1133 * If not send the create conference -- the response handler for the createconf | |
1134 * will call this function again. | |
1135 */ | |
1136 static void | |
1137 _send_message(NMUser * user, NMMessage * message) | |
1138 { | |
1139 NMConference *conf; | |
1140 NMERR_T rc = NM_OK; | |
1141 | |
1142 conf = nm_message_get_conference(message); | |
1143 if (conf) { | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1144 /* We have a conference make sure that the |
8675 | 1145 server knows about it already. */ |
1146 if (nm_conference_is_instantiated(conf)) { | |
1147 | |
1148 /* We have everything that we need...finally! */ | |
1149 rc = nm_send_message(user, message, _send_message_resp_cb); | |
1150 _check_for_disconnect(user, rc); | |
1151 | |
1152 nm_release_message(message); | |
1153 | |
1154 } else { | |
8933 | 1155 rc = nm_send_create_conference(user, conf, _createconf_resp_send_msg, message); |
8675 | 1156 _check_for_disconnect(user, rc); |
1157 } | |
1158 } | |
1159 } | |
1160 | |
11971 | 1161 /* |
1162 * Update the status of the given buddy in the Gaim buddy list | |
1163 */ | |
8675 | 1164 static void |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1165 _update_buddy_status(NMUser *user, GaimBuddy * buddy, int novellstatus, int gmt) |
8675 | 1166 { |
11971 | 1167 GaimAccount *account; |
1168 const char *status_id; | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1169 const char *text = NULL; |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1170 const char *dn; |
8675 | 1171 int idle = 0; |
9927 | 1172 gboolean loggedin = TRUE; |
8675 | 1173 |
11971 | 1174 account = buddy->account; |
1175 | |
1176 switch (novellstatus) { | |
8675 | 1177 case NM_STATUS_AVAILABLE: |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1178 status_id = NOVELL_STATUS_TYPE_AVAILABLE; |
8675 | 1179 break; |
1180 case NM_STATUS_AWAY: | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1181 status_id = NOVELL_STATUS_TYPE_AWAY; |
11971 | 1182 break; |
8675 | 1183 case NM_STATUS_BUSY: |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1184 status_id = NOVELL_STATUS_TYPE_BUSY; |
8675 | 1185 break; |
1186 case NM_STATUS_OFFLINE: | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1187 status_id = NOVELL_STATUS_TYPE_OFFLINE; |
9927 | 1188 loggedin = FALSE; |
8675 | 1189 break; |
1190 case NM_STATUS_AWAY_IDLE: | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1191 status_id = NOVELL_STATUS_TYPE_AWAY; |
8675 | 1192 idle = gmt; |
1193 break; | |
1194 default: | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1195 status_id = NOVELL_STATUS_TYPE_OFFLINE; |
9927 | 1196 loggedin = FALSE; |
8675 | 1197 break; |
1198 } | |
1199 | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1200 /* Get status text for the user */ |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1201 dn = nm_lookup_dn(user, buddy->name); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1202 if (dn) { |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1203 NMUserRecord *user_record = nm_find_user_record(user, dn); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1204 if (user_record) { |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1205 text = nm_user_record_get_status_text(user_record); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1206 } |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1207 } |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1208 |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1209 gaim_prpl_got_user_status(account, buddy->name, status_id, |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1210 "message", text, NULL); |
11971 | 1211 gaim_prpl_got_user_idle(account, buddy->name, |
1212 (novellstatus == NM_STATUS_AWAY_IDLE), idle); | |
8675 | 1213 } |
1214 | |
8933 | 1215 /* Iterate through the cached Gaim buddy list and remove buddies |
1216 * that are not in the server side list. | |
8675 | 1217 */ |
1218 static void | |
8933 | 1219 _remove_gaim_buddies(NMUser *user) |
8675 | 1220 { |
1221 GaimBlistNode *gnode; | |
1222 GaimBlistNode *cnode; | |
1223 GaimBlistNode *bnode; | |
1224 GaimGroup *group; | |
1225 GaimBuddy *buddy; | |
1226 GaimBuddyList *blist; | |
1227 GSList *rem_list = NULL; | |
1228 GSList *l; | |
8933 | 1229 NMFolder *folder = NULL; |
9651 | 1230 const char *gname = NULL; |
8675 | 1231 |
1232 if ((blist = gaim_get_blist())) { | |
1233 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
1234 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
1235 continue; | |
1236 group = (GaimGroup *) gnode; | |
1237 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
1238 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
1239 continue; | |
1240 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
1241 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
1242 continue; | |
1243 buddy = (GaimBuddy *) bnode; | |
1244 if (buddy->account == user->client_data) { | |
9651 | 1245 gname = group->name; |
1246 if (strcmp(group->name, NM_ROOT_FOLDER_NAME) == 0) | |
1247 gname = ""; | |
1248 folder = nm_find_folder(user, gname); | |
8933 | 1249 if (folder == NULL || |
1250 !nm_folder_find_contact_by_display_id(folder, buddy->name)) { | |
1251 rem_list = g_slist_append(rem_list, buddy); | |
1252 } | |
8675 | 1253 } |
1254 } | |
1255 } | |
1256 } | |
1257 | |
1258 if (rem_list) { | |
1259 for (l = rem_list; l; l = l->next) { | |
1260 gaim_blist_remove_buddy(l->data); | |
1261 } | |
1262 g_slist_free(rem_list); | |
1263 } | |
1264 } | |
1265 } | |
1266 | |
1267 /* Add all of the contacts in the given folder to the Gaim buddy list */ | |
1268 static void | |
1269 _add_contacts_to_gaim_blist(NMUser * user, NMFolder * folder) | |
1270 { | |
1271 NMUserRecord *user_record = NULL; | |
1272 NMContact *contact = NULL; | |
1273 GaimBuddy *buddy = NULL; | |
8782
5a2b5e4abf3a
[gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents:
8781
diff
changeset
|
1274 GaimGroup *group; |
8675 | 1275 NMERR_T cnt = 0, i; |
1276 const char *text = NULL; | |
1277 const char *name = NULL; | |
9651 | 1278 const char *fname = NULL; |
8675 | 1279 int status = 0; |
1280 | |
9651 | 1281 /* If this is the root folder give it a name. Gaim does not have the concept of |
1282 * a root folder. | |
1283 */ | |
1284 fname = nm_folder_get_name(folder); | |
1285 if (fname == NULL || *fname == '\0') { | |
1286 fname = NM_ROOT_FOLDER_NAME; | |
1287 } | |
1288 | |
8933 | 1289 /* Does the Gaim group exist already? */ |
9651 | 1290 group = gaim_find_group(fname); |
8933 | 1291 if (group == NULL) { |
9651 | 1292 group = gaim_group_new(fname); |
8933 | 1293 gaim_blist_add_group(group, NULL); |
1294 } | |
1295 | |
8675 | 1296 /* Get each contact for this folder */ |
1297 cnt = nm_folder_get_contact_count(folder); | |
1298 for (i = 0; i < cnt; i++) { | |
1299 contact = nm_folder_get_contact(folder, i); | |
1300 if (contact) { | |
1301 | |
1302 name = nm_contact_get_display_id(contact); | |
1303 if (name) { | |
8933 | 1304 |
1305 buddy = gaim_find_buddy_in_group(user->client_data, name, group); | |
1306 if (buddy == NULL) { | |
1307 /* Add it to the gaim buddy list */ | |
1308 buddy = gaim_buddy_new(user->client_data, | |
1309 name, | |
1310 nm_contact_get_display_name(contact)); | |
1311 | |
1312 gaim_blist_add_buddy(buddy, NULL, group, NULL); | |
8675 | 1313 } |
1314 | |
1315 /* Set the initial status for the buddy */ | |
1316 user_record = nm_contact_get_user_record(contact); | |
1317 if (user_record) { | |
1318 status = nm_user_record_get_status(user_record); | |
1319 text = nm_user_record_get_status_text(user_record); | |
1320 } | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1321 _update_buddy_status(user, buddy, status, time(0)); |
8675 | 1322 |
1323 /* Save the new buddy as part of the contact object */ | |
1324 nm_contact_set_data(contact, (gpointer) buddy); | |
1325 } | |
1326 | |
1327 } else { | |
1328 /* NULL contact. This should not happen, but | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1329 * let's break out of the loop. |
8675 | 1330 */ |
1331 break; | |
1332 } | |
1333 } | |
1334 } | |
1335 | |
1336 /* Add all of the server side contacts to the Gaim buddy list. */ | |
1337 static void | |
1338 _add_gaim_buddies(NMUser * user) | |
1339 { | |
9651 | 1340 int cnt = 0, i; |
8675 | 1341 NMFolder *root_folder = NULL; |
1342 NMFolder *folder = NULL; | |
1343 | |
1344 root_folder = nm_get_root_folder(user); | |
1345 if (root_folder) { | |
1346 | |
9651 | 1347 /* Add sub-folders and contacts to sub-folders... |
1348 * iterate throught the sub-folders in reverse order | |
1349 * because Gaim adds the folders to the front -- so we | |
1350 * want to add the first folder last | |
1351 */ | |
8675 | 1352 cnt = nm_folder_get_subfolder_count(root_folder); |
9651 | 1353 for (i = cnt-1; i >= 0; i--) { |
8675 | 1354 folder = nm_folder_get_subfolder(root_folder, i); |
1355 if (folder) { | |
1356 _add_contacts_to_gaim_blist(user, folder); | |
1357 } | |
1358 } | |
1359 | |
1360 /* Add contacts for the root folder */ | |
1361 _add_contacts_to_gaim_blist(user, root_folder); | |
1362 } | |
1363 } | |
1364 | |
8933 | 1365 static void |
1366 _sync_contact_list(NMUser *user) | |
1367 { | |
1368 /* Remove all buddies from the local list that are | |
1369 * not in the server side list and add all buddies | |
1370 * from the server side list that are not in | |
1371 * the local list | |
1372 */ | |
1373 _remove_gaim_buddies(user); | |
1374 _add_gaim_buddies(user); | |
9360 | 1375 user->clist_synched = TRUE; |
8933 | 1376 } |
1377 | |
1378 static void | |
1379 _sync_privacy_lists(NMUser *user) | |
1380 { | |
1381 GSList *node = NULL, *rem_list = NULL; | |
1382 GaimConnection *gc; | |
1383 const char *name, *dn; | |
1384 NMUserRecord *user_record; | |
1385 | |
1386 if (user == NULL) | |
1387 return; | |
1388 | |
1389 gc = gaim_account_get_connection(user->client_data); | |
1390 if (gc == NULL) | |
1391 return; | |
1392 | |
1393 /* Set the Gaim privacy setting */ | |
1394 if (user->default_deny) { | |
1395 if (user->allow_list == NULL) { | |
1396 gc->account->perm_deny = GAIM_PRIVACY_DENY_ALL; | |
1397 } else { | |
1398 gc->account->perm_deny = GAIM_PRIVACY_ALLOW_USERS; | |
1399 } | |
1400 } else { | |
1401 if (user->deny_list == NULL) { | |
1402 gc->account->perm_deny = GAIM_PRIVACY_ALLOW_ALL; | |
1403 } else { | |
1404 gc->account->perm_deny = GAIM_PRIVACY_DENY_USERS; | |
1405 } | |
1406 } | |
1407 | |
1408 /* Add stuff */ | |
1409 for (node = user->allow_list; node; node = node->next) { | |
1410 user_record = nm_find_user_record(user, (char *)node->data); | |
1411 if (user_record) | |
1412 name = nm_user_record_get_display_id(user_record); | |
1413 else | |
1414 name =(char *)node->data; | |
1415 | |
1416 if (!g_slist_find_custom(gc->account->permit, | |
1417 name, (GCompareFunc)nm_utf8_strcasecmp)) { | |
1418 gaim_privacy_permit_add(gc->account, name , TRUE); | |
1419 } | |
1420 } | |
1421 | |
1422 for (node = user->deny_list; node; node = node->next) { | |
1423 user_record = nm_find_user_record(user, (char *)node->data); | |
1424 if (user_record) | |
1425 name = nm_user_record_get_display_id(user_record); | |
1426 else | |
1427 name =(char *)node->data; | |
1428 | |
1429 if (!g_slist_find_custom(gc->account->deny, | |
1430 name, (GCompareFunc)nm_utf8_strcasecmp)) { | |
1431 gaim_privacy_deny_add(gc->account, name, TRUE); | |
1432 } | |
1433 } | |
1434 | |
1435 | |
1436 /* Remove stuff */ | |
1437 for (node = gc->account->permit; node; node = node->next) { | |
1438 dn = nm_lookup_dn(user, (char *)node->data); | |
1439 if (dn != NULL && | |
1440 !g_slist_find_custom(user->allow_list, | |
1441 dn, (GCompareFunc)nm_utf8_strcasecmp)) { | |
1442 rem_list = g_slist_append(rem_list, node->data); | |
1443 } | |
1444 } | |
1445 | |
1446 if (rem_list) { | |
1447 for (node = rem_list; node; node = node->next) { | |
1448 gaim_privacy_permit_remove(gc->account, (char *)node->data, TRUE); | |
1449 } | |
1450 g_free(rem_list); | |
1451 rem_list = NULL; | |
1452 } | |
1453 | |
1454 for (node = gc->account->deny; node; node = node->next) { | |
1455 dn = nm_lookup_dn(user, (char *)node->data); | |
1456 if (dn != NULL && | |
1457 !g_slist_find_custom(user->deny_list, | |
1458 dn, (GCompareFunc)nm_utf8_strcasecmp)) { | |
1459 rem_list = g_slist_append(rem_list, node->data); | |
1460 } | |
1461 } | |
1462 | |
1463 if (rem_list) { | |
1464 for (node = rem_list; node; node = node->next) { | |
1465 gaim_privacy_deny_remove(gc->account, (char *)node->data, TRUE); | |
1466 } | |
1467 g_slist_free(rem_list); | |
1468 } | |
1469 } | |
1470 | |
9820 | 1471 /* Map known property tags to user-friendly strings */ |
1472 static const char * | |
1473 _map_property_tag(const char *tag) | |
1474 { | |
1475 if (tag == NULL) return NULL; | |
1476 | |
1477 if (strcmp(tag, "telephoneNumber") == 0) | |
1478 return _("Telephone Number"); | |
1479 else if (strcmp(tag, "L") == 0) | |
1480 return _("Location"); | |
1481 else if (strcmp(tag, "OU") == 0) | |
1482 return _("Department"); | |
1483 else if (strcmp(tag, "personalTitle") == 0) | |
1484 return _("Personal Title"); | |
1485 else if (strcmp(tag, "Title") == 0) | |
1486 return _("Title"); | |
1487 else if (strcmp(tag, "mailstop") == 0) | |
1488 return _("Mailstop"); | |
1489 else if (strcmp(tag, "Internet EMail Address") == 0) | |
1490 return _("Email Address"); | |
1491 else | |
1492 return tag; | |
1493 } | |
1494 | |
8675 | 1495 /* Display a dialog box showing the properties for the given user record */ |
1496 static void | |
1497 _show_info(GaimConnection * gc, NMUserRecord * user_record) | |
1498 { | |
1499 GString *info_text; | |
1500 int count, i; | |
1501 NMProperty *property; | |
1502 const char *tag, *value; | |
1503 | |
1504 info_text = g_string_new(""); | |
1505 | |
9820 | 1506 tag = _("User ID"); |
8675 | 1507 value = nm_user_record_get_userid(user_record); |
1508 if (value) { | |
9820 | 1509 g_string_append_printf(info_text, "<b>%s:</b> %s<br>", tag, value); |
8675 | 1510 } |
1511 | |
1512 /* tag = _("DN"); | |
1513 value = nm_user_record_get_dn(user_record); | |
1514 if (value) { | |
9820 | 1515 g_string_append_printf(info_text, "<b>%s:</b> %s<br>", |
8675 | 1516 tag, value); |
1517 } | |
1518 */ | |
1519 | |
1520 tag = _("Full name"); | |
1521 value = nm_user_record_get_full_name(user_record); | |
1522 if (value) { | |
9820 | 1523 g_string_append_printf(info_text, "<b>%s:</b> %s<br>", tag, value); |
8675 | 1524 } |
1525 | |
1526 count = nm_user_record_get_property_count(user_record); | |
1527 for (i = 0; i < count; i++) { | |
1528 property = nm_user_record_get_property(user_record, i); | |
1529 if (property) { | |
9820 | 1530 tag = _map_property_tag(nm_property_get_tag(property)); |
8675 | 1531 value = nm_property_get_value(property); |
1532 if (tag && value) { | |
9820 | 1533 g_string_append_printf(info_text, "<b>%s:</b> %s<br>", |
8675 | 1534 tag, value); |
1535 } | |
1536 nm_release_property(property); | |
1537 } | |
1538 } | |
1539 | |
11531
bf763a1b2454
[gaim-migrate @ 13780]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1540 gaim_notify_userinfo(gc, nm_user_record_get_userid(user_record), |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11531
diff
changeset
|
1541 info_text->str, NULL, NULL); |
8675 | 1542 |
1543 g_string_free(info_text, TRUE); | |
1544 } | |
1545 | |
1546 /* Send a join conference, the first item in the parms list is the | |
1547 * NMUser object and the second item is the conference to join. | |
1548 * This callback is passed to gaim_request_action when we ask the | |
1549 * user if they want to join the conference. | |
1550 */ | |
1551 static void | |
1552 _join_conference_cb(GSList * parms) | |
1553 { | |
1554 NMUser *user; | |
1555 NMConference *conference; | |
1556 NMERR_T rc = NM_OK; | |
1557 | |
1558 if (parms == NULL || g_slist_length(parms) != 2) | |
1559 return; | |
1560 | |
1561 user = g_slist_nth_data(parms, 0); | |
1562 conference = g_slist_nth_data(parms, 1); | |
1563 | |
1564 if (user && conference) { | |
1565 rc = nm_send_join_conference(user, conference, | |
1566 _join_conf_resp_cb, conference); | |
1567 _check_for_disconnect(user, rc); | |
1568 } | |
1569 | |
1570 g_slist_free(parms); | |
1571 } | |
1572 | |
1573 /* Send a reject conference, the first item in the parms list is the | |
1574 * NMUser object and the second item is the conference to reject. | |
1575 * This callback is passed to gaim_request_action when we ask the | |
1576 * user if they want to joing the conference. | |
1577 */ | |
1578 static void | |
1579 _reject_conference_cb(GSList * parms) | |
1580 { | |
1581 NMUser *user; | |
1582 NMConference *conference; | |
1583 NMERR_T rc = NM_OK; | |
1584 | |
1585 if (parms == NULL || g_slist_length(parms) != 2) | |
1586 return; | |
1587 | |
1588 user = g_slist_nth_data(parms, 0); | |
1589 conference = g_slist_nth_data(parms, 1); | |
1590 | |
1591 if (user && conference) { | |
1592 rc = nm_send_reject_conference(user, conference, NULL, NULL); | |
1593 _check_for_disconnect(user, rc); | |
1594 } | |
1595 | |
1596 g_slist_free(parms); | |
1597 } | |
1598 | |
8933 | 1599 static void |
9030 | 1600 _initiate_conference_cb(GaimBlistNode *node, gpointer ignored) |
8933 | 1601 { |
9030 | 1602 GaimBuddy *buddy; |
1603 GaimConnection *gc; | |
1604 | |
8933 | 1605 NMUser *user; |
1606 const char *conf_name; | |
1607 GaimConversation *chat = NULL; | |
1608 NMUserRecord *user_record; | |
1609 NMConference *conference; | |
1610 | |
9030 | 1611 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
1612 | |
1613 buddy = (GaimBuddy *) node; | |
1614 gc = gaim_account_get_connection(buddy->account); | |
1615 | |
8933 | 1616 user = gc->proto_data; |
1617 if (user == NULL) | |
1618 return; | |
1619 | |
1620 /* We should already have a userrecord for the buddy */ | |
9030 | 1621 user_record = nm_find_user_record(user, buddy->name); |
8933 | 1622 if (user_record == NULL) |
1623 return; | |
1624 | |
1625 conf_name = _get_conference_name(++user->conference_count); | |
1626 chat = serv_got_joined_chat(gc, user->conference_count, conf_name); | |
1627 if (chat) { | |
1628 | |
1629 conference = nm_create_conference(NULL); | |
1630 nm_conference_set_data(conference, (gpointer) chat); | |
1631 nm_send_create_conference(user, conference, _createconf_resp_send_invite, user_record); | |
1632 nm_release_conference(conference); | |
1633 } | |
1634 } | |
1635 | |
1636 const char * | |
1637 _get_conference_name(int id) | |
1638 { | |
1639 static char *name = NULL; | |
1640 | |
1641 if (name) | |
1642 g_free(name); | |
1643 | |
1644 name = g_strdup_printf(_("GroupWise Conference %d"), id); | |
1645 | |
1646 return name; | |
1647 } | |
1648 | |
12408
3d297efa70bb
[gaim-migrate @ 14715]
Richard Laager <rlaager@wiktel.com>
parents:
12222
diff
changeset
|
1649 static void |
8933 | 1650 _show_privacy_locked_error(GaimConnection *gc, NMUser *user) |
1651 { | |
1652 char *err; | |
1653 | |
1654 err = g_strdup_printf(_("Unable to change server side privacy settings (%s)."), | |
1655 nm_error_to_string(NMERR_ADMIN_LOCKED)); | |
1656 gaim_notify_error(gc, NULL, err, NULL); | |
1657 g_free(err); | |
1658 } | |
1659 | |
8675 | 1660 /******************************************************************************* |
1661 * Connect and recv callbacks | |
1662 ******************************************************************************/ | |
1663 | |
1664 static void | |
1665 novell_ssl_connect_error(GaimSslConnection * gsc, | |
1666 GaimSslErrorType error, gpointer data) | |
1667 { | |
1668 gaim_connection_error((GaimConnection *)data, | |
1669 _("Unable to make SSL connection to server.")); | |
1670 } | |
1671 | |
1672 static void | |
1673 novell_ssl_recv_cb(gpointer data, GaimSslConnection * gsc, | |
1674 GaimInputCondition condition) | |
1675 { | |
1676 GaimConnection *gc = data; | |
1677 NMUser *user; | |
1678 NMERR_T rc; | |
1679 | |
1680 if (gc == NULL) | |
1681 return; | |
1682 | |
1683 user = gc->proto_data; | |
1684 if (user == NULL) | |
1685 return; | |
1686 | |
1687 rc = nm_process_new_data(user); | |
1688 if (rc != NM_OK) { | |
1689 | |
1690 if (_is_disconnect_error(rc)) { | |
8933 | 1691 |
8675 | 1692 gaim_connection_error(gc, |
1693 _("Error communicating with server." | |
1694 " Closing connection.")); | |
1695 } else { | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1696 gaim_debug(GAIM_DEBUG_INFO, "novell", |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1697 "Error processing event or response (%d).\n", rc); |
8675 | 1698 } |
1699 } | |
1700 } | |
1701 | |
1702 static void | |
1703 novell_ssl_connected_cb(gpointer data, GaimSslConnection * gsc, | |
1704 GaimInputCondition cond) | |
1705 { | |
1706 GaimConnection *gc = data; | |
1707 NMUser *user; | |
1708 NMConn *conn; | |
1709 NMERR_T rc = 0; | |
1710 const char *pwd = NULL; | |
1711 const char *my_addr = NULL; | |
1712 char *ua = NULL; | |
1713 | |
1714 if (gc == NULL || gsc == NULL) | |
1715 return; | |
1716 | |
1717 user = gc->proto_data; | |
1718 if ((user == NULL) || (conn = user->conn) == NULL) | |
1719 return; | |
1720 | |
1721 conn->ssl_conn = g_new0(NMSSLConn, 1); | |
1722 conn->ssl_conn->data = gsc; | |
1723 conn->ssl_conn->read = (nm_ssl_read_cb) gaim_ssl_read; | |
1724 conn->ssl_conn->write = (nm_ssl_write_cb) gaim_ssl_write; | |
1725 | |
1726 gaim_connection_update_progress(gc, _("Authenticating..."), | |
1727 2, NOVELL_CONNECT_STEPS); | |
1728 | |
8838 | 1729 my_addr = gaim_network_get_my_ip(gsc->fd); |
10740 | 1730 pwd = gaim_connection_get_password(gc); |
8675 | 1731 ua = _user_agent_string(); |
1732 | |
1733 rc = nm_send_login(user, pwd, my_addr, ua, _login_resp_cb, NULL); | |
1734 if (rc == NM_OK) { | |
1735 conn->connected = TRUE; | |
1736 gaim_ssl_input_add(gsc, novell_ssl_recv_cb, gc); | |
1737 } else { | |
1738 gaim_connection_error(gc, _("Unable to connect to server.")); | |
1739 } | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1740 |
8675 | 1741 gaim_connection_update_progress(gc, _("Waiting for response..."), |
1742 3, NOVELL_CONNECT_STEPS); | |
1743 | |
1744 g_free(ua); | |
1745 } | |
1746 | |
1747 /******************************************************************************* | |
1748 * Event callback and event handlers | |
1749 ******************************************************************************/ | |
1750 | |
1751 static void | |
1752 _evt_receive_message(NMUser * user, NMEvent * event) | |
1753 { | |
1754 NMUserRecord *user_record = NULL; | |
1755 NMContact *contact = NULL; | |
1756 GaimConversation *gconv; | |
1757 NMConference *conference; | |
12216 | 1758 GaimMessageFlags flags; |
9268 | 1759 char *text = NULL; |
1760 | |
1761 text = g_markup_escape_text(nm_event_get_text(event), -1); | |
8675 | 1762 |
1763 conference = nm_event_get_conference(event); | |
1764 if (conference) { | |
1765 | |
1766 GaimConversation *chat = nm_conference_get_data(conference); | |
1767 | |
1768 /* Is this a single person 'conversation' or a conference? */ | |
1769 if (chat == NULL && nm_conference_get_participant_count(conference) == 1) { | |
1770 | |
1771 user_record = nm_find_user_record(user, nm_event_get_source(event)); | |
1772 if (user_record) { | |
1773 | |
12216 | 1774 flags = 0; |
8675 | 1775 if (nm_event_get_type(event) == NMEVT_RECEIVE_AUTOREPLY) |
12216 | 1776 flags |= GAIM_MESSAGE_AUTO_RESP; |
8675 | 1777 |
1778 serv_got_im(gaim_account_get_connection(user->client_data), | |
1779 nm_user_record_get_display_id(user_record), | |
12216 | 1780 text, flags, |
8675 | 1781 nm_event_get_gmt(event)); |
1782 | |
11338 | 1783 gconv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, |
8675 | 1784 nm_user_record_get_display_id(user_record), |
1785 (GaimAccount *) user->client_data); | |
1786 if (gconv) { | |
1787 | |
1788 contact = nm_find_contact(user, nm_event_get_source(event)); | |
1789 if (contact) { | |
1790 | |
1791 gaim_conversation_set_title( | |
9268 | 1792 gconv, nm_contact_get_display_name(contact)); |
8675 | 1793 |
1794 | |
1795 } else { | |
1796 | |
1797 const char *name = | |
1798 nm_user_record_get_full_name(user_record); | |
1799 | |
1800 if (name == NULL) | |
1801 name = nm_user_record_get_userid(user_record); | |
1802 | |
1803 gaim_conversation_set_title(gconv, name); | |
1804 } | |
1805 | |
1806 } | |
1807 | |
1808 } else { | |
1809 /* this should not happen, see the event code. | |
1810 * the event code will get the contact details from | |
1811 * the server if it does not have them before calling | |
1812 * the event callback. | |
1813 */ | |
1814 } | |
1815 | |
1816 } else if (chat) { | |
1817 | |
1818 /* get the contact for send if we have one */ | |
1819 NMContact *contact = nm_find_contact(user, | |
1820 nm_event_get_source(event)); | |
1821 | |
1822 /* get the user record for the sender */ | |
1823 user_record = nm_find_user_record(user, nm_event_get_source(event)); | |
1824 if (user_record) { | |
1825 const char *name = nm_contact_get_display_name(contact); | |
1826 | |
1827 if (name == NULL) { | |
1828 name = nm_user_record_get_full_name(user_record); | |
1829 if (name == NULL) | |
1830 name = nm_user_record_get_display_id(user_record); | |
1831 } | |
1832 | |
1833 serv_got_chat_in(gaim_account_get_connection(user->client_data), | |
1834 gaim_conv_chat_get_id(GAIM_CONV_CHAT(chat)), | |
9268 | 1835 name, 0, text, nm_event_get_gmt(event)); |
8675 | 1836 } |
1837 } | |
1838 } | |
9268 | 1839 |
1840 g_free(text); | |
8675 | 1841 } |
1842 | |
1843 static void | |
1844 _evt_conference_left(NMUser * user, NMEvent * event) | |
1845 { | |
1846 GaimConversation *chat; | |
1847 NMConference *conference; | |
1848 | |
1849 conference = nm_event_get_conference(event); | |
1850 if (conference) { | |
1851 chat = nm_conference_get_data(conference); | |
1852 if (chat) { | |
1853 NMUserRecord *ur = nm_find_user_record(user, | |
1854 nm_event_get_source(event)); | |
1855 | |
1856 if (ur) | |
1857 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(chat), | |
1858 nm_user_record_get_display_id(ur), | |
1859 NULL); | |
1860 } | |
1861 } | |
1862 } | |
1863 | |
1864 static void | |
8933 | 1865 _evt_conference_invite_notify(NMUser * user, NMEvent * event) |
1866 { | |
1867 GaimConversation *gconv; | |
1868 NMConference *conference; | |
1869 NMUserRecord *user_record = NULL; | |
1870 char *str = NULL; | |
1871 | |
1872 user_record = nm_find_user_record(user, nm_event_get_source(event)); | |
1873 conference = nm_event_get_conference(event); | |
1874 if (user_record && conference) { | |
1875 gconv = nm_conference_get_data(conference); | |
1876 str = g_strdup_printf(_("%s has been invited to this conversation."), | |
1877 nm_user_record_get_display_id(user_record)); | |
1878 gaim_conversation_write(gconv, NULL, str, | |
1879 GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1880 g_free(str); | |
1881 } | |
1882 } | |
1883 | |
1884 static void | |
8675 | 1885 _evt_conference_invite(NMUser * user, NMEvent * event) |
1886 { | |
1887 NMUserRecord *ur; | |
11246 | 1888 GaimConnection *gc; |
8675 | 1889 GSList *parms = NULL; |
1890 const char *title = NULL; | |
1891 const char *secondary = NULL; | |
1892 const char *name = NULL; | |
1893 char *primary = NULL; | |
1894 time_t gmt; | |
1895 | |
1896 ur = nm_find_user_record(user, nm_event_get_source(event)); | |
1897 if (ur) | |
1898 name = nm_user_record_get_full_name(ur); | |
1899 | |
1900 if (name == NULL) | |
1901 name = nm_event_get_source(event); | |
1902 | |
1903 gmt = nm_event_get_gmt(event); | |
1904 title = _("Invitation to Conversation"); | |
1905 primary = g_strdup_printf(_("Invitation from: %s\n\nSent: %s"), | |
1906 name, asctime(localtime(&gmt))); | |
1907 secondary = _("Would you like to join the conversation?"); | |
1908 | |
1909 /* Set up parms list for the callbacks | |
1910 * We need to send the NMUser object and | |
1911 * the NMConference object to the callbacks | |
1912 */ | |
1913 parms = NULL; | |
1914 parms = g_slist_append(parms, user); | |
1915 parms = g_slist_append(parms, nm_event_get_conference(event)); | |
1916 | |
1917 /* Prompt the user */ | |
11246 | 1918 gc = gaim_account_get_connection(user->client_data); |
1919 gaim_request_action(gc, title, primary, secondary, | |
10116 | 1920 GAIM_DEFAULT_ACTION_NONE, parms, 2, |
8675 | 1921 _("Yes"), G_CALLBACK(_join_conference_cb), |
1922 _("No"), G_CALLBACK(_reject_conference_cb)); | |
1923 | |
1924 g_free(primary); | |
1925 } | |
1926 | |
1927 | |
1928 static void | |
1929 _evt_conference_joined(NMUser * user, NMEvent * event) | |
1930 { | |
1931 GaimConversation *chat = NULL; | |
1932 GaimConnection *gc; | |
1933 NMConference *conference = NULL; | |
1934 NMUserRecord *ur = NULL; | |
1935 const char *name; | |
8933 | 1936 const char *conf_name; |
8675 | 1937 |
1938 gc = gaim_account_get_connection(user->client_data); | |
1939 if (gc == NULL) | |
1940 return; | |
1941 | |
1942 conference = nm_event_get_conference(event); | |
1943 if (conference) { | |
1944 chat = nm_conference_get_data(conference); | |
1945 if (nm_conference_get_participant_count(conference) == 2 && chat == NULL) { | |
1946 ur = nm_conference_get_participant(conference, 0); | |
1947 if (ur) { | |
8933 | 1948 conf_name = _get_conference_name(++user->conference_count); |
8675 | 1949 chat = |
1950 serv_got_joined_chat(gc, user->conference_count, conf_name); | |
1951 if (chat) { | |
1952 | |
1953 nm_conference_set_data(conference, (gpointer) chat); | |
1954 | |
1955 name = nm_user_record_get_display_id(ur); | |
9846 | 1956 gaim_conv_chat_add_user(GAIM_CONV_CHAT(chat), name, NULL, |
1957 GAIM_CBFLAGS_NONE, TRUE); | |
8675 | 1958 |
1959 } | |
1960 } | |
1961 } | |
1962 | |
1963 if (chat != NULL) { | |
1964 ur = nm_find_user_record(user, nm_event_get_source(event)); | |
1965 if (ur) { | |
1966 name = nm_user_record_get_display_id(ur); | |
9554 | 1967 if (!gaim_conv_chat_find_user(GAIM_CONV_CHAT(chat), name)) { |
9846 | 1968 gaim_conv_chat_add_user(GAIM_CONV_CHAT(chat), name, NULL, |
1969 GAIM_CBFLAGS_NONE, TRUE); | |
8933 | 1970 } |
8675 | 1971 } |
1972 } | |
1973 } | |
1974 } | |
1975 | |
1976 static void | |
1977 _evt_status_change(NMUser * user, NMEvent * event) | |
1978 { | |
1979 GaimBuddy *buddy = NULL; | |
1980 GSList *buddies; | |
1981 GSList *bnode; | |
1982 NMUserRecord *user_record; | |
1983 const char *display_id; | |
1984 int status; | |
1985 | |
1986 user_record = nm_event_get_user_record(event); | |
1987 if (user_record) { | |
1988 | |
1989 /* Retrieve new status */ | |
1990 status = nm_user_record_get_status(user_record); | |
1991 | |
1992 /* Update status for buddy in all folders */ | |
1993 display_id = nm_user_record_get_display_id(user_record); | |
1994 buddies = gaim_find_buddies(user->client_data, display_id); | |
1995 for (bnode = buddies; bnode; bnode = bnode->next) { | |
1996 buddy = (GaimBuddy *) bnode->data; | |
1997 if (buddy) { | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1998 _update_buddy_status(user, buddy, status, nm_event_get_gmt(event)); |
8675 | 1999 } |
2000 } | |
2001 | |
2002 g_slist_free(buddies); | |
2003 | |
2004 } | |
2005 } | |
2006 | |
2007 static void | |
2008 _evt_user_disconnect(NMUser * user, NMEvent * event) | |
2009 { | |
2010 GaimConnection *gc; | |
2011 | |
2012 gc = gaim_account_get_connection((GaimAccount *) user->client_data); | |
2013 if (gc) | |
2014 gaim_connection_error(gc, _("You have been logged out because you" | |
2015 " logged in at another workstation.")); | |
2016 } | |
2017 | |
2018 static void | |
2019 _evt_user_typing(NMUser * user, NMEvent * event) | |
2020 { | |
2021 GaimConnection *gc; | |
2022 NMUserRecord *user_record = NULL; | |
2023 | |
2024 gc = gaim_account_get_connection((GaimAccount *) user->client_data); | |
2025 if (gc) { | |
2026 user_record = nm_find_user_record(user, nm_event_get_source(event)); | |
2027 if (user_record) { | |
2028 serv_got_typing(gc, nm_user_record_get_display_id(user_record), | |
2029 30, GAIM_TYPING); | |
2030 } | |
2031 } | |
2032 } | |
2033 | |
2034 static void | |
2035 _evt_user_not_typing(NMUser * user, NMEvent * event) | |
2036 { | |
2037 GaimConnection *gc; | |
2038 NMUserRecord *user_record; | |
2039 | |
2040 gc = gaim_account_get_connection((GaimAccount *) user->client_data); | |
2041 if (gc) { | |
2042 user_record = nm_find_user_record(user, nm_event_get_source(event)); | |
2043 if (user_record) { | |
2044 serv_got_typing_stopped(gc, | |
2045 nm_user_record_get_display_id(user_record)); | |
2046 } | |
2047 } | |
2048 } | |
2049 | |
2050 static void | |
2051 _evt_undeliverable_status(NMUser * user, NMEvent * event) | |
2052 { | |
2053 NMUserRecord *ur; | |
2054 GaimConversation *gconv; | |
2055 char *str; | |
2056 | |
2057 ur = nm_find_user_record(user, nm_event_get_source(event)); | |
2058 if (ur) { | |
11338 | 2059 /* XXX - Should this be GAIM_CONV_TYPE_IM? */ |
8675 | 2060 gconv = |
11338 | 2061 gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, |
10246 | 2062 nm_user_record_get_display_id(ur), |
8675 | 2063 user->client_data); |
2064 if (gconv) { | |
2065 const char *name = nm_user_record_get_full_name(ur); | |
2066 | |
2067 if (name == NULL) { | |
2068 name = nm_user_record_get_display_id(ur); | |
2069 } | |
2070 str = g_strdup_printf(_("%s appears to be offline and did not receive" | |
2071 " the message that you just sent."), name); | |
2072 gaim_conversation_write(gconv, NULL, str, | |
2073 GAIM_MESSAGE_SYSTEM, time(NULL)); | |
2074 g_free(str); | |
2075 } | |
2076 } | |
2077 } | |
2078 | |
2079 static void | |
2080 _event_callback(NMUser * user, NMEvent * event) | |
2081 { | |
2082 if (user == NULL || event == NULL) | |
2083 return; | |
2084 | |
2085 switch (nm_event_get_type(event)) { | |
2086 case NMEVT_STATUS_CHANGE: | |
2087 _evt_status_change(user, event); | |
2088 break; | |
2089 case NMEVT_RECEIVE_AUTOREPLY: | |
2090 case NMEVT_RECEIVE_MESSAGE: | |
2091 _evt_receive_message(user, event); | |
2092 break; | |
2093 case NMEVT_USER_DISCONNECT: | |
2094 _evt_user_disconnect(user, event); | |
2095 break; | |
2096 case NMEVT_USER_TYPING: | |
2097 _evt_user_typing(user, event); | |
2098 break; | |
2099 case NMEVT_USER_NOT_TYPING: | |
2100 _evt_user_not_typing(user, event); | |
2101 break; | |
2102 case NMEVT_SERVER_DISCONNECT: | |
2103 /* Nothing to do? */ | |
2104 break; | |
2105 case NMEVT_INVALID_RECIPIENT: | |
2106 break; | |
2107 case NMEVT_UNDELIVERABLE_STATUS: | |
2108 _evt_undeliverable_status(user, event); | |
2109 break; | |
2110 case NMEVT_CONFERENCE_INVITE_NOTIFY: | |
2111 /* Someone else has been invited to join a | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2112 * conference that we are currently a part of |
8675 | 2113 */ |
8933 | 2114 _evt_conference_invite_notify(user, event); |
8675 | 2115 break; |
2116 case NMEVT_CONFERENCE_INVITE: | |
2117 /* We have been invited to join a conference */ | |
2118 _evt_conference_invite(user, event); | |
2119 break; | |
2120 case NMEVT_CONFERENCE_JOINED: | |
2121 /* Some one has joined a conference that we | |
2122 * are a part of | |
2123 */ | |
2124 _evt_conference_joined(user, event); | |
2125 break; | |
2126 case NMEVT_CONFERENCE_LEFT: | |
2127 /* Someone else has left a conference that we | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2128 * are currently a part of |
8675 | 2129 */ |
2130 _evt_conference_left(user, event); | |
2131 break; | |
2132 default: | |
2133 gaim_debug(GAIM_DEBUG_INFO, "novell", | |
2134 "_event_callback(): unhandled event, %d\n", | |
2135 nm_event_get_type(event)); | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2136 break; |
8675 | 2137 } |
2138 } | |
2139 | |
2140 /******************************************************************************* | |
2141 * Prpl Ops | |
2142 ******************************************************************************/ | |
2143 | |
2144 static void | |
11837 | 2145 novell_login(GaimAccount * account) |
8675 | 2146 { |
2147 GaimConnection *gc; | |
2148 NMUser *user = NULL; | |
2149 const char *server; | |
2150 const char *name; | |
2151 int port; | |
2152 | |
2153 if (account == NULL) | |
2154 return; | |
2155 | |
2156 gc = gaim_account_get_connection(account); | |
2157 if (gc == NULL) | |
2158 return; | |
2159 | |
2160 server = gaim_account_get_string(account, "server", NULL); | |
2161 if (server == NULL || *server == '\0') { | |
2162 | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2163 /* TODO: Would be nice to prompt if not set! |
8675 | 2164 * gaim_request_fields(gc, _("Server Address"),...); |
2165 */ | |
2166 | |
2167 /* ...but for now just error out with a nice message. */ | |
2168 gaim_connection_error(gc, _("Unable to connect to server." | |
2169 " Please enter the address of the server" | |
2170 " you wish to connect to.")); | |
2171 return; | |
2172 } | |
2173 | |
2174 port = gaim_account_get_int(account, "port", DEFAULT_PORT); | |
2175 name = gaim_account_get_username(account); | |
2176 | |
2177 user = nm_initialize_user(name, server, port, account, _event_callback); | |
2178 if (user) { | |
2179 /* save user */ | |
2180 gc->proto_data = user; | |
2181 | |
2182 /* connect to the server */ | |
2183 gaim_connection_update_progress(gc, _("Connecting"), | |
2184 1, NOVELL_CONNECT_STEPS); | |
2185 | |
2186 user->conn->use_ssl = TRUE; | |
2187 if (gaim_ssl_connect(user->client_data, user->conn->addr, | |
2188 user->conn->port, novell_ssl_connected_cb, | |
2189 novell_ssl_connect_error, gc) == NULL) { | |
2190 gaim_connection_error(gc, _("Error." | |
2191 " SSL support is not installed.")); | |
2192 } | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2193 } |
8675 | 2194 } |
2195 | |
2196 static void | |
2197 novell_close(GaimConnection * gc) | |
2198 { | |
2199 NMUser *user; | |
2200 NMConn *conn; | |
2201 | |
2202 if (gc == NULL) | |
2203 return; | |
2204 | |
2205 user = gc->proto_data; | |
2206 if (user) { | |
2207 conn = user->conn; | |
9651 | 2208 if (conn && conn->ssl_conn) { |
2209 gaim_ssl_close(user->conn->ssl_conn->data); | |
8675 | 2210 } |
2211 nm_deinitialize_user(user); | |
2212 } | |
2213 gc->proto_data = NULL; | |
2214 } | |
2215 | |
2216 static int | |
2217 novell_send_im(GaimConnection * gc, const char *name, | |
12216 | 2218 const char *message_body, GaimMessageFlags flags) |
8675 | 2219 { |
2220 NMUserRecord *user_record = NULL; | |
2221 NMConference *conf = NULL; | |
2222 NMMessage *message; | |
2223 NMUser *user; | |
2224 const char *dn = NULL; | |
12216 | 2225 char *plain; |
8675 | 2226 gboolean done = TRUE, created_conf = FALSE; |
2227 NMERR_T rc = NM_OK; | |
2228 | |
2229 if (gc == NULL || name == NULL || | |
2230 message_body == NULL || *message_body == '\0') | |
2231 return 0; | |
2232 | |
2233 user = gc->proto_data; | |
2234 if (user == NULL) | |
2235 return 0; | |
2236 | |
2237 /* Create a new message */ | |
12216 | 2238 plain = gaim_unescape_html(message_body); |
2239 message = nm_create_message(plain); | |
2240 g_free(plain); | |
8675 | 2241 |
2242 /* Need to get the DN for the buddy so we can look up the convo */ | |
2243 dn = nm_lookup_dn(user, name); | |
2244 | |
2245 /* Do we already know about the sender? */ | |
2246 user_record = nm_find_user_record(user, dn); | |
2247 if (user_record) { | |
2248 | |
2249 /* Do we already have an instantiated conference? */ | |
2250 conf = nm_find_conversation(user, dn); | |
2251 if (conf == NULL) { | |
2252 | |
2253 /* If not, create a blank conference */ | |
2254 conf = nm_create_conference(NULL); | |
2255 created_conf = TRUE; | |
2256 | |
2257 nm_conference_add_participant(conf, user_record); | |
2258 } | |
2259 | |
2260 nm_message_set_conference(message, conf); | |
2261 | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2262 /* Make sure conference is instantiated */ |
8675 | 2263 if (!nm_conference_is_instantiated(conf)) { |
2264 | |
2265 /* It is not, so send the createconf. We will | |
2266 * have to finish sending the message when we | |
2267 * get the response with the new conference guid. | |
2268 */ | |
8933 | 2269 rc = nm_send_create_conference(user, conf, _createconf_resp_send_msg, message); |
8675 | 2270 _check_for_disconnect(user, rc); |
2271 | |
2272 done = FALSE; | |
2273 } | |
2274 | |
2275 } else { | |
2276 | |
2277 /* If we don't have details for the user, then we don't have | |
2278 * a conference yet. So create one and send the getdetails | |
2279 * to the server. We will have to finish sending the message | |
2280 * when we get the response from the server. | |
2281 */ | |
2282 conf = nm_create_conference(NULL); | |
2283 created_conf = TRUE; | |
2284 | |
2285 nm_message_set_conference(message, conf); | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2286 |
8675 | 2287 rc = nm_send_get_details(user, name, _get_details_resp_send_msg, message); |
2288 _check_for_disconnect(user, rc); | |
2289 | |
2290 done = FALSE; | |
2291 } | |
2292 | |
2293 if (done) { | |
2294 | |
2295 /* Did we find everything we needed? */ | |
2296 rc = nm_send_message(user, message, _send_message_resp_cb); | |
2297 _check_for_disconnect(user, rc); | |
2298 | |
2299 nm_release_message(message); | |
2300 } | |
2301 | |
2302 if (created_conf && conf) | |
2303 nm_release_conference(conf); | |
2304 | |
2305 return 1; | |
2306 } | |
2307 | |
2308 static int | |
2309 novell_send_typing(GaimConnection * gc, const char *name, int typing) | |
2310 { | |
2311 NMConference *conf = NULL; | |
2312 NMUser *user; | |
2313 const char *dn = NULL; | |
2314 NMERR_T rc = NM_OK; | |
2315 | |
2316 if (gc == NULL || name == NULL) | |
2317 return -1; | |
2318 | |
2319 user = gc->proto_data; | |
2320 if (user == NULL) | |
2321 return -1; | |
2322 | |
2323 /* Need to get the DN for the buddy so we can look up the convo */ | |
2324 dn = nm_lookup_dn(user, name); | |
2325 if (dn) { | |
2326 | |
2327 /* Now find the conference in our list */ | |
2328 conf = nm_find_conversation(user, dn); | |
2329 if (conf) { | |
2330 | |
2331 rc = nm_send_typing(user, conf, | |
2332 ((typing == GAIM_TYPING) ? TRUE : FALSE), NULL); | |
2333 _check_for_disconnect(user, rc); | |
2334 | |
2335 } | |
2336 | |
2337 } | |
2338 | |
2339 return 0; | |
2340 } | |
2341 | |
2342 static void | |
2343 novell_convo_closed(GaimConnection * gc, const char *who) | |
2344 { | |
2345 NMUser *user; | |
2346 NMConference *conf; | |
2347 const char *dn; | |
2348 NMERR_T rc = NM_OK; | |
2349 | |
2350 if (gc == NULL || who == NULL) | |
2351 return; | |
2352 | |
2353 user = gc->proto_data; | |
2354 if (user && (dn = nm_lookup_dn(user, who))) { | |
2355 conf = nm_find_conversation(user, dn); | |
2356 if (conf) { | |
2357 rc = nm_send_leave_conference(user, conf, NULL, NULL); | |
2358 _check_for_disconnect(user, rc); | |
2359 } | |
2360 } | |
2361 } | |
2362 | |
2363 static void | |
2364 novell_chat_leave(GaimConnection * gc, int id) | |
2365 { | |
2366 NMConference *conference; | |
2367 NMUser *user; | |
2368 GaimConversation *chat; | |
2369 GSList *cnode; | |
2370 NMERR_T rc = NM_OK; | |
2371 | |
2372 if (gc == NULL) | |
2373 return; | |
2374 | |
2375 user = gc->proto_data; | |
2376 if (user == NULL) | |
2377 return; | |
2378 | |
2379 for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) { | |
2380 conference = cnode->data; | |
2381 if (conference && (chat = nm_conference_get_data(conference))) { | |
2382 if (gaim_conv_chat_get_id(GAIM_CONV_CHAT(chat)) == id) { | |
2383 rc = nm_send_leave_conference(user, conference, NULL, NULL); | |
2384 _check_for_disconnect(user, rc); | |
2385 break; | |
2386 } | |
2387 } | |
2388 } | |
2389 | |
2390 serv_got_chat_left(gc, id); | |
2391 } | |
2392 | |
12408
3d297efa70bb
[gaim-migrate @ 14715]
Richard Laager <rlaager@wiktel.com>
parents:
12222
diff
changeset
|
2393 static void |
8933 | 2394 novell_chat_invite(GaimConnection *gc, int id, |
2395 const char *message, const char *who) | |
2396 { | |
2397 NMConference *conference; | |
2398 NMUser *user; | |
2399 GaimConversation *chat; | |
2400 GSList *cnode; | |
2401 NMERR_T rc = NM_OK; | |
2402 NMUserRecord *user_record = NULL; | |
2403 | |
2404 if (gc == NULL) | |
2405 return; | |
2406 | |
2407 user = gc->proto_data; | |
2408 if (user == NULL) | |
2409 return; | |
2410 | |
2411 user_record = nm_find_user_record(user, who); | |
2412 if (user_record == NULL) { | |
10112 | 2413 rc = nm_send_get_details(user, who, _get_details_resp_send_invite, GINT_TO_POINTER(id)); |
8933 | 2414 _check_for_disconnect(user, rc); |
2415 return; | |
2416 } | |
2417 | |
2418 for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) { | |
2419 conference = cnode->data; | |
2420 if (conference && (chat = nm_conference_get_data(conference))) { | |
2421 if (gaim_conv_chat_get_id(GAIM_CONV_CHAT(chat)) == id) { | |
2422 rc = nm_send_conference_invite(user, conference, user_record, | |
2423 message, _sendinvite_resp_cb, NULL); | |
2424 _check_for_disconnect(user, rc); | |
2425 break; | |
2426 } | |
2427 } | |
2428 } | |
2429 } | |
2430 | |
8675 | 2431 static int |
12216 | 2432 novell_chat_send(GaimConnection * gc, int id, const char *text, GaimMessageFlags flags) |
8675 | 2433 { |
2434 NMConference *conference; | |
2435 GaimConversation *chat; | |
2436 GSList *cnode; | |
2437 NMMessage *message; | |
2438 NMUser *user; | |
2439 NMERR_T rc = NM_OK; | |
2440 const char *name; | |
12216 | 2441 char *str, *plain; |
8675 | 2442 |
2443 if (gc == NULL || text == NULL) | |
2444 return -1; | |
2445 | |
2446 user = gc->proto_data; | |
2447 if (user == NULL) | |
2448 return -1; | |
2449 | |
12216 | 2450 plain = gaim_unescape_html(text); |
2451 message = nm_create_message(plain); | |
2452 g_free(plain); | |
8675 | 2453 |
2454 for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) { | |
2455 conference = cnode->data; | |
2456 if (conference && (chat = nm_conference_get_data(conference))) { | |
2457 if (gaim_conv_chat_get_id(GAIM_CONV_CHAT(chat)) == id) { | |
2458 | |
2459 nm_message_set_conference(message, conference); | |
2460 | |
8933 | 2461 /* check to see if the conference is instatiated yet */ |
2462 if (!nm_conference_is_instantiated(conference)) { | |
2463 nm_message_add_ref(message); | |
2464 nm_send_create_conference(user, conference, _createconf_resp_send_msg, message); | |
2465 } else { | |
2466 rc = nm_send_message(user, message, _send_message_resp_cb); | |
2467 } | |
2468 | |
8675 | 2469 nm_release_message(message); |
2470 | |
2471 if (!_check_for_disconnect(user, rc)) { | |
2472 | |
2473 /* Use the account alias if it is set */ | |
2474 name = gaim_account_get_alias(user->client_data); | |
2475 if (name == NULL || *name == '\0') { | |
2476 | |
2477 /* If there is no account alias, try full name */ | |
2478 name = nm_user_record_get_full_name(user->user_record); | |
2479 if (name == NULL || *name == '\0') { | |
2480 | |
2481 /* Fall back to the username that we are signed in with */ | |
2482 name = gaim_account_get_username(user->client_data); | |
2483 } | |
2484 } | |
2485 | |
2486 serv_got_chat_in(gc, id, name, 0, text, time(NULL)); | |
2487 return 0; | |
2488 } else | |
2489 return -1; | |
2490 | |
2491 } | |
2492 } | |
2493 } | |
2494 | |
8933 | 2495 |
8675 | 2496 /* The conference was not found, must be closed */ |
2497 chat = gaim_find_chat(gc, id); | |
2498 if (chat) { | |
2499 str = g_strdup_printf(_("This conference has been closed." | |
2500 " No more messages can be sent.")); | |
2501 gaim_conversation_write(chat, NULL, str, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
2502 g_free(str); | |
2503 } | |
2504 | |
8744 | 2505 if (message) |
2506 nm_release_message(message); | |
2507 | |
8675 | 2508 return -1; |
2509 } | |
2510 | |
2511 static void | |
9285 | 2512 novell_add_buddy(GaimConnection * gc, GaimBuddy *buddy, GaimGroup * group) |
8675 | 2513 { |
2514 NMFolder *folder = NULL; | |
2515 NMContact *contact; | |
2516 NMUser *user; | |
2517 NMERR_T rc = NM_OK; | |
9651 | 2518 const char *alias, *gname; |
9285 | 2519 |
2520 if (gc == NULL || buddy == NULL || group == NULL) | |
8675 | 2521 return; |
2522 | |
2523 user = (NMUser *) gc->proto_data; | |
2524 if (user == NULL) | |
2525 return; | |
2526 | |
9360 | 2527 /* If we haven't synched the contact list yet, ignore |
2528 * the add_buddy calls. Server side list is the master. | |
2529 */ | |
2530 if (!user->clist_synched) | |
2531 return; | |
2532 | |
8675 | 2533 contact = nm_create_contact(); |
9285 | 2534 nm_contact_set_dn(contact, buddy->name); |
8675 | 2535 |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2536 /* Remove the GaimBuddy (we will add it back after adding it |
8675 | 2537 * to the server side list). Save the alias if there is one. |
2538 */ | |
9620 | 2539 alias = gaim_buddy_get_alias(buddy); |
9285 | 2540 if (alias && strcmp(alias, buddy->name)) |
2541 nm_contact_set_display_name(contact, alias); | |
2542 | |
2543 gaim_blist_remove_buddy(buddy); | |
2544 buddy = NULL; | |
8675 | 2545 |
9651 | 2546 if (strcmp(group->name, NM_ROOT_FOLDER_NAME) == 0) { |
2547 gname = ""; | |
2548 } else { | |
2549 gname = group->name; | |
2550 } | |
2551 | |
2552 folder = nm_find_folder(user, gname); | |
8675 | 2553 if (folder) { |
2554 | |
2555 /* We have everything that we need, so send the createcontact */ | |
2556 rc = nm_send_create_contact(user, folder, contact, | |
2557 _create_contact_resp_cb, contact); | |
2558 | |
2559 } else { | |
2560 | |
2561 /* Need to create the folder before we can add the contact */ | |
9651 | 2562 rc = nm_send_create_folder(user, gname, |
8675 | 2563 _create_folder_resp_add_contact, contact); |
2564 } | |
2565 | |
2566 _check_for_disconnect(user, rc); | |
2567 | |
2568 } | |
2569 | |
2570 static void | |
9360 | 2571 novell_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
8675 | 2572 { |
2573 NMContact *contact; | |
2574 NMFolder *folder; | |
2575 NMUser *user; | |
9651 | 2576 const char *dn, *gname; |
8675 | 2577 NMERR_T rc = NM_OK; |
2578 | |
9285 | 2579 if (gc == NULL || buddy == NULL || group == NULL) |
8675 | 2580 return; |
2581 | |
2582 user = (NMUser *) gc->proto_data; | |
9285 | 2583 if (user && (dn = nm_lookup_dn(user, buddy->name))) { |
9651 | 2584 if (strcmp(group->name, NM_ROOT_FOLDER_NAME) == 0) { |
2585 gname = ""; | |
2586 } else { | |
2587 gname = group->name; | |
2588 } | |
2589 folder = nm_find_folder(user, gname); | |
8675 | 2590 if (folder) { |
2591 contact = nm_folder_find_contact(folder, dn); | |
2592 if (contact) { | |
2593 | |
2594 /* Remove the buddy from the contact */ | |
2595 nm_contact_set_data(contact, NULL); | |
2596 | |
2597 /* Tell the server to remove the contact */ | |
2598 rc = nm_send_remove_contact(user, folder, contact, | |
2599 _remove_contact_resp_cb, NULL); | |
2600 _check_for_disconnect(user, rc); | |
2601 } | |
2602 } | |
2603 } | |
2604 } | |
2605 | |
2606 static void | |
9285 | 2607 novell_remove_group(GaimConnection * gc, GaimGroup *group) |
8675 | 2608 { |
2609 NMUser *user; | |
2610 NMERR_T rc = NM_OK; | |
2611 | |
9285 | 2612 if (gc == NULL || group == NULL) |
8675 | 2613 return; |
2614 | |
2615 user = (NMUser *) gc->proto_data; | |
2616 if (user) { | |
9285 | 2617 NMFolder *folder = nm_find_folder(user, group->name); |
8675 | 2618 |
2619 if (folder) { | |
2620 rc = nm_send_remove_folder(user, folder, | |
2621 _remove_folder_resp_cb, NULL); | |
2622 _check_for_disconnect(user, rc); | |
2623 } | |
2624 } | |
2625 } | |
2626 | |
2627 static void | |
2628 novell_alias_buddy(GaimConnection * gc, const char *name, const char *alias) | |
2629 { | |
2630 NMContact *contact; | |
2631 NMUser *user; | |
2632 GList *contacts = NULL; | |
2633 GList *cnode = NULL; | |
9651 | 2634 const char *dn = NULL, *fname = NULL; |
8675 | 2635 NMERR_T rc = NM_OK; |
2636 | |
2637 if (gc == NULL || name == NULL || alias == NULL) | |
2638 return; | |
2639 | |
2640 user = (NMUser *) gc->proto_data; | |
2641 if (user && (dn = nm_lookup_dn(user, name))) { | |
2642 | |
2643 /* Alias all of instances of the contact */ | |
2644 contacts = nm_find_contacts(user, dn); | |
2645 for (cnode = contacts; cnode != NULL; cnode = cnode->next) { | |
2646 contact = (NMContact *) cnode->data; | |
2647 if (contact) { | |
9651 | 2648 GaimGroup *group = NULL; |
8675 | 2649 GaimBuddy *buddy; |
2650 NMFolder *folder; | |
2651 | |
2652 /* Alias the Gaim buddy? */ | |
2653 folder = nm_find_folder_by_id(user, | |
2654 nm_contact_get_parent_id(contact)); | |
9651 | 2655 if (folder) { |
2656 fname = nm_folder_get_name(folder); | |
2657 if (*fname == '\0') { | |
2658 fname = NM_ROOT_FOLDER_NAME; | |
2659 } | |
2660 group = gaim_find_group(fname); | |
2661 } | |
2662 | |
2663 if (group) { | |
8675 | 2664 buddy = gaim_find_buddy_in_group(user->client_data, |
2665 name, group); | |
2666 if (buddy && strcmp(buddy->alias, alias)) | |
2667 gaim_blist_alias_buddy(buddy, alias); | |
2668 } | |
9651 | 2669 |
8675 | 2670 /* Tell the server to alias the contact */ |
2671 rc = nm_send_rename_contact(user, contact, alias, | |
2672 _rename_contact_resp_cb, NULL); | |
2673 _check_for_disconnect(user, rc); | |
2674 } | |
2675 } | |
2676 if (contacts) | |
2677 g_list_free(contacts); | |
2678 } | |
2679 } | |
2680 | |
2681 static void | |
2682 novell_group_buddy(GaimConnection * gc, | |
2683 const char *name, const char *old_group_name, | |
2684 const char *new_group_name) | |
2685 { | |
2686 NMFolder *old_folder; | |
2687 NMFolder *new_folder; | |
2688 NMContact *contact; | |
2689 NMUser *user; | |
2690 const char *dn; | |
2691 NMERR_T rc = NM_OK; | |
2692 | |
2693 if (gc == NULL || name == NULL || | |
2694 old_group_name == NULL || new_group_name == NULL) | |
2695 return; | |
2696 | |
2697 user = (NMUser *) gc->proto_data; | |
2698 if (user && (dn = nm_lookup_dn(user, name))) { | |
2699 | |
2700 /* Find the old folder */ | |
9651 | 2701 if (strcmp(old_group_name, NM_ROOT_FOLDER_NAME) == 0) { |
2702 old_folder = nm_get_root_folder(user); | |
2703 if (nm_folder_find_contact(old_folder, dn) == NULL) | |
2704 old_folder = nm_find_folder(user, old_group_name); | |
2705 } else { | |
2706 old_folder = nm_find_folder(user, old_group_name); | |
2707 } | |
2708 | |
8675 | 2709 if (old_folder && (contact = nm_folder_find_contact(old_folder, dn))) { |
2710 | |
2711 /* Find the new folder */ | |
2712 new_folder = nm_find_folder(user, new_group_name); | |
9651 | 2713 if (new_folder == NULL) { |
2714 if (strcmp(new_group_name, NM_ROOT_FOLDER_NAME) == 0) | |
2715 new_folder = nm_get_root_folder(user); | |
2716 } | |
2717 | |
8675 | 2718 if (new_folder) { |
2719 | |
2720 /* Tell the server to move the contact to the new folder */ | |
2721 rc = nm_send_move_contact(user, contact, new_folder, | |
2722 _move_contact_resp_cb, NULL); | |
2723 | |
2724 } else { | |
2725 | |
2726 nm_contact_add_ref(contact); | |
2727 | |
2728 /* Remove the old contact first */ | |
2729 nm_send_remove_contact(user, old_folder, contact, | |
2730 _remove_contact_resp_cb, NULL); | |
2731 | |
2732 /* New folder does not exist yet, so create it */ | |
2733 rc = nm_send_create_folder(user, new_group_name, | |
2734 _create_folder_resp_move_contact, | |
2735 contact); | |
2736 } | |
2737 | |
2738 _check_for_disconnect(user, rc); | |
2739 } | |
2740 } | |
2741 } | |
2742 | |
2743 static void | |
2744 novell_rename_group(GaimConnection * gc, const char *old_name, | |
9285 | 2745 GaimGroup *group, GList *moved_buddies) |
8675 | 2746 { |
2747 NMERR_T rc = NM_OK; | |
8782
5a2b5e4abf3a
[gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents:
8781
diff
changeset
|
2748 NMFolder *folder; |
8675 | 2749 NMUser *user; |
2750 | |
9285 | 2751 if (gc == NULL || old_name == NULL || group == NULL || moved_buddies == NULL) { |
8675 | 2752 return; |
2753 } | |
2754 | |
2755 user = gc->proto_data; | |
2756 if (user) { | |
2757 /* Does new folder exist already? */ | |
9285 | 2758 if (nm_find_folder(user, group->name)) { |
9651 | 2759 /* gaim_blist_rename_group() adds the buddies |
2760 * to the new group and removes the old group... | |
2761 * so there is nothing more to do here. | |
8675 | 2762 */ |
2763 return; | |
2764 } | |
2765 | |
9651 | 2766 if (strcmp(old_name, NM_ROOT_FOLDER_NAME) == 0) { |
2767 /* Can't rename the root folder ... need to revisit this */ | |
2768 return; | |
2769 } | |
2770 | |
8782
5a2b5e4abf3a
[gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents:
8781
diff
changeset
|
2771 folder = nm_find_folder(user, old_name); |
8675 | 2772 if (folder) { |
9285 | 2773 rc = nm_send_rename_folder(user, folder, group->name, |
8675 | 2774 _rename_folder_resp_cb, NULL); |
2775 _check_for_disconnect(user, rc); | |
2776 } | |
2777 } | |
2778 } | |
2779 | |
2780 static void | |
9972 | 2781 novell_list_emblems(GaimBuddy * buddy, const char **se, const char **sw, const char **nw, const char **ne) |
8675 | 2782 { |
11536 | 2783 NMUserRecord *user_record = NULL; |
2784 GaimConnection *gc; | |
2785 NMUser *user; | |
2786 int status = 0; | |
2787 | |
2788 gc = gaim_account_get_connection(buddy->account); | |
2789 | |
2790 if (gc == NULL || (user = gc->proto_data) == NULL) | |
2791 return; | |
2792 | |
2793 user_record = nm_find_user_record(user, buddy->name); | |
2794 | |
2795 if (user_record) | |
2796 status = nm_user_record_get_status(user_record); | |
8675 | 2797 |
2798 switch (status) { | |
2799 case NM_STATUS_AVAILABLE: | |
2800 *se = ""; | |
2801 break; | |
2802 case NM_STATUS_AWAY: | |
2803 *se = "away"; | |
2804 break; | |
2805 case NM_STATUS_BUSY: | |
2806 *se = "occupied"; | |
2807 break; | |
2808 case NM_STATUS_UNKNOWN: | |
2809 *se = "error"; | |
2810 break; | |
2811 } | |
2812 } | |
2813 | |
2814 static const char * | |
2815 novell_list_icon(GaimAccount * account, GaimBuddy * buddy) | |
2816 { | |
2817 return "novell"; | |
2818 } | |
2819 | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2820 static void |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2821 novell_tooltip_text(GaimBuddy * buddy, GString * str, gboolean full) |
8675 | 2822 { |
2823 NMUserRecord *user_record = NULL; | |
2824 GaimConnection *gc; | |
2825 NMUser *user; | |
2826 int status = 0; | |
2827 const char *status_str = NULL; | |
2828 const char *text = NULL; | |
2829 | |
2830 if (buddy == NULL) | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2831 return; |
8675 | 2832 |
2833 gc = gaim_account_get_connection(buddy->account); | |
2834 if (gc == NULL || (user = gc->proto_data) == NULL) | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2835 return; |
8675 | 2836 |
2837 if (GAIM_BUDDY_IS_ONLINE(buddy)) { | |
2838 user_record = nm_find_user_record(user, buddy->name); | |
2839 if (user_record) { | |
2840 status = nm_user_record_get_status(user_record); | |
2841 text = nm_user_record_get_status_text(user_record); | |
2842 /* No custom text, so default it ... */ | |
2843 switch (status) { | |
2844 case NM_STATUS_AVAILABLE: | |
2845 status_str = _("Available"); | |
2846 break; | |
2847 case NM_STATUS_AWAY: | |
2848 status_str = _("Away"); | |
2849 break; | |
2850 case NM_STATUS_BUSY: | |
2851 status_str = _("Busy"); | |
2852 break; | |
2853 case NM_STATUS_AWAY_IDLE: | |
2854 status_str = _("Idle"); | |
2855 break; | |
2856 case NM_STATUS_OFFLINE: | |
2857 status_str = _("Offline"); | |
2858 break; | |
2859 default: | |
2860 status_str = _("Unknown"); | |
2861 break; | |
2862 } | |
2863 | |
2864 if (text) | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2865 g_string_append_printf(str, "\n<b>%s:</b> %s" |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2866 "\n<b>%s:</b> %s", |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2867 _("Status"), status_str, |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2868 _("Message"), text); |
8675 | 2869 else |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2870 g_string_append_printf(str, "\n<b>%s:</b> %s", |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2871 _("Status"), status_str); |
8675 | 2872 } |
2873 } | |
2874 } | |
2875 | |
2876 static void | |
2877 novell_set_idle(GaimConnection * gc, int time) | |
2878 { | |
2879 NMUser *user; | |
2880 NMERR_T rc = NM_OK; | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2881 const char *id = NULL; |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2882 GaimStatus *status = NULL; |
8675 | 2883 |
2884 if (gc == NULL) | |
2885 return; | |
2886 | |
2887 user = gc->proto_data; | |
2888 if (user == NULL) | |
2889 return; | |
2890 | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2891 status = gaim_account_get_active_status(gaim_connection_get_account(gc)); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2892 id = gaim_status_get_id(status); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2893 |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2894 /* Only go idle if active status is available */ |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2895 if (!strcmp(id, NOVELL_STATUS_TYPE_AVAILABLE)) { |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2896 if (time > 0) { |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2897 rc = nm_send_set_status(user, NM_STATUS_AWAY_IDLE, NULL, NULL, NULL, NULL); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2898 } else { |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2899 rc = nm_send_set_status(user, NM_STATUS_AVAILABLE, NULL, NULL, NULL, NULL); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2900 } |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2901 } |
8675 | 2902 |
2903 _check_for_disconnect(user, rc); | |
2904 } | |
2905 | |
2906 static void | |
2907 novell_get_info(GaimConnection * gc, const char *name) | |
2908 { | |
2909 NMUserRecord *user_record; | |
2910 NMUser *user; | |
2911 NMERR_T rc; | |
2912 | |
2913 if (gc == NULL || name == NULL) | |
2914 return; | |
2915 | |
2916 user = (NMUser *) gc->proto_data; | |
2917 if (user) { | |
2918 | |
2919 user_record = nm_find_user_record(user, name); | |
2920 if (user_record) { | |
2921 | |
2922 _show_info(gc, user_record); | |
2923 | |
2924 } else { | |
2925 | |
2926 rc = nm_send_get_details(user, name, | |
2927 _get_details_resp_show_info, g_strdup(name)); | |
2928 | |
2929 _check_for_disconnect(user, rc); | |
2930 | |
2931 } | |
2932 | |
2933 } | |
2934 } | |
2935 | |
2936 static char * | |
2937 novell_status_text(GaimBuddy * buddy) | |
2938 { | |
2939 const char *text = NULL; | |
2940 const char *dn = NULL; | |
2941 | |
2942 if (buddy && buddy->account) { | |
2943 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
2944 | |
2945 if (gc && gc->proto_data) { | |
2946 NMUser *user = gc->proto_data; | |
2947 | |
2948 dn = nm_lookup_dn(user, buddy->name); | |
2949 if (dn) { | |
2950 NMUserRecord *user_record = nm_find_user_record(user, dn); | |
2951 | |
2952 if (user_record) { | |
2953 text = nm_user_record_get_status_text(user_record); | |
2954 if (text) | |
2955 return g_strdup(text); | |
2956 } | |
2957 } | |
2958 } | |
2959 } | |
2960 | |
2961 return NULL; | |
2962 } | |
10762 | 2963 |
8675 | 2964 static GList * |
10762 | 2965 novell_status_types(GaimAccount *account) |
8675 | 2966 { |
10762 | 2967 GList *status_types = NULL; |
2968 GaimStatusType *type; | |
2969 | |
2970 g_return_val_if_fail(account != NULL, NULL); | |
2971 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2972 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, NOVELL_STATUS_TYPE_AVAILABLE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2973 NULL, TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2974 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2975 NULL); |
10762 | 2976 status_types = g_list_append(status_types, type); |
2977 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2978 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, NOVELL_STATUS_TYPE_AWAY, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2979 NULL, TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2980 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2981 NULL); |
10762 | 2982 status_types = g_list_append(status_types, type); |
2983 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2984 type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, NOVELL_STATUS_TYPE_BUSY, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2985 _("Busy"), TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2986 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2987 NULL); |
11971 | 2988 status_types = g_list_append(status_types, type); |
2989 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2990 type = gaim_status_type_new_full(GAIM_STATUS_INVISIBLE, NOVELL_STATUS_TYPE_APPEAR_OFFLINE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2991 NULL, TRUE, TRUE, FALSE); |
10762 | 2992 status_types = g_list_append(status_types, type); |
2993 | |
12658 | 2994 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, NULL, NULL, FALSE, TRUE, FALSE); |
2995 status_types = g_list_append(status_types, type); | |
2996 | |
10762 | 2997 return status_types; |
8675 | 2998 } |
2999 | |
3000 static void | |
10762 | 3001 novell_set_status(GaimAccount *account, GaimStatus *status) |
3002 { | |
11971 | 3003 GaimConnection *gc; |
10762 | 3004 gboolean connected; |
11972 | 3005 GaimPresence *presence; |
10762 | 3006 GaimStatusType *type; |
11971 | 3007 GaimStatusPrimitive primitive; |
3008 NMUser *user; | |
3009 NMSTATUS_T novellstatus = NM_STATUS_AVAILABLE; | |
3010 NMERR_T rc = NM_OK; | |
3011 const char *msg = NULL; | |
3012 char *text = NULL; | |
10762 | 3013 |
3014 connected = gaim_account_is_connected(account); | |
11972 | 3015 presence = gaim_status_get_presence(status); |
10762 | 3016 type = gaim_status_get_type(status); |
3017 primitive = gaim_status_type_get_primitive(type); | |
3018 | |
3019 /* | |
3020 * We don't have any independent statuses, so we don't need to | |
3021 * do anything when a status is deactivated (because another | |
3022 * status is about to be activated). | |
3023 */ | |
3024 if (!gaim_status_is_active(status)) | |
3025 return; | |
3026 | |
11718 | 3027 if (!connected) |
3028 return; | |
3029 | |
11971 | 3030 gc = gaim_account_get_connection(account); |
8675 | 3031 user = gc->proto_data; |
3032 if (user == NULL) | |
3033 return; | |
3034 | |
11971 | 3035 if (primitive == GAIM_STATUS_AVAILABLE) { |
3036 novellstatus = NM_STATUS_AVAILABLE; | |
3037 } else if (primitive == GAIM_STATUS_AWAY) { | |
3038 novellstatus = NM_STATUS_AWAY; | |
3039 } else if (primitive == GAIM_STATUS_UNAVAILABLE) { | |
3040 novellstatus = NM_STATUS_BUSY; | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
3041 } else if (primitive == GAIM_STATUS_INVISIBLE) { |
11971 | 3042 novellstatus = NM_STATUS_OFFLINE; |
11972 | 3043 } else if (gaim_presence_is_idle(presence)) { |
11971 | 3044 novellstatus = NM_STATUS_AWAY_IDLE; |
8675 | 3045 } else { |
11971 | 3046 novellstatus = NM_STATUS_AVAILABLE; |
8675 | 3047 } |
3048 | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3049 if (primitive == GAIM_STATUS_AWAY || primitive == GAIM_STATUS_AVAILABLE || |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3050 primitive == GAIM_STATUS_UNAVAILABLE) { |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3051 msg = gaim_status_get_attr_string(status, "message"); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3052 text = g_strdup(msg); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3053 |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3054 if (primitive == GAIM_STATUS_AVAILABLE) |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3055 msg = NULL; /* no auto replies for online status */ |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3056 |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3057 /* Don't want newlines in status text */ |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3058 gaim_util_chrreplace(text, '\n', ' '); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3059 } |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3060 |
11971 | 3061 rc = nm_send_set_status(user, novellstatus, text, msg, NULL, NULL); |
8675 | 3062 _check_for_disconnect(user, rc); |
3063 | |
3064 if (text) | |
3065 g_free(text); | |
3066 } | |
10762 | 3067 |
8933 | 3068 static void |
3069 novell_add_permit(GaimConnection *gc, const char *who) | |
3070 { | |
3071 NMUser *user; | |
3072 NMERR_T rc = NM_OK; | |
3073 const char *name = who; | |
3074 | |
3075 if (gc == NULL || who == NULL) | |
3076 return; | |
3077 | |
3078 user = gc->proto_data; | |
3079 if (user == NULL) | |
3080 return; | |
3081 | |
3082 /* Remove first -- we will add it back in when we get | |
3083 * the okay from the server | |
3084 */ | |
3085 gaim_privacy_permit_remove(gc->account, who, TRUE); | |
3086 | |
3087 if (nm_user_is_privacy_locked(user)) { | |
3088 _show_privacy_locked_error(gc, user); | |
3089 _sync_privacy_lists(user); | |
3090 return; | |
3091 } | |
3092 | |
3093 /* Work around for problem with un-typed, dotted contexts */ | |
3094 if (strchr(who, '.')) { | |
3095 const char *dn = nm_lookup_dn(user, who); | |
3096 if (dn == NULL) { | |
3097 rc = nm_send_get_details(user, who, _get_details_send_privacy_create, | |
3098 (gpointer)TRUE); | |
3099 _check_for_disconnect(user, rc); | |
3100 return; | |
3101 } else { | |
3102 name = dn; | |
3103 } | |
3104 } | |
3105 | |
3106 rc = nm_send_create_privacy_item(user, name, TRUE, | |
3107 _create_privacy_item_permit_resp_cb, | |
3108 g_strdup(who)); | |
3109 _check_for_disconnect(user, rc); | |
3110 } | |
3111 | |
3112 static void | |
3113 novell_add_deny(GaimConnection *gc, const char *who) | |
3114 { | |
3115 NMUser *user; | |
3116 NMERR_T rc = NM_OK; | |
3117 const char *name = who; | |
3118 | |
3119 if (gc == NULL || who == NULL) | |
3120 return; | |
3121 | |
3122 user = gc->proto_data; | |
3123 if (user == NULL) | |
3124 return; | |
3125 | |
3126 /* Remove first -- we will add it back in when we get | |
3127 * the okay from the server | |
3128 */ | |
3129 gaim_privacy_deny_remove(gc->account, who, TRUE); | |
3130 | |
3131 if (nm_user_is_privacy_locked(user)) { | |
3132 _show_privacy_locked_error(gc, user); | |
3133 _sync_privacy_lists(user); | |
3134 return; | |
3135 } | |
3136 | |
3137 /* Work around for problem with un-typed, dotted contexts */ | |
3138 if (strchr(who, '.')) { | |
3139 const char *dn = nm_lookup_dn(user, who); | |
3140 if (dn == NULL) { | |
3141 rc = nm_send_get_details(user, who, _get_details_send_privacy_create, | |
3142 (gpointer)FALSE); | |
3143 _check_for_disconnect(user, rc); | |
3144 return; | |
3145 } else { | |
3146 name = dn; | |
3147 } | |
3148 } | |
3149 | |
3150 rc = nm_send_create_privacy_item(user, name, FALSE, | |
3151 _create_privacy_item_deny_resp_cb, | |
3152 g_strdup(who)); | |
3153 _check_for_disconnect(user, rc); | |
3154 } | |
3155 | |
3156 static void | |
3157 novell_rem_permit(GaimConnection *gc, const char *who) | |
3158 { | |
3159 NMUser *user; | |
3160 NMERR_T rc = NM_OK; | |
3161 const char *dn = NULL; | |
3162 | |
3163 if (gc == NULL || who == NULL) | |
3164 return; | |
3165 | |
3166 user = gc->proto_data; | |
3167 if (user == NULL) | |
3168 return; | |
3169 | |
3170 if (nm_user_is_privacy_locked(user)) { | |
3171 _show_privacy_locked_error(gc, user); | |
3172 _sync_privacy_lists(user); | |
3173 return; | |
3174 } | |
3175 | |
3176 dn = nm_lookup_dn(user, who); | |
3177 if (dn == NULL) | |
3178 dn = who; | |
3179 | |
3180 rc = nm_send_remove_privacy_item(user, dn, TRUE, | |
3181 _remove_privacy_item_resp_cb, | |
3182 g_strdup(who)); | |
3183 _check_for_disconnect(user, rc); | |
3184 } | |
3185 | |
3186 static void | |
3187 novell_rem_deny(GaimConnection *gc, const char *who) | |
3188 { | |
3189 NMUser *user; | |
3190 NMERR_T rc = NM_OK; | |
3191 const char *dn = NULL; | |
3192 | |
3193 if (gc == NULL || who == NULL) | |
3194 return; | |
3195 | |
3196 user = gc->proto_data; | |
3197 if (user == NULL) | |
3198 return; | |
3199 | |
3200 if (nm_user_is_privacy_locked(user)) { | |
3201 _show_privacy_locked_error(gc, user); | |
3202 _sync_privacy_lists(user); | |
3203 return; | |
3204 } | |
3205 | |
3206 dn = nm_lookup_dn(user, who); | |
3207 if (dn == NULL) | |
3208 dn = who; | |
3209 | |
3210 rc = nm_send_remove_privacy_item(user, dn, FALSE, | |
3211 _remove_privacy_item_resp_cb, | |
3212 g_strdup(who)); | |
3213 _check_for_disconnect(user, rc); | |
3214 } | |
3215 | |
3216 static void | |
3217 novell_set_permit_deny(GaimConnection *gc) | |
3218 { | |
3219 NMERR_T rc = NM_OK; | |
3220 const char *dn, *name = NULL; | |
3221 NMUserRecord *user_record = NULL; | |
3222 GSList *node = NULL, *copy = NULL; | |
3223 NMUser *user; | |
3224 int i, j, num_contacts, num_folders; | |
3225 NMContact *contact; | |
3226 NMFolder *folder = NULL; | |
3227 | |
3228 if (gc == NULL) | |
3229 return; | |
3230 | |
3231 user = gc->proto_data; | |
3232 if (user == NULL) | |
3233 return; | |
3234 | |
9268 | 3235 if (user->privacy_synched == FALSE) { |
3236 _sync_privacy_lists(user); | |
3237 user->privacy_synched = TRUE; | |
8933 | 3238 return; |
3239 } | |
3240 | |
3241 if (nm_user_is_privacy_locked(user)) { | |
3242 _show_privacy_locked_error(gc, user); | |
3243 _sync_privacy_lists(user); | |
3244 return; | |
3245 } | |
3246 | |
3247 switch (gc->account->perm_deny) { | |
3248 | |
3249 case GAIM_PRIVACY_ALLOW_ALL: | |
3250 rc = nm_send_set_privacy_default(user, FALSE, | |
3251 _set_privacy_default_resp_cb, NULL); | |
3252 _check_for_disconnect(user, rc); | |
3253 | |
3254 /* clear server side deny list */ | |
3255 if (rc == NM_OK) { | |
3256 copy = g_slist_copy(user->deny_list); | |
3257 for (node = copy; node && node->data; node = node->next) { | |
3258 rc = nm_send_remove_privacy_item(user, (const char *)node->data, | |
3259 FALSE, NULL, NULL); | |
3260 if (_check_for_disconnect(user, rc)) | |
3261 break; | |
3262 } | |
3263 g_slist_free(copy); | |
3264 g_slist_free(user->deny_list); | |
3265 user->deny_list = NULL; | |
3266 } | |
3267 break; | |
3268 | |
3269 case GAIM_PRIVACY_DENY_ALL: | |
3270 rc = nm_send_set_privacy_default(user, TRUE, | |
3271 _set_privacy_default_resp_cb, NULL); | |
3272 _check_for_disconnect(user, rc); | |
3273 | |
3274 /* clear server side allow list */ | |
3275 if (rc == NM_OK) { | |
3276 copy = g_slist_copy(user->allow_list); | |
3277 for (node = copy; node && node->data; node = node->next) { | |
3278 rc = nm_send_remove_privacy_item(user, (const char *)node->data, | |
3279 TRUE, NULL, NULL); | |
3280 if (_check_for_disconnect(user, rc)) | |
3281 break; | |
3282 } | |
3283 g_slist_free(copy); | |
3284 g_slist_free(user->allow_list); | |
3285 user->allow_list = NULL; | |
3286 } | |
3287 break; | |
3288 | |
3289 case GAIM_PRIVACY_ALLOW_USERS: | |
3290 | |
3291 rc = nm_send_set_privacy_default(user, TRUE, | |
3292 _set_privacy_default_resp_cb, NULL); | |
3293 _check_for_disconnect(user, rc); | |
3294 | |
3295 /* sync allow lists */ | |
3296 if (rc == NM_OK) { | |
3297 | |
3298 for (node = user->allow_list; node; node = node->next) { | |
3299 user_record = nm_find_user_record(user, (char *)node->data); | |
3300 if (user_record) { | |
3301 name = nm_user_record_get_display_id(user_record); | |
3302 | |
3303 if (!g_slist_find_custom(gc->account->permit, | |
3304 name, (GCompareFunc)nm_utf8_strcasecmp)) { | |
3305 gaim_privacy_permit_add(gc->account, name , TRUE); | |
3306 } | |
3307 } | |
3308 } | |
3309 | |
3310 for (node = gc->account->permit; node; node = node->next) { | |
3311 name = NULL; | |
3312 dn = nm_lookup_dn(user, (char *)node->data); | |
3313 if (dn) { | |
3314 user_record = nm_find_user_record(user, dn); | |
3315 name = nm_user_record_get_display_id(user_record); | |
3316 | |
3317 if (!g_slist_find_custom(user->allow_list, | |
3318 dn, (GCompareFunc)nm_utf8_strcasecmp)) { | |
3319 rc = nm_send_create_privacy_item(user, dn, TRUE, | |
3320 _create_privacy_item_deny_resp_cb, | |
3321 g_strdup(dn)); | |
3322 } | |
3323 } else { | |
3324 gaim_privacy_permit_remove(gc->account, (char *)node->data, TRUE); | |
3325 } | |
3326 } | |
3327 } | |
3328 break; | |
3329 | |
3330 case GAIM_PRIVACY_DENY_USERS: | |
3331 | |
3332 /* set to default allow */ | |
3333 rc = nm_send_set_privacy_default(user, FALSE, | |
3334 _set_privacy_default_resp_cb, NULL); | |
3335 _check_for_disconnect(user, rc); | |
3336 | |
3337 /* sync deny lists */ | |
3338 if (rc == NM_OK) { | |
3339 | |
3340 for (node = user->deny_list; node; node = node->next) { | |
3341 user_record = nm_find_user_record(user, (char *)node->data); | |
3342 if (user_record) { | |
3343 name = nm_user_record_get_display_id(user_record); | |
3344 | |
3345 if (!g_slist_find_custom(gc->account->deny, | |
3346 name, (GCompareFunc)nm_utf8_strcasecmp)) { | |
3347 gaim_privacy_deny_add(gc->account, name , TRUE); | |
3348 } | |
3349 } | |
3350 } | |
3351 | |
3352 for (node = gc->account->deny; node; node = node->next) { | |
3353 | |
3354 name = NULL; | |
3355 dn = nm_lookup_dn(user, (char *)node->data); | |
3356 if (dn) { | |
3357 user_record = nm_find_user_record(user, dn); | |
3358 name = nm_user_record_get_display_id(user_record); | |
3359 | |
3360 if (!g_slist_find_custom(user->deny_list, | |
3361 dn, (GCompareFunc)nm_utf8_strcasecmp)) { | |
3362 rc = nm_send_create_privacy_item(user, dn, FALSE, | |
3363 _create_privacy_item_deny_resp_cb, | |
3364 g_strdup(name)); | |
3365 } | |
3366 } else { | |
3367 gaim_privacy_deny_remove(gc->account, (char *)node->data, TRUE); | |
3368 } | |
3369 } | |
3370 | |
3371 } | |
3372 break; | |
3373 | |
3374 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
3375 | |
3376 /* remove users from allow list that are not in buddy list */ | |
3377 copy = g_slist_copy(user->allow_list); | |
3378 for (node = copy; node && node->data; node = node->next) { | |
3379 if (!nm_find_contacts(user, node->data)) { | |
3380 rc = nm_send_remove_privacy_item(user, (const char *)node->data, | |
3381 TRUE, NULL, NULL); | |
3382 if (_check_for_disconnect(user, rc)) | |
3383 return; | |
3384 } | |
3385 } | |
3386 g_slist_free(copy); | |
3387 | |
3388 /* add all buddies to allow list */ | |
3389 num_contacts = nm_folder_get_contact_count(user->root_folder); | |
3390 for (i = 0; i < num_contacts; i++) { | |
3391 contact = nm_folder_get_contact(user->root_folder, i); | |
3392 dn = nm_contact_get_dn(contact); | |
3393 if (dn && !g_slist_find_custom(user->allow_list, | |
3394 dn, (GCompareFunc)nm_utf8_strcasecmp)) | |
3395 { | |
3396 rc = nm_send_create_privacy_item(user, dn, TRUE, | |
3397 _create_privacy_item_deny_resp_cb, | |
3398 g_strdup(dn)); | |
3399 if (_check_for_disconnect(user, rc)) | |
3400 return; | |
3401 } | |
3402 | |
3403 } | |
3404 | |
3405 num_folders = nm_folder_get_subfolder_count(user->root_folder); | |
3406 for (i = 0; i < num_folders; i++) { | |
3407 folder = nm_folder_get_subfolder(user->root_folder, i); | |
3408 num_contacts = nm_folder_get_contact_count(folder); | |
3409 for (j = 0; j < num_contacts; j++) { | |
3410 contact = nm_folder_get_contact(folder, j); | |
3411 dn = nm_contact_get_dn(contact); | |
3412 if (dn && !g_slist_find_custom(user->allow_list, | |
3413 dn, (GCompareFunc)nm_utf8_strcasecmp)) | |
3414 { | |
3415 rc = nm_send_create_privacy_item(user, dn, TRUE, | |
3416 _create_privacy_item_deny_resp_cb, | |
3417 g_strdup(dn)); | |
3418 if (_check_for_disconnect(user, rc)) | |
3419 return; | |
3420 } | |
3421 } | |
3422 } | |
3423 | |
3424 /* set to default deny */ | |
3425 rc = nm_send_set_privacy_default(user, TRUE, | |
3426 _set_privacy_default_resp_cb, NULL); | |
3427 if (_check_for_disconnect(user, rc)) | |
3428 break; | |
3429 | |
3430 break; | |
3431 } | |
3432 } | |
3433 | |
3434 static GList * | |
9030 | 3435 novell_blist_node_menu(GaimBlistNode *node) |
8933 | 3436 { |
3437 GList *list = NULL; | |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12715
diff
changeset
|
3438 GaimMenuAction *act; |
9030 | 3439 |
3440 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12715
diff
changeset
|
3441 act = gaim_menu_action_new(_("Initiate _Chat"), |
13020
72300c551dc2
[gaim-migrate @ 15373]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12978
diff
changeset
|
3442 GAIM_CALLBACK(_initiate_conference_cb), |
72300c551dc2
[gaim-migrate @ 15373]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12978
diff
changeset
|
3443 NULL, NULL); |
9030 | 3444 list = g_list_append(list, act); |
3445 } | |
8933 | 3446 |
3447 return list; | |
3448 } | |
3449 | |
9268 | 3450 static void |
3451 novell_keepalive(GaimConnection *gc) | |
3452 { | |
3453 NMUser *user; | |
3454 NMERR_T rc = NM_OK; | |
3455 | |
3456 if (gc == NULL) | |
3457 return; | |
3458 | |
3459 user = gc->proto_data; | |
3460 if (user == NULL) | |
3461 return; | |
3462 | |
3463 rc = nm_send_keepalive(user, NULL, NULL); | |
3464 _check_for_disconnect(user, rc); | |
3465 } | |
3466 | |
8675 | 3467 static GaimPluginProtocolInfo prpl_info = { |
3468 0, | |
9475 | 3469 NULL, /* user_splits */ |
3470 NULL, /* protocol_options */ | |
3471 NO_BUDDY_ICONS, /* icon_spec */ | |
3472 novell_list_icon, /* list_icon */ | |
3473 novell_list_emblems, /* list_emblems */ | |
3474 novell_status_text, /* status_text */ | |
3475 novell_tooltip_text, /* tooltip_text */ | |
10762 | 3476 novell_status_types, /* status_types */ |
9475 | 3477 novell_blist_node_menu, /* blist_node_menu */ |
8675 | 3478 NULL, /* chat_info */ |
9754 | 3479 NULL, /* chat_info_defaults */ |
9475 | 3480 novell_login, /* login */ |
3481 novell_close, /* close */ | |
3482 novell_send_im, /* send_im */ | |
8675 | 3483 NULL, /* set_info */ |
9475 | 3484 novell_send_typing, /* send_typing */ |
3485 novell_get_info, /* get_info */ | |
10762 | 3486 novell_set_status, /* set_status */ |
9475 | 3487 novell_set_idle, /* set_idle */ |
3488 NULL, /* change_passwd */ | |
3489 novell_add_buddy, /* add_buddy */ | |
8675 | 3490 NULL, /* add_buddies */ |
9475 | 3491 novell_remove_buddy, /* remove_buddy */ |
8675 | 3492 NULL, /* remove_buddies */ |
9475 | 3493 novell_add_permit, /* add_permit */ |
3494 novell_add_deny, /* add_deny */ | |
3495 novell_rem_permit, /* rem_permit */ | |
3496 novell_rem_deny, /* rem_deny */ | |
3497 novell_set_permit_deny, /* set_permit_deny */ | |
8675 | 3498 NULL, /* join_chat */ |
9268 | 3499 NULL, /* reject_chat */ |
9917 | 3500 NULL, /* get_chat_name */ |
8933 | 3501 novell_chat_invite, /* chat_invite */ |
9475 | 3502 novell_chat_leave, /* chat_leave */ |
8675 | 3503 NULL, /* chat_whisper */ |
9475 | 3504 novell_chat_send, /* chat_send */ |
3505 novell_keepalive, /* keepalive */ | |
8675 | 3506 NULL, /* register_user */ |
3507 NULL, /* get_cb_info */ | |
9475 | 3508 NULL, /* get_cb_away */ |
3509 novell_alias_buddy, /* alias_buddy */ | |
3510 novell_group_buddy, /* group_buddy */ | |
3511 novell_rename_group, /* rename_group */ | |
8675 | 3512 NULL, /* buddy_free */ |
9475 | 3513 novell_convo_closed, /* convo_closed */ |
11153 | 3514 gaim_normalize_nocase, /* normalize */ |
8675 | 3515 NULL, /* set_buddy_icon */ |
9475 | 3516 novell_remove_group, /* remove_group */ |
3517 NULL, /* get_cb_real_name */ | |
3518 NULL, /* set_chat_topic */ | |
3519 NULL, /* find_blist_chat */ | |
3520 NULL, /* roomlist_get_list */ | |
3521 NULL, /* roomlist_cancel */ | |
3522 NULL, /* roomlist_expand_category */ | |
9473 | 3523 NULL, /* can_receive_file */ |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12126
diff
changeset
|
3524 NULL, /* send_file */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
3525 NULL, /* new_xfer */ |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
3526 NULL, /* offline_message */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
3527 NULL, /* whiteboard_prpl_ops */ |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
3528 NULL, /* media_prpl_ops */ |
8675 | 3529 }; |
3530 | |
3531 static GaimPluginInfo info = { | |
9943 | 3532 GAIM_PLUGIN_MAGIC, |
3533 GAIM_MAJOR_VERSION, | |
3534 GAIM_MINOR_VERSION, | |
8993 | 3535 GAIM_PLUGIN_PROTOCOL, /**< type */ |
3536 NULL, /**< ui_requirement */ | |
3537 0, /**< flags */ | |
3538 NULL, /**< dependencies */ | |
3539 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
3540 "prpl-novell", /**< id */ | |
3541 "GroupWise", /**< name */ | |
3542 VERSION, /**< version */ | |
8675 | 3543 /** summary */ |
3544 N_("Novell GroupWise Messenger Protocol Plugin"), | |
3545 /** description */ | |
3546 N_("Novell GroupWise Messenger Protocol Plugin"), | |
8993 | 3547 NULL, /**< author */ |
3548 GAIM_WEBSITE, /**< homepage */ | |
3549 | |
3550 NULL, /**< load */ | |
3551 NULL, /**< unload */ | |
3552 NULL, /**< destroy */ | |
3553 | |
3554 NULL, /**< ui_info */ | |
3555 &prpl_info, /**< extra_info */ | |
3556 NULL, | |
3557 NULL | |
8675 | 3558 }; |
3559 | |
3560 static void | |
3561 init_plugin(GaimPlugin * plugin) | |
3562 { | |
3563 GaimAccountOption *option; | |
3564 | |
3565 option = gaim_account_option_string_new(_("Server address"), "server", NULL); | |
3566 prpl_info.protocol_options = | |
3567 g_list_append(prpl_info.protocol_options, option); | |
3568 | |
3569 option = gaim_account_option_int_new(_("Server port"), "port", DEFAULT_PORT); | |
3570 prpl_info.protocol_options = | |
3571 g_list_append(prpl_info.protocol_options, option); | |
3572 | |
3573 my_protocol = plugin; | |
3574 } | |
3575 | |
3576 GAIM_INIT_PLUGIN(novell, init_plugin, info); |