Subversion Repositories tpanel

Rev

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

Rev 21 Rev 22
Line 26... Line 26...
26
#include "tpage.h"
26
#include "tpage.h"
27
#include "tsubpage.h"
27
#include "tsubpage.h"
28
#include "tpagemanager.h"
28
#include "tpagemanager.h"
29
#include "tqtmain.h"
29
#include "tqtmain.h"
30
 
30
 
-
 
31
#ifdef Q_OS_ANDROID
-
 
32
#include <QStandardPaths>
-
 
33
#endif
-
 
34
#ifdef __ANDROID__
-
 
35
#include <android/log.h>
-
 
36
#endif
-
 
37
 
31
using std::string;
38
using std::string;
32
using std::find;
39
using std::find;
33
using std::vector;
40
using std::vector;
34
using std::cout;
41
using std::cout;
35
using std::endl;
42
using std::endl;
Line 154... Line 161...
154
    cout << "                          configuration file." << endl << endl;
161
    cout << "                          configuration file." << endl << endl;
155
    cout << "-h | --help               This help." << endl << endl;
162
    cout << "-h | --help               This help." << endl << endl;
156
#endif
163
#endif
157
}
164
}
158
 
165
 
-
 
166
#ifndef __ANDROID__
159
/**
167
/**
160
 * @brief banner displays a shor banner with informations about this application.
168
 * @brief banner displays a shor banner with informations about this application.
161
 *
169
 *
162
 * This function shows a short information about this application. It prints
170
 * This function shows a short information about this application. It prints
163
 * this on the standard output.
171
 * this on the standard output.
Line 167... Line 175...
167
 *
175
 *
168
 * @param pname The name of this application.
176
 * @param pname The name of this application.
169
 */
177
 */
170
void banner(const string& pname)
178
void banner(const string& pname)
171
{
179
{
172
#ifdef __ANDROID__
-
 
173
    return;
180
    return;
174
#else
-
 
175
    if (!TConfig::showBanner())
181
    if (!TConfig::showBanner())
176
        return;
182
        return;
177
 
183
 
178
    cout << pname << " v" << V_MAJOR << "."  << V_MINOR << "." << V_PATCH << endl;
184
    cout << pname << " v" << V_MAJOR << "."  << V_MINOR << "." << V_PATCH << endl;
179
    cout << "(C) Andreas Theofilu <andreas@theosys.at>" << endl;
185
    cout << "(C) Andreas Theofilu <andreas@theosys.at>" << endl;
180
    cout << "This program is under the terms of GPL version 3" << endl << endl;
186
    cout << "This program is under the terms of GPL version 3" << endl << endl;
181
#endif
-
 
182
}
187
}
-
 
188
#endif
183
 
189
 
184
/**
190
/**
185
 * @brief main is the main entry function.
191
 * @brief main is the main entry function.
186
 *
192
 *
187
 * This is where the program starts.
193
 * This is where the program starts.
Line 194... Line 200...
194
 * In case of an error a number grater than 0 is returned.
200
 * In case of an error a number grater than 0 is returned.
195
 */
201
 */
196
int main(int argc, char *argv[])
202
int main(int argc, char *argv[])
197
{
203
{
198
    string configFile;
204
    string configFile;
199
 
-
 
-
 
205
#ifndef __ANDROID__
200
    string pname = *argv;
206
    string pname = *argv;
201
    size_t pos = pname.find_last_of("/");
207
    size_t pos = pname.find_last_of("/");
202
 
208
 
203
    if (pos != string::npos)
209
    if (pos != string::npos)
204
        pname = pname.substr(pos + 1);
210
        pname = pname.substr(pos + 1);
205
 
211
#else
-
 
212
    string pname = "tpanel";
-
 
213
#endif
206
    TConfig::setProgName(pname);    // Remember the name of this application.
214
    TConfig::setProgName(pname);    // Remember the name of this application.
207
 
-
 
-
 
215
#ifndef Q_OS_ANDROID
208
    int oldArgc = argc;
216
    int oldArgc = argc;
209
    InputParser input(&argc, argv); // Parse the command line parameters.
217
    InputParser input(&argc, argv); // Parse the command line parameters.
210
 
218
 
211
    // Evaluate the command line parameters.
219
    // Evaluate the command line parameters.
212
    if (input.cmdOptionExists("-h") || input.cmdOptionExists("--help"))
220
    if (input.cmdOptionExists("-h") || input.cmdOptionExists("--help"))
Line 229... Line 237...
229
            std::cerr << "Missing the path and name of the configuration file!" << std::endl;
237
            std::cerr << "Missing the path and name of the configuration file!" << std::endl;
230
            usage();
238
            usage();
231
            return 1;
239
            return 1;
232
        }
240
        }
233
    }
241
    }
234
 
242
#endif
235
    TError::clear();                    // Clear all errors (initialize)
243
    TError::clear();                    // Clear all errors (initialize)
236
    TConfig config(configFile);         // Read the configuration file.
244
    TConfig config(configFile);         // Read the configuration file.
237
 
245
 
238
    if (TError::isError())              // Exit if the previous command failed.
246
    if (TError::isError())              // Exit if the previous command failed.
-
 
247
    {
-
 
248
        TError::displayMessage(TError::getErrorMsg());
239
        return 1;
249
        return 1;
240
 
250
    }
-
 
251
#ifndef __ANDROID__
241
    banner(pname);
252
    banner(pname);
-
 
253
#endif
242
    TError::clear();
254
    TError::clear();
243
    // Read in the pages
255
    // Read in the pages
244
    TPageManager pageManager;
256
    TPageManager pageManager;
245
 
257
 
246
    if (TError::isError())
258
    if (TError::isError())
247
        return 1;
259
        return 1;
248
 
260
 
249
    // Prepare command line stack
261
    // Prepare command line stack
-
 
262
#ifndef __ANDROID__
250
    int pt = oldArgc - argc;
263
    int pt = oldArgc - argc;
-
 
264
#else
-
 
265
    int pt = 0;
-
 
266
#endif
251
    // Start the graphical environment
267
    // Start the graphical environment
252
 
268
 
253
    int ret = 0;
269
    int ret = 0;
254
 
270
 
255
    if ((ret = qtmain(argc, &argv[pt], &pageManager)) != 0)
271
    if ((ret = qtmain(argc, &argv[pt], &pageManager)) != 0)