2 * Copyright (c) 2003, Robert Collins <rbtcollins@hotmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins.
17 #include "ConnectionSetting.h"
18 #include "UserSettings.h"
19 #include "io_stream.h"
24 ConnectionSetting::ConnectionSetting ()
27 if ((fg_ret
= UserSettings::instance().get ("net-method")))
28 NetIO::net_method
= typeFromString(fg_ret
);
29 if ((fg_ret
= UserSettings::instance().get ("net-proxy-host")))
30 NetIO::net_proxy_host
= strdup(fg_ret
);
31 if ((fg_ret
= UserSettings::instance().get ("net-proxy-port")))
32 NetIO::net_proxy_port
= atoi(fg_ret
);
35 ConnectionSetting::~ConnectionSetting ()
37 switch (NetIO::net_method
)
40 UserSettings::instance().set("net-method", "Direct");
42 case IDC_NET_PRECONFIG
:
43 UserSettings::instance().set("net-method", "IE");
47 UserSettings::instance().set("net-method", "Proxy");
48 UserSettings::instance().set("net-proxy-host", NetIO::net_proxy_host
);
49 sprintf(port_str
, "%d", NetIO::net_proxy_port
);
50 UserSettings::instance().set("net-proxy-port", port_str
);
58 ConnectionSetting::typeFromString(const std::string
& aType
)
60 if (!casecompare(aType
, "Direct"))
61 return IDC_NET_DIRECT
;
62 if (!casecompare(aType
, "IE"))
63 return IDC_NET_PRECONFIG
;
64 if (!casecompare(aType
, "Proxy"))
67 /* Migrate the removed direct(legacy) to direct */
68 if (!casecompare(aType
, "Legacy"))
69 return IDC_NET_DIRECT
;
71 /* A sanish default */
72 return IDC_NET_PRECONFIG
;