~xavi-garcia-mena/ubuntu/vivid/upower/percentages-power-off

« back to all changes in this revision

Viewing changes to src/freebsd/up-acpi-native.vala

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2010-02-16 10:16:24 UTC
  • Revision ID: james.westby@ubuntu.com-20100216101624-2cmwqsr1ndftdd87
Tags: upstream-0.9.0+git20100216.72bb2
ImportĀ upstreamĀ versionĀ 0.9.0+git20100216.72bb2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
public class UpAcpiNative : Object {
 
2
    private string? _driver;
 
3
    private int _unit;
 
4
    private string _path;
 
5
 
 
6
    public string driver {
 
7
        get { return _driver; }
 
8
    }
 
9
 
 
10
    public int unit {
 
11
        get { return _unit; }
 
12
    }
 
13
 
 
14
    public string path {
 
15
        get { return _path; }
 
16
    }
 
17
 
 
18
    public UpAcpiNative (string path) {
 
19
        Regex r;
 
20
        MatchInfo mi;
 
21
        bool ret;
 
22
 
 
23
        try {
 
24
            r = new Regex("dev\\.([^\\.])\\.(\\d+)");
 
25
            ret = r.match(path, 0, out mi);
 
26
            if (ret) {
 
27
                _driver = mi.fetch(1);
 
28
                _unit = mi.fetch(2).to_int();
 
29
            } else {
 
30
                _driver = null;
 
31
                _unit = -1;
 
32
            }
 
33
        } catch (RegexError re) {
 
34
            _driver = null;
 
35
            _unit = -1;
 
36
        }
 
37
 
 
38
        _path = path;
 
39
    }
 
40
 
 
41
    public UpAcpiNative.driver_unit (string driver, int unit) {
 
42
        _driver = driver;
 
43
        _unit = unit;
 
44
        _path = "dev.%s.%i".printf (_driver, _unit);
 
45
    }
 
46
}