2
* This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3
* http://www.gnu.org/licenses/gpl-3.0.html
6
* $Id: devpakupdater.cpp 4909 2008-02-27 13:15:26Z mortenmacfly $
7
* $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/plugins/contrib/devpak_plugin/devpakupdater.cpp $
10
#include "devpakupdater.h"
11
#include "updatedlg.h"
14
#include <configmanager.h>
15
#include <compilerfactory.h>
17
#include <wx/msgdlg.h>
18
#include <wx/dirdlg.h>
21
// Register the plugin
24
PluginRegistrant<DevPakUpdater> reg(_T("DevPakUpdater"));
27
DevPakUpdater::DevPakUpdater()
30
if(!Manager::LoadResource(_T("devpakupdater.zip")))
32
NotifyMissingFile(_T("devpakupdater.zip"));
34
g_MasterPath = Manager::Get()->GetConfigManager(_T("devpak_plugin"))->Read(_T("/master_path"));
37
DevPakUpdater::~DevPakUpdater()
42
void DevPakUpdater::OnAttach()
46
void DevPakUpdater::OnRelease(bool appShutDown)
50
bool DevPakUpdater::ConfigurationValid()
52
// let's make sure we have a valid configuration
53
if (g_MasterPath.IsEmpty() || !wxDirExists(g_MasterPath))
55
if (wxMessageBox(_("The Dev-C++ DevPak Plugin is not configured yet.\nDo you want to configure it now?"), _("Question"), wxICON_QUESTION | wxYES_NO) == wxNO)
59
// ask to add in compiler paths
60
if (wxMessageBox(_("Do you want to add this path to the compiler's search dirs?\n"
61
"(needed to be able to actually compile anything)"),
62
_("Question"), wxICON_QUESTION | wxYES_NO) == wxYES)
64
Compiler* compiler = CompilerFactory::GetCompiler(0); // GCC is always first compiler
67
wxMessageBox(_("Invalid compiler!?!"), _("Error"), wxICON_ERROR);
70
compiler->AddIncludeDir(g_MasterPath + wxFILE_SEP_PATH + _T("include"));
71
compiler->AddLibDir(g_MasterPath + wxFILE_SEP_PATH + _T("lib"));
77
int DevPakUpdater::Configure()
79
if (g_MasterPath.IsEmpty())
80
g_MasterPath = ConfigManager::GetConfigFolder() + wxFILE_SEP_PATH + _T("DevPaks");
81
wxString dir = wxDirSelector(_("Please select the path where DevPaks will be downloaded and installed:"),
86
if (!ConfigurationValid())
91
Manager::Get()->GetConfigManager(_T("devpak_plugin"))->Write(_T("/master_path"), g_MasterPath);
97
int DevPakUpdater::Execute()
99
if (!ConfigurationValid())
101
UpdateDlg dlg(Manager::Get()->GetAppWindow());