Skip to content

Commit

Permalink
eliminate re-issue prompt flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Sep 29, 2011
1 parent dcf4615 commit 8f49192
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 27 deletions.
24 changes: 8 additions & 16 deletions src/cpp/session/SessionMain.cpp
Expand Up @@ -2154,8 +2154,7 @@ void syncRSaveAction()

namespace {

void waitForMethodInitFunction(const ClientEvent& initEvent,
bool reissuePrompt)
void waitForMethodInitFunction(const ClientEvent& initEvent)
{
module_context::enqueClientEvent(initEvent);

Expand All @@ -2164,40 +2163,33 @@ void waitForMethodInitFunction(const ClientEvent& initEvent,
ClientEvent busyEvent(client_events::kBusy, true);
module_context::enqueClientEvent(busyEvent);
}
else if (reissuePrompt)
else
{
reissueLastConsolePrompt();
}
}

bool registeredWaitForMethod(const std::string& method,
const ClientEvent& event,
bool reissuePrompt,
core::json::JsonRpcRequest* pRequest)
{
// enque the event which notifies the client we want input
module_context::enqueClientEvent(event);

// compose initFunction
boost::function<void()> initFunction =
boost::bind(waitForMethodInitFunction, event, reissuePrompt);

// wait for method
return waitForMethod(method, initFunction, disallowSuspend, pRequest);
return waitForMethod(method,
boost::bind(waitForMethodInitFunction, event),
disallowSuspend,
pRequest);
}

} // anonymous namepace

WaitForMethodFunction registerWaitForMethod(const std::string& methodName,
const ClientEvent& event,
bool reissuePrompt)
const ClientEvent& event)
{
s_waitForMethodNames.push_back(methodName);
return boost::bind(registeredWaitForMethod,
methodName,
event,
reissuePrompt,
_1);
return boost::bind(registeredWaitForMethod, methodName, event, _1);
}

} // namespace module_context
Expand Down
6 changes: 1 addition & 5 deletions src/cpp/session/include/session/SessionModuleContext.hpp
Expand Up @@ -123,14 +123,10 @@ core::Error executeAsync(const core::json::JsonRpcFunction& function,
// (a) enque the passed event
// (b) wait for the specified methodName to be returned from the client
// (c) automatically re-issue the event after a client-init
// (d) if requested, automatically re-prompt after client-init (this
// is useful for situations where the blocking state is NOT origined
// inside the REPL loop -- e.g. for interactions with ssh)
//
typedef boost::function<bool(core::json::JsonRpcRequest*)> WaitForMethodFunction;
WaitForMethodFunction registerWaitForMethod(const std::string& methodName,
const ClientEvent& event,
bool reissuePrompt = false);
const ClientEvent& event);

namespace {

Expand Down
8 changes: 2 additions & 6 deletions src/cpp/session/modules/SessionSourceControl.cpp
Expand Up @@ -1762,17 +1762,13 @@ core::Error initialize()
if (error)
return error;

// register waitForMethod handler. we pass 'true' for the reissuePrompt
// parameter because passphrase prompting does not occur in reponse
// to the REPL loop so after a client init we need to remind the
// client that they are still in a REPL state waiting for input
// register waitForMethod handler
json::Object payload;
payload["prompt"] = std::string("Enter passphrase:");
ClientEvent askPassEvent(client_events::kAskPass, payload);
s_waitForAskPass = module_context::registerWaitForMethod(
"askpass_completed",
askPassEvent,
true);
askPassEvent);

// setup environment
BOOST_ASSERT(boost::algorithm::ends_with(sshAskCmd, "rpostback-askpass"));
Expand Down

0 comments on commit 8f49192

Please sign in to comment.