~ubuntu-branches/ubuntu/saucy/sflphone/saucy

« back to all changes in this revision

Viewing changes to sflphone-common/src/config/config.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2010-12-24 16:33:55 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101224163355-tkvvikqxbrbav6up
Tags: 0.9.11-1
* New upstream release
* Add new build dependencies on libwebkit-dev and libyaml-dev

* Bump Standards-Version up to 3.9.1
* Bump debhelper compatibility to 8
* Patch another typo in the upstream code (lintian notice)

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include <errno.h>
39
39
#include <iostream>
40
40
#include <string.h>
 
41
#include "yamlparser.h"
41
42
 
42
43
namespace Conf
43
44
{
50
51
// dtor
51
52
ConfigTree::~ConfigTree()
52
53
{
 
54
 
53
55
    // erase every new ItemMap (by CreateSection)
54
56
    SectionMap::iterator iter = _sections.begin();
55
57
 
210
212
    SectionMap::iterator iter = _sections.find (section);
211
213
 
212
214
    if (iter == _sections.end()) {
213
 
      // _error("ConfigTree: Error: Did not found section %s in config tree", section.c_str());
 
215
        // _error("ConfigTree: Error: Did not found section %s in config tree", section.c_str());
214
216
        return NULL;
215
217
    }
216
218
 
217
219
    ItemMap::iterator iterItem = iter->second->find (itemName);
218
220
 
219
221
    if (iterItem == iter->second->end()) {
220
 
      // _error("ConfigTree: Error: Did not found item %s in config tree", itemName.c_str());
 
222
        // _error("ConfigTree: Error: Did not found item %s in config tree", itemName.c_str());
221
223
        return NULL;
222
224
    }
223
225
 
271
273
bool
272
274
ConfigTree::saveConfigTree (const std::string& fileName)
273
275
{
 
276
    _debug ("ConfigTree: Save %s", fileName.c_str());
 
277
 
274
278
    if (fileName.empty() && _sections.begin() == _sections.end()) {
275
279
        return false;
276
280
    }
280
284
    file.open (fileName.data(), std::fstream::out);
281
285
 
282
286
    if (!file.is_open()) {
283
 
        _error("ConfigTree: Error: Could not open %s configuration file", fileName.c_str());
 
287
        _error ("ConfigTree: Error: Could not open %s configuration file", fileName.c_str());
284
288
        return false;
285
289
    }
286
290
 
304
308
    file.close();
305
309
 
306
310
    if (chmod (fileName.c_str(), S_IRUSR | S_IWUSR)) {
307
 
        _error("ConfigTree: Error: Failed to set permission on configuration: %s",strerror (errno));
 
311
        _error ("ConfigTree: Error: Failed to set permission on configuration: %s",strerror (errno));
308
312
    }
309
313
 
310
314
    return true;
319
323
{
320
324
    bool out = false;
321
325
 
 
326
    _debug ("ConfigTree: Populate from file %s", fileName.c_str());
 
327
 
322
328
    if (fileName.empty()) {
323
329
        return 0;
324
330
    }
378
384
                if (key.length() > 0 && val.length() > 0) {
379
385
                    setConfigTreeItem (section, key, val);
380
386
                }
381
 
                /*
382
 
                if (key.length() > 0) {
383
 
 
384
 
                    if(val.length() > 0) 
385
 
                        setConfigTreeItem (section, key, val);
386
 
                    else
387
 
                        setConfigTreeItem (section, key, "");
388
 
                }
389
 
                */
 
387
 
 
388
                /*
 
389
                if (key.length() > 0) {
 
390
 
 
391
                    if(val.length() > 0)
 
392
                        setConfigTreeItem (section, key, val);
 
393
                    else
 
394
                        setConfigTreeItem (section, key, "");
 
395
                        }
 
396
                */
390
397
            }
391
398
        }
392
399
    }