Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

changed: move addonbrowser to a mediawindow derivate

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@29227 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information...
commit 639b31468f85763b7722bc71d84de1ef78424163 1 parent afae664
spiff_ authored
8 language/English/strings.xml
View
@@ -2129,7 +2129,13 @@
<string id="24051">Version:</string>
<string id="24052">Disclaimer:</string>
<string id="24053">License:</string>
- <string id="24059">Would you like to install this Add-on?</string>
+ <string id="24059">Would you like to enable this Add-on?</string>
+ <string id="24060">Would you like to disable this Add-on?</string>
+ <string id="24061">Addon-on update available!</string>
+ <string id="24062">Enabled Add-ons</string>
+ <string id="24063">Enable auto-update</string>
+ <string id="24064">Add-on enabled</string>
+ <string id="24065">Add-on updated</string>
<string id="24070">Add-on can not used</string>
<string id="24071">An unknown error has occurred</string>
432 skin/Confluence/720p/AddonBrowser.xml
View
@@ -1,301 +1,181 @@
-<window id="40">
- <defaultcontrol always="true">2</defaultcontrol>
+<window id="20">
+ <defaultcontrol always="true">50</defaultcontrol>
<allowoverlay>no</allowoverlay>
+ <views>50,51,500</views>
<controls>
- <include>CommonSettingsBackground</include>
+ <include>CommonScriptBackground</include>
<include>CommonMediaPlayingBackground</include>
<control type="group">
- <posx>90</posx>
- <posy>50</posy>
- <animation type="WindowOpen" reversible="false">
- <effect type="zoom" start="80" end="100" center="640,360" easing="out" tween="back" time="300" />
- <effect type="fade" start="0" end="100" time="300" />
- </animation>
- <animation type="WindowClose" reversible="false">
- <effect type="zoom" start="100" end="80" center="640,360" easing="in" tween="back" time="300" />
- <effect type="fade" start="100" end="0" time="300" />
- </animation>
+ <include>Window_OpenClose_Animation</include>
<control type="image">
<posx>0</posx>
<posy>0</posy>
- <width>1100</width>
- <height>640</height>
- <texture border="20">DialogBack.png</texture>
+ <width>1280</width>
+ <height>720</height>
+ <texture border="20">black-back.png</texture>
+ <include>VisibleFadeEffect</include>
+ <visible>Control.IsVisible(50) | Control.IsVisible(51) | Control.IsVisible(500)</visible>
</control>
- <control type="button">
- <description>Close Window button</description>
- <posx>980</posx>
- <posy>9</posy>
- <width>64</width>
- <height>32</height>
+ <control type="image">
+ <posx>0</posx>
+ <posy>128r</posy>
+ <width>1280</width>
+ <height>128</height>
+ <texture>floor.png</texture>
+ <include>VisibleFadeEffect</include>
+ <visible>Control.IsVisible(50) | Control.IsVisible(51) | Control.IsVisible(500)</visible>
+ </control>
+ <control type="group">
+ <include>VisibleFadeEffect</include>
+ <visible>Control.IsVisible(50)</visible>
+ <control type="image">
+ <posx>50</posx>
+ <posy>60</posy>
+ <width>750</width>
+ <height>600</height>
+ <texture border="20">ContentPanel.png</texture>
+ </control>
+ <control type="image">
+ <posx>50</posx>
+ <posy>645</posy>
+ <width>750</width>
+ <height>600</height>
+ <aspectratio aligny="top">keep</aspectratio>
+ <texture diffuse="diffuse_mirror3.png" flipy="true" border="20">ContentPanel.png</texture>
+ </control>
+ </control>
+ <control type="group">
+ <include>VisibleFadeEffect</include>
+ <visible>Control.IsVisible(51) | Control.IsVisible(500)</visible>
+ <control type="image">
+ <posx>75</posx>
+ <posy>60</posy>
+ <width>1130</width>
+ <height>600</height>
+ <texture border="20">ContentPanel.png</texture>
+ </control>
+ <control type="image">
+ <posx>75</posx>
+ <posy>645</posy>
+ <width>1130</width>
+ <height>600</height>
+ <aspectratio aligny="top">keep</aspectratio>
+ <texture diffuse="diffuse_mirror3.png" flipy="true" border="20">ContentPanel.png</texture>
+ </control>
+ </control>
+ </control>
+ <control type="group">
+ <include>Window_OpenClose_Animation</include>
+ <include>CommonRootView</include> <!-- view id = 50 -->
+ <include>FullWidthList</include> <!-- view id = 51 -->
+ <include>ThumbnailView</include> <!-- view id = 500 -->
+ </control>
+ <include>CommonPageCount</include>
+ <include>BehindDialogFadeOut</include>
+ <include>ScrollOffsetLabel</include>
+ <control type="group">
+ <animation effect="slide" start="0,0" end="250,0" time="400" tween="quadratic" easing="out" condition="ControlGroup(9000).HasFocus | Control.HasFocus(8999)">Conditional</animation>
+ <animation effect="slide" start="0,0" end="-250,0" time="400" tween="quadratic" easing="out" condition="ControlGroup(9000).HasFocus | Control.HasFocus(8999)">WindowClose</animation>
+ <control type="button" id="8999">
+ <description>Fake button for mouse control</description>
+ <posx>-250</posx>
+ <posy>0</posy>
+ <width>265</width>
+ <height>720</height>
<label>-</label>
<font>-</font>
- <onclick>PreviousMenu</onclick>
- <texturefocus>DialogCloseButton-focus.png</texturefocus>
- <texturenofocus>DialogCloseButton.png</texturenofocus>
- <onleft>1</onleft>
- <onright>1</onright>
- <onup>1</onup>
- <ondown>1</ondown>
- <visible>system.getbool(input.enablemouse)</visible>
- </control>
- <control type="grouplist" id="3">
- <description>button area</description>
- <posx>10</posx>
- <posy>90</posy>
- <width>260</width>
- <height>481</height>
- <itemgap>-1</itemgap>
- <onleft>60</onleft>
- <onright>2</onright>
- <onup>3</onup>
- <ondown>3</ondown>
+ <texturenofocus>-</texturenofocus>
+ <texturefocus>-</texturefocus>
+ <visible>true</visible>
</control>
+ <include>SideBladeLeft</include>
<control type="image">
<description>LOGO</description>
- <posx>30</posx>
- <posy>15</posy>
+ <posx>-230</posx>
+ <posy>50</posy>
<width>220</width>
<height>80</height>
<aspectratio>keep</aspectratio>
<texture>Confluence_Logo.png</texture>
</control>
- <control type="image">
- <posx>268</posx>
- <posy>10</posy>
- <width>790</width>
- <height>618</height>
- <texture border="5">black-back2.png</texture>
- </control>
- <control type="image">
- <posx>268</posx>
- <posy>10</posy>
- <width>804</width>
- <height>70</height>
- <aspectratio>stretch</aspectratio>
- <texture>GlassTitleBar.png</texture>
- </control>
- <control type="label">
- <description>header label</description>
- <posx>300</posx>
- <posy>20</posy>
- <width>740</width>
- <height>30</height>
- <font>font16caps</font>
- <label>$LOCALIZE[24001]</label>
- <align>left</align>
- <aligny>center</aligny>
- <textcolor>white</textcolor>
- <shadowcolor>black</shadowcolor>
- </control>
- <control type="list" id="2">
- <posx>290</posx>
- <posy>70</posy>
- <width>750</width>
- <height>530</height>
- <onup>2</onup>
- <ondown>2</ondown>
- <onleft>3</onleft>
- <onright>60</onright>
- <pagecontrol>60</pagecontrol>
- <scrolltime>200</scrolltime>
- <itemlayout height="75" width="750">
- <control type="image">
- <posx>0</posx>
- <posy>0</posy>
- <width>750</width>
- <height>75</height>
- <aspectratio>stretch</aspectratio>
- <texture border="5">MenuItemNF.png</texture>
- </control>
- <control type="image">
- <posx>0</posx>
- <posy>2</posy>
- <width>90</width>
- <height>66</height>
- <texture>$INFO[ListItem.Icon]</texture>
- </control>
- <control type="label">
- <posx>100</posx>
- <posy>2</posy>
- <width>625</width>
- <height>28</height>
- <font>font13</font>
- <textcolor>selected</textcolor>
- <selectedcolor>selected</selectedcolor>
- <shadowcolor>black</shadowcolor>
- <align>left</align>
- <aligny>center</aligny>
- <label>[B]$INFO[ListItem.Property(Addon.Name)][/B] - $INFO[ListItem.Property(Addon.Version)] - [COLOR=blue]([/COLOR]$LOCALIZE[305][COLOR=blue])[/COLOR]</label>
- <visible>![$INFO[ListItem.Property(Addon.Disabled)]]</visible>
- </control>
- <control type="label">
- <posx>100</posx>
- <posy>2</posy>
- <width>625</width>
- <height>28</height>
- <font>font13</font>
- <textcolor>grey2</textcolor>
- <selectedcolor>selected</selectedcolor>
- <shadowcolor>black</shadowcolor>
- <align>left</align>
- <aligny>center</aligny>
- <label>[B]$INFO[ListItem.Property(Addon.Name)][/B] - $INFO[ListItem.Property(Addon.Version)]</label>
- <visible>[$INFO[ListItem.Property(Addon.Disabled)]]</visible>
- </control>
- <control type="label">
- <posx>100</posx>
- <posy>25</posy>
- <width>625</width>
- <height>25</height>
- <font>font12</font>
- <textcolor>grey2</textcolor>
- <selectedcolor>selected</selectedcolor>
- <align>left</align>
- <aligny>center</aligny>
- <label>$INFO[ListItem.Property(Addon.Summary)]</label>
- </control>
- <control type="image">
- <posx>725</posx>
- <posy>25</posy>
- <width>24</width>
- <height>24</height>
- <texture>radiobutton-nofocus.png</texture>
- <visible>[$INFO[ListItem.Property(Addon.Disabled)]]</visible>
- </control>
- <control type="image">
- <posx>725</posx>
- <posy>25</posy>
- <width>24</width>
- <height>24</height>
- <texture>radiobutton-focus.png</texture>
- <visible>![$INFO[ListItem.Property(Addon.Disabled)]]</visible>
- </control>
- </itemlayout>
- <focusedlayout height="75" width="750">
- <control type="image">
- <posx>0</posx>
- <posy>0</posy>
- <width>750</width>
- <height>75</height>
- <aspectratio>stretch</aspectratio>
- <texture border="5">MenuItemNF.png</texture>
- <visible>!Control.HasFocus(2)</visible>
- <include>VisibleFadeEffect</include>
- </control>
- <control type="image">
- <posx>0</posx>
- <posy>0</posy>
- <width>750</width>
- <height>75</height>
- <aspectratio>stretch</aspectratio>
- <texture border="5">MenuItemFO.png</texture>
- <visible>Control.HasFocus(2)</visible>
- <include>VisibleFadeEffect</include>
- </control>
- <control type="image">
- <posx>0</posx>
- <posy>2</posy>
- <width>90</width>
- <height>66</height>
- <texture>$INFO[ListItem.Icon]</texture>
- </control>
- <control type="label">
- <posx>100</posx>
- <posy>2</posy>
- <width>625</width>
- <height>28</height>
- <font>font13</font>
- <textcolor>selected</textcolor>
- <selectedcolor>selected</selectedcolor>
- <shadowcolor>black</shadowcolor>
- <align>left</align>
- <aligny>center</aligny>
- <label>[B]$INFO[ListItem.Property(Addon.Name)][/B] - $INFO[ListItem.Property(Addon.Version)] - [COLOR=blue]([/COLOR]$LOCALIZE[305][COLOR=blue])[/COLOR]</label>
- <visible>![$INFO[ListItem.Property(Addon.Disabled)]]</visible>
- </control>
- <control type="label">
- <posx>100</posx>
- <posy>2</posy>
- <width>625</width>
- <height>28</height>
- <font>font13</font>
- <textcolor>white</textcolor>
- <selectedcolor>selected</selectedcolor>
- <shadowcolor>black</shadowcolor>
- <align>left</align>
- <aligny>center</aligny>
- <label>[B]$INFO[ListItem.Property(Addon.Name)][/B] - $INFO[ListItem.Property(Addon.Version)]</label>
- <visible>[$INFO[ListItem.Property(Addon.Disabled)]]</visible>
- </control>
- <control type="label">
- <posx>100</posx>
- <posy>25</posy>
- <width>625</width>
- <height>25</height>
- <font>font12</font>
- <textcolor>white</textcolor>
- <selectedcolor>selected</selectedcolor>
- <align>left</align>
- <aligny>center</aligny>
- <label>$INFO[ListItem.Property(Addon.Summary)]</label>
- </control>
- <control type="image">
- <posx>725</posx>
- <posy>25</posy>
- <width>24</width>
- <height>24</height>
- <texture>radiobutton-nofocus.png</texture>
- <visible>[$INFO[ListItem.Property(Addon.Disabled)]]</visible>
- </control>
- <control type="image">
- <posx>725</posx>
- <posy>25</posy>
- <width>24</width>
- <height>24</height>
- <texture>radiobutton-focus.png</texture>
- <visible>![$INFO[ListItem.Property(Addon.Disabled)]]</visible>
- </control>
- </focusedlayout>
- </control>
- <control type="scrollbar" id="60">
- <posx>1060</posx>
- <posy>60</posy>
- <width>25</width>
- <height>530</height>
- <texturesliderbackground border="0,14,0,14">ScrollBarV.png</texturesliderbackground>
- <texturesliderbar border="0,14,0,14">ScrollBarV_bar.png</texturesliderbar>
- <texturesliderbarfocus border="0,14,0,14">ScrollBarV_bar_focus.png</texturesliderbarfocus>
- <textureslidernib>ScrollBarNib.png</textureslidernib>
- <textureslidernibfocus>ScrollBarNib.png</textureslidernibfocus>
- <onleft>2</onleft>
- <onright>4</onright>
- <showonepage>false</showonepage>
- <orientation>vertical</orientation>
+ <control type="group" id="9000">
+ <posx>-250</posx>
+ <posy>130</posy>
+ <include>CommonNowPlaying</include>
+ <control type="button" id="2">
+ <description>View As button</description>
+ <posx>0</posx>
+ <posy>0</posy>
+ <include>ButtonCommonValues</include>
+ <label>-</label>
+ <onleft>50</onleft>
+ <onright>50</onright>
+ <onup>611</onup>
+ <ondown>3</ondown>
+ </control>
+ <control type="button" id="3">
+ <description>Sort by button</description>
+ <posx>0</posx>
+ <posy>40</posy>
+ <include>ButtonCommonValues</include>
+ <label>103</label>
+ <onleft>50</onleft>
+ <onright>4</onright>
+ <onup>2</onup>
+ <ondown>5</ondown>
+ </control>
+ <control type="togglebutton" id="4">
+ <description>Sort asc</description>
+ <posx>220</posx>
+ <posy>53</posy>
+ <label>-</label>
+ <onleft>3</onleft>
+ <onright>50</onright>
+ <onup>2</onup>
+ <ondown>610</ondown>
+ </control>
+ <control type="togglebutton" id ="5">
+ <description>Enable auto-updates</description>
+ <posx>10</posx>
+ <posy>90</posy>
+ <width>250</width>
+ <height>80</height>
+ <textoffsety>13</textoffsety>
+ <label>24063</label>
+ <include>ButtonCommonValues</include>
+ <align>left</align>
+ <aligny>top</aligny>
+ <texturenofocus border="5">MenuItemNF.png</texturenofocus>
+ <texturefocus border="5">MenuItemFO.png</texturefocus>
+ <onleft>50</onleft>
+ <onright>50</onright>
+ <onup>3</onup>
+ <ondown>2</ondown>
+ </control>
+ <control type="button" id="610">
+ <description>Fake Button to fix Player Controls Navigation</description>
+ <onup>3</onup>
+ <ondown>603</ondown>
+ <visible>false</visible>
+ </control>
+ <control type="group">
+ <posx>0</posx>
+ <posy>260</posy>
+ <include>CommonNowPlaying_Controls</include>
+ </control>
+ <control type="button" id="611">
+ <description>Fake Button to fix Player Controls Navigation</description>
+ <onup>608</onup>
+ <ondown>2</ondown>
+ <visible>false</visible>
+ </control>
</control>
</control>
- <include>BehindDialogFadeOut</include>
-
- <control type="button" id="10">
- <description>Default Category Button</description>
- <height>60</height>
- <width>260</width>
- <textoffsetx>20</textoffsetx>
- <align>right</align>
- <aligny>center</aligny>
- <font>font13_title</font>
- <textcolor>grey2</textcolor>
- <focusedcolor>white</focusedcolor>
- <texturefocus border="5">MenuItemFO.png</texturefocus>
- <texturenofocus border="5">MenuItemNF.png</texturenofocus>
- <pulseonselect>false</pulseonselect>
- </control>
-
<control type="group">
<posx>60</posx>
<posy>0</posy>
- <animation effect="slide" end="-310,0" time="400" tween="quadratic" easing="out" condition="Window.Next(Home) | Window.Next(1111)">WindowClose</animation>
- <animation effect="slide" start="-310,0" time="400" tween="quadratic" easing="out" condition="Window.Previous(Home) | Window.Previous(1111)">WindowOpen</animation>
+ <animation effect="slide" end="-310,0" time="400" tween="quadratic" easing="out">WindowClose</animation>
+ <animation effect="slide" start="-310,0" time="400" tween="quadratic" easing="out">WindowOpen</animation>
<control type="image">
<posx>0</posx>
<posy>0</posy>
@@ -306,7 +186,7 @@
<control type="label">
<include>WindowTitleCommons</include>
<posx>220</posx>
- <label>$LOCALIZE[5]</label>
+ <label>$LOCALIZE[24001]</label>
</control>
</control>
<include>WindowTitleHomeButton</include>
5 system/keymaps/keyboard.xml
View
@@ -413,11 +413,6 @@
<backspace>PreviousMenu</backspace>
</keyboard>
</Settings>
- <AddonBrowser>
- <keyboard>
- <backspace>PreviousMenu</backspace>
- </keyboard>
- </AddonBrowser>
<MyPicturesSettings>
<keyboard>
<backspace>PreviousMenu</backspace>
2  xbmc/Application.cpp
View
@@ -766,6 +766,7 @@ bool CApplication::InitDirectoriesLinux()
CDirectory::Create("special://temp/");
CDirectory::Create("special://home/skin");
CDirectory::Create("special://home/addons");
+ CDirectory::Create("special://home/addons/packages");
CDirectory::Create("special://home/media");
CDirectory::Create("special://home/sounds");
CDirectory::Create("special://home/system");
@@ -4761,6 +4762,7 @@ void CApplication::ProcessSlow()
g_lcd->Initialize();
}
#endif
+ ADDON::CAddonMgr::Get()->UpdateRepos();
}
// Global Idle Time in Seconds
57 xbmc/FileSystem/AddonsDirectory.cpp
View
@@ -21,10 +21,13 @@
#include "AddonsDirectory.h"
+#include "AddonDatabase.h"
#include "FactoryDirectory.h"
#include "Directory.h"
#include "DirectoryCache.h"
#include "FileItem.h"
+#include "addons/Repository.h"
+#include "StringUtils.h"
using namespace ADDON;
@@ -43,19 +46,56 @@ CAddonsDirectory::~CAddonsDirectory(void)
bool CAddonsDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CURL path(strPath);
- if (!path.GetProtocol().Equals("addons"))
- return false;
VECADDONS addons;
- if (path.GetPassWord().empty())
- CAddonMgr::Get()->GetAddons(TranslateType(path.GetHostName()), addons);
+ // get info from repository
+ if (path.GetHostName().Equals("enabled"))
+ CAddonMgr::Get()->GetAllAddons(addons);
else
- CAddonMgr::Get()->GetAddons(TranslateType(path.GetHostName()), addons, TranslateContent(path.GetPassWord()));
+ {
+ AddonPtr addon;
+ CAddonMgr::Get()->GetAddon(path.GetHostName(),addon);
+ if (!addon)
+ return false;
+ CAddonDatabase database;
+ database.Open();
+ if (!database.GetRepository(addon->ID(),addons))
+ {
+ RepositoryPtr repo = boost::dynamic_pointer_cast<CRepository>(addon);
+ addons = CRepositoryUpdateJob::GrabAddons(repo,false);
+ }
+ }
+
+ if (path.GetFileName().IsEmpty())
+ {
+ for (int i=ADDON_UNKNOWN+1;i<ADDON_VIZ_LIBRARY;++i)
+ {
+ for (unsigned int j=0;j<addons.size();++j)
+ {
+ if (addons[j]->Type() == (TYPE)i)
+ {
+ CFileItemPtr item(new CFileItem(TranslateType((TYPE)i,true)));
+ item->m_strPath = CUtil::AddFileToFolder(strPath,TranslateType((TYPE)i,false));
+ item->m_bIsFolder = true;
+ items.Add(item);
+ break;
+ }
+ }
+ }
+ items.m_strPath = strPath;
+ return true;
+ }
+
+ TYPE type = TranslateType(path.GetFileName());
+ for (unsigned int j=0;j<addons.size();++j)
+ if (addons[j]->Type() != type)
+ addons.erase(addons.begin()+j--);
+ items.m_strPath = strPath;
GenerateListing(path, addons, items);
- return !items.IsEmpty();
+ return true;
}
void CAddonsDirectory::GenerateListing(CURL &path, VECADDONS& addons, CFileItemList &items)
@@ -68,18 +108,19 @@ void CAddonsDirectory::GenerateListing(CURL &path, VECADDONS& addons, CFileItemL
CFileItemPtr pItem(new CFileItem(path.Get(), false));
pItem->SetLabel(addon->Name());
pItem->SetLabel2(addon->Summary());
+ pItem->SetProperty("Addon.ID", addon->ID());
pItem->SetProperty("Addon.Type", TranslateType(addon->Type()));
pItem->SetProperty("Addon.Name", addon->Name());
+ pItem->SetProperty("Addon.Version", addon->Version().Print());
pItem->SetProperty("Addon.Summary", addon->Summary());
pItem->SetProperty("Addon.Description", addon->Description());
pItem->SetProperty("Addon.Creator", addon->Author());
pItem->SetProperty("Addon.Disclaimer", addon->Disclaimer());
pItem->SetProperty("Addon.Rating", addon->Stars());
+ pItem->SetProperty("Addon.Path", addon->Path());
pItem->SetThumbnailImage(addon->Icon());
items.Add(pItem);
}
- items.FillInDefaultIcons();
- items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);
}
}
3  xbmc/FileSystem/AddonsDirectory.h
View
@@ -41,7 +41,6 @@ namespace XFILE
virtual bool Create(const char* strPath) { return true; }
virtual bool Exists(const char* strPath) { return true; }
- private:
- void GenerateListing(CURL &path, ADDON::VECADDONS& addons, CFileItemList &items);
+ static void GenerateListing(CURL &path, ADDON::VECADDONS& addons, CFileItemList &items);
};
}
4 xbmc/GUIViewState.cpp
View
@@ -20,6 +20,7 @@
*/
#include "GUIViewState.h"
+#include "GUIViewStateAddonBrowser.h"
#include "GUIViewStateMusic.h"
#include "GUIViewStateVideo.h"
#include "GUIViewStatePictures.h"
@@ -119,6 +120,9 @@ CGUIViewState* CGUIViewState::GetViewState(int windowId, const CFileItemList& it
if (windowId==WINDOW_PROGRAMS)
return new CGUIViewStateWindowPrograms(items);
+
+ if (windowId==WINDOW_ADDON_BROWSER)
+ return new CGUIViewStateAddonBrowser(items);
// Use as fallback/default
return new CGUIViewStateGeneral(items);
84 xbmc/GUIViewStateAddonBrowser.cpp
View
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2005-2008 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "GUIViewStateAddonBrowser.h"
+#include "GUIBaseContainer.h"
+#include "FileItem.h"
+#include "Key.h"
+#include "ViewState.h"
+#include "Settings.h"
+#include "FileSystem/Directory.h"
+#include "addons/Addon.h"
+#include "addons/AddonManager.h"
+
+using namespace XFILE;
+using namespace ADDON;
+
+CGUIViewStateAddonBrowser::CGUIViewStateAddonBrowser(const CFileItemList& items) : CGUIViewState(items)
+{
+ AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | Foldername, empty
+ AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Filename, Date | Foldername, Date
+ SetSortMethod(SORT_METHOD_LABEL);
+
+ SetViewAsControl(DEFAULT_VIEW_LIST);
+
+ SetSortOrder(SORT_ORDER_ASC);
+ LoadViewState(items.m_strPath, WINDOW_ADDON_BROWSER);
+}
+
+void CGUIViewStateAddonBrowser::SaveViewState()
+{
+ SaveViewToDb(m_items.m_strPath, WINDOW_ADDON_BROWSER);
+}
+
+CStdString CGUIViewStateAddonBrowser::GetExtensions()
+{
+ return "";
+}
+
+VECSOURCES& CGUIViewStateAddonBrowser::GetSources()
+{
+ m_sources.clear();
+
+ VECADDONS addons;
+ CAddonMgr::Get()->GetAllAddons(addons);
+ if (addons.size())
+ {
+ CMediaSource share;
+ share.strPath = "addons://enabled/";
+ share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
+ share.strName = g_localizeStrings.Get(24062);
+ m_sources.push_back(share);
+ }
+ addons.clear();
+ CAddonMgr::Get()->GetAddons(ADDON_REPOSITORY,addons,CONTENT_NONE,true);
+ for (unsigned int i=0;i<addons.size();++i)
+ {
+ CMediaSource share;
+ share.strPath = "addons://"+addons[i]->ID();
+ share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
+ share.strName = addons[i]->Name();
+ m_sources.push_back(share);
+ }
+
+ return CGUIViewState::GetSources();
+}
+
36 xbmc/GUIViewStateAddonBrowser.h
View
@@ -0,0 +1,36 @@
+#pragma once
+
+/*
+ * Copyright (C) 2005-2008 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "GUIViewState.h"
+
+class CGUIViewStateAddonBrowser : public CGUIViewState
+{
+public:
+ CGUIViewStateAddonBrowser(const CFileItemList& items);
+
+protected:
+ virtual void SaveViewState();
+ virtual CStdString GetExtensions();
+ virtual VECSOURCES& GetSources();
+};
+
3  xbmc/GUIViewStateScripts.cpp
View
@@ -53,7 +53,8 @@ CStdString CGUIViewStateWindowScripts::GetExtensions()
#if defined(__APPLE__)
return ".py|.applescript";
#else
- return ".py";
+// return ".py";
+ return "";
#endif
}
380 xbmc/GUIWindowAddonBrowser.cpp
View
@@ -19,267 +19,245 @@
*
*/
-#include "addons/AddonManager.h"
#include "GUIWindowAddonBrowser.h"
-#include "GUISpinControlEx.h"
-#include "GUIControlGroupList.h"
-#include "Settings.h"
+#include "addons/AddonManager.h"
#include "GUIDialogContextMenu.h"
#include "GUIDialogAddonSettings.h"
-#include "GUIDialogYesNo.h"
-#include "GUIDialogNumeric.h"
#include "GUIDialogKeyboard.h"
+#include "GUIDialogYesNo.h"
+#include "GUIEditControl.h"
+#include "GUIUserMessages.h"
#include "GUIWindowManager.h"
#include "Util.h"
#include "URL.h"
-#include "utils/log.h"
#include "FileItem.h"
+#include "FileSystem/File.h"
+#include "FileSystem/Directory.h"
+#include "utils/FileOperationJob.h"
+#include "utils/JobManager.h"
+#include "Settings.h"
+#include "Application.h"
+#include "AddonDatabase.h"
-#define CONTROL_ADDONSLIST 2
-#define CATEGORY_GROUP_ID 3
-#define CONTROL_DEFAULT_CATEGORY_BUTTON 10
-#define CONTROL_HEADING_LABEL 411
-#define CONTROL_START_BUTTONS -100
+#define CONTROL_AUTOUPDATE 5
using namespace ADDON;
+using namespace XFILE;
CGUIWindowAddonBrowser::CGUIWindowAddonBrowser(void)
-: CGUIWindow(WINDOW_ADDON_BROWSER, "AddonBrowser.xml")
+: CGUIMediaWindow(WINDOW_ADDON_BROWSER, "AddonBrowser.xml")
{
- m_vecItems = new CFileItemList;
}
CGUIWindowAddonBrowser::~CGUIWindowAddonBrowser()
{
}
-bool CGUIWindowAddonBrowser::OnAction(const CAction &action)
-{
- if (action.GetID() == ACTION_PREVIOUS_MENU)
- {
- g_windowManager.PreviousWindow();
- return true;
- }
- else if (action.GetID() == ACTION_CONTEXT_MENU || action.GetID() == ACTION_MOUSE_RIGHT_CLICK)
- {
- int iItem = GetSelectedItem();
- return OnContextMenu(iItem);
- }
- return CGUIWindow::OnAction(action);
-}
-
bool CGUIWindowAddonBrowser::OnMessage(CGUIMessage& message)
{
switch ( message.GetMessage() )
{
- case GUI_MSG_WINDOW_DEINIT:
+ case GUI_MSG_WINDOW_INIT:
{
- CGUIWindow::OnMessage(message);
- ClearListItems();
- return true;
+ m_vecItems->m_strPath = "";
+ SetHistoryForPath(m_vecItems->m_strPath);
}
- break;
-
case GUI_MSG_CLICKED:
{
- if (message.GetSenderId() == CONTROL_ADDONSLIST) // list control
+ int iControl = message.GetSenderId();
+ if (iControl == CONTROL_AUTOUPDATE)
{
- int iItem = GetSelectedItem();
- int iAction = message.GetParam1();
- if (iItem < 0) break;
- if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_MOUSE_LEFT_CLICK)
- {
- return OnContextMenu(iItem);
- }
- if (iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_RIGHT_CLICK)
- {
- return OnContextMenu(iItem);
- }
+ g_settings.m_bAddonAutoUpdate = !g_settings.m_bAddonAutoUpdate;
+ g_settings.Save();
+ return true;
}
}
break;
- case GUI_MSG_FOCUSED:
- {
- CGUIWindow::OnMessage(message);
- int focusedControl = GetFocusedControlID();
- if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < CONTROL_START_BUTTONS+(int)m_categories.size())
- {
- m_currentCategory = focusedControl-CONTROL_START_BUTTONS;
- Update();
- }
- return true;
- }
- break;
+ default:
+ break;
}
- return CGUIWindow::OnMessage(message);
-}
-
-void CGUIWindowAddonBrowser::ClearListItems()
-{
- m_vecItems->Clear();
+ return CGUIMediaWindow::OnMessage(message);
}
-void CGUIWindowAddonBrowser::OnInitWindow()
+void CGUIWindowAddonBrowser::GetContextButtons(int itemNumber,
+ CContextButtons& buttons)
{
- CGUIWindow::OnInitWindow();
- m_currentCategory = 0;
- SetupControls();
- Update();
-}
-
-int CGUIWindowAddonBrowser::GetSelectedItem()
-{
- CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_ADDONSLIST);
- g_windowManager.SendMessage(msg);
+ CFileItemPtr pItem = m_vecItems->Get(itemNumber);
+ TYPE type = TranslateType(pItem->GetProperty("Addon.Type"));
+ AddonPtr addon;
+ if (!CAddonMgr::Get()->GetAddon(pItem->GetProperty("Addon.ID"),
+ addon, type, false))
+ return;
- return msg.GetParam1();
+ if (addon->HasSettings())
+ buttons.Add(CONTEXT_BUTTON_SETTINGS,24020);
}
-bool CGUIWindowAddonBrowser::SelectItem(int select)
+bool CGUIWindowAddonBrowser::OnContextButton(int itemNumber,
+ CONTEXT_BUTTON button)
{
- CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_ADDONSLIST, select);
- return g_windowManager.SendMessage(msg);
-}
+ CFileItemPtr pItem = m_vecItems->Get(itemNumber);
+ TYPE type = TranslateType(pItem->GetProperty("Addon.Type"));
+ AddonPtr addon;
+ if (!CAddonMgr::Get()->GetAddon(pItem->GetProperty("Addon.ID"),
+ addon, type, false))
+ return false;
+ if (button == CONTEXT_BUTTON_SETTINGS)
+ return CGUIDialogAddonSettings::ShowAndGetInput(addon);
-void CGUIWindowAddonBrowser::OnSort()
-{
- m_vecItems->Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);
+ return false;
}
-void CGUIWindowAddonBrowser::Update()
+bool CGUIWindowAddonBrowser::OnClick(int iItem)
{
- int selected = GetSelectedItem();
- m_vecItems->Clear();
-
- if (m_categories.empty())
- return;
-
- VECADDONS addons;
- CAddonMgr::Get()->GetAddons(m_categories[m_currentCategory], addons, CONTENT_NONE);
-
- for (unsigned i=0; i < addons.size(); i++)
+ CFileItemPtr item = m_vecItems->Get(iItem);
+ if (!item->m_bIsFolder)
{
- AddonPtr addon = addons[i];
- CFileItemPtr pItem(new CFileItem(addon->ID(), false));
- pItem->SetLabel(addon->Name());
- pItem->SetProperty("Addon.ID", addon->ID());
- pItem->SetProperty("Addon.Type", TranslateType(addon->Type()));
- pItem->SetProperty("Addon.Disabled", addon->Disabled());
- pItem->SetProperty("Addon.Name", addon->Name());
- pItem->SetProperty("Addon.Version", addon->Version().Print());
- pItem->SetProperty("Addon.Summary", addon->Summary());
- pItem->SetProperty("Addon.Description", addon->Description());
- pItem->SetProperty("Addon.Creator", addon->Author());
- pItem->SetProperty("Addon.Disclaimer", addon->Disclaimer());
- pItem->SetProperty("Addon.Rating", addon->Stars());
- pItem->SetThumbnailImage(addon->Icon());
- m_vecItems->Add(pItem);
+ AddonPtr addon;
+ if (CAddonMgr::Get()->GetAddon(item->GetProperty("Addon.ID"),addon))
+ {
+ if (CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24000),
+ addon->Name(),
+ g_localizeStrings.Get(24060),""))
+ {
+ CFileItemList list;
+ list.Add(CFileItemPtr(new CFileItem(CUtil::AddFileToFolder("special://home/addons",item->GetProperty("Addon.ID")),true)));
+ list[0]->Select(true);
+ CJobManager::GetInstance().AddJob(new CFileOperationJob(CFileOperationJob::ActionDelete,list,"special://home/addons/"),this);
+ }
+ }
+ else
+ {
+ if (CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24000),
+ item->GetProperty("Addon.Name"),
+ g_localizeStrings.Get(24059),""))
+ {
+ AddJob(item->GetProperty("Addon.Path"));
+ }
+ }
+ return true;
}
- OnSort();
- CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_ADDONSLIST, 0, 0, m_vecItems);
- OnMessage(msg);
- CGUIControl *control = GetFirstFocusableControl(CONTROL_START_BUTTONS + m_currentCategory);
- ((CGUIButtonControl *)control)->SetSelected(true);
-
- if (selected != 0)
- SelectItem(selected);
+ return CGUIMediaWindow::OnClick(iItem);
}
-void CGUIWindowAddonBrowser::OnClick(int iItem)
+void CGUIWindowAddonBrowser::OnJobComplete(unsigned int jobID,
+ bool success, CJob* job2)
{
- if ( iItem < 0 || iItem >= (int)m_vecItems->Size() ) return ;
- CFileItemPtr pItem = (*m_vecItems)[iItem];
- CStdString strPath = pItem->m_strPath;
-
- // check if user is allowed to open this window
- if (g_settings.GetCurrentProfile().addonmanagerLocked() && g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
- if (!g_passwordManager.IsMasterLockUnlocked(true))
- return;
+ if (success)
+ {
+ CFileOperationJob* job = (CFileOperationJob*)job2;
+ if (job->GetAction() == CFileOperationJob::ActionCopy)
+ {
+ for (int i=0;i<job->GetItems().Size();++i)
+ {
+ CStdString strFolder = job->GetItems()[i]->m_strPath;
+ // zip is downloaded - now extract it
+ if (CUtil::IsZIP(strFolder))
+ {
+ AddJob(strFolder);
+ }
+ else
+ {
+ CURL url(strFolder);
+ // zip extraction job is done
+ if (url.GetProtocol() == "zip")
+ {
+ CFileItemList list;
+ CDirectory::GetDirectory(url.Get(),list);
+ CStdString dirname = "";
+ for (int i=0;i<list.Size();++i)
+ {
+ if (list[i]->m_bIsFolder)
+ {
+ dirname = list[i]->GetLabel();
+ break;
+ }
+ }
+ strFolder = CUtil::AddFileToFolder("special://home/addons/",
+ dirname);
+ }
+ else // not reachable - in case we decide to allow non-zipped repos
+ {
+ CUtil::RemoveSlashAtEnd(strFolder);
+ strFolder = CUtil::AddFileToFolder("special://home/addons/",
+ CUtil::GetFileName(strFolder));
+ }
+ AddonPtr addon;
+ if (CAddonMgr::AddonFromInfoXML(strFolder,addon))
+ {
+ CStdString strFolder2;
+ CUtil::GetDirectory(strFolder,strFolder2);
+ for (ADDONDEPS::iterator it = addon->GetDeps().begin();
+ it != addon->GetDeps().end();++it)
+ {
+ AddonPtr addon2;
+ if (!CAddonMgr::Get()->GetAddon(it->first,addon2))
+ {
+ CAddonDatabase database;
+ database.Open();
+ database.GetAddon(it->first,addon2);
+ AddJob(addon2->Path());
+ }
+ }
+ if (addon->Type() >= ADDON_VIZ_LIBRARY)
+ continue;
+ AddonPtr addon2;
+ if (CAddonMgr::Get()->GetAddon(addon->ID(),addon2))
+ {
+ g_application.m_guiDialogKaiToast.QueueNotification(
+ CGUIDialogKaiToast::Info,
+ addon->Name(),
+ g_localizeStrings.Get(24065));
+ }
+ else
+ {
+ g_application.m_guiDialogKaiToast.QueueNotification(
+ CGUIDialogKaiToast::Info,
+ addon->Name(),
+ g_localizeStrings.Get(24064));
+ }
+ }
+ }
+ }
+ }
+ CAddonMgr::Get()->FindAddons();
- //TODO handle installation via OnClick() ?
-/* AddonPtr addon;
- TYPE type = TranslateType(pItem->GetProperty("Addon.Type"));
- if (CAddonMgr::Get()->GetAddon(pItem->GetProperty("Addon.ID"), addon, type, false))
- {
- if (addon->Disabled())
- CAddonMgr::Get()->EnableAddon(addon);
- else
- CAddonMgr::Get()->DisableAddon(addon);
- Update();
- }*/
+ CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE);
+ g_windowManager.SendThreadMessage(msg);
+ }
}
-bool CGUIWindowAddonBrowser::OnContextMenu(int iItem)
+void CGUIWindowAddonBrowser::UpdateButtons()
{
- // check if user is allowed to open this window
- if (g_settings.GetCurrentProfile().addonmanagerLocked() && g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
- if (!g_passwordManager.IsMasterLockUnlocked(true))
- return false;
-
- CFileItemPtr pItem = m_vecItems->Get(iItem);
-
- TYPE type = TranslateType(pItem->GetProperty("Addon.Type"));
- AddonPtr addon;
- if (!CAddonMgr::Get()->GetAddon(pItem->GetProperty("Addon.ID"), addon, type, false))
- return false;
- if (!addon->HasSettings())
- return false;
-
- CGUIDialogContextMenu* pMenu = (CGUIDialogContextMenu*)g_windowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
- if (!pMenu)
- return false;
-
- pMenu->Initialize();
-
- int iSettingsLabel = 24020;
- int btn_Settings = pMenu->AddButton(iSettingsLabel);
-
- pMenu->CenterWindow();
- pMenu->DoModal();
-
- int btnid = pMenu->GetButton();
- if (btnid == -1)
- return false;
-
- if (btnid == btn_Settings)
- {
- CGUIDialogAddonSettings::ShowAndGetInput(addon);
- return true;
- }
- return false;
+ SET_CONTROL_SELECTED(GetID(),CONTROL_AUTOUPDATE,g_settings.m_bAddonAutoUpdate);
+ CGUIMediaWindow::UpdateButtons();
}
-void CGUIWindowAddonBrowser::SetupControls()
+void CGUIWindowAddonBrowser::AddJob(const CStdString& path)
{
- FreeControls();
- CGUIButtonControl* pOriginalCategoryButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_CATEGORY_BUTTON);
- CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CATEGORY_GROUP_ID);
- if (!pOriginalCategoryButton || !group)
- return;
- pOriginalCategoryButton->SetVisible(false);
- for (unsigned int i=ADDON::ADDON_UNKNOWN+1;i<ADDON_VIZ_LIBRARY;++i)
+ CGUIWindowAddonBrowser* that = (CGUIWindowAddonBrowser*)g_windowManager.GetWindow(WINDOW_ADDON_BROWSER);
+ CFileItemList list;
+ CStdString dest="special://home/addons/packages/";
+ CStdString package = CUtil::AddFileToFolder("special://home/addons/packages/",
+ CUtil::GetFileName(path));
+ // check for cached copy
+ if (CFile::Exists(package))
{
- if (!CAddonMgr::Get()->HasAddons((ADDON::TYPE)i))
- continue;
- CGUIButtonControl* pButton = pOriginalCategoryButton->Clone();
- pButton->SetLabel(ADDON::TranslateType((ADDON::TYPE)i,true));
- pButton->SetID(CONTROL_START_BUTTONS+m_categories.size());
- pButton->SetVisible(true);
- pButton->AllocResources();
- group->AddControl(pButton);
- m_categories.push_back((ADDON::TYPE)i);
+ CStdString archive;
+ CUtil::CreateArchivePath(archive,"zip",package,"");
+ list.Add(CFileItemPtr(new CFileItem(archive,true)));
+ dest = "special://home/addons/";
}
-}
-
-void CGUIWindowAddonBrowser::FreeControls()
-{
- CGUIControlGroupList *control = (CGUIControlGroupList *)GetControl(CATEGORY_GROUP_ID);
- if (control)
+ else
{
- control->FreeResources();
- control->ClearAll();
+ list.Add(CFileItemPtr(new CFileItem(path,false)));
}
- m_categories.clear();
+
+ CUtil::GetDirectory(path,package);
+ list[0]->SetProperty("Repo.Path",package);
+ list[0]->Select(true);
+ CJobManager::GetInstance().AddJob(
+ new CFileOperationJob(CFileOperationJob::ActionCopy,list,dest),that);
}
30 xbmc/GUIWindowAddonBrowser.h
View
@@ -22,35 +22,29 @@
*/
#include "addons/Addon.h"
-#include "GUIWindow.h"
-#include "GUIViewControl.h"
+#include "GUIMediaWindow.h"
+#include "utils/Job.h"
class CFileItem;
class CFileItemList;
class CGUIWindowAddonBrowser :
- public CGUIWindow
+ public CGUIMediaWindow,
+ public IJobCallback
{
public:
CGUIWindowAddonBrowser(void);
virtual ~CGUIWindowAddonBrowser(void);
virtual bool OnMessage(CGUIMessage& message);
- virtual bool OnAction(const CAction &action);
-protected:
- virtual void OnInitWindow();
- int GetSelectedItem();
- bool SelectItem(int select);
- void OnClick(int iItem);
- void OnSort();
- void ClearListItems();
- void Update();
- void SetupControls();
- void FreeControls();
- bool OnContextMenu(int iItem);
+ // job callback
+ void OnJobComplete(unsigned int jobID, bool success, CJob* job);
- CFileItemList* m_vecItems;
- std::vector<ADDON::TYPE> m_categories;
- int m_currentCategory;
+ static void AddJob(const CStdString& path);
+protected:
+ virtual void GetContextButtons(int itemNumber, CContextButtons &buttons);
+ virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button);
+ virtual bool OnClick(int iItem);
+ virtual void UpdateButtons();
};
1  xbmc/Makefile.in
View
@@ -29,6 +29,7 @@ SRCS=Application.cpp \
GUIDialogMusicScan.cpp \
GUIViewControl.cpp \
GUIViewState.cpp \
+ GUIViewStateAddonBrowser.cpp \
GUIViewStateMusic.cpp \
GUIWindowMusicBase.cpp \
GUIWindowMusicInfo.cpp \
3  xbmc/Settings.cpp
View
@@ -95,6 +95,7 @@ void CSettings::Initialize()
m_bMyVideoPlaylistShuffle = false;
m_bMyVideoNavFlatten = false;
m_bStartVideoWindowed = false;
+ m_bAddonAutoUpdate = true;
m_nVolumeLevel = 0;
m_dynamicRangeCompressionLevel = 0;
@@ -701,6 +702,7 @@ bool CSettings::LoadSettings(const CStdString& strSettingsFile)
GetFloat(pElement, "subtitledelay", m_defaultVideoSettings.m_SubtitleDelay, 0.0f, -10.0f, 10.0f);
XMLUtils::GetBoolean(pElement, "autocrop", m_defaultVideoSettings.m_Crop);
XMLUtils::GetBoolean(pElement, "nonlinstretch", m_defaultVideoSettings.m_CustomNonLinStretch);
+ XMLUtils::GetBoolean(pElement, "addonautoupdate", m_bAddonAutoUpdate);
m_defaultVideoSettings.m_SubtitleCached = false;
}
@@ -863,6 +865,7 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo
XMLUtils::SetFloat(pNode, "subtitledelay", m_defaultVideoSettings.m_SubtitleDelay);
XMLUtils::SetBoolean(pNode, "autocrop", m_defaultVideoSettings.m_Crop);
XMLUtils::SetBoolean(pNode, "nonlinstretch", m_defaultVideoSettings.m_CustomNonLinStretch);
+ XMLUtils::SetBoolean(pNode, "addonautoupdate", m_bAddonAutoUpdate);
// audio settings
1  xbmc/Settings.h
View
@@ -179,6 +179,7 @@ class CSettings
bool m_bMyVideoPlaylistShuffle;
bool m_bMyVideoNavFlatten;
bool m_bStartVideoWindowed;
+ bool m_bAddonAutoUpdate;
int m_iVideoStartWindow;
38 xbmc/addons/AddonManager.cpp
View
@@ -20,9 +20,12 @@
*/
#include "AddonManager.h"
#include "Addon.h"
+#include "AddonDatabase.h"
#include "StringUtils.h"
#include "RegExp.h"
#include "XMLUtils.h"
+#include "utils/JobManager.h"
+#include "utils/SingleLock.h"
#include "FileItem.h"
#include "Settings.h"
#include "GUISettings.h"
@@ -58,6 +61,8 @@ map<TYPE, IAddonMgrCallback*> CAddonMgr::m_managers;
CAddonMgr::CAddonMgr()
{
+ FindAddons();
+ m_watch.StartZero();
}
CAddonMgr::~CAddonMgr()
@@ -237,11 +242,11 @@ CStdString CAddonMgr::GetString(const CStdString &id, const int number)
void CAddonMgr::FindAddons()
{
CSingleLock lock(m_critSection);
+ m_addons.clear();
+ m_idMap.clear();
// parse the user & system dirs for addons of the requested type
CFileItemList items;
- if (!CSpecialProtocol::XBMCIsHome())
- CDirectory::GetDirectory("special://home/addons", items);
- CDirectory::GetDirectory("special://xbmc/addons", items);
+ CDirectory::GetDirectory("special://home/addons", items);
// store any addons with unresolved deps, then recheck at the end
VECADDONS unresolved;
@@ -667,5 +672,32 @@ AddonPtr CAddonMgr::AddonFromProps(AddonProps& addonProps)
return AddonPtr();
}
+void CAddonMgr::UpdateRepos()
+{
+ CSingleLock lock(m_critSection);
+ if (m_watch.GetElapsedSeconds() < 600)
+ return;
+ m_watch.StartZero();
+ VECADDONS addons;
+ GetAddons(ADDON_REPOSITORY,addons);
+ for (unsigned int i=0;i<addons.size();++i)
+ {
+ RepositoryPtr repo = boost::dynamic_pointer_cast<CRepository>(addons[i]);
+ if (repo->LastUpdate()+CDateTimeSpan(0,6,0,0) < CDateTime::GetCurrentDateTime())
+ {
+ CLog::Log(LOGDEBUG,"Checking repository %s for updates",repo->Name().c_str());
+ CJobManager::GetInstance().AddJob(new CRepositoryUpdateJob(repo),this);
+ }
+ }
+}
+
+void CAddonMgr::OnJobComplete(unsigned int jobID, bool success, CJob* job)
+{
+ if (!success)
+ return;
+
+ ((CRepositoryUpdateJob*)job)->m_repo->SetUpdated(CDateTime::GetCurrentDateTime());
+}
+
} /* namespace ADDON */
15 xbmc/addons/AddonManager.h
View
@@ -24,8 +24,8 @@
#include "tinyXML/tinyxml.h"
#include "utils/CriticalSection.h"
#include "StdString.h"
-#include "DateTime.h"
-#include "DownloadQueue.h"
+#include "utils/Job.h"
+#include "utils/Stopwatch.h"
#include <vector>
#include <map>
@@ -64,7 +64,7 @@ namespace ADDON
* otherwise. Services the generic callbacks available
* to all addon variants.
*/
- class CAddonMgr
+ class CAddonMgr : public IJobCallback
{
public:
static CAddonMgr* Get();
@@ -86,10 +86,11 @@ namespace ADDON
const CStdString &strPath);
static bool AddonFromInfoXML(const CStdString &path, AddonPtr &addon);
static AddonPtr AddonFromProps(AddonProps& props);
- private:
+ void UpdateRepos();
void FindAddons();
- bool LoadAddonsXML();
- bool SaveAddonsXML();
+
+ void OnJobComplete(unsigned int jobID, bool sucess, CJob* job);
+ private:
bool DependenciesMet(AddonPtr &addon);
bool UpdateIfKnown(AddonPtr &addon);
@@ -97,7 +98,7 @@ namespace ADDON
static CAddonMgr* m_pInstance;
static std::map<TYPE, IAddonMgrCallback*> m_managers;
MAPADDONS m_addons;
- CDateTime m_lastDirScan;
+ CStopWatch m_watch;
std::map<CStdString, AddonPtr> m_idMap;
CCriticalSection m_critSection;
};
Please sign in to comment.
Something went wrong with that request. Please try again.