~mardy/ubuntu-system-settings-online-accounts/click-plugins-old

« back to all changes in this revision

Viewing changes to click-hooks/main.cpp

  • Committer: Alberto Mardegan
  • Date: 2014-11-05 08:01:48 UTC
  • mfrom: (193.2.16 simplify-hooks)
  • Revision ID: alberto.mardegan@canonical.com-20141105080148-19dmlywvuejcnci0
Auto-fill service type if missing

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
    void addPackageDir(const QString &appId);
90
90
    QString profile() const;
91
91
    void addDesktopFile(const QString &appId);
 
92
    void addServiceType(const QString &shortAppId);
92
93
    void checkIconPath(const QString &appId);
93
94
    bool writeTo(const QString &fileName) const;
94
95
    bool isValid() const { return m_isValid; }
158
159
    root.appendChild(elem);
159
160
}
160
161
 
 
162
void LibAccountsFile::addServiceType(const QString &shortAppId)
 
163
{
 
164
    QString serviceTypeTag = QStringLiteral("type");
 
165
    QDomElement root = documentElement();
 
166
    /* if a <service-type> element already exists, don't touch it */
 
167
    QDomElement elem = root.firstChildElement(serviceTypeTag);
 
168
    if (!elem.isNull()) return;
 
169
 
 
170
    elem = createElement(serviceTypeTag);
 
171
    elem.appendChild(createTextNode(shortAppId));
 
172
    root.appendChild(elem);
 
173
}
 
174
 
161
175
void LibAccountsFile::checkIconPath(const QString &appId)
162
176
{
163
177
    QString iconTag = QStringLiteral("icon");
297
311
        xml.checkIconPath(appId);
298
312
        if (fileType == "application") {
299
313
            xml.addDesktopFile(appId);
 
314
        } else if (fileType == "service") {
 
315
            xml.addServiceType(shortAppId);
300
316
        }
301
317
        xml.writeTo(destination);
302
318
    }