2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "GUIViewStateAddonBrowser.h"
23 #include "guilib/GraphicContext.h"
24 #include "guilib/WindowIDs.h"
25 #include "view/ViewState.h"
26 #include "addons/Addon.h"
27 #include "addons/AddonManager.h"
28 #include "AddonDatabase.h"
30 using namespace XFILE;
31 using namespace ADDON;
33 CGUIViewStateAddonBrowser::CGUIViewStateAddonBrowser(const CFileItemList& items) : CGUIViewState(items)
35 AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | Foldername, empty
36 AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Filename, Date | Foldername, Date
37 SetSortMethod(SortByLabel, SortAttributeIgnoreFolders);
39 SetViewAsControl(DEFAULT_VIEW_AUTO);
41 SetSortOrder(SortOrderAscending);
42 LoadViewState(items.GetPath(), WINDOW_ADDON_BROWSER);
45 void CGUIViewStateAddonBrowser::SaveViewState()
47 SaveViewToDb(m_items.GetPath(), WINDOW_ADDON_BROWSER);
50 CStdString CGUIViewStateAddonBrowser::GetExtensions()
55 VECSOURCES& CGUIViewStateAddonBrowser::GetSources()
59 // we always have some enabled addons
62 share.strPath = "addons://enabled/";
63 share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
64 share.strName = g_localizeStrings.Get(24062);
65 m_sources.push_back(share);
68 if (db.Open() && db.HasDisabledAddons())
71 share.strPath = "addons://disabled/";
72 share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
73 share.strName = g_localizeStrings.Get(24039);
74 m_sources.push_back(share);
76 if (CAddonMgr::Get().HasOutdatedAddons())
79 share.strPath = "addons://outdated/";
80 share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
81 share.strName = g_localizeStrings.Get(24043);
82 m_sources.push_back(share);
84 if (CAddonMgr::Get().HasAddons(ADDON_REPOSITORY,true))
87 share.strPath = "addons://repos/";
88 share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
89 share.strName = g_localizeStrings.Get(24033);
90 m_sources.push_back(share);
92 // add "install from zip"
95 share.strPath = "addons://install/";
96 share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
97 share.strName = g_localizeStrings.Get(24041);
98 m_sources.push_back(share);
103 share.strPath = "addons://search/";
104 share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
105 share.strName = g_localizeStrings.Get(137);
106 m_sources.push_back(share);
109 return CGUIViewState::GetSources();