]> cygwin.com Git - cygwin-apps/setup.git/blob - ConnectionSetting.cc
2003-07-30 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / ConnectionSetting.cc
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
16 #if 0
17 static const char *cvsid =
18 "\n%%% $Id$\n";
19 #endif
20
21 #include "ConnectionSetting.h"
22 #include "UserSettings.h"
23 #include "io_stream.h"
24 #include "state.h"
25 #include "resource.h"
26 #include "String++.h"
27
28 void
29 ConnectionSetting::load()
30 {
31 static int inited = 0;
32 if (inited)
33 return;
34 io_stream *f = UserSettings::Instance().settingFileForLoad("last-connection");
35 if (f)
36 {
37 char localdir[1000];
38 char *fg_ret = f->gets (localdir, 1000);
39 delete f;
40 if (fg_ret)
41 net_method = typeFromString(fg_ret);
42 }
43 inited = 1;
44 }
45
46 void
47 ConnectionSetting::save()
48 {
49
50 io_stream *f = UserSettings::Instance().settingFileForSave("last-connection");
51 if (f)
52 {
53 switch (net_method) {
54 case IDC_NET_DIRECT:
55 f->write("Direct\n",7);
56 break;
57 case IDC_NET_IE5:
58 f->write("IE\n",3);
59 break;
60 case IDC_NET_PROXY:
61 f->write("Proxy\n",6);
62 // TODO: also write the proxy and port, and then parse them in load.
63 break;
64 default:
65 break;
66 }
67 delete f;
68 }
69 }
70
71 int
72 ConnectionSetting::typeFromString(String const & aType)
73 {
74 if (!aType.casecompare("Direct"))
75 return IDC_NET_DIRECT;
76 if (!aType.casecompare("IE"))
77 return IDC_NET_IE5;
78 if (!aType.casecompare("Proxy"))
79 return IDC_NET_PROXY;
80
81 /* A sanish default */
82 return IDC_NET_IE5;
83 }
This page took 0.037831 seconds and 5 git commands to generate.