src/protocols/silc/util.c

changeset 9488
9d6520fa53fd
parent 9353
ff6546387358
child 10589
4e10236e06d4
equal deleted inserted replaced
9487:30b821f23d2c 9488:9d6520fa53fd
316 g_string_append_printf(s, _("Host Name: \t%s\n"), ident->host); 316 g_string_append_printf(s, _("Host Name: \t%s\n"), ident->host);
317 if (ident->org) 317 if (ident->org)
318 g_string_append_printf(s, _("Organization: \t%s\n"), ident->org); 318 g_string_append_printf(s, _("Organization: \t%s\n"), ident->org);
319 if (ident->country) 319 if (ident->country)
320 g_string_append_printf(s, _("Country: \t%s\n"), ident->country); 320 g_string_append_printf(s, _("Country: \t%s\n"), ident->country);
321 g_string_append_printf(s, _("Algorithm: \t\t%s\n"), public_key->name); 321 g_string_append_printf(s, _("Algorithm: \t%s\n"), public_key->name);
322 g_string_append_printf(s, _("Key Length: \t%d bits\n"), (int)key_len); 322 g_string_append_printf(s, _("Key Length: \t%d bits\n"), (int)key_len);
323 g_string_append_printf(s, "\n"); 323 g_string_append_printf(s, "\n");
324 g_string_append_printf(s, _("Public Key Fingerprint:\n%s\n\n"), fingerprint); 324 g_string_append_printf(s, _("Public Key Fingerprint:\n%s\n\n"), fingerprint);
325 g_string_append_printf(s, _("Public Key Babbleprint:\n%s"), babbleprint); 325 g_string_append_printf(s, _("Public Key Babbleprint:\n%s"), babbleprint);
326 326
434 if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES_ROBOTS) 434 if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES_ROBOTS)
435 strcat(buf, "[blocks robot messages] "); 435 strcat(buf, "[blocks robot messages] ");
436 if (mode & SILC_CHANNEL_UMODE_QUIET) 436 if (mode & SILC_CHANNEL_UMODE_QUIET)
437 strcat(buf, "[quieted] "); 437 strcat(buf, "[quieted] ");
438 } 438 }
439
440 void
441 silcgaim_parse_attrs(SilcDList attrs, char **moodstr, char **statusstr,
442 char **contactstr, char **langstr, char **devicestr,
443 char **tzstr, char **geostr)
444 {
445 SilcAttributePayload attr;
446 SilcAttributeMood mood = 0;
447 SilcAttributeContact contact;
448 SilcAttributeObjDevice device;
449 SilcAttributeObjGeo geo;
450
451 char tmp[1024];
452 GString *s;
453
454 *moodstr = NULL;
455 *statusstr = NULL;
456 *contactstr = NULL;
457 *langstr = NULL;
458 *devicestr = NULL;
459 *tzstr = NULL;
460 *geostr = NULL;
461
462 if (!attrs)
463 return;
464
465 s = g_string_new("");
466 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_STATUS_MOOD);
467 if (attr && silc_attribute_get_object(attr, &mood, sizeof(mood))) {
468 if (mood & SILC_ATTRIBUTE_MOOD_HAPPY)
469 g_string_append_printf(s, "[%s] ", _("Happy"));
470 if (mood & SILC_ATTRIBUTE_MOOD_SAD)
471 g_string_append_printf(s, "[%s] ", _("Sad"));
472 if (mood & SILC_ATTRIBUTE_MOOD_ANGRY)
473 g_string_append_printf(s, "[%s] ", _("Angry"));
474 if (mood & SILC_ATTRIBUTE_MOOD_JEALOUS)
475 g_string_append_printf(s, "[%s] ", _("Jealous"));
476 if (mood & SILC_ATTRIBUTE_MOOD_ASHAMED)
477 g_string_append_printf(s, "[%s] ", _("Ashamed"));
478 if (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE)
479 g_string_append_printf(s, "[%s] ", _("Invincible"));
480 if (mood & SILC_ATTRIBUTE_MOOD_INLOVE)
481 g_string_append_printf(s, "[%s] ", _("In Love"));
482 if (mood & SILC_ATTRIBUTE_MOOD_SLEEPY)
483 g_string_append_printf(s, "[%s] ", _("Sleepy"));
484 if (mood & SILC_ATTRIBUTE_MOOD_BORED)
485 g_string_append_printf(s, "[%s] ", _("Bored"));
486 if (mood & SILC_ATTRIBUTE_MOOD_EXCITED)
487 g_string_append_printf(s, "[%s] ", _("Excited"));
488 if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS)
489 g_string_append_printf(s, "[%s] ", _("Anxious"));
490 }
491 if (strlen(s->str)) {
492 *moodstr = s->str;
493 g_string_free(s, FALSE);
494 } else
495 g_string_free(s, TRUE);
496
497 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_STATUS_FREETEXT);
498 memset(tmp, 0, sizeof(tmp));
499 if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp)))
500 *statusstr = g_strdup(tmp);
501
502 s = g_string_new("");
503 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_CONTACT);
504 if (attr && silc_attribute_get_object(attr, &contact, sizeof(contact))) {
505 if (contact & SILC_ATTRIBUTE_CONTACT_CHAT)
506 g_string_append_printf(s, "[%s] ", _("Chat"));
507 if (contact & SILC_ATTRIBUTE_CONTACT_EMAIL)
508 g_string_append_printf(s, "[%s] ", _("Email"));
509 if (contact & SILC_ATTRIBUTE_CONTACT_CALL)
510 g_string_append_printf(s, "[%s] ", _("Phone"));
511 if (contact & SILC_ATTRIBUTE_CONTACT_PAGE)
512 g_string_append_printf(s, "[%s] ", _("Paging"));
513 if (contact & SILC_ATTRIBUTE_CONTACT_SMS)
514 g_string_append_printf(s, "[%s] ", _("SMS"));
515 if (contact & SILC_ATTRIBUTE_CONTACT_MMS)
516 g_string_append_printf(s, "[%s] ", _("MMS"));
517 if (contact & SILC_ATTRIBUTE_CONTACT_VIDEO)
518 g_string_append_printf(s, "[%s] ", _("Video Conferencing"));
519 }
520 if (strlen(s->str)) {
521 *contactstr = s->str;
522 g_string_free(s, FALSE);
523 } else
524 g_string_free(s, TRUE);
525
526 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_LANGUAGE);
527 memset(tmp, 0, sizeof(tmp));
528 if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp)))
529 *langstr = g_strdup(tmp);
530
531 s = g_string_new("");
532 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_DEVICE_INFO);
533 memset(&device, 0, sizeof(device));
534 if (attr && silc_attribute_get_object(attr, &device, sizeof(device))) {
535 if (device.type == SILC_ATTRIBUTE_DEVICE_COMPUTER)
536 g_string_append_printf(s, "%s: ", _("Computer"));
537 if (device.type == SILC_ATTRIBUTE_DEVICE_MOBILE_PHONE)
538 g_string_append_printf(s, "%s: ", _("Mobile Phone"));
539 if (device.type == SILC_ATTRIBUTE_DEVICE_PDA)
540 g_string_append_printf(s, "%s: ", _("PDA"));
541 if (device.type == SILC_ATTRIBUTE_DEVICE_TERMINAL)
542 g_string_append_printf(s, "%s: ", _("Terminal"));
543 g_string_append_printf(s, "%s %s %s %s",
544 device.manufacturer ? device.manufacturer : "",
545 device.version ? device.version : "",
546 device.model ? device.model : "",
547 device.language ? device.language : "");
548 }
549 if (strlen(s->str)) {
550 *devicestr = s->str;
551 g_string_free(s, FALSE);
552 } else
553 g_string_free(s, TRUE);
554
555 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_TIMEZONE);
556 memset(tmp, 0, sizeof(tmp));
557 if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp)))
558 *tzstr = g_strdup(tmp);
559
560 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_GEOLOCATION);
561 memset(&geo, 0, sizeof(geo));
562 if (attr && silc_attribute_get_object(attr, &geo, sizeof(geo)))
563 *geostr = g_strdup_printf("%s %s %s (%s)",
564 geo.longitude ? geo.longitude : "",
565 geo.latitude ? geo.latitude : "",
566 geo.altitude ? geo.altitude : "",
567 geo.accuracy ? geo.accuracy : "");
568 }

mercurial