jingle/disco.c
changeset 78 0b138243bd4a
equal deleted inserted replaced
77:56c6ab96026f 78:0b138243bd4a
       
     1 st/*
       
     2  * disco.c
       
     3  *
       
     4  * Copyrigth (C) 2010 Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
       
     5  *
       
     6  * This program is free software; you can redistribute it and/or modify
       
     7  * it under the terms of the GNU General Public License as published by
       
     8  * the Free Software Foundation; either version 2 of the License, or (at
       
     9  * your option) any later version.
       
    10  *
       
    11  * This program is distributed in the hope that it will be useful, but
       
    12  * WITHOUT ANY WARRANTY; without even the implied warranty of
       
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    14  * General Public License for more details.
       
    15  *
       
    16  * You should have received a copy of the GNU General Public License
       
    17  * along with this program; if not, write to the Free Software
       
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
       
    19  * USA
       
    20  */
       
    21 
       
    22 #include "config.h"
       
    23  
       
    24 #include <glib.h>
       
    25 #include <loudmouth/loudmouth.h>
       
    26 
       
    27 #include <mcabber/roster.h>
       
    28 
       
    29 static gint compare_resources(gconstpointer a, gconstpointer b)
       
    30 {
       
    31   return buddy_getresourceprio(a)-buddy_getresourceprio(b);
       
    32 }
       
    33 
       
    34 GSList* get_sorted_resources(const gchar *jid)
       
    35 {
       
    36   roster *rs;
       
    37   
       
    38   GSList *reslist = buddy_search_jid(jid);
       
    39   
       
    40   if (reslist == NULL)
       
    41     return NULL;
       
    42   
       
    43   rs = (roster*)reslist->data;
       
    44 
       
    45   reslist = buddy_getresources(rs);
       
    46   
       
    47   reslist = g_slist_sort(reslist, compare_resources);
       
    48   
       
    49   return reslist;
       
    50 }
       
    51 
       
    52 void free_gslist_resources(GSList *reslist)
       
    53 {
       
    54   GSList *el;
       
    55   roster *rs;
       
    56   
       
    57   for (el=reslist; el; el=el->next) {
       
    58     rs=(roster*)el->data;
       
    59     free_roster_user_data(rs);
       
    60   }
       
    61   g_slist_free(reslist);
       
    62 }
       
    63 
       
    64