|
Revision 644, 2.2 kB
(checked in by fujii, 4 years ago)
|
Add new netinstall source.
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
#if 0 |
|---|
| 17 |
static const char *cvsid = |
|---|
| 18 |
"\n%%% $Id: ConnectionSetting.cc,v 2.2 2003/10/26 12:02:52 rbcollins Exp $\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 |
if (fg_ret) |
|---|
| 40 |
net_method = typeFromString(fg_ret); |
|---|
| 41 |
fg_ret = f->gets (localdir, 1000); |
|---|
| 42 |
if (fg_ret) |
|---|
| 43 |
net_proxy_host = strdup(fg_ret); |
|---|
| 44 |
fg_ret = f->gets (localdir, 1000); |
|---|
| 45 |
if (fg_ret) |
|---|
| 46 |
net_proxy_port = atoi(fg_ret); |
|---|
| 47 |
delete f; |
|---|
| 48 |
} |
|---|
| 49 |
inited = 1; |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
void |
|---|
| 53 |
ConnectionSetting::save() |
|---|
| 54 |
{ |
|---|
| 55 |
char port_str[20]; |
|---|
| 56 |
|
|---|
| 57 |
io_stream *f = UserSettings::Instance().settingFileForSave("last-connection"); |
|---|
| 58 |
if (f) |
|---|
| 59 |
{ |
|---|
| 60 |
switch (net_method) { |
|---|
| 61 |
case IDC_NET_DIRECT: |
|---|
| 62 |
f->write("Direct\n",7); |
|---|
| 63 |
break; |
|---|
| 64 |
case IDC_NET_IE5: |
|---|
| 65 |
f->write("IE\n",3); |
|---|
| 66 |
break; |
|---|
| 67 |
case IDC_NET_PROXY: |
|---|
| 68 |
f->write("Proxy\n",6); |
|---|
| 69 |
f->write(net_proxy_host,strlen(net_proxy_host)); |
|---|
| 70 |
sprintf(port_str, "\n%d\n", net_proxy_port); |
|---|
| 71 |
f->write(port_str,strlen(port_str)); |
|---|
| 72 |
break; |
|---|
| 73 |
default: |
|---|
| 74 |
break; |
|---|
| 75 |
} |
|---|
| 76 |
delete f; |
|---|
| 77 |
} |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
int |
|---|
| 81 |
ConnectionSetting::typeFromString(String const & aType) |
|---|
| 82 |
{ |
|---|
| 83 |
if (!aType.casecompare("Direct")) |
|---|
| 84 |
return IDC_NET_DIRECT; |
|---|
| 85 |
if (!aType.casecompare("IE")) |
|---|
| 86 |
return IDC_NET_IE5; |
|---|
| 87 |
if (!aType.casecompare("Proxy")) |
|---|
| 88 |
return IDC_NET_PROXY; |
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
return IDC_NET_IE5; |
|---|
| 92 |
} |
|---|