Changeset fd79497


Ignore:
Timestamp:
Jul 22, 2009, 1:07:41 PM (12 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
029a8b5
Parents:
0bf6757
Message:
Jabber: Sort roster entries

Entries in a roster group are now sorted alphabetically, case insensitive.
Groups in the roster are also sorted in the same way.
The [unsorted] pseudo-group still appears at the end of the roster.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r96f7b07 rfd79497  
    186186}
    187187
     188# Sort, ignoring markup.
     189sub blistSort {
     190    return uc(BarnOwl::ztext_stylestrip($a)) cmp uc(BarnOwl::ztext_stylestrip($b));
     191}
     192
    188193sub getSingleBuddyList {
    189194    my $jid = shift;
     
    195200        $blist .= "\n" . BarnOwl::Style::boldify("Jabber Roster for $jid\n");
    196201
     202        my @gTexts = ();
    197203        foreach my $group ( $roster->groups() ) {
    198             $blist .= "  Group: $group\n";
    199204            my @buddies = $roster->jids( 'group', $group );
     205            my @bTexts = ();
    200206            foreach my $buddy ( @buddies ) {
    201                 $blist .= blist_listBuddy( $roster, $buddy );
     207                push(@bTexts, blist_listBuddy( $roster, $buddy ));
    202208            }
    203         }
     209            push(@gTexts, "  Group: $group\n".join('',sort blistSort @bTexts));
     210        }
     211        # Sort groups before adding ungrouped entries.
     212        @gTexts = sort blistSort @gTexts;
    204213
    205214        my @unsorted = $roster->jids('nogroup');
    206215        if (@unsorted) {
    207             $blist .= "  [unsorted]\n";
     216            my @bTexts = ();
    208217            foreach my $buddy (@unsorted) {
    209                 $blist .= blist_listBuddy( $roster, $buddy );
     218                push(@bTexts, blist_listBuddy( $roster, $buddy ));
    210219            }
    211         }
     220            push(@gTexts, "  [unsorted]\n".join('',sort blistSort @bTexts));
     221        }
     222        $blist .= join('', @gTexts);
    212223    }
    213224    return $blist;
Note: See TracChangeset for help on using the changeset viewer.