'Load the profiles.
:param selected: which profile is already selected.'

def load_profiles(self, selected=None, retry=True):

    liststore = gtk.ListStore(str, str, str, int, str)
    self.profile_instances = {None: None}
    (instance_list, invalid_profiles) = self.w3af.profiles.get_profile_list()
    tmpprofiles = []
    for profile_obj in instance_list:
        nom = profile_obj.get_name()
        desc = profile_obj.get_desc()
        tmpprofiles.append((nom, desc, profile_obj))
    if self._parameter_profile:
        try:
            profile_obj = profile(self._parameter_profile)
        except BaseFrameworkException:
            raise ValueError((_('The    profile    %r    does    not    exists!') % self._parameter_profile))
        else:
            nom = profile_obj.get_name()
            desc = profile_obj.get_desc()
            add_to_list = True
            for (nom_tmp, desc_tmp, profile_tmp) in tmpprofiles:
                if ((nom_tmp == nom) and (desc_tmp == desc)):
                    add_to_list = False
                    break
            if add_to_list:
                tmpprofiles.append((nom, desc, profile_obj))
    tmpprofiles = sorted(tmpprofiles)
    tmpprofiles_special_order = []
    for (nom, desc, profile_obj) in tmpprofiles:
        if (nom == 'empty_profile'):
            tmpprofiles_special_order.insert(0, (nom, desc, profile_obj))
        else:
            tmpprofiles_special_order.append((nom, desc, profile_obj))
    for (nom, desc, profile_obj) in tmpprofiles_special_order:
        prfid = str(id(profile_obj))
        self.profile_instances[prfid] = profile_obj
        liststore.append([nom, desc, prfid, 0, nom])
    self.liststore = liststore
    self.set_model(liststore)
    self.selectedProfile = None
    if (selected is None):
        self.set_cursor(0)
        self._use_profile()
    else:
        for (i, (nom, desc, prfid, changed, perm)) in enumerate(liststore):
            the_prof = self.profile_instances[prfid]
            if ((selected == the_prof.get_profile_file()) or (selected == the_prof.get_name())):
                self.set_cursor(i)
                self._use_profile()
                break
        else:
            if retry:
                self.load_profiles(selected, retry=False)
            else:
                self.set_cursor(0)
    if invalid_profiles:
        message = 'The    following    profiles    are    invalid    and    failed    to    load:\n'
        for i in invalid_profiles:
            message += ('\n DCTB -    ' + i)
        message += '\n\nPlease    click    OK    to    continue    without    these    profiles.'
        dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, message)
        dlg.run()
        dlg.destroy()
