MCPcopy Create free account
hub / github.com/amule-project/amule / PromptAndInstall

Function PromptAndInstall

src/AppImageIntegration.cpp:214–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214void PromptAndInstall(wxWindow* parent)
215{
216 if (!ShouldPrompt()) {
217 return;
218 }
219
220 wxRichMessageDialog dlg(parent,
221 _("aMule can install a desktop launcher and icon into your home directory "
222 "so it appears in your application menu like a regularly installed app. "
223 "This is reversible — the files live under ~/.local/share/applications "
224 "and ~/.local/share/icons and can be removed at any time.\n\n"
225 "Install desktop integration now?"),
226 _("Add aMule to your application menu?"),
227 wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION);
228 dlg.SetYesNoLabels(_("Install"), _("Not now"));
229 dlg.ShowCheckBox(_("Don't ask again"));
230
231 const int answer = dlg.ShowModal();
232 const bool dontAskAgain = dlg.IsCheckBoxChecked();
233
234 if (dontAskAgain) {
235 thePrefs::SetAppImageIntegrationDeclined(true);
236 // Persist immediately so a crash before normal shutdown still
237 // remembers the user's choice.
238 theApp->glob_prefs->Save();
239 }
240
241 if (answer != wxID_YES) {
242 return;
243 }
244
245 const wxString appimagePath = GetAppImagePath();
246 const wxString appdir = GetAppDir();
247 if (appdir.IsEmpty()) {
248 const wxString msg = _("Cannot install desktop integration: the APPDIR environment variable is not set. This usually means the AppImage was launched in a non-standard way.");
249 AddLogLineC(msg);
250 wxMessageBox(msg, _("aMule integration failed"), wxOK | wxICON_ERROR, parent);
251 return;
252 }
253
254 const wxString userAppsDir = GetUserApplicationsDir();
255 const wxString userIconsDir = GetUserIconsDir();
256
257 if (!wxDirExists(userAppsDir) && !wxFileName::Mkdir(userAppsDir, 0755, wxPATH_MKDIR_FULL)) {
258 const wxString msg = wxString::Format(
259 _("Cannot install desktop integration: failed to create %s. Check that your home directory is writable."),
260 userAppsDir);
261 AddLogLineC(msg);
262 wxMessageBox(msg, _("aMule integration failed"), wxOK | wxICON_ERROR, parent);
263 return;
264 }
265
266 const wxString sourceDesktop = appdir + wxT("/usr/share/applications/org.amule.aMule.desktop");
267 const wxString destDesktop = userAppsDir + wxT("/org.amule.aMule.desktop");
268
269 if (!InstallDesktopFile(appimagePath, sourceDesktop, destDesktop)) {
270 const wxString msg = wxString::Format(
271 _("Cannot install desktop integration: failed to write %s. Check that your home directory is writable."),

Callers 1

OnInitMethod · 0.85

Calls 11

ShouldPromptFunction · 0.85
GetAppImagePathFunction · 0.85
GetAppDirFunction · 0.85
GetUserApplicationsDirFunction · 0.85
GetUserIconsDirFunction · 0.85
InstallDesktopFileFunction · 0.85
InstallIconsFunction · 0.85
RefreshSystemCachesFunction · 0.85
SaveMethod · 0.45
IsEmptyMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected