~ubuntu-branches/debian/jessie/xiphos/jessie

« back to all changes in this revision

Viewing changes to src/backend/module_manager.cc

  • Committer: Bazaar Package Importer
  • Author(s): Dmitrijs Ledkovs
  • Date: 2010-03-22 18:15:54 UTC
  • mfrom: (4.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100322181554-qlqchymwhcw28c0c
* New upstream release:
  + Bugfix only
  + Compatible with xulrunner 1.9.2
  + Update translations

* Revert changes introduced in 3.1.2-1ubuntu1. Thank you Chris Coulson
  for temporary fix.
* debian/xiphos.1 - spelling mistake
* waf is now default buildsystem
* help is now licensed under GPL
* Bumped standards version no changes required
* Changed email to @ubuntu.com

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Xiphos Bible Study Tool
3
 
 * module_manager.cc 
 
3
 * module_manager.cc
4
4
 *
5
5
 * Copyright (C) 2000-2009 Xiphos Developer Team
6
6
 *
45
45
 
46
46
#include "gui/debug_glib_null.h"
47
47
 
48
 
#ifdef DEBUG 
 
48
#ifdef DEBUG
49
49
static const gchar *f_message = "backend/module_manager.cc line #%d \"%s\" = %s\n";
50
50
#endif
51
51
using namespace sword;
66
66
 * Synopsis
67
67
 *   #include "backend/module_manager.hh"
68
68
 *
69
 
 *   void StatusReporter::preStatus(long totalBytes, long completedBytes, 
 
69
 *   void StatusReporter::preStatus(long totalBytes, long completedBytes,
70
70
 *                                 const char *message)
71
71
 *
72
72
 * Description
73
 
 *   
 
73
 *
74
74
 *
75
75
 * Return value
76
76
 *   void
77
77
 */
78
78
 
79
79
void GSStatusReporter::preStatus(long totalBytes,
80
 
                                 long completedBytes, 
 
80
                                 long completedBytes,
81
81
                                 const char *message)
82
82
{
83
83
        GS_print((f_message,83,"message",message));
94
94
 *   void StatusReporter::statusUpdate(double dltotal, double dlnow)
95
95
 *
96
96
 * Description
97
 
 *   
 
97
 *
98
98
 *
99
99
 * Return value
100
100
 *   void
101
101
 */
102
102
 
103
103
void GSStatusReporter::statusUpdate(double dltotal,
104
 
                                    double dlnow) 
 
104
                                    double dlnow)
105
105
{
106
106
        if (!dltotal)
107
 
                return; 
 
107
                return;
108
108
        double filefraction  = (dlnow / dltotal);
109
109
        update_install_progress(filefraction);
110
110
}
111
111
 
112
112
 
113
 
ModuleManager::ModuleManager() {        
 
113
ModuleManager::ModuleManager() {
114
114
        const gchar *envhomedir = g_getenv(HOMEVAR);
115
115
        baseDir = (envhomedir) ? envhomedir : ".";
116
116
        baseDir += "/" DOTSWORD "/InstallMgr";
117
117
        statusReporter = new GSStatusReporter();
118
118
}
119
 
 
 
119
 
120
120
ModuleManager::~ModuleManager() {
121
 
        
 
121
 
122
122
}
123
123
 
124
124
char *backend_mod_mgr_get_config_entry(char *module_name,
125
125
                                       const char *entry) {
126
126
        SWModule *mod;
127
127
        ModMap::iterator it;    //-- iteratior
128
 
        //-- iterate through the modules until we find modName  
 
128
        //-- iterate through the modules until we find modName
129
129
        it = mgr->Modules.find(module_name);
130
130
        //-- if we find the module
131
131
        if (it != mgr->Modules.end()) {
153
153
 *   GList *backend_module_mgr_get_next_module()
154
154
 *
155
155
 * Description
156
 
 *   
 
156
 *
157
157
 *
158
158
 * Return value
159
159
 *   MOD_MGR *
163
163
{
164
164
        MOD_MGR *mod_info = NULL;
165
165
        SWModule *module;
166
 
        
 
166
 
167
167
        if (it != end) {
168
168
                module = it->second;
169
169
                mod_info = g_new(MOD_MGR, 1);
209
209
                        mod_info->installed =
210
210
                            backend_mod_mgr_is_module(name);
211
211
                        mod_info->description = module->Description();
212
 
                        mod_info->locked = 
 
212
                        mod_info->locked =
213
213
                            ((module->getConfigEntry("CipherKey")) ? 1 : 0);
214
 
                        it++;   
 
214
                        it++;
215
215
                        return (MOD_MGR *) mod_info;
216
216
                }
217
 
        } 
 
217
        }
218
218
        return NULL;
219
219
}
220
220
 
229
229
 *   GList *backend_module_mgr_remote_list_modules(const char *sourceName)
230
230
 *
231
231
 * Description
232
 
 *   
 
232
 *
233
233
 *
234
234
 * Return value
235
235
 *   GList *
259
259
 *   GList *backend_module_mgr_list_local_modules(const char *dir)
260
260
 *
261
261
 * Description
262
 
 *   
 
262
 *
263
263
 *
264
264
 * Return value
265
265
 *   GList *
288
288
 
289
289
 *
290
290
 * Description
291
 
 *   
 
291
 *
292
292
 *
293
293
 * Return value
294
294
 *   int
304
304
                tmp_mgr = new SWMgr(dir);
305
305
        else
306
306
                tmp_mgr = new SWMgr();
307
 
        
 
307
 
308
308
        ModMap::iterator it = tmp_mgr->Modules.find(modName);
309
309
        if (it == tmp_mgr->Modules.end()) {
310
310
                printf("Couldn't find module [%s] to remove\n",
329
329
 
330
330
 *
331
331
 * Description
332
 
 *   
 
332
 *
333
333
 *
334
334
 * Return value
335
335
 *   int
372
372
 *   int backend_local_install_module(const char *destdir, const char *srcdir, const char *mod_name)
373
373
 *
374
374
 * Description
375
 
 *   
 
375
 *
376
376
 *
377
377
 * Return value
378
378
 *   int
398
398
 *   GList *backend_module_mgr_list_remote_sources(void)
399
399
 *
400
400
 * Description
401
 
 *   
 
401
 *
402
402
 *
403
403
 * Return value
404
404
 *   GList *
421
421
#else
422
422
        InstallMgr *inst_mgr = new InstallMgr(baseDir);
423
423
#endif
424
 
        
 
424
 
425
425
        for (InstallSourceMap::iterator it =
426
426
             inst_mgr->sources.begin();
427
427
             it != inst_mgr->sources.end(); it++) {
456
456
 *   GList *backend_module_mgr_list_local_sources(void)
457
457
 *
458
458
 * Description
459
 
 *   
 
459
 *
460
460
 *
461
461
 * Return value
462
462
 *   GList *
465
465
GList *backend_module_mgr_list_local_sources(void)
466
466
{
467
467
        MOD_MGR_SOURCE *mms;
468
 
        GList *retval = NULL;   
 
468
        GList *retval = NULL;
469
469
        const gchar *envhomedir = g_getenv(HOMEVAR);
470
470
        SWBuf confPath = (envhomedir) ? envhomedir : ".";
471
471
        confPath += "/" DOTSWORD "/InstallMgr/InstallMgr.conf";
472
472
        SWConfig *installConf= new SWConfig(confPath.c_str());
473
 
        
 
473
 
474
474
        SectionMap::iterator sourcesSection;
475
475
        ConfigEntMap::iterator sourceBegin;
476
476
        ConfigEntMap::iterator sourceEnd;
477
 
        
 
477
 
478
478
        sourcesSection = installConf->Sections.find("Sources");
479
479
        if (sourcesSection != installConf->Sections.end()) {
480
480
                sourceBegin = sourcesSection->second.lower_bound("DIRSource");
482
482
 
483
483
                while (sourceBegin != sourceEnd) {
484
484
                        mms = g_new(MOD_MGR_SOURCE, 1);
485
 
                        InstallSource *is = new InstallSource("DIR", 
 
485
                        InstallSource *is = new InstallSource("DIR",
486
486
                                        sourceBegin->second.c_str());
487
487
                        mms->caption = is->caption;
488
488
                        mms->type = is->type;
516
516
 *   int backend_module_mgr_refresh_remote_source(const char *sourceName)
517
517
 *
518
518
 * Description
519
 
 *   
 
519
 *
520
520
 *
521
521
 * Return value
522
522
 *   int
545
545
 *   void backend_init_module_mgr_config(void)
546
546
 *
547
547
 * Description
548
 
 *   
 
548
 *
549
549
 *
550
550
 * Return value
551
551
 *   void
553
553
 
554
554
void backend_init_module_mgr_config(void)
555
555
{
556
 
        
 
556
 
557
557
        const gchar *envhomedir = g_getenv(HOMEVAR);
558
558
        SWBuf confPath = (envhomedir) ? envhomedir : ".";
559
559
        confPath += "/" DOTSWORD "/InstallMgr/InstallMgr.conf";
575
575
        is_local.caption = "cdrom";
576
576
        is_local.source = "[local]";
577
577
        is_local.directory = "/mnt/cdrom";
578
 
        config["Sources"]["DIRSource"] = is_local.getConfEnt(); 
 
578
        config["Sources"]["DIRSource"] = is_local.getConfEnt();
579
579
        config.Save();
580
580
}
581
581
 
632
632
 *   void backend_module_mgr_clear_config(void)
633
633
 *
634
634
 * Description
635
 
 *   
 
635
 *
636
636
 *
637
637
 * Return value
638
638
 *   void
694
694
 *                                 const char * uid)
695
695
 *
696
696
 * Description
697
 
 *   
 
697
 *
698
698
 *
699
699
 * Return value
700
700
 *   void
713
713
        SWBuf confPath = (envhomedir) ? envhomedir : ".";
714
714
        confPath += "/" DOTSWORD "/InstallMgr/InstallMgr.conf";
715
715
        FileMgr::createParent(confPath.c_str());
716
 
        
 
716
 
717
717
        SWConfig config(confPath.c_str());
718
718
 
719
719
        InstallSource is(type);
725
725
        is.p = pass;
726
726
        is.uid = uid;
727
727
#endif
728
 
        config.Sections["Sources"].insert(ConfigEntMap::value_type(vtype, 
729
 
                is.getConfEnt().c_str()));      
 
728
        config.Sections["Sources"].insert(ConfigEntMap::value_type(vtype,
 
729
                is.getConfEnt().c_str()));
730
730
        config.Save();
731
731
}
732
732
 
740
740
 *   void backend_init_module_mgr(const char *dir, gboolean augment)
741
741
 *
742
742
 * Description
743
 
 *   
 
743
 *
744
744
 *
745
745
 * Return value
746
746
 *   void
762
762
        GTimer *t;
763
763
        double d;
764
764
        t = g_timer_new();
765
 
        
 
765
 
766
766
        if (regular) {          // use main (regular) swmgr.
767
767
                if (mgr)
768
768
                        delete mgr;
775
775
        g_timer_stop(t);
776
776
        d = g_timer_elapsed(t, NULL);
777
777
        GS_message(("create SWMgr time is %f", d));
778
 
        
 
778
 
779
779
        const gchar *envhomedir = g_getenv(HOMEVAR);
780
780
        SWBuf baseDir = (envhomedir) ? envhomedir : ".";
781
781
        baseDir += "/" DOTSWORD "/InstallMgr";
806
806
 *   void backend_terminate_module_mgr(void)
807
807
 *
808
808
 * Description
809
 
 *   
 
809
 *
810
810
 *
811
811
 * Return value
812
812
 *   void
827
827
 *   void backend_shut_down_module_mgr(void)
828
828
 *
829
829
 * Description
830
 
 *   
 
830
 *
831
831
 *
832
832
 * Return value
833
833
 *   void
839
839
        installMgr = NULL;
840
840
        delete mgr;
841
841
        mgr = NULL;
842
 
        delete list_mgr; 
 
842
        delete list_mgr;
843
843
        list_mgr = NULL;
844
844
}