Subversion Repositories tpanel

Rev

Rev 235 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 235 Rev 239
Line 28... Line 28...
28
#include "tpage.h"
28
#include "tpage.h"
29
#include "tsubpage.h"
29
#include "tsubpage.h"
30
#include "tpagemanager.h"
30
#include "tpagemanager.h"
31
#include "tqtmain.h"
31
#include "tqtmain.h"
32
 
32
 
33
#ifdef Q_OS_ANDROID
33
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
34
#include <QStandardPaths>
34
#include <QStandardPaths>
35
#endif
35
#endif
36
#ifdef __ANDROID__
36
#ifdef __ANDROID__
37
#include <android/log.h>
37
#include <android/log.h>
38
#endif
38
#endif
39
 
39
 
40
using std::string;
40
using std::string;
41
using std::find;
41
using std::find;
42
using std::vector;
42
using std::vector;
43
using std::cout;
43
using std::cout;
-
 
44
using std::cerr;
44
using std::endl;
45
using std::endl;
45
 
46
 
46
bool _restart_ = false;
47
bool _restart_ = false;
47
#ifdef __ANDROID__
48
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
48
extern std::atomic<bool> killed;
49
extern std::atomic<bool> killed;
49
extern std::atomic<bool> _netRunning;
50
extern std::atomic<bool> _netRunning;
50
#endif
51
#endif
51
 
52
 
52
/**
53
/**
Line 158... Line 159...
158
 * NOTE: This function is not available on Android systems.
159
 * NOTE: This function is not available on Android systems.
159
 * \endverbatim
160
 * \endverbatim
160
 */
161
 */
161
void usage()
162
void usage()
162
{
163
{
163
#ifndef __ANDROID__
164
#if not defined(Q_OS_ANDROID) && not defined(Q_OS_IOS)
164
    cout << TConfig::getProgName() << " version " <<  VERSION_STRING() << endl << endl;
165
    cout << TConfig::getProgName() << " version " <<  VERSION_STRING() << endl << endl;
165
    cout << "Usage: tpanel [-c <config file>]" << endl;
166
    cout << "Usage: tpanel [-c <config file>]" << endl;
166
    cout << "-c | --config-file <file> The path and name of the configuration file." << endl;
167
    cout << "-c | --config-file <file> The path and name of the configuration file." << endl;
167
    cout << "                          This parameter is optional. If it is omitted," << endl;
168
    cout << "                          This parameter is optional. If it is omitted," << endl;
168
    cout << "                          The standard path is searched for the" << endl;
169
    cout << "                          The standard path is searched for the" << endl;
169
    cout << "                          configuration file." << endl << endl;
170
    cout << "                          configuration file." << endl << endl;
170
    cout << "-h | --help               This help." << endl << endl;
171
    cout << "-h | --help               This help." << endl << endl;
171
#endif
172
#endif
172
}
173
}
173
 
174
 
174
#ifndef __ANDROID__
175
#if not defined(Q_OS_ANDROID) && not defined(Q_OS_IOS)
175
/**
176
/**
176
 * @brief banner displays a shor banner with informations about this application.
177
 * @brief banner displays a shor banner with informations about this application.
177
 *
178
 *
178
 * This function shows a short information about this application. It prints
179
 * This function shows a short information about this application. It prints
179
 * this on the standard output.
180
 * this on the standard output.
Line 207... Line 208...
207
 * @param argc      This is the actual parameter counter.
208
 * @param argc      This is the actual parameter counter.
208
 * @param argv      This is the pointer array to the environment.
209
 * @param argv      This is the pointer array to the environment.
209
 *
210
 *
210
 * @return of success TRUE is returned. Otherwise FALSE.
211
 * @return of success TRUE is returned. Otherwise FALSE.
211
 */
212
 */
212
#ifndef __ANDROID__
213
#if not defined(Q_OS_ANDROID) && not defined(Q_OS_IOS)
213
bool _startUp(int oldArgc, int argc, char *argv[])
214
bool _startUp(int oldArgc, int argc, char *argv[])
214
#else
215
#else
215
bool _startUp(int, int argc, char *argv[])
216
bool _startUp(int, int argc, char *argv[])
216
#endif
217
#endif
217
{
218
{
Line 219... Line 220...
219
 
220
 
220
    TPageManager *pageManager = new TPageManager;
221
    TPageManager *pageManager = new TPageManager;
221
 
222
 
222
    if (TError::isError())
223
    if (TError::isError())
223
    {
224
    {
-
 
225
        cerr << "FATAL: There was an unrecoverable error in creating the page manager!" << endl;
224
        delete pageManager;
226
        delete pageManager;
225
        pageManager = nullptr;
227
        pageManager = nullptr;
226
        return false;
228
        return false;
227
    }
229
    }
228
 
230
 
229
    // Prepare command line stack
231
    // Prepare command line stack
230
#ifndef __ANDROID__
232
#if not defined(Q_OS_ANDROID) && not defined(Q_OS_IOS)
231
    int pt = oldArgc - argc;
233
    int pt = oldArgc - argc;
232
#else
234
#else
233
    int pt = 0;
235
    int pt = 0;
234
#endif
236
#endif
235
    // Start the graphical environment
237
    // Start the graphical environment
236
    int ret = 0;
238
    int ret = 0;
237
 
-
 
238
    // The _restart_ variable is reset in class initialization MainWindow.
239
    // The _restart_ variable is reset in class initialization MainWindow.
239
    ret = qtmain(argc, &argv[pt], pageManager);
240
    ret = qtmain(argc, &argv[pt], pageManager);
240
    delete pageManager;
241
    delete pageManager;
241
    pageManager = nullptr;
242
    pageManager = nullptr;
242
 
243
 
Line 260... Line 261...
260
 */
261
 */
261
int main(int argc, char *argv[])
262
int main(int argc, char *argv[])
262
{
263
{
263
    string configFile;
264
    string configFile;
264
    int oldArgc = argc;
265
    int oldArgc = argc;
265
#ifndef __ANDROID__
266
#if not defined(Q_OS_ANDROID) && not defined(Q_OS_IOS)
266
    string pname = *argv;
267
    string pname = *argv;
267
    size_t pos = pname.find_last_of("/");
268
    size_t pos = pname.find_last_of("/");
268
 
269
 
269
    if (pos != string::npos)
270
    if (pos != string::npos)
270
        pname = pname.substr(pos + 1);
271
        pname = pname.substr(pos + 1);
Line 272... Line 273...
272
    string pname = "tpanel";
273
    string pname = "tpanel";
273
    killed = false;
274
    killed = false;
274
    _netRunning = false;
275
    _netRunning = false;
275
#endif
276
#endif
276
    TConfig::setProgName(pname);    // Remember the name of this application.
277
    TConfig::setProgName(pname);    // Remember the name of this application.
277
#ifndef Q_OS_ANDROID
278
#if not defined(Q_OS_ANDROID) && not defined(Q_OS_IOS)
278
    InputParser input(&argc, argv); // Parse the command line parameters.
279
    InputParser input(&argc, argv); // Parse the command line parameters.
279
 
280
 
280
    // Evaluate the command line parameters.
281
    // Evaluate the command line parameters.
281
    if (input.cmdOptionExists("-h") || input.cmdOptionExists("--help"))
282
    if (input.cmdOptionExists("-h") || input.cmdOptionExists("--help"))
282
    {
283
    {
Line 310... Line 311...
310
        __android_log_print(ANDROID_LOG_ERROR, "tpanel", "%s", TError::getErrorMsg().c_str());
311
        __android_log_print(ANDROID_LOG_ERROR, "tpanel", "%s", TError::getErrorMsg().c_str());
311
#endif
312
#endif
312
        TError::displayMessage(TError::getErrorMsg());
313
        TError::displayMessage(TError::getErrorMsg());
313
        return 1;
314
        return 1;
314
    }
315
    }
315
#ifndef __ANDROID__
316
#if not defined(Q_OS_ANDROID) && not defined(Q_OS_IOS)
316
    banner(pname);
317
    banner(pname);
317
#endif
318
#endif
318
    TError::clear();
319
    TError::clear();
319
    // Start the page manager. This is the core class handling everything.
320
    // Start the page manager. This is the core class handling everything.
320
    try
321
    try