int main(int argc, char * const argv[]) { core::system::initializeLog("rserver", 2); LOG_WARNING_MESSAGE("hello cmake!"); return EXIT_SUCCESS; }
bool validateUser(const std::string& username, const std::string& requiredGroup, bool groupFailureWarning) { // short circuit if we aren't validating users if (!server::options().authValidateUsers()) return true; // get the user core::system::user::User user; Error error = userFromUsername(username, &user); if (error) { // log the error only if it is unexpected if (!core::system::isUserNotFoundError(error)) LOG_ERROR(error); // not found either due to non-existence or an unexpected error return false; } // validate user if necessary if (!requiredGroup.empty()) { // see if they are a member of the required group bool belongsToGroup ; error = core::system::userBelongsToGroup(user, requiredGroup, &belongsToGroup); if (error) { // log and return false LOG_ERROR(error); return false; } else { // log a warning whenever a user doesn't belong to a required group if (!belongsToGroup && groupFailureWarning) { LOG_WARNING_MESSAGE( "User " + username + " could not be authenticated because they " "do not belong to the required group (" + requiredGroup + ")"); } // return belongs status return belongsToGroup; } } else { // not validating (running in some type of dev mode where we // don't have a system account for every login) return true; } }
bool detectLineEndings(const FilePath& filePath, LineEnding* pType) { if (!filePath.exists()) return false; boost::shared_ptr<std::istream> pIfs; Error error = filePath.open_r(&pIfs); if (error) { LOG_ERROR(error); return false; } // read file character-by-character using a streambuf try { std::istream::sentry se(*pIfs, true); std::streambuf* sb = pIfs->rdbuf(); while(true) { int ch = sb->sbumpc(); if (ch == '\n') { // using posix line endings *pType = string_utils::LineEndingPosix; return true; } else if (ch == '\r' && sb->sgetc() == '\n') { // using windows line endings *pType = string_utils::LineEndingWindows; return true; } else if (ch == EOF) { break; } else if (pIfs->fail()) { LOG_WARNING_MESSAGE("I/O Error reading file " + filePath.absolutePath()); break; } } } CATCH_UNEXPECTED_EXCEPTION // no detection possible (perhaps the file is empty or has only one line) return false; }
void ChildProcessTracker::attemptToReapProcess( const std::pair<PidType,ExitHandler>& process) { // non-blocking wait for the child int pid = process.first; int status; int result = waitPid(pid, &status); // reaped the child if (result == pid) { // confirm this was a real exit bool exited = false; if (WIFEXITED(status)) { exited = true; status = WEXITSTATUS(status); } else if (WIFSIGNALED(status)) { exited = true; } // if it was a real exit (as opposed to a SIGSTOP or SIGCONT) // then remove the pid from our table and fire the event if (exited) { // all done with this pid removeProcess(pid); // call exit handler if we have one ExitHandler exitHandler = process.second; if (exitHandler) exitHandler(pid, status); } else { boost::format fmt("Received SIGCHLD when child did not " "actually exit (pid=%1%, status=%2%"); LOG_WARNING_MESSAGE(boost::str(fmt % pid % status)); } } // error occured else if (result == -1) { Error error = systemError(errno, ERROR_LOCATION); error.addProperty("pid", pid); LOG_ERROR(error); } }
virtual void stop() { // don't stop if we never started if (!started_) { LOG_WARNING_MESSAGE("Stopping HttpConnectionListener " "which wasn't started"); return; } // close acceptor boost::system::error_code ec ; acceptorService_.closeAcceptor(ec); if (ec) LOG_ERROR(core::Error(ec, ERROR_LOCATION)); // stop the server ioService().stop(); // join the thread and wait for it complete if (listenerThread_.joinable()) { if (!listenerThread_.timed_join(boost::posix_time::seconds(3))) { LOG_WARNING_MESSAGE( "HttpConnectionListener didn't stop within 3 sec"); } listenerThread_.detach(); } // allow subclass specific cleanup core::Error error = cleanup(); if (error) LOG_ERROR(error); }
bool FileLock::verifyInitialized() { if (!s_isInitialized) { static bool s_warned = false; if (s_warned) return s_isInitialized; s_warned = true; LOG_WARNING_MESSAGE( "FileLock classes not yet initialized; please call " "'FileLock::initialize()' and 'FileLock::cleanUp()' as appropriate"); } return s_isInitialized; }
Error scanRegistryForRTools(std::vector<RToolsInfo>* pRTools) { core::system::RegistryKey regKey; Error error = regKey.open(HKEY_LOCAL_MACHINE, "Software\\R-core\\Rtools", KEY_READ | KEY_WOW64_32KEY); if (error) { if (error.code() != boost::system::errc::no_such_file_or_directory) return error; else return Success(); } std::vector<std::string> keys = regKey.keyNames(); for (int i = 0; i < keys.size(); i++) { std::string name = keys.at(i); core::system::RegistryKey verKey; error = verKey.open(regKey.handle(), name, KEY_READ | KEY_WOW64_32KEY); if (error) { LOG_ERROR(error); continue; } std::string installPath = verKey.getStringValue("InstallPath", ""); if (!installPath.empty()) { std::string utf8InstallPath = string_utils::systemToUtf8(installPath); RToolsInfo toolsInfo(name, FilePath(utf8InstallPath)); if (toolsInfo.isStillInstalled()) { if (toolsInfo.isRecognized()) pRTools->push_back(toolsInfo); else LOG_WARNING_MESSAGE("Unknown Rtools version: " + name); } } } return Success(); }
void TexRegionRender::Render( DeviceContextGLImpl *pCtxGL, ITextureView *pSrcSRV, RESOURCE_DIMENSION TexType, TEXTURE_FORMAT TexFormat, Int32 DstToSrcXOffset, Int32 DstToSrcYOffset, Int32 SrcZ, Int32 SrcMipLevel) { { MapHelper< int > pConstant( pCtxGL, m_pConstantBuffer, MAP_WRITE_DISCARD, 0 ); pConstant[0] = DstToSrcXOffset; pConstant[1] = DstToSrcYOffset; pConstant[2] = SrcZ; pConstant[3] = SrcMipLevel; } const auto &TexFmtAttribs = GetTextureFormatAttribs(TexFormat); Uint32 FSInd = TexType * 3; if( TexFmtAttribs.ComponentType == COMPONENT_TYPE_SINT ) FSInd += 1; else if( TexFmtAttribs.ComponentType == COMPONENT_TYPE_UINT ) FSInd += 2; if( TexFmtAttribs.ComponentType == COMPONENT_TYPE_SNORM ) { LOG_WARNING_MESSAGE("CopyData() is performed by rendering to texture.\n" "There might be an issue in OpenGL driver on NVidia hardware: when rendering to SNORM textures, all negative values are clamped to zero.") } pCtxGL->SetPipelineState(m_pPSO[FSInd]); auto SrcTexVar = m_pFragmentShaders[FSInd]->GetShaderVariable( "gSourceTex" ); SrcTexVar->Set( pSrcSRV ); DrawAttribs DrawAttrs; DrawAttrs.NumVertices = 4; DrawAttrs.Topology = PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; pCtxGL->Draw( DrawAttrs ); SrcTexVar->Set( nullptr ); }
void run(const boost::function<void()>& checkForInput) { // ensure we have a run loop for this thread (not sure if this is // strictly necessary but it is not harmful) ::CFRunLoopGetCurrent(); while (true) { // process the run loop for 1 second SInt32 reason = ::CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, false); if (reason == kCFRunLoopRunStopped) { LOG_WARNING_MESSAGE("Unexpected stop of file monitor run loop"); break; } // check for input checkForInput(); } }
Cookie::Cookie(const Request& request, const std::string& name, const std::string& value, const std::string& path, bool httpOnly) : name_(name), value_(value), path_(path), expires_(not_a_date_time), httpOnly_(httpOnly) { if (path.empty() && URL::complete(request.uri(), "") != "/") { // If we're here, it means we're using an implicit path that // isn't the root. In other words, we're setting a cookie // that will only apply under the current "path". Since this // is not something we're likely to want, we warn--if this // is actually the desired behavior then use an explicit path // value. LOG_WARNING_MESSAGE("Implicit path used with non-root URL (" + request.uri() + ")"); } }
std::string ClientEvent::typeName() const { switch(type_) { case client_events::kBusy: return "busy"; case client_events::kConsolePrompt: return "console_prompt"; case client_events::kConsoleWriteOutput: return "console_output"; case client_events::kConsoleWriteError: return "console_error"; case client_events::kShowErrorMessage: return "show_error_message"; case client_events::kShowHelp: return "show_help"; case client_events::kBrowseUrl: return "browse_url"; case client_events::kShowEditor: return "show_editor"; case client_events::kChooseFile: return "choose_file"; case client_events::kAbendWarning: return "abend_warning"; case client_events::kQuit: return "quit"; case client_events::kSuicide: return "suicide"; case client_events::kFileChanged: return "file_changed"; case client_events::kWorkingDirChanged: return "working_dir_changed"; case client_events::kPlotsStateChanged: return "plots_state_changed"; case client_events::kViewData: return "view_data"; case client_events::kPackageStatusChanged: return "package_status_changed"; case client_events::kPackageStateChanged: return "package_state_changed"; case client_events::kLocator: return "locator"; case client_events::kConsoleResetHistory: return "console_reset_history"; case client_events::kSessionSerialization: return "session_serialization"; case client_events::kHistoryEntriesAdded: return "history_entries_added"; case client_events::kQuotaStatus: return "quota_status"; case client_events::kFileEdit: return "file_edit"; case client_events::kShowContent: return "show_content"; case client_events::kShowData: return "show_data"; case client_events::kAsyncCompletion: return "async_completion"; case client_events::kSaveActionChanged: return "save_action_changed"; case client_events::kConsoleWritePrompt: return "console_write_prompt"; case client_events::kConsoleWriteInput: return "console_write_input"; case client_events::kShowWarningBar: return "show_warning_bar"; case client_events::kOpenProjectError: return "open_project_error"; case client_events::kVcsRefresh: return "vcs_refresh"; case client_events::kAskPass: return "ask_pass"; case client_events::kConsoleProcessOutput: return "console_process_output"; case client_events::kConsoleProcessExit: return "console_process_exit"; case client_events::kListChanged: return "list_changed"; case client_events::kUiPrefsChanged: return "ui_prefs_changed"; case client_events::kHandleUnsavedChanges: return "handle_unsaved_changes"; case client_events::kConsoleProcessPrompt: return "console_process_prompt"; case client_events::kConsoleProcessCreated: return "console_process_created"; case client_events::kHTMLPreviewStartedEvent: return "html_preview_started_event"; case client_events::kHTMLPreviewOutputEvent: return "html_preview_output_event"; case client_events::kHTMLPreviewCompletedEvent: return "html_preview_completed_event"; case client_events::kCompilePdfStartedEvent: return "compile_pdf_started_event"; case client_events::kCompilePdfOutputEvent: return "compile_pdf_output_event"; case client_events::kCompilePdfErrorsEvent: return "compile_pdf_errors_event"; case client_events::kCompilePdfCompletedEvent: return "compile_pdf_completed_event"; case client_events::kSynctexEditFile: return "synctex_edit_file"; case client_events::kFindResult: return "find_result"; case client_events::kFindOperationEnded: return "find_operation_ended"; case client_events::kRPubsUploadStatus: return "rpubs_upload_status"; case client_events::kBuildStarted: return "build_started"; case client_events::kBuildOutput: return "build_output"; case client_events::kBuildCompleted: return "build_completed"; case client_events::kBuildErrors: return "build_errors"; case client_events::kDirectoryNavigate: return "directory_navigate"; case client_events::kDeferredInitCompleted: return "deferred_init_completed"; case client_events::kPlotsZoomSizeChanged: return "plots_zoom_size_changed"; case client_events::kSourceCppStarted: return "source_cpp_started"; case client_events::kSourceCppCompleted: return "source_cpp_completed"; case client_events::kLoadedPackageUpdates: return "loaded_package_updates"; case client_events::kActivatePane: return "activate_pane"; case client_events::kShowPresentationPane: return "show_presentation_pane"; case client_events::kEnvironmentRefresh: return "environment_refresh"; case client_events::kContextDepthChanged: return "context_depth_changed"; case client_events::kEnvironmentAssigned: return "environment_assigned"; case client_events::kEnvironmentRemoved: return "environment_removed"; case client_events::kBrowserLineChanged: return "browser_line_changed"; case client_events::kPackageLoaded: return "package_loaded"; case client_events::kPackageUnloaded: return "package_unloaded"; case client_events::kPresentationPaneRequestCompleted: return "presentation_pane_request_completed"; case client_events::kUnhandledError: return "unhandled_error"; case client_events::kErrorHandlerChanged: return "error_handler_changed"; case client_events::kViewerNavigate: return "viewer_navigate"; case client_events::kSourceExtendedTypeDetected: return "source_extended_type_detected"; case client_events::kShinyViewer: return "shiny_viewer"; case client_events::kDebugSourceCompleted: return "debug_source_completed"; case client_events::kRmdRenderStarted: return "rmd_render_started"; case client_events::kRmdRenderOutput: return "rmd_render_output"; case client_events::kRmdRenderCompleted: return "rmd_render_completed"; case client_events::kRmdShinyDocStarted: return "rmd_shiny_doc_started"; case client_events::kRmdRSConnectDeploymentOutput: return "rsconnect_deployment_output"; case client_events::kRmdRSConnectDeploymentCompleted: return "rsconnect_deployment_completed"; case client_events::kRmdRSConnectDeploymentFailed: return "rsconnect_deployment_failed"; case client_events::kUserPrompt: return "user_prompt"; case client_events::kInstallRtools: return "install_r_tools"; case client_events::kInstallShiny: return "install_shiny"; case client_events::kSuspendAndRestart: return "suspend_and_restart"; case client_events::kDataViewChanged: return "data_view_changed"; case client_events::kViewFunction: return "view_function"; case client_events::kMarkersChanged: return "markers_changed"; case client_events::kEnableRStudioConnect: return "enable_rstudio_connect"; case client_events::kUpdateGutterMarkers: return "update_gutter_markers"; case client_events::kSnippetsChanged: return "snippets_changed"; case client_events::kJumpToFunction: return "jump_to_function"; case client_events::kCollabEditStarted: return "collab_edit_started"; case client_events::kSessionCountChanged: return "session_count_changed"; case client_events::kCollabEditEnded: return "collab_edit_ended"; case client_events::kProjectUsersChanged: return "project_users_changed"; case client_events::kRVersionsChanged: return "r_versions_changed"; case client_events::kShinyGadgetDialog: return "shiny_gadget_dialog"; case client_events::kRmdParamsReady: return "rmd_params_ready"; case client_events::kRegisterUserCommand: return "register_user_command"; case client_events::kSendToConsole: return "send_to_console"; case client_events::kUserFollowStarted: return "user_follow_started"; case client_events::kUserFollowEnded: return "user_follow_ended"; case client_events::kProjectAccessRevoked: return "project_access_revoked"; case client_events::kCollabEditSaved: return "collab_edit_saved"; case client_events::kAddinRegistryUpdated: return "addin_registry_updated"; case client_events::kChunkOutput: return "chunk_output"; case client_events::kChunkOutputFinished: return "chunk_output_finished"; case client_events::kRprofStarted: return "rprof_started"; case client_events::kRprofStopped: return "rprof_stopped"; case client_events::kRprofCreated: return "rprof_created"; case client_events::kEditorCommand: return "editor_command"; case client_events::kPreviewRmd: return "preview_rmd"; case client_events::kWebsiteFileSaved: return "website_file_saved"; case client_events::kChunkPlotRefreshed: return "chunk_plot_refreshed"; case client_events::kChunkPlotRefreshFinished: return "chunk_plot_refresh_finished"; case client_events::kReloadWithLastChanceSave: return "reload_with_last_chance_save"; case client_events::kConnectionUpdated: return "connection_updated"; case client_events::kEnableConnections: return "enable_connections"; case client_events::kConnectionListChanged: return "connection_list_changed"; case client_events::kActiveConnectionsChanged: return "active_connections_changed"; case client_events::kConnectionOpened: return "connection_opened"; case client_events::kNotebookRangeExecuted: return "notebook_range_executed"; case client_events::kChunkExecStateChanged: return "chunk_exec_state_changed"; case client_events::kNavigateShinyFrame: return "navigate_shiny_frame"; case client_events::kUpdateNewConnectionDialog: return "update_new_connection_dialog"; case client_events::kProjectTemplateRegistryUpdated: return "project_template_registry_updated"; case client_events::kTerminalSubprocs: return "terminal_subprocs"; case client_events::kPackageExtensionIndexingCompleted: return "package_extension_indexing_completed"; case client_events::kRStudioAPIShowDialog: return "rstudioapi_show_dialog"; case client_events::kRStudioAPIShowDialogCompleted: return "rstudioapi_show_dialog_completed"; case client_events::kObjectExplorerEvent: return "object_explorer_event"; case client_events::kSendToTerminal: return "send_to_terminal"; case client_events::kClearTerminal: return "clear_terminal"; case client_events::kAddTerminal: return "add_terminal"; case client_events::kActivateTerminal: return "activate_terminal"; case client_events::kTerminalCwd: return "terminal_cwd"; case client_events::kAdminNotification: return "admin_notification"; case client_events::kRequestDocumentSave: return "request_document_save"; case client_events::kRequestDocumentSaveCompleted: return "request_document_save_completed"; case client_events::kRequestOpenProject: return "request_open_project"; case client_events::kOpenFileDialog: return "open_file_dialog"; case client_events::kRemoveTerminal: return "remove_terminal"; default: LOG_WARNING_MESSAGE("unexpected event type: " + safe_convert::numberToString(type_)); return ""; } }
std::string ClientEvent::typeName() const { switch(type_) { case client_events::kBusy: return "busy"; case client_events::kConsolePrompt: return "console_prompt"; case client_events::kConsoleWriteOutput: return "console_output"; case client_events::kConsoleWriteError: return "console_error"; case client_events::kShowErrorMessage: return "show_error_message"; case client_events::kShowHelp: return "show_help"; case client_events::kBrowseUrl: return "browse_url"; case client_events::kShowEditor: return "show_editor"; case client_events::kChooseFile: return "choose_file"; case client_events::kAbendWarning: return "abend_warning"; case client_events::kQuit: return "quit"; case client_events::kSuicide: return "suicide"; case client_events::kFileChanged: return "file_changed"; case client_events::kWorkingDirChanged: return "working_dir_changed"; case client_events::kPlotsStateChanged: return "plots_state_changed"; case client_events::kViewData: return "view_data"; case client_events::kPackageStatusChanged: return "package_status_changed"; case client_events::kPackageStateChanged: return "package_state_changed"; case client_events::kLocator: return "locator"; case client_events::kConsoleResetHistory: return "console_reset_history"; case client_events::kSessionSerialization: return "session_serialization"; case client_events::kHistoryEntriesAdded: return "history_entries_added"; case client_events::kQuotaStatus: return "quota_status"; case client_events::kFileEdit: return "file_edit"; case client_events::kShowContent: return "show_content"; case client_events::kShowData: return "show_data"; case client_events::kAsyncCompletion: return "async_completion"; case client_events::kSaveActionChanged: return "save_action_changed"; case client_events::kConsoleWritePrompt: return "console_write_prompt"; case client_events::kConsoleWriteInput: return "console_write_input"; case client_events::kShowWarningBar: return "show_warning_bar"; case client_events::kOpenProjectError: return "open_project_error"; case client_events::kVcsRefresh: return "vcs_refresh"; case client_events::kAskPass: return "ask_pass"; case client_events::kConsoleProcessOutput: return "console_process_output"; case client_events::kConsoleProcessExit: return "console_process_exit"; case client_events::kListChanged: return "list_changed"; case client_events::kUiPrefsChanged: return "ui_prefs_changed"; case client_events::kHandleUnsavedChanges: return "handle_unsaved_changes"; case client_events::kConsoleProcessPrompt: return "console_process_prompt"; case client_events::kConsoleProcessCreated: return "console_process_created"; case client_events::kHTMLPreviewStartedEvent: return "html_preview_started_event"; case client_events::kHTMLPreviewOutputEvent: return "html_preview_output_event"; case client_events::kHTMLPreviewCompletedEvent: return "html_preview_completed_event"; case client_events::kCompilePdfStartedEvent: return "compile_pdf_started_event"; case client_events::kCompilePdfOutputEvent: return "compile_pdf_output_event"; case client_events::kCompilePdfErrorsEvent: return "compile_pdf_errors_event"; case client_events::kCompilePdfCompletedEvent: return "compile_pdf_completed_event"; case client_events::kSynctexEditFile: return "synctex_edit_file"; case client_events::kFindResult: return "find_result"; case client_events::kFindOperationEnded: return "find_operation_ended"; case client_events::kRPubsUploadStatus: return "rpubs_upload_status"; case client_events::kBuildStarted: return "build_started"; case client_events::kBuildOutput: return "build_output"; case client_events::kBuildCompleted: return "build_completed"; case client_events::kBuildErrors: return "build_errors"; case client_events::kDirectoryNavigate: return "directory_navigate"; case client_events::kDeferredInitCompleted: return "deferred_init_completed"; case client_events::kPlotsZoomSizeChanged: return "plots_zoom_size_changed"; case client_events::kSourceCppStarted: return "source_cpp_started"; case client_events::kSourceCppCompleted: return "source_cpp_completed"; case client_events::kLoadedPackageUpdates: return "loaded_package_updates"; case client_events::kActivatePane: return "activate_pane"; case client_events::kShowPresentationPane: return "show_presentation_pane"; case client_events::kEnvironmentRefresh: return "environment_refresh"; case client_events::kContextDepthChanged: return "context_depth_changed"; case client_events::kEnvironmentAssigned: return "environment_assigned"; case client_events::kEnvironmentRemoved: return "environment_removed"; case client_events::kBrowserLineChanged: return "browser_line_changed"; case client_events::kPackageLoaded: return "package_loaded"; case client_events::kPackageUnloaded: return "package_unloaded"; case client_events::kPresentationPaneRequestCompleted: return "presentation_pane_request_completed"; case client_events::kUnhandledError: return "unhandled_error"; case client_events::kErrorHandlerChanged: return "error_handler_changed"; case client_events::kViewerNavigate: return "viewer_navigate"; case client_events::kSourceExtendedTypeDetected: return "source_extended_type_detected"; case client_events::kShinyViewer: return "shiny_viewer"; case client_events::kDebugSourceCompleted: return "debug_source_completed"; case client_events::kRmdRenderStarted: return "rmd_render_started"; case client_events::kRmdRenderOutput: return "rmd_render_output"; case client_events::kRmdRenderCompleted: return "rmd_render_completed"; case client_events::kRmdTemplateDiscovered: return "rmd_template_discovered"; case client_events::kRmdTemplateDiscoveryCompleted: return "rmd_template_discovery_completed"; case client_events::kRmdShinyDocStarted: return "rmd_shiny_doc_started"; case client_events::kRmdRSConnectDeploymentOutput: return "rsconnect_deployment_output"; case client_events::kRmdRSConnectDeploymentCompleted: return "rsconnect_deployment_completed"; case client_events::kUserPrompt: return "user_prompt"; case client_events::kInstallRtools: return "install_r_tools"; case client_events::kInstallShiny: return "install_shiny"; case client_events::kSuspendAndRestart: return "suspend_and_restart"; case client_events::kDataViewChanged: return "data_view_changed"; case client_events::kViewFunction: return "view_function"; case client_events::kMarkersChanged: return "markers_changed"; case client_events::kEnableRStudioConnect: return "enable_rstudio_connect"; case client_events::kUpdateGutterMarkers: return "update_gutter_markers"; case client_events::kSnippetsChanged: return "snippets_changed"; case client_events::kJumpToFunction: return "jump_to_function"; case client_events::kCollabEditStarted: return "collab_edit_started"; case client_events::kSessionCountChanged: return "session_count_changed"; case client_events::kCollabEditEnded: return "collab_edit_ended"; case client_events::kProjectUsersChanged: return "project_users_changed"; case client_events::kRVersionsChanged: return "r_versions_changed"; case client_events::kRmdParamsEdit: return "rmd_params_edit"; case client_events::kRmdParamsReady: return "rmd_params_ready"; case client_events::kRegisterUserCommand: return "register_user_command"; default: LOG_WARNING_MESSAGE("unexpected event type: " + safe_convert::numberToString(type_)); return ""; } }
std::string ClientEvent::typeName() const { switch(type_) { case client_events::kBusy: return "busy"; case client_events::kConsolePrompt: return "console_prompt"; case client_events::kConsoleWriteOutput: return "console_output"; case client_events::kConsoleWriteError: return "console_error"; case client_events::kShowErrorMessage: return "show_error_message"; case client_events::kShowHelp: return "show_help"; case client_events::kBrowseUrl: return "browse_url"; case client_events::kWorkspaceRefresh: return "workspace_refresh"; case client_events::kWorkspaceAssign: return "workspace_assign"; case client_events::kWorkspaceRemove: return "workspace_remove"; case client_events::kShowEditor: return "show_editor"; case client_events::kChooseFile: return "choose_file"; case client_events::kAbendWarning: return "abend_warning"; case client_events::kQuit: return "quit"; case client_events::kSuicide: return "suicide"; case client_events::kFileChanged: return "file_changed"; case client_events::kWorkingDirChanged: return "working_dir_changed"; case client_events::kPlotsStateChanged: return "plots_state_changed"; case client_events::kViewData: return "view_data"; case client_events::kPackageStatusChanged: return "package_status_changed"; case client_events::kInstalledPackagesChanged: return "installed_packages_changed"; case client_events::kLocator: return "locator"; case client_events::kConsoleResetHistory: return "console_reset_history"; case client_events::kSessionSerialization: return "session_serialization"; case client_events::kHistoryEntriesAdded: return "history_entries_added"; case client_events::kQuotaStatus: return "quota_status"; case client_events::kFileEdit: return "file_edit"; case client_events::kShowContent: return "show_content"; case client_events::kShowData: return "show_data"; case client_events::kAsyncCompletion: return "async_completion"; case client_events::kSaveActionChanged: return "save_action_changed"; case client_events::kConsoleWritePrompt: return "console_write_prompt"; case client_events::kConsoleWriteInput: return "console_write_input"; case client_events::kShowWarningBar: return "show_warning_bar"; case client_events::kOpenProjectError: return "open_project_error"; case client_events::kVcsRefresh: return "vcs_refresh"; case client_events::kAskPass: return "ask_pass"; case client_events::kConsoleProcessOutput: return "console_process_output"; case client_events::kConsoleProcessExit: return "console_process_exit"; case client_events::kListChanged: return "list_changed"; case client_events::kUiPrefsChanged: return "ui_prefs_changed"; case client_events::kHandleUnsavedChanges: return "handle_unsaved_changes"; case client_events::kConsoleProcessPrompt: return "console_process_prompt"; case client_events::kConsoleProcessCreated: return "console_process_created"; case client_events::kHTMLPreviewStartedEvent: return "html_preview_started_event"; case client_events::kHTMLPreviewOutputEvent: return "html_preview_output_event"; case client_events::kHTMLPreviewCompletedEvent: return "html_preview_completed_event"; case client_events::kCompilePdfStartedEvent: return "compile_pdf_started_event"; case client_events::kCompilePdfOutputEvent: return "compile_pdf_output_event"; case client_events::kCompilePdfErrorsEvent: return "compile_pdf_errors_event"; case client_events::kCompilePdfCompletedEvent: return "compile_pdf_completed_event"; case client_events::kSynctexEditFile: return "synctex_edit_file"; case client_events::kFindResult: return "find_result"; case client_events::kFindOperationEnded: return "find_operation_ended"; case client_events::kRPubsUploadStatus: return "rpubs_upload_status"; case client_events::kBuildStarted: return "build_started"; case client_events::kBuildOutput: return "build_output"; case client_events::kBuildCompleted: return "build_completed"; default: LOG_WARNING_MESSAGE("unexpected event type: " + boost::lexical_cast<std::string>(type_)); return ""; } }
std::string ClientEvent::typeName() const { switch(type_) { case client_events::kBusy: return "busy"; case client_events::kConsolePrompt: return "console_prompt"; case client_events::kConsoleWriteOutput: return "console_output"; case client_events::kConsoleWriteError: return "console_error"; case client_events::kShowErrorMessage: return "show_error_message"; case client_events::kShowHelp: return "show_help"; case client_events::kBrowseUrl: return "browse_url"; case client_events::kShowEditor: return "show_editor"; case client_events::kChooseFile: return "choose_file"; case client_events::kAbendWarning: return "abend_warning"; case client_events::kQuit: return "quit"; case client_events::kSuicide: return "suicide"; case client_events::kFileChanged: return "file_changed"; case client_events::kWorkingDirChanged: return "working_dir_changed"; case client_events::kPlotsStateChanged: return "plots_state_changed"; case client_events::kViewData: return "view_data"; case client_events::kPackageStatusChanged: return "package_status_changed"; case client_events::kInstalledPackagesChanged: return "installed_packages_changed"; case client_events::kLocator: return "locator"; case client_events::kConsoleResetHistory: return "console_reset_history"; case client_events::kSessionSerialization: return "session_serialization"; case client_events::kHistoryEntriesAdded: return "history_entries_added"; case client_events::kQuotaStatus: return "quota_status"; case client_events::kFileEdit: return "file_edit"; case client_events::kShowContent: return "show_content"; case client_events::kShowData: return "show_data"; case client_events::kAsyncCompletion: return "async_completion"; case client_events::kSaveActionChanged: return "save_action_changed"; case client_events::kConsoleWritePrompt: return "console_write_prompt"; case client_events::kConsoleWriteInput: return "console_write_input"; case client_events::kShowWarningBar: return "show_warning_bar"; case client_events::kOpenProjectError: return "open_project_error"; case client_events::kVcsRefresh: return "vcs_refresh"; case client_events::kAskPass: return "ask_pass"; case client_events::kConsoleProcessOutput: return "console_process_output"; case client_events::kConsoleProcessExit: return "console_process_exit"; case client_events::kListChanged: return "list_changed"; case client_events::kUiPrefsChanged: return "ui_prefs_changed"; case client_events::kHandleUnsavedChanges: return "handle_unsaved_changes"; case client_events::kConsoleProcessPrompt: return "console_process_prompt"; case client_events::kConsoleProcessCreated: return "console_process_created"; case client_events::kHTMLPreviewStartedEvent: return "html_preview_started_event"; case client_events::kHTMLPreviewOutputEvent: return "html_preview_output_event"; case client_events::kHTMLPreviewCompletedEvent: return "html_preview_completed_event"; case client_events::kCompilePdfStartedEvent: return "compile_pdf_started_event"; case client_events::kCompilePdfOutputEvent: return "compile_pdf_output_event"; case client_events::kCompilePdfErrorsEvent: return "compile_pdf_errors_event"; case client_events::kCompilePdfCompletedEvent: return "compile_pdf_completed_event"; case client_events::kSynctexEditFile: return "synctex_edit_file"; case client_events::kFindResult: return "find_result"; case client_events::kFindOperationEnded: return "find_operation_ended"; case client_events::kRPubsUploadStatus: return "rpubs_upload_status"; case client_events::kBuildStarted: return "build_started"; case client_events::kBuildOutput: return "build_output"; case client_events::kBuildCompleted: return "build_completed"; case client_events::kBuildErrors: return "build_errors"; case client_events::kDirectoryNavigate: return "directory_navigate"; case client_events::kDeferredInitCompleted: return "deferred_init_completed"; case client_events::kPlotsZoomSizeChanged: return "plots_zoom_size_changed"; case client_events::kSourceCppStarted: return "source_cpp_started"; case client_events::kSourceCppCompleted: return "source_cpp_completed"; case client_events::kLoadedPackageUpdates: return "loaded_package_updates"; case client_events::kActivatePane: return "activate_pane"; case client_events::kShowPresentationPane: return "show_presentation_pane"; case client_events::kEnvironmentRefresh: return "environment_refresh"; case client_events::kContextDepthChanged: return "context_depth_changed"; case client_events::kEnvironmentAssigned: return "environment_assigned"; case client_events::kEnvironmentRemoved: return "environment_removed"; case client_events::kBrowserLineChanged: return "browser_line_changed"; case client_events::kPackageLoaded: return "package_loaded"; case client_events::kPackageUnloaded: return "package_unloaded"; case client_events::kPresentationPaneRequestCompleted: return "presentation_pane_request_completed"; case client_events::kUnhandledError: return "unhandled_error"; case client_events::kErrorHandlerChanged: return "error_handler_changed"; case client_events::kViewerNavigate: return "viewer_navigate"; case client_events::kSourceExtendedTypeDetected: return "source_extended_type_detected"; default: LOG_WARNING_MESSAGE("unexpected event type: " + safe_convert::numberToString(type_)); return ""; } }
bool rConsoleRead(const std::string& prompt, bool addToHistory, rstudio::r::session::RConsoleInput* pConsoleInput) { // this is an invalid state in a forked (multicore) process if (main_process::wasForked()) { LOG_WARNING_MESSAGE("rConsoleRead called in forked processs"); return false; } // r is not processing input setExecuting(false); if (!s_consoleInputBuffer.empty()) { *pConsoleInput = s_consoleInputBuffer.front(); s_consoleInputBuffer.pop(); } // otherwise prompt and wait for console_input from the client else { // fire console_prompt event (unless we are just starting up, in which // case we will either prompt as part of the response to client_init or // we shouldn't prompt at all because we are resuming a suspended session) if (init::isSessionInitialized()) consolePrompt(prompt, addToHistory); // wait for console_input json::JsonRpcRequest request ; bool succeeded = http_methods::waitForMethod( kConsoleInput, boost::bind(consolePrompt, prompt, addToHistory), boost::bind(canSuspend, prompt), &request); // exit process if we failed if (!succeeded) return false; // extract console input. if there is an error during extraction we log it // but still return and empty string and true (returning false will cause R // to abort) Error error = extractConsoleInput(request); if (error) { LOG_ERROR(error); *pConsoleInput = rstudio::r::session::RConsoleInput("", ""); } *pConsoleInput = s_consoleInputBuffer.front(); s_consoleInputBuffer.pop(); } // fire onBeforeExecute and onConsoleInput events if this isn't a cancel if (!pConsoleInput->cancel) { module_context::events().onBeforeExecute(); module_context::events().onConsoleInput(pConsoleInput->text); } // we are about to return input to r so set the flag indicating that state setExecuting(true); // ensure that output resulting from this input goes to the correct console if (clientEventQueue().setActiveConsole(pConsoleInput->console)) { module_context::events().onActiveConsoleChanged(pConsoleInput->console, pConsoleInput->text); } ClientEvent promptEvent(client_events::kConsoleWritePrompt, prompt); clientEventQueue().add(promptEvent); enqueueConsoleInput(*pConsoleInput); // always return true (returning false causes the process to exit) return true; }