2 * PROJECT: ReactOS Applications Manager
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/rapps/available.c
5 * PURPOSE: Functions for working with availabled applications
6 * PROGRAMMERS: Dmitry Chapyshev (dmitry@reactos.org)
12 ShowAvailableAppInfo(INT Index
)
14 PAPPLICATION_INFO Info
= (PAPPLICATION_INFO
) ListViewGetlParam(Index
);
15 WCHAR szText
[MAX_STR_LEN
];
17 if (!Info
) return FALSE
;
19 NewRichEditText(Info
->szName
, CFE_BOLD
);
21 InsertRichEditText(L
"\n", 0);
23 #define ADD_TEXT(a, b, c, d) \
26 LoadStringW(hInst, a, szText, sizeof(szText) / sizeof(WCHAR)); \
27 InsertRichEditText(szText, c); \
28 InsertRichEditText(b, d); \
31 ADD_TEXT(IDS_AINFO_VERSION, Info->szVersion, CFE_BOLD, 0);
32 ADD_TEXT(IDS_AINFO_LICENCE
, Info
->szLicence
, CFE_BOLD
, 0);
33 ADD_TEXT(IDS_AINFO_SIZE
, Info
->szSize
, CFE_BOLD
, 0);
34 ADD_TEXT(IDS_AINFO_URLSITE
, Info
->szUrlSite
, CFE_BOLD
, CFE_LINK
);
35 ADD_TEXT(IDS_AINFO_DESCRIPTION
, Info
->szDesc
, CFE_BOLD
, 0);
41 DeleteCurrentAppsDB(VOID
)
43 HANDLE hFind
= INVALID_HANDLE_VALUE
;
44 WIN32_FIND_DATAW FindFileData
;
45 WCHAR szCabPath
[MAX_PATH
];
46 WCHAR szSearchPath
[MAX_PATH
];
47 WCHAR szPath
[MAX_PATH
];
48 WCHAR szTmp
[MAX_PATH
];
51 if (!GetStorageDirectory(szPath
, sizeof(szPath
) / sizeof(szPath
[0])))
54 hr
= StringCbPrintfW(szCabPath
, sizeof(szCabPath
),
60 if (GetFileAttributesW(szCabPath
) != INVALID_FILE_ATTRIBUTES
)
62 if (!DeleteFileW(szCabPath
))
66 hr
= StringCbCatW(szPath
, sizeof(szPath
), L
"\\rapps\\");
70 hr
= StringCbPrintfW(szSearchPath
, sizeof(szSearchPath
),
76 hFind
= FindFirstFileW(szSearchPath
, &FindFileData
);
77 if (hFind
== INVALID_HANDLE_VALUE
)
82 hr
= StringCbPrintfW(szTmp
, sizeof(szTmp
),
84 szPath
, FindFileData
.cFileName
);
85 if (FAILED(hr
) || !DeleteFileW(szTmp
))
91 while (FindNextFileW(hFind
, &FindFileData
) != 0);
102 WCHAR szPath
[MAX_PATH
];
103 WCHAR szAppsPath
[MAX_PATH
];
104 WCHAR szCabPath
[MAX_PATH
];
106 if (!DeleteCurrentAppsDB())
109 DownloadApplicationsDB(APPLICATION_DATEBASE_URL
);
111 if (!GetStorageDirectory(szPath
, sizeof(szPath
) / sizeof(szPath
[0])))
114 if (FAILED(StringCbPrintfW(szCabPath
, sizeof(szCabPath
),
121 if (FAILED(StringCbPrintfW(szAppsPath
, sizeof(szAppsPath
),
128 ExtractFilesFromCab(szCabPath
, szAppsPath
);
135 EnumAvailableApplications(INT EnumType
, AVAILENUMPROC lpEnumProc
)
137 HANDLE hFind
= INVALID_HANDLE_VALUE
;
138 WIN32_FIND_DATAW FindFileData
;
139 WCHAR szPath
[MAX_PATH
];
140 WCHAR szAppsPath
[MAX_PATH
];
141 WCHAR szSectionLocale
[MAX_PATH
] = L
"Section.";
142 WCHAR szCabPath
[MAX_PATH
];
143 WCHAR szLocale
[4 + 1];
144 APPLICATION_INFO Info
;
147 if (!GetStorageDirectory(szPath
, sizeof(szPath
) / sizeof(szPath
[0])))
152 hr
= StringCbPrintfW(szCabPath
, sizeof(szCabPath
),
158 hr
= StringCbCatW(szPath
, sizeof(szPath
), L
"\\rapps\\");
161 hr
= StringCbCopyW(szAppsPath
, sizeof(szAppsPath
), szPath
);
165 if (!CreateDirectory(szPath
, NULL
) &&
166 GetLastError() != ERROR_ALREADY_EXISTS
)
171 GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_ILANGUAGE
, szLocale
, sizeof(szLocale
) / sizeof(WCHAR
));
172 hr
= StringCbCatW(szSectionLocale
, sizeof(szSectionLocale
), szLocale
);
176 hr
= StringCbCatW(szPath
, sizeof(szPath
), L
"*.txt");
180 hFind
= FindFirstFileW(szPath
, &FindFileData
);
181 if (hFind
== INVALID_HANDLE_VALUE
)
183 if (GetFileAttributesW(szCabPath
) == INVALID_FILE_ATTRIBUTES
)
184 DownloadApplicationsDB(APPLICATION_DATEBASE_URL
);
186 ExtractFilesFromCab(szCabPath
, szAppsPath
);
187 hFind
= FindFirstFileW(szPath
, &FindFileData
);
188 if (hFind
== INVALID_HANDLE_VALUE
)
192 #define GET_STRING1(a, b) \
193 if (!ParserGetString(szSectionLocale, a, b, MAX_PATH, FindFileData.cFileName)) \
194 if (!ParserGetString(L"Section", a, b, MAX_PATH, FindFileData.cFileName)) \
197 #define GET_STRING2(a, b) \
198 if (!ParserGetString(szSectionLocale, a, b, MAX_PATH, FindFileData.cFileName)) \
199 if (!ParserGetString(L"Section", a, b, MAX_PATH, FindFileData.cFileName)) \
204 Info
.Category
= ParserGetInt(szSectionLocale
, L
"Category", FindFileData
.cFileName
);
205 if (Info
.Category
== -1)
207 Info
.Category
= ParserGetInt(L
"Section", L
"Category", FindFileData
.cFileName
);
208 if (Info
.Category
== -1)
212 if (EnumType
!= Info
.Category
&& EnumType
!= ENUM_ALL_AVAILABLE
) continue;
214 GET_STRING1(L
"Name", Info
.szName
);
215 GET_STRING1(L
"URLDownload", Info
.szUrlDownload
);
217 GET_STRING2(L
"RegName", Info
.szRegName
);
218 GET_STRING2(L
"Version", Info
.szVersion
);
219 GET_STRING2(L
"Licence", Info
.szLicence
);
220 GET_STRING2(L
"Description", Info
.szDesc
);
221 GET_STRING2(L
"Size", Info
.szSize
);
222 GET_STRING2(L
"URLSite", Info
.szUrlSite
);
223 GET_STRING2(L
"CDPath", Info
.szCDPath
);
225 if (!lpEnumProc(Info
)) break;
227 while (FindNextFileW(hFind
, &FindFileData
) != 0);