ReactOS  0.4.15-dev-507-g90aff8d
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 97 of file available.h.

Constructor & Destructor Documentation

◆ CAvailableApps()

CAvailableApps::CAvailableApps ( )

Definition at line 246 of file available.cpp.

247 {
248 }

Member Function Documentation

◆ DeleteCurrentAppsDB()

VOID CAvailableApps::DeleteCurrentAppsDB ( )
static

Definition at line 264 of file available.cpp.

265 {
267  WIN32_FIND_DATAW FindFileData;
268 
269  hFind = FindFirstFileW(m_Strings.szSearchPath.GetString(), &FindFileData);
270 
271  if (hFind != INVALID_HANDLE_VALUE)
272  {
274  do
275  {
276  szTmp = m_Strings.szAppsPath + FindFileData.cFileName;
277  DeleteFileW(szTmp.GetString());
278  } while (FindNextFileW(hFind, &FindFileData) != 0);
279  FindClose(hFind);
280  }
281 
284 }
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
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:99
PCXSTR GetString() const
Definition: atlsimpstr.h:361
ATL::CStringW szPath
Definition: available.h:87
ATL::CStringW szAppsPath
Definition: available.h:89
ATL::CStringW szSearchPath
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().

◆ Enum()

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

Definition at line 325 of file available.cpp.

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

◆ FindInfo()

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

Definition at line 394 of file available.cpp.

395 {
396  if (m_InfoList.IsEmpty())
397  {
398  return NULL;
399  }
400 
401  // linear search
402  POSITION CurrentListPosition = m_InfoList.GetHeadPosition();
404  while (CurrentListPosition != NULL)
405  {
406  info = m_InfoList.GetNext(CurrentListPosition);
407  if (info->m_szName.CompareNoCase(szAppName) == 0)
408  {
409  return info;
410  }
411  }
412  return NULL;
413 }
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
TCHAR szAppName[128]
Definition: solitaire.cpp:16
ATL::CAtlList< CAvailableApplicationInfo * > m_InfoList
Definition: available.h:100
bool IsEmpty() const
Definition: atlcoll.h:543

Referenced by FindInfoList().

◆ FindInfoList()

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

Definition at line 415 of file available.cpp.

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

320 {
322  return UpdateAppsDB();
323 }
static BOOL UpdateAppsDB()
Definition: available.cpp:286
static VOID DeleteCurrentAppsDB()
Definition: available.cpp:264

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

◆ FreeCachedEntries()

VOID CAvailableApps::FreeCachedEntries ( )

Definition at line 250 of file available.cpp.

251 {
252  POSITION InfoListPosition = m_InfoList.GetHeadPosition();
253 
254  /* loop and deallocate all the cached app infos in the list */
255  while (InfoListPosition)
256  {
257  CAvailableApplicationInfo* Info = m_InfoList.GetNext(InfoListPosition);
258  delete Info;
259  }
260 
262 }
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:100

Referenced by CMainWindow::ProcessWindowMessage().

◆ GetAppPath()

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

Definition at line 451 of file available.cpp.

452 {
453  return m_Strings.szAppsPath;
454 }
static AvailableStrings m_Strings
Definition: available.h:99
ATL::CStringW szAppsPath
Definition: available.h:89

◆ GetCabPath()

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

Definition at line 456 of file available.cpp.

457 {
458  return m_Strings.szCabPath;
459 }
ATL::CStringW szCabPath
Definition: available.h:88
static AvailableStrings m_Strings
Definition: available.h:99

◆ GetFolderPath()

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

Definition at line 446 of file available.cpp.

447 {
448  return m_Strings.szPath;
449 }
static AvailableStrings m_Strings
Definition: available.h:99
ATL::CStringW szPath
Definition: available.h:87

◆ GetSelected()

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

Definition at line 429 of file available.cpp.

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

Referenced by CMainWindow::OnCommand().

◆ UpdateAppsDB()

BOOL CAvailableApps::UpdateAppsDB ( )
static

Definition at line 286 of file available.cpp.

287 {
289  WIN32_FIND_DATAW FindFileData;
290 
292  {
293  return FALSE;
294  }
295 
296  //if there are some files in the db folder - we're good
297  hFind = FindFirstFileW(m_Strings.szSearchPath, &FindFileData);
298  if (hFind != INVALID_HANDLE_VALUE)
299  {
300  FindClose(hFind);
301  return TRUE;
302  }
303 
306 
310  {
311  return FALSE;
312  }
313 
315 
316  return TRUE;
317 }
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:33
VOID DownloadApplicationsDB(LPCWSTR lpUrl, BOOL IsOfficial)
Definition: loaddlg.cpp:978
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
WCHAR szSourceURL[INTERNET_MAX_URL_LENGTH]
Definition: winmain.h:25
BOOL bUseSource
Definition: winmain.h:24
ATL::CStringW szCabPath
Definition: available.h:88
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:18
static AvailableStrings m_Strings
Definition: available.h:99
ATL::CStringW szCabDir
Definition: available.h:92
ATL::CStringW szPath
Definition: available.h:87
ATL::CStringW szAppsPath
Definition: available.h:89
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
ATL::CStringW szSearchPath
Definition: available.h:90
ATL::CStringW szCabName
Definition: available.h:91
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 100 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: