ssucoreconfig_p.h 3.67 KB
Newer Older
1
/**
2
 * @file ssucoreconfig_p.h
3 4 5 6 7
 * @copyright 2013 Jolla Ltd.
 * @author Bernd Wachter <bwachter@lart.info>
 * @date 2013
 */

8 9
#ifndef _SSUCORECONFIG_P_H
#define _SSUCORECONFIG_P_H
10 11

#include <QObject>
12
#include "ssusettings_p.h"
13
#include "ssu.h"
14 15

#ifndef SSU_CONFIGURATION
16
/// Path to the main ssu configuration file
17 18 19 20
#define SSU_CONFIGURATION "/etc/ssu/ssu.ini"
#endif

#ifndef SSU_DEFAULT_CONFIGURATION
21
/// Path to the main ssu configuration file
22 23 24
#define SSU_DEFAULT_CONFIGURATION "/usr/share/ssu/ssu-defaults.ini"
#endif

25 26
class QDBusConnection;

27 28
class SsuCoreConfig: public SsuSettings
{
29 30
    Q_OBJECT

31
public:
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
    static SsuCoreConfig *instance();
    /**
     * Find a username/password pair for the given scope
     * @return a QPair with username and password, or an empty QPair if scope is invalid
     */
    QPair<QString, QString> credentials(QString scope);
    /**
     * Get the scope for a repository, taking into account different scopes for
     * release and RnD repositories
     *
     * Please note that variable scope is not yet implemented -- one default scope is
     * read from the configuration file.
     *
     * @return a string containing the scope; it can be used to look up login credentials using  credentials()
     */
47
    QString credentialsScope(QString repoName, bool rndRepo = false);
48 49 50 51 52 53 54 55 56 57 58 59
    /**
     * Return the URL for which credentials scope is valid
     */
    QString credentialsUrl(QString scope);
    /**
     * Get the current flavour when RnD repositories are used
     * @return current flavour (usually something like testing, release, ..)
     */
    Q_INVOKABLE QString flavour();
    /**
     * Get the current mode bits for the device
     */
60
    Q_INVOKABLE Ssu::DeviceModeFlags deviceMode();
61 62
    /**
     * Get the current domain used in registration
63 64
     * Internally - in the domain is replaced by :, if you need
     * to print the domain name set pretty to true
65 66
     * @return domain, or "" if not set
     */
67
    Q_INVOKABLE QString domain(bool pretty = false);
68 69 70 71 72 73 74 75
    /**
     * Return devices RND registration status
     * @retval true device is registered
     * @retval false device is not registered
     */
    Q_INVOKABLE bool isRegistered();
    /**
     * Return the date/time when the credentials to access internal
76
     * ssu servers were updated the last time
77 78 79 80 81
     */
    Q_INVOKABLE QDateTime lastCredentialsUpdate();
    /**
     * Return the release version string for either a release, or a RnD snapshot
     */
82
    Q_INVOKABLE QString release(bool rnd = false);
83 84 85
    /**
     * Set mode bits for the device
     */
86
    Q_INVOKABLE void setDeviceMode(Ssu::DeviceModeFlags mode, enum Ssu::EditMode editMode = Ssu::Replace);
87 88 89 90 91 92 93
    /**
     * Set the flavour used when resolving RND repositories
     */
    Q_INVOKABLE void setFlavour(QString flavour);
    /**
     * Set the release version string for either a release, or a RnD snapshot
     */
94
    Q_INVOKABLE void setRelease(QString release, bool rnd = false);
95 96 97 98 99 100 101 102 103 104
    /**
     * Set the domain string (usually something like nemo, jolla, ..)
     */
    Q_INVOKABLE void setDomain(QString domain);
    /**
     * Return configuration settings regarding ssl verification
     * @retval true SSL verification must be used; that's the default if not configured
     * @retval false SSL verification should be disabled
     */
    Q_INVOKABLE bool useSslVerify();
105 106 107 108
    /**
     * Return a DBus connection object connected to the session bus of the active user
     */
    static QDBusConnection userSessionBus();
109 110


111
private:
112 113 114 115 116 117 118 119
    SsuCoreConfig(): SsuSettings(SSU_CONFIGURATION, QSettings::IniFormat, SSU_DEFAULT_CONFIGURATION) {};
    SsuCoreConfig(const SsuCoreConfig &); // hide copy constructor

    static SsuCoreConfig *ssuCoreConfig;
};


#endif