diff --git a/AndroidManifest.xml b/AndroidManifest.xml index f0c07268..110d2fed 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -7,6 +7,7 @@ + currentTag = new Stack(); + + while (eventType != XmlPullParser.END_DOCUMENT) + { + if (eventType == XmlPullParser.START_TAG) { + currentTag.push(xpp.getName()); + for (int i = 0; i < xpp.getAttributeCount(); i++) + { + if (xpp.getAttributeName(i).equals(attribute)) + return xpp.getAttributeValue(i); + } + } else if (eventType == XmlPullParser.END_TAG) { + currentTag.pop(); + } else if (eventType == XmlPullParser.TEXT) { + if (currentTag.peek().equals(attribute)) { + return xpp.getText(); + } + } + eventType = xpp.next(); + } + + return null; + } + + private InputStream openHttpConnection(String url) throws IOException + { + return new URL(url).openConnection().getInputStream(); + } + + public String getAppVersion() throws XmlPullParserException, IOException + { + InputStream in = openHttpConnection("http://"+host+":"+PORT+"/appversion"); + return getXmlString(in, "appversion"); + } + + public boolean getPairState() throws IOException, XmlPullParserException + { + InputStream in = openHttpConnection("http://"+host+":"+PORT+"/pairstate?mac="+macAddress); + String paired = getXmlString(in, "paired"); + return Integer.valueOf(paired) != 0; + } + + public int getSessionId() throws IOException, XmlPullParserException + { + InputStream in = openHttpConnection("http://"+host+":"+PORT+"/pair?mac="+macAddress+"&devicename=ANDROID"); + String sessionId = getXmlString(in, "sessionid"); + return Integer.valueOf(sessionId); + } + + public int getSteamAppId(int sessionId) throws IOException, XmlPullParserException + { + InputStream in = openHttpConnection("http://"+host+":"+PORT+"/applist?session="+sessionId); + String appId = getXmlString(in, "ID"); + return Integer.valueOf(appId); + } + + // Returns gameSession XML attribute + public int launchApp(int sessionId, int appId) throws IOException, XmlPullParserException + { + InputStream in = openHttpConnection("http://"+host+":"+PORT+"/launch?session="+sessionId+"&appid="+appId); + String gameSession = getXmlString(in, "gamesession"); + return Integer.valueOf(gameSession); + } +}