Find file
Fetching contributors…
Cannot retrieve contributors at this time
130 lines (108 sloc) 3.49 KB
* Copyright (C) 2009, Alexander Stigsen,
* This software is licensed under the Open Company License as described
* in the file license.txt, which you should have received as part of this
* distribution. The terms are also available at
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <vector>
#include "FileInfo.h"
#include "BundleInfo.h"
class ITmLoadBundles;
class PListHandler;
class wxFileName;
class wxProgressDialog;
class wxListCtrl;
class wxListEvent;
class IHtmlWnd;
class IHtmlWndBeforeLoadEvent;
class RemoteThread;
class cxRemoteListEvent;
class cxRemoteAction;
class BundleManager : public wxDialog {
BundleManager(wxWindow *parent, RemoteThread& remoteThread, ITmLoadBundles* syntaxHandler);
bool NeedBundleReload() const {return m_needBundleReload;};
void LoadBundleLists();
void UpdateBundleList();
void RestoreBundle();
bool InstallBundle();
bool InstallBundle(const cxFileInfo* bundle, const wxString& url, long ix);
bool DownloadDir(const wxString& url, const wxFileName& path, wxProgressDialog& dlg);
void AddItems(const wxString& repoName, const std::vector<cxFileInfo>& bundleList);
void SetDirModDate(wxFileName& path, const wxDateTime& modDate);
void DelTree(const wxString& path);
void SelectItem(long itemId, bool update=false);
const wxString& GetCurrentRepoUrl() const;
const wxString& GetRepoUrl(const wxString& name) const;
// Event handlers
void OnRemoteListReceived(cxRemoteListEvent& event);
void OnRemoteAction(cxRemoteAction& event);
void OnItemSelected(wxListEvent& event);
void OnInstallButton(wxCommandEvent& event);
void OnDeleteButton(wxCommandEvent& event);
void OnClose(wxCloseEvent& event);
void OnBeforeLoad(IHtmlWndBeforeLoadEvent& event);
void OnUpdateAllBundles(wxCommandEvent& event);
enum BundleState {
cxBundleInfo* GetState(const cxFileInfo* bundle, BundleState& state);
class RepoInfo {
RepoInfo(const wxString& name, const wxString& url) : name(name), url(url), received(false) {};
RepoInfo& operator=(const RepoInfo& ri) {
name =;
url = ri.url;
received = ri.received;
bundleList = ri.bundleList;
return *this;
wxString name;
wxString url;
bool received;
std::vector<cxFileInfo> bundleList;
// Member variables
RemoteThread& m_remoteThread;
ITmLoadBundles* m_syntaxHandler;
PListHandler& m_plistHandler;
wxString m_tempFile;
std::vector<cxBundleInfo> m_installedBundles;
std::vector<RepoInfo> m_repositories;
bool m_allBundlesReceived;
bool m_needBundleReload;
static const wxString s_emptyString; // to avoid return temp warning
// Current selection
long m_currentSel;
wxString m_currentRepo;
const cxFileInfo* m_currentBundle;
cxBundleInfo* m_currentBundleInfo;
BundleState m_currentBundleState;
// Member ctrls
wxSizer* m_mainSizer;
wxListCtrl* m_bundleList;
IHtmlWnd* m_browser;
wxStaticText* m_statusText;
wxButton* m_installButton;
wxButton* m_deleteButton;
#endif // __BUNDLEMANAGER_H__