bool CMainFrame::ShowHtmlHelp() { App appType( AppDeltaview ); HelpSystem helpSys( appType ); long lHelpID = helpSys.GetProductHelpID( HIDC_DV_MINI_PANE ); return GetApp()->DisplayHtmlHelp(lHelpID); }
status_t retrieve_preferred_app(BMessage* message, bool sameAs, const char* forType, BString& preferredApp) { entry_ref ref; if (message == NULL || message->FindRef("refs", &ref) != B_OK) return B_BAD_VALUE; BFile file(&ref, B_READ_ONLY); status_t status = file.InitCheck(); char preferred[B_MIME_TYPE_LENGTH]; if (status == B_OK) { if (sameAs) { // get preferred app from file BNodeInfo nodeInfo(&file); status = nodeInfo.InitCheck(); if (status == B_OK) { if (nodeInfo.GetPreferredApp(preferred) != B_OK) preferred[0] = '\0'; if (!preferred[0]) { // get MIME type from file char type[B_MIME_TYPE_LENGTH]; if (nodeInfo.GetType(type) == B_OK) { BMimeType mimeType(type); mimeType.GetPreferredApp(preferred); } } } } else { // get application signature BAppFileInfo appInfo(&file); status = appInfo.InitCheck(); if (status == B_OK && appInfo.GetSignature(preferred) != B_OK) preferred[0] = '\0'; } } if (status != B_OK) { error_alert(B_TRANSLATE("File could not be opened"), status, B_STOP_ALERT); return status; } if (!preferred[0]) { error_alert(sameAs ? B_TRANSLATE("Could not retrieve preferred application of this " "file") : B_TRANSLATE("Could not retrieve application signature")); return B_ERROR; } // Check if the application chosen supports this type BMimeType mimeType(forType); bool found = false; BMessage applications; if (mimeType.GetSupportingApps(&applications) == B_OK && is_application_in_message(applications, preferred)) found = true; applications.MakeEmpty(); if (!found && mimeType.GetWildcardApps(&applications) == B_OK && is_application_in_message(applications, preferred)) found = true; if (!found) { // warn user BMimeType appType(preferred); char description[B_MIME_TYPE_LENGTH]; if (appType.GetShortDescription(description) != B_OK) description[0] = '\0'; char warning[512]; snprintf(warning, sizeof(warning), B_TRANSLATE("The application " "\"%s\" does not support this file type.\n" "Are you sure you want to set it anyway?"), description[0] ? description : preferred); BAlert* alert = new BAlert(B_TRANSLATE("FileTypes request"), warning, B_TRANSLATE("Set Preferred Application"), B_TRANSLATE("Cancel"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); if (alert->Go() == 1) return B_ERROR; } preferredApp = preferred; return B_OK; }