~ubuntu-branches/ubuntu/trusty/content-hub/trusty-proposed

« back to all changes in this revision

Viewing changes to src/com/ubuntu/content/service/registry.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Loïc Minier, Ken VanDine, Javier Collado, Dimitri John Ledkov, Michael Sheldon
  • Date: 2014-04-02 14:46:54 UTC
  • mfrom: (1.1.20)
  • Revision ID: package-import@ubuntu.com-20140402144654-8ilsrlzz6bx5p3ox
Tags: 0.0+14.04.20140402-0ubuntu1
[ Loïc Minier ]
* Downgrade content-hub Recommends to a Suggests as we don't want
  content-hub pulled via ubuntu-sdk on developer desktops.

[ Ken VanDine ]
* protect against queries for Type::unknown (LP: #1293463)
* Replace a couple missed qDebug lines for logging
* Don't unref the g_icon, the value belongs to app
* Ensure m_defaultSources is a StringList before attempting to use it
  as a list
* ContentPeerPicker: Make headers translatable and use a
  ResponsiveGridView for the devices grid to match the apps grid.
  ContentPeerPicker: hide the devices section until we have a way to
  populate it

[ Javier Collado ]
* Added README file (LP: #1274899)

[ Dimitri John Ledkov ]
* Exit quicker, if there is nothing to do. (LP: #1287674) (LP:
  #1287674)

[ Michael Sheldon ]
* Fixes updating of the ContentPeerModel when using Loader and
  changing ContentType or ContentHandler dynamically and ensures that
  ContentPeerModel Loader doesn't begin loading the model until the
  peer picker becomes visible (avoiding delaying app start-up time).
* Make qdoc based documentation compatible with the Qt 5.2 version of
  qdoc.
* Fixes version number of import statements in QML documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    {
38
38
        if (m_defaultSources->keys().contains(type.id()))
39
39
        {
40
 
            QString peer_id = m_defaultSources->get(type.id()).toString();
41
 
            QStringList as(m_defaultSources->get(type.id()).toStringList());
42
 
            if (!as.isEmpty())
43
 
            {
44
 
                std::string pkg = as[0].toStdString();
45
 
                std::string app = as[1].toStdString();
46
 
                std::string ver = as[2].toStdString();
47
 
                cuc::Peer peer;
48
 
                if (app.empty() || ver.empty())
49
 
                    peer = QString::fromStdString(pkg);
50
 
                else
51
 
                    peer = QString::fromLocal8Bit(upstart_app_launch_triplet_to_app_id(pkg.c_str(), app.c_str(), ver.c_str()));
52
 
                install_source_for_type(type, cuc::Peer{peer.id(), true});
 
40
            QVariant peer_v = m_defaultSources->get(type.id());
 
41
            // If default isn't a StringList, attempt to reset
 
42
            if (peer_v.type() != QVariant::StringList)
 
43
            {
 
44
                TRACE() << Q_FUNC_INFO << "Default type for" << type.id() << "is incorrect, resetting";
 
45
                m_defaultSources->reset(type.id());
 
46
                // After reset, lets get a new QVariant
 
47
                peer_v = m_defaultSources->get(type.id());
 
48
            }
 
49
 
 
50
            /* Only assume the default is correct if the type is a StringList
 
51
             * The reset above should have ensured it was reset, lets double
 
52
             * check anyway to prevent crashes
 
53
             */
 
54
            if (peer_v.type() == QVariant::StringList)
 
55
            {
 
56
                QStringList as(peer_v.toStringList());
 
57
                if (!as.isEmpty())
 
58
                {
 
59
                    std::string pkg = as[0].toStdString();
 
60
                    std::string app = as[1].toStdString();
 
61
                    std::string ver = as[2].toStdString();
 
62
                    cuc::Peer peer;
 
63
                    if (app.empty() || ver.empty())
 
64
                        peer = QString::fromStdString(pkg);
 
65
                    else
 
66
                        peer = QString::fromLocal8Bit(upstart_app_launch_triplet_to_app_id(pkg.c_str(), app.c_str(), ver.c_str()));
 
67
                    install_source_for_type(type, cuc::Peer{peer.id(), true});
 
68
                }
53
69
            }
54
70
        }
55
71
    }
62
78
    TRACE() << Q_FUNC_INFO << type.id();
63
79
    if (m_defaultSources->keys().contains(type.id()))
64
80
    {
65
 
        QStringList as(m_defaultSources->get(type.id()).toStringList());
 
81
        QVariant peer_v = m_defaultSources->get(type.id());
 
82
        if (peer_v.type() != QVariant::StringList)
 
83
            return cuc::Peer(peer_v.toString());
 
84
        QStringList as(peer_v.toStringList());
66
85
        if (!as.isEmpty())
67
86
        {
68
87
            std::string pkg = as[0].toStdString();
69
88
            std::string app = as[1].toStdString();
70
89
            std::string ver = as[2].toStdString();
71
 
            cuc::Peer peer;
72
90
            if (app.empty() || ver.empty())
73
91
                return cuc::Peer(QString::fromStdString(pkg));
74
92
            return cuc::Peer(QString::fromLocal8Bit(upstart_app_launch_triplet_to_app_id(pkg.c_str(), app.c_str(), ver.c_str())), true);
122
140
    {
123
141
        TRACE() << Q_FUNC_INFO << k;
124
142
        bool defaultPeer = false;
125
 
        QStringList as(m_defaultSources->get(type.id()).toStringList());
126
 
        if (!as.isEmpty())
127
 
        {   
128
 
            std::string pkg = as[0].toStdString();
129
 
            std::string app = as[1].toStdString();
130
 
            std::string ver = as[2].toStdString();
131
 
            if (app.empty() || ver.empty())
132
 
                defaultPeer = QString::fromStdString(pkg) == k;
133
 
            else
134
 
                defaultPeer = QString::fromLocal8Bit(upstart_app_launch_triplet_to_app_id(pkg.c_str(), app.c_str(), ver.c_str())) == k;
 
143
        QVariant peer_v = m_defaultSources->get(type.id());
 
144
        if (peer_v.type() == QVariant::StringList)
 
145
        {
 
146
            QStringList as(peer_v.toStringList());
 
147
            if (!as.isEmpty())
 
148
            {
 
149
                std::string pkg = as[0].toStdString();
 
150
                std::string app = as[1].toStdString();
 
151
                std::string ver = as[2].toStdString();
 
152
                if (app.empty() || ver.empty())
 
153
                    defaultPeer = QString::fromStdString(pkg) == k;
 
154
                else
 
155
                    defaultPeer = QString::fromLocal8Bit(upstart_app_launch_triplet_to_app_id(pkg.c_str(), app.c_str(), ver.c_str())) == k;
 
156
            }
135
157
        }
136
158
        for_each(cuc::Peer{k, defaultPeer});
137
159
    }
140
162
void Registry::enumerate_known_destinations_for_type(cuc::Type type, const std::function<void(const cuc::Peer&)>&for_each)
141
163
{
142
164
    TRACE() << Q_FUNC_INFO << type.id();
 
165
 
 
166
    if (type == cuc::Type::unknown())
 
167
        return;
 
168
 
143
169
    Q_FOREACH (QString k, m_dests->get(type.id()).toStringList())
144
170
    {
145
171
        TRACE() << Q_FUNC_INFO << k;
151
177
{
152
178
    TRACE() << Q_FUNC_INFO << type.id();
153
179
 
 
180
    if (type == cuc::Type::unknown())
 
181
        return;
 
182
 
154
183
    Q_FOREACH (QString k, m_shares->get(type.id()).toStringList())
155
184
    {
156
185
        TRACE() << Q_FUNC_INFO << k;