~ubuntu-branches/ubuntu/trusty/xiphos/trusty

« back to all changes in this revision

Viewing changes to src/backend/sword_main.cc

  • Committer: Bazaar Package Importer
  • Author(s): Dmitrijs Ledkovs, Jonathan Marsden, Dmitrijs Ledkovs
  • Date: 2010-11-25 21:26:48 UTC
  • mfrom: (2.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20101125212648-mc64wvs0nw3xp7bx
Tags: 3.1.4-1
[ Jonathan Marsden ]
* New upstream release 3.1.4
* Removed debian/patch/* since the one patch was included upstream.
* Bumped Standards-Version to 3.9.1 (no changes required).
* debian/README.Debian: Corrected spelling and reworded for clarity.
* debian/control: Add Jonathan Marsden back into Uploaders.

[ Dmitrijs Ledkovs ]
* Added local options dpkg-source to unapply patches and fail on
  upstream source changes (ignoring false positives).
* Added bzr-builddeb hook to generate source-format before build. If you
  are not using bzr-builddeb, you must run "./debian/rules clean" before
  building.
* patches/xul-2.0.patch: bump UPPER_RANGE to allow running against xul20.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Xiphos Bible Study Tool
3
3
 * sword_main.cc -
4
4
 *
5
 
 * Copyright (C) 2000-2009 Xiphos Developer Team
 
5
 * Copyright (C) 2000-2010 Xiphos Developer Team
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify
8
8
 * it under the terms of the GNU General Public License as published by
22
22
#include <config.h>
23
23
#endif
24
24
 
 
25
#include <set>
 
26
 
25
27
#include <swmgr.h>
26
28
#include <swmodule.h>
27
29
#include <localemgr.h>
256
258
{
257
259
        SWModule *mod;
258
260
        ModMap::iterator it;
259
 
        //-- iterate through the modules until we find modName
 
261
 
260
262
        it = main_mgr->Modules.find(module_name);
261
 
        //-- if we find the module
262
263
        if (it != main_mgr->Modules.end()) {
263
264
                mod = (*it).second;
264
265
                return mod->getConfig().has("GlobalOptionFilter", option);
272
273
                return NULL;
273
274
        SWModule *mod;
274
275
        ModMap::iterator it;
275
 
        //-- iterate through the modules until we find modName
 
276
 
276
277
        it = main_mgr->Modules.find(module_name);
277
 
        //-- if we find the module
278
278
        if (it != main_mgr->Modules.end()) {
279
279
                mod = (*it).second;
280
 
                //GS_message(("get_config_entry: %s",mod->getConfigEntry(entry)));
281
280
                return g_strdup((char *) mod->getConfigEntry(entry));
282
281
        } else
283
282
                return NULL;
302
301
{
303
302
        SWModule *mod;
304
303
        ModMap::iterator it;
305
 
        //-- iterate through the modules until we find modName
 
304
 
306
305
        it = main_mgr->Modules.find(module_name);
307
 
        //-- if we find the module
308
306
        if (it != main_mgr->Modules.end()) {
309
307
                mod = (*it).second;
310
308
                mod->setKey(key);
317
315
{
318
316
        SWModule *mod;
319
317
        ModMap::iterator it;
320
 
        //-- iterate through the modules until we find modName
 
318
 
321
319
        it = main_mgr->Modules.find(module_name);
322
 
        //-- if we find the module
323
320
        if (it != main_mgr->Modules.end()) {
324
321
                mod = (*it).second;
325
322
                mod->setKey(key);
332
329
{
333
330
        SWModule *mod;
334
331
        ModMap::iterator it;
335
 
        //-- iterate through the modules until we find modName
 
332
 
336
333
        it = main_mgr->Modules.find(module_name);
337
 
        //-- if we find the module
338
334
        if (it != main_mgr->Modules.end()) {
339
335
                mod = (*it).second;
340
336
                return strdup((char *) mod->RenderText(text));
346
342
{
347
343
        SWModule *mod;
348
344
        ModMap::iterator it;
349
 
        //-- iterate through the modules until we find modName
 
345
 
350
346
        it = main_mgr->Modules.find(module_name);
351
 
        //-- if we find the module
352
347
        if (it != main_mgr->Modules.end()) {
353
348
                mod = (*it).second;
354
349
                return strdup((char *) mod->StripText(string));
359
354
{
360
355
        SWModule *mod;
361
356
        ModMap::iterator it;
362
 
        //-- iterate through the modules until we find modName
 
357
 
363
358
        it = main_mgr->Modules.find(module_name);
364
 
        //-- if we find the module
365
359
        if (it != main_mgr->Modules.end()) {
366
360
                mod = (*it).second;
367
361
                mod->setKey(key);
390
384
        vkey.AutoNormalize(1);
391
385
        vkey = key;
392
386
 
393
 
#ifdef SWORD_MULTIVERSE
394
387
        return strdup((char*)vkey.getBookName());
395
 
#else
396
 
        return strdup((char*)vkey.books[vkey.Testament() - 1][vkey.Book() -1].name);
397
 
#endif
398
388
}
399
389
 
400
390
 
420
410
        vkey.AutoNormalize(1);
421
411
        vkey = key;
422
412
 
423
 
#ifdef SWORD_MULTIVERSE
424
413
        return (vkey.getChapterMax());
425
 
#else
426
 
        char testament = vkey.Testament() ;
427
 
        char book = vkey.Book();
428
 
        return (vkey.books[testament-1][book-1].chapmax);
429
 
#endif
430
414
}
431
415
 
432
416
 
436
420
        vkey.AutoNormalize(1);
437
421
        vkey = key;
438
422
 
439
 
#ifdef SWORD_MULTIVERSE
440
423
        return (vkey.getVerseMax());
441
 
#else
442
 
        char testament = vkey.Testament() ;
443
 
        char book = vkey.Book();
444
 
        int chapter = vkey.Chapter();
445
 
        return (vkey.books[testament-1][book-1].versemax[chapter-1]);
446
 
#endif
447
424
}
448
425
 
449
426
 
484
461
const char *BackEnd::module_get_language(const char *module_name)
485
462
{
486
463
        ModMap::iterator it;
487
 
        //-- iterate through the modules until we find modName
488
464
        it = main_mgr->Modules.find(module_name);
489
 
        //-- if we find the module
490
465
        if (it != main_mgr->Modules.end())
491
466
                return main_get_language_map((*it).second->Lang());
492
467
        return "unknown";
493
468
}
494
469
 
495
470
 
 
471
char **BackEnd::get_module_language_list(void)
 
472
{
 
473
        char **retval;
 
474
        int i;
 
475
 
 
476
        std::set < SWBuf > module_languages;
 
477
        std::set < SWBuf > ::iterator  ml_it;
 
478
 
 
479
        // create a set of unique language names in use by modules.
 
480
        ModMap::iterator it;
 
481
        for (it = main_mgr->Modules.begin(); it != main_mgr->Modules.end(); it++)
 
482
                module_languages.insert((*it).second->Lang());
 
483
 
 
484
        // construct a list of char* from the uniquified set.
 
485
        retval = g_new0(char *, module_languages.size() + 1);
 
486
        for (i = 0, ml_it = module_languages.begin();
 
487
             ml_it != module_languages.end();
 
488
             ++i, ++ml_it) {
 
489
            retval[i] = g_strdup(ml_it->c_str());
 
490
        }
 
491
        return retval;
 
492
}
 
493
 
 
494
 
496
495
int BackEnd::is_module(const char *mod_name)
497
496
{
498
497
        if (mod_name == NULL)
510
509
        ModMap::iterator it;
511
510
        if ((!mod_name) || (strlen(mod_name) < 2))
512
511
                return -1;
513
 
        //-- iterate through the modules until we find modName
 
512
 
514
513
        it = main_mgr->Modules.find(mod_name);
515
 
        //-- if we find the module
516
514
        if (it != main_mgr->Modules.end()) {
517
515
 
518
516
                if (!strcmp((*it).second->Type(), TEXT_MODS)) {
545
543
 
546
544
        if ((!mod_name) || (strlen(mod_name) < 2))
547
545
                return NULL;
548
 
        //-- iterate through the modules until we find modName
 
546
 
549
547
        it = main_mgr->Modules.find(mod_name);
550
 
        //-- if we find the module
551
548
        if (it != main_mgr->Modules.end()) {
552
549
                return (*it).second->Description();
553
550
        }
682
679
        display_mod = main_mgr->Modules[module_name];
683
680
 
684
681
        if (display_mod) {
685
 
                GS_message((f_message,878,"key",key));
686
682
                display_mod->setKey(key);
687
683
                return 1;
688
684
        }
732
728
}
733
729
void BackEnd::set_treekey(unsigned long offset)
734
730
{
 
731
        if (!display_mod) {
 
732
                gui_generic_warning(_("Xiphos failure: \"can't happen\", display_mod: null"
 
733
                                      "\nPlease report this. sword_main.cc:set_treekey"
 
734
                                      "\nWhat were you doing when this occurred?"));
 
735
                return;
 
736
        }
735
737
        if (tree_key)
736
738
                delete tree_key;
737
739
        tree_key = (TreeKeyIdx *) display_mod->CreateKey();
751
753
        SWModule *mod;
752
754
        ModMap::iterator it;
753
755
        unsigned long retval = 0;
754
 
        //-- iterate through the modules until we find modName
 
756
 
755
757
        it = main_mgr->Modules.find(module_name);
756
 
        //-- if we find the module
757
758
        if (it != main_mgr->Modules.end()) {
758
759
                mod = (*it).second;
759
760
                TreeKeyIdx *tree_key_idx = (TreeKeyIdx *) mod->CreateKey();
809
810
{
810
811
        if (tree_key) {
811
812
                tree_key->setOffset(offset);
812
 
                //-- returned value must be freed by calling function
813
813
                return strdup((char *) tree_key->getLocalName());
814
814
        }
815
815
        return NULL;