ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

available.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS Applications Manager
00003  * LICENSE:         GPL - See COPYING in the top level directory
00004  * FILE:            base/applications/rapps/available.c
00005  * PURPOSE:         Functions for working with availabled applications
00006  * PROGRAMMERS:     Dmitry Chapyshev (dmitry@reactos.org)
00007  */
00008 
00009 #include "rapps.h"
00010 
00011 
00012 BOOL
00013 ShowAvailableAppInfo(INT Index)
00014 {
00015     PAPPLICATION_INFO Info = (PAPPLICATION_INFO) ListViewGetlParam(Index);
00016     WCHAR szText[MAX_STR_LEN];
00017 
00018     if (!Info) return FALSE;
00019 
00020     NewRichEditText(Info->szName, CFE_BOLD);
00021 
00022     InsertRichEditText(L"\n", 0);
00023 
00024 #define ADD_TEXT(a, b, c, d) \
00025     if (b[0] != '\0') \
00026     { \
00027         LoadStringW(hInst, a, szText, sizeof(szText) / sizeof(WCHAR)); \
00028         InsertRichEditText(szText, c); \
00029         InsertRichEditText(b, d); \
00030     } \
00031 
00032     ADD_TEXT(IDS_AINFO_VERSION, Info->szVersion, CFE_BOLD, 0);
00033     ADD_TEXT(IDS_AINFO_LICENCE, Info->szLicence, CFE_BOLD, 0);
00034     ADD_TEXT(IDS_AINFO_SIZE, Info->szSize, CFE_BOLD, 0);
00035     ADD_TEXT(IDS_AINFO_URLSITE, Info->szUrlSite, CFE_BOLD, CFE_LINK);
00036     ADD_TEXT(IDS_AINFO_DESCRIPTION, Info->szDesc, CFE_BOLD, 0);
00037 
00038     return TRUE;
00039 }
00040 
00041 static BOOL
00042 DeleteCurrentAppsDB(VOID)
00043 {
00044     HANDLE hFind = INVALID_HANDLE_VALUE;
00045     WIN32_FIND_DATAW FindFileData;
00046     WCHAR szCabPath[MAX_PATH];
00047     WCHAR szSearchPath[MAX_PATH];
00048     WCHAR szPath[MAX_PATH];
00049     WCHAR szTmp[MAX_PATH];
00050 
00051     if (!GetCurrentDirectoryW(MAX_PATH, szPath))
00052         return FALSE;
00053 
00054     swprintf(szCabPath, L"%s\\rappmgr.cab", szPath);
00055 
00056     if (GetFileAttributesW(szCabPath) != INVALID_FILE_ATTRIBUTES)
00057     {
00058         if (!DeleteFileW(szCabPath))
00059             return FALSE;
00060     }
00061 
00062     wcscat(szPath, L"\\rapps\\");
00063     swprintf(szSearchPath, L"%s*.txt", szPath);
00064 
00065     hFind = FindFirstFileW(szSearchPath, &FindFileData);
00066     if (hFind == INVALID_HANDLE_VALUE)
00067         return TRUE;
00068 
00069     do
00070     {
00071         swprintf(szTmp, L"%s%s", szPath, FindFileData.cFileName);
00072         if (!DeleteFileW(szTmp))
00073         {
00074             FindClose(hFind);
00075             return FALSE;
00076         }
00077     }
00078     while (FindNextFileW(hFind, &FindFileData) != 0);
00079 
00080     FindClose(hFind);
00081 
00082     return TRUE;
00083 }
00084 
00085 
00086 BOOL
00087 UpdateAppsDB(VOID)
00088 {
00089     WCHAR szPath[MAX_PATH];
00090     WCHAR szAppsPath[MAX_PATH];
00091     WCHAR szCabPath[MAX_PATH];
00092 
00093     if (!DeleteCurrentAppsDB())
00094         return FALSE;
00095 
00096     DownloadApplicationsDB(APPLICATION_DATEBASE_URL);
00097 
00098     if (!GetCurrentDirectoryW(MAX_PATH, szPath))
00099         return FALSE;
00100 
00101     swprintf(szCabPath, L"%s\\rappmgr.cab", szPath);
00102 
00103     wcscat(szPath, L"\\rapps\\");
00104     wcscpy(szAppsPath, szPath);
00105 
00106     ExtractFilesFromCab(szCabPath, szAppsPath);
00107 
00108     return TRUE;
00109 }
00110 
00111 
00112 BOOL
00113 EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc)
00114 {
00115     HANDLE hFind = INVALID_HANDLE_VALUE;
00116     WIN32_FIND_DATAW FindFileData;
00117     WCHAR szPath[MAX_PATH];
00118     WCHAR szAppsPath[MAX_PATH];
00119     WCHAR szSectionLocale[MAX_PATH] = L"Section.";
00120     WCHAR szCabPath[MAX_PATH];
00121     WCHAR szLocale[4 + 1];
00122     APPLICATION_INFO Info;
00123 
00124     if (!GetCurrentDirectoryW(MAX_PATH, szPath))
00125     {
00126         return FALSE;
00127     }
00128 
00129     swprintf(szCabPath, L"%s\\rappmgr.cab", szPath);
00130 
00131     wcscat(szPath, L"\\rapps\\");
00132     wcscpy(szAppsPath, szPath);
00133 
00134     if (!CreateDirectory(szPath, NULL) &&
00135         GetLastError() != ERROR_ALREADY_EXISTS)
00136     {
00137         return FALSE;
00138     }
00139 
00140     GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_ILANGUAGE, szLocale, sizeof(szLocale) / sizeof(WCHAR));
00141     wcscat(szSectionLocale, szLocale);
00142 
00143     wcscat(szPath, L"*.txt");
00144 
00145     hFind = FindFirstFileW(szPath, &FindFileData);
00146     if (hFind == INVALID_HANDLE_VALUE)
00147     {
00148         if (GetFileAttributesW(szCabPath) == INVALID_FILE_ATTRIBUTES)
00149             DownloadApplicationsDB(APPLICATION_DATEBASE_URL);
00150 
00151         ExtractFilesFromCab(szCabPath, szAppsPath);
00152         hFind = FindFirstFileW(szPath, &FindFileData);
00153         if (hFind == INVALID_HANDLE_VALUE)
00154             return FALSE;
00155     }
00156 
00157 #define GET_STRING1(a, b)  \
00158     if (!ParserGetString(szSectionLocale, a, b, MAX_PATH, FindFileData.cFileName)) \
00159         if (!ParserGetString(L"Section", a, b, MAX_PATH, FindFileData.cFileName)) \
00160             continue;
00161 
00162 #define GET_STRING2(a, b)  \
00163     if (!ParserGetString(szSectionLocale, a, b, MAX_PATH, FindFileData.cFileName)) \
00164         if (!ParserGetString(L"Section", a, b, MAX_PATH, FindFileData.cFileName)) \
00165             b[0] = '\0';
00166 
00167     do
00168     {
00169         Info.Category = ParserGetInt(szSectionLocale, L"Category", FindFileData.cFileName);
00170         if (Info.Category == -1)
00171         {
00172             Info.Category = ParserGetInt(L"Section", L"Category", FindFileData.cFileName);
00173             if (Info.Category == -1)
00174                 continue;
00175         }
00176 
00177         if (EnumType != Info.Category && EnumType != ENUM_ALL_AVAILABLE) continue;
00178 
00179         GET_STRING1(L"Name", Info.szName);
00180         GET_STRING1(L"URLDownload", Info.szUrlDownload);
00181 
00182         GET_STRING2(L"RegName", Info.szRegName);
00183         GET_STRING2(L"Version", Info.szVersion);
00184         GET_STRING2(L"Licence", Info.szLicence);
00185         GET_STRING2(L"Description", Info.szDesc);
00186         GET_STRING2(L"Size", Info.szSize);
00187         GET_STRING2(L"URLSite", Info.szUrlSite);
00188         GET_STRING2(L"CDPath", Info.szCDPath);
00189 
00190         if (!lpEnumProc(Info)) break;
00191     }
00192     while (FindNextFileW(hFind, &FindFileData) != 0);
00193 
00194     FindClose(hFind);
00195 
00196     return TRUE;
00197 }

Generated on Sat May 26 2012 04:16:16 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.