~carlos-mazieri/ubuntu-filemanager-app/samba-browsing

« back to all changes in this revision

Viewing changes to src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.cpp

  • Committer: Tarmac
  • Author(s): Carlos Mazieri
  • Date: 2015-10-28 01:23:07 UTC
  • mfrom: (473.4.3 samba-improvements-07)
  • Revision ID: tarmac-20151028012307-c32ip056vuswym5x
improved SmbUtil::findSmBServer().

Approved by Arto Jalkanen, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
716
716
 */
717
717
QString SmbUtil::findSmBServer(const smbc_dirent & dirent)
718
718
{
719
 
    QString host("localhost");
 
719
    QString host;
720
720
    if (dirent.name[0] != 0)
721
721
    {
722
722
        QString name(dirent.name);
723
723
        host = name;
724
 
        QString comment(dirent.comment);
725
 
        if (!comment.isEmpty())
 
724
    }
 
725
    QString comment(dirent.comment);
 
726
    if (!comment.isEmpty())
 
727
    {
 
728
        QString fullName = comment.split(QLatin1Char(' '), QString::SkipEmptyParts).first();
 
729
        if (!fullName.isEmpty())
726
730
        {
727
 
            QString fullName = comment.split(QLatin1Char(' '), QString::SkipEmptyParts).first();
728
 
            if (!fullName.isEmpty() &&  fullName.startsWith(name), Qt::CaseSensitive)
729
 
            {
730
 
                host = fullName;
731
 
            }
 
731
            host = fullName;
732
732
        }
733
733
    }
 
734
    if (host.isEmpty())
 
735
    {
 
736
        host = QLatin1String("localhost");
 
737
    }
734
738
    return host.toLower();
735
739
}
736
740