Ticket #1050: lastname.patch

File lastname.patch, 3.8 KB (added by anonymous, at 2013-04-26T13:02:54Z)
  • doc/user-guide/commands.xml

    diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml
    a b  
    11291129
    11301130        <bitlbee-setting name="nick_source" type="string" scope="account">
    11311131                <default>handle</default>
    1132                 <possible-values>handle, full_name, first_name</possible-values>
     1132                <possible-values>handle, full_name, first_name, last_name</possible-values>
    11331133
    11341134                <description>
    11351135                        <para>
  • doc/user-guide/help.txt

    diff --git a/doc/user-guide/help.txt b/doc/user-guide/help.txt
    index 4822e01..5fe2c3f 100644
    a b See help nick_format for more information. 
    832832Type: string
    833833Scope: account
    834834Default: handle
    835 Possible Values: handle, full_name, first_name
     835Possible Values: handle, full_name, first_name, last_name
    836836
    837837By default, BitlBee generates a nickname for every contact by taking its handle and chopping off everything after the @. In some cases, this gives very inconvenient nicknames. The Facebook XMPP server is a good example, as all Facebook XMPP handles are numeric.
    838838
    839 With this setting set to full_name, the person's full name is used to generate a nickname. Or if you don't like long nicknames, set this setting to first_name instead and only the first word will be used. Note that the full name can be full of non-ASCII characters which will be stripped off.
     839With this setting set to full_name, the person's full name is used to generate a nickname. Or if you don't like long nicknames, set this setting to first_name or last_name instead and only the first or last word will be used. Note that the full name can be full of non-ASCII characters which will be stripped off.
    840840%
    841841?set oauth
    842842Type: boolean
    The setting is basically some kind of format string. It can contain normal text 
    12861286 %handle - The handle/screenname of the contact.
    12871287 %full_name - The full name of the contact.
    12881288 %first_name - The first name of the contact (the full name up to the first space).
     1289 %last_name - The last name of the contact (the full name from the last space).
    12891290 %group - The name of the group this contact is a member of
    12901291 %account - Account tag of the contact
    12911292
  • doc/user-guide/misc.xml

    diff --git a/doc/user-guide/misc.xml b/doc/user-guide/misc.xml
    index ac2734c..12b0369 100644
    a b text that will be copied to the nick, combined with several variables: 
    233233        <varlistentry><term>%handle</term><listitem><para>The handle/screenname of the contact.</para></listitem></varlistentry>
    234234        <varlistentry><term>%full_name</term><listitem><para>The full name of the contact.</para></listitem></varlistentry>
    235235        <varlistentry><term>%first_name</term><listitem><para>The first name of the contact (the full name up to the first space).</para></listitem></varlistentry>
     236    <varlistentry><term>%last_name</term><listitem><para>The last name of the contact (the full name from the last space).</para></listitem></varlistentry>
    236237        <varlistentry><term>%group</term><listitem><para>The name of the group this contact is a member of</para></listitem></varlistentry>
    237238        <varlistentry><term>%account</term><listitem><para>Account tag of the contact</para></listitem></varlistentry>
    238239</variablelist>
  • nick.c

    diff --git a/nick.c b/nick.c
    index 4b7e71d..de18411 100644
    a b char *nick_gen( bee_user_t *bu ) 
    175175                                chop = ' ';
    176176                                break;
    177177                        }
     178                        else if( g_strncasecmp( fmt, "last_name", 9 ) == 0 )
     179                        {
     180                                char **parts = g_strsplit(bu->fullname, " ", 2);
     181                                ssize_t len = g_strv_length(parts);
     182                                part = len >= 2 ? g_strdup(parts[len - 1]) : bu->handle;
     183                                g_strfreev(parts);
     184
     185                                fmt += 9;
     186                                ok |= part && *part;
     187                                break;
     188                        }
    178189                        else if( g_strncasecmp( fmt, "group", 5 ) == 0 )
    179190                        {
    180191                                part = bu->group ? bu->group->name : NULL;