Subversion Repositories tpanel

Rev

Rev 449 | Rev 482 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 449 Rev 480
Line 77... Line 77...
77
bool TConfig::mMute{false};
77
bool TConfig::mMute{false};
78
bool TConfig::mTemporary{false};
78
bool TConfig::mTemporary{false};
79
bool TConfig::mLogFileEnabled{false};
79
bool TConfig::mLogFileEnabled{false};
80
std::mutex config_mutex;
80
std::mutex config_mutex;
81
 
81
 
-
 
82
typedef struct _APPS_t
-
 
83
{
-
 
84
    string appID;       // Name corresponding to G5 apps table
-
 
85
    string path;        // Path and name of the application
-
 
86
}_APPS_t;
-
 
87
 
82
/**
88
/**
83
 * @struct SETTINGS
89
 * @struct SETTINGS
84
 * @brief The SETTINGS struct bundles the configuration options.
90
 * @brief The SETTINGS struct bundles the configuration options.
85
 *
91
 *
86
 * This structure contains variables for all possible configuration options.
92
 * This structure contains variables for all possible configuration options.
Line 102... Line 108...
102
    string logFile;             //!< Optional path and name of a logfile
108
    string logFile;             //!< Optional path and name of a logfile
103
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
109
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
104
#ifdef QT_DEBUG
110
#ifdef QT_DEBUG
105
    string logLevel{"INFO|WARNING|ERROR|DEBUG"};   //!< The log level(s).
111
    string logLevel{"INFO|WARNING|ERROR|DEBUG"};   //!< The log level(s).
106
    uint logLevelBits{HLOG_INFO|HLOG_WARNING|HLOG_ERROR|HLOG_DEBUG};//!< The numeric bit field of the loglevel
112
    uint logLevelBits{HLOG_INFO|HLOG_WARNING|HLOG_ERROR|HLOG_DEBUG};//!< The numeric bit field of the loglevel
107
#else
113
#else   // QT_DEBUG
108
    string logLevel{"NONE"};   //!< The log level(s).
114
    string logLevel{"NONE"};   //!< The log level(s).
109
    uint logLevelBits{HLOG_NONE};//!< The numeric bit field of the loglevel
115
    uint logLevelBits{HLOG_NONE};//!< The numeric bit field of the loglevel
110
#endif
116
#endif  // QT_DEBUG
111
#else
117
#else
112
    string logLevel{"PROTOCOL"};//!< The log level(s).
118
    string logLevel{"PROTOCOL"};//!< The log level(s).
113
    uint logLevelBits{HLOG_PROTOCOL};//!< The numeric bit field of the loglevel
119
    uint logLevelBits{HLOG_PROTOCOL};//!< The numeric bit field of the loglevel
-
 
120
    vector<_APPS_t> apps;
114
#endif
121
#endif
115
    bool longformat{false};     //!< TRUE = long format
122
    bool longformat{false};     //!< TRUE = long format
116
    bool noBanner{false};       //!< Startup without showing a banner on the command line.
123
    bool noBanner{false};       //!< Startup without showing a banner on the command line.
117
    bool certCheck{false};      //!< TRUE = Check certificate for SSL connection
124
    bool certCheck{false};      //!< TRUE = Check certificate for SSL connection
118
    bool scale{false};          //!< TRUE = Images are scaled to fit the whole screen
125
    bool scale{false};          //!< TRUE = Images are scaled to fit the whole screen
Line 1237... Line 1244...
1237
        localSettings.sip_enabled = state;
1244
        localSettings.sip_enabled = state;
1238
 
1245
 
1239
    mTemporary = false;
1246
    mTemporary = false;
1240
}
1247
}
1241
 
1248
 
-
 
1249
string TConfig::getApp(const string& id)
-
 
1250
{
-
 
1251
    DECL_TRACER("TConfig::getApp(const string& id)");
-
 
1252
 
-
 
1253
    if (localSettings.apps.empty())
-
 
1254
        return string();
-
 
1255
 
-
 
1256
    vector<_APPS_t>::iterator iter;
-
 
1257
 
-
 
1258
    for (iter = localSettings.apps.begin(); iter != localSettings.apps.end(); ++iter)
-
 
1259
    {
-
 
1260
        if (iter->appID == id)
-
 
1261
            return iter->path;
-
 
1262
    }
-
 
1263
 
-
 
1264
    return string();
-
 
1265
}
-
 
1266
 
1242
bool TConfig::saveSettings()
1267
bool TConfig::saveSettings()
1243
{
1268
{
1244
    DECL_TRACER("TConfig::saveSettings()");
1269
    DECL_TRACER("TConfig::saveSettings()");
1245
 
1270
 
1246
    TLock<std::mutex> guard(config_mutex);
1271
    TLock<std::mutex> guard(config_mutex);
Line 1303... Line 1328...
1303
        lines += string("SIP_IPV4=") + (localSettings.sip_ipv4 ? "true" : "false") + "\n";
1328
        lines += string("SIP_IPV4=") + (localSettings.sip_ipv4 ? "true" : "false") + "\n";
1304
        lines += string("SIP_IPV6=") + (localSettings.sip_ipv6 ? "true" : "false") + "\n";
1329
        lines += string("SIP_IPV6=") + (localSettings.sip_ipv6 ? "true" : "false") + "\n";
1305
        lines += string("SIP_IPHONE=") + (localSettings.sip_iphone ? "true" : "false") + "\n";
1330
        lines += string("SIP_IPHONE=") + (localSettings.sip_iphone ? "true" : "false") + "\n";
1306
        lines += "SIP_FIREWALL=" + sipFirewallToString(localSettings.sip_firewall) + "\n";
1331
        lines += "SIP_FIREWALL=" + sipFirewallToString(localSettings.sip_firewall) + "\n";
1307
        lines += string("SIP_ENABLED=") + (localSettings.sip_enabled ? "true" : "false") + "\n";
1332
        lines += string("SIP_ENABLED=") + (localSettings.sip_enabled ? "true" : "false") + "\n";
-
 
1333
 
-
 
1334
        if (!localSettings.apps.empty())
-
 
1335
        {
-
 
1336
            vector<_APPS_t>::iterator iter;
-
 
1337
 
-
 
1338
            for (iter = localSettings.apps.begin(); iter != localSettings.apps.end(); ++iter)
-
 
1339
                lines += "APP=" + iter->appID + ";" + iter->path + "\n";
-
 
1340
        }
-
 
1341
 
1308
        file.write(lines.c_str(), lines.size());
1342
        file.write(lines.c_str(), lines.size());
1309
        file.close();
1343
        file.close();
1310
        MSG_INFO("Actual log level: " << localSettings.logLevel);
1344
        MSG_INFO("Actual log level: " << localSettings.logLevel);
1311
 
1345
 
1312
        if (mTemporary)
1346
        if (mTemporary)
Line 1709... Line 1743...
1709
    content += "SIP_IPV6=" + string(localSettings.sip_ipv6 ? "TRUE" : "FALSE") + "\n";
1743
    content += "SIP_IPV6=" + string(localSettings.sip_ipv6 ? "TRUE" : "FALSE") + "\n";
1710
    content += "SIP_IPHONE=" + string(localSettings.sip_iphone ? "TRUE" : "FALSE") + "\n";
1744
    content += "SIP_IPHONE=" + string(localSettings.sip_iphone ? "TRUE" : "FALSE") + "\n";
1711
    content += "SIP_FIREWALL=" + sipFirewallToString(localSettings.sip_firewall) + "\n";
1745
    content += "SIP_FIREWALL=" + sipFirewallToString(localSettings.sip_firewall) + "\n";
1712
    content += "SIP_ENABLED=" + string(localSettings.sip_ipv6 ? "TRUE" : "FALSE") + "\n";
1746
    content += "SIP_ENABLED=" + string(localSettings.sip_ipv6 ? "TRUE" : "FALSE") + "\n";
1713
 
1747
 
-
 
1748
#ifdef __linux__
-
 
1749
    content += string("APP=Calculator;/usr/bin/kcalc\n");
-
 
1750
    content += string("APP=PDF Viewer;/usr/bin/okular\n");
-
 
1751
    content += string("APP=Browser;/usr/bin/firefox\n");
-
 
1752
    content += string("APP=Calendar;/usr/bin/kalendar\n");
-
 
1753
    content += string("APP=Contacts;/usr/bin/kaddressbook\n");
-
 
1754
    content += string("APP=Email;/usr/bin/kmail\n");
-
 
1755
    content += string("APP=FileBrowser;/usr/bin/dolphin\n");
-
 
1756
    content += string("APP=Gallery;/usr/bin/gwenview\n");
-
 
1757
    content += string("APP=Excel Viewer;/usr/bin/libreoffice --calc\n");
-
 
1758
    content += string("APP=PowerPoint Viewer;/usr/bin/libreoffice --impress\n");
-
 
1759
    content += string("APP=Word Viewer;/usr/bin/libreoffice --writer\n");
-
 
1760
#endif
1714
    return content;
1761
    return content;
1715
}
1762
}
1716
 
1763
 
1717
/**
1764
/**
1718
 * @brief TConfig::findConfig search for the location of the configuration file.
1765
 * @brief TConfig::findConfig search for the location of the configuration file.
Line 2280... Line 2327...
2280
                localSettings.sip_iphone = isTrue(right);
2327
                localSettings.sip_iphone = isTrue(right);
2281
            else if (caseCompare(left, "SIP_FIREWALL") == 0 && !right.empty())
2328
            else if (caseCompare(left, "SIP_FIREWALL") == 0 && !right.empty())
2282
                localSettings.sip_firewall = sipFirewallStrToEnum(right);
2329
                localSettings.sip_firewall = sipFirewallStrToEnum(right);
2283
            else if (caseCompare(left, "SIP_ENABLED") == 0 && !right.empty())
2330
            else if (caseCompare(left, "SIP_ENABLED") == 0 && !right.empty())
2284
                localSettings.sip_enabled = isTrue(right);
2331
                localSettings.sip_enabled = isTrue(right);
-
 
2332
            else if (caseCompare(left, "APP") == 0 && !right.empty())
-
 
2333
            {
-
 
2334
                _APPS_t app;
-
 
2335
                vector<string> parts = StrSplit(right, ";");
-
 
2336
 
-
 
2337
                if (parts.size() >= 2)
-
 
2338
                {
-
 
2339
                    app.appID = parts[0];
-
 
2340
                    app.path = parts[1];
-
 
2341
                    localSettings.apps.push_back(app);
-
 
2342
                }
-
 
2343
            }
2285
        }
2344
        }
2286
    }
2345
    }
2287
 
2346
 
2288
    fs.close();
2347
    fs.close();
2289
    mInitialized = true;
2348
    mInitialized = true;
Line 2355... Line 2414...
2355
        MSG_INFO("    SIP IPv4:     " << (localSettings.sip_ipv4 ? "YES" : "NO"));
2414
        MSG_INFO("    SIP IPv4:     " << (localSettings.sip_ipv4 ? "YES" : "NO"));
2356
        MSG_INFO("    SIP IPv6:     " << (localSettings.sip_ipv6 ? "YES" : "NO"));
2415
        MSG_INFO("    SIP IPv6:     " << (localSettings.sip_ipv6 ? "YES" : "NO"));
2357
        MSG_INFO("    SIP Int.Phone:" << (localSettings.sip_iphone ? "YES" : "NO"));
2416
        MSG_INFO("    SIP Int.Phone:" << (localSettings.sip_iphone ? "YES" : "NO"));
2358
        MSG_INFO("    SIP firewall: " << sipFirewallToString(localSettings.sip_firewall));
2417
        MSG_INFO("    SIP firewall: " << sipFirewallToString(localSettings.sip_firewall));
2359
        MSG_INFO("    SIP enabled:  " << (localSettings.sip_enabled ? "YES" : "NO"));
2418
        MSG_INFO("    SIP enabled:  " << (localSettings.sip_enabled ? "YES" : "NO"));
-
 
2419
 
-
 
2420
        if (!localSettings.apps.empty())
-
 
2421
        {
-
 
2422
            vector<_APPS_t>::iterator iter;
-
 
2423
 
-
 
2424
            for (iter = localSettings.apps.begin(); iter != localSettings.apps.end(); ++iter)
-
 
2425
            {
-
 
2426
                MSG_INFO("    Appl.:        " << iter->appID << "; " << iter->path);
-
 
2427
            }
-
 
2428
        }
2360
    }
2429
    }
2361
 
2430
 
2362
    localSettings_temp = localSettings;
2431
    localSettings_temp = localSettings;
2363
#endif
2432
#endif
2364
    return true;
2433
    return true;