PageRenderTime 72ms CodeModel.GetById 22ms app.highlight 45ms RepoModel.GetById 1ms app.codeStats 0ms

/xbmc/pictures/GUIWindowPictures.cpp

http://github.com/xbmc/xbmc
C++ | 615 lines | 522 code | 75 blank | 18 comment | 153 complexity | fd5a316991d7dc95f19e9adbf90d71bc MD5 | raw file
  1/*
  2 *  Copyright (C) 2005-2020 Team Kodi
  3 *  This file is part of Kodi - https://kodi.tv
  4 *
  5 *  SPDX-License-Identifier: GPL-2.0-or-later
  6 *  See LICENSES/README.md for more information.
  7 */
  8
  9#include "GUIWindowPictures.h"
 10
 11#include "Application.h"
 12#include "Autorun.h"
 13#include "GUIDialogPictureInfo.h"
 14#include "GUIPassword.h"
 15#include "GUIWindowSlideShow.h"
 16#include "PictureInfoLoader.h"
 17#include "PlayListPlayer.h"
 18#include "ServiceBroker.h"
 19#include "URL.h"
 20#include "Util.h"
 21#include "addons/GUIDialogAddonInfo.h"
 22#include "dialogs/GUIDialogMediaSource.h"
 23#include "dialogs/GUIDialogProgress.h"
 24#include "guilib/GUIComponent.h"
 25#include "guilib/GUIWindowManager.h"
 26#include "interfaces/AnnouncementManager.h"
 27#include "media/MediaLockState.h"
 28#include "messaging/helpers/DialogOKHelper.h"
 29#include "playlists/PlayList.h"
 30#include "playlists/PlayListFactory.h"
 31#include "settings/MediaSourceSettings.h"
 32#include "settings/Settings.h"
 33#include "settings/SettingsComponent.h"
 34#include "threads/SystemClock.h"
 35#include "utils/SortUtils.h"
 36#include "utils/StringUtils.h"
 37#include "utils/URIUtils.h"
 38#include "utils/Variant.h"
 39#include "utils/XTimeUtils.h"
 40#include "utils/log.h"
 41#include "view/GUIViewState.h"
 42
 43#define CONTROL_BTNVIEWASICONS      2
 44#define CONTROL_BTNSORTBY           3
 45#define CONTROL_BTNSORTASC          4
 46#define CONTROL_LABELFILES         12
 47
 48using namespace XFILE;
 49using namespace PLAYLIST;
 50using namespace KODI::MESSAGING;
 51
 52#define CONTROL_BTNSLIDESHOW   6
 53#define CONTROL_BTNSLIDESHOW_RECURSIVE   7
 54#define CONTROL_SHUFFLE      9
 55
 56CGUIWindowPictures::CGUIWindowPictures(void)
 57    : CGUIMediaWindow(WINDOW_PICTURES, "MyPics.xml")
 58{
 59  m_thumbLoader.SetObserver(this);
 60  m_slideShowStarted = false;
 61  m_dlgProgress = NULL;
 62}
 63
 64void CGUIWindowPictures::OnInitWindow()
 65{
 66  CGUIMediaWindow::OnInitWindow();
 67  if (m_slideShowStarted)
 68  {
 69    CGUIWindowSlideShow* wndw = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW);
 70    std::string path;
 71    if (wndw && wndw->GetCurrentSlide())
 72      path = URIUtils::GetDirectory(wndw->GetCurrentSlide()->GetPath());
 73    if (m_vecItems->IsPath(path))
 74    {
 75      if (wndw && wndw->GetCurrentSlide())
 76        m_viewControl.SetSelectedItem(wndw->GetCurrentSlide()->GetPath());
 77      SaveSelectedItemInHistory();
 78    }
 79    m_slideShowStarted = false;
 80  }
 81}
 82
 83CGUIWindowPictures::~CGUIWindowPictures(void) = default;
 84
 85bool CGUIWindowPictures::OnMessage(CGUIMessage& message)
 86{
 87  switch ( message.GetMessage() )
 88  {
 89  case GUI_MSG_WINDOW_DEINIT:
 90    {
 91      if (m_thumbLoader.IsLoading())
 92        m_thumbLoader.StopThread();
 93
 94    }
 95    break;
 96
 97  case GUI_MSG_WINDOW_INIT:
 98    {
 99      // is this the first time accessing this window?
100      if (m_vecItems->GetPath() == "?" && message.GetStringParam().empty())
101        message.SetStringParam(CMediaSourceSettings::GetInstance().GetDefaultSource("pictures"));
102
103      m_dlgProgress = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS);
104    }
105    break;
106
107  case GUI_MSG_CLICKED:
108    {
109      int iControl = message.GetSenderId();
110      if (iControl == CONTROL_BTNSLIDESHOW) // Slide Show
111      {
112        OnSlideShow();
113      }
114      else if (iControl == CONTROL_BTNSLIDESHOW_RECURSIVE) // Recursive Slide Show
115      {
116        OnSlideShowRecursive();
117      }
118      else if (iControl == CONTROL_SHUFFLE)
119      {
120        const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings();
121        settings->ToggleBool(CSettings::SETTING_SLIDESHOW_SHUFFLE);
122        settings->Save();
123      }
124      else if (m_viewControl.HasControl(iControl))  // list/thumb control
125      {
126        int iItem = m_viewControl.GetSelectedItem();
127        int iAction = message.GetParam1();
128
129        // iItem is checked for validity inside these routines
130        if (iAction == ACTION_DELETE_ITEM)
131        {
132          // is delete allowed?
133          if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_ALLOWFILEDELETION))
134            OnDeleteItem(iItem);
135          else
136            return false;
137        }
138        else if (iAction == ACTION_PLAYER_PLAY)
139        {
140          ShowPicture(iItem, true);
141          return true;
142        }
143        else if (iAction == ACTION_SHOW_INFO)
144        {
145          OnItemInfo(iItem);
146          return true;
147        }
148      }
149    }
150    break;
151  }
152  return CGUIMediaWindow::OnMessage(message);
153}
154
155void CGUIWindowPictures::UpdateButtons()
156{
157  CGUIMediaWindow::UpdateButtons();
158
159  // Update the shuffle button
160  SET_CONTROL_SELECTED(GetID(), CONTROL_SHUFFLE, CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_SLIDESHOW_SHUFFLE));
161
162  // check we can slideshow or recursive slideshow
163  int nFolders = m_vecItems->GetFolderCount();
164  if (nFolders == m_vecItems->Size() ||
165      m_vecItems->GetPath() == "addons://sources/image/")
166  {
167    CONTROL_DISABLE(CONTROL_BTNSLIDESHOW);
168  }
169  else
170  {
171    CONTROL_ENABLE(CONTROL_BTNSLIDESHOW);
172  }
173  if (m_guiState.get() && !m_guiState->HideParentDirItems())
174    nFolders--;
175  if (m_vecItems->Size() == 0 || nFolders == 0 ||
176      m_vecItems->GetPath() == "addons://sources/image/")
177  {
178    CONTROL_DISABLE(CONTROL_BTNSLIDESHOW_RECURSIVE);
179  }
180  else
181  {
182    CONTROL_ENABLE(CONTROL_BTNSLIDESHOW_RECURSIVE);
183  }
184}
185
186void CGUIWindowPictures::OnPrepareFileItems(CFileItemList& items)
187{
188  CGUIMediaWindow::OnPrepareFileItems(items);
189
190  for (int i=0;i<items.Size();++i )
191    if (StringUtils::EqualsNoCase(items[i]->GetLabel(), "folder.jpg"))
192      items.Remove(i);
193
194  if (items.GetFolderCount() == items.Size() || !CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_PICTURES_USETAGS))
195    return;
196
197  // Start the music info loader thread
198  CPictureInfoLoader loader;
199  loader.SetProgressCallback(m_dlgProgress);
200  loader.Load(items);
201
202  bool bShowProgress = !CServiceBroker::GetGUI()->GetWindowManager().HasModalDialog(true);
203  bool bProgressVisible = false;
204
205  unsigned int tick=XbmcThreads::SystemClockMillis();
206
207  while (loader.IsLoading() && m_dlgProgress && !m_dlgProgress->IsCanceled())
208  {
209    if (bShowProgress)
210    { // Do we have to init a progress dialog?
211      unsigned int elapsed=XbmcThreads::SystemClockMillis()-tick;
212
213      if (!bProgressVisible && elapsed>1500 && m_dlgProgress)
214      { // tag loading takes more then 1.5 secs, show a progress dialog
215        CURL url(items.GetPath());
216
217        m_dlgProgress->SetHeading(CVariant{189});
218        m_dlgProgress->SetLine(0, CVariant{505});
219        m_dlgProgress->SetLine(1, CVariant{""});
220        m_dlgProgress->SetLine(2, CVariant{url.GetWithoutUserDetails()});
221        m_dlgProgress->Open();
222        m_dlgProgress->ShowProgressBar(true);
223        bProgressVisible = true;
224      }
225
226      if (bProgressVisible && m_dlgProgress)
227      { // keep GUI alive
228        m_dlgProgress->Progress();
229      }
230    } // if (bShowProgress)
231    KODI::TIME::Sleep(1);
232  } // while (loader.IsLoading())
233
234  if (bProgressVisible && m_dlgProgress)
235    m_dlgProgress->Close();
236}
237
238bool CGUIWindowPictures::Update(const std::string &strDirectory, bool updateFilterPath /* = true */)
239{
240  if (m_thumbLoader.IsLoading())
241    m_thumbLoader.StopThread();
242
243  if (!CGUIMediaWindow::Update(strDirectory, updateFilterPath))
244    return false;
245
246  m_vecItems->SetArt("thumb", "");
247  if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_PICTURES_GENERATETHUMBS))
248    m_thumbLoader.Load(*m_vecItems);
249
250  CPictureThumbLoader thumbLoader;
251  std::string thumb = thumbLoader.GetCachedImage(*m_vecItems, "thumb");
252  m_vecItems->SetArt("thumb", thumb);
253
254  return true;
255}
256
257bool CGUIWindowPictures::OnClick(int iItem, const std::string &player)
258{
259  if ( iItem < 0 || iItem >= m_vecItems->Size() ) return true;
260  CFileItemPtr pItem = m_vecItems->Get(iItem);
261
262  if (pItem->IsCBZ() || pItem->IsCBR())
263  {
264    CURL pathToUrl;
265    if (pItem->IsCBZ())
266      pathToUrl = URIUtils::CreateArchivePath("zip", pItem->GetURL(), "");
267    else
268      pathToUrl = URIUtils::CreateArchivePath("rar", pItem->GetURL(), "");
269
270    OnShowPictureRecursive(pathToUrl.Get());
271    return true;
272  }
273  else if (CGUIMediaWindow::OnClick(iItem, player))
274    return true;
275
276  return false;
277}
278
279bool CGUIWindowPictures::GetDirectory(const std::string &strDirectory, CFileItemList& items)
280{
281  if (!CGUIMediaWindow::GetDirectory(strDirectory, items))
282    return false;
283
284  std::string label;
285  if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::GetInstance().GetSources("pictures"), &label))
286    items.SetLabel(label);
287
288  if (items.GetContent().empty() && !items.IsVirtualDirectoryRoot() && !items.IsPlugin())
289    items.SetContent("images");
290  return true;
291}
292
293bool CGUIWindowPictures::OnPlayMedia(int iItem, const std::string &player)
294{
295  if (m_vecItems->Get(iItem)->IsVideo())
296    return CGUIMediaWindow::OnPlayMedia(iItem);
297
298  return ShowPicture(iItem, false);
299}
300
301bool CGUIWindowPictures::ShowPicture(int iItem, bool startSlideShow)
302{
303  if ( iItem < 0 || iItem >= m_vecItems->Size() ) return false;
304  CFileItemPtr pItem = m_vecItems->Get(iItem);
305  std::string strPicture = pItem->GetPath();
306
307#ifdef HAS_DVD_DRIVE
308  if (pItem->IsDVD())
309    return MEDIA_DETECT::CAutorun::PlayDiscAskResume(m_vecItems->Get(iItem)->GetPath());
310#endif
311
312  if (pItem->m_bIsShareOrDrive)
313    return false;
314
315  CGUIWindowSlideShow *pSlideShow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW);
316  if (!pSlideShow)
317    return false;
318  if (g_application.GetAppPlayer().IsPlayingVideo())
319    g_application.StopPlaying();
320
321  pSlideShow->Reset();
322  bool bShowVideos = CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_PICTURES_SHOWVIDEOS);
323  for (const auto pItem : *m_vecItems)
324  {
325    if (!pItem->m_bIsFolder &&
326        !(URIUtils::IsRAR(pItem->GetPath()) || URIUtils::IsZIP(pItem->GetPath())) &&
327        (pItem->IsPicture() || (bShowVideos && pItem->IsVideo())))
328    {
329      pSlideShow->Add(pItem.get());
330    }
331  }
332
333  if (pSlideShow->NumSlides() == 0)
334    return false;
335
336  pSlideShow->Select(strPicture);
337
338  if (startSlideShow)
339    pSlideShow->StartSlideShow();
340  else
341  {
342    CVariant param;
343    param["player"]["speed"] = 1;
344    param["player"]["playerid"] = PLAYLIST_PICTURE;
345    CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "xbmc", "OnPlay", pSlideShow->GetCurrentSlide(), param);
346  }
347
348  m_slideShowStarted = true;
349  CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_SLIDESHOW);
350
351  return true;
352}
353
354void CGUIWindowPictures::OnShowPictureRecursive(const std::string& strPath)
355{
356  CGUIWindowSlideShow *pSlideShow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW);
357  if (pSlideShow)
358  {
359    // stop any video
360    if (g_application.GetAppPlayer().IsPlayingVideo())
361      g_application.StopPlaying();
362
363    SortDescription sorting = m_guiState->GetSortMethod();
364    pSlideShow->AddFromPath(strPath, true,
365                            sorting.sortBy, sorting.sortOrder, sorting.sortAttributes);
366    if (pSlideShow->NumSlides())
367    {
368      m_slideShowStarted = true;
369      CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_SLIDESHOW);
370    }
371  }
372}
373
374void CGUIWindowPictures::OnSlideShowRecursive(const std::string &strPicture)
375{
376  CGUIWindowSlideShow *pSlideShow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW);
377  if (pSlideShow)
378  {
379    std::string strExtensions;
380    CFileItemList items;
381    CGUIViewState* viewState=CGUIViewState::GetViewState(GetID(), items);
382    if (viewState)
383    {
384      strExtensions = viewState->GetExtensions();
385      delete viewState;
386    }
387    m_slideShowStarted = true;
388
389    SortDescription sorting = m_guiState->GetSortMethod();
390    pSlideShow->RunSlideShow(strPicture, true,
391                             CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_SLIDESHOW_SHUFFLE),false,
392                             "", true,
393                             sorting.sortBy, sorting.sortOrder, sorting.sortAttributes,
394                             strExtensions);
395  }
396}
397
398void CGUIWindowPictures::OnSlideShowRecursive()
399{
400  std::string strEmpty = "";
401  OnSlideShowRecursive(m_vecItems->GetPath());
402}
403
404void CGUIWindowPictures::OnSlideShow()
405{
406  OnSlideShow(m_vecItems->GetPath());
407}
408
409void CGUIWindowPictures::OnSlideShow(const std::string &strPicture)
410{
411  CGUIWindowSlideShow *pSlideShow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW);
412  if (pSlideShow)
413  {
414    std::string strExtensions;
415    CFileItemList items;
416    CGUIViewState* viewState=CGUIViewState::GetViewState(GetID(), items);
417    if (viewState)
418    {
419      strExtensions = viewState->GetExtensions();
420      delete viewState;
421    }
422    m_slideShowStarted = true;
423
424    SortDescription sorting = m_guiState->GetSortMethod();
425    pSlideShow->RunSlideShow(strPicture, false ,false, false,
426                             "", true,
427                             sorting.sortBy, sorting.sortOrder, sorting.sortAttributes,
428                             strExtensions);
429  }
430}
431
432void CGUIWindowPictures::OnRegenerateThumbs()
433{
434  if (m_thumbLoader.IsLoading()) return;
435  m_thumbLoader.SetRegenerateThumbs(true);
436  m_thumbLoader.Load(*m_vecItems);
437}
438
439void CGUIWindowPictures::GetContextButtons(int itemNumber, CContextButtons &buttons)
440{
441  CFileItemPtr item;
442  if (itemNumber >= 0 && itemNumber < m_vecItems->Size())
443    item = m_vecItems->Get(itemNumber);
444
445  if (item)
446  {
447    if ( m_vecItems->IsVirtualDirectoryRoot() || m_vecItems->GetPath() == "sources://pictures/" )
448    {
449      CGUIDialogContextMenu::GetContextButtons("pictures", item, buttons);
450    }
451    else
452    {
453      if (item)
454      {
455        if (!(item->m_bIsFolder || item->IsZIP() || item->IsRAR() || item->IsCBZ() || item->IsCBR() || item->IsScript()))
456        {
457          if (item->IsPicture())
458            buttons.Add(CONTEXT_BUTTON_INFO, 13406); // picture info
459          buttons.Add(CONTEXT_BUTTON_VIEW_SLIDESHOW, item->m_bIsFolder ? 13317 : 13422);      // View Slideshow
460        }
461        if (item->m_bIsFolder)
462          buttons.Add(CONTEXT_BUTTON_RECURSIVE_SLIDESHOW, 13318);     // Recursive Slideshow
463
464        if (!m_thumbLoader.IsLoading())
465          buttons.Add(CONTEXT_BUTTON_REFRESH_THUMBS, 13315);         // Create Thumbnails
466        if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_ALLOWFILEDELETION) && !item->IsReadOnly())
467        {
468          buttons.Add(CONTEXT_BUTTON_DELETE, 117);
469          buttons.Add(CONTEXT_BUTTON_RENAME, 118);
470        }
471      }
472
473      if (!item->IsPlugin() && !item->IsScript() && !m_vecItems->IsPlugin())
474        buttons.Add(CONTEXT_BUTTON_SWITCH_MEDIA, 523);
475    }
476  }
477  CGUIMediaWindow::GetContextButtons(itemNumber, buttons);
478}
479
480bool CGUIWindowPictures::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
481{
482  CFileItemPtr item = (itemNumber >= 0 && itemNumber < m_vecItems->Size()) ? m_vecItems->Get(itemNumber) : CFileItemPtr();
483  if (CGUIDialogContextMenu::OnContextButton("pictures", item, button))
484  {
485    Update("");
486    return true;
487  }
488  switch (button)
489  {
490  case CONTEXT_BUTTON_VIEW_SLIDESHOW:
491    if (item && item->m_bIsFolder)
492      OnSlideShow(item->GetPath());
493    else
494      ShowPicture(itemNumber, true);
495    return true;
496  case CONTEXT_BUTTON_RECURSIVE_SLIDESHOW:
497    if (item)
498      OnSlideShowRecursive(item->GetPath());
499    return true;
500  case CONTEXT_BUTTON_INFO:
501    OnItemInfo(itemNumber);
502    return true;
503  case CONTEXT_BUTTON_REFRESH_THUMBS:
504    OnRegenerateThumbs();
505    return true;
506  case CONTEXT_BUTTON_DELETE:
507    OnDeleteItem(itemNumber);
508    return true;
509  case CONTEXT_BUTTON_RENAME:
510    OnRenameItem(itemNumber);
511    return true;
512  case CONTEXT_BUTTON_SWITCH_MEDIA:
513    CGUIDialogContextMenu::SwitchMedia("pictures", m_vecItems->GetPath());
514    return true;
515  default:
516    break;
517  }
518  return CGUIMediaWindow::OnContextButton(itemNumber, button);
519}
520
521bool CGUIWindowPictures::OnAddMediaSource()
522{
523  return CGUIDialogMediaSource::ShowAndAddMediaSource("pictures");
524}
525
526void CGUIWindowPictures::OnItemLoaded(CFileItem *pItem)
527{
528  CPictureThumbLoader::ProcessFoldersAndArchives(pItem);
529}
530
531void CGUIWindowPictures::LoadPlayList(const std::string& strPlayList)
532{
533  CLog::Log(LOGDEBUG,"CGUIWindowPictures::LoadPlayList()... converting playlist into slideshow: %s", strPlayList.c_str());
534  std::unique_ptr<CPlayList> pPlayList (CPlayListFactory::Create(strPlayList));
535  if (nullptr != pPlayList)
536  {
537    if (!pPlayList->Load(strPlayList))
538    {
539      HELPERS::ShowOKDialogText(CVariant{6}, CVariant{477});
540      return ; //hmmm unable to load playlist?
541    }
542  }
543
544  CPlayList playlist = *pPlayList;
545  if (playlist.size() > 0)
546  {
547    // set up slideshow
548    CGUIWindowSlideShow *pSlideShow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW);
549    if (!pSlideShow)
550      return;
551    if (g_application.GetAppPlayer().IsPlayingVideo())
552      g_application.StopPlaying();
553
554    // convert playlist items into slideshow items
555    pSlideShow->Reset();
556    for (int i = 0; i < playlist.size(); ++i)
557    {
558      CFileItemPtr pItem = playlist[i];
559      //CLog::Log(LOGDEBUG,"-- playlist item: %s", pItem->GetPath().c_str());
560      if (pItem->IsPicture() && !(pItem->IsZIP() || pItem->IsRAR() || pItem->IsCBZ() || pItem->IsCBR()))
561        pSlideShow->Add(pItem.get());
562    }
563
564    // start slideshow if there are items
565    pSlideShow->StartSlideShow();
566    if (pSlideShow->NumSlides())
567      CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_SLIDESHOW);
568  }
569}
570
571void CGUIWindowPictures::OnItemInfo(int itemNumber)
572{
573  CFileItemPtr item = m_vecItems->Get(itemNumber);
574  if (!item)
575    return;
576  if (!m_vecItems->IsPlugin() && (item->IsPlugin() || item->IsScript()))
577  {
578    CGUIDialogAddonInfo::ShowForItem(item);
579    return;
580  }
581  if (item->m_bIsFolder || item->IsZIP() || item->IsRAR() || item->IsCBZ() || item->IsCBR() || !item->IsPicture())
582    return;
583  CGUIDialogPictureInfo *pictureInfo = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogPictureInfo>(WINDOW_DIALOG_PICTURE_INFO);
584  if (pictureInfo)
585  {
586    pictureInfo->SetPicture(item.get());
587    pictureInfo->Open();
588  }
589}
590
591std::string CGUIWindowPictures::GetStartFolder(const std::string &dir)
592{
593  if (StringUtils::EqualsNoCase(dir, "plugins") ||
594      StringUtils::EqualsNoCase(dir, "addons"))
595    return "addons://sources/image/";
596
597  SetupShares();
598  VECSOURCES shares;
599  m_rootDir.GetSources(shares);
600  bool bIsSourceName = false;
601  int iIndex = CUtil::GetMatchingSource(dir, shares, bIsSourceName);
602  if (iIndex > -1)
603  {
604    if (iIndex < static_cast<int>(shares.size()) && shares[iIndex].m_iHasLock == LOCK_STATE_LOCKED)
605    {
606      CFileItem item(shares[iIndex]);
607      if (!g_passwordManager.IsItemUnlocked(&item,"pictures"))
608        return "";
609    }
610    if (bIsSourceName)
611      return shares[iIndex].strPath;
612    return dir;
613  }
614  return CGUIMediaWindow::GetStartFolder(dir);
615}