Search in sources :

Example 1 with WebClientInfo

use of org.apache.wicket.protocol.http.request.WebClientInfo in project wicket by apache.

the class DynamicJQueryResourceReference method getName.

@Override
public String getName() {
    RequestCycle requestCycle = RequestCycle.get();
    String name = requestCycle.getMetaData(KEY);
    if (name == null) {
        WebClientInfo clientInfo;
        name = getVersion2();
        if (Session.exists()) {
            WebSession session = WebSession.get();
            clientInfo = session.getClientInfo();
        } else {
            clientInfo = new WebClientInfo(requestCycle);
        }
        ClientProperties clientProperties = clientInfo.getProperties();
        if (clientProperties.isBrowserInternetExplorer() && clientProperties.getBrowserVersionMajor() < 9) {
            name = getVersion1();
        }
        requestCycle.setMetaData(KEY, name);
    }
    return name;
}
Also used : WebClientInfo(org.apache.wicket.protocol.http.request.WebClientInfo) ClientProperties(org.apache.wicket.protocol.http.ClientProperties) WebSession(org.apache.wicket.protocol.http.WebSession) RequestCycle(org.apache.wicket.request.cycle.RequestCycle)

Example 2 with WebClientInfo

use of org.apache.wicket.protocol.http.request.WebClientInfo in project wicket by apache.

the class WebSession method getClientInfo.

/**
 * {@inheritDoc}
 *
 * <p>
 * To gather the client information this implementation redirects temporarily to a special page
 * ({@link BrowserInfoPage}).
 * <p>
 * Note: Do <strong>not</strong> call this method from your custom {@link Session} constructor
 * because the temporary page needs a constructed {@link Session} to be able to work.
 * <p>
 * If you need to set a default client info property then better use
 * {@link #setClientInfo(org.apache.wicket.core.request.ClientInfo)} directly.
 */
@Override
public WebClientInfo getClientInfo() {
    if (clientInfo == null) {
        RequestCycle requestCycle = RequestCycle.get();
        clientInfo = new WebClientInfo(requestCycle);
        if (getApplication().getRequestCycleSettings().getGatherExtendedBrowserInfo()) {
            WebPage browserInfoPage = newBrowserInfoPage();
            throw new RestartResponseAtInterceptPageException(browserInfoPage);
        }
    }
    return (WebClientInfo) clientInfo;
}
Also used : WebClientInfo(org.apache.wicket.protocol.http.request.WebClientInfo) WebPage(org.apache.wicket.markup.html.WebPage) RequestCycle(org.apache.wicket.request.cycle.RequestCycle) RestartResponseAtInterceptPageException(org.apache.wicket.RestartResponseAtInterceptPageException)

Example 3 with WebClientInfo

use of org.apache.wicket.protocol.http.request.WebClientInfo in project openmeetings by apache.

the class HashPage method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    StringValue secure = p.get(HASH);
    StringValue invitation = p.get(INVITATION_HASH);
    WebSession ws = WebSession.get();
    ws.checkHashes(secure, invitation);
    String errorMsg = getString("invalid.hash");
    recContainer.setVisible(false);
    add(new EmptyPanel(PANEL_MAIN).setVisible(false));
    if (!invitation.isEmpty()) {
        Invitation i = ws.getInvitation();
        if (i == null) {
            errorMsg = getString("error.hash.invalid");
        } else if (!i.isAllowEntry()) {
            FastDateFormat sdf = FormatHelper.getDateTimeFormat(i.getInvitee());
            errorMsg = Valid.OneTime == i.getValid() ? getString("error.hash.used") : String.format("%s %s - %s, %s", getString("error.hash.period"), sdf.format(i.getValidFrom()), sdf.format(i.getValidTo()), i.getInvitee().getTimeZoneId());
        } else {
            Recording rec = i.getRecording();
            if (rec != null) {
                vi.setVisible(!i.isPasswordProtected());
                vp.setVisible(!i.isPasswordProtected());
                if (!i.isPasswordProtected()) {
                    vi.update(null, rec);
                    vp.update(null, rec);
                }
                recContainer.setVisible(true);
                error = false;
            }
            Room r = i.getRoom();
            if (r != null && !r.isDeleted()) {
                createRoom(r.getId());
                if (i.isPasswordProtected() && rp != null) {
                    mp.getChat().setVisible(false);
                    rp.setOutputMarkupPlaceholderTag(true).setVisible(false);
                }
            }
        }
    } else if (!secure.isEmpty()) {
        Long recId = getRecordingId(), roomId = ws.getRoomId();
        if (recId == null && roomId == null) {
            errorMsg = getString("1599");
        } else if (recId != null) {
            recContainer.setVisible(true);
            Recording rec = recDao.get(recId);
            vi.update(null, rec);
            vp.update(null, rec);
            error = false;
        } else {
            createRoom(roomId);
        }
    }
    StringValue swf = p.get(SWF);
    StringValue app = swf.isEmpty() ? p.get(APP) : swf;
    if (!app.isEmpty()) {
        if (APP_TYPE_NETWORK.equals(app.toString())) {
            replace(new NetTestPanel(PANEL_MAIN).add(AttributeModifier.append("class", "app")));
            error = false;
        }
        if (APP_TYPE_SETTINGS.equals(app.toString())) {
            replace(new VideoSettings(PANEL_MAIN).replace(new OmWebSocketPanel("ws-panel") {

                private static final long serialVersionUID = 1L;

                private WsClient c = null;

                @Override
                protected void onConnect(ConnectedMessage message) {
                    c = new WsClient(message.getSessionId(), message.getKey().hashCode());
                }

                @Override
                protected IWsClient getWsClient() {
                    return c;
                }
            }).add(new OmAjaxClientInfoBehavior() {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onClientInfo(AjaxRequestTarget target, WebClientInfo info) {
                    super.onClientInfo(target, info);
                    target.appendJavaScript(String.format("VideoSettings.init(%s);VideoSettings.open();", VideoSettings.getInitJson("noclient")));
                }
            }));
            error = false;
        }
    }
    add(recContainer.add(vi.setShowShare(false).setOutputMarkupPlaceholderTag(true), vp.setOutputMarkupPlaceholderTag(true)), new InvitationPasswordDialog("i-pass", this));
    remove(urlParametersReceivingBehavior);
    add(new MessageDialog("access-denied", getString("invalid.hash"), errorMsg, DialogButtons.OK, DialogIcon.ERROR) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onConfigure(JQueryBehavior behavior) {
            super.onConfigure(behavior);
            behavior.setOption("autoOpen", error);
            behavior.setOption("resizable", false);
        }

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
        // no-op
        }
    });
}
Also used : WebClientInfo(org.apache.wicket.protocol.http.request.WebClientInfo) DialogButton(com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton) EmptyPanel(org.apache.wicket.markup.html.panel.EmptyPanel) OmWebSocketPanel(org.apache.openmeetings.web.common.OmWebSocketPanel) WsClient(org.apache.openmeetings.db.entity.basic.WsClient) IWsClient(org.apache.openmeetings.db.entity.basic.IWsClient) ConnectedMessage(org.apache.wicket.protocol.ws.api.message.ConnectedMessage) MessageDialog(com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog) StringValue(org.apache.wicket.util.string.StringValue) Room(org.apache.openmeetings.db.entity.room.Room) IWsClient(org.apache.openmeetings.db.entity.basic.IWsClient) JQueryBehavior(com.googlecode.wicket.jquery.core.JQueryBehavior) VideoSettings(org.apache.openmeetings.web.room.VideoSettings) Invitation(org.apache.openmeetings.db.entity.room.Invitation) OmAjaxClientInfoBehavior(org.apache.openmeetings.web.common.OmAjaxClientInfoBehavior) IPartialPageRequestHandler(org.apache.wicket.core.request.handler.IPartialPageRequestHandler) FastDateFormat(org.apache.commons.lang3.time.FastDateFormat) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) WebSession(org.apache.openmeetings.web.app.WebSession) NetTestPanel(org.apache.openmeetings.web.room.NetTestPanel) Recording(org.apache.openmeetings.db.entity.record.Recording)

Example 4 with WebClientInfo

use of org.apache.wicket.protocol.http.request.WebClientInfo in project gitblit by gitblit.

the class RepositoryUrlPanel method createApplicationMenus.

protected Fragment createApplicationMenus(String wicketId, final UserModel user, final RepositoryModel repository, final List<RepositoryUrl> repositoryUrls) {
    final List<GitClientApplication> displayedApps = new ArrayList<GitClientApplication>();
    final String userAgent = ((WebClientInfo) GitBlitWebSession.get().getClientInfo()).getUserAgent();
    if (user.canClone(repository)) {
        for (GitClientApplication app : app().gitblit().getClientApplications()) {
            if (app.isActive && app.allowsPlatform(userAgent)) {
                displayedApps.add(app);
            }
        }
    }
    final String baseURL = WicketUtils.getGitblitURL(RequestCycle.get().getRequest());
    ListDataProvider<GitClientApplication> displayedAppsDp = new ListDataProvider<GitClientApplication>(displayedApps);
    DataView<GitClientApplication> appMenus = new DataView<GitClientApplication>("appMenus", displayedAppsDp) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(final Item<GitClientApplication> item) {
            final GitClientApplication clientApp = item.getModelObject();
            // filter the urls for the client app
            List<RepositoryUrl> urls = new ArrayList<RepositoryUrl>();
            for (RepositoryUrl repoUrl : repositoryUrls) {
                if (clientApp.minimumPermission == null || !repoUrl.hasPermission()) {
                    // no minimum permission or untracked permissions, assume it is satisfactory
                    if (clientApp.supportsTransport(repoUrl.url)) {
                        urls.add(repoUrl);
                    }
                } else if (repoUrl.permission.atLeast(clientApp.minimumPermission)) {
                    // repo url meets minimum permission requirement
                    if (clientApp.supportsTransport(repoUrl.url)) {
                        urls.add(repoUrl);
                    }
                }
            }
            if (urls.size() == 0) {
                // do not show this app menu because there are no urls
                item.add(new Label("appMenu").setVisible(false));
                return;
            }
            Fragment appMenu = new Fragment("appMenu", "appMenuFragment", this);
            appMenu.setRenderBodyOnly(true);
            item.add(appMenu);
            // menu button
            appMenu.add(new Label("applicationName", clientApp.name));
            // application icon
            Component img;
            if (StringUtils.isEmpty(clientApp.icon)) {
                img = WicketUtils.newClearPixel("applicationIcon").setVisible(false);
            } else {
                if (clientApp.icon.contains("://")) {
                    // external image
                    img = new ExternalImage("applicationIcon", clientApp.icon);
                } else {
                    // context image
                    img = WicketUtils.newImage("applicationIcon", clientApp.icon);
                }
            }
            appMenu.add(img);
            // application menu title, may be a link
            if (StringUtils.isEmpty(clientApp.productUrl)) {
                appMenu.add(new Label("applicationTitle", clientApp.toString()));
            } else {
                appMenu.add(new LinkPanel("applicationTitle", null, clientApp.toString(), clientApp.productUrl, true));
            }
            // brief application description
            if (StringUtils.isEmpty(clientApp.description)) {
                appMenu.add(new Label("applicationDescription").setVisible(false));
            } else {
                appMenu.add(new Label("applicationDescription", clientApp.description));
            }
            // brief application legal info, copyright, license, etc
            if (StringUtils.isEmpty(clientApp.legal)) {
                appMenu.add(new Label("applicationLegal").setVisible(false));
            } else {
                appMenu.add(new Label("applicationLegal", clientApp.legal));
            }
            // a nested repeater for all action items
            ListDataProvider<RepositoryUrl> urlsDp = new ListDataProvider<RepositoryUrl>(urls);
            DataView<RepositoryUrl> actionItems = new DataView<RepositoryUrl>("actionItems", urlsDp) {

                private static final long serialVersionUID = 1L;

                @Override
                public void populateItem(final Item<RepositoryUrl> repoLinkItem) {
                    RepositoryUrl repoUrl = repoLinkItem.getModelObject();
                    Fragment fragment = new Fragment("actionItem", "actionFragment", this);
                    fragment.add(createPermissionBadge("permission", repoUrl));
                    if (!StringUtils.isEmpty(clientApp.cloneUrl)) {
                        // custom registered url
                        String url = substitute(clientApp.cloneUrl, repoUrl.url, baseURL, user.username, repository.name);
                        fragment.add(new LinkPanel("content", "applicationMenuItem", getString("gb.clone") + " " + repoUrl.url, url));
                        repoLinkItem.add(fragment);
                        fragment.add(new Label("copyFunction").setVisible(false));
                    } else if (!StringUtils.isEmpty(clientApp.command)) {
                        // command-line
                        String command = substitute(clientApp.command, repoUrl.url, baseURL, user.username, repository.name);
                        Label content = new Label("content", command);
                        WicketUtils.setCssClass(content, "commandMenuItem");
                        fragment.add(content);
                        repoLinkItem.add(fragment);
                        // copy function for command
                        fragment.add(createCopyFragment(command));
                    }
                }
            };
            appMenu.add(actionItems);
        }
    };
    Fragment applicationMenus = new Fragment(wicketId, "applicationMenusFragment", this);
    applicationMenus.add(appMenus);
    return applicationMenus;
}
Also used : WebClientInfo(org.apache.wicket.protocol.http.request.WebClientInfo) ListDataProvider(org.apache.wicket.markup.repeater.data.ListDataProvider) GitClientApplication(com.gitblit.models.GitClientApplication) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) RepositoryUrl(com.gitblit.models.RepositoryUrl) Fragment(org.apache.wicket.markup.html.panel.Fragment) DataView(org.apache.wicket.markup.repeater.data.DataView) Item(org.apache.wicket.markup.repeater.Item) ExternalImage(com.gitblit.wicket.ExternalImage) Component(org.apache.wicket.Component)

Example 5 with WebClientInfo

use of org.apache.wicket.protocol.http.request.WebClientInfo in project gitblit by gitblit.

the class ObjectContainer method getClientProperties.

// shortcut to the client properties:
protected ClientProperties getClientProperties() {
    if (clientProperties == null) {
        ClientInfo clientInfo = WebSession.get().getClientInfo();
        if (clientInfo == null || !(clientInfo instanceof WebClientInfo)) {
            clientInfo = new WebClientInfo((WebRequestCycle) getRequestCycle());
            WebSession.get().setClientInfo(clientInfo);
        }
        clientProperties = ((WebClientInfo) clientInfo).getProperties();
    }
    return (clientProperties);
}
Also used : WebRequestCycle(org.apache.wicket.protocol.http.WebRequestCycle) WebClientInfo(org.apache.wicket.protocol.http.request.WebClientInfo) WebClientInfo(org.apache.wicket.protocol.http.request.WebClientInfo) ClientInfo(org.apache.wicket.request.ClientInfo)

Aggregations

WebClientInfo (org.apache.wicket.protocol.http.request.WebClientInfo)9 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)4 ClientProperties (org.apache.wicket.protocol.http.ClientProperties)3 OmAjaxClientInfoBehavior (org.apache.openmeetings.web.common.OmAjaxClientInfoBehavior)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 WebSession (org.apache.wicket.protocol.http.WebSession)2 GitClientApplication (com.gitblit.models.GitClientApplication)1 RepositoryUrl (com.gitblit.models.RepositoryUrl)1 ExternalImage (com.gitblit.wicket.ExternalImage)1 JQueryBehavior (com.googlecode.wicket.jquery.core.JQueryBehavior)1 DialogButton (com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton)1 MessageDialog (com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog)1 ArrayList (java.util.ArrayList)1 FastDateFormat (org.apache.commons.lang3.time.FastDateFormat)1 IWsClient (org.apache.openmeetings.db.entity.basic.IWsClient)1 WsClient (org.apache.openmeetings.db.entity.basic.WsClient)1 Recording (org.apache.openmeetings.db.entity.record.Recording)1 Invitation (org.apache.openmeetings.db.entity.room.Invitation)1 Room (org.apache.openmeetings.db.entity.room.Room)1 WebSession (org.apache.openmeetings.web.app.WebSession)1