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
];
52 if (!GetStorageDirectory(szPath
, sizeof(szPath
) / sizeof(szPath
[0])))
55 hr
= StringCbPrintfW(szCabPath
, sizeof(szCabPath
),
61 result
= result
&& DeleteFileW(szCabPath
);
63 hr
= StringCbCatW(szPath
, sizeof(szPath
), L
"\\rapps\\");
67 hr
= StringCbPrintfW(szSearchPath
, sizeof(szSearchPath
),
73 hFind
= FindFirstFileW(szSearchPath
, &FindFileData
);
74 if (hFind
== INVALID_HANDLE_VALUE
)
79 hr
= StringCbPrintfW(szTmp
, sizeof(szTmp
),
81 szPath
, FindFileData
.cFileName
);
84 result
= result
&& DeleteFileW(szTmp
);
85 } while (FindNextFileW(hFind
, &FindFileData
) != 0);
96 WCHAR szPath
[MAX_PATH
];
97 WCHAR szAppsPath
[MAX_PATH
];
98 WCHAR szCabPath
[MAX_PATH
];
100 if (!DeleteCurrentAppsDB())
103 DownloadApplicationsDB(APPLICATION_DATEBASE_URL
);
105 if (!GetStorageDirectory(szPath
, sizeof(szPath
) / sizeof(szPath
[0])))
108 if (FAILED(StringCbPrintfW(szCabPath
, sizeof(szCabPath
),
115 if (FAILED(StringCbPrintfW(szAppsPath
, sizeof(szAppsPath
),
122 ExtractFilesFromCab(szCabPath
, szAppsPath
);
129 EnumAvailableApplications(INT EnumType
, AVAILENUMPROC lpEnumProc
)
131 HANDLE hFind
= INVALID_HANDLE_VALUE
;
132 WIN32_FIND_DATAW FindFileData
;
133 WCHAR szPath
[MAX_PATH
];
134 WCHAR szAppsPath
[MAX_PATH
];
135 WCHAR szSectionLocale
[MAX_PATH
] = L
"Section.";
136 WCHAR szCabPath
[MAX_PATH
];
137 WCHAR szLocale
[4 + 1];
138 APPLICATION_INFO Info
;
141 if (!GetStorageDirectory(szPath
, sizeof(szPath
) / sizeof(szPath
[0])))
144 hr
= StringCbPrintfW(szCabPath
, sizeof(szCabPath
),
150 hr
= StringCbCatW(szPath
, sizeof(szPath
), L
"\\rapps\\");
153 hr
= StringCbCopyW(szAppsPath
, sizeof(szAppsPath
), szPath
);
157 if (!CreateDirectory(szPath
, NULL
) &&
158 GetLastError() != ERROR_ALREADY_EXISTS
)
163 hr
= StringCbCatW(szPath
, sizeof(szPath
), L
"*.txt");
167 hFind
= FindFirstFileW(szPath
, &FindFileData
);
168 if (hFind
== INVALID_HANDLE_VALUE
)
170 if (GetFileAttributesW(szCabPath
) == INVALID_FILE_ATTRIBUTES
)
171 DownloadApplicationsDB(APPLICATION_DATEBASE_URL
);
173 ExtractFilesFromCab(szCabPath
, szAppsPath
);
174 hFind
= FindFirstFileW(szPath
, &FindFileData
);
175 if (hFind
== INVALID_HANDLE_VALUE
)
179 if (!GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_ILANGUAGE
,
180 szLocale
, sizeof(szLocale
) / sizeof(WCHAR
)))
186 hr
= StringCbCatW(szSectionLocale
, sizeof(szSectionLocale
), szLocale
);
193 #define GET_STRING1(a, b) \
194 if (!ParserGetString(szSectionLocale, a, b, MAX_PATH, FindFileData.cFileName)) \
195 if (!ParserGetString(L"Section", a, b, MAX_PATH, FindFileData.cFileName)) \
198 #define GET_STRING2(a, b) \
199 if (!ParserGetString(szSectionLocale, a, b, MAX_PATH, FindFileData.cFileName)) \
200 if (!ParserGetString(L"Section", a, b, MAX_PATH, FindFileData.cFileName)) \
205 Info
.Category
= ParserGetInt(szSectionLocale
, L
"Category", FindFileData
.cFileName
);
206 if (Info
.Category
== -1)
208 Info
.Category
= ParserGetInt(L
"Section", L
"Category", FindFileData
.cFileName
);
209 if (Info
.Category
== -1)
213 if (EnumType
!= Info
.Category
&& EnumType
!= ENUM_ALL_AVAILABLE
) continue;
215 GET_STRING1(L
"Name", Info
.szName
);
216 GET_STRING1(L
"URLDownload", Info
.szUrlDownload
);
218 GET_STRING2(L
"RegName", Info
.szRegName
);
219 GET_STRING2(L
"Version", Info
.szVersion
);
220 GET_STRING2(L
"Licence", Info
.szLicence
);
221 GET_STRING2(L
"Description", Info
.szDesc
);
222 GET_STRING2(L
"Size", Info
.szSize
);
223 GET_STRING2(L
"URLSite", Info
.szUrlSite
);
224 GET_STRING2(L
"CDPath", Info
.szCDPath
);
226 if (!lpEnumProc(&Info
)) break;
227 } while (FindNextFileW(hFind
, &FindFileData
) != 0);