Subversion Repositories tpanel

Rev

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

Rev 88 Rev 113
Line 54... Line 54...
54
 
54
 
55
bool TTPInit::createPanelConfigs()
55
bool TTPInit::createPanelConfigs()
56
{
56
{
57
    DECL_TRACER("TTPInit::createPanelConfigs()");
57
    DECL_TRACER("TTPInit::createPanelConfigs()");
58
 
58
 
59
    bool err = false;
59
    vector<string> resFiles = {
60
    QFile external(":ressources/external.xma");
60
        ":ressources/external.xma",
61
 
61
        ":ressources/fnt.xma",
62
    if (external.exists())
62
        ":ressources/icon.xma",
63
    {
63
        ":ressources/_main.xml",
64
        QString path = mPath.c_str();
64
        ":ressources/manifest.xma",
65
        path += "/external.xma";
65
        ":ressources/map.xma",
66
 
66
        ":ressources/pal_001.xma",
67
        if (!external.copy(path))
67
        ":ressources/prj.xma",
68
        {
68
        ":ressources/_setup.xml",
69
#ifdef __ANDROID__
69
        ":ressources/table.xma",
70
            if (!askPermissions())
70
        ":ressources/fonts/arial.ttf",
71
            {
71
        ":ressources/images/theosys_logo.png",
72
                MSG_ERROR("Could not copy \"external.xma\" to " << path.toStdString());
72
        ":ressources/__system/graphics/fonts/amxbold_.ttf",
73
                err = true;
73
        ":ressources/__system/graphics/fonts/arialbd.ttf",
74
            }
74
        ":ressources/__system/graphics/fonts/arial.ttf",
75
            else if (!external.copy(path))
75
        ":ressources/__system/graphics/fonts/cour.ttf",
76
            {
76
        ":ressources/__system/graphics/sounds/audioTest.wav",
77
                MSG_ERROR("Could not copy \"external.xma\" to " << path.toStdString());
77
        ":ressources/__system/graphics/sounds/docked.mp3",
78
                err = true;
78
        ":ressources/__system/graphics/sounds/doubleBeep01.wav",
79
            }
79
        ":ressources/__system/graphics/sounds/doubleBeep02.wav",
80
#else
80
        ":ressources/__system/graphics/sounds/doubleBeep03.wav",
81
            MSG_ERROR("Could not copy \"external.xma\" to " << path.toStdString());
81
        ":ressources/__system/graphics/sounds/doubleBeep04.wav",
82
            err = true;
82
        ":ressources/__system/graphics/sounds/doubleBeep05.wav",
83
#endif
83
        ":ressources/__system/graphics/sounds/doubleBeep06.wav",
84
        }
84
        ":ressources/__system/graphics/sounds/doubleBeep07.wav",
85
    }
85
        ":ressources/__system/graphics/sounds/doubleBeep08.wav",
86
    else
86
        ":ressources/__system/graphics/sounds/doubleBeep09.wav",
87
    {
87
        ":ressources/__system/graphics/sounds/doubleBeep10.wav",
88
        MSG_ERROR("File " << external.fileName().toStdString() << " doesn't exist!");
88
        ":ressources/__system/graphics/sounds/doubleBeep.wav",
89
        err = true;
89
        ":ressources/__system/graphics/sounds/ringback.wav",
90
    }
90
        ":ressources/__system/graphics/sounds/ringtone.wav",
91
 
91
        ":ressources/__system/graphics/sounds/singleBeep01.wav",
92
    QFile fnt(":ressources/fnt.xma");
92
        ":ressources/__system/graphics/sounds/singleBeep02.wav",
93
 
93
        ":ressources/__system/graphics/sounds/singleBeep03.wav",
94
    if (fnt.exists())
94
        ":ressources/__system/graphics/sounds/singleBeep04.wav",
95
    {
95
        ":ressources/__system/graphics/sounds/singleBeep05.wav",
96
        QString path = mPath.c_str();
96
        ":ressources/__system/graphics/sounds/singleBeep06.wav",
97
        path += "/fnt.xma";
97
        ":ressources/__system/graphics/sounds/singleBeep07.wav",
98
 
98
        ":ressources/__system/graphics/sounds/singleBeep08.wav",
99
        if (!fnt.copy(path))
99
        ":ressources/__system/graphics/sounds/singleBeep09.wav",
100
        {
100
        ":ressources/__system/graphics/sounds/singleBeep10.wav",
101
            MSG_ERROR("Could not copy \"fnt.xma\" to " << path.toStdString());
101
        ":ressources/__system/graphics/sounds/singleBeep.wav",
102
            err = true;
102
        ":ressources/__system/graphics/draw.xma",
103
        }
103
        ":ressources/__system/graphics/fnt.xma",
104
    }
104
        ":ressources/__system/graphics/version.xma"
105
    else
-
 
106
    {
-
 
107
        MSG_ERROR("File " << fnt.fileName().toStdString() << " doesn't exist!");
-
 
108
        err = true;
-
 
109
    }
-
 
110
 
-
 
111
    QFile icon(":ressources/icon.xma");
-
 
112
 
-
 
113
    if (icon.exists())
-
 
114
    {
-
 
115
        QString path = mPath.c_str();
-
 
116
        path += "/icon.xma";
-
 
117
 
-
 
118
        if (!icon.copy(path))
-
 
119
        {
-
 
120
            MSG_ERROR("Could not copy \"icon.xma\" to " << path.toStdString());
-
 
121
            err = true;
-
 
122
        }
-
 
123
    }
-
 
124
    else
-
 
125
    {
-
 
126
        MSG_ERROR("File " << icon.fileName().toStdString() << " doesn't exist!");
-
 
127
        err = true;
-
 
128
    }
-
 
129
 
-
 
130
    QFile _main(":ressources/_main.xml");
-
 
131
 
-
 
132
    if (_main.exists())
-
 
133
    {
-
 
134
        QString path = mPath.c_str();
-
 
135
        path += "/_main.xml";
-
 
136
 
-
 
137
        if (!_main.copy(path))
-
 
138
        {
-
 
139
            MSG_ERROR("Could not copy \"_main.xml\" to " << path.toStdString());
-
 
140
            err = true;
-
 
141
        }
-
 
142
    }
-
 
143
    else
-
 
144
    {
-
 
145
        MSG_ERROR("File " << _main.fileName().toStdString() << " doesn't exist!");
-
 
146
        err = true;
-
 
147
    }
-
 
148
 
-
 
149
    QFile manifest(":ressources/manifest.xma");
-
 
150
 
-
 
151
    if (manifest.exists())
-
 
152
    {
-
 
153
        QString path = mPath.c_str();
-
 
154
        path += "/manifest.xma";
-
 
155
 
-
 
156
        if (!manifest.copy(path))
-
 
157
        {
-
 
158
            MSG_ERROR("Could not copy \"manifest.xma\" to " << path.toStdString());
-
 
159
            err = true;
-
 
160
        }
-
 
161
    }
-
 
162
    else
-
 
163
    {
-
 
164
        MSG_ERROR("File " << manifest.fileName().toStdString() << " doesn't exist!");
-
 
165
        err = true;
-
 
166
    }
-
 
167
 
-
 
168
    QFile map(":ressources/map.xma");
-
 
169
 
-
 
170
    if (map.exists())
-
 
171
    {
-
 
172
        QString path = mPath.c_str();
-
 
173
        path += "/map.xma";
-
 
174
 
-
 
175
        if (!map.copy(path))
-
 
176
        {
-
 
177
            MSG_ERROR("Could not copy \"map.xma\" to " << path.toStdString());
-
 
178
            err = true;
-
 
179
        }
-
 
180
    }
-
 
181
    else
-
 
182
    {
-
 
183
        MSG_ERROR("File " << map.fileName().toStdString() << " doesn't exist!");
-
 
184
        err = true;
-
 
185
    }
-
 
186
 
-
 
187
    QFile pal(":ressources/pal_001.xma");
-
 
188
 
-
 
189
    if (pal.exists())
-
 
190
    {
-
 
191
        QString path = mPath.c_str();
-
 
192
        path += "/pal_001.xma";
-
 
193
 
-
 
194
        if (!pal.copy(path))
-
 
195
        {
-
 
196
            MSG_ERROR("Could not copy \"pal_001.xma\" to " << path.toStdString());
-
 
197
            err = true;
-
 
198
        }
-
 
199
    }
-
 
200
    else
-
 
201
    {
-
 
202
        MSG_ERROR("File " << pal.fileName().toStdString() << " doesn't exist!");
-
 
203
        err = true;
-
 
204
    }
-
 
205
 
-
 
206
    QFile prj(":ressources/prj.xma");
-
 
207
 
-
 
208
    if (prj.exists())
-
 
209
    {
-
 
210
        QString path = mPath.c_str();
-
 
211
        path += "/prj.xma";
-
 
212
 
-
 
213
        if (!prj.copy(path))
-
 
214
        {
-
 
215
            MSG_ERROR("Could not copy \"prj.xma\" to " << path.toStdString());
-
 
216
            err = true;
-
 
217
        }
-
 
218
    }
-
 
219
    else
-
 
220
    {
-
 
221
        MSG_ERROR("File " << prj.fileName().toStdString() << " doesn't exist!");
-
 
222
        err = true;
-
 
223
    }
-
 
224
 
-
 
225
    QFile _setup(":ressources/_setup.xml");
-
 
226
 
-
 
227
    if (_setup.exists())
-
 
228
    {
-
 
229
        QString path = mPath.c_str();
-
 
230
        path += "/_setup.xml";
-
 
231
 
-
 
232
        if (!_setup.copy(path))
-
 
233
        {
-
 
234
            MSG_ERROR("Could not copy \"_setup.xml\" to " << path.toStdString());
-
 
235
            err = true;
-
 
236
        }
-
 
237
    }
-
 
238
    else
-
 
239
    {
-
 
240
        MSG_ERROR("File " << _setup.fileName().toStdString() << " doesn't exist!");
-
 
241
        err = true;
-
 
242
    }
-
 
243
 
-
 
244
    QFile table(":ressources/table.xma");
-
 
245
 
-
 
246
    if (table.exists())
-
 
247
    {
-
 
248
        QString path = mPath.c_str();
-
 
249
        path += "/table.xma";
-
 
250
 
-
 
251
        if (!table.copy(path))
-
 
252
        {
-
 
253
            MSG_ERROR("Could not copy \"table.xma\" to " << path.toStdString());
-
 
254
            err = true;
-
 
255
        }
-
 
256
    }
-
 
257
    else
-
 
258
    {
-
 
259
        MSG_ERROR("File " << table.fileName().toStdString() << " doesn't exist!");
-
 
260
        err = true;
-
 
261
    }
-
 
262
 
-
 
263
    QFile fonts(":ressources/fonts/arial.ttf");
-
 
264
 
-
 
265
    if (fonts.exists())
-
 
266
    {
-
 
267
        QString path = mPath.c_str();
-
 
268
        path += "/fonts/arial.ttf";
-
 
269
 
-
 
270
        if (!fonts.copy(path))
-
 
271
        {
-
 
272
#ifdef __ANDROID__
-
 
273
            if (!askPermissions())
-
 
274
            {
-
 
275
                MSG_ERROR("Could not copy \"arial.ttf\" to " << path.toStdString());
-
 
276
                err = true;
-
 
277
            }
-
 
278
            else if (!fonts.copy(path))
-
 
279
            {
-
 
280
                MSG_ERROR("Could not copy \"arial.ttf\" to " << path.toStdString());
-
 
281
                err = true;
-
 
282
            }
-
 
283
#else
-
 
284
        MSG_ERROR("Could not copy \"arial.ttf\" to " << path.toStdString());
-
 
285
        err = true;
-
 
286
#endif
-
 
287
        }
-
 
288
    }
-
 
289
    else
-
 
290
    {
-
 
291
        MSG_ERROR("File " << fonts.fileName().toStdString() << " doesn't exist!");
-
 
292
        err = true;
-
 
293
    }
-
 
294
 
-
 
295
    QFile images(":ressources/images/theosys_logo.png");
-
 
296
 
-
 
297
    if (images.exists())
-
 
298
    {
-
 
299
        QString path = mPath.c_str();
-
 
300
        path += "/images/theosys_logo.png";
-
 
301
 
-
 
302
        if (!images.copy(path))
-
 
303
        {
-
 
304
#ifdef __ANDROID__
-
 
305
            if (!askPermissions())
-
 
306
            {
-
 
307
                MSG_ERROR("Could not copy \"theosys_logo.png\" to " << path.toStdString());
-
 
308
                err = true;
-
 
309
            }
-
 
310
            else if (!images.copy(path))
-
 
311
            {
-
 
312
                MSG_ERROR("Could not copy \"theosys_logo.png\" to " << path.toStdString());
-
 
313
                err = true;
-
 
314
            }
-
 
315
#else
-
 
316
        MSG_ERROR("Could not copy \"theosys_logo.png\" to " << path.toStdString());
-
 
317
        err = true;
-
 
318
#endif
-
 
319
        }
-
 
320
    }
-
 
321
    else
-
 
322
    {
-
 
323
        MSG_ERROR("File " << images.fileName().toStdString() << " doesn't exist!");
-
 
324
        err = true;
-
 
325
    }
-
 
326
 
-
 
327
    vector<QString> sysFonts = {
-
 
328
        "/__system/graphics/fonts/amxbold_.ttf",
-
 
329
        "/__system/graphics/fonts/arialbd.ttf",
-
 
330
        "/__system/graphics/fonts/arial.ttf",
-
 
331
        "/__system/graphics/fonts/cour.ttf"
-
 
332
    };
105
    };
333
 
106
 
334
    vector<QString>::iterator iter;
-
 
335
 
-
 
336
    for (iter = sysFonts.begin(); iter != sysFonts.end(); ++iter)
-
 
337
    {
-
 
338
        QFile sys;
-
 
339
        sys.setFileName(":ressources" + *iter);
-
 
340
 
-
 
341
        if (sys.exists())
-
 
342
        {
-
 
343
            QString path = mPath.c_str();
-
 
344
            path += *iter;
-
 
345
 
-
 
346
            if (!sys.copy(path))
-
 
347
            {
-
 
348
                MSG_ERROR("Could not copy \":ressources" << iter->toStdString() << "\" to " << path.toStdString());
-
 
349
                err = true;
107
    bool err = false;
350
            }
-
 
351
        }
-
 
352
 
-
 
353
        if (sys.isOpen())
-
 
354
            sys.close();
-
 
355
    }
-
 
356
 
-
 
357
    vector<QString> sounds = {
108
    vector<string>::iterator iter;
358
        "/__system/graphics/sounds/audioTest.wav",
-
 
359
        "/__system/graphics/sounds/docked.mp3",
-
 
360
        "/__system/graphics/sounds/doubleBeep01.wav",
-
 
361
        "/__system/graphics/sounds/doubleBeep02.wav",
-
 
362
        "/__system/graphics/sounds/doubleBeep03.wav",
-
 
363
        "/__system/graphics/sounds/doubleBeep04.wav",
-
 
364
        "/__system/graphics/sounds/doubleBeep05.wav",
-
 
365
        "/__system/graphics/sounds/doubleBeep06.wav",
-
 
366
        "/__system/graphics/sounds/doubleBeep07.wav",
-
 
367
        "/__system/graphics/sounds/doubleBeep08.wav",
-
 
368
        "/__system/graphics/sounds/doubleBeep09.wav",
-
 
369
        "/__system/graphics/sounds/doubleBeep10.wav",
-
 
370
        "/__system/graphics/sounds/doubleBeep.wav",
-
 
371
        "/__system/graphics/sounds/ringback.wav",
-
 
372
        "/__system/graphics/sounds/ringtone.wav",
-
 
373
        "/__system/graphics/sounds/singleBeep01.wav",
-
 
374
        "/__system/graphics/sounds/singleBeep02.wav",
-
 
375
        "/__system/graphics/sounds/singleBeep03.wav",
-
 
376
        "/__system/graphics/sounds/singleBeep04.wav",
-
 
377
        "/__system/graphics/sounds/singleBeep05.wav",
-
 
378
        "/__system/graphics/sounds/singleBeep06.wav",
-
 
379
        "/__system/graphics/sounds/singleBeep07.wav",
-
 
380
        "/__system/graphics/sounds/singleBeep08.wav",
-
 
381
        "/__system/graphics/sounds/singleBeep09.wav",
-
 
382
        "/__system/graphics/sounds/singleBeep10.wav",
-
 
383
        "/__system/graphics/sounds/singleBeep.wav"
-
 
384
    };
-
 
385
 
109
 
386
    for (iter = sounds.begin(); iter != sounds.end(); ++iter)
110
    for (iter = resFiles.begin(); iter != resFiles.end(); ++iter)
387
    {
111
    {
388
        QFile sysSounds;
-
 
389
        sysSounds.setFileName(":ressources" + *iter);
-
 
390
 
-
 
391
        if (sysSounds.exists())
112
        if (!copyFile(*iter))
392
        {
-
 
393
            QString path = mPath.c_str();
-
 
394
            path += *iter;
-
 
395
 
-
 
396
            if (!sysSounds.copy(path))
-
 
397
            {
-
 
398
                MSG_ERROR("Could not copy \"" << iter->toStdString() << "\" to " << path.toStdString());
-
 
399
                err = true;
113
            err = true;
400
            }
-
 
401
        }
-
 
402
 
-
 
403
        if (sysSounds.isOpen())
-
 
404
            sysSounds.close();
-
 
405
    }
114
    }
406
 
115
 
407
    vector<QString> sysSettings = {
-
 
408
        "/__system/graphics/draw.xma",
-
 
409
        "/__system/graphics/fnt.xma",
-
 
410
        "/__system/graphics/version.xma"
-
 
411
    };
-
 
412
 
-
 
413
    for (iter = sysSettings.begin(); iter != sysSettings.end(); ++iter)
-
 
414
    {
-
 
415
        QFile sys;
-
 
416
        sys.setFileName(":ressources" + *iter);
-
 
417
 
-
 
418
        if (sys.exists())
-
 
419
        {
-
 
420
            QString path = mPath.c_str();
-
 
421
            path += *iter;
-
 
422
 
-
 
423
            if (!sys.copy(path))
-
 
424
            {
-
 
425
                MSG_ERROR("Could not copy \"" << iter->toStdString() << "\" to " << path.toStdString());
-
 
426
                err = true;
-
 
427
            }
-
 
428
        }
-
 
429
 
-
 
430
        if (sys.isOpen())
-
 
431
            sys.close();
-
 
432
    }
-
 
433
 
116
 
434
    return err;
117
    return err;
435
}
118
}
436
 
119
 
437
bool TTPInit::createDirectoryStructure()
120
bool TTPInit::createDirectoryStructure()
Line 523... Line 206...
523
    }
206
    }
524
 
207
 
525
    return true;
208
    return true;
526
}
209
}
527
 
210
 
-
 
211
bool TTPInit::copyFile(const std::string& fname)
-
 
212
{
-
 
213
    DECL_TRACER("TTPInit::copyFile(const std::string& fname)");
-
 
214
 
-
 
215
    bool err = false;
-
 
216
    QFile external(fname.c_str());
-
 
217
    size_t pos = fname.find_first_of("/");
-
 
218
    string bname;
-
 
219
 
-
 
220
    if (pos != string::npos)
-
 
221
        bname = fname.substr(pos);
-
 
222
    else
-
 
223
        bname = fname;
-
 
224
 
-
 
225
    if (external.exists())
-
 
226
    {
-
 
227
        QString path = mPath.c_str();
-
 
228
        path += bname.c_str();
-
 
229
 
-
 
230
        if (!external.copy(path))
-
 
231
        {
-
 
232
#ifdef __ANDROID__
-
 
233
            if (!askPermissions())
-
 
234
            {
-
 
235
                MSG_ERROR("Could not copy \"" << bname << "\" to " << path.toStdString() << " because permission was denied!");
-
 
236
                err = true;
-
 
237
            }
-
 
238
            else if (!external.copy(path))
-
 
239
            {
-
 
240
                MSG_ERROR("Could not copy \"" << bname << "\" to " << path.toStdString());
-
 
241
                err = true;
-
 
242
            }
-
 
243
#else
-
 
244
            MSG_ERROR("Could not copy \"" << bname << "\" to " << path.toStdString());
-
 
245
            err = true;
-
 
246
#endif
-
 
247
        }
-
 
248
    }
-
 
249
    else
-
 
250
    {
-
 
251
        MSG_ERROR("File " << external.fileName().toStdString() << " doesn't exist!");
-
 
252
        err = true;
-
 
253
    }
-
 
254
 
-
 
255
    return err;
-
 
256
}
-
 
257
 
528
#ifdef __ANDROID__
258
#ifdef __ANDROID__
529
bool TTPInit::askPermissions()
259
bool TTPInit::askPermissions()
530
{
260
{
531
    DECL_TRACER("TTPInit::askPermissions(const std::string& path)");
261
    DECL_TRACER("TTPInit::askPermissions(const std::string& path)");
532
 
262