aboutsummaryrefslogtreecommitdiffstats
path: root/fsogsmd/src/lib/factories.vala
blob: e68f41d5dc8b2d542c57674f59f7619f046d2bef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 * Copyright (C) 2009-2012 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 */

namespace FsoGsm
{
    private FsoGsm.LowLevel createLowLevelFromType( string lowleveltype )
    {
        FsoGsm.LowLevel lowlevel;
        string typename = "none";

        switch ( lowleveltype )
        {
            case "motorola_ezx":
                typename = "LowLevelMotorolaEZX";
                break;
            case "openmoko":
                typename = "LowLevelOpenmoko";
                break;
            case "nokia900":
                typename = "LowLevelNokia900";
                break;
            case "samsung_crespo":
                typename = "LowLevelSamsungCrespo";
                break;
            case "gta04":
                typename = "LowLevelGTA04";
                break;
            default:
                FsoFramework.theLogger.warning( @"Invalid lowlevel_type $lowleveltype; vendor specifics will NOT be available" );
                lowleveltype = "none";
                break;
        }

        if ( lowleveltype != "none" )
        {
            var lowlevelclass = Type.from_name( typename );
            if ( lowlevelclass == Type.INVALID  )
            {
                FsoFramework.theLogger.warning( @"Can't find plugin for lowlevel_type $lowleveltype; vendor specifics will NOT be available" );
                lowlevel = new FsoGsm.NullLowLevel();
            }
            else
            {
                lowlevel = Object.new( lowlevelclass ) as FsoGsm.LowLevel;
                FsoFramework.theLogger.info( @"Ready. Using lowlevel plugin $lowleveltype to handle vendor specifics" );
            }
        }
        else
        {
            lowlevel = new FsoGsm.NullLowLevel();
        }

        return lowlevel;
    }

    private FsoGsm.IPdpHandler createPdpHandlerFromType( string pdphandlertype )
    {
        FsoGsm.IPdpHandler pdphandler;
        string typename = "none";

        switch ( pdphandlertype )
        {
            case "ppp":
                typename = "PdpPpp";
                break;
            case "mux":
                typename = "PdpPppMux";
                break;
            case "qmi":
                typename = "PdpQmi";
                break;
            case "ippp":
                typename = "PdpPppInternal";
                break;
            case "nokia_isi":
                typename = "PdpNokiaIsi";
                break;
            case "samsung_ipc":
                typename = "SamsungPdpHandler";
                break;
            case "option_gtm601":
                typename = "PdpOptionGtm601";
                break;
            default:
                FsoFramework.theLogger.warning( @"Invalid pdp_type $pdphandlertype; data connectivity will NOT be available" );
                pdphandlertype = "none";
                break;
        }

        if ( pdphandlertype != "none" )
        {
            var pdphandlerclass = Type.from_name( typename );
            if ( pdphandlerclass == Type.INVALID  )
            {
                FsoFramework.theLogger.warning( @"Can't find plugin for pdp_type $pdphandlertype; data connectivity will NOT be available" );
                pdphandler = new FsoGsm.NullPdpHandler();
            }
            else
            {
                pdphandler = Object.new( pdphandlerclass ) as FsoGsm.PdpHandler;
                FsoFramework.theLogger.info( @"Ready. Using pdp plugin $pdphandlertype to handle data connectivity" );
            }
        }
        else
        {
            pdphandler = new FsoGsm.NullPdpHandler();
        }

        return pdphandler;
    }
}

// vim:ts=4:sw=4:expandtab