Mercurial > pidgin
annotate src/protocols/novell/novell.c @ 13967:99b9b58b19dd
[gaim-migrate @ 16523]
Fix a crazy MSN crash. Basically it's possible to have more than one
slplink associated with a given switchboard, but our code did not
allow for that. I think it happens when you're in a multi-user
chat and you do stuff with multiple users that involves slplinks.
Like maybe file transfer and buddy icon related stuff.
Tracking this down took an ungodly amount of time, but thanks to
Meebo for letting me do it :-)
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 20 Jul 2006 07:31:15 +0000 |
parents | a9ff4499d9ce |
children |
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 |
13072 | 127 /* Don't attempt to auto-reconnect if our password |
128 * was invalid. | |
12222
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) { |
13072 | 133 gc->wants_to_die = TRUE; |
12222
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 | |
13436
a04ebe46930a
[gaim-migrate @ 15811]
Richard Laager <rlaager@wiktel.com>
parents:
13296
diff
changeset
|
342 if (folder_name == NULL || *folder_name == '\0') |
9651 | 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 GSList *cnode; | |
960 NMConference *conference; | |
961 gpointer chat; | |
962 long id = (long) user_data; | |
963 | |
964 if (user == NULL) | |
965 return; | |
966 | |
967 gc = gaim_account_get_connection(user->client_data); | |
968 | |
969 if (ret_code == NM_OK) { | |
970 | |
971 for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) { | |
972 conference = cnode->data; | |
973 if (conference && (chat = nm_conference_get_data(conference))) { | |
974 if (gaim_conv_chat_get_id(GAIM_CONV_CHAT(chat)) == id) { | |
975 rc = nm_send_conference_invite(user, conference, user_record, | |
976 NULL, _sendinvite_resp_cb, NULL); | |
977 _check_for_disconnect(user, rc); | |
978 break; | |
979 } | |
980 } | |
981 } | |
982 | |
983 } else { | |
984 | |
985 err = g_strdup_printf(_("Unable to invite user (%s)."), nm_error_to_string(ret_code)); | |
986 gaim_notify_error(gc, NULL, err, NULL); | |
987 g_free(err); | |
988 | |
989 } | |
990 } | |
991 | |
992 static void | |
993 _createconf_resp_send_invite(NMUser * user, NMERR_T ret_code, | |
994 gpointer resp_data, gpointer user_data) | |
995 { | |
996 NMERR_T rc = NM_OK; | |
997 NMConference *conference = resp_data; | |
998 NMUserRecord *user_record = user_data; | |
999 GaimConnection *gc; | |
1000 char *err; | |
1001 | |
1002 if (user == NULL) | |
1003 return; | |
1004 | |
1005 | |
1006 | |
1007 if (ret_code == NM_OK) { | |
1008 rc = nm_send_conference_invite(user, conference, user_record, | |
1009 NULL, _sendinvite_resp_cb, NULL); | |
1010 _check_for_disconnect(user, rc); | |
1011 } else { | |
1012 err = g_strdup_printf(_("Unable to create conference (%s)."), nm_error_to_string(ret_code)); | |
1013 gc = gaim_account_get_connection(user->client_data); | |
1014 gaim_notify_error(gc, NULL, err, NULL); | |
1015 g_free(err); | |
1016 } | |
1017 } | |
1018 | |
8675 | 1019 /******************************************************************************* |
1020 * Helper functions | |
1021 ******************************************************************************/ | |
1022 | |
1023 static char * | |
1024 _user_agent_string() | |
1025 { | |
1026 | |
1027 #if !defined(_WIN32) | |
1028 | |
1029 const char *sysname = ""; | |
1030 const char *release = ""; | |
1031 struct utsname u; | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1032 |
8675 | 1033 if (uname(&u) == 0) { |
1034 sysname = u.sysname; | |
1035 release = u.release; | |
1036 } else { | |
1037 sysname = "Linux"; | |
1038 release = "Unknown"; | |
1039 } | |
1040 | |
12408
3d297efa70bb
[gaim-migrate @ 14715]
Richard Laager <rlaager@wiktel.com>
parents:
12222
diff
changeset
|
1041 return g_strdup_printf("Gaim/%s (%s; %s)", VERSION, sysname, release); |
8675 | 1042 |
1043 #else | |
1044 | |
1045 const char *sysname = ""; | |
1046 OSVERSIONINFO os_info; | |
1047 SYSTEM_INFO sys_info; | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1048 |
8675 | 1049 os_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
1050 GetVersionEx(&os_info); | |
1051 GetSystemInfo(&sys_info); | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1052 |
8675 | 1053 if (os_info.dwPlatformId == VER_PLATFORM_WIN32_NT) { |
1054 switch (os_info.dwMajorVersion) { | |
1055 case 3: | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1056 case 4: |
8675 | 1057 sysname = "Windows NT"; |
1058 break; | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1059 case 5: |
8675 | 1060 switch (os_info.dwMinorVersion) { |
1061 case 0: | |
1062 sysname = "Windows 2000"; | |
1063 break; | |
1064 case 1: | |
1065 sysname = "Windows XP"; | |
1066 break; | |
1067 case 2: | |
1068 sysname = "Windows Server 2003"; | |
1069 break; | |
1070 default: | |
1071 sysname = "Windows"; | |
1072 break; | |
1073 } | |
1074 break; | |
1075 default: | |
1076 sysname = "Windows"; | |
1077 break; | |
1078 } | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1079 |
8675 | 1080 } else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { |
1081 switch (os_info.dwMinorVersion) { | |
1082 case 0: | |
1083 sysname = "Windows 95"; | |
1084 break; | |
1085 case 10: | |
1086 sysname = "Windows 98"; | |
1087 break; | |
1088 case 90: | |
1089 sysname = "Windows ME"; | |
1090 break; | |
1091 default: | |
1092 sysname = "Windows"; | |
1093 break; | |
1094 } | |
1095 } else { | |
1096 sysname = "Windows"; | |
1097 } | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1098 |
12715
3dedbe04a684
[gaim-migrate @ 15059]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12658
diff
changeset
|
1099 return g_strdup_printf("Gaim/%s (%s; %ld.%ld)", VERSION, sysname, |
8675 | 1100 os_info.dwMajorVersion, os_info.dwMinorVersion); |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1101 |
8675 | 1102 #endif |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1103 |
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1104 |
8675 | 1105 } |
1106 | |
1107 static gboolean | |
1108 _is_disconnect_error(NMERR_T err) | |
1109 { | |
1110 return (err == NMERR_TCP_WRITE || | |
1111 err == NMERR_TCP_READ || err == NMERR_PROTOCOL); | |
1112 } | |
1113 | |
1114 static gboolean | |
1115 _check_for_disconnect(NMUser * user, NMERR_T err) | |
1116 { | |
1117 GaimConnection *gc = gaim_account_get_connection(user->client_data); | |
1118 | |
1119 if (_is_disconnect_error(err)) { | |
1120 | |
1121 gaim_connection_error(gc, _("Error communicating with server." | |
1122 " Closing connection.")); | |
1123 return TRUE; | |
1124 | |
1125 } | |
1126 | |
1127 return FALSE; | |
1128 } | |
1129 | |
1130 /* Check to see if the conference is instantiated, if so send the message. | |
1131 * If not send the create conference -- the response handler for the createconf | |
1132 * will call this function again. | |
1133 */ | |
1134 static void | |
1135 _send_message(NMUser * user, NMMessage * message) | |
1136 { | |
1137 NMConference *conf; | |
1138 NMERR_T rc = NM_OK; | |
1139 | |
1140 conf = nm_message_get_conference(message); | |
1141 if (conf) { | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1142 /* We have a conference make sure that the |
8675 | 1143 server knows about it already. */ |
1144 if (nm_conference_is_instantiated(conf)) { | |
1145 | |
1146 /* We have everything that we need...finally! */ | |
1147 rc = nm_send_message(user, message, _send_message_resp_cb); | |
1148 _check_for_disconnect(user, rc); | |
1149 | |
1150 nm_release_message(message); | |
1151 | |
1152 } else { | |
8933 | 1153 rc = nm_send_create_conference(user, conf, _createconf_resp_send_msg, message); |
8675 | 1154 _check_for_disconnect(user, rc); |
1155 } | |
1156 } | |
1157 } | |
1158 | |
11971 | 1159 /* |
1160 * Update the status of the given buddy in the Gaim buddy list | |
1161 */ | |
8675 | 1162 static void |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1163 _update_buddy_status(NMUser *user, GaimBuddy * buddy, int novellstatus, int gmt) |
8675 | 1164 { |
11971 | 1165 GaimAccount *account; |
1166 const char *status_id; | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1167 const char *text = NULL; |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1168 const char *dn; |
8675 | 1169 int idle = 0; |
9927 | 1170 gboolean loggedin = TRUE; |
8675 | 1171 |
11971 | 1172 account = buddy->account; |
1173 | |
1174 switch (novellstatus) { | |
8675 | 1175 case NM_STATUS_AVAILABLE: |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1176 status_id = NOVELL_STATUS_TYPE_AVAILABLE; |
8675 | 1177 break; |
1178 case NM_STATUS_AWAY: | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1179 status_id = NOVELL_STATUS_TYPE_AWAY; |
11971 | 1180 break; |
8675 | 1181 case NM_STATUS_BUSY: |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1182 status_id = NOVELL_STATUS_TYPE_BUSY; |
8675 | 1183 break; |
1184 case NM_STATUS_OFFLINE: | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1185 status_id = NOVELL_STATUS_TYPE_OFFLINE; |
9927 | 1186 loggedin = FALSE; |
8675 | 1187 break; |
1188 case NM_STATUS_AWAY_IDLE: | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1189 status_id = NOVELL_STATUS_TYPE_AWAY; |
8675 | 1190 idle = gmt; |
1191 break; | |
1192 default: | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1193 status_id = NOVELL_STATUS_TYPE_OFFLINE; |
9927 | 1194 loggedin = FALSE; |
8675 | 1195 break; |
1196 } | |
1197 | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1198 /* Get status text for the user */ |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1199 dn = nm_lookup_dn(user, buddy->name); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1200 if (dn) { |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1201 NMUserRecord *user_record = nm_find_user_record(user, dn); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1202 if (user_record) { |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1203 text = nm_user_record_get_status_text(user_record); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1204 } |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1205 } |
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 gaim_prpl_got_user_status(account, buddy->name, status_id, |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1208 "message", text, NULL); |
11971 | 1209 gaim_prpl_got_user_idle(account, buddy->name, |
1210 (novellstatus == NM_STATUS_AWAY_IDLE), idle); | |
8675 | 1211 } |
1212 | |
8933 | 1213 /* Iterate through the cached Gaim buddy list and remove buddies |
1214 * that are not in the server side list. | |
8675 | 1215 */ |
1216 static void | |
8933 | 1217 _remove_gaim_buddies(NMUser *user) |
8675 | 1218 { |
1219 GaimBlistNode *gnode; | |
1220 GaimBlistNode *cnode; | |
1221 GaimBlistNode *bnode; | |
1222 GaimGroup *group; | |
1223 GaimBuddy *buddy; | |
1224 GaimBuddyList *blist; | |
1225 GSList *rem_list = NULL; | |
1226 GSList *l; | |
8933 | 1227 NMFolder *folder = NULL; |
9651 | 1228 const char *gname = NULL; |
8675 | 1229 |
1230 if ((blist = gaim_get_blist())) { | |
1231 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
1232 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
1233 continue; | |
1234 group = (GaimGroup *) gnode; | |
1235 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
1236 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
1237 continue; | |
1238 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
1239 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
1240 continue; | |
1241 buddy = (GaimBuddy *) bnode; | |
1242 if (buddy->account == user->client_data) { | |
9651 | 1243 gname = group->name; |
1244 if (strcmp(group->name, NM_ROOT_FOLDER_NAME) == 0) | |
1245 gname = ""; | |
1246 folder = nm_find_folder(user, gname); | |
8933 | 1247 if (folder == NULL || |
1248 !nm_folder_find_contact_by_display_id(folder, buddy->name)) { | |
1249 rem_list = g_slist_append(rem_list, buddy); | |
1250 } | |
8675 | 1251 } |
1252 } | |
1253 } | |
1254 } | |
1255 | |
1256 if (rem_list) { | |
1257 for (l = rem_list; l; l = l->next) { | |
1258 gaim_blist_remove_buddy(l->data); | |
1259 } | |
1260 g_slist_free(rem_list); | |
1261 } | |
1262 } | |
1263 } | |
1264 | |
1265 /* Add all of the contacts in the given folder to the Gaim buddy list */ | |
1266 static void | |
1267 _add_contacts_to_gaim_blist(NMUser * user, NMFolder * folder) | |
1268 { | |
1269 NMUserRecord *user_record = NULL; | |
1270 NMContact *contact = NULL; | |
1271 GaimBuddy *buddy = NULL; | |
8782
5a2b5e4abf3a
[gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents:
8781
diff
changeset
|
1272 GaimGroup *group; |
8675 | 1273 NMERR_T cnt = 0, i; |
1274 const char *text = NULL; | |
1275 const char *name = NULL; | |
9651 | 1276 const char *fname = NULL; |
8675 | 1277 int status = 0; |
1278 | |
9651 | 1279 /* If this is the root folder give it a name. Gaim does not have the concept of |
1280 * a root folder. | |
1281 */ | |
1282 fname = nm_folder_get_name(folder); | |
1283 if (fname == NULL || *fname == '\0') { | |
1284 fname = NM_ROOT_FOLDER_NAME; | |
1285 } | |
1286 | |
8933 | 1287 /* Does the Gaim group exist already? */ |
9651 | 1288 group = gaim_find_group(fname); |
8933 | 1289 if (group == NULL) { |
9651 | 1290 group = gaim_group_new(fname); |
8933 | 1291 gaim_blist_add_group(group, NULL); |
1292 } | |
1293 | |
8675 | 1294 /* Get each contact for this folder */ |
1295 cnt = nm_folder_get_contact_count(folder); | |
1296 for (i = 0; i < cnt; i++) { | |
1297 contact = nm_folder_get_contact(folder, i); | |
1298 if (contact) { | |
1299 | |
1300 name = nm_contact_get_display_id(contact); | |
1301 if (name) { | |
8933 | 1302 |
1303 buddy = gaim_find_buddy_in_group(user->client_data, name, group); | |
1304 if (buddy == NULL) { | |
1305 /* Add it to the gaim buddy list */ | |
1306 buddy = gaim_buddy_new(user->client_data, | |
1307 name, | |
1308 nm_contact_get_display_name(contact)); | |
1309 | |
1310 gaim_blist_add_buddy(buddy, NULL, group, NULL); | |
8675 | 1311 } |
1312 | |
1313 /* Set the initial status for the buddy */ | |
1314 user_record = nm_contact_get_user_record(contact); | |
1315 if (user_record) { | |
1316 status = nm_user_record_get_status(user_record); | |
1317 text = nm_user_record_get_status_text(user_record); | |
1318 } | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1319 _update_buddy_status(user, buddy, status, time(0)); |
8675 | 1320 |
1321 /* Save the new buddy as part of the contact object */ | |
1322 nm_contact_set_data(contact, (gpointer) buddy); | |
1323 } | |
1324 | |
1325 } else { | |
1326 /* NULL contact. This should not happen, but | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1327 * let's break out of the loop. |
8675 | 1328 */ |
1329 break; | |
1330 } | |
1331 } | |
1332 } | |
1333 | |
1334 /* Add all of the server side contacts to the Gaim buddy list. */ | |
1335 static void | |
1336 _add_gaim_buddies(NMUser * user) | |
1337 { | |
9651 | 1338 int cnt = 0, i; |
8675 | 1339 NMFolder *root_folder = NULL; |
1340 NMFolder *folder = NULL; | |
1341 | |
1342 root_folder = nm_get_root_folder(user); | |
1343 if (root_folder) { | |
1344 | |
9651 | 1345 /* Add sub-folders and contacts to sub-folders... |
1346 * iterate throught the sub-folders in reverse order | |
1347 * because Gaim adds the folders to the front -- so we | |
1348 * want to add the first folder last | |
1349 */ | |
8675 | 1350 cnt = nm_folder_get_subfolder_count(root_folder); |
9651 | 1351 for (i = cnt-1; i >= 0; i--) { |
8675 | 1352 folder = nm_folder_get_subfolder(root_folder, i); |
1353 if (folder) { | |
1354 _add_contacts_to_gaim_blist(user, folder); | |
1355 } | |
1356 } | |
1357 | |
1358 /* Add contacts for the root folder */ | |
1359 _add_contacts_to_gaim_blist(user, root_folder); | |
1360 } | |
1361 } | |
1362 | |
8933 | 1363 static void |
1364 _sync_contact_list(NMUser *user) | |
1365 { | |
1366 /* Remove all buddies from the local list that are | |
1367 * not in the server side list and add all buddies | |
1368 * from the server side list that are not in | |
1369 * the local list | |
1370 */ | |
1371 _remove_gaim_buddies(user); | |
1372 _add_gaim_buddies(user); | |
9360 | 1373 user->clist_synched = TRUE; |
8933 | 1374 } |
1375 | |
1376 static void | |
1377 _sync_privacy_lists(NMUser *user) | |
1378 { | |
1379 GSList *node = NULL, *rem_list = NULL; | |
1380 GaimConnection *gc; | |
1381 const char *name, *dn; | |
1382 NMUserRecord *user_record; | |
1383 | |
1384 if (user == NULL) | |
1385 return; | |
1386 | |
1387 gc = gaim_account_get_connection(user->client_data); | |
1388 if (gc == NULL) | |
1389 return; | |
1390 | |
1391 /* Set the Gaim privacy setting */ | |
1392 if (user->default_deny) { | |
1393 if (user->allow_list == NULL) { | |
1394 gc->account->perm_deny = GAIM_PRIVACY_DENY_ALL; | |
1395 } else { | |
1396 gc->account->perm_deny = GAIM_PRIVACY_ALLOW_USERS; | |
1397 } | |
1398 } else { | |
1399 if (user->deny_list == NULL) { | |
1400 gc->account->perm_deny = GAIM_PRIVACY_ALLOW_ALL; | |
1401 } else { | |
1402 gc->account->perm_deny = GAIM_PRIVACY_DENY_USERS; | |
1403 } | |
1404 } | |
1405 | |
1406 /* Add stuff */ | |
1407 for (node = user->allow_list; node; node = node->next) { | |
1408 user_record = nm_find_user_record(user, (char *)node->data); | |
1409 if (user_record) | |
1410 name = nm_user_record_get_display_id(user_record); | |
1411 else | |
1412 name =(char *)node->data; | |
1413 | |
1414 if (!g_slist_find_custom(gc->account->permit, | |
1415 name, (GCompareFunc)nm_utf8_strcasecmp)) { | |
1416 gaim_privacy_permit_add(gc->account, name , TRUE); | |
1417 } | |
1418 } | |
1419 | |
1420 for (node = user->deny_list; node; node = node->next) { | |
1421 user_record = nm_find_user_record(user, (char *)node->data); | |
1422 if (user_record) | |
1423 name = nm_user_record_get_display_id(user_record); | |
1424 else | |
1425 name =(char *)node->data; | |
1426 | |
1427 if (!g_slist_find_custom(gc->account->deny, | |
1428 name, (GCompareFunc)nm_utf8_strcasecmp)) { | |
1429 gaim_privacy_deny_add(gc->account, name, TRUE); | |
1430 } | |
1431 } | |
1432 | |
1433 | |
1434 /* Remove stuff */ | |
1435 for (node = gc->account->permit; node; node = node->next) { | |
1436 dn = nm_lookup_dn(user, (char *)node->data); | |
1437 if (dn != NULL && | |
1438 !g_slist_find_custom(user->allow_list, | |
1439 dn, (GCompareFunc)nm_utf8_strcasecmp)) { | |
1440 rem_list = g_slist_append(rem_list, node->data); | |
1441 } | |
1442 } | |
1443 | |
1444 if (rem_list) { | |
1445 for (node = rem_list; node; node = node->next) { | |
1446 gaim_privacy_permit_remove(gc->account, (char *)node->data, TRUE); | |
1447 } | |
1448 g_free(rem_list); | |
1449 rem_list = NULL; | |
1450 } | |
1451 | |
1452 for (node = gc->account->deny; node; node = node->next) { | |
1453 dn = nm_lookup_dn(user, (char *)node->data); | |
1454 if (dn != NULL && | |
1455 !g_slist_find_custom(user->deny_list, | |
1456 dn, (GCompareFunc)nm_utf8_strcasecmp)) { | |
1457 rem_list = g_slist_append(rem_list, node->data); | |
1458 } | |
1459 } | |
1460 | |
1461 if (rem_list) { | |
1462 for (node = rem_list; node; node = node->next) { | |
1463 gaim_privacy_deny_remove(gc->account, (char *)node->data, TRUE); | |
1464 } | |
1465 g_slist_free(rem_list); | |
1466 } | |
1467 } | |
1468 | |
9820 | 1469 /* Map known property tags to user-friendly strings */ |
1470 static const char * | |
1471 _map_property_tag(const char *tag) | |
1472 { | |
1473 if (tag == NULL) return NULL; | |
1474 | |
1475 if (strcmp(tag, "telephoneNumber") == 0) | |
1476 return _("Telephone Number"); | |
1477 else if (strcmp(tag, "L") == 0) | |
1478 return _("Location"); | |
1479 else if (strcmp(tag, "OU") == 0) | |
1480 return _("Department"); | |
1481 else if (strcmp(tag, "personalTitle") == 0) | |
1482 return _("Personal Title"); | |
1483 else if (strcmp(tag, "Title") == 0) | |
1484 return _("Title"); | |
1485 else if (strcmp(tag, "mailstop") == 0) | |
1486 return _("Mailstop"); | |
1487 else if (strcmp(tag, "Internet EMail Address") == 0) | |
13545
cfc2f7fcb3dd
[gaim-migrate @ 15922]
Richard Laager <rlaager@wiktel.com>
parents:
13436
diff
changeset
|
1488 return _("E-Mail Address"); |
9820 | 1489 else |
1490 return tag; | |
1491 } | |
1492 | |
8675 | 1493 /* Display a dialog box showing the properties for the given user record */ |
1494 static void | |
1495 _show_info(GaimConnection * gc, NMUserRecord * user_record) | |
1496 { | |
1497 GString *info_text; | |
1498 int count, i; | |
1499 NMProperty *property; | |
1500 const char *tag, *value; | |
1501 | |
1502 info_text = g_string_new(""); | |
1503 | |
9820 | 1504 tag = _("User ID"); |
8675 | 1505 value = nm_user_record_get_userid(user_record); |
1506 if (value) { | |
9820 | 1507 g_string_append_printf(info_text, "<b>%s:</b> %s<br>", tag, value); |
8675 | 1508 } |
1509 | |
1510 /* tag = _("DN"); | |
1511 value = nm_user_record_get_dn(user_record); | |
1512 if (value) { | |
9820 | 1513 g_string_append_printf(info_text, "<b>%s:</b> %s<br>", |
8675 | 1514 tag, value); |
1515 } | |
1516 */ | |
1517 | |
1518 tag = _("Full name"); | |
1519 value = nm_user_record_get_full_name(user_record); | |
1520 if (value) { | |
9820 | 1521 g_string_append_printf(info_text, "<b>%s:</b> %s<br>", tag, value); |
8675 | 1522 } |
1523 | |
1524 count = nm_user_record_get_property_count(user_record); | |
1525 for (i = 0; i < count; i++) { | |
1526 property = nm_user_record_get_property(user_record, i); | |
1527 if (property) { | |
9820 | 1528 tag = _map_property_tag(nm_property_get_tag(property)); |
8675 | 1529 value = nm_property_get_value(property); |
1530 if (tag && value) { | |
9820 | 1531 g_string_append_printf(info_text, "<b>%s:</b> %s<br>", |
8675 | 1532 tag, value); |
1533 } | |
1534 nm_release_property(property); | |
1535 } | |
1536 } | |
1537 | |
11531
bf763a1b2454
[gaim-migrate @ 13780]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1538 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
|
1539 info_text->str, NULL, NULL); |
8675 | 1540 |
1541 g_string_free(info_text, TRUE); | |
1542 } | |
1543 | |
1544 /* Send a join conference, the first item in the parms list is the | |
1545 * NMUser object and the second item is the conference to join. | |
1546 * This callback is passed to gaim_request_action when we ask the | |
1547 * user if they want to join the conference. | |
1548 */ | |
1549 static void | |
1550 _join_conference_cb(GSList * parms) | |
1551 { | |
1552 NMUser *user; | |
1553 NMConference *conference; | |
1554 NMERR_T rc = NM_OK; | |
1555 | |
1556 if (parms == NULL || g_slist_length(parms) != 2) | |
1557 return; | |
1558 | |
1559 user = g_slist_nth_data(parms, 0); | |
1560 conference = g_slist_nth_data(parms, 1); | |
1561 | |
1562 if (user && conference) { | |
1563 rc = nm_send_join_conference(user, conference, | |
1564 _join_conf_resp_cb, conference); | |
1565 _check_for_disconnect(user, rc); | |
1566 } | |
1567 | |
1568 g_slist_free(parms); | |
1569 } | |
1570 | |
1571 /* Send a reject conference, the first item in the parms list is the | |
1572 * NMUser object and the second item is the conference to reject. | |
1573 * This callback is passed to gaim_request_action when we ask the | |
1574 * user if they want to joing the conference. | |
1575 */ | |
1576 static void | |
1577 _reject_conference_cb(GSList * parms) | |
1578 { | |
1579 NMUser *user; | |
1580 NMConference *conference; | |
1581 NMERR_T rc = NM_OK; | |
1582 | |
1583 if (parms == NULL || g_slist_length(parms) != 2) | |
1584 return; | |
1585 | |
1586 user = g_slist_nth_data(parms, 0); | |
1587 conference = g_slist_nth_data(parms, 1); | |
1588 | |
1589 if (user && conference) { | |
1590 rc = nm_send_reject_conference(user, conference, NULL, NULL); | |
1591 _check_for_disconnect(user, rc); | |
1592 } | |
1593 | |
1594 g_slist_free(parms); | |
1595 } | |
1596 | |
8933 | 1597 static void |
9030 | 1598 _initiate_conference_cb(GaimBlistNode *node, gpointer ignored) |
8933 | 1599 { |
9030 | 1600 GaimBuddy *buddy; |
1601 GaimConnection *gc; | |
1602 | |
8933 | 1603 NMUser *user; |
1604 const char *conf_name; | |
1605 GaimConversation *chat = NULL; | |
1606 NMUserRecord *user_record; | |
1607 NMConference *conference; | |
1608 | |
9030 | 1609 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
1610 | |
1611 buddy = (GaimBuddy *) node; | |
1612 gc = gaim_account_get_connection(buddy->account); | |
1613 | |
8933 | 1614 user = gc->proto_data; |
1615 if (user == NULL) | |
1616 return; | |
1617 | |
1618 /* We should already have a userrecord for the buddy */ | |
9030 | 1619 user_record = nm_find_user_record(user, buddy->name); |
8933 | 1620 if (user_record == NULL) |
1621 return; | |
1622 | |
1623 conf_name = _get_conference_name(++user->conference_count); | |
1624 chat = serv_got_joined_chat(gc, user->conference_count, conf_name); | |
1625 if (chat) { | |
1626 | |
1627 conference = nm_create_conference(NULL); | |
1628 nm_conference_set_data(conference, (gpointer) chat); | |
1629 nm_send_create_conference(user, conference, _createconf_resp_send_invite, user_record); | |
1630 nm_release_conference(conference); | |
1631 } | |
1632 } | |
1633 | |
1634 const char * | |
1635 _get_conference_name(int id) | |
1636 { | |
1637 static char *name = NULL; | |
1638 | |
1639 if (name) | |
1640 g_free(name); | |
1641 | |
1642 name = g_strdup_printf(_("GroupWise Conference %d"), id); | |
1643 | |
1644 return name; | |
1645 } | |
1646 | |
12408
3d297efa70bb
[gaim-migrate @ 14715]
Richard Laager <rlaager@wiktel.com>
parents:
12222
diff
changeset
|
1647 static void |
8933 | 1648 _show_privacy_locked_error(GaimConnection *gc, NMUser *user) |
1649 { | |
1650 char *err; | |
1651 | |
1652 err = g_strdup_printf(_("Unable to change server side privacy settings (%s)."), | |
1653 nm_error_to_string(NMERR_ADMIN_LOCKED)); | |
1654 gaim_notify_error(gc, NULL, err, NULL); | |
1655 g_free(err); | |
1656 } | |
1657 | |
8675 | 1658 /******************************************************************************* |
1659 * Connect and recv callbacks | |
1660 ******************************************************************************/ | |
1661 | |
1662 static void | |
1663 novell_ssl_connect_error(GaimSslConnection * gsc, | |
1664 GaimSslErrorType error, gpointer data) | |
1665 { | |
1666 gaim_connection_error((GaimConnection *)data, | |
1667 _("Unable to make SSL connection to server.")); | |
1668 } | |
1669 | |
1670 static void | |
1671 novell_ssl_recv_cb(gpointer data, GaimSslConnection * gsc, | |
1672 GaimInputCondition condition) | |
1673 { | |
1674 GaimConnection *gc = data; | |
1675 NMUser *user; | |
1676 NMERR_T rc; | |
1677 | |
1678 if (gc == NULL) | |
1679 return; | |
1680 | |
1681 user = gc->proto_data; | |
1682 if (user == NULL) | |
1683 return; | |
1684 | |
1685 rc = nm_process_new_data(user); | |
1686 if (rc != NM_OK) { | |
1687 | |
1688 if (_is_disconnect_error(rc)) { | |
8933 | 1689 |
8675 | 1690 gaim_connection_error(gc, |
1691 _("Error communicating with server." | |
1692 " Closing connection.")); | |
1693 } else { | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1694 gaim_debug(GAIM_DEBUG_INFO, "novell", |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1695 "Error processing event or response (%d).\n", rc); |
8675 | 1696 } |
1697 } | |
1698 } | |
1699 | |
1700 static void | |
1701 novell_ssl_connected_cb(gpointer data, GaimSslConnection * gsc, | |
1702 GaimInputCondition cond) | |
1703 { | |
1704 GaimConnection *gc = data; | |
1705 NMUser *user; | |
1706 NMConn *conn; | |
1707 NMERR_T rc = 0; | |
1708 const char *pwd = NULL; | |
1709 const char *my_addr = NULL; | |
1710 char *ua = NULL; | |
1711 | |
1712 if (gc == NULL || gsc == NULL) | |
1713 return; | |
1714 | |
1715 user = gc->proto_data; | |
1716 if ((user == NULL) || (conn = user->conn) == NULL) | |
1717 return; | |
1718 | |
1719 conn->ssl_conn = g_new0(NMSSLConn, 1); | |
1720 conn->ssl_conn->data = gsc; | |
1721 conn->ssl_conn->read = (nm_ssl_read_cb) gaim_ssl_read; | |
1722 conn->ssl_conn->write = (nm_ssl_write_cb) gaim_ssl_write; | |
1723 | |
1724 gaim_connection_update_progress(gc, _("Authenticating..."), | |
1725 2, NOVELL_CONNECT_STEPS); | |
1726 | |
8838 | 1727 my_addr = gaim_network_get_my_ip(gsc->fd); |
10740 | 1728 pwd = gaim_connection_get_password(gc); |
8675 | 1729 ua = _user_agent_string(); |
1730 | |
1731 rc = nm_send_login(user, pwd, my_addr, ua, _login_resp_cb, NULL); | |
1732 if (rc == NM_OK) { | |
1733 conn->connected = TRUE; | |
1734 gaim_ssl_input_add(gsc, novell_ssl_recv_cb, gc); | |
1735 } else { | |
1736 gaim_connection_error(gc, _("Unable to connect to server.")); | |
1737 } | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
1738 |
8675 | 1739 gaim_connection_update_progress(gc, _("Waiting for response..."), |
1740 3, NOVELL_CONNECT_STEPS); | |
1741 | |
1742 g_free(ua); | |
1743 } | |
1744 | |
1745 /******************************************************************************* | |
1746 * Event callback and event handlers | |
1747 ******************************************************************************/ | |
1748 | |
1749 static void | |
1750 _evt_receive_message(NMUser * user, NMEvent * event) | |
1751 { | |
1752 NMUserRecord *user_record = NULL; | |
1753 NMContact *contact = NULL; | |
1754 GaimConversation *gconv; | |
1755 NMConference *conference; | |
12216 | 1756 GaimMessageFlags flags; |
9268 | 1757 char *text = NULL; |
1758 | |
1759 text = g_markup_escape_text(nm_event_get_text(event), -1); | |
8675 | 1760 |
1761 conference = nm_event_get_conference(event); | |
1762 if (conference) { | |
1763 | |
1764 GaimConversation *chat = nm_conference_get_data(conference); | |
1765 | |
1766 /* Is this a single person 'conversation' or a conference? */ | |
1767 if (chat == NULL && nm_conference_get_participant_count(conference) == 1) { | |
1768 | |
1769 user_record = nm_find_user_record(user, nm_event_get_source(event)); | |
1770 if (user_record) { | |
1771 | |
12216 | 1772 flags = 0; |
8675 | 1773 if (nm_event_get_type(event) == NMEVT_RECEIVE_AUTOREPLY) |
12216 | 1774 flags |= GAIM_MESSAGE_AUTO_RESP; |
8675 | 1775 |
1776 serv_got_im(gaim_account_get_connection(user->client_data), | |
1777 nm_user_record_get_display_id(user_record), | |
12216 | 1778 text, flags, |
8675 | 1779 nm_event_get_gmt(event)); |
1780 | |
11338 | 1781 gconv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, |
8675 | 1782 nm_user_record_get_display_id(user_record), |
1783 (GaimAccount *) user->client_data); | |
1784 if (gconv) { | |
1785 | |
1786 contact = nm_find_contact(user, nm_event_get_source(event)); | |
1787 if (contact) { | |
1788 | |
1789 gaim_conversation_set_title( | |
9268 | 1790 gconv, nm_contact_get_display_name(contact)); |
8675 | 1791 |
1792 | |
1793 } else { | |
1794 | |
1795 const char *name = | |
1796 nm_user_record_get_full_name(user_record); | |
1797 | |
1798 if (name == NULL) | |
1799 name = nm_user_record_get_userid(user_record); | |
1800 | |
1801 gaim_conversation_set_title(gconv, name); | |
1802 } | |
1803 | |
1804 } | |
1805 | |
1806 } else { | |
1807 /* this should not happen, see the event code. | |
1808 * the event code will get the contact details from | |
1809 * the server if it does not have them before calling | |
1810 * the event callback. | |
1811 */ | |
1812 } | |
1813 | |
1814 } else if (chat) { | |
1815 | |
1816 /* get the contact for send if we have one */ | |
1817 NMContact *contact = nm_find_contact(user, | |
1818 nm_event_get_source(event)); | |
1819 | |
1820 /* get the user record for the sender */ | |
1821 user_record = nm_find_user_record(user, nm_event_get_source(event)); | |
1822 if (user_record) { | |
1823 const char *name = nm_contact_get_display_name(contact); | |
1824 | |
1825 if (name == NULL) { | |
1826 name = nm_user_record_get_full_name(user_record); | |
1827 if (name == NULL) | |
1828 name = nm_user_record_get_display_id(user_record); | |
1829 } | |
1830 | |
1831 serv_got_chat_in(gaim_account_get_connection(user->client_data), | |
1832 gaim_conv_chat_get_id(GAIM_CONV_CHAT(chat)), | |
9268 | 1833 name, 0, text, nm_event_get_gmt(event)); |
8675 | 1834 } |
1835 } | |
1836 } | |
9268 | 1837 |
1838 g_free(text); | |
8675 | 1839 } |
1840 | |
1841 static void | |
1842 _evt_conference_left(NMUser * user, NMEvent * event) | |
1843 { | |
1844 GaimConversation *chat; | |
1845 NMConference *conference; | |
1846 | |
1847 conference = nm_event_get_conference(event); | |
1848 if (conference) { | |
1849 chat = nm_conference_get_data(conference); | |
1850 if (chat) { | |
1851 NMUserRecord *ur = nm_find_user_record(user, | |
1852 nm_event_get_source(event)); | |
1853 | |
1854 if (ur) | |
1855 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(chat), | |
1856 nm_user_record_get_display_id(ur), | |
1857 NULL); | |
1858 } | |
1859 } | |
1860 } | |
1861 | |
1862 static void | |
8933 | 1863 _evt_conference_invite_notify(NMUser * user, NMEvent * event) |
1864 { | |
1865 GaimConversation *gconv; | |
1866 NMConference *conference; | |
1867 NMUserRecord *user_record = NULL; | |
1868 char *str = NULL; | |
1869 | |
1870 user_record = nm_find_user_record(user, nm_event_get_source(event)); | |
1871 conference = nm_event_get_conference(event); | |
1872 if (user_record && conference) { | |
1873 gconv = nm_conference_get_data(conference); | |
1874 str = g_strdup_printf(_("%s has been invited to this conversation."), | |
1875 nm_user_record_get_display_id(user_record)); | |
1876 gaim_conversation_write(gconv, NULL, str, | |
1877 GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1878 g_free(str); | |
1879 } | |
1880 } | |
1881 | |
1882 static void | |
8675 | 1883 _evt_conference_invite(NMUser * user, NMEvent * event) |
1884 { | |
1885 NMUserRecord *ur; | |
11246 | 1886 GaimConnection *gc; |
8675 | 1887 GSList *parms = NULL; |
1888 const char *title = NULL; | |
1889 const char *secondary = NULL; | |
1890 const char *name = NULL; | |
1891 char *primary = NULL; | |
1892 time_t gmt; | |
1893 | |
1894 ur = nm_find_user_record(user, nm_event_get_source(event)); | |
1895 if (ur) | |
1896 name = nm_user_record_get_full_name(ur); | |
1897 | |
1898 if (name == NULL) | |
1899 name = nm_event_get_source(event); | |
1900 | |
1901 gmt = nm_event_get_gmt(event); | |
1902 title = _("Invitation to Conversation"); | |
1903 primary = g_strdup_printf(_("Invitation from: %s\n\nSent: %s"), | |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
1904 name, gaim_date_format_full(localtime(&gmt))); |
8675 | 1905 secondary = _("Would you like to join the conversation?"); |
1906 | |
1907 /* Set up parms list for the callbacks | |
1908 * We need to send the NMUser object and | |
1909 * the NMConference object to the callbacks | |
1910 */ | |
1911 parms = NULL; | |
1912 parms = g_slist_append(parms, user); | |
1913 parms = g_slist_append(parms, nm_event_get_conference(event)); | |
1914 | |
1915 /* Prompt the user */ | |
11246 | 1916 gc = gaim_account_get_connection(user->client_data); |
1917 gaim_request_action(gc, title, primary, secondary, | |
10116 | 1918 GAIM_DEFAULT_ACTION_NONE, parms, 2, |
8675 | 1919 _("Yes"), G_CALLBACK(_join_conference_cb), |
1920 _("No"), G_CALLBACK(_reject_conference_cb)); | |
1921 | |
1922 g_free(primary); | |
1923 } | |
1924 | |
1925 | |
1926 static void | |
1927 _evt_conference_joined(NMUser * user, NMEvent * event) | |
1928 { | |
1929 GaimConversation *chat = NULL; | |
1930 GaimConnection *gc; | |
1931 NMConference *conference = NULL; | |
1932 NMUserRecord *ur = NULL; | |
1933 const char *name; | |
8933 | 1934 const char *conf_name; |
8675 | 1935 |
1936 gc = gaim_account_get_connection(user->client_data); | |
1937 if (gc == NULL) | |
1938 return; | |
1939 | |
1940 conference = nm_event_get_conference(event); | |
1941 if (conference) { | |
1942 chat = nm_conference_get_data(conference); | |
1943 if (nm_conference_get_participant_count(conference) == 2 && chat == NULL) { | |
1944 ur = nm_conference_get_participant(conference, 0); | |
1945 if (ur) { | |
8933 | 1946 conf_name = _get_conference_name(++user->conference_count); |
8675 | 1947 chat = |
1948 serv_got_joined_chat(gc, user->conference_count, conf_name); | |
1949 if (chat) { | |
1950 | |
1951 nm_conference_set_data(conference, (gpointer) chat); | |
1952 | |
1953 name = nm_user_record_get_display_id(ur); | |
9846 | 1954 gaim_conv_chat_add_user(GAIM_CONV_CHAT(chat), name, NULL, |
1955 GAIM_CBFLAGS_NONE, TRUE); | |
8675 | 1956 |
1957 } | |
1958 } | |
1959 } | |
1960 | |
1961 if (chat != NULL) { | |
1962 ur = nm_find_user_record(user, nm_event_get_source(event)); | |
1963 if (ur) { | |
1964 name = nm_user_record_get_display_id(ur); | |
9554 | 1965 if (!gaim_conv_chat_find_user(GAIM_CONV_CHAT(chat), name)) { |
9846 | 1966 gaim_conv_chat_add_user(GAIM_CONV_CHAT(chat), name, NULL, |
1967 GAIM_CBFLAGS_NONE, TRUE); | |
8933 | 1968 } |
8675 | 1969 } |
1970 } | |
1971 } | |
1972 } | |
1973 | |
1974 static void | |
1975 _evt_status_change(NMUser * user, NMEvent * event) | |
1976 { | |
1977 GaimBuddy *buddy = NULL; | |
1978 GSList *buddies; | |
1979 GSList *bnode; | |
1980 NMUserRecord *user_record; | |
1981 const char *display_id; | |
1982 int status; | |
1983 | |
1984 user_record = nm_event_get_user_record(event); | |
1985 if (user_record) { | |
1986 | |
1987 /* Retrieve new status */ | |
1988 status = nm_user_record_get_status(user_record); | |
1989 | |
1990 /* Update status for buddy in all folders */ | |
1991 display_id = nm_user_record_get_display_id(user_record); | |
1992 buddies = gaim_find_buddies(user->client_data, display_id); | |
1993 for (bnode = buddies; bnode; bnode = bnode->next) { | |
1994 buddy = (GaimBuddy *) bnode->data; | |
1995 if (buddy) { | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
1996 _update_buddy_status(user, buddy, status, nm_event_get_gmt(event)); |
8675 | 1997 } |
1998 } | |
1999 | |
2000 g_slist_free(buddies); | |
2001 | |
2002 } | |
2003 } | |
2004 | |
2005 static void | |
2006 _evt_user_disconnect(NMUser * user, NMEvent * event) | |
2007 { | |
2008 GaimConnection *gc; | |
2009 | |
2010 gc = gaim_account_get_connection((GaimAccount *) user->client_data); | |
2011 if (gc) | |
2012 gaim_connection_error(gc, _("You have been logged out because you" | |
2013 " logged in at another workstation.")); | |
2014 } | |
2015 | |
2016 static void | |
2017 _evt_user_typing(NMUser * user, NMEvent * event) | |
2018 { | |
2019 GaimConnection *gc; | |
2020 NMUserRecord *user_record = NULL; | |
2021 | |
2022 gc = gaim_account_get_connection((GaimAccount *) user->client_data); | |
2023 if (gc) { | |
2024 user_record = nm_find_user_record(user, nm_event_get_source(event)); | |
2025 if (user_record) { | |
2026 serv_got_typing(gc, nm_user_record_get_display_id(user_record), | |
2027 30, GAIM_TYPING); | |
2028 } | |
2029 } | |
2030 } | |
2031 | |
2032 static void | |
2033 _evt_user_not_typing(NMUser * user, NMEvent * event) | |
2034 { | |
2035 GaimConnection *gc; | |
2036 NMUserRecord *user_record; | |
2037 | |
2038 gc = gaim_account_get_connection((GaimAccount *) user->client_data); | |
2039 if (gc) { | |
2040 user_record = nm_find_user_record(user, nm_event_get_source(event)); | |
2041 if (user_record) { | |
2042 serv_got_typing_stopped(gc, | |
2043 nm_user_record_get_display_id(user_record)); | |
2044 } | |
2045 } | |
2046 } | |
2047 | |
2048 static void | |
2049 _evt_undeliverable_status(NMUser * user, NMEvent * event) | |
2050 { | |
2051 NMUserRecord *ur; | |
2052 GaimConversation *gconv; | |
2053 char *str; | |
2054 | |
2055 ur = nm_find_user_record(user, nm_event_get_source(event)); | |
2056 if (ur) { | |
11338 | 2057 /* XXX - Should this be GAIM_CONV_TYPE_IM? */ |
8675 | 2058 gconv = |
11338 | 2059 gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, |
10246 | 2060 nm_user_record_get_display_id(ur), |
8675 | 2061 user->client_data); |
2062 if (gconv) { | |
2063 const char *name = nm_user_record_get_full_name(ur); | |
2064 | |
2065 if (name == NULL) { | |
2066 name = nm_user_record_get_display_id(ur); | |
2067 } | |
2068 str = g_strdup_printf(_("%s appears to be offline and did not receive" | |
2069 " the message that you just sent."), name); | |
2070 gaim_conversation_write(gconv, NULL, str, | |
2071 GAIM_MESSAGE_SYSTEM, time(NULL)); | |
2072 g_free(str); | |
2073 } | |
2074 } | |
2075 } | |
2076 | |
2077 static void | |
2078 _event_callback(NMUser * user, NMEvent * event) | |
2079 { | |
2080 if (user == NULL || event == NULL) | |
2081 return; | |
2082 | |
2083 switch (nm_event_get_type(event)) { | |
2084 case NMEVT_STATUS_CHANGE: | |
2085 _evt_status_change(user, event); | |
2086 break; | |
2087 case NMEVT_RECEIVE_AUTOREPLY: | |
2088 case NMEVT_RECEIVE_MESSAGE: | |
2089 _evt_receive_message(user, event); | |
2090 break; | |
2091 case NMEVT_USER_DISCONNECT: | |
2092 _evt_user_disconnect(user, event); | |
2093 break; | |
2094 case NMEVT_USER_TYPING: | |
2095 _evt_user_typing(user, event); | |
2096 break; | |
2097 case NMEVT_USER_NOT_TYPING: | |
2098 _evt_user_not_typing(user, event); | |
2099 break; | |
2100 case NMEVT_SERVER_DISCONNECT: | |
2101 /* Nothing to do? */ | |
2102 break; | |
2103 case NMEVT_INVALID_RECIPIENT: | |
2104 break; | |
2105 case NMEVT_UNDELIVERABLE_STATUS: | |
2106 _evt_undeliverable_status(user, event); | |
2107 break; | |
2108 case NMEVT_CONFERENCE_INVITE_NOTIFY: | |
2109 /* Someone else has been invited to join a | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2110 * conference that we are currently a part of |
8675 | 2111 */ |
8933 | 2112 _evt_conference_invite_notify(user, event); |
8675 | 2113 break; |
2114 case NMEVT_CONFERENCE_INVITE: | |
2115 /* We have been invited to join a conference */ | |
2116 _evt_conference_invite(user, event); | |
2117 break; | |
2118 case NMEVT_CONFERENCE_JOINED: | |
2119 /* Some one has joined a conference that we | |
2120 * are a part of | |
2121 */ | |
2122 _evt_conference_joined(user, event); | |
2123 break; | |
2124 case NMEVT_CONFERENCE_LEFT: | |
2125 /* Someone else has left a conference that we | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2126 * are currently a part of |
8675 | 2127 */ |
2128 _evt_conference_left(user, event); | |
2129 break; | |
2130 default: | |
2131 gaim_debug(GAIM_DEBUG_INFO, "novell", | |
2132 "_event_callback(): unhandled event, %d\n", | |
2133 nm_event_get_type(event)); | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2134 break; |
8675 | 2135 } |
2136 } | |
2137 | |
2138 /******************************************************************************* | |
2139 * Prpl Ops | |
2140 ******************************************************************************/ | |
2141 | |
2142 static void | |
11837 | 2143 novell_login(GaimAccount * account) |
8675 | 2144 { |
2145 GaimConnection *gc; | |
2146 NMUser *user = NULL; | |
2147 const char *server; | |
2148 const char *name; | |
2149 int port; | |
2150 | |
2151 if (account == NULL) | |
2152 return; | |
2153 | |
2154 gc = gaim_account_get_connection(account); | |
2155 if (gc == NULL) | |
2156 return; | |
2157 | |
2158 server = gaim_account_get_string(account, "server", NULL); | |
2159 if (server == NULL || *server == '\0') { | |
2160 | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2161 /* TODO: Would be nice to prompt if not set! |
8675 | 2162 * gaim_request_fields(gc, _("Server Address"),...); |
2163 */ | |
2164 | |
2165 /* ...but for now just error out with a nice message. */ | |
2166 gaim_connection_error(gc, _("Unable to connect to server." | |
2167 " Please enter the address of the server" | |
2168 " you wish to connect to.")); | |
2169 return; | |
2170 } | |
2171 | |
2172 port = gaim_account_get_int(account, "port", DEFAULT_PORT); | |
2173 name = gaim_account_get_username(account); | |
2174 | |
2175 user = nm_initialize_user(name, server, port, account, _event_callback); | |
2176 if (user) { | |
2177 /* save user */ | |
2178 gc->proto_data = user; | |
2179 | |
2180 /* connect to the server */ | |
2181 gaim_connection_update_progress(gc, _("Connecting"), | |
2182 1, NOVELL_CONNECT_STEPS); | |
2183 | |
2184 user->conn->use_ssl = TRUE; | |
2185 if (gaim_ssl_connect(user->client_data, user->conn->addr, | |
2186 user->conn->port, novell_ssl_connected_cb, | |
2187 novell_ssl_connect_error, gc) == NULL) { | |
2188 gaim_connection_error(gc, _("Error." | |
2189 " SSL support is not installed.")); | |
2190 } | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2191 } |
8675 | 2192 } |
2193 | |
2194 static void | |
2195 novell_close(GaimConnection * gc) | |
2196 { | |
2197 NMUser *user; | |
2198 NMConn *conn; | |
2199 | |
2200 if (gc == NULL) | |
2201 return; | |
2202 | |
2203 user = gc->proto_data; | |
2204 if (user) { | |
2205 conn = user->conn; | |
9651 | 2206 if (conn && conn->ssl_conn) { |
2207 gaim_ssl_close(user->conn->ssl_conn->data); | |
8675 | 2208 } |
2209 nm_deinitialize_user(user); | |
2210 } | |
2211 gc->proto_data = NULL; | |
2212 } | |
2213 | |
2214 static int | |
2215 novell_send_im(GaimConnection * gc, const char *name, | |
12216 | 2216 const char *message_body, GaimMessageFlags flags) |
8675 | 2217 { |
2218 NMUserRecord *user_record = NULL; | |
2219 NMConference *conf = NULL; | |
2220 NMMessage *message; | |
2221 NMUser *user; | |
2222 const char *dn = NULL; | |
12216 | 2223 char *plain; |
8675 | 2224 gboolean done = TRUE, created_conf = FALSE; |
2225 NMERR_T rc = NM_OK; | |
2226 | |
2227 if (gc == NULL || name == NULL || | |
2228 message_body == NULL || *message_body == '\0') | |
2229 return 0; | |
2230 | |
2231 user = gc->proto_data; | |
2232 if (user == NULL) | |
2233 return 0; | |
2234 | |
2235 /* Create a new message */ | |
12216 | 2236 plain = gaim_unescape_html(message_body); |
2237 message = nm_create_message(plain); | |
2238 g_free(plain); | |
8675 | 2239 |
2240 /* Need to get the DN for the buddy so we can look up the convo */ | |
2241 dn = nm_lookup_dn(user, name); | |
2242 | |
2243 /* Do we already know about the sender? */ | |
2244 user_record = nm_find_user_record(user, dn); | |
2245 if (user_record) { | |
2246 | |
2247 /* Do we already have an instantiated conference? */ | |
2248 conf = nm_find_conversation(user, dn); | |
2249 if (conf == NULL) { | |
2250 | |
2251 /* If not, create a blank conference */ | |
2252 conf = nm_create_conference(NULL); | |
2253 created_conf = TRUE; | |
2254 | |
2255 nm_conference_add_participant(conf, user_record); | |
2256 } | |
2257 | |
2258 nm_message_set_conference(message, conf); | |
2259 | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2260 /* Make sure conference is instantiated */ |
8675 | 2261 if (!nm_conference_is_instantiated(conf)) { |
2262 | |
2263 /* It is not, so send the createconf. We will | |
2264 * have to finish sending the message when we | |
2265 * get the response with the new conference guid. | |
2266 */ | |
8933 | 2267 rc = nm_send_create_conference(user, conf, _createconf_resp_send_msg, message); |
8675 | 2268 _check_for_disconnect(user, rc); |
2269 | |
2270 done = FALSE; | |
2271 } | |
2272 | |
2273 } else { | |
2274 | |
2275 /* If we don't have details for the user, then we don't have | |
2276 * a conference yet. So create one and send the getdetails | |
2277 * to the server. We will have to finish sending the message | |
2278 * when we get the response from the server. | |
2279 */ | |
2280 conf = nm_create_conference(NULL); | |
2281 created_conf = TRUE; | |
2282 | |
2283 nm_message_set_conference(message, conf); | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2284 |
8675 | 2285 rc = nm_send_get_details(user, name, _get_details_resp_send_msg, message); |
2286 _check_for_disconnect(user, rc); | |
2287 | |
2288 done = FALSE; | |
2289 } | |
2290 | |
2291 if (done) { | |
2292 | |
2293 /* Did we find everything we needed? */ | |
2294 rc = nm_send_message(user, message, _send_message_resp_cb); | |
2295 _check_for_disconnect(user, rc); | |
2296 | |
2297 nm_release_message(message); | |
2298 } | |
2299 | |
2300 if (created_conf && conf) | |
2301 nm_release_conference(conf); | |
2302 | |
2303 return 1; | |
2304 } | |
2305 | |
13842 | 2306 static unsigned int |
2307 novell_send_typing(GaimConnection * gc, const char *name, GaimTypingState state) | |
8675 | 2308 { |
2309 NMConference *conf = NULL; | |
2310 NMUser *user; | |
2311 const char *dn = NULL; | |
2312 NMERR_T rc = NM_OK; | |
2313 | |
2314 if (gc == NULL || name == NULL) | |
13842 | 2315 return 0; |
8675 | 2316 |
2317 user = gc->proto_data; | |
2318 if (user == NULL) | |
13842 | 2319 return 0; |
8675 | 2320 |
2321 /* Need to get the DN for the buddy so we can look up the convo */ | |
2322 dn = nm_lookup_dn(user, name); | |
2323 if (dn) { | |
2324 | |
2325 /* Now find the conference in our list */ | |
2326 conf = nm_find_conversation(user, dn); | |
2327 if (conf) { | |
2328 | |
2329 rc = nm_send_typing(user, conf, | |
13842 | 2330 ((state == GAIM_TYPING) ? TRUE : FALSE), NULL); |
8675 | 2331 _check_for_disconnect(user, rc); |
2332 | |
2333 } | |
2334 | |
2335 } | |
2336 | |
2337 return 0; | |
2338 } | |
2339 | |
2340 static void | |
2341 novell_convo_closed(GaimConnection * gc, const char *who) | |
2342 { | |
2343 NMUser *user; | |
2344 NMConference *conf; | |
2345 const char *dn; | |
2346 NMERR_T rc = NM_OK; | |
2347 | |
2348 if (gc == NULL || who == NULL) | |
2349 return; | |
2350 | |
2351 user = gc->proto_data; | |
2352 if (user && (dn = nm_lookup_dn(user, who))) { | |
2353 conf = nm_find_conversation(user, dn); | |
2354 if (conf) { | |
2355 rc = nm_send_leave_conference(user, conf, NULL, NULL); | |
2356 _check_for_disconnect(user, rc); | |
2357 } | |
2358 } | |
2359 } | |
2360 | |
2361 static void | |
2362 novell_chat_leave(GaimConnection * gc, int id) | |
2363 { | |
2364 NMConference *conference; | |
2365 NMUser *user; | |
2366 GaimConversation *chat; | |
2367 GSList *cnode; | |
2368 NMERR_T rc = NM_OK; | |
2369 | |
2370 if (gc == NULL) | |
2371 return; | |
2372 | |
2373 user = gc->proto_data; | |
2374 if (user == NULL) | |
2375 return; | |
2376 | |
2377 for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) { | |
2378 conference = cnode->data; | |
2379 if (conference && (chat = nm_conference_get_data(conference))) { | |
2380 if (gaim_conv_chat_get_id(GAIM_CONV_CHAT(chat)) == id) { | |
2381 rc = nm_send_leave_conference(user, conference, NULL, NULL); | |
2382 _check_for_disconnect(user, rc); | |
2383 break; | |
2384 } | |
2385 } | |
2386 } | |
2387 | |
2388 serv_got_chat_left(gc, id); | |
2389 } | |
2390 | |
12408
3d297efa70bb
[gaim-migrate @ 14715]
Richard Laager <rlaager@wiktel.com>
parents:
12222
diff
changeset
|
2391 static void |
8933 | 2392 novell_chat_invite(GaimConnection *gc, int id, |
2393 const char *message, const char *who) | |
2394 { | |
2395 NMConference *conference; | |
2396 NMUser *user; | |
2397 GaimConversation *chat; | |
2398 GSList *cnode; | |
2399 NMERR_T rc = NM_OK; | |
2400 NMUserRecord *user_record = NULL; | |
2401 | |
2402 if (gc == NULL) | |
2403 return; | |
2404 | |
2405 user = gc->proto_data; | |
2406 if (user == NULL) | |
2407 return; | |
2408 | |
2409 user_record = nm_find_user_record(user, who); | |
2410 if (user_record == NULL) { | |
10112 | 2411 rc = nm_send_get_details(user, who, _get_details_resp_send_invite, GINT_TO_POINTER(id)); |
8933 | 2412 _check_for_disconnect(user, rc); |
2413 return; | |
2414 } | |
2415 | |
2416 for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) { | |
2417 conference = cnode->data; | |
2418 if (conference && (chat = nm_conference_get_data(conference))) { | |
2419 if (gaim_conv_chat_get_id(GAIM_CONV_CHAT(chat)) == id) { | |
2420 rc = nm_send_conference_invite(user, conference, user_record, | |
2421 message, _sendinvite_resp_cb, NULL); | |
2422 _check_for_disconnect(user, rc); | |
2423 break; | |
2424 } | |
2425 } | |
2426 } | |
2427 } | |
2428 | |
8675 | 2429 static int |
12216 | 2430 novell_chat_send(GaimConnection * gc, int id, const char *text, GaimMessageFlags flags) |
8675 | 2431 { |
2432 NMConference *conference; | |
2433 GaimConversation *chat; | |
2434 GSList *cnode; | |
2435 NMMessage *message; | |
2436 NMUser *user; | |
2437 NMERR_T rc = NM_OK; | |
2438 const char *name; | |
12216 | 2439 char *str, *plain; |
8675 | 2440 |
2441 if (gc == NULL || text == NULL) | |
2442 return -1; | |
2443 | |
2444 user = gc->proto_data; | |
2445 if (user == NULL) | |
2446 return -1; | |
2447 | |
12216 | 2448 plain = gaim_unescape_html(text); |
2449 message = nm_create_message(plain); | |
2450 g_free(plain); | |
8675 | 2451 |
2452 for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) { | |
2453 conference = cnode->data; | |
2454 if (conference && (chat = nm_conference_get_data(conference))) { | |
2455 if (gaim_conv_chat_get_id(GAIM_CONV_CHAT(chat)) == id) { | |
2456 | |
2457 nm_message_set_conference(message, conference); | |
2458 | |
8933 | 2459 /* check to see if the conference is instatiated yet */ |
2460 if (!nm_conference_is_instantiated(conference)) { | |
2461 nm_message_add_ref(message); | |
2462 nm_send_create_conference(user, conference, _createconf_resp_send_msg, message); | |
2463 } else { | |
2464 rc = nm_send_message(user, message, _send_message_resp_cb); | |
2465 } | |
2466 | |
8675 | 2467 nm_release_message(message); |
2468 | |
2469 if (!_check_for_disconnect(user, rc)) { | |
2470 | |
2471 /* Use the account alias if it is set */ | |
2472 name = gaim_account_get_alias(user->client_data); | |
2473 if (name == NULL || *name == '\0') { | |
2474 | |
2475 /* If there is no account alias, try full name */ | |
2476 name = nm_user_record_get_full_name(user->user_record); | |
2477 if (name == NULL || *name == '\0') { | |
2478 | |
2479 /* Fall back to the username that we are signed in with */ | |
2480 name = gaim_account_get_username(user->client_data); | |
2481 } | |
2482 } | |
2483 | |
2484 serv_got_chat_in(gc, id, name, 0, text, time(NULL)); | |
2485 return 0; | |
2486 } else | |
2487 return -1; | |
2488 | |
2489 } | |
2490 } | |
2491 } | |
2492 | |
8933 | 2493 |
8675 | 2494 /* The conference was not found, must be closed */ |
2495 chat = gaim_find_chat(gc, id); | |
2496 if (chat) { | |
2497 str = g_strdup_printf(_("This conference has been closed." | |
2498 " No more messages can be sent.")); | |
2499 gaim_conversation_write(chat, NULL, str, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
2500 g_free(str); | |
2501 } | |
2502 | |
8744 | 2503 if (message) |
2504 nm_release_message(message); | |
2505 | |
8675 | 2506 return -1; |
2507 } | |
2508 | |
2509 static void | |
9285 | 2510 novell_add_buddy(GaimConnection * gc, GaimBuddy *buddy, GaimGroup * group) |
8675 | 2511 { |
2512 NMFolder *folder = NULL; | |
2513 NMContact *contact; | |
2514 NMUser *user; | |
2515 NMERR_T rc = NM_OK; | |
9651 | 2516 const char *alias, *gname; |
9285 | 2517 |
2518 if (gc == NULL || buddy == NULL || group == NULL) | |
8675 | 2519 return; |
2520 | |
2521 user = (NMUser *) gc->proto_data; | |
2522 if (user == NULL) | |
2523 return; | |
2524 | |
9360 | 2525 /* If we haven't synched the contact list yet, ignore |
2526 * the add_buddy calls. Server side list is the master. | |
2527 */ | |
2528 if (!user->clist_synched) | |
2529 return; | |
2530 | |
8675 | 2531 contact = nm_create_contact(); |
9285 | 2532 nm_contact_set_dn(contact, buddy->name); |
8675 | 2533 |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8676
diff
changeset
|
2534 /* Remove the GaimBuddy (we will add it back after adding it |
8675 | 2535 * to the server side list). Save the alias if there is one. |
2536 */ | |
9620 | 2537 alias = gaim_buddy_get_alias(buddy); |
9285 | 2538 if (alias && strcmp(alias, buddy->name)) |
2539 nm_contact_set_display_name(contact, alias); | |
2540 | |
2541 gaim_blist_remove_buddy(buddy); | |
2542 buddy = NULL; | |
8675 | 2543 |
9651 | 2544 if (strcmp(group->name, NM_ROOT_FOLDER_NAME) == 0) { |
2545 gname = ""; | |
2546 } else { | |
2547 gname = group->name; | |
2548 } | |
2549 | |
2550 folder = nm_find_folder(user, gname); | |
8675 | 2551 if (folder) { |
2552 | |
2553 /* We have everything that we need, so send the createcontact */ | |
2554 rc = nm_send_create_contact(user, folder, contact, | |
2555 _create_contact_resp_cb, contact); | |
2556 | |
2557 } else { | |
2558 | |
2559 /* Need to create the folder before we can add the contact */ | |
9651 | 2560 rc = nm_send_create_folder(user, gname, |
8675 | 2561 _create_folder_resp_add_contact, contact); |
2562 } | |
2563 | |
2564 _check_for_disconnect(user, rc); | |
2565 | |
2566 } | |
2567 | |
2568 static void | |
9360 | 2569 novell_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
8675 | 2570 { |
2571 NMContact *contact; | |
2572 NMFolder *folder; | |
2573 NMUser *user; | |
9651 | 2574 const char *dn, *gname; |
8675 | 2575 NMERR_T rc = NM_OK; |
2576 | |
9285 | 2577 if (gc == NULL || buddy == NULL || group == NULL) |
8675 | 2578 return; |
2579 | |
2580 user = (NMUser *) gc->proto_data; | |
9285 | 2581 if (user && (dn = nm_lookup_dn(user, buddy->name))) { |
9651 | 2582 if (strcmp(group->name, NM_ROOT_FOLDER_NAME) == 0) { |
2583 gname = ""; | |
2584 } else { | |
2585 gname = group->name; | |
2586 } | |
2587 folder = nm_find_folder(user, gname); | |
8675 | 2588 if (folder) { |
2589 contact = nm_folder_find_contact(folder, dn); | |
2590 if (contact) { | |
2591 | |
2592 /* Remove the buddy from the contact */ | |
2593 nm_contact_set_data(contact, NULL); | |
2594 | |
2595 /* Tell the server to remove the contact */ | |
2596 rc = nm_send_remove_contact(user, folder, contact, | |
2597 _remove_contact_resp_cb, NULL); | |
2598 _check_for_disconnect(user, rc); | |
2599 } | |
2600 } | |
2601 } | |
2602 } | |
2603 | |
2604 static void | |
9285 | 2605 novell_remove_group(GaimConnection * gc, GaimGroup *group) |
8675 | 2606 { |
2607 NMUser *user; | |
2608 NMERR_T rc = NM_OK; | |
2609 | |
9285 | 2610 if (gc == NULL || group == NULL) |
8675 | 2611 return; |
2612 | |
2613 user = (NMUser *) gc->proto_data; | |
2614 if (user) { | |
9285 | 2615 NMFolder *folder = nm_find_folder(user, group->name); |
8675 | 2616 |
2617 if (folder) { | |
2618 rc = nm_send_remove_folder(user, folder, | |
2619 _remove_folder_resp_cb, NULL); | |
2620 _check_for_disconnect(user, rc); | |
2621 } | |
2622 } | |
2623 } | |
2624 | |
2625 static void | |
2626 novell_alias_buddy(GaimConnection * gc, const char *name, const char *alias) | |
2627 { | |
2628 NMContact *contact; | |
2629 NMUser *user; | |
2630 GList *contacts = NULL; | |
2631 GList *cnode = NULL; | |
9651 | 2632 const char *dn = NULL, *fname = NULL; |
8675 | 2633 NMERR_T rc = NM_OK; |
2634 | |
2635 if (gc == NULL || name == NULL || alias == NULL) | |
2636 return; | |
2637 | |
2638 user = (NMUser *) gc->proto_data; | |
2639 if (user && (dn = nm_lookup_dn(user, name))) { | |
2640 | |
2641 /* Alias all of instances of the contact */ | |
2642 contacts = nm_find_contacts(user, dn); | |
2643 for (cnode = contacts; cnode != NULL; cnode = cnode->next) { | |
2644 contact = (NMContact *) cnode->data; | |
2645 if (contact) { | |
9651 | 2646 GaimGroup *group = NULL; |
8675 | 2647 GaimBuddy *buddy; |
2648 NMFolder *folder; | |
2649 | |
2650 /* Alias the Gaim buddy? */ | |
2651 folder = nm_find_folder_by_id(user, | |
2652 nm_contact_get_parent_id(contact)); | |
9651 | 2653 if (folder) { |
2654 fname = nm_folder_get_name(folder); | |
2655 if (*fname == '\0') { | |
2656 fname = NM_ROOT_FOLDER_NAME; | |
2657 } | |
2658 group = gaim_find_group(fname); | |
2659 } | |
2660 | |
2661 if (group) { | |
8675 | 2662 buddy = gaim_find_buddy_in_group(user->client_data, |
2663 name, group); | |
2664 if (buddy && strcmp(buddy->alias, alias)) | |
2665 gaim_blist_alias_buddy(buddy, alias); | |
2666 } | |
9651 | 2667 |
8675 | 2668 /* Tell the server to alias the contact */ |
2669 rc = nm_send_rename_contact(user, contact, alias, | |
2670 _rename_contact_resp_cb, NULL); | |
2671 _check_for_disconnect(user, rc); | |
2672 } | |
2673 } | |
2674 if (contacts) | |
2675 g_list_free(contacts); | |
2676 } | |
2677 } | |
2678 | |
2679 static void | |
2680 novell_group_buddy(GaimConnection * gc, | |
2681 const char *name, const char *old_group_name, | |
2682 const char *new_group_name) | |
2683 { | |
2684 NMFolder *old_folder; | |
2685 NMFolder *new_folder; | |
2686 NMContact *contact; | |
2687 NMUser *user; | |
2688 const char *dn; | |
2689 NMERR_T rc = NM_OK; | |
2690 | |
2691 if (gc == NULL || name == NULL || | |
2692 old_group_name == NULL || new_group_name == NULL) | |
2693 return; | |
2694 | |
2695 user = (NMUser *) gc->proto_data; | |
2696 if (user && (dn = nm_lookup_dn(user, name))) { | |
2697 | |
2698 /* Find the old folder */ | |
9651 | 2699 if (strcmp(old_group_name, NM_ROOT_FOLDER_NAME) == 0) { |
2700 old_folder = nm_get_root_folder(user); | |
2701 if (nm_folder_find_contact(old_folder, dn) == NULL) | |
2702 old_folder = nm_find_folder(user, old_group_name); | |
2703 } else { | |
2704 old_folder = nm_find_folder(user, old_group_name); | |
2705 } | |
2706 | |
8675 | 2707 if (old_folder && (contact = nm_folder_find_contact(old_folder, dn))) { |
2708 | |
2709 /* Find the new folder */ | |
2710 new_folder = nm_find_folder(user, new_group_name); | |
9651 | 2711 if (new_folder == NULL) { |
2712 if (strcmp(new_group_name, NM_ROOT_FOLDER_NAME) == 0) | |
2713 new_folder = nm_get_root_folder(user); | |
2714 } | |
2715 | |
8675 | 2716 if (new_folder) { |
2717 | |
2718 /* Tell the server to move the contact to the new folder */ | |
2719 rc = nm_send_move_contact(user, contact, new_folder, | |
2720 _move_contact_resp_cb, NULL); | |
2721 | |
2722 } else { | |
2723 | |
2724 nm_contact_add_ref(contact); | |
2725 | |
2726 /* Remove the old contact first */ | |
2727 nm_send_remove_contact(user, old_folder, contact, | |
2728 _remove_contact_resp_cb, NULL); | |
2729 | |
2730 /* New folder does not exist yet, so create it */ | |
2731 rc = nm_send_create_folder(user, new_group_name, | |
2732 _create_folder_resp_move_contact, | |
2733 contact); | |
2734 } | |
2735 | |
2736 _check_for_disconnect(user, rc); | |
2737 } | |
2738 } | |
2739 } | |
2740 | |
2741 static void | |
2742 novell_rename_group(GaimConnection * gc, const char *old_name, | |
9285 | 2743 GaimGroup *group, GList *moved_buddies) |
8675 | 2744 { |
2745 NMERR_T rc = NM_OK; | |
8782
5a2b5e4abf3a
[gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents:
8781
diff
changeset
|
2746 NMFolder *folder; |
8675 | 2747 NMUser *user; |
2748 | |
9285 | 2749 if (gc == NULL || old_name == NULL || group == NULL || moved_buddies == NULL) { |
8675 | 2750 return; |
2751 } | |
2752 | |
2753 user = gc->proto_data; | |
2754 if (user) { | |
2755 /* Does new folder exist already? */ | |
9285 | 2756 if (nm_find_folder(user, group->name)) { |
9651 | 2757 /* gaim_blist_rename_group() adds the buddies |
2758 * to the new group and removes the old group... | |
2759 * so there is nothing more to do here. | |
8675 | 2760 */ |
2761 return; | |
2762 } | |
2763 | |
9651 | 2764 if (strcmp(old_name, NM_ROOT_FOLDER_NAME) == 0) { |
2765 /* Can't rename the root folder ... need to revisit this */ | |
2766 return; | |
2767 } | |
2768 | |
8782
5a2b5e4abf3a
[gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents:
8781
diff
changeset
|
2769 folder = nm_find_folder(user, old_name); |
8675 | 2770 if (folder) { |
9285 | 2771 rc = nm_send_rename_folder(user, folder, group->name, |
8675 | 2772 _rename_folder_resp_cb, NULL); |
2773 _check_for_disconnect(user, rc); | |
2774 } | |
2775 } | |
2776 } | |
2777 | |
2778 static void | |
9972 | 2779 novell_list_emblems(GaimBuddy * buddy, const char **se, const char **sw, const char **nw, const char **ne) |
8675 | 2780 { |
11536 | 2781 NMUserRecord *user_record = NULL; |
2782 GaimConnection *gc; | |
2783 NMUser *user; | |
2784 int status = 0; | |
2785 | |
2786 gc = gaim_account_get_connection(buddy->account); | |
2787 | |
2788 if (gc == NULL || (user = gc->proto_data) == NULL) | |
2789 return; | |
2790 | |
2791 user_record = nm_find_user_record(user, buddy->name); | |
2792 | |
2793 if (user_record) | |
2794 status = nm_user_record_get_status(user_record); | |
8675 | 2795 |
2796 switch (status) { | |
2797 case NM_STATUS_AVAILABLE: | |
2798 *se = ""; | |
2799 break; | |
2800 case NM_STATUS_AWAY: | |
2801 *se = "away"; | |
2802 break; | |
2803 case NM_STATUS_BUSY: | |
2804 *se = "occupied"; | |
2805 break; | |
2806 case NM_STATUS_UNKNOWN: | |
2807 *se = "error"; | |
2808 break; | |
2809 } | |
2810 } | |
2811 | |
2812 static const char * | |
2813 novell_list_icon(GaimAccount * account, GaimBuddy * buddy) | |
2814 { | |
2815 return "novell"; | |
2816 } | |
2817 | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2818 static void |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2819 novell_tooltip_text(GaimBuddy * buddy, GString * str, gboolean full) |
8675 | 2820 { |
2821 NMUserRecord *user_record = NULL; | |
2822 GaimConnection *gc; | |
2823 NMUser *user; | |
2824 int status = 0; | |
2825 const char *status_str = NULL; | |
2826 const char *text = NULL; | |
2827 | |
2828 if (buddy == NULL) | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2829 return; |
8675 | 2830 |
2831 gc = gaim_account_get_connection(buddy->account); | |
2832 if (gc == NULL || (user = gc->proto_data) == NULL) | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2833 return; |
8675 | 2834 |
2835 if (GAIM_BUDDY_IS_ONLINE(buddy)) { | |
2836 user_record = nm_find_user_record(user, buddy->name); | |
2837 if (user_record) { | |
2838 status = nm_user_record_get_status(user_record); | |
2839 text = nm_user_record_get_status_text(user_record); | |
2840 /* No custom text, so default it ... */ | |
2841 switch (status) { | |
2842 case NM_STATUS_AVAILABLE: | |
2843 status_str = _("Available"); | |
2844 break; | |
2845 case NM_STATUS_AWAY: | |
2846 status_str = _("Away"); | |
2847 break; | |
2848 case NM_STATUS_BUSY: | |
2849 status_str = _("Busy"); | |
2850 break; | |
2851 case NM_STATUS_AWAY_IDLE: | |
2852 status_str = _("Idle"); | |
2853 break; | |
2854 case NM_STATUS_OFFLINE: | |
2855 status_str = _("Offline"); | |
2856 break; | |
2857 default: | |
2858 status_str = _("Unknown"); | |
2859 break; | |
2860 } | |
2861 | |
2862 if (text) | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2863 g_string_append_printf(str, "\n<b>%s:</b> %s" |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2864 "\n<b>%s:</b> %s", |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2865 _("Status"), status_str, |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2866 _("Message"), text); |
8675 | 2867 else |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2868 g_string_append_printf(str, "\n<b>%s:</b> %s", |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2869 _("Status"), status_str); |
8675 | 2870 } |
2871 } | |
2872 } | |
2873 | |
2874 static void | |
2875 novell_set_idle(GaimConnection * gc, int time) | |
2876 { | |
2877 NMUser *user; | |
2878 NMERR_T rc = NM_OK; | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2879 const char *id = NULL; |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2880 GaimStatus *status = NULL; |
8675 | 2881 |
2882 if (gc == NULL) | |
2883 return; | |
2884 | |
2885 user = gc->proto_data; | |
2886 if (user == NULL) | |
2887 return; | |
2888 | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2889 status = gaim_account_get_active_status(gaim_connection_get_account(gc)); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2890 id = gaim_status_get_id(status); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2891 |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2892 /* Only go idle if active status is available */ |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2893 if (!strcmp(id, NOVELL_STATUS_TYPE_AVAILABLE)) { |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2894 if (time > 0) { |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2895 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
|
2896 } else { |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2897 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
|
2898 } |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2899 } |
8675 | 2900 |
2901 _check_for_disconnect(user, rc); | |
2902 } | |
2903 | |
2904 static void | |
2905 novell_get_info(GaimConnection * gc, const char *name) | |
2906 { | |
2907 NMUserRecord *user_record; | |
2908 NMUser *user; | |
2909 NMERR_T rc; | |
2910 | |
2911 if (gc == NULL || name == NULL) | |
2912 return; | |
2913 | |
2914 user = (NMUser *) gc->proto_data; | |
2915 if (user) { | |
2916 | |
2917 user_record = nm_find_user_record(user, name); | |
2918 if (user_record) { | |
2919 | |
2920 _show_info(gc, user_record); | |
2921 | |
2922 } else { | |
2923 | |
2924 rc = nm_send_get_details(user, name, | |
2925 _get_details_resp_show_info, g_strdup(name)); | |
2926 | |
2927 _check_for_disconnect(user, rc); | |
2928 | |
2929 } | |
2930 | |
2931 } | |
2932 } | |
2933 | |
2934 static char * | |
2935 novell_status_text(GaimBuddy * buddy) | |
2936 { | |
2937 const char *text = NULL; | |
2938 const char *dn = NULL; | |
2939 | |
2940 if (buddy && buddy->account) { | |
2941 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
2942 | |
2943 if (gc && gc->proto_data) { | |
2944 NMUser *user = gc->proto_data; | |
2945 | |
2946 dn = nm_lookup_dn(user, buddy->name); | |
2947 if (dn) { | |
2948 NMUserRecord *user_record = nm_find_user_record(user, dn); | |
2949 | |
2950 if (user_record) { | |
2951 text = nm_user_record_get_status_text(user_record); | |
2952 if (text) | |
2953 return g_strdup(text); | |
2954 } | |
2955 } | |
2956 } | |
2957 } | |
2958 | |
2959 return NULL; | |
2960 } | |
10762 | 2961 |
8675 | 2962 static GList * |
10762 | 2963 novell_status_types(GaimAccount *account) |
8675 | 2964 { |
10762 | 2965 GList *status_types = NULL; |
2966 GaimStatusType *type; | |
2967 | |
2968 g_return_val_if_fail(account != NULL, NULL); | |
2969 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2970 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
|
2971 NULL, TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2972 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2973 NULL); |
10762 | 2974 status_types = g_list_append(status_types, type); |
2975 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2976 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
|
2977 NULL, TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2978 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2979 NULL); |
10762 | 2980 status_types = g_list_append(status_types, type); |
2981 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2982 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
|
2983 _("Busy"), TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2984 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
2985 NULL); |
11971 | 2986 status_types = g_list_append(status_types, type); |
2987 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
2988 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
|
2989 NULL, TRUE, TRUE, FALSE); |
10762 | 2990 status_types = g_list_append(status_types, type); |
2991 | |
12658 | 2992 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, NULL, NULL, FALSE, TRUE, FALSE); |
2993 status_types = g_list_append(status_types, type); | |
2994 | |
10762 | 2995 return status_types; |
8675 | 2996 } |
2997 | |
2998 static void | |
10762 | 2999 novell_set_status(GaimAccount *account, GaimStatus *status) |
3000 { | |
11971 | 3001 GaimConnection *gc; |
10762 | 3002 gboolean connected; |
11972 | 3003 GaimPresence *presence; |
10762 | 3004 GaimStatusType *type; |
11971 | 3005 GaimStatusPrimitive primitive; |
3006 NMUser *user; | |
3007 NMSTATUS_T novellstatus = NM_STATUS_AVAILABLE; | |
3008 NMERR_T rc = NM_OK; | |
3009 const char *msg = NULL; | |
3010 char *text = NULL; | |
10762 | 3011 |
3012 connected = gaim_account_is_connected(account); | |
11972 | 3013 presence = gaim_status_get_presence(status); |
10762 | 3014 type = gaim_status_get_type(status); |
3015 primitive = gaim_status_type_get_primitive(type); | |
3016 | |
3017 /* | |
3018 * We don't have any independent statuses, so we don't need to | |
3019 * do anything when a status is deactivated (because another | |
3020 * status is about to be activated). | |
3021 */ | |
3022 if (!gaim_status_is_active(status)) | |
3023 return; | |
3024 | |
11718 | 3025 if (!connected) |
3026 return; | |
3027 | |
11971 | 3028 gc = gaim_account_get_connection(account); |
8675 | 3029 user = gc->proto_data; |
3030 if (user == NULL) | |
3031 return; | |
3032 | |
11971 | 3033 if (primitive == GAIM_STATUS_AVAILABLE) { |
3034 novellstatus = NM_STATUS_AVAILABLE; | |
3035 } else if (primitive == GAIM_STATUS_AWAY) { | |
3036 novellstatus = NM_STATUS_AWAY; | |
3037 } else if (primitive == GAIM_STATUS_UNAVAILABLE) { | |
3038 novellstatus = NM_STATUS_BUSY; | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12408
diff
changeset
|
3039 } else if (primitive == GAIM_STATUS_INVISIBLE) { |
11971 | 3040 novellstatus = NM_STATUS_OFFLINE; |
11972 | 3041 } else if (gaim_presence_is_idle(presence)) { |
11971 | 3042 novellstatus = NM_STATUS_AWAY_IDLE; |
8675 | 3043 } else { |
11971 | 3044 novellstatus = NM_STATUS_AVAILABLE; |
8675 | 3045 } |
3046 | |
12222
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3047 if (primitive == GAIM_STATUS_AWAY || primitive == GAIM_STATUS_AVAILABLE || |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3048 primitive == GAIM_STATUS_UNAVAILABLE) { |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3049 msg = gaim_status_get_attr_string(status, "message"); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3050 text = g_strdup(msg); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3051 |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3052 if (primitive == GAIM_STATUS_AVAILABLE) |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3053 msg = NULL; /* no auto replies for online status */ |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3054 |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3055 /* Don't want newlines in status text */ |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3056 gaim_util_chrreplace(text, '\n', ' '); |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3057 } |
b1d06ade0e10
[gaim-migrate @ 14524]
Luke Schierer <lschiere@pidgin.im>
parents:
12216
diff
changeset
|
3058 |
11971 | 3059 rc = nm_send_set_status(user, novellstatus, text, msg, NULL, NULL); |
8675 | 3060 _check_for_disconnect(user, rc); |
3061 | |
3062 if (text) | |
3063 g_free(text); | |
3064 } | |
10762 | 3065 |
8933 | 3066 static void |
3067 novell_add_permit(GaimConnection *gc, const char *who) | |
3068 { | |
3069 NMUser *user; | |
3070 NMERR_T rc = NM_OK; | |
3071 const char *name = who; | |
3072 | |
3073 if (gc == NULL || who == NULL) | |
3074 return; | |
3075 | |
3076 user = gc->proto_data; | |
3077 if (user == NULL) | |
3078 return; | |
3079 | |
3080 /* Remove first -- we will add it back in when we get | |
3081 * the okay from the server | |
3082 */ | |
3083 gaim_privacy_permit_remove(gc->account, who, TRUE); | |
3084 | |
3085 if (nm_user_is_privacy_locked(user)) { | |
3086 _show_privacy_locked_error(gc, user); | |
3087 _sync_privacy_lists(user); | |
3088 return; | |
3089 } | |
3090 | |
3091 /* Work around for problem with un-typed, dotted contexts */ | |
3092 if (strchr(who, '.')) { | |
3093 const char *dn = nm_lookup_dn(user, who); | |
3094 if (dn == NULL) { | |
3095 rc = nm_send_get_details(user, who, _get_details_send_privacy_create, | |
3096 (gpointer)TRUE); | |
3097 _check_for_disconnect(user, rc); | |
3098 return; | |
3099 } else { | |
3100 name = dn; | |
3101 } | |
3102 } | |
3103 | |
3104 rc = nm_send_create_privacy_item(user, name, TRUE, | |
3105 _create_privacy_item_permit_resp_cb, | |
3106 g_strdup(who)); | |
3107 _check_for_disconnect(user, rc); | |
3108 } | |
3109 | |
3110 static void | |
3111 novell_add_deny(GaimConnection *gc, const char *who) | |
3112 { | |
3113 NMUser *user; | |
3114 NMERR_T rc = NM_OK; | |
3115 const char *name = who; | |
3116 | |
3117 if (gc == NULL || who == NULL) | |
3118 return; | |
3119 | |
3120 user = gc->proto_data; | |
3121 if (user == NULL) | |
3122 return; | |
3123 | |
3124 /* Remove first -- we will add it back in when we get | |
3125 * the okay from the server | |
3126 */ | |
3127 gaim_privacy_deny_remove(gc->account, who, TRUE); | |
3128 | |
3129 if (nm_user_is_privacy_locked(user)) { | |
3130 _show_privacy_locked_error(gc, user); | |
3131 _sync_privacy_lists(user); | |
3132 return; | |
3133 } | |
3134 | |
3135 /* Work around for problem with un-typed, dotted contexts */ | |
3136 if (strchr(who, '.')) { | |
3137 const char *dn = nm_lookup_dn(user, who); | |
3138 if (dn == NULL) { | |
3139 rc = nm_send_get_details(user, who, _get_details_send_privacy_create, | |
3140 (gpointer)FALSE); | |
3141 _check_for_disconnect(user, rc); | |
3142 return; | |
3143 } else { | |
3144 name = dn; | |
3145 } | |
3146 } | |
3147 | |
3148 rc = nm_send_create_privacy_item(user, name, FALSE, | |
3149 _create_privacy_item_deny_resp_cb, | |
3150 g_strdup(who)); | |
3151 _check_for_disconnect(user, rc); | |
3152 } | |
3153 | |
3154 static void | |
3155 novell_rem_permit(GaimConnection *gc, const char *who) | |
3156 { | |
3157 NMUser *user; | |
3158 NMERR_T rc = NM_OK; | |
3159 const char *dn = NULL; | |
3160 | |
3161 if (gc == NULL || who == NULL) | |
3162 return; | |
3163 | |
3164 user = gc->proto_data; | |
3165 if (user == NULL) | |
3166 return; | |
3167 | |
3168 if (nm_user_is_privacy_locked(user)) { | |
3169 _show_privacy_locked_error(gc, user); | |
3170 _sync_privacy_lists(user); | |
3171 return; | |
3172 } | |
3173 | |
3174 dn = nm_lookup_dn(user, who); | |
3175 if (dn == NULL) | |
3176 dn = who; | |
3177 | |
3178 rc = nm_send_remove_privacy_item(user, dn, TRUE, | |
3179 _remove_privacy_item_resp_cb, | |
3180 g_strdup(who)); | |
3181 _check_for_disconnect(user, rc); | |
3182 } | |
3183 | |
3184 static void | |
3185 novell_rem_deny(GaimConnection *gc, const char *who) | |
3186 { | |
3187 NMUser *user; | |
3188 NMERR_T rc = NM_OK; | |
3189 const char *dn = NULL; | |
3190 | |
3191 if (gc == NULL || who == NULL) | |
3192 return; | |
3193 | |
3194 user = gc->proto_data; | |
3195 if (user == NULL) | |
3196 return; | |
3197 | |
3198 if (nm_user_is_privacy_locked(user)) { | |
3199 _show_privacy_locked_error(gc, user); | |
3200 _sync_privacy_lists(user); | |
3201 return; | |
3202 } | |
3203 | |
3204 dn = nm_lookup_dn(user, who); | |
3205 if (dn == NULL) | |
3206 dn = who; | |
3207 | |
3208 rc = nm_send_remove_privacy_item(user, dn, FALSE, | |
3209 _remove_privacy_item_resp_cb, | |
3210 g_strdup(who)); | |
3211 _check_for_disconnect(user, rc); | |
3212 } | |
3213 | |
3214 static void | |
3215 novell_set_permit_deny(GaimConnection *gc) | |
3216 { | |
3217 NMERR_T rc = NM_OK; | |
3218 const char *dn, *name = NULL; | |
3219 NMUserRecord *user_record = NULL; | |
3220 GSList *node = NULL, *copy = NULL; | |
3221 NMUser *user; | |
3222 int i, j, num_contacts, num_folders; | |
3223 NMContact *contact; | |
3224 NMFolder *folder = NULL; | |
3225 | |
3226 if (gc == NULL) | |
3227 return; | |
3228 | |
3229 user = gc->proto_data; | |
3230 if (user == NULL) | |
3231 return; | |
3232 | |
9268 | 3233 if (user->privacy_synched == FALSE) { |
3234 _sync_privacy_lists(user); | |
3235 user->privacy_synched = TRUE; | |
8933 | 3236 return; |
3237 } | |
3238 | |
3239 if (nm_user_is_privacy_locked(user)) { | |
3240 _show_privacy_locked_error(gc, user); | |
3241 _sync_privacy_lists(user); | |
3242 return; | |
3243 } | |
3244 | |
3245 switch (gc->account->perm_deny) { | |
3246 | |
3247 case GAIM_PRIVACY_ALLOW_ALL: | |
3248 rc = nm_send_set_privacy_default(user, FALSE, | |
3249 _set_privacy_default_resp_cb, NULL); | |
3250 _check_for_disconnect(user, rc); | |
3251 | |
3252 /* clear server side deny list */ | |
3253 if (rc == NM_OK) { | |
3254 copy = g_slist_copy(user->deny_list); | |
3255 for (node = copy; node && node->data; node = node->next) { | |
3256 rc = nm_send_remove_privacy_item(user, (const char *)node->data, | |
3257 FALSE, NULL, NULL); | |
3258 if (_check_for_disconnect(user, rc)) | |
3259 break; | |
3260 } | |
3261 g_slist_free(copy); | |
3262 g_slist_free(user->deny_list); | |
3263 user->deny_list = NULL; | |
3264 } | |
3265 break; | |
3266 | |
3267 case GAIM_PRIVACY_DENY_ALL: | |
3268 rc = nm_send_set_privacy_default(user, TRUE, | |
3269 _set_privacy_default_resp_cb, NULL); | |
3270 _check_for_disconnect(user, rc); | |
3271 | |
3272 /* clear server side allow list */ | |
3273 if (rc == NM_OK) { | |
3274 copy = g_slist_copy(user->allow_list); | |
3275 for (node = copy; node && node->data; node = node->next) { | |
3276 rc = nm_send_remove_privacy_item(user, (const char *)node->data, | |
3277 TRUE, NULL, NULL); | |
3278 if (_check_for_disconnect(user, rc)) | |
3279 break; | |
3280 } | |
3281 g_slist_free(copy); | |
3282 g_slist_free(user->allow_list); | |
3283 user->allow_list = NULL; | |
3284 } | |
3285 break; | |
3286 | |
3287 case GAIM_PRIVACY_ALLOW_USERS: | |
3288 | |
3289 rc = nm_send_set_privacy_default(user, TRUE, | |
3290 _set_privacy_default_resp_cb, NULL); | |
3291 _check_for_disconnect(user, rc); | |
3292 | |
3293 /* sync allow lists */ | |
3294 if (rc == NM_OK) { | |
3295 | |
3296 for (node = user->allow_list; node; node = node->next) { | |
3297 user_record = nm_find_user_record(user, (char *)node->data); | |
3298 if (user_record) { | |
3299 name = nm_user_record_get_display_id(user_record); | |
3300 | |
3301 if (!g_slist_find_custom(gc->account->permit, | |
3302 name, (GCompareFunc)nm_utf8_strcasecmp)) { | |
3303 gaim_privacy_permit_add(gc->account, name , TRUE); | |
3304 } | |
3305 } | |
3306 } | |
3307 | |
3308 for (node = gc->account->permit; node; node = node->next) { | |
3309 name = NULL; | |
3310 dn = nm_lookup_dn(user, (char *)node->data); | |
3311 if (dn) { | |
3312 user_record = nm_find_user_record(user, dn); | |
3313 name = nm_user_record_get_display_id(user_record); | |
3314 | |
3315 if (!g_slist_find_custom(user->allow_list, | |
3316 dn, (GCompareFunc)nm_utf8_strcasecmp)) { | |
3317 rc = nm_send_create_privacy_item(user, dn, TRUE, | |
3318 _create_privacy_item_deny_resp_cb, | |
3319 g_strdup(dn)); | |
3320 } | |
3321 } else { | |
3322 gaim_privacy_permit_remove(gc->account, (char *)node->data, TRUE); | |
3323 } | |
3324 } | |
3325 } | |
3326 break; | |
3327 | |
3328 case GAIM_PRIVACY_DENY_USERS: | |
3329 | |
3330 /* set to default allow */ | |
3331 rc = nm_send_set_privacy_default(user, FALSE, | |
3332 _set_privacy_default_resp_cb, NULL); | |
3333 _check_for_disconnect(user, rc); | |
3334 | |
3335 /* sync deny lists */ | |
3336 if (rc == NM_OK) { | |
3337 | |
3338 for (node = user->deny_list; node; node = node->next) { | |
3339 user_record = nm_find_user_record(user, (char *)node->data); | |
3340 if (user_record) { | |
3341 name = nm_user_record_get_display_id(user_record); | |
3342 | |
3343 if (!g_slist_find_custom(gc->account->deny, | |
3344 name, (GCompareFunc)nm_utf8_strcasecmp)) { | |
3345 gaim_privacy_deny_add(gc->account, name , TRUE); | |
3346 } | |
3347 } | |
3348 } | |
3349 | |
3350 for (node = gc->account->deny; node; node = node->next) { | |
3351 | |
3352 name = NULL; | |
3353 dn = nm_lookup_dn(user, (char *)node->data); | |
3354 if (dn) { | |
3355 user_record = nm_find_user_record(user, dn); | |
3356 name = nm_user_record_get_display_id(user_record); | |
3357 | |
3358 if (!g_slist_find_custom(user->deny_list, | |
3359 dn, (GCompareFunc)nm_utf8_strcasecmp)) { | |
3360 rc = nm_send_create_privacy_item(user, dn, FALSE, | |
3361 _create_privacy_item_deny_resp_cb, | |
3362 g_strdup(name)); | |
3363 } | |
3364 } else { | |
3365 gaim_privacy_deny_remove(gc->account, (char *)node->data, TRUE); | |
3366 } | |
3367 } | |
3368 | |
3369 } | |
3370 break; | |
3371 | |
3372 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
3373 | |
3374 /* remove users from allow list that are not in buddy list */ | |
3375 copy = g_slist_copy(user->allow_list); | |
3376 for (node = copy; node && node->data; node = node->next) { | |
3377 if (!nm_find_contacts(user, node->data)) { | |
3378 rc = nm_send_remove_privacy_item(user, (const char *)node->data, | |
3379 TRUE, NULL, NULL); | |
3380 if (_check_for_disconnect(user, rc)) | |
3381 return; | |
3382 } | |
3383 } | |
3384 g_slist_free(copy); | |
3385 | |
3386 /* add all buddies to allow list */ | |
3387 num_contacts = nm_folder_get_contact_count(user->root_folder); | |
3388 for (i = 0; i < num_contacts; i++) { | |
3389 contact = nm_folder_get_contact(user->root_folder, i); | |
3390 dn = nm_contact_get_dn(contact); | |
3391 if (dn && !g_slist_find_custom(user->allow_list, | |
3392 dn, (GCompareFunc)nm_utf8_strcasecmp)) | |
3393 { | |
3394 rc = nm_send_create_privacy_item(user, dn, TRUE, | |
3395 _create_privacy_item_deny_resp_cb, | |
3396 g_strdup(dn)); | |
3397 if (_check_for_disconnect(user, rc)) | |
3398 return; | |
3399 } | |
3400 | |
3401 } | |
3402 | |
3403 num_folders = nm_folder_get_subfolder_count(user->root_folder); | |
3404 for (i = 0; i < num_folders; i++) { | |
3405 folder = nm_folder_get_subfolder(user->root_folder, i); | |
3406 num_contacts = nm_folder_get_contact_count(folder); | |
3407 for (j = 0; j < num_contacts; j++) { | |
3408 contact = nm_folder_get_contact(folder, j); | |
3409 dn = nm_contact_get_dn(contact); | |
3410 if (dn && !g_slist_find_custom(user->allow_list, | |
3411 dn, (GCompareFunc)nm_utf8_strcasecmp)) | |
3412 { | |
3413 rc = nm_send_create_privacy_item(user, dn, TRUE, | |
3414 _create_privacy_item_deny_resp_cb, | |
3415 g_strdup(dn)); | |
3416 if (_check_for_disconnect(user, rc)) | |
3417 return; | |
3418 } | |
3419 } | |
3420 } | |
3421 | |
3422 /* set to default deny */ | |
3423 rc = nm_send_set_privacy_default(user, TRUE, | |
3424 _set_privacy_default_resp_cb, NULL); | |
3425 if (_check_for_disconnect(user, rc)) | |
3426 break; | |
3427 | |
3428 break; | |
3429 } | |
3430 } | |
3431 | |
3432 static GList * | |
9030 | 3433 novell_blist_node_menu(GaimBlistNode *node) |
8933 | 3434 { |
3435 GList *list = NULL; | |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12715
diff
changeset
|
3436 GaimMenuAction *act; |
9030 | 3437 |
3438 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12715
diff
changeset
|
3439 act = gaim_menu_action_new(_("Initiate _Chat"), |
13020
72300c551dc2
[gaim-migrate @ 15373]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12978
diff
changeset
|
3440 GAIM_CALLBACK(_initiate_conference_cb), |
72300c551dc2
[gaim-migrate @ 15373]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12978
diff
changeset
|
3441 NULL, NULL); |
9030 | 3442 list = g_list_append(list, act); |
3443 } | |
8933 | 3444 |
3445 return list; | |
3446 } | |
3447 | |
9268 | 3448 static void |
3449 novell_keepalive(GaimConnection *gc) | |
3450 { | |
3451 NMUser *user; | |
3452 NMERR_T rc = NM_OK; | |
3453 | |
3454 if (gc == NULL) | |
3455 return; | |
3456 | |
3457 user = gc->proto_data; | |
3458 if (user == NULL) | |
3459 return; | |
3460 | |
3461 rc = nm_send_keepalive(user, NULL, NULL); | |
3462 _check_for_disconnect(user, rc); | |
3463 } | |
3464 | |
8675 | 3465 static GaimPluginProtocolInfo prpl_info = { |
3466 0, | |
9475 | 3467 NULL, /* user_splits */ |
3468 NULL, /* protocol_options */ | |
3469 NO_BUDDY_ICONS, /* icon_spec */ | |
3470 novell_list_icon, /* list_icon */ | |
3471 novell_list_emblems, /* list_emblems */ | |
3472 novell_status_text, /* status_text */ | |
3473 novell_tooltip_text, /* tooltip_text */ | |
10762 | 3474 novell_status_types, /* status_types */ |
9475 | 3475 novell_blist_node_menu, /* blist_node_menu */ |
8675 | 3476 NULL, /* chat_info */ |
9754 | 3477 NULL, /* chat_info_defaults */ |
9475 | 3478 novell_login, /* login */ |
3479 novell_close, /* close */ | |
3480 novell_send_im, /* send_im */ | |
8675 | 3481 NULL, /* set_info */ |
9475 | 3482 novell_send_typing, /* send_typing */ |
3483 novell_get_info, /* get_info */ | |
10762 | 3484 novell_set_status, /* set_status */ |
9475 | 3485 novell_set_idle, /* set_idle */ |
3486 NULL, /* change_passwd */ | |
3487 novell_add_buddy, /* add_buddy */ | |
8675 | 3488 NULL, /* add_buddies */ |
9475 | 3489 novell_remove_buddy, /* remove_buddy */ |
8675 | 3490 NULL, /* remove_buddies */ |
9475 | 3491 novell_add_permit, /* add_permit */ |
3492 novell_add_deny, /* add_deny */ | |
3493 novell_rem_permit, /* rem_permit */ | |
3494 novell_rem_deny, /* rem_deny */ | |
3495 novell_set_permit_deny, /* set_permit_deny */ | |
8675 | 3496 NULL, /* join_chat */ |
9268 | 3497 NULL, /* reject_chat */ |
9917 | 3498 NULL, /* get_chat_name */ |
8933 | 3499 novell_chat_invite, /* chat_invite */ |
9475 | 3500 novell_chat_leave, /* chat_leave */ |
8675 | 3501 NULL, /* chat_whisper */ |
9475 | 3502 novell_chat_send, /* chat_send */ |
3503 novell_keepalive, /* keepalive */ | |
8675 | 3504 NULL, /* register_user */ |
3505 NULL, /* get_cb_info */ | |
9475 | 3506 NULL, /* get_cb_away */ |
3507 novell_alias_buddy, /* alias_buddy */ | |
3508 novell_group_buddy, /* group_buddy */ | |
3509 novell_rename_group, /* rename_group */ | |
8675 | 3510 NULL, /* buddy_free */ |
9475 | 3511 novell_convo_closed, /* convo_closed */ |
11153 | 3512 gaim_normalize_nocase, /* normalize */ |
8675 | 3513 NULL, /* set_buddy_icon */ |
9475 | 3514 novell_remove_group, /* remove_group */ |
3515 NULL, /* get_cb_real_name */ | |
3516 NULL, /* set_chat_topic */ | |
3517 NULL, /* find_blist_chat */ | |
3518 NULL, /* roomlist_get_list */ | |
3519 NULL, /* roomlist_cancel */ | |
3520 NULL, /* roomlist_expand_category */ | |
9473 | 3521 NULL, /* can_receive_file */ |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12126
diff
changeset
|
3522 NULL, /* send_file */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
3523 NULL, /* new_xfer */ |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
3524 NULL, /* offline_message */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
3525 NULL, /* whiteboard_prpl_ops */ |
8675 | 3526 }; |
3527 | |
3528 static GaimPluginInfo info = { | |
9943 | 3529 GAIM_PLUGIN_MAGIC, |
3530 GAIM_MAJOR_VERSION, | |
3531 GAIM_MINOR_VERSION, | |
8993 | 3532 GAIM_PLUGIN_PROTOCOL, /**< type */ |
3533 NULL, /**< ui_requirement */ | |
3534 0, /**< flags */ | |
3535 NULL, /**< dependencies */ | |
3536 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
3537 "prpl-novell", /**< id */ | |
3538 "GroupWise", /**< name */ | |
3539 VERSION, /**< version */ | |
8675 | 3540 /** summary */ |
3541 N_("Novell GroupWise Messenger Protocol Plugin"), | |
3542 /** description */ | |
3543 N_("Novell GroupWise Messenger Protocol Plugin"), | |
8993 | 3544 NULL, /**< author */ |
3545 GAIM_WEBSITE, /**< homepage */ | |
3546 | |
3547 NULL, /**< load */ | |
3548 NULL, /**< unload */ | |
3549 NULL, /**< destroy */ | |
3550 | |
3551 NULL, /**< ui_info */ | |
3552 &prpl_info, /**< extra_info */ | |
3553 NULL, | |
3554 NULL | |
8675 | 3555 }; |
3556 | |
3557 static void | |
3558 init_plugin(GaimPlugin * plugin) | |
3559 { | |
3560 GaimAccountOption *option; | |
3561 | |
3562 option = gaim_account_option_string_new(_("Server address"), "server", NULL); | |
3563 prpl_info.protocol_options = | |
3564 g_list_append(prpl_info.protocol_options, option); | |
3565 | |
3566 option = gaim_account_option_int_new(_("Server port"), "port", DEFAULT_PORT); | |
3567 prpl_info.protocol_options = | |
3568 g_list_append(prpl_info.protocol_options, option); | |
3569 | |
3570 my_protocol = plugin; | |
3571 } | |
3572 | |
3573 GAIM_INIT_PLUGIN(novell, init_plugin, info); |