Changeset f25812b
- Timestamp:
- Mar 24, 2010, 4:24:38 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 125fd21
- Parents:
- 59ab8dd
- git-author:
- Alejandro R. Sedeño <asedeno@mit.edu> (03/23/10 01:11:31)
- git-committer:
- Alejandro R. Sedeño <asedeno@mit.edu> (03/24/10 16:24:38)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r5934b87 rf25812b 3410 3410 int i, j; 3411 3411 owl_list anyone; 3412 owl_message *m;3413 3412 owl_zbuddylist *zbl; 3413 GList **zaldlist; 3414 GList *zaldptr; 3415 ZAsyncLocateData_t *zald; 3414 3416 const char *user; 3415 ZLocations_t location[200];3416 int numlocs, ret;3417 3417 3418 3418 if (!owl_global_is_havezephyr(&g)) return; 3419 3420 zbl=owl_global_get_zephyr_buddylist(&g); 3419 owl_global_set_pseudologin_notify(&g, notify); 3420 zbl = owl_global_get_zephyr_buddylist(&g); 3421 zaldlist = owl_global_get_zaldlist(&g); 3422 3423 /* Clear the existing ZALDs first. */ 3424 zaldptr = g_list_first(*zaldlist); 3425 while (zaldptr) { 3426 ZFreeALD(zaldptr->data); 3427 owl_free(zaldptr->data); 3428 zaldptr = g_list_next(zaldptr); 3429 } 3430 g_list_free(*zaldlist); 3431 *zaldlist = NULL; 3421 3432 3422 3433 owl_list_create(&anyone); 3423 ret=owl_zephyr_get_anyone_list(&anyone, NULL); 3424 3425 j=owl_list_get_size(&anyone); 3426 for (i=0; i<j; i++) { 3427 user=owl_list_get_element(&anyone, i); 3428 ret=ZLocateUser(zstr(user), &numlocs, ZAUTH); 3429 if (ret!=ZERR_NONE) { 3430 owl_function_error("Error getting location for %s", user); 3431 continue; 3432 } 3433 numlocs=200; 3434 ret=ZGetLocations(location, &numlocs); 3435 if (ret==0) { 3436 if ((numlocs>0) && !owl_zbuddylist_contains_user(zbl, user)) { 3437 /* Send a PSEUDO LOGIN! */ 3438 if (notify) { 3439 m=owl_malloc(sizeof(owl_message)); 3440 owl_message_create_pseudo_zlogin(m, 0, user, location[0].host, location[0].time, location[0].tty); 3441 owl_global_messagequeue_addmsg(&g, m); 3442 } 3443 owl_zbuddylist_adduser(zbl, user); 3444 owl_function_debugmsg("owl_function_zephyr_buddy_check: login for %s ", user); 3445 } else if ((numlocs==0) && owl_zbuddylist_contains_user(zbl, user)) { 3446 /* I don't think this ever happens (if there are 0 locations we should get an error from 3447 * ZGetLocations) 3448 */ 3449 owl_function_error("owl_function_zephyr_buddy_check: exceptional case logout for %s ",user); 3450 } 3451 } else if ((ret==ZERR_NOLOCATIONS) && owl_zbuddylist_contains_user(zbl, user)) { 3452 /* Send a PSEUDO LOGOUT! */ 3453 if (notify) { 3454 m=owl_malloc(sizeof(owl_message)); 3455 owl_message_create_pseudo_zlogin(m, 1, user, "", "", ""); 3456 owl_global_messagequeue_addmsg(&g, m); 3457 } 3458 owl_zbuddylist_deluser(zbl, user); 3459 owl_function_debugmsg("owl_function_zephyr_buddy_check: logout for %s ",user); 3434 owl_zephyr_get_anyone_list(&anyone, NULL); 3435 j = owl_list_get_size(&anyone); 3436 for (i = 0; i < j; i++) { 3437 user = owl_list_get_element(&anyone, i); 3438 zald = owl_malloc(sizeof(ZAsyncLocateData_t)); 3439 if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) { 3440 *zaldlist = g_list_append(*zaldlist, zald); 3441 } else { 3442 owl_free(zald); 3460 3443 } 3461 3444 } -
global.c
r59ab8dd rf25812b 110 110 owl_zbuddylist_create(&(g->zbuddies)); 111 111 112 g->zaldlist = NULL; 113 g->pseudologin_notify = 0; 114 112 115 owl_obarray_init(&(g->obarray)); 113 116 … … 963 966 } 964 967 968 GList **owl_global_get_zaldlist(owl_global *g) 969 { 970 return &(g->zaldlist); 971 } 972 973 int owl_global_get_pseudologin_notify(owl_global *g) 974 { 975 return g->pseudologin_notify; 976 } 977 978 void owl_global_set_pseudologin_notify(owl_global *g, int notify) 979 { 980 g->pseudologin_notify = notify; 981 } 982 965 983 struct termios *owl_global_get_startup_tio(owl_global *g) 966 984 { -
owl.h
r03c5bdd rf25812b 604 604 owl_zbuddylist zbuddies; 605 605 owl_timer zephyr_buddycheck_timer; 606 GList *zaldlist; 607 int pseudologin_notify; 606 608 struct termios startup_tio; 607 609 owl_obarray obarray; -
zephyr.c
rc230bc1 rf25812b 1299 1299 } 1300 1300 1301 #ifdef HAVE_LIBZEPHYR 1302 void owl_zephyr_process_pseudologin(ZNotice_t *n) 1303 { 1304 owl_message *m; 1305 owl_zbuddylist *zbl; 1306 GList **zaldlist; 1307 GList *zaldptr; 1308 ZAsyncLocateData_t *zald = NULL; 1309 ZLocations_t location; 1310 int numlocs, ret, notify; 1311 1312 /* Find a ZALD to match this notice. */ 1313 zaldlist = owl_global_get_zaldlist(&g); 1314 zaldptr = g_list_first(*zaldlist); 1315 while (zaldptr) { 1316 if (ZCompareALDPred(n, zaldptr->data)) { 1317 zald = zaldptr->data; 1318 *zaldlist = g_list_remove(*zaldlist, zaldptr->data); 1319 break; 1320 } 1321 zaldptr = g_list_next(zaldptr); 1322 } 1323 if (zald) { 1324 /* Deal with notice. */ 1325 notify = owl_global_get_pseudologin_notify(&g); 1326 zbl = owl_global_get_zephyr_buddylist(&g); 1327 ret = ZParseLocations(n, zald, &numlocs, NULL); 1328 if (ret == ZERR_NONE) { 1329 if (numlocs > 0 && !owl_zbuddylist_contains_user(zbl, zald->user)) { 1330 if (notify) { 1331 numlocs = 1; 1332 ret = ZGetLocations(&location, &numlocs); 1333 if (ret == ZERR_NONE) { 1334 /* Send a PSEUDO LOGIN! */ 1335 m = owl_malloc(sizeof(owl_message)); 1336 owl_message_create_pseudo_zlogin(m, 0, zald->user, 1337 location.host, 1338 location.time, 1339 location.tty); 1340 owl_global_messagequeue_addmsg(&g, m); 1341 } 1342 owl_zbuddylist_adduser(zbl, zald->user); 1343 owl_function_debugmsg("owl_function_zephyr_buddy_check: login for %s ", zald->user); 1344 } 1345 } else if (numlocs == 0 && owl_zbuddylist_contains_user(zbl, zald->user)) { 1346 /* Send a PSEUDO LOGOUT! */ 1347 if (notify) { 1348 m = owl_malloc(sizeof(owl_message)); 1349 owl_message_create_pseudo_zlogin(m, 1, zald->user, "", "", ""); 1350 owl_global_messagequeue_addmsg(&g, m); 1351 } 1352 owl_zbuddylist_deluser(zbl, zald->user); 1353 owl_function_debugmsg("owl_function_zephyr_buddy_check: logout for %s ", zald->user); 1354 } 1355 } 1356 ZFreeALD(zald); 1357 owl_free(zald); 1358 } 1359 } 1360 #else 1361 void owl_zephyr_process_pseudologin(void *n) 1362 { 1363 } 1364 #endif 1365 1301 1366 /* 1302 1367 * Process zephyrgrams from libzephyr's queue. To prevent starvation, … … 1333 1398 } 1334 1399 1400 /* if it is a LOCATE message, it's for pseudologins. */ 1401 if (strcmp(notice.z_opcode, LOCATE_LOCATE) == 0) { 1402 owl_zephyr_process_pseudologin(¬ice); 1403 ZFreeNotice(¬ice); 1404 continue; 1405 } 1406 1335 1407 /* create the new message */ 1336 1408 m=owl_malloc(sizeof(owl_message));
Note: See TracChangeset
for help on using the changeset viewer.