ReactOS  0.4.14-dev-608-gd495a4f
CAvailableApps Class Reference

#include <available.h>

Collaboration diagram for CAvailableApps:

Public Member Functions

 CAvailableApps ()
 
VOID FreeCachedEntries ()
 
BOOL Enum (INT EnumType, AVAILENUMPROC lpEnumProc, PVOID param)
 
CAvailableApplicationInfoFindInfo (const ATL::CStringW &szAppName) const
 
ATL::CSimpleArray< CAvailableApplicationInfoFindInfoList (const ATL::CSimpleArray< ATL::CStringW > &arrAppsNames) const
 
ATL::CSimpleArray< CAvailableApplicationInfoGetSelected () 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 ()
 

Private Attributes

ATL::CAtlList< CAvailableApplicationInfo * > m_InfoList
 

Static Private Attributes

static AvailableStrings m_Strings
 

Detailed Description

Definition at line 96 of file available.h.

Constructor & Destructor Documentation

◆ CAvailableApps()

CAvailableApps::CAvailableApps ( )

Definition at line 245 of file available.cpp.

246 {
247 }

Member Function Documentation

◆ DeleteCurrentAppsDB()

VOID CAvailableApps::DeleteCurrentAppsDB ( )
static

Definition at line 263 of file available.cpp.

264 {
266  WIN32_FIND_DATAW FindFileData;
267 
268  hFind = FindFirstFileW(m_Strings.szSearchPath.GetString(), &FindFileData);
269 
270  if (hFind != INVALID_HANDLE_VALUE)
271  {
273  do
274  {
275  szTmp = m_Strings.szAppsPath + FindFileData.cFileName;
276  DeleteFileW(szTmp.GetString());
277  } while (FindNextFileW(hFind, &FindFileData) != 0);
278  FindClose(hFind);
279  }
280 
283 }
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
char szTmp[518]
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
static AvailableStrings m_Strings
Definition: available.h:98
PCXSTR GetString() const
Definition: atlsimpstr.h:361
ATL::CStringW szPath
Definition: available.h:86
ATL::CStringW szAppsPath
Definition: available.h:88
ATL::CStringW szSearchPath
Definition: available.h:89
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().

◆ Enum()

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

Definition at line 323 of file available.cpp.

324 {
325 
327  WIN32_FIND_DATAW FindFileData;
328 
329  hFind = FindFirstFileW(m_Strings.szSearchPath.GetString(), &FindFileData);
330 
331  if (hFind == INVALID_HANDLE_VALUE)
332  {
333  //no db yet
334  return FALSE;
335  }
336 
337  do
338  {
339  // loop for all the cached entries
340  POSITION CurrentListPosition = m_InfoList.GetHeadPosition();
342 
343  while (CurrentListPosition != NULL)
344  {
345  POSITION LastListPosition = CurrentListPosition;
346  Info = m_InfoList.GetNext(CurrentListPosition);
347 
348  // do we already have this entry in cache?
349  if (Info->m_sFileName == FindFileData.cFileName)
350  {
351  // is it current enough, or the file has been modified since our last time here?
352  if (CompareFileTime(&FindFileData.ftLastWriteTime, &Info->m_ftCacheStamp) == 1)
353  {
354  // recreate our cache, this is the slow path
355  m_InfoList.RemoveAt(LastListPosition);
356 
357  delete Info;
358  Info = NULL;
359  break;
360  }
361  else
362  {
363  // speedy path, compare directly, we already have the data
364  goto skip_if_cached;
365  }
366  }
367  }
368 
369  // create a new entry
370  Info = new CAvailableApplicationInfo(FindFileData.cFileName);
371 
372  // set a timestamp for the next time
373  Info->SetLastWriteTime(&FindFileData.ftLastWriteTime);
375 
376 skip_if_cached:
377  if (EnumType == Info->m_Category
378  || EnumType == ENUM_ALL_AVAILABLE
379  || (EnumType == ENUM_CAT_SELECTED && Info->m_IsSelected))
380  {
381  Info->RefreshAppInfo();
382 
383  if (lpEnumProc)
384  lpEnumProc(Info, m_Strings.szAppsPath.GetString(), param);
385  }
386  } while (FindNextFileW(hFind, &FindFileData) != 0);
387 
388  FindClose(hFind);
389  return TRUE;
390 }
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
POSITION GetHeadPosition() const
Definition: atlcoll.h:523
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
struct TraceInfo Info
smooth NULL
Definition: ftsmooth.c:416
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:535
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
static AvailableStrings m_Strings
Definition: available.h:98
GLfloat param
Definition: glext.h:5796
PCXSTR GetString() const
Definition: atlsimpstr.h:361
ATL::CAtlList< CAvailableApplicationInfo * > m_InfoList
Definition: available.h:99
POSITION AddTail(INARGTYPE element)
Definition: atlcoll.h:598
ATL::CStringW szAppsPath
Definition: available.h:88
void RemoveAt(_In_ POSITION pos)
Definition: atlcoll.h:720
ATL::CStringW szSearchPath
Definition: available.h:89
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 CMainWindow::UpdateApplicationsList(), and UseCmdParameters().

◆ FindInfo()

CAvailableApplicationInfo * CAvailableApps::FindInfo ( const ATL::CStringW szAppName) const

Definition at line 392 of file available.cpp.

393 {
394  if (m_InfoList.IsEmpty())
395  {
396  return NULL;
397  }
398 
399  // linear search
400  POSITION CurrentListPosition = m_InfoList.GetHeadPosition();
402  while (CurrentListPosition != NULL)
403  {
404  info = m_InfoList.GetNext(CurrentListPosition);
405  if (info->m_szName.CompareNoCase(szAppName) == 0)
406  {
407  return info;
408  }
409  }
410  return NULL;
411 }
POSITION GetHeadPosition() const
Definition: atlcoll.h:523
struct _test_info info[]
Definition: SetCursorPos.c:19
smooth NULL
Definition: ftsmooth.c:416
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:535
TCHAR szAppName[128]
Definition: solitaire.cpp:16
ATL::CAtlList< CAvailableApplicationInfo * > m_InfoList
Definition: available.h:99
bool IsEmpty() const
Definition: atlcoll.h:517

Referenced by FindInfoList().

◆ FindInfoList()

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

Definition at line 413 of file available.cpp.

414 {
416  for (INT i = 0; i < arrAppsNames.GetSize(); ++i)
417  {
418  CAvailableApplicationInfo* Info = FindInfo(arrAppsNames[i]);
419  if (Info)
420  {
421  result.Add(*Info);
422  }
423  }
424  return result;
425 }
int GetSize() const
Definition: atlsimpcoll.h:104
int32_t INT
Definition: typedefs.h:56
struct TraceInfo Info
CAvailableApplicationInfo * FindInfo(const ATL::CStringW &szAppName) const
Definition: available.cpp:392
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 UseCmdParameters().

◆ ForceUpdateAppsDB()

BOOL CAvailableApps::ForceUpdateAppsDB ( )
static

Definition at line 317 of file available.cpp.

318 {
320  return UpdateAppsDB();
321 }
static BOOL UpdateAppsDB()
Definition: available.cpp:285
static VOID DeleteCurrentAppsDB()
Definition: available.cpp:263

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

◆ FreeCachedEntries()

VOID CAvailableApps::FreeCachedEntries ( )

Definition at line 249 of file available.cpp.

250 {
251  POSITION InfoListPosition = m_InfoList.GetHeadPosition();
252 
253  /* loop and deallocate all the cached app infos in the list */
254  while (InfoListPosition)
255  {
256  CAvailableApplicationInfo* Info = m_InfoList.GetNext(InfoListPosition);
257  delete Info;
258  }
259 
261 }
POSITION GetHeadPosition() const
Definition: atlcoll.h:523
struct TraceInfo Info
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:535
void RemoveAll()
Definition: atlcoll.h:699
ATL::CAtlList< CAvailableApplicationInfo * > m_InfoList
Definition: available.h:99

Referenced by CMainWindow::ProcessWindowMessage().

◆ GetAppPath()

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

Definition at line 449 of file available.cpp.

450 {
451  return m_Strings.szAppsPath;
452 }
static AvailableStrings m_Strings
Definition: available.h:98
ATL::CStringW szAppsPath
Definition: available.h:88

◆ GetCabPath()

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

Definition at line 454 of file available.cpp.

455 {
456  return m_Strings.szCabPath;
457 }
ATL::CStringW szCabPath
Definition: available.h:87
static AvailableStrings m_Strings
Definition: available.h:98

◆ GetFolderPath()

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

Definition at line 444 of file available.cpp.

445 {
446  return m_Strings.szPath;
447 }
static AvailableStrings m_Strings
Definition: available.h:98
ATL::CStringW szPath
Definition: available.h:86

◆ GetSelected()

ATL::CSimpleArray< CAvailableApplicationInfo > CAvailableApps::GetSelected ( ) const

Definition at line 427 of file available.cpp.

428 {
430  POSITION CurrentListPosition = m_InfoList.GetHeadPosition();
432 
433  while (CurrentListPosition != NULL)
434  {
435  Info = m_InfoList.GetNext(CurrentListPosition);
436  if (Info->m_IsSelected)
437  {
438  result.Add(*Info);
439  }
440  }
441  return result;
442 }
POSITION GetHeadPosition() const
Definition: atlcoll.h:523
struct TraceInfo Info
smooth NULL
Definition: ftsmooth.c:416
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:535
ATL::CAtlList< CAvailableApplicationInfo * > m_InfoList
Definition: available.h:99
GLuint64EXT * result
Definition: glext.h:11304

Referenced by CMainWindow::OnCommand().

◆ UpdateAppsDB()

BOOL CAvailableApps::UpdateAppsDB ( )
static

Definition at line 285 of file available.cpp.

286 {
288  WIN32_FIND_DATAW FindFileData;
289 
291  {
292  return FALSE;
293  }
294 
295  //if there are some files in the db folder - we're good
296  hFind = FindFirstFileW(m_Strings.szSearchPath, &FindFileData);
297  if (hFind != INVALID_HANDLE_VALUE)
298  {
299  FindClose(hFind);
300  return TRUE;
301  }
302 
304 
308  {
309  return FALSE;
310  }
311 
313 
314  return TRUE;
315 }
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:257
#define TRUE
Definition: types.h:120
#define APPLICATION_DATABASE_URL
Definition: defines.h:32
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
VOID DownloadApplicationsDB(LPCWSTR lpUrl)
Definition: loaddlg.cpp:894
ATL::CStringW szCabPath
Definition: available.h:87
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
static AvailableStrings m_Strings
Definition: available.h:98
ATL::CStringW szCabDir
Definition: available.h:91
ATL::CStringW szPath
Definition: available.h:86
ATL::CStringW szAppsPath
Definition: available.h:88
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
ATL::CStringW szSearchPath
Definition: available.h:89
ATL::CStringW szCabName
Definition: available.h:90
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(), and UseCmdParameters().

Member Data Documentation

◆ m_InfoList

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

Definition at line 99 of file available.h.

Referenced by Enum(), FindInfo(), FreeCachedEntries(), and GetSelected().

◆ m_Strings

AvailableStrings CAvailableApps::m_Strings
staticprivate

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