]> cgit.babelmonkeys.de Git - jubjub.git/blob - src/core/JubConfig.m
Prefix ivars with an underscore
[jubjub.git] / src / core / JubConfig.m
1 #import "JubConfig.h"
2
3 @implementation JubConfig
4 @synthesize domain = _domain;
5 @synthesize server = _server;;
6 @synthesize username = _username;
7 @synthesize password = _password;
8
9 - initWithFile: (OFString*)file
10 {
11         self = [super init];
12
13         @try {
14                 OFAutoreleasePool *pool = [OFAutoreleasePool new];
15                 OFXMLElement *element = [OFXMLElement elementWithFile: file];
16
17                 if (![element.name isEqual: @"config"] ||
18                     ![element.namespace isEqual: CONFIG_NS]) {
19                         // TODO: load default config
20                         [pool release];
21                         return self;
22                 }
23
24                 // TODO: Add error handling for missing elements
25                 of_log(@"Parsed file: %@", element);
26                 _domain = [[[element
27                     elementForName: @"domain"
28                          namespace: CONFIG_NS] stringValue] copy];
29                 _server = [[[element
30                     elementForName: @"server"
31                          namespace: CONFIG_NS] stringValue] copy];
32                 _username = [[[element
33                     elementForName: @"username"
34                          namespace: CONFIG_NS] stringValue] copy];
35                 _password = [[[element
36                     elementForName: @"password"
37                          namespace: CONFIG_NS] stringValue] copy];
38
39                 [pool release];
40         } @catch (id e) {
41                 [self release];
42                 @throw e;
43         }
44
45         return self;
46 }
47
48 - (void)dealloc
49 {
50         [_domain release];
51         [_server release];
52         [_username release];
53         [_password release];
54
55         [super dealloc];
56 }
57 @end