Пример #1
0
Error initialize()
{
   boost::shared_ptr<SEXP> pErrorHandler =
         boost::make_shared<SEXP>(R_NilValue);
   boost::shared_ptr<bool> pHandleUserErrorsOnly =
         boost::make_shared<bool>(true);

   using boost::bind;
   using namespace module_context;

   // Check to see whether the error handler has changed immediately after init
   // (to find changes from e.g. .Rprofile) and after every console prompt.
   events().onConsolePrompt.connect(bind(detectHandlerChange,
                                         pErrorHandler, false));
   events().onDeferredInit.connect(bind(detectHandlerChange,
                                        pErrorHandler, true));
   userSettings().onChanged.connect(bind(onUserSettingsChanged,
                                         pErrorHandler,
                                         pHandleUserErrorsOnly));

   json::JsonRpcFunction setErrMgmt =
         bind(setErrHandlerType, pErrorHandler, _1, _2);

   ExecBlock initBlock;
   initBlock.addFunctions()
      (bind(registerRpcMethod, "set_error_management_type", setErrMgmt))
      (bind(sourceModuleRFile, "SessionErrors.R"))
      (bind(initializeErrManagement, pErrorHandler, pHandleUserErrorsOnly));

   return initBlock.execute();
}
Пример #2
0
Error completeEmbeddedRInitialization(bool useInternet2)
{
   // set memory limit
   setMemoryLimit();

   // use IE proxy settings if requested
   boost::format fmt("suppressWarnings(utils::setInternet2(%1%))");
   Error error = r::exec::executeString(boost::str(fmt % useInternet2));
   if (error)
      LOG_ERROR(error);

   using boost::bind;
   using namespace r::function_hook ;
   ExecBlock block ;
   block.addFunctions()
      (bind(registerUnsupported, "loadhistory", "utils"))
      (bind(registerUnsupported, "savehistory", "utils"))
      (bind(registerUnsupported, "history", "utils"))
      (bind(registerUnsupported, "timestamp", "utils"))
      (bind(registerUnsupported, "winMenuAdd", "utils"))
      (bind(registerUnsupported, "winMenuAddItem", "utils"))
      (bind(registerUnsupported, "winMenuDel", "utils"))
      (bind(registerUnsupported, "winMenuDelItem", "utils"))
      (bind(registerUnsupported, "winMenuNames", "utils"))
      (bind(registerUnsupported, "winMenuItems", "utils"));
   return block.execute();
}
Пример #3
0
Error completeEmbeddedRInitialization(bool useInternet2)
{
   // set memory limit
   setMemoryLimit();

   // use IE proxy settings if requested
   if (!r::session::utils::isR3_3())
   {
      boost::format fmt("suppressWarnings(utils::setInternet2(%1%))");
      Error error = r::exec::executeString(boost::str(fmt % useInternet2));
      if (error)
         LOG_ERROR(error);
   }

   // register history functions
   Error error = r::exec::RFunction(".rs.registerHistoryFunctions").call();
   if (error)
      LOG_ERROR(error);

   using boost::bind;
   using namespace r::function_hook ;
   ExecBlock block ;
   block.addFunctions()
      (bind(registerUnsupported, "bringToTop", "grDevices"))
      (bind(registerUnsupported, "winMenuAdd", "utils"))
      (bind(registerUnsupported, "winMenuAddItem", "utils"))
      (bind(registerUnsupported, "winMenuDel", "utils"))
      (bind(registerUnsupported, "winMenuDelItem", "utils"))
      (bind(registerUnsupported, "winMenuNames", "utils"))
      (bind(registerUnsupported, "winMenuItems", "utils"));
   return block.execute();
}
Пример #4
0
Error initialize()
{
   R_CallMethodDef methodDef;
   methodDef.name = "rs_checkSpelling" ;
   methodDef.fun = (DL_FUNC) rs_checkSpelling ;
   methodDef.numArgs = 1;
   r::routines::addCallMethod(methodDef);

   // initialize spelling engine
   using namespace rstudio::core::spelling;
   HunspellSpellingEngine* pHunspell = new HunspellSpellingEngine(
                                             userSettings().spellingLanguage(),
                                             hunspellDictionaryManager(),
                                             &r::util::iconvstr);
   s_pSpellingEngine.reset(pHunspell);

   // connect to user settings changed
   userSettings().onChanged.connect(onUserSettingsChanged);

   // register rpc methods
   using boost::bind;
   using namespace module_context;
   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(registerRpcMethod, "check_spelling", checkSpelling))
      (bind(registerRpcMethod, "suggestion_list", suggestionList))
      (bind(registerRpcMethod, "get_word_chars", getWordChars))
      (bind(registerRpcMethod, "add_custom_dictionary", addCustomDictionary))
      (bind(registerRpcMethod, "remove_custom_dictionary", removeCustomDictionary))
      (bind(registerRpcMethod, "install_all_dictionaries", installAllDictionaries))
      (bind(sourceModuleRFile, "SessionSpelling.R"));
   return initBlock.execute();
}
Пример #5
0
Error initialize()
{
   // register postback handler for sumatra pdf
#ifdef _WIN32
   std::string ignoredCommand; // assumes bash script invocation, we
                               // don't/can't use that for rsinverse
   Error error = module_context::registerPostbackHandler("rsinverse",
                                                         rsinversePostback,
                                                         &ignoredCommand);
   if (error)
      return error ;

#endif

   // install rpc methods
   using boost::bind;
   using namespace module_context;
   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(registerRpcMethod, "apply_forward_concordance", rpcApplyForwardConcordance))
      (bind(registerRpcMethod, "apply_inverse_concordance", rpcApplyInverseConcordance))
      (bind(registerRpcMethod, "synctex_forward_search", synctexForwardSearch))
      (bind(registerRpcMethod, "synctex_inverse_search", synctexInverseSearch))
   ;
   return initBlock.execute();
}
Пример #6
0
Error initialize()
{    
   if (!session::options().verifyInstallation())
   {
      // capture standard streams
      Error error = initializeOutputCapture();
      if (error)
         return error;
   }
   
   // subscribe to events
   using boost::bind;
   using namespace module_context;
   events().onClientInit.connect(bind(onClientInit));
   events().onDetectChanges.connect(bind(onDetectChanges, _1));

   // more initialization 
   using boost::bind;
   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(sourceModuleRFile, "SessionConsole.R"))
      (bind(registerRpcMethod, "reset_console_actions", resetConsoleActions));

   return initBlock.execute();
}
Пример #7
0
Error initialize()
{
   using boost::bind;
   using namespace module_context;
   ExecBlock initBlock;
   initBlock.addFunctions()
      (bind(sourceModuleRFile, "SessionRHooks.R"));
   return initBlock.execute();
}
Пример #8
0
Error initialize()
{
    using boost::bind;
    using namespace session::module_context;
    ExecBlock initBlock ;
    initBlock.addFunctions()
    (bind(registerUriHandler, "/content", handleContentRequest))
    (bind(registerRpcMethod, "remove_content_url", removeContentUrl));
    return initBlock.execute();
}
Пример #9
0
core::Error initHtmlWidgets()
{
   RS_REGISTER_CALL_METHOD(rs_recordHtmlWidget, 3);

   ExecBlock initBlock;
   initBlock.addFunctions()
      (boost::bind(module_context::sourceModuleRFile, "NotebookHtmlWidgets.R"));

   return initBlock.execute();
}
Пример #10
0
Error initialize()
{
   // install rpc methods
   using boost::bind;
   using namespace module_context;
   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(registerRpcMethod, "get_public_key", getPublicKey));
   return initBlock.execute();
}
Пример #11
0
Error ignoreTerminalSignals()
{
   ExecBlock ignoreBlock ;
   ignoreBlock.addFunctions()
      (boost::bind(ignoreSig, SIGHUP))
      (boost::bind(ignoreSig, SIGTSTP))
      (boost::bind(ignoreSig, SIGTTOU))
      (boost::bind(ignoreSig, SIGTTIN));
   return ignoreBlock.execute();
}
Пример #12
0
core::Error initData()
{
    RS_REGISTER_CALL_METHOD(rs_recordData, 2);

    ExecBlock initBlock;
    initBlock.addFunctions()
    (boost::bind(module_context::sourceModuleRFile, "NotebookData.R"))
    (boost::bind(module_context::registerUriHandler, kNotebookDataResourceLocation, handleNotebookDataResReq));

    return initBlock.execute();
}
Пример #13
0
Error initialize()
{
   using boost::bind;
   using namespace module_context;

   ExecBlock initBlock;
   initBlock.addFunctions()
      (bind(registerAsyncRpcMethod, "check_for_updates", checkForUpdates))
   ;
   return initBlock.execute();
}
Пример #14
0
Error initialize()
{
   // install rpc methods
   using boost::bind;
   using namespace module_context;
   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(registerUriHandler, "/view_pdf", handleViewPdf))
      (bind(registerUriHandler, kPdfJsPath, handlePdfJs))
   ;
   return initBlock.execute();
}
Пример #15
0
Error initialize()
{
   using boost::bind;
   using namespace session::module_context;
   ExecBlock initBlock ;
   initBlock.addFunctions()
      (data::viewer::initialize)
      (bind(sourceModuleRFile, "SessionDataImport.R"))
      (bind(sourceModuleRFile, "SessionDataImportV2.R"));

   return initBlock.execute();
}
Пример #16
0
Error initialize()
{
   using boost::bind;
   using namespace module_context;
   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(registerRpcMethod, "accept_agreement", handleAcceptAgreement))
      (bind(registerUriHandler, "/agreement", handleAgreementRequest))
   ;

   return initBlock.execute();
}
Пример #17
0
Error initialize()
{
   // install rpc methods
   using boost::bind;
   using namespace module_context;
   ExecBlock initBlock ;
   initBlock.addFunctions()
      (tex::compile_pdf::initialize)
      (bind(registerRpcMethod, "is_tex_installed", isTexInstalled))
      (bind(registerRpcMethod, "get_tex_capabilities", getTexCapabilities))
   ;
  return initBlock.execute();
}
Пример #18
0
Error initialize()
{
   RS_REGISTER_CALL_METHOD(rs_fromJSON, 1);
   RS_REGISTER_CALL_METHOD(rs_isNullExternalPointer, 1);
   
   using boost::bind;
   using namespace module_context;

   ExecBlock initBlock;
   initBlock.addFunctions()
         (bind(sourceModuleRFile, "SessionRUtil.R"));
   return initBlock.execute();
}
Пример #19
0
Error initialize()
{
    // install rpc methods
    using boost::bind;
    using namespace module_context;
    ExecBlock initBlock ;
    initBlock.addFunctions()
    (bind(registerRpcMethod, "process_prepare", procInit))
    (bind(registerRpcMethod, "process_start", procStart))
    (bind(registerRpcMethod, "process_interrupt", procInterrupt));

    return initBlock.execute();
}
Пример #20
0
Error initialize()
{  
   ExecBlock initBlock ;
   
   source_database::events().onDocPendingRemove.connect(onDocPendingRemove);

   initBlock.addFunctions()
      (boost::bind(module_context::sourceModuleRFile, "SessionProfiler.R"))
      (boost::bind(module_context::registerUriHandler, "/" kProfilesUrlPath "/", handleProfilerResReq));

   RS_REGISTER_CALL_METHOD(rs_profilesPath, 0);

   return initBlock.execute();
}
Пример #21
0
Error initialize()
{
   // subscribe to events
   using boost::bind;
   using namespace module_context;

   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(registerRpcMethod, "get_function_state", getFunctionState))
      (bind(registerRpcMethod, "set_function_breakpoints", setBreakpoints))
      (bind(sourceModuleRFile, "SessionBreakpoints.R"));

   return initBlock.execute();
}
Пример #22
0
Error initialize()
{
   using namespace module_context;
   module_context::events().onClientInit.connect(boost::bind(onClientInit));

   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(registerRpcMethod, "start_posix_shell", startPosixShell))
      (bind(registerRpcMethod, "interrupt_posix_shell", interruptPosixShell))
      (bind(registerRpcMethod, "send_input_to_posix_shell", sendInputToPosixShell))
      (bind(registerRpcMethod, "terminate_posix_shell", terminatePosixShell));
   return initBlock.execute();

}
Пример #23
0
Error initialize()
{
   // subscribe to events
   using boost::bind;
   using namespace session::module_context;
   events().onDetectChanges.connect(bind(onDetectChanges, _1));

   // source R functions
   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(registerRpcMethod, "list_environment", listEnvironment))
      (bind(sourceModuleRFile, "SessionEnvironment.R"));

   return initBlock.execute();
}
Пример #24
0
core::Error initialize()
{
   using namespace module_context;
   using boost::bind;
   
   events().afterSessionInitHook.connect(afterSessionInitHook);
   events().onClientInit.connect(onClientInit);
   
   ExecBlock initBlock;
   initBlock.addFunctions()
         (bind(registerRpcMethod, "save_snippets", saveSnippets))
         (bind(registerRpcMethod, "get_snippets", getSnippets));
   
   return initBlock.execute();
}
Пример #25
0
Error initialize()
{
   // subscribe to events
   using boost::bind;
   using namespace module_context;

   events().onPackageLoaded.connect(onPackageLoaded);

   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(registerRpcMethod, "get_function_sync_state", getFunctionSyncState))
      (bind(sourceModuleRFile, "SessionBreakpoints.R"));

   return initBlock.execute();
}
Пример #26
0
core::Error initialize()
{
   using namespace session::module_context;

   // register suspend handler
   addSuspendHandler(SuspendHandler(onSuspend, onResume));

   // install handlers
   using boost::bind;
   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(registerRpcMethod, "begin_find", beginFind))
      (bind(registerRpcMethod, "stop_find", stopFind))
      (bind(registerRpcMethod, "clear_find_results", clearFindResults));
   return initBlock.execute();
}
Пример #27
0
Error initialize()
{
   using boost::bind;
   using namespace module_context;

   // add suspend/resume handler
   addSuspendHandler(SuspendHandler(onSuspend, onResume));

   // install rpc methods
   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(registerRpcMethod, "process_prepare", procInit))
      (bind(registerRpcMethod, "process_start", procStart))
      (bind(registerRpcMethod, "process_interrupt", procInterrupt))
      (bind(registerRpcMethod, "process_reap", procReap));

   return initBlock.execute();
}
Пример #28
0
Error initialize()
{
   using boost::bind;
   using namespace module_context;

   boost::shared_ptr<int> pShinyViewerType =
         boost::make_shared<int>(SHINY_VIEWER_NONE);

   R_CallMethodDef methodDefViewer;
   methodDefViewer.name = "rs_shinyviewer";
   methodDefViewer.fun = (DL_FUNC) rs_shinyviewer;
   methodDefViewer.numArgs = 2;
   r::routines::addCallMethod(methodDefViewer);

   userSettings().onChanged.connect(bind(onUserSettingsChanged,
                                         pShinyViewerType));

   ExecBlock initBlock;
   initBlock.addFunctions()
      (bind(sourceModuleRFile, "SessionShinyViewer.R"))
      (bind(initShinyViewerPref, pShinyViewerType));

   return initBlock.execute();
}
Пример #29
0
Error initialize()
{
   // register rs_showPresentation
   R_CallMethodDef methodDefShowPresentation;
   methodDefShowPresentation.name = "rs_showPresentation" ;
   methodDefShowPresentation.fun = (DL_FUNC) rs_showPresentation;
   methodDefShowPresentation.numArgs = 1;
   r::routines::addCallMethod(methodDefShowPresentation);

   // register rs_showPresentationHelpDoc
   R_CallMethodDef methodDefShowHelpDoc;
   methodDefShowHelpDoc.name = "rs_showPresentationHelpDoc" ;
   methodDefShowHelpDoc.fun = (DL_FUNC) rs_showPresentationHelpDoc;
   methodDefShowHelpDoc.numArgs = 1;
   r::routines::addCallMethod(methodDefShowHelpDoc);

   // initialize presentation log
   Error error = log().initialize();
   if (error)
      return error;

   using boost::bind;
   using namespace session::module_context;
   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(registerUriHandler, "/presentation", handlePresentationPaneRequest))
      (bind(registerRpcMethod, "create_standalone_presentation", createStandalonePresentation))
      (bind(registerRpcMethod, "create_presentation_rpubs_source", createPresentationRpubsSource))
      (bind(registerRpcMethod, "set_presentation_slide_index", setPresentationSlideIndex))
      (bind(registerRpcMethod, "close_presentation_pane", closePresentationPane))
      (bind(registerRpcMethod, "presentation_execute_code", presentationExecuteCode))
      (bind(presentation::state::initialize))
      (bind(sourceModuleRFile, "SessionPresentation.R"));

   return initBlock.execute();
}
Пример #30
0
core::Error initialize()
{
   git::initialize();
   svn::initialize();

   // http endpoints
   using boost::bind;
   using namespace module_context;
   ExecBlock initBlock ;
   initBlock.addFunctions()
      (bind(registerRpcMethod, "vcs_clone", vcsClone));
   Error error = initBlock.execute();
   if (error)
      return error;

   // If VCS is disabled, or we're not in a project, do nothing
   const projects::ProjectContext& projContext = projects::projectContext();
   FilePath workingDir = projContext.directory();

   if (!session::options().allowVcs() || !userSettings().vcsEnabled() || workingDir.empty())
      return Success();


   // If Git or SVN was explicitly specified, choose it if valid
   projects::RProjectVcsOptions vcsOptions;
   if (projContext.hasProject())
   {
      Error vcsError = projContext.readVcsOptions(&vcsOptions);
      if (vcsError)
         LOG_ERROR(vcsError);
   }

   if (vcsOptions.vcsOverride == kVcsIdNone)
   {
      return Success();
   }
   else if (vcsOptions.vcsOverride == git::kVcsId)
   {
      if (git::isGitInstalled() && git::isGitDirectory(workingDir))
         return git::initializeGit(workingDir);
      return Success();
   }
   else if (vcsOptions.vcsOverride == svn::kVcsId)
   {
      if (svn::isSvnInstalled() && svn::isSvnDirectory(workingDir))
         return svn::initializeSvn(workingDir);
      return Success();
   }

   if (git::isGitInstalled() && git::isGitDirectory(workingDir))
   {
      return git::initializeGit(workingDir);
   }
   else if (svn::isSvnInstalled() && svn::isSvnDirectory(workingDir))
   {
      return svn::initializeSvn(workingDir);
   }
   else
   {
      return Success();  // none specified or detected
   }
}