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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2011-04-05 14:14:13 UTC
  • mfrom: (4.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110405141413-hbwbunfsxpn2rtre
Tags: 0.9.13-1
* New upstream release
  - remove Debian patch (applied upstream)
* Fix watch file
* Remove unnecessary versioned dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
{
40
40
 
41
41
YamlParser::YamlParser (const char *file) : filename (file)
 
42
        , fd(NULL)
 
43
        , events()
42
44
    , eventNumber (0)
43
45
    , doc (NULL)
44
46
    , eventIndex (0)
60
62
    close();
61
63
}
62
64
 
63
 
void YamlParser::open()
 
65
void YamlParser::open() throw(YamlParserException)
64
66
{
65
67
 
66
68
    fd = fopen (filename.c_str(), "rb");
69
71
        throw YamlParserException ("Could not open file descriptor");
70
72
 
71
73
    if (!yaml_parser_initialize (&parser))
72
 
        throw YamlParserException ("Could not open file descriptor");
 
74
        throw YamlParserException ("Could not initialize");
73
75
 
74
76
    yaml_parser_set_input_file (&parser, fd);
75
77
}
76
78
 
77
 
void YamlParser::close()
 
79
void YamlParser::close() throw(YamlParserException)
78
80
{
79
81
    if (!fd)
80
82
        throw YamlParserException ("File descriptor not valid");
81
83
 
82
 
    // fclose (fd);
83
84
    if (fclose (fd))
84
85
        throw YamlParserException ("Error closing file descriptor");
85
86
 
95
96
    }
96
97
}
97
98
 
98
 
void YamlParser::serializeEvents()
 
99
void YamlParser::serializeEvents() throw(YamlParserException)
99
100
{
100
101
    bool done = false;
101
 
    yaml_event_t event;
102
 
 
103
 
    while (!done) {
104
 
 
105
 
        if (!yaml_parser_parse (&parser, &event))
106
 
            throw YamlParserException ("Error while parsing");
107
 
 
108
 
        done = (event.type == YAML_STREAM_END_EVENT);
109
 
 
110
 
        if (eventNumber > PARSER_MAXEVENT)
111
 
            throw YamlParserException ("Reached maximum of event");
112
 
 
113
 
        if (!copyEvent (& (events[eventNumber++]), &event))
114
 
            throw YamlParserException ("Error copying event");
115
 
 
116
 
        yaml_event_delete (&event);
 
102
    yaml_event_t event, copiedEvent;
 
103
 
 
104
    try {
 
105
 
 
106
        while (!done) {
 
107
 
 
108
                if (!yaml_parser_parse (&parser, &event))
 
109
                        throw YamlParserException ("Error while parsing");
 
110
 
 
111
                done = (event.type == YAML_STREAM_END_EVENT);
 
112
 
 
113
                copyEvent (&copiedEvent, &event);
 
114
 
 
115
                events.push_back(copiedEvent);
 
116
 
 
117
                eventNumber++;
 
118
 
 
119
                yaml_event_delete (&event);
 
120
        }
 
121
    }
 
122
    catch(YamlParserException &e) {
 
123
        throw;
117
124
    }
118
125
 
119
126
}
120
127
 
121
128
 
122
 
int YamlParser::copyEvent (yaml_event_t *event_to, yaml_event_t *event_from)
 
129
void YamlParser::copyEvent (yaml_event_t *event_to, yaml_event_t *event_from) throw(YamlParserException)
123
130
{
124
131
 
125
132
    switch (event_from->type) {
126
133
        case YAML_STREAM_START_EVENT: {
127
 
            // _debug("YAML_STREAM_START_EVENT");
128
 
            return yaml_stream_start_event_initialize (event_to,
129
 
                    event_from->data.stream_start.encoding);
 
134
            if(yaml_stream_start_event_initialize (event_to,
 
135
                    event_from->data.stream_start.encoding) == 0) {
 
136
                throw YamlParserException("Error stream start event");
 
137
            }
 
138
            break;
130
139
        }
131
140
 
132
141
        case YAML_STREAM_END_EVENT: {
133
 
            //_debug("YAML_STREAM_END_EVENT");
134
 
            return yaml_stream_end_event_initialize (event_to);
 
142
            if(yaml_stream_end_event_initialize (event_to) == 0) {
 
143
                throw YamlParserException("Error stream end event");
 
144
            }
 
145
            break;
135
146
        }
136
147
 
137
148
        case YAML_DOCUMENT_START_EVENT: {
138
 
            // _debug("YAML_DOCUMENT_START_EVENT");
139
 
            return yaml_document_start_event_initialize (event_to,
 
149
            if(yaml_document_start_event_initialize (event_to,
140
150
                    event_from->data.document_start.version_directive,
141
151
                    event_from->data.document_start.tag_directives.start,
142
152
                    event_from->data.document_start.tag_directives.end,
143
 
                    event_from->data.document_start.implicit);
 
153
                    event_from->data.document_start.implicit) == 0) {
 
154
                throw YamlParserException("Error document start event");
 
155
            }
 
156
            break;
144
157
        }
145
158
 
146
159
        case YAML_DOCUMENT_END_EVENT: {
147
 
            // _debug("YAML_DOCUMENT_END_EVENT");
148
 
            return yaml_document_end_event_initialize (event_to,
149
 
                    event_from->data.document_end.implicit);
 
160
            if(yaml_document_end_event_initialize (event_to,
 
161
                    event_from->data.document_end.implicit) == 0) {
 
162
                throw YamlParserException("Error document end event");
 
163
            }
 
164
            break;
150
165
        }
151
166
        case YAML_ALIAS_EVENT: {
152
 
            // _debug("YAML_ALIAS_EVENT");
153
 
            return yaml_alias_event_initialize (event_to,
154
 
                                                event_from->data.alias.anchor);
 
167
            if (yaml_alias_event_initialize (event_to,
 
168
                     event_from->data.alias.anchor) == 0) {
 
169
                throw YamlParserException("Error alias event initialize");
 
170
            }
 
171
            break;
155
172
        }
156
173
        case YAML_SCALAR_EVENT: {
157
 
            // _debug("YAML_SCALAR_EVENT");
158
 
            return yaml_scalar_event_initialize (event_to,
159
 
                                                 event_from->data.scalar.anchor,
160
 
                                                 event_from->data.scalar.tag,
161
 
                                                 event_from->data.scalar.value,
162
 
                                                 event_from->data.scalar.length,
163
 
                                                 event_from->data.scalar.plain_implicit,
164
 
                                                 event_from->data.scalar.quoted_implicit,
165
 
                                                 event_from->data.scalar.style);
 
174
            if(yaml_scalar_event_initialize (event_to,
 
175
                    event_from->data.scalar.anchor,
 
176
                    event_from->data.scalar.tag,
 
177
                    event_from->data.scalar.value,
 
178
                    event_from->data.scalar.length,
 
179
                    event_from->data.scalar.plain_implicit,
 
180
                    event_from->data.scalar.quoted_implicit,
 
181
                    event_from->data.scalar.style) == 0) {
 
182
                throw YamlParserException("Error scalar event initialize");
 
183
            }
 
184
            break;
166
185
        }
167
186
        case YAML_SEQUENCE_START_EVENT: {
168
 
            // _debug("YAML_SEQUENCE_START_EVENT");
169
 
            return yaml_sequence_start_event_initialize (event_to,
 
187
            if(yaml_sequence_start_event_initialize (event_to,
170
188
                    event_from->data.sequence_start.anchor,
171
189
                    event_from->data.sequence_start.tag,
172
190
                    event_from->data.sequence_start.implicit,
173
 
                    event_from->data.sequence_start.style);
 
191
                    event_from->data.sequence_start.style) == 0) {
 
192
                throw YamlParserException("Error sequence start event");
 
193
            }
 
194
            break;
174
195
        }
175
196
        case YAML_SEQUENCE_END_EVENT: {
176
 
            // _debug("YAML_SEQUENCE_END_EVENT");
177
 
            return yaml_sequence_end_event_initialize (event_to);
 
197
            if(yaml_sequence_end_event_initialize (event_to) == 0) {
 
198
                throw YamlParserException("Error sequence end event");
 
199
            }
 
200
            break;
178
201
        }
179
202
        case YAML_MAPPING_START_EVENT: {
180
 
            // _debug("YAML_MAPPING_START_EVENT");
181
 
            return yaml_mapping_start_event_initialize (event_to,
 
203
            if(yaml_mapping_start_event_initialize (event_to,
182
204
                    event_from->data.mapping_start.anchor,
183
205
                    event_from->data.mapping_start.tag,
184
206
                    event_from->data.mapping_start.implicit,
185
 
                    event_from->data.mapping_start.style);
 
207
                    event_from->data.mapping_start.style) == 0) {
 
208
                throw YamlParserException("Error mapping start event");
 
209
            }
 
210
            break;
186
211
        }
187
212
        case YAML_MAPPING_END_EVENT: {
188
 
            // _debug("YAML_MAPPING_END_EVENT");
189
 
            return yaml_mapping_end_event_initialize (event_to);
190
 
 
 
213
            if(yaml_mapping_end_event_initialize (event_to) == 0) {
 
214
                throw YamlParserException("Error mapping end event");
 
215
            }
 
216
            break;
191
217
        }
192
218
        default:
193
 
            assert (1);
194
 
 
 
219
                break;
195
220
    }
196
 
 
197
 
    return 0;
198
221
}
199
222
 
200
223
 
201
 
YamlDocument *YamlParser::composeEvents()
 
224
YamlDocument *YamlParser::composeEvents() throw(YamlParserException)
202
225
{
203
 
 
204
 
    // _debug("YamlParser: Compose Events");
205
 
 
206
 
    if (eventNumber == 0)
207
 
        throw YamlParserException ("No event available");
208
 
 
209
 
    if (events[0].type != YAML_STREAM_START_EVENT)
210
 
        throw YamlParserException ("Parsing does not start with stream start");
211
 
 
212
 
    eventIndex = 0;
213
 
 
214
 
    processStream();
 
226
        try {
 
227
                if (eventNumber == 0)
 
228
                        throw YamlParserException ("No event available");
 
229
 
 
230
                if (events[0].type != YAML_STREAM_START_EVENT)
 
231
                        throw YamlParserException ("Parsing does not start with stream start");
 
232
 
 
233
                eventIndex = 0;
 
234
 
 
235
                processStream();
 
236
        }
 
237
        catch(YamlParserException &e) {
 
238
                throw;
 
239
        }
 
240
 
215
241
 
216
242
    return doc;
217
243
}
218
244
 
219
 
void YamlParser::processStream ()
 
245
void YamlParser::processStream () throw(YamlParserException)
220
246
{
221
 
 
222
 
    // _debug("YamlParser: process stream");
223
 
 
224
 
    while ( (eventIndex < eventNumber) && (events[eventIndex].type != YAML_STREAM_END_EVENT)) {
225
 
 
226
 
        if (events[eventIndex].type == YAML_DOCUMENT_START_EVENT)
227
 
            processDocument();
228
 
 
229
 
        eventIndex++;
230
 
    }
231
 
 
232
 
    if (events[eventIndex].type != YAML_STREAM_END_EVENT)
233
 
        throw YamlParserException ("Did not found end of stream");
 
247
        try {
 
248
                while ( (eventIndex < eventNumber) && (events[eventIndex].type != YAML_STREAM_END_EVENT)) {
 
249
 
 
250
                        if (events[eventIndex].type == YAML_DOCUMENT_START_EVENT)
 
251
                                processDocument();
 
252
 
 
253
                        eventIndex++;
 
254
                }
 
255
 
 
256
                if (events[eventIndex].type != YAML_STREAM_END_EVENT)
 
257
                        throw YamlParserException ("Did not found end of stream");
 
258
        }
 
259
        catch(YamlParserException &e) {
 
260
                throw;
 
261
        }
234
262
}
235
263
 
236
 
 
237
 
void YamlParser::processDocument()
 
264
void YamlParser::processDocument() throw(YamlParserException)
238
265
{
239
 
    // _debug("YamlParser: process document");
240
 
 
241
 
    doc = new YamlDocument();
242
 
 
243
 
    if (!doc)
244
 
        throw YamlParserException ("Not able to create new document");
245
 
 
246
 
    while ( (eventIndex < eventNumber) && (events[eventIndex].type != YAML_DOCUMENT_END_EVENT)) {
247
 
 
248
 
        switch (events[eventIndex].type) {
 
266
        try {
 
267
 
 
268
                doc = new YamlDocument();
 
269
 
 
270
                if (!doc)
 
271
                        throw YamlParserException ("Not able to create new document");
 
272
 
 
273
                while ( (eventIndex < eventNumber) && (events[eventIndex].type != YAML_DOCUMENT_END_EVENT)) {
 
274
 
 
275
                        switch (events[eventIndex].type) {
249
276
            case YAML_SCALAR_EVENT:
250
 
                processScalar ( (YamlNode *) doc);
251
 
                break;
 
277
                processScalar ( (YamlNode *) doc);
 
278
                break;
252
279
            case YAML_SEQUENCE_START_EVENT:
253
 
                processSequence ( (YamlNode *) doc);
254
 
                break;
 
280
                processSequence ( (YamlNode *) doc);
 
281
                break;
255
282
            case YAML_MAPPING_START_EVENT:
256
283
                processMapping ( (YamlNode *) doc);
257
284
                break;
258
285
            default:
259
286
                break;
260
 
        }
261
 
 
262
 
        eventIndex++;
263
 
    }
264
 
 
265
 
    if (events[eventIndex].type != YAML_DOCUMENT_END_EVENT)
266
 
        throw YamlParserException ("Did not found end of document");
267
 
 
 
287
                        }
 
288
 
 
289
                        eventIndex++;
 
290
                }
 
291
 
 
292
                if (events[eventIndex].type != YAML_DOCUMENT_END_EVENT)
 
293
                        throw YamlParserException ("Did not found end of document");
 
294
 
 
295
        }
 
296
        catch(YamlParserException &e) {
 
297
                throw;
 
298
        }
268
299
}
269
300
 
270
301
 
271
 
void YamlParser::processScalar (YamlNode *topNode)
 
302
void YamlParser::processScalar (YamlNode *topNode) throw(YamlParserException)
272
303
{
273
 
 
274
 
    // _debug("YamlParser: process scalar");
275
 
 
276
 
    if (!topNode)
277
 
        throw YamlParserException ("No container for scalar");
278
 
 
279
 
    char buffer[1000];
280
 
    snprintf (buffer, 1000, "%s", events[eventIndex].data.scalar.value);
281
 
    // _debug("and the scalar is: %s", buffer);
282
 
 
283
 
    ScalarNode *sclr = new ScalarNode (buffer, topNode);
284
 
 
285
 
    switch (topNode->getType()) {
 
304
        try {
 
305
 
 
306
                if (!topNode)
 
307
                        throw YamlParserException ("No container for scalar");
 
308
 
 
309
                char buffer[1000];
 
310
                snprintf (buffer, 1000, "%s", events[eventIndex].data.scalar.value);
 
311
 
 
312
                ScalarNode *sclr = new ScalarNode (buffer, topNode);
 
313
 
 
314
                switch (topNode->getType()) {
286
315
        case DOCUMENT:
287
316
            ( (YamlDocument *) (topNode))->addNode (sclr);
288
317
            break;
294
323
        case SCALAR:
295
324
        default:
296
325
            break;
297
 
    }
 
326
                }
 
327
        }
 
328
        catch(YamlParserException &e) {
 
329
                throw;
 
330
        }
298
331
}
299
332
 
300
333
 
301
 
void YamlParser::processSequence (YamlNode *topNode)
 
334
void YamlParser::processSequence (YamlNode *topNode) throw(YamlParserException)
302
335
{
303
 
    _debug ("YamlParser: process sequence");
304
 
 
305
 
    if (!topNode)
306
 
        throw YamlParserException ("No container for sequence");
307
 
 
308
 
    SequenceNode *seq = new SequenceNode (topNode);
309
 
 
310
 
    switch (topNode->getType()) {
 
336
 
 
337
        try {
 
338
 
 
339
                if (!topNode)
 
340
                        throw YamlParserException ("No container for sequence");
 
341
 
 
342
                SequenceNode *seq = new SequenceNode (topNode);
 
343
 
 
344
                switch (topNode->getType()) {
311
345
        case DOCUMENT:
312
346
            ( (YamlDocument *) (topNode))->addNode (seq);
313
347
            break;
319
353
        case SCALAR:
320
354
        default:
321
355
            break;
322
 
    }
323
 
 
324
 
    eventIndex++;
325
 
 
326
 
    while ( (eventIndex < eventNumber) && (events[eventIndex].type != YAML_SEQUENCE_END_EVENT)) {
327
 
 
328
 
        switch (events[eventIndex].type) {
 
356
                }
 
357
 
 
358
                eventIndex++;
 
359
 
 
360
                while ( (eventIndex < eventNumber) && (events[eventIndex].type != YAML_SEQUENCE_END_EVENT)) {
 
361
 
 
362
                        switch (events[eventIndex].type) {
329
363
            case YAML_SCALAR_EVENT:
330
364
                processScalar (seq);
331
365
                break;
337
371
                break;
338
372
            default:
339
373
                break;
340
 
        }
341
 
 
342
 
        eventIndex++;
343
 
    }
344
 
 
345
 
    if (events[eventIndex].type != YAML_SEQUENCE_END_EVENT)
346
 
        throw YamlParserException ("Did not found end of sequence");
 
374
                        }
 
375
 
 
376
                        eventIndex++;
 
377
                }
 
378
 
 
379
                if (events[eventIndex].type != YAML_SEQUENCE_END_EVENT)
 
380
                        throw YamlParserException ("Did not found end of sequence");
 
381
 
 
382
        }
 
383
        catch(YamlParserException &e) {
 
384
                throw;
 
385
        }
 
386
 
347
387
}
348
388
 
349
 
 
350
 
void YamlParser::processMapping (YamlNode *topNode)
 
389
void YamlParser::processMapping (YamlNode *topNode) throw(YamlParserException)
351
390
{
352
 
    // _debug("YamlParser: process mapping");
353
 
 
354
 
    if (!topNode)
355
 
        throw YamlParserException ("No container for mapping");
356
 
 
357
 
    MappingNode *map = new MappingNode (topNode);
358
 
 
359
 
    switch (topNode->getType()) {
 
391
        try {
 
392
 
 
393
                if (!topNode)
 
394
                        throw YamlParserException ("No container for mapping");
 
395
 
 
396
                MappingNode *map = new MappingNode (topNode);
 
397
 
 
398
                switch (topNode->getType()) {
360
399
        case DOCUMENT:
361
400
            ( (YamlDocument *) (topNode))->addNode (map);
362
401
            break;
368
407
        case SCALAR:
369
408
        default:
370
409
            break;
371
 
    }
372
 
 
373
 
    eventIndex++;
374
 
 
375
 
    while ( (eventIndex < eventNumber) && (events[eventIndex].type != YAML_MAPPING_END_EVENT)) {
376
 
 
377
 
        if (events[eventIndex].type != YAML_SCALAR_EVENT)
378
 
            throw YamlParserException ("Mapping not followed by a key");
379
 
 
380
 
        char buffer[1000];
381
 
        snprintf (buffer, 1000, "%s", events[eventIndex].data.scalar.value);
382
 
        map->setTmpKey (Key (buffer));
383
 
        // _debug("KEY %s", buffer);
384
 
 
385
 
        eventIndex++;
386
 
 
387
 
        switch (events[eventIndex].type) {
 
410
                }
 
411
 
 
412
                eventIndex++;
 
413
 
 
414
                while ( (eventIndex < eventNumber) && (events[eventIndex].type != YAML_MAPPING_END_EVENT)) {
 
415
 
 
416
                        if (events[eventIndex].type != YAML_SCALAR_EVENT)
 
417
                                throw YamlParserException ("Mapping not followed by a key");
 
418
 
 
419
                        char buffer[1000];
 
420
                        snprintf (buffer, 1000, "%s", events[eventIndex].data.scalar.value);
 
421
                        map->setTmpKey (Key (buffer));
 
422
 
 
423
                        eventIndex++;
 
424
 
 
425
                        switch (events[eventIndex].type) {
388
426
            case YAML_SCALAR_EVENT:
389
427
                processScalar (map);
390
428
                break;
396
434
                break;
397
435
            default:
398
436
                break;
399
 
        }
400
 
 
401
 
        eventIndex++;
402
 
    }
403
 
 
404
 
    if (events[eventIndex].type != YAML_MAPPING_END_EVENT)
405
 
        throw YamlParserException ("Did not found end of mapping");
 
437
                        }
 
438
 
 
439
                        eventIndex++;
 
440
                }
 
441
 
 
442
                if (events[eventIndex].type != YAML_MAPPING_END_EVENT)
 
443
                        throw YamlParserException ("Did not found end of mapping");
 
444
 
 
445
        }
 
446
        catch(YamlParserException &e) {
 
447
                throw;
 
448
        }
406
449
}
407
450
 
408
 
void YamlParser::constructNativeData()
 
451
void YamlParser::constructNativeData() throw(YamlParserException)
409
452
{
410
453
 
411
 
    Sequence *seq;
412
 
 
413
 
    seq = doc->getSequence();
414
 
 
415
 
    Sequence::iterator iter = seq->begin();
416
 
 
417
 
    while (iter != seq->end()) {
418
 
 
419
 
        switch ( (*iter)->getType()) {
 
454
        try {
 
455
                Sequence *seq;
 
456
 
 
457
                seq = doc->getSequence();
 
458
 
 
459
                Sequence::iterator iter = seq->begin();
 
460
 
 
461
                while (iter != seq->end()) {
 
462
 
 
463
                        switch ( (*iter)->getType()) {
420
464
            case SCALAR:
421
465
                // _debug("construct scalar");
422
466
                throw YamlParserException ("No scalar allowed at document level, expect a mapping");
434
478
            default:
435
479
                throw YamlParserException ("Unknown type in configuration file, expect a mapping");
436
480
                break;
437
 
        }
438
 
 
439
 
        iter++;
440
 
 
441
 
    }
 
481
                        }
 
482
 
 
483
                        iter++;
 
484
 
 
485
                }
 
486
        }
 
487
        catch(YamlParserException &e) {
 
488
                throw;
 
489
        }
442
490
 
443
491
}
444
492
 
445
493
 
446
 
void YamlParser::mainNativeDataMapping (MappingNode *map)
 
494
void YamlParser::mainNativeDataMapping (MappingNode *map) throw(YamlParserException)
447
495
{
448
496
 
449
 
 
450
 
    Mapping::iterator iter = map->getMapping()->begin();
451
 
 
452
 
    Key accounts ("accounts");
453
 
    Key addressbook ("addressbook");
454
 
    Key audio ("audio");
455
 
    Key hooks ("hooks");
456
 
    Key preferences ("preferences");
457
 
    Key voiplink ("voipPreferences");
458
 
    Key shortcuts ("shortcuts");
459
 
 
460
 
    while (iter != map->getMapping()->end()) {
461
 
 
462
 
        _debug ("Iterating: %s", iter->first.c_str());
463
 
 
464
 
        if (accounts.compare (iter->first) == 0) {
465
 
            _debug ("YamlParser: Adding voip account preferences");
466
 
            accountSequence = (SequenceNode *) (iter->second);
467
 
        } else if (addressbook.compare (iter->first) == 0) {
468
 
            _debug ("YamlParser: Adding addressbook preference");
469
 
            addressbookSequence = (SequenceNode *) (iter->second);
470
 
        } else if (audio.compare (iter->first) == 0) {
471
 
            _debug ("YamlParser: Adding audio preference");
472
 
            audioSequence = (SequenceNode *) (iter->second);
473
 
        } else if (hooks.compare (iter->first) == 0) {
474
 
            _debug ("YamlParser: Adding hooks preference");
475
 
            hooksSequence = (SequenceNode *) (iter->second);
476
 
        } else if (preferences.compare (iter->first) == 0) {
477
 
            _debug ("YamlParser: Adding preference preference");
478
 
            preferenceSequence = (SequenceNode *) (iter->second);
479
 
        } else if (voiplink.compare (iter->first) == 0) {
480
 
            _debug ("YamlParser: Adding voip preference");
481
 
            voiplinkSequence = (SequenceNode *) (iter->second);
482
 
        } else if (shortcuts.compare (iter->first) == 0) {
483
 
            _debug ("YamlParser: Adding shortcut preference");
484
 
            shortcutSequence = (SequenceNode *) (iter->second);
485
 
        } else
486
 
            throw YamlParserException ("Unknow map key in configuration");
487
 
 
488
 
        iter++;
489
 
    }
490
 
 
491
 
    // _debug("Done");
 
497
        try {
 
498
                Mapping::iterator iter = map->getMapping()->begin();
 
499
 
 
500
                Key accounts ("accounts");
 
501
                Key addressbook ("addressbook");
 
502
                Key audio ("audio");
 
503
                Key hooks ("hooks");
 
504
                Key preferences ("preferences");
 
505
                Key voiplink ("voipPreferences");
 
506
                Key shortcuts ("shortcuts");
 
507
 
 
508
                while (iter != map->getMapping()->end()) {
 
509
 
 
510
                        _debug ("Iterating: %s", iter->first.c_str());
 
511
 
 
512
                        if (accounts.compare (iter->first) == 0) {
 
513
                                _debug ("YamlParser: Adding voip account preferences");
 
514
                                accountSequence = (SequenceNode *) (iter->second);
 
515
                        } else if (addressbook.compare (iter->first) == 0) {
 
516
                                _debug ("YamlParser: Adding addressbook preference");
 
517
                                addressbookSequence = (SequenceNode *) (iter->second);
 
518
                        } else if (audio.compare (iter->first) == 0) {
 
519
                                _debug ("YamlParser: Adding audio preference");
 
520
                                audioSequence = (SequenceNode *) (iter->second);
 
521
                        } else if (hooks.compare (iter->first) == 0) {
 
522
                                _debug ("YamlParser: Adding hooks preference");
 
523
                                hooksSequence = (SequenceNode *) (iter->second);
 
524
                        } else if (preferences.compare (iter->first) == 0) {
 
525
                                _debug ("YamlParser: Adding preference preference");
 
526
                                preferenceSequence = (SequenceNode *) (iter->second);
 
527
                        } else if (voiplink.compare (iter->first) == 0) {
 
528
                                _debug ("YamlParser: Adding voip preference");
 
529
                                voiplinkSequence = (SequenceNode *) (iter->second);
 
530
                        } else if (shortcuts.compare (iter->first) == 0) {
 
531
                                _debug ("YamlParser: Adding shortcut preference");
 
532
                                shortcutSequence = (SequenceNode *) (iter->second);
 
533
                        } else
 
534
                                throw YamlParserException ("Unknow map key in configuration");
 
535
 
 
536
                        iter++;
 
537
                }
 
538
        }
 
539
        catch(YamlParserException &e) {
 
540
                throw;
 
541
        }
492
542
}
493
543
 
494
544
}