Ticket #7616: 7616-trunk-v1.patch

File 7616-trunk-v1.patch, 6.0 KB (added by danielk, 11 years ago)

untested initial patch

  • libs/libmythdb/mythdb.cpp

     
    1313
    1414unsigned int db_messages = VB_IMPORTANT | VB_GENERAL;
    1515
     16// For thread safety reasons this is not a QString
     17const char *kSentinelValue = "<settings_sentinel_value>";
     18
    1619MythDB *MythDB::getMythDB(void)
    1720{
    1821    if (mythdb)
     
    362365        }
    363366        else
    364367        {
    365             return d->m_settings->GetSetting(key, defaultval);
     368            value = d->m_settings->GetSetting(key, defaultval);
    366369        }
    367370    }
    368371
    369     if (d->useSettingsCache)
     372    if (d->useSettingsCache && value != kSentinelValue)
    370373    {
    371374        key.squeeze();
    372375        value.squeeze();
     
    397400    return retval.toDouble();
    398401}
    399402
     403QString MythDB::GetSetting(const QString &key)
     404{
     405    QString sentinel = QString(kSentinelValue);
     406    QString retval = GetSetting(key, sentinel);
     407    return (retval == sentinel) ? "" : retval;
     408}
     409
     410int MythDB::GetNumSetting(const QString &key)
     411{
     412    QString sentinel = QString(kSentinelValue);
     413    QString retval = GetSetting(key, sentinel);
     414    return (retval == sentinel) ? 0 : retval.toInt();
     415}
     416
     417double MythDB::GetFloatSetting(const QString &key)
     418{
     419    QString sentinel = QString(kSentinelValue);
     420    QString retval = GetSetting(key, sentinel);
     421    return (retval == sentinel) ? 0.0 : retval.toDouble();
     422}
     423
    400424QString MythDB::GetSettingOnHost(const QString &_key, const QString &_host,
    401425                                 const QString &defaultval)
    402426{
     
    450474    if (query.exec() && query.next())
    451475    {
    452476        value = query.value(0).toString();
     477    }
    453478
    454         if (d->useSettingsCache)
    455         {
    456             myKey.squeeze();
    457             value.squeeze();
    458             d->settingsCacheLock.lockForWrite();
    459             if (d->settingsCache.find(myKey) == d->settingsCache.end())
    460                 d->settingsCache[myKey] = value;
    461             d->settingsCacheLock.unlock();
    462         }
     479    if (d->useSettingsCache && value != kSentinelValue)
     480    {
     481        myKey.squeeze();
     482        value.squeeze();
     483        d->settingsCacheLock.lockForWrite();
     484        if (d->settingsCache.find(myKey) == d->settingsCache.end())
     485            d->settingsCache[myKey] = value;
     486        d->settingsCacheLock.unlock();
    463487    }
    464488
    465489    return value;
     
    483507    return retval.toDouble();
    484508}
    485509
     510QString MythDB::GetSettingOnHost(const QString &key, const QString &host)
     511{
     512    QString sentinel = QString(kSentinelValue);
     513    QString retval = GetSettingOnHost(key, host, sentinel);
     514    return (retval == sentinel) ? "" : retval;
     515}
     516
     517int MythDB::GetNumSettingOnHost(const QString &key, const QString &host)
     518{
     519    QString sentinel = QString(kSentinelValue);
     520    QString retval = GetSettingOnHost(key, host, sentinel);
     521    return (retval == sentinel) ? 0 : retval.toInt();
     522}
     523
     524double MythDB::GetFloatSettingOnHost(const QString &key, const QString &host)
     525{
     526    QString sentinel = QString(kSentinelValue);
     527    QString retval = GetSettingOnHost(key, host, sentinel);
     528    return (retval == sentinel) ? 0.0 : retval.toDouble();
     529}
     530
    486531void MythDB::SetSetting(const QString &key, const QString &newValue)
    487532{
    488533    d->m_settings->SetSetting(key, newValue);
  • libs/libmythdb/mythversion.h

     
    88/// Update this whenever the plug-in API changes.
    99/// Including changes in the libmythdb, libmyth and libmythui class methods
    1010/// used by plug-ins.
    11 #define MYTH_BINARY_VERSION "0.23.20091116-1"
     11#define MYTH_BINARY_VERSION "0.23.20091119-1"
    1212
    1313/** \brief Increment this whenever the MythTV network protocol changes.
    1414 *
  • libs/libmythdb/mythdb.h

     
    4141    bool SaveSettingOnHost(const QString &key, const QString &newValue,
    4242                           const QString &host);
    4343
    44     QString GetSetting(const QString &key, const QString &defaultval = "");
    45     int GetNumSetting(const QString &key, int defaultval = 0);
    46     double GetFloatSetting(const QString &key, double defaultval = 0.0);
     44    QString GetSetting(     const QString &key, const QString &defaultval);
     45    int     GetNumSetting(  const QString &key, int            defaultval);
     46    double  GetFloatSetting(const QString &key, double         defaultval);
     47
     48    QString GetSetting(     const QString &key);
     49    int     GetNumSetting(  const QString &key);
     50    double  GetFloatSetting(const QString &key);
     51
     52    QString GetSettingOnHost(
     53        const QString &key, const QString &host, const QString &defaultval);
     54    int     GetNumSettingOnHost(
     55        const QString &key, const QString &host, int            defaultval);
     56    double  GetFloatSettingOnHost(
     57        const QString &key, const QString &host, double         defaultval);
     58
     59    QString GetSettingOnHost(     const QString &key, const QString &host);
     60    int     GetNumSettingOnHost(  const QString &key, const QString &host);
     61    double  GetFloatSettingOnHost(const QString &key, const QString &host);
     62
    4763    void GetResolutionSetting(const QString &type, int &width, int &height,
    4864                              double& forced_aspect, double &refreshrate,
    4965                              int index=-1);
    5066    void GetResolutionSetting(const QString &type, int &width, int &height,
    5167                              int index=-1);
    5268
    53     QString GetSettingOnHost(const QString &key, const QString &host,
    54                              const QString &defaultval = "");
    55     int GetNumSettingOnHost(const QString &key, const QString &host,
    56                             int defaultval = 0);
    57     double GetFloatSettingOnHost(const QString &key, const QString &host,
    58                                  double defaultval = 0.0);
    59 
    6069    void SetSetting(const QString &key, const QString &newValue);
    6170
    6271    static MythDB *getMythDB();