Mercurial > pidgin
comparison src/server.c @ 678:c72f58814e9f
[gaim-migrate @ 688]
permit/deny stuff moved to prefs; permit/deny stuff works *properly* now, permit/deny stuff much more logical in preferences.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 15 Aug 2000 01:29:35 +0000 |
parents | b3b5d9d18eea |
children | 71b2477033cb |
comparison
equal
deleted
inserted
replaced
677:05f6f7dabb7e | 678:c72f58814e9f |
---|---|
376 | 376 |
377 | 377 |
378 void serv_set_permit_deny() | 378 void serv_set_permit_deny() |
379 { | 379 { |
380 if (!USE_OSCAR) { | 380 if (!USE_OSCAR) { |
381 char buf[MSG_LEN]; | 381 char buf[MSG_LEN]; |
382 int at; | 382 int at; |
383 GList *list; | 383 int cnt; |
384 | 384 GList *list; |
385 if (permdeny == 1 || permdeny == 4) { | 385 GList *mem; |
386 g_snprintf(buf, sizeof(buf), "toc_add_deny"); | 386 struct buddy *b; |
387 sflap_send(buf, -1, TYPE_DATA); | 387 struct group *g; |
388 } else { | 388 |
389 g_snprintf(buf, sizeof(buf), "toc_add_permit"); | 389 switch (permdeny) { |
390 sflap_send(buf, -1, TYPE_DATA); | 390 case PERMIT_ALL: |
391 } | 391 /* toc_add_permit current_user to go to permit mode, |
392 | 392 toc_add_deny <none> to deny none */ |
393 | 393 sprintf(buf, "toc_add_deny %s", current_user->username); |
394 if (permit) { | 394 sflap_send(buf, -1, TYPE_DATA); |
395 at = g_snprintf(buf, sizeof(buf), "toc_add_permit"); | 395 break; |
396 list = permit; | 396 case PERMIT_NONE: |
397 while(list) { | 397 /* toc_add_deny current_user to go to deny mode, |
398 at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data)); | 398 toc_add_permit <none> to permit none */ |
399 list = list->next; | 399 sprintf(buf, "toc_add_permit %s", current_user->username); |
400 } | 400 sflap_send(buf, -1, TYPE_DATA); |
401 buf[at] = 0; | 401 break; |
402 sflap_send(buf, -1, TYPE_DATA); | 402 case PERMIT_SOME: |
403 } | 403 /* toc_add_permit <permit> */ |
404 | 404 /* if permit is empty this is the same as PERMIT_NONE */ |
405 if (deny) { | 405 if (permit) { |
406 at = g_snprintf(buf, sizeof(buf), "toc_add_deny"); | 406 at = g_snprintf(buf, sizeof(buf), "toc_add_permit"); |
407 list = deny; | 407 list = permit; |
408 while(list) { | 408 while (list) { |
409 at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data)); | 409 at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data)); |
410 list = list->next; | 410 list = list->next; |
411 } | 411 } |
412 buf[at] = 0; | 412 buf[at] = 0; /* is this necessary? */ |
413 sflap_send(buf, -1, TYPE_DATA); | 413 sflap_send(buf, -1, TYPE_DATA); |
414 } | 414 } else { |
415 } else { | 415 sprintf(buf, "toc_add_deny %s", current_user->username); |
416 /* oscar requires us to do everyone at once (?) */ | 416 sflap_send(buf, -1, TYPE_DATA); |
417 /* I think this code is OK now. */ | 417 sprintf(buf, "toc_add_permit"); |
418 char buf[BUF_LONG]; int at; GList *list, *grp, *bud; | 418 sflap_send(buf, -1, TYPE_DATA); |
419 if (permdeny == 3) { /* Permit Some : Only people on buddy list and | |
420 on permit list */ | |
421 struct group *g; struct buddy *b; | |
422 at = 0; list = permit; grp = groups; | |
423 debug_print("Setting permit list...\n"); | |
424 while (grp) { | |
425 g = (struct group *)grp->data; | |
426 bud = g->members; | |
427 while (bud) { | |
428 b = (struct buddy *)bud->data; | |
429 at += g_snprintf(&buf[at], sizeof(buf) - at, | |
430 "%s&", b->name); | |
431 bud = bud->next; | |
432 } | 419 } |
433 grp = grp->next; | 420 break; |
434 } | 421 case DENY_SOME: |
435 while (list) { | 422 /* toc_add_deny <deny> */ |
436 at += g_snprintf(&buf[at], sizeof(buf) - at, "%s&", | 423 /* if deny is empty this is the same as PERMIT_ALL */ |
437 (char *)list->data); | 424 if (deny) { |
438 list = list->next; | 425 at = g_snprintf(buf, sizeof(buf), "toc_add_deny"); |
439 } | 426 list = deny; |
440 aim_bos_changevisibility(gaim_sess, gaim_conn, | 427 while (list) { |
441 AIM_VISIBILITYCHANGE_PERMITADD, buf); | 428 at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data)); |
442 } else { /* Deny Some : Deny people on deny list */ | 429 list = list->next; |
443 list = deny; at = 0; | 430 } |
444 if (list == NULL) return; | 431 buf[at] = 0; /* is this necessary? */ |
445 while (list) { | 432 sflap_send(buf, -1, TYPE_DATA); |
446 at += g_snprintf(&buf[at], sizeof(buf) - at, "%s&", | 433 } else { |
447 (char *)list->data); | 434 sprintf(buf, "toc_add_permit %s", current_user->username); |
448 list = list->next; | 435 sflap_send(buf, -1, TYPE_DATA); |
449 } | 436 sprintf(buf, "toc_add_deny"); |
450 aim_bos_changevisibility(gaim_sess, gaim_conn, | 437 sflap_send(buf, -1, TYPE_DATA); |
451 AIM_VISIBILITYCHANGE_DENYADD, buf); | 438 } |
452 } | 439 break; |
440 case PERMIT_BUDDY: | |
441 /* toc_add_permit <bud> */ | |
442 /* if there are no buddies this is the same as PERMIT_NONE */ | |
443 at = g_snprintf(buf, sizeof(buf), "toc_add_permit"); | |
444 list = groups; | |
445 cnt = 0; | |
446 while (list) { | |
447 g = (struct group *)list->data; | |
448 mem = g->members; | |
449 while (mem) { | |
450 b = (struct buddy *)mem->data; | |
451 at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(b->name)); | |
452 cnt++; | |
453 mem = mem->next; | |
454 } | |
455 list = list->next; | |
456 } | |
457 if (cnt) { | |
458 sflap_send(buf, -1, TYPE_DATA); | |
459 } else { | |
460 sprintf(buf, "toc_add_deny %s", current_user->username); | |
461 sflap_send(buf, -1, TYPE_DATA); | |
462 sprintf(buf, "toc_add_permit"); | |
463 sflap_send(buf, -1, TYPE_DATA); | |
464 } | |
465 } | |
466 } else { | |
467 int at; | |
468 GList *list; | |
469 GList *mem; | |
470 struct buddy *b; | |
471 struct group *g; | |
472 char buf[MSG_LEN]; | |
473 int cnt; | |
474 | |
475 switch (permdeny) { | |
476 /* aim_bos_changevisibility(gaim_sess, gaim_conn, type, list) */ | |
477 case PERMIT_ALL: | |
478 /* AIM_VISIBILITYCHANGE_DENYADD current_user */ | |
479 aim_bos_changevisibility(gaim_sess, gaim_conn, | |
480 AIM_VISIBILITYCHANGE_DENYADD, current_user->username); | |
481 break; | |
482 case PERMIT_NONE: | |
483 /* AIM_VISIBILITY_PERMITADD current_user */ | |
484 aim_bos_changevisibility(gaim_sess, gaim_conn, | |
485 AIM_VISIBILITYCHANGE_PERMITADD, current_user->username); | |
486 break; | |
487 case PERMIT_SOME: | |
488 /* PERMIT <permit> */ | |
489 /* if permit is empty this is the same as PERMIT_NONE */ | |
490 if (permit) { | |
491 at = 0; | |
492 list = permit; | |
493 while (list) { | |
494 at += g_snprintf(&buf[at], sizeof(buf) - at, "%s", list->data); | |
495 list = list->next; | |
496 if (list) | |
497 at += g_snprintf(&buf[at], sizeof(buf) - at, "&"); | |
498 } | |
499 aim_bos_changevisibility(gaim_sess, gaim_conn, | |
500 AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
501 } else { | |
502 aim_bos_changevisibility(gaim_sess, gaim_conn, | |
503 AIM_VISIBILITYCHANGE_PERMITADD, current_user->username); | |
504 } | |
505 break; | |
506 case DENY_SOME: | |
507 /* DENY <deny> */ | |
508 /* if deny is empty this is the same as PERMIT_ALL */ | |
509 if (deny) { | |
510 at = 0; | |
511 list = permit; | |
512 while (list) { | |
513 at += g_snprintf(&buf[at], sizeof(buf) - at, "%s", list->data); | |
514 list = list->next; | |
515 if (list) | |
516 at += g_snprintf(&buf[at], sizeof(buf) - at, "&"); | |
517 } | |
518 aim_bos_changevisibility(gaim_sess, gaim_conn, | |
519 AIM_VISIBILITYCHANGE_DENYADD, buf); | |
520 } else { | |
521 aim_bos_changevisibility(gaim_sess, gaim_conn, | |
522 AIM_VISIBILITYCHANGE_DENYADD, current_user->username); | |
523 } | |
524 break; | |
525 case PERMIT_BUDDY: | |
526 /* PERMIT <bud> */ | |
527 /* if there are no buddies this is the same as PERMIT_NONE */ | |
528 at = 0; | |
529 list = groups; | |
530 cnt = 0; | |
531 while (list) { | |
532 g = (struct group *)list->data; | |
533 mem = g->members; | |
534 while (mem) { | |
535 b = (struct buddy *)mem->data; | |
536 if (at) | |
537 at += g_snprintf(&buf[at], sizeof(buf) - at, "&"); | |
538 at += g_snprintf(&buf[at], sizeof(buf) - at, "%s", b->name); | |
539 cnt++; | |
540 mem = mem->next; | |
541 } | |
542 list = list->next; | |
543 } | |
544 if (cnt) { | |
545 aim_bos_changevisibility(gaim_sess, gaim_conn, | |
546 AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
547 } else { | |
548 aim_bos_changevisibility(gaim_sess, gaim_conn, | |
549 AIM_VISIBILITYCHANGE_PERMITADD, current_user->username); | |
550 } | |
551 break; | |
552 } | |
453 } | 553 } |
454 } | 554 } |
455 | 555 |
456 void serv_set_idle(int time) | 556 void serv_set_idle(int time) |
457 { | 557 { |