~ubuntu-filemanager-dev/ubuntu-filemanager-app/trunk

« back to all changes in this revision

Viewing changes to src/plugin/folderlistmodel/cleanurl.cpp

  • Committer: Bileto Bot
  • Date: 2017-04-04 17:06:41 UTC
  • mfrom: (588.1.19 fix-desktop-file)
  • Revision ID: ci-train-bot@canonical.com-20170404170641-1p15lmx8wodlx2ut
* Rename binary file to ubuntu-filemanager-app
* Join plugin packages into the main package 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************
 
2
 *
 
3
 * Copyright 2015 Canonical Ltd.
 
4
 * Copyright 2015 Carlos J Mazieri <carlos.mazieri@gmail.com>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU Lesser General Public License as published by
 
8
 * the Free Software Foundation; version 3.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 *
 
18
 * File: cleanurl.cpp
 
19
 * Date: 04/02/2015
 
20
 */
 
21
 
 
22
#include "cleanurl.h"
 
23
 
 
24
#include <QUrl>
 
25
 
 
26
CleanUrl::CleanUrl(const QString &urlPath) : m_user(0), m_password(0)
 
27
{
 
28
    QUrl  url(urlPath);
 
29
    if (url.isValid())
 
30
    {
 
31
        QString user = url.userName();
 
32
        if (!user.isEmpty())
 
33
        {
 
34
            m_user     = new QString(user);
 
35
            m_password = new QString(url.password());
 
36
            url.setPassword(QLatin1String(0));
 
37
            url.setUserName(QLatin1String(0));
 
38
        }
 
39
        m_url = url.toString();
 
40
    }
 
41
    else
 
42
    {
 
43
        m_url = urlPath;
 
44
    }
 
45
}
 
46
 
 
47
 
 
48
CleanUrl::~CleanUrl()
 
49
{
 
50
    if (m_user)     { delete m_user; }
 
51
    if (m_password) { delete m_password;}
 
52
}
 
53
 
 
54
 
 
55
bool CleanUrl::hasAuthenticationData() const
 
56
{
 
57
    return m_user ? true : false;
 
58
}
 
59
 
 
60
QString CleanUrl::user() const
 
61
{
 
62
    return m_user ? *m_user : QString();
 
63
}
 
64
 
 
65
QString CleanUrl::password() const
 
66
{
 
67
    return m_password ? *m_password : QString();
 
68
}
 
69
 
 
70
QString CleanUrl::cleanUrl() const
 
71
{
 
72
    return m_url;
 
73
}