Skip to content
Permalink
Browse files

Open source companion commit for rstudio/rstudio-pro#1244

  • Loading branch information
kfeinauer committed Oct 9, 2019
1 parent 21f6fca commit ca41511c75cd510e0140c8fbff3773e875dcc744
@@ -435,7 +435,7 @@ class AsyncServerImpl : public AsyncServer, boost::noncopyable

if (!originator.empty() && originator != host)
{
LOG_ERROR_MESSAGE("Rejecting request with mistmatched originator " + originator + " - "
LOG_ERROR_MESSAGE("Rejecting request with mismatched originator " + originator + " - "
"expected: " + host + " for URI " + pRequest->uri());
pConnection->response().setStatusCode(http::status::BadRequest);
return false;
@@ -1390,7 +1390,7 @@ void GwtCallback::showLicenseDialog()

void GwtCallback::showSessionServerOptionsDialog()
{
sessionServers().showSessionServerOptionsDialog();
sessionServers().showSessionServerOptionsDialog(pMainWindow_);
}

QString GwtCallback::getInitMessages()
@@ -1652,5 +1652,18 @@ int GwtCallback::getProxyPortNumber()
return pLauncher_->getProxyPortNumber();
}

void GwtCallback::signOut()
{
// set the currently connected session server as a pending reload
// this ensure that once we sign out, we can reconnect to the server
// with a completely clean state
if (pMainWindow_->getRemoteDesktopSessionLauncher() != nullptr)
{
sessionServers().setPendingSessionServerReconnect(
pMainWindow_->getRemoteDesktopSessionLauncher()->sessionServer());
pMainWindow_->getRemoteDesktopSessionLauncher()->closeOnSignOut();
}
}

} // namespace desktop
} // namespace rstudio
@@ -274,6 +274,8 @@ public Q_SLOTS:
void validateJobsConfig();
int getProxyPortNumber();

void signOut();

private:
void invokeReflowComment();
Synctex& synctex();
@@ -928,7 +928,7 @@ int main(int argc, char* argv[])

// keep the launcher object alive for the program's duration
boost::shared_ptr<void> pSessionLauncher;

bool remoteLaunch = false;
if (!launchServer)
{
// launch a local session
@@ -938,6 +938,8 @@ int main(int argc, char* argv[])
}
else
{
remoteLaunch = true;

// launch a remote session
// first, check to make sure the server is reachable/valid
Error error = launchServer->test();
@@ -1015,6 +1017,15 @@ int main(int argc, char* argv[])
continue;
}

// check to see if we had a remote launch error - if so, show the launch location dialog
if (remoteLaunch &&
boost::static_pointer_cast<RemoteDesktopSessionLauncher>(pSessionLauncher)->failedToLaunch())
{
forceSessionServerLaunch = false;
forceShowSessionLocationDialog = true;
continue;
}

return result;
}
}
@@ -28,7 +28,7 @@ DesktopSessionServers& sessionServers()

DesktopSessionServers::DesktopSessionServers() = default;

void DesktopSessionServers::showSessionServerOptionsDialog()
void DesktopSessionServers::showSessionServerOptionsDialog(QWidget* parent)
{
}

@@ -134,7 +134,7 @@ class DesktopSessionServers : public QObject
public:
DesktopSessionServers();

void showSessionServerOptionsDialog();
void showSessionServerOptionsDialog(QWidget* parent = nullptr);
LaunchLocationResult showSessionLaunchLocationDialog();

void setPendingSessionServerReconnect(const SessionServer& server);
@@ -66,5 +66,9 @@ void RemoteDesktopSessionLauncher::closeAllSatellites()
{
}

void RemoteDesktopSessionLauncher::closeOnSignOut()
{
}

} // namespace desktop
} // namespace rstudio
@@ -107,7 +107,8 @@ class RemoteDesktopSessionLauncher : public QObject
pAppLaunch_(pAppLaunch),
pMainWindow_(nullptr),
createNewSession_(createNewSession),
signingIn_(false)
signingIn_(false),
failedToLaunch_(false)
{
}

@@ -119,14 +120,19 @@ class RemoteDesktopSessionLauncher : public QObject
pMainWindow_(nullptr),
createNewSession_(false),
sessionUrl_(sessionUrl),
signingIn_(false)
signingIn_(false),
failedToLaunch_(false)
{
}

void launchFirstSession();

const SessionServer& sessionServer() const { return server_; }

bool failedToLaunch() const { return failedToLaunch_; }

void closeOnSignOut();

public Q_SLOTS:
void onCookieAdded(const QNetworkCookie& cookie);

@@ -158,7 +164,9 @@ public Q_SLOTS:
bool createNewSession_;
std::string sessionUrl_;
bool signingIn_;
bool failedToLaunch_;

std::string workspacesUrl_;
std::map<std::string, QNetworkCookie> authCookies_;
};

@@ -363,6 +363,12 @@ public void onLogoutRequested(LogoutRequestedEvent event)
// append the form to the document and submit it
DocumentEx.get().getBody().appendChild(form);
form.submit();

if (Desktop.isRemoteDesktop())
{
// let the desktop application know that we are signing out
Desktop.getFrame().signOut();
}
}

@Handler
@@ -225,4 +225,6 @@ void externalSynctexView(String pdfFile,
void getJobContainerUser();
void validateJobsConfig();
void getProxyPortNumber(CommandWithArg<Integer> callback);

void signOut();
}
@@ -25,9 +25,12 @@
import org.rstudio.core.client.dom.DomUtils;
import org.rstudio.core.client.dom.WindowEx;
import org.rstudio.core.client.js.JsObject;
import org.rstudio.core.client.resources.ImageResource2x;
import org.rstudio.core.client.theme.res.ThemeResources;
import org.rstudio.core.client.theme.res.ThemeStyles;
import org.rstudio.core.client.widget.Operation;
import org.rstudio.core.client.widget.ToolbarButton;
import org.rstudio.core.client.widget.ToolbarLabel;
import org.rstudio.studio.client.RStudioGinjector;
import org.rstudio.studio.client.application.ApplicationQuit;
import org.rstudio.studio.client.application.ApplicationQuit.QuitContext;
@@ -36,6 +39,7 @@
import org.rstudio.studio.client.application.DesktopInfo;
import org.rstudio.studio.client.application.IgnoredUpdates;
import org.rstudio.studio.client.application.events.EventBus;
import org.rstudio.studio.client.application.events.LogoutRequestedEvent;
import org.rstudio.studio.client.application.model.ApplicationServerOperations;
import org.rstudio.studio.client.application.model.UpdateCheckResult;
import org.rstudio.studio.client.application.ui.ApplicationHeader;
@@ -69,6 +73,8 @@
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
import com.google.inject.Inject;
import com.google.inject.Provider;

@@ -122,6 +128,9 @@ public void onSessionInit(SessionInitEvent sie)

isFlatTheme_ = RStudioThemes.isFlat(pUIPrefs_.get());

if (Desktop.isRemoteDesktop())
addSignoutToolbar();

overlay_.addConnectionStatusToolbar(DesktopApplicationHeader.this);

toolbar_.completeInitialization(sessionInfo);
@@ -213,6 +222,39 @@ private void fireEditEvent(final int type)
{
eventBus_.fireEvent(new EditEvent(true, type));
}

private void addSignoutToolbar()
{

if (session_.getSessionInfo().getShowIdentity() && session_.getSessionInfo().getAllowFullUI())
{
String userIdentity = session_.getSessionInfo().getUserIdentity();
ToolbarLabel usernameLabel = new ToolbarLabel();
usernameLabel.setTitle(userIdentity);
userIdentity = userIdentity.split("@")[0];
usernameLabel.setText(userIdentity);

addRightCommand(usernameLabel);

ToolbarButton signOutButton = new ToolbarButton(
ToolbarButton.NoText,
"Sign out",
new ImageResource2x(RESOURCES.signOut2x()),
event -> eventBus_.fireEvent(new LogoutRequestedEvent()));


addRightCommand(signOutButton);
addRightCommandSeparator();
}
}

interface Resources extends ClientBundle
{
@Source("signOut_2x.png")
ImageResource signOut2x();
}

private static final DesktopApplicationHeader.Resources RESOURCES = (DesktopApplicationHeader.Resources) GWT.create(DesktopApplicationHeader.Resources.class);

@Handler
void onUndoDummy()

0 comments on commit ca41511

Please sign in to comment.
You can’t perform that action at this time.