ReactOS  0.4.15-dev-1177-g6cb3b62
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
 
const ATL::CStringWGetFolderPath () const
 
const ATL::CStringWGetAppPath () const
 
const ATL::CStringWGetCabPath () 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 105 of file available.h.

Constructor & Destructor Documentation

◆ CAvailableApps()

CAvailableApps::CAvailableApps ( )

Definition at line 341 of file available.cpp.

342 {
343 }

Member Function Documentation

◆ AddSelected()

BOOL CAvailableApps::AddSelected ( CAvailableApplicationInfo AvlbInfo)

Definition at line 546 of file available.cpp.

547 {
548  return m_SelectedList.AddTail(AvlbInfo) != 0;
549 }
ATL::CAtlList< CAvailableApplicationInfo * > m_SelectedList
Definition: available.h:108
POSITION AddTail(INARGTYPE element)
Definition: atlcoll.h:624

Referenced by CMainWindow::ItemCheckStateChanged().

◆ DeleteCurrentAppsDB()

VOID CAvailableApps::DeleteCurrentAppsDB ( )
static

Definition at line 386 of file available.cpp.

387 {
388  // Delete icons
390  PathAppendW(IconPath.GetBuffer(MAX_PATH), L"icons");
391  IconPath.ReleaseBuffer();
392  DeleteWithWildcard(IconPath + L"\\*.ico");
393 
394  // Delete leftover screenshots
395  ATL::CStringW ScrnshotFolder = m_Strings.szAppsPath;
396  PathAppendW(ScrnshotFolder.GetBuffer(MAX_PATH), L"screenshots");
397  ScrnshotFolder.ReleaseBuffer();
398  DeleteWithWildcard(IconPath + L"\\*.tmp");
399 
400  // Delete data base files (*.txt)
402 
404  RemoveDirectoryW(ScrnshotFolder);
407 }
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:121
static void DeleteWithWildcard(const CStringW &DirWithFilter)
Definition: available.cpp:359
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:111
#define MAX_PATH
Definition: compat.h:34
static const WCHAR L[]
Definition: oid.c:1250
ATL::CStringW szPath
Definition: available.h:30
ATL::CStringW szAppsPath
Definition: available.h:32
static const WCHAR IconPath[]
Definition: install.c:51
ATL::CStringW szSearchPath
Definition: available.h:33

Referenced by ForceUpdateAppsDB().

◆ Enum()

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

Definition at line 448 of file available.cpp.

449 {
450  if (EnumType == ENUM_CAT_SELECTED)
451  {
452  CAvailableApplicationInfo *EnumAvlbInfo = NULL;
453 
454  // enum all object in m_SelectedList and invoke callback
458  {
459  EnumAvlbInfo->RefreshAppInfo(m_Strings);
460 
461  if (lpEnumProc)
462  lpEnumProc(EnumAvlbInfo, TRUE, param);
463  }
464  return TRUE;
465  }
466  else
467  {
469  WIN32_FIND_DATAW FindFileData;
470 
471  hFind = FindFirstFileW(m_Strings.szSearchPath.GetString(), &FindFileData);
472 
473  if (hFind == INVALID_HANDLE_VALUE)
474  {
475  //no db yet
476  return FALSE;
477  }
478 
479  do
480  {
481  // loop for all the cached entries
482  POSITION CurrentListPosition = m_InfoList.GetHeadPosition();
484 
485  while (CurrentListPosition != NULL)
486  {
487  POSITION LastListPosition = CurrentListPosition;
488  Info = m_InfoList.GetNext(CurrentListPosition);
489 
490  // do we already have this entry in cache?
491  if (Info->m_sFileName == FindFileData.cFileName)
492  {
493  // is it current enough, or the file has been modified since our last time here?
494  if (CompareFileTime(&FindFileData.ftLastWriteTime, &Info->m_ftCacheStamp) == 1)
495  {
496  // recreate our cache, this is the slow path
497  m_InfoList.RemoveAt(LastListPosition);
498 
499  // also remove this in selected list (if exist)
501 
502  delete Info;
503  Info = NULL;
504  break;
505  }
506  else
507  {
508  // speedy path, compare directly, we already have the data
509  goto skip_if_cached;
510  }
511  }
512  }
513 
514  // create a new entry
515  Info = new CAvailableApplicationInfo(FindFileData.cFileName, m_Strings);
516 
517  // set a timestamp for the next time
518  Info->SetLastWriteTime(&FindFileData.ftLastWriteTime);
520 
521  skip_if_cached:
522  if (EnumType == Info->m_Category
523  || EnumType == ENUM_ALL_AVAILABLE)
524  {
525  Info->RefreshAppInfo(m_Strings);
526 
527  if (lpEnumProc)
528  {
529  if (m_SelectedList.Find(Info))
530  {
531  lpEnumProc(Info, TRUE, param);
532  }
533  else
534  {
535  lpEnumProc(Info, FALSE, param);
536  }
537  }
538  }
539  } while (FindNextFileW(hFind, &FindFileData));
540 
541  FindClose(hFind);
542  return TRUE;
543  }
544 }
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:479
struct TraceInfo Info
#define FALSE
Definition: types.h:117
ULONG CurrentPosition
Definition: patchapi.h:57
smooth NULL
Definition: ftsmooth.c:416
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:111
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:108
ATL::CAtlList< CAvailableApplicationInfo * > m_InfoList
Definition: available.h:107
POSITION AddTail(INARGTYPE element)
Definition: atlcoll.h:624
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:33
BOOL RemoveSelected(CAvailableApplicationInfo *AvlbInfo)
Definition: available.cpp:551
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 573 of file available.cpp.

574 {
575  if (m_InfoList.IsEmpty())
576  {
577  return NULL;
578  }
579 
580  // linear search
581  POSITION CurrentListPosition = m_InfoList.GetHeadPosition();
583  while (CurrentListPosition != NULL)
584  {
585  info = m_InfoList.GetNext(CurrentListPosition);
586  if (info->m_szPkgName.CompareNoCase(szPkgName) == 0)
587  {
588  return info;
589  }
590  }
591  return NULL;
592 }
POSITION GetHeadPosition() const
Definition: atlcoll.h:549
struct _test_info info[]
Definition: SetCursorPos.c:19
smooth NULL
Definition: ftsmooth.c:416
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:561
ATL::CAtlList< CAvailableApplicationInfo * > m_InfoList
Definition: available.h:107
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 594 of file available.cpp.

595 {
597  for (INT i = 0; i < PkgNameList.GetSize(); ++i)
598  {
600  if (Info)
601  {
602  result.Add(*Info);
603  }
604  }
605  return result;
606 }
CAvailableApplicationInfo * FindAppByPkgName(const ATL::CStringW &szPkgName) const
Definition: available.cpp:573
int32_t INT
Definition: typedefs.h:58
struct TraceInfo Info
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
GLuint64EXT * result
Definition: glext.h:11304

Referenced by HandleInstallCommand(), and HandleSetupCommand().

◆ ForceUpdateAppsDB()

BOOL CAvailableApps::ForceUpdateAppsDB ( )
static

Definition at line 442 of file available.cpp.

443 {
445  return UpdateAppsDB();
446 }
static BOOL UpdateAppsDB()
Definition: available.cpp:409
static VOID DeleteCurrentAppsDB()
Definition: available.cpp:386

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

◆ FreeCachedEntries()

VOID CAvailableApps::FreeCachedEntries ( )

Definition at line 345 of file available.cpp.

346 {
347  POSITION InfoListPosition = m_InfoList.GetHeadPosition();
348 
349  /* loop and deallocate all the cached app infos in the list */
350  while (InfoListPosition)
351  {
352  CAvailableApplicationInfo* Info = m_InfoList.GetNext(InfoListPosition);
353  delete Info;
354  }
355 
357 }
POSITION GetHeadPosition() const
Definition: atlcoll.h:549
struct TraceInfo Info
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:561
void RemoveAll()
Definition: atlcoll.h:725
ATL::CAtlList< CAvailableApplicationInfo * > m_InfoList
Definition: available.h:107

Referenced by CMainWindow::ProcessWindowMessage().

◆ GetAppPath()

const ATL::CStringW & CAvailableApps::GetAppPath ( ) const

Definition at line 613 of file available.cpp.

614 {
615  return m_Strings.szAppsPath;
616 }
static AvailableStrings m_Strings
Definition: available.h:111
ATL::CStringW szAppsPath
Definition: available.h:32

◆ GetCabPath()

const ATL::CStringW & CAvailableApps::GetCabPath ( ) const

Definition at line 618 of file available.cpp.

619 {
620  return m_Strings.szCabPath;
621 }
ATL::CStringW szCabPath
Definition: available.h:31
static AvailableStrings m_Strings
Definition: available.h:111

◆ GetFolderPath()

const ATL::CStringW & CAvailableApps::GetFolderPath ( ) const

Definition at line 608 of file available.cpp.

609 {
610  return m_Strings.szPath;
611 }
static AvailableStrings m_Strings
Definition: available.h:111
ATL::CStringW szPath
Definition: available.h:30

◆ GetSelectedCount()

int CAvailableApps::GetSelectedCount ( )

Definition at line 568 of file available.cpp.

569 {
570  return m_SelectedList.GetCount();
571 }
size_t GetCount() const
Definition: atlcoll.h:537
ATL::CAtlList< CAvailableApplicationInfo * > m_SelectedList
Definition: available.h:108

Referenced by CMainWindow::UpdateStatusBarText().

◆ RemoveAllSelected()

VOID CAvailableApps::RemoveAllSelected ( )

Definition at line 562 of file available.cpp.

563 {
565  return;
566 }
void RemoveAll()
Definition: atlcoll.h:725
ATL::CAtlList< CAvailableApplicationInfo * > m_SelectedList
Definition: available.h:108

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

◆ RemoveSelected()

BOOL CAvailableApps::RemoveSelected ( CAvailableApplicationInfo AvlbInfo)

Definition at line 551 of file available.cpp.

552 {
553  POSITION Position = m_SelectedList.Find(AvlbInfo);
554  if (Position)
555  {
557  return TRUE;
558  }
559  return FALSE;
560 }
#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:108
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 409 of file available.cpp.

410 {
412  WIN32_FIND_DATAW FindFileData;
413 
415  {
416  return FALSE;
417  }
418 
419  //if there are some files in the db folder - we're good
420  hFind = FindFirstFileW(m_Strings.szSearchPath, &FindFileData);
421  if (hFind != INVALID_HANDLE_VALUE)
422  {
423  FindClose(hFind);
424  return TRUE;
425  }
426 
429 
433  {
434  return FALSE;
435  }
436 
438 
439  return TRUE;
440 }
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:33
#define TRUE
Definition: types.h:120
VOID DownloadApplicationsDB(LPCWSTR lpUrl, BOOL IsOfficial)
Definition: loaddlg.cpp:1026
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
WCHAR szSourceURL[INTERNET_MAX_URL_LENGTH]
Definition: settings.h:24
BOOL bUseSource
Definition: settings.h:23
ATL::CStringW szCabPath
Definition: available.h:31
#define FALSE
Definition: types.h:117
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:25
static AvailableStrings m_Strings
Definition: available.h:111
ATL::CStringW szCabDir
Definition: available.h:35
ATL::CStringW szPath
Definition: available.h:30
ATL::CStringW szAppsPath
Definition: available.h:32
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
ATL::CStringW szSearchPath
Definition: available.h:33
ATL::CStringW szCabName
Definition: available.h:34
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 107 of file available.h.

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

◆ m_SelectedList

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

Definition at line 108 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: