]> cygwin.com Git - cygwin-apps/setup.git/blame - ConnectionSetting.cc
Add NTSecurity::hasSymlinkCreationRights()
[cygwin-apps/setup.git] / ConnectionSetting.cc
CommitLineData
39b42ff3
RC
1/*
2 * Copyright (c) 2003, Robert Collins <rbtcollins@hotmail.com>
3 *
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.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by Robert Collins.
13 *
14 */
15
2e0aaec9 16#include <stdlib.h>
39b42ff3
RC
17#include "ConnectionSetting.h"
18#include "UserSettings.h"
19#include "io_stream.h"
071f7af3 20#include "netio.h"
39b42ff3
RC
21#include "resource.h"
22#include "String++.h"
23
f26f525f 24ConnectionSetting::ConnectionSetting ()
39b42ff3 25{
f26f525f
CF
26 const char *fg_ret;
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);
39b42ff3
RC
33}
34
f26f525f 35ConnectionSetting::~ConnectionSetting ()
39b42ff3 36{
f26f525f 37 switch (NetIO::net_method)
39b42ff3 38 {
f26f525f
CF
39 case IDC_NET_DIRECT:
40 UserSettings::instance().set("net-method", "Direct");
41 break;
4b615680 42 case IDC_NET_PRECONFIG:
f26f525f
CF
43 UserSettings::instance().set("net-method", "IE");
44 break;
45 case IDC_NET_PROXY:
46 char port_str[20];
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);
51 break;
52 default:
53 break;
39b42ff3
RC
54 }
55}
56
57int
08678720 58ConnectionSetting::typeFromString(const std::string& aType)
39b42ff3 59{
afa76033 60 if (!casecompare(aType, "Direct"))
39b42ff3 61 return IDC_NET_DIRECT;
afa76033 62 if (!casecompare(aType, "IE"))
4b615680 63 return IDC_NET_PRECONFIG;
afa76033 64 if (!casecompare(aType, "Proxy"))
39b42ff3
RC
65 return IDC_NET_PROXY;
66
3d7dbd62
JT
67 /* Migrate the removed direct(legacy) to direct */
68 if (!casecompare(aType, "Legacy"))
69 return IDC_NET_DIRECT;
70
39b42ff3 71 /* A sanish default */
4b615680 72 return IDC_NET_PRECONFIG;
39b42ff3 73}
This page took 0.09351 seconds and 5 git commands to generate.