ReactOS  0.4.15-dev-4614-ga5a6101
CAvailableApps Class Reference

#include <available.h>

Collaboration diagram for CAvailableApps:

Public Member Functions

 CAvailableApps ()
 
VOID FreeCachedEntries ()
 
BOOL Enum (INT EnumType, AVAILENUMPROC lpEnumProc, PVOID param)
 
BOOL AddSelected (CAvailableApplicationInfo *AvlbInfo)
 
BOOL RemoveSelected (CAvailableApplicationInfo *AvlbInfo)
 
VOID RemoveAllSelected ()
 
int GetSelectedCount ()
 
CAvailableApplicationInfoFindAppByPkgName (const ATL::CStringW &szPkgName) const
 
ATL::CSimpleArray< CAvailableApplicationInfoFindAppsByPkgNameList (const ATL::CSimpleArray< ATL::CStringW > &arrAppsNames) const
 

Static Public Member Functions

static BOOL UpdateAppsDB ()
 
static BOOL ForceUpdateAppsDB ()
 
static VOID DeleteCurrentAppsDB ()
 

Static Public Attributes

static AvailableStrings m_Strings
 

Private Attributes

ATL::CAtlList< CAvailableApplicationInfo * > m_InfoList
 
ATL::CAtlList< CAvailableApplicationInfo * > m_SelectedList
 

Detailed Description

Definition at line 106 of file available.h.

Constructor & Destructor Documentation

◆ CAvailableApps()

CAvailableApps::CAvailableApps ( )

Definition at line 337 of file available.cpp.

338 {
339 }

Member Function Documentation

◆ AddSelected()

BOOL CAvailableApps::AddSelected ( CAvailableApplicationInfo AvlbInfo)

Definition at line 551 of file available.cpp.

552 {
553  return m_SelectedList.AddTail(AvlbInfo) != 0;
554 }
ATL::CAtlList< CAvailableApplicationInfo * > m_SelectedList
Definition: available.h:109
POSITION AddTail(INARGTYPE element)
Definition: atlcoll.h:624

Referenced by CMainWindow::ItemCheckStateChanged().

◆ DeleteCurrentAppsDB()

VOID CAvailableApps::DeleteCurrentAppsDB ( )
static

Definition at line 382 of file available.cpp.

383 {
384  // Delete icons
386  PathAppendW(IconPath.GetBuffer(MAX_PATH), L"icons");
387  IconPath.ReleaseBuffer();
388  DeleteWithWildcard(IconPath + L"\\*.ico");
389 
390  // Delete leftover screenshots
391  ATL::CStringW ScrnshotFolder = m_Strings.szAppsPath;
392  PathAppendW(ScrnshotFolder.GetBuffer(MAX_PATH), L"screenshots");
393  ScrnshotFolder.ReleaseBuffer();
394  DeleteWithWildcard(IconPath + L"\\*.tmp");
395 
396  // Delete data base files (*.txt)
398 
400  RemoveDirectoryW(ScrnshotFolder);
403 }
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126
static void DeleteWithWildcard(const CStringW &DirWithFilter)
Definition: available.cpp:355
#define L(x)
Definition: ntvdm.h:50
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
static AvailableStrings m_Strings
Definition: available.h:112
#define MAX_PATH
Definition: compat.h:34
ATL::CStringW szPath
Definition: available.h:31
ATL::CStringW szAppsPath
Definition: available.h:33
static const WCHAR IconPath[]
Definition: install.c:51
ATL::CStringW szSearchPath
Definition: available.h:34

Referenced by ForceUpdateAppsDB().

◆ Enum()

BOOL CAvailableApps::Enum ( INT  EnumType,
AVAILENUMPROC  lpEnumProc,
PVOID  param 
)

Definition at line 444 of file available.cpp.

445 {
446  if (EnumType == ENUM_CAT_SELECTED)
447  {
448  CAvailableApplicationInfo *EnumAvlbInfo = NULL;
449 
450  // enum all object in m_SelectedList and invoke callback
454  {
455  EnumAvlbInfo->RefreshAppInfo(m_Strings);
456 
457  if (lpEnumProc)
458  lpEnumProc(EnumAvlbInfo, TRUE, param);
459  }
460  return TRUE;
461  }
462  else
463  {
465  WIN32_FIND_DATAW FindFileData;
466 
467  hFind = FindFirstFileW(m_Strings.szSearchPath.GetString(), &FindFileData);
468 
469  if (hFind == INVALID_HANDLE_VALUE)
470  {
471  //no db yet
472  return FALSE;
473  }
474 
475  do
476  {
477  // loop for all the cached entries
478  POSITION CurrentListPosition = m_InfoList.GetHeadPosition();
480 
481  while (CurrentListPosition != NULL)
482  {
483  POSITION LastListPosition = CurrentListPosition;
484  Info = m_InfoList.GetNext(CurrentListPosition);
485 
486  // do we already have this entry in cache?
487  if (Info->m_sFileName == FindFileData.cFileName)
488  {
489  // is it current enough, or the file has been modified since our last time here?
490  if (CompareFileTime(&FindFileData.ftLastWriteTime, &Info->m_ftCacheStamp) == 1)
491  {
492  // recreate our cache, this is the slow path
493  m_InfoList.RemoveAt(LastListPosition);
494 
495  // also remove this in selected list (if exist)
497 
498  delete Info;
499  Info = NULL;
500  break;
501  }
502  else
503  {
504  // speedy path, compare directly, we already have the data
505  goto skip_if_cached;
506  }
507  }
508  }
509 
510  // create a new entry
511  Info = new CAvailableApplicationInfo(FindFileData.cFileName, m_Strings);
512 
513  // set a timestamp for the next time
514  Info->SetLastWriteTime(&FindFileData.ftLastWriteTime);
515 
516  /* Check if we have the download URL */
517  if (Info->m_szUrlDownload.IsEmpty())
518  {
519  /* Can't use it, delete it */
520  delete Info;
521  continue;
522  }
523 
525 
526  skip_if_cached:
527  if (EnumType == Info->m_Category
528  || EnumType == ENUM_ALL_AVAILABLE)
529  {
530  Info->RefreshAppInfo(m_Strings);
531 
532  if (lpEnumProc)
533  {
534  if (m_SelectedList.Find(Info))
535  {
536  lpEnumProc(Info, TRUE, param);
537  }
538  else
539  {
540  lpEnumProc(Info, FALSE, param);
541  }
542  }
543  }
544  } while (FindNextFileW(hFind, &FindFileData));
545 
546  FindClose(hFind);
547  return TRUE;
548  }
549 }
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
POSITION GetHeadPosition() const
Definition: atlcoll.h:549
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
#define FALSE
Definition: types.h:117
ULONG CurrentPosition
Definition: patchapi.h:57
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:561
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
static AvailableStrings m_Strings
Definition: available.h:112
GLfloat param
Definition: glext.h:5796
PCXSTR GetString() const
Definition: atlsimpstr.h:361
E & GetAt(_In_ POSITION pos)
Definition: atlcoll.h:593
ATL::CAtlList< CAvailableApplicationInfo * > m_SelectedList
Definition: available.h:109
ATL::CAtlList< CAvailableApplicationInfo * > m_InfoList
Definition: available.h:108
POSITION AddTail(INARGTYPE element)
Definition: atlcoll.h:624
#define NULL
Definition: types.h:112
void RemoveAt(_In_ POSITION pos)
Definition: atlcoll.h:746
POSITION Find(INARGTYPE element, _In_opt_ POSITION posStartAfter=NULL) const
Definition: atlcoll.h:771
ATL::CStringW szSearchPath
Definition: available.h:34
BOOL RemoveSelected(CAvailableApplicationInfo *AvlbInfo)
Definition: available.cpp:556
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by HandleFindCommand(), HandleInfoCommand(), HandleInstallCommand(), HandleSetupCommand(), CMainWindow::InstallApplication(), CMainWindow::OnCommand(), and CMainWindow::UpdateApplicationsList().

◆ FindAppByPkgName()

CAvailableApplicationInfo * CAvailableApps::FindAppByPkgName ( const ATL::CStringW szPkgName) const

Definition at line 578 of file available.cpp.

579 {
580  if (m_InfoList.IsEmpty())
581  {
582  return NULL;
583  }
584 
585  // linear search
586  POSITION CurrentListPosition = m_InfoList.GetHeadPosition();
588  while (CurrentListPosition != NULL)
589  {
590  info = m_InfoList.GetNext(CurrentListPosition);
591  if (info->m_szPkgName.CompareNoCase(szPkgName) == 0)
592  {
593  return info;
594  }
595  }
596  return NULL;
597 }
POSITION GetHeadPosition() const
Definition: atlcoll.h:549
static struct _test_info info[]
Definition: SetCursorPos.c:19
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:561
ATL::CAtlList< CAvailableApplicationInfo * > m_InfoList
Definition: available.h:108
#define NULL
Definition: types.h:112
bool IsEmpty() const
Definition: atlcoll.h:543

Referenced by FindAppsByPkgNameList(), and HandleInfoCommand().

◆ FindAppsByPkgNameList()

ATL::CSimpleArray< CAvailableApplicationInfo > CAvailableApps::FindAppsByPkgNameList ( const ATL::CSimpleArray< ATL::CStringW > &  arrAppsNames) const

Definition at line 599 of file available.cpp.

600 {
602  for (INT i = 0; i < PkgNameList.GetSize(); ++i)
603  {
605  if (Info)
606  {
607  result.Add(*Info);
608  }
609  }
610  return result;
611 }
GLuint64EXT * result
Definition: glext.h:11304
CAvailableApplicationInfo * FindAppByPkgName(const ATL::CStringW &szPkgName) const
Definition: available.cpp:578
int32_t INT
Definition: typedefs.h:58
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by HandleInstallCommand(), and HandleSetupCommand().

◆ ForceUpdateAppsDB()

BOOL CAvailableApps::ForceUpdateAppsDB ( )
static

Definition at line 438 of file available.cpp.

439 {
441  return UpdateAppsDB();
442 }
static BOOL UpdateAppsDB()
Definition: available.cpp:405
static VOID DeleteCurrentAppsDB()
Definition: available.cpp:382

Referenced by CMainWindow::OnCommand(), and ParseCmdAndExecute().

◆ FreeCachedEntries()

VOID CAvailableApps::FreeCachedEntries ( )

Definition at line 341 of file available.cpp.

342 {
343  POSITION InfoListPosition = m_InfoList.GetHeadPosition();
344 
345  /* loop and deallocate all the cached app infos in the list */
346  while (InfoListPosition)
347  {
348  CAvailableApplicationInfo* Info = m_InfoList.GetNext(InfoListPosition);
349  delete Info;
350  }
351 
353 }
POSITION GetHeadPosition() const
Definition: atlcoll.h:549
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:561
void RemoveAll()
Definition: atlcoll.h:725
ATL::CAtlList< CAvailableApplicationInfo * > m_InfoList
Definition: available.h:108

Referenced by CMainWindow::ProcessWindowMessage().

◆ GetSelectedCount()

int CAvailableApps::GetSelectedCount ( )

Definition at line 573 of file available.cpp.

574 {
575  return m_SelectedList.GetCount();
576 }
size_t GetCount() const
Definition: atlcoll.h:537
ATL::CAtlList< CAvailableApplicationInfo * > m_SelectedList
Definition: available.h:109

Referenced by CMainWindow::UpdateStatusBarText().

◆ RemoveAllSelected()

VOID CAvailableApps::RemoveAllSelected ( )

Definition at line 567 of file available.cpp.

568 {
570  return;
571 }
void RemoveAll()
Definition: atlcoll.h:725
ATL::CAtlList< CAvailableApplicationInfo * > m_SelectedList
Definition: available.h:109

Referenced by CMainWindow::InstallApplication(), and CMainWindow::OnCommand().

◆ RemoveSelected()

BOOL CAvailableApps::RemoveSelected ( CAvailableApplicationInfo AvlbInfo)

Definition at line 556 of file available.cpp.

557 {
558  POSITION Position = m_SelectedList.Find(AvlbInfo);
559  if (Position)
560  {
562  return TRUE;
563  }
564  return FALSE;
565 }
#define TRUE
Definition: types.h:120
static COORD Position
Definition: mouse.c:34
#define FALSE
Definition: types.h:117
ATL::CAtlList< CAvailableApplicationInfo * > m_SelectedList
Definition: available.h:109
void RemoveAt(_In_ POSITION pos)
Definition: atlcoll.h:746
POSITION Find(INARGTYPE element, _In_opt_ POSITION posStartAfter=NULL) const
Definition: atlcoll.h:771

Referenced by Enum(), and CMainWindow::ItemCheckStateChanged().

◆ UpdateAppsDB()

BOOL CAvailableApps::UpdateAppsDB ( )
static

Definition at line 405 of file available.cpp.

406 {
408  WIN32_FIND_DATAW FindFileData;
409 
411  {
412  return FALSE;
413  }
414 
415  // If there are some files in the db folder, we're good
416  hFind = FindFirstFileW(m_Strings.szSearchPath, &FindFileData);
417  if (hFind != INVALID_HANDLE_VALUE)
418  {
419  FindClose(hFind);
420  return TRUE;
421  }
422 
425 
429  {
430  return FALSE;
431  }
432 
434 
435  return TRUE;
436 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
BOOL ExtractFilesFromCab(const ATL::CStringW &szCabName, const ATL::CStringW &szCabDir, const ATL::CStringW &szOutputDir)
Definition: cabinet.cpp:281
#define APPLICATION_DATABASE_URL
Definition: defines.h:32
#define TRUE
Definition: types.h:120
VOID DownloadApplicationsDB(LPCWSTR lpUrl, BOOL IsOfficial)
Definition: loaddlg.cpp:1048
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
WCHAR szSourceURL[INTERNET_MAX_URL_LENGTH]
Definition: settings.h:24
BOOL bUseSource
Definition: settings.h:23
ATL::CStringW szCabPath
Definition: available.h:32
#define FALSE
Definition: types.h:117
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:20
static AvailableStrings m_Strings
Definition: available.h:112
ATL::CStringW szCabDir
Definition: available.h:36
ATL::CStringW szPath
Definition: available.h:31
#define NULL
Definition: types.h:112
ATL::CStringW szAppsPath
Definition: available.h:33
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
ATL::CStringW szSearchPath
Definition: available.h:34
ATL::CStringW szCabName
Definition: available.h:35
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by ForceUpdateAppsDB(), HandleFindCommand(), HandleInfoCommand(), HandleInstallCommand(), and HandleSetupCommand().

Member Data Documentation

◆ m_InfoList

ATL::CAtlList<CAvailableApplicationInfo*> CAvailableApps::m_InfoList
private

Definition at line 108 of file available.h.

Referenced by Enum(), FindAppByPkgName(), and FreeCachedEntries().

◆ m_SelectedList

ATL::CAtlList< CAvailableApplicationInfo*> CAvailableApps::m_SelectedList
private

Definition at line 109 of file available.h.

Referenced by AddSelected(), Enum(), GetSelectedCount(), RemoveAllSelected(), and RemoveSelected().

◆ m_Strings

AvailableStrings CAvailableApps::m_Strings
static

The documentation for this class was generated from the following files: