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.
16 #include "SourceSetting.h"
17 #include "UserSettings.h"
18 #include "io_stream.h"
23 SourceSetting::SourceSetting ()
26 if ((fg_ret
= UserSettings::instance().get ("last-action")))
27 source
= sourceFromString(fg_ret
);
30 SourceSetting::~SourceSetting ()
34 case IDC_SOURCE_DOWNLOAD
:
35 UserSettings::instance().set ("last-action", "Download");
37 case IDC_SOURCE_NETINST
:
38 UserSettings::instance().set ("last-action", "Download,Install");
40 case IDC_SOURCE_LOCALDIR
:
41 UserSettings::instance().set ("last-action", "Install");
49 SourceSetting::sourceFromString(const std::string
& aSource
)
51 if (!casecompare(aSource
, "Download"))
52 return IDC_SOURCE_DOWNLOAD
;
53 if (!casecompare(aSource
, "Download,Install"))
54 return IDC_SOURCE_NETINST
;
55 if (!casecompare(aSource
, "Install"))
56 return IDC_SOURCE_LOCALDIR
;
58 /* A sanish default */
59 return IDC_SOURCE_NETINST
;