avatar.c
changeset 24 7aa499342e2b
parent 23 2b7060ce1152
child 25 6ad07b1d4e7f
equal deleted inserted replaced
23:2b7060ce1152 24:7aa499342e2b
    50 // module description
    50 // module description
    51 
    51 
    52 static void avatar_init   (void);
    52 static void avatar_init   (void);
    53 static void avatar_uninit (void);
    53 static void avatar_uninit (void);
    54 
    54 
       
    55 #define DESCRIPTION ( \
       
    56 	"PEP avatars handling\n" \
       
    57 	"Recognizes options avatar_directory, avatar_font_height, avatar_font_width, avatar_max_height, avatar_max_width and avatar_background\n" \
       
    58 	"Provides command /avatar" )
    55 static const gchar *deps[] = { "pep", NULL };
    59 static const gchar *deps[] = { "pep", NULL };
       
    60 
       
    61 static module_info_t info_avatar_experimental = {
       
    62 	.branch      = "experimental",
       
    63 	.api         = 5,
       
    64 	.version     = PROJECT_VERSION,
       
    65 	.description = DESCRIPTION,
       
    66 	.requires    = deps,
       
    67 	.init        = avatar_init,
       
    68 	.uninit      = avatar_uninit,
       
    69 	.next        = NULL,
       
    70 };
       
    71 
    56 module_info_t info_avatar = {
    72 module_info_t info_avatar = {
    57 	.mcabber_version = "0.10.0",
    73 	.branch      = "dev",
    58 	.requires        = deps,
    74 	.api         = 4,
    59 	.init            = avatar_init,
    75 	.version     = PROJECT_VERSION,
    60 	.uninit          = avatar_uninit,
    76 	.description = DESCRIPTION,
       
    77 	.requires    = deps,
       
    78 	.init        = avatar_init,
       
    79 	.uninit      = avatar_uninit,
       
    80 	.next        = &info_avatar_experimental,
    61 };
    81 };
    62 
    82 
    63 // globals
    83 // globals
    64 
    84 
    65 #define NS_AVATAR_DATA            ( "urn:xmpp:avatar:data"            )
    85 #define NS_AVATAR_DATA            ( "urn:xmpp:avatar:data"            )
   649 		int maxcharh = settings_opt_get_int ("avatar_max_height");
   669 		int maxcharh = settings_opt_get_int ("avatar_max_height");
   650 		int maxcharw = settings_opt_get_int ("avatar_max_width");
   670 		int maxcharw = settings_opt_get_int ("avatar_max_width");
   651 		int fonth    = settings_opt_get_int ("avatar_font_height");
   671 		int fonth    = settings_opt_get_int ("avatar_font_height");
   652 		int fontw    = settings_opt_get_int ("avatar_font_width");
   672 		int fontw    = settings_opt_get_int ("avatar_font_width");
   653 
   673 
   654 		// if not set explicitly, try to calculate available space
   674 		// if not set explicitly, calculate available space
   655 		if (!maxcharh) {
   675 		if (!maxcharh)
   656 			char *var = getenv ("LINES");
   676 			maxcharh = scr_gettextheight() - 1; // -1 due to avatar header line
   657 
   677 
   658 			if (var)
   678 		if (!maxcharw)
   659 				maxcharh = atoi (var);
   679 			maxcharw = scr_gettextwidth();
   660 			else
       
   661 				maxcharh = 25;
       
   662 
       
   663 			maxcharh -= settings_opt_get_int ("log_win_height") + 3 + 1; // +1 due to avatar header line
       
   664 		}
       
   665 
       
   666 		if (!maxcharw) {
       
   667 			char *var = getenv ("COLUMNS");
       
   668 
       
   669 			if (var)
       
   670 				maxcharw = atoi (var);
       
   671 			else
       
   672 				maxcharw = 80;
       
   673 
       
   674 			maxcharw -= settings_opt_get_int ("roster_width") + scr_getprefixwidth ();
       
   675 		}
       
   676 
   680 
   677 		if (!fonth)
   681 		if (!fonth)
   678 			fonth = 16;
   682 			fonth = 16;
   679 		if (!fontw)
   683 		if (!fontw)
   680 			fontw = 8;
   684 			fontw = 8;