You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2011/09/28 20:37:45 UTC
svn commit: r1177005 - in
/myfaces/trinidad/branches/jwaldman-offline-mode-branch:
trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/
trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/
trinidad-impl/src/main/java/org/ap...
Author: jwaldman
Date: Wed Sep 28 18:37:44 2011
New Revision: 1177005
URL: http://svn.apache.org/viewvc?rev=1177005&view=rev
Log:
TRINIDAD-2141 add a new 'browser-generic' agent
The agent's name is genericDesktop. It represents the lowest common denominator agent for all browsers
thanks to Pavitra Subramaniam for the patch
Added:
myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/resources/META-INF/agent/genericDesktop.xml
Modified:
myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/Agent.java
myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java
myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentNameUtil.java
myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/TrinidadAgent.java
myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java
myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/resources/META-INF/agent/capabilities.xml
Modified: myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/Agent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/Agent.java?rev=1177005&r1=1177004&r2=1177005&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/Agent.java (original)
+++ myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/Agent.java Wed Sep 28 18:37:44 2011
@@ -160,6 +160,11 @@ public interface Agent
public static final String AGENT_UNKNOWN = "unknown";
/**
+ * Constant for a generic desktop agent that is unknown but relatively powerful
+ */
+ public static final String AGENT_GENERIC_DESKTOP = "genericDesktop";
+
+ /**
* Constant for Konqueror agent
*/
public static final String AGENT_KONQUEROR = "konqueror";
Modified: myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java?rev=1177005&r1=1177004&r2=1177005&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java (original)
+++ myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java Wed Sep 28 18:37:44 2011
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -244,6 +245,14 @@ abstract public class RequestContext
*/
public abstract String getOutputMode();
+ /**
+ * Returns the OutputMode enumeration
+ * @return OutputMode
+ */
+ public OutputMode getOutputModeEnum()
+ {
+ return OutputMode.fromId(getOutputMode());
+ }
/**
* Returns the name of the preferred skin family.
@@ -319,6 +328,70 @@ abstract public class RequestContext
};
/**
+ * Enumeration representing OutputModes
+ */
+ public enum OutputMode
+ {
+ DEFAULT("default"), PORTLET("portlet"), PRINTABLE("printable"), EMAIL("email"),
+ OFFLINE("offline"), WEB_CRAWLER("webcrawler");
+
+ private OutputMode(String id)
+ {
+ if (id == null) throw new NullPointerException();
+
+ _id = id;
+ }
+
+ /**
+ * @return the id of this OutputMode.
+ */
+ public String id()
+ {
+ return _id;
+ }
+
+ @Override
+ public String toString()
+ {
+ return _id;
+ }
+
+ /**
+ * Returns the OutputMode isntance of <code>null</code> if no id matches.
+ * @param id of OutputMode to return
+ * @return The OutputMode with the specified id
+ * @throws NullPointerException if <code>id</code> is null.
+ * @throws IllegalArgumentException if there is no enum with the specified name.
+ */
+ public static OutputMode fromId(String id)
+ {
+ if (id == null)
+ throw new NullPointerException();
+
+ OutputMode outputMode = ID_TO_OUTPUT_MODE.get(id);
+
+ if (outputMode == null)
+ throw new IllegalArgumentException();
+
+ return outputMode;
+ }
+
+ private static final Map<String, OutputMode> ID_TO_OUTPUT_MODE = new HashMap<String, OutputMode>();
+
+ static
+ {
+ OutputMode[] instances = OutputMode.class.getEnumConstants();
+
+ for (int i = 0; i < instances.length; i++)
+ {
+ ID_TO_OUTPUT_MODE.put(instances[i].toString(), instances[i]);
+ }
+ }
+
+ private final String _id;
+ }
+
+ /**
* Returns the name of the current accessibility mode.
*/
public abstract Accessibility getAccessibilityMode();
Modified: myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java?rev=1177005&r1=1177004&r2=1177005&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java (original)
+++ myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java Wed Sep 28 18:37:44 2011
@@ -24,6 +24,7 @@ import java.util.Map;
import javax.faces.context.FacesContext;
import org.apache.myfaces.trinidad.context.Agent;
+import org.apache.myfaces.trinidad.context.RequestContext;
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlConstants;
@@ -77,9 +78,14 @@ public class AgentFactoryImpl implements
String userAgent = headerMap.get("User-Agent");
String isEmail = null;
+ String outputMode = null;
+
if (facesContext != null)
- isEmail = facesContext.getExternalContext().getRequestParameterMap().
- get(_EMAIL_PARAM);
+ {
+ Map<String, String> requestParamMap = facesContext.getExternalContext().getRequestParameterMap();
+ isEmail = requestParamMap.get(_EMAIL_PARAM);
+ outputMode = requestParamMap.get(_OUTPUTMODE_PARAM);
+ }
if ("true".equals(isEmail))
{
@@ -87,6 +93,15 @@ public class AgentFactoryImpl implements
return;
}
+ RequestContext reqContext = RequestContext.getCurrentInstance();
+ if ((reqContext != null &&
+ RequestContext.OutputMode.OFFLINE.id().equals(reqContext.getOutputMode())) ||
+ RequestContext.OutputMode.OFFLINE.id().equals(outputMode))
+ {
+ _populateGenericDesktopAgentImpl(agent);
+ return;
+ }
+
if ((userAgent != null) && userAgent.startsWith("PTG"))
{
_populateIaswAgentImpl(userAgent,
@@ -664,6 +679,22 @@ public class AgentFactoryImpl implements
agentObj.setType(Agent.TYPE_PHONE);
}
+ /**
+ * Returns an AgentEntry for a generic desktop agent
+ */
+ private void _populateGenericDesktopAgentImpl(AgentImpl agent)
+ {
+ // Generic Desktop agent
+ agent.setType(Agent.TYPE_DESKTOP);
+
+ agent.setAgent(Agent.AGENT_GENERIC_DESKTOP);
+ agent.setAgentVersion("0.0"); // we don't know the version
+ agent.setPlatform(Agent.PLATFORM_UNKNOWN);
+ agent.setPlatformVersion(Agent.PLATFORM_VERSION_UNKNOWN);
+ agent.setMakeModel(Agent.MAKE_MODEL_UNKNOWN);
+ }
+
+
/**
* Returns an AgentEntry for the browsers that use the Gecko Layout Engine.
*/
@@ -1078,6 +1109,8 @@ public class AgentFactoryImpl implements
}
static private final String _EMAIL_PARAM =
"org.apache.myfaces.trinidad.agent.email";
+ static private final String _OUTPUTMODE_PARAM =
+ "org.apache.myfaces.trinidad.outputMode";
static final private String _IASW_DEVICE_HINT_PARAM = "X-Oracle-Device.Class";
static final private TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(AgentFactoryImpl.class);
Modified: myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentNameUtil.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentNameUtil.java?rev=1177005&r1=1177004&r2=1177005&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentNameUtil.java (original)
+++ myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentNameUtil.java Wed Sep 28 18:37:44 2011
@@ -51,6 +51,11 @@ public class AgentNameUtil
return TrinidadAgent.APPLICATION_GECKO;
}
+ if (TrinidadAgent.AGENT_GENERIC_DESKTOP.equals(agentName))
+ {
+ return TrinidadAgent.APPLICATION_GENERIC_DESKTOP;
+ }
+
if (TrinidadAgent.AGENT_EMAIL.equals(agentName))
{
return TrinidadAgent.APPLICATION_EMAIL;
@@ -228,6 +233,8 @@ public class AgentNameUtil
return TrinidadAgent.AGENT_IE;
case TrinidadAgent.APPLICATION_GECKO:
return TrinidadAgent.AGENT_GECKO;
+ case TrinidadAgent.APPLICATION_GENERIC_DESKTOP:
+ return TrinidadAgent.AGENT_GENERIC_DESKTOP;
case TrinidadAgent.APPLICATION_WEB_CLIPPING:
return TrinidadAgent.AGENT_ELAINE;
case TrinidadAgent.APPLICATION_ICE:
Modified: myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/TrinidadAgent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/TrinidadAgent.java?rev=1177005&r1=1177004&r2=1177005&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/TrinidadAgent.java (original)
+++ myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/TrinidadAgent.java Wed Sep 28 18:37:44 2011
@@ -285,8 +285,6 @@ public interface TrinidadAgent extends A
*/
static public final int TYPE_WEBCRAWLER = 4;
-
-
/**
* Application constant for an entirely unknown application.
*/
@@ -400,6 +398,11 @@ public interface TrinidadAgent extends A
static public final int APPLICATION_ORACLE_SES = 19;
/**
+ * Application constant for a generic desktop application.
+ */
+ static public final int APPLICATION_GENERIC_DESKTOP = 20;
+
+ /**
* OS constant for an unknown operating system.
*/
static public final int OS_UNKNOWN = 0;
Modified: myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java?rev=1177005&r1=1177004&r2=1177005&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java (original)
+++ myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java Wed Sep 28 18:37:44 2011
@@ -59,7 +59,9 @@ public class NameUtils
int browser = TrinidadAgent.APPLICATION_UNKNOWN;
- if (_BROWSER_NETSCAPE.equals(browserName))
+ if (_BROWSER_GENERIC_DESKTOP.equals(browserName))
+ browser = TrinidadAgent.APPLICATION_GENERIC_DESKTOP;
+ else if (_BROWSER_NETSCAPE.equals(browserName))
browser = TrinidadAgent.APPLICATION_NETSCAPE;
else if (_BROWSER_IE.equals(browserName))
browser = TrinidadAgent.APPLICATION_IEXPLORER;
@@ -123,6 +125,9 @@ public class NameUtils
case TrinidadAgent.APPLICATION_EMAIL:
name = _BROWSER_EMAIL;
break;
+ case TrinidadAgent.APPLICATION_GENERIC_DESKTOP:
+ name = _BROWSER_GENERIC_DESKTOP;
+ break;
case TrinidadAgent.APPLICATION_UNKNOWN:
// This case is only here to avoid the default assertion
break;
@@ -761,6 +766,8 @@ public class NameUtils
private static final String _DIRECTION_LTR = "ltr";
// Browser constants
+ private static final String _BROWSER_GENERIC_DESKTOP = "genericDesktop";
+
private static final String _BROWSER_NETSCAPE = "netscape";
private static final String _BROWSER_IE = "ie";
Modified: myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/resources/META-INF/agent/capabilities.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/resources/META-INF/agent/capabilities.xml?rev=1177005&r1=1177004&r2=1177005&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/resources/META-INF/agent/capabilities.xml (original)
+++ myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/resources/META-INF/agent/capabilities.xml Wed Sep 28 18:37:44 2011
@@ -30,6 +30,11 @@
<include src="html.xml"/>
</capabilities>
+ <capabilities id="genericDesktop" default="true" >
+ <include refid="html"/>
+ <include src="genericDesktop.xml"/>
+ </capabilities>
+
<capabilities id="pda" platforms="palm">
<include refid="htmlBasic"/>
<include src ="pdaHtml.xml"/>
Added: myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/resources/META-INF/agent/genericDesktop.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/resources/META-INF/agent/genericDesktop.xml?rev=1177005&view=auto
==============================================================================
--- myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/resources/META-INF/agent/genericDesktop.xml (added)
+++ myfaces/trinidad/branches/jwaldman-offline-mode-branch/trinidad-impl/src/main/resources/META-INF/agent/genericDesktop.xml Wed Sep 28 18:37:44 2011
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<capabilityData xmlns="http://myfaces.apache.org/trinidad/agent/capabilities">
+ <capability name="accessKeys" value="false"/>
+ <capability name="-adfinternal-altRendersTooltipOnImage" value="true"/>
+ <capability name="-adfinternal-cssSelectors" value="multiple"/>
+ <capability name="-adfinternal-imageStretch" value="true"/>
+ <capability name="-adfinternal-pngImage" value="true"/>
+ <capability name="-adfinternal-transparentPngImage" value="true"/>
+ <capability name="partialRendering" value="false"/>
+</capabilityData>