Browse files

Added new projects and modified the old one.

  • Loading branch information...
1 parent 5eea65c commit de5b054e9c0c6f3915600155616de438b359e0ae @rakeshcusat committed Jul 13, 2012
Showing with 539 additions and 3 deletions.
  1. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/.classpath
  2. +1 −1 AndroidProjects/{GCMExample → GCMAndroidExample}/.project
  3. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/AndroidManifest.xml
  4. +6 −2 AndroidProjects/{GCMExample → GCMAndroidExample}/bin/AndroidManifest.xml
  5. +3 −0 AndroidProjects/GCMAndroidExample/bin/jarlist.cache
  6. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/gen/com/rakesh/gcmexample/BuildConfig.java
  7. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/gen/com/rakesh/gcmexample/Manifest.java
  8. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/gen/com/rakesh/gcmexample/R.java
  9. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/ic_launcher-web.png
  10. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/libs/android-support-v4.jar
  11. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/libs/gcm.jar
  12. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/proguard-project.txt
  13. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/project.properties
  14. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/drawable-hdpi/ic_action_search.png
  15. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/drawable-hdpi/ic_launcher.png
  16. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/drawable-ldpi/ic_launcher.png
  17. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/drawable-mdpi/ic_action_search.png
  18. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/drawable-mdpi/ic_launcher.png
  19. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/drawable-xhdpi/ic_action_search.png
  20. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/drawable-xhdpi/ic_launcher.png
  21. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/layout/activity_gcmmain.xml
  22. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/menu/activity_gcmmain.xml
  23. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/values-large/dimens.xml
  24. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/values-v11/styles.xml
  25. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/values-v14/styles.xml
  26. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/values/dimens.xml
  27. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/values/strings.xml
  28. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/res/values/styles.xml
  29. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/src/com/rakesh/gcmexample/GCMIntentService.java
  30. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/src/com/rakesh/gcmexample/GCMMainActivity.java
  31. 0 AndroidProjects/{GCMExample → GCMAndroidExample}/src/com/rakesh/gcmexample/Utility.java
  32. +8 −0 AndroidProjects/GCMAppEngineExample/.classpath
  33. +44 −0 AndroidProjects/GCMAppEngineExample/.project
  34. +9 −0 AndroidProjects/GCMAppEngineExample/.settings/com.google.appengine.eclipse.core.prefs
  35. +4 −0 AndroidProjects/GCMAppEngineExample/.settings/com.google.gdt.eclipse.core.prefs
  36. +8 −0 AndroidProjects/GCMAppEngineExample/.settings/org.eclipse.jdt.core.prefs
  37. +4 −0 AndroidProjects/GCMAppEngineExample/.settings/org.eclipse.wst.common.project.facet.core.xml
  38. +15 −0 AndroidProjects/GCMAppEngineExample/src/META-INF/jdoconfig.xml
  39. +15 −0 AndroidProjects/GCMAppEngineExample/src/META-INF/persistence.xml
  40. +26 −0 AndroidProjects/GCMAppEngineExample/src/guestbook/EntityFactory.java
  41. +41 −0 AndroidProjects/GCMAppEngineExample/src/guestbook/GCMExampleServlet.java
  42. +25 −0 AndroidProjects/GCMAppEngineExample/src/guestbook/GuestbookServlet.java
  43. +56 −0 AndroidProjects/GCMAppEngineExample/src/guestbook/SignGuestbookServlet.java
  44. +24 −0 AndroidProjects/GCMAppEngineExample/src/log4j.properties
  45. +10 −0 AndroidProjects/GCMAppEngineExample/war/WEB-INF/appengine-generated/datastore-indexes-auto.xml
  46. BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/appengine-generated/local_db.bin
  47. +11 −0 AndroidProjects/GCMAppEngineExample/war/WEB-INF/appengine-web.xml
  48. +15 −0 AndroidProjects/GCMAppEngineExample/war/WEB-INF/classes/META-INF/jdoconfig.xml
  49. +15 −0 AndroidProjects/GCMAppEngineExample/war/WEB-INF/classes/META-INF/persistence.xml
  50. +24 −0 AndroidProjects/GCMAppEngineExample/war/WEB-INF/classes/log4j.properties
  51. BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/appengine-api-1.0-sdk-1.7.0.jar
  52. BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/appengine-api-labs.jar
  53. BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/appengine-endpoints.jar
  54. BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/appengine-jsr107cache-1.7.0.jar
  55. BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/datanucleus-appengine-1.0.10.final.jar
  56. BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/datanucleus-core-1.1.5.jar
  57. BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/datanucleus-jpa-1.1.5.jar
  58. BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/geronimo-jpa_3.0_spec-1.1.1.jar
  59. BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/geronimo-jta_1.1_spec-1.1.1.jar
  60. BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/gson-2.2.2.jar
  61. BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/jdo2-api-2.3-eb.jar
  62. BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/jsr107cache-1.1.jar
  63. +14 −0 AndroidProjects/GCMAppEngineExample/war/WEB-INF/logging.properties
  64. +42 −0 AndroidProjects/GCMAppEngineExample/war/WEB-INF/web.xml
  65. BIN AndroidProjects/GCMAppEngineExample/war/favicon.ico
  66. +88 −0 AndroidProjects/GCMAppEngineExample/war/guestbook.jsp
  67. +27 −0 AndroidProjects/GCMAppEngineExample/war/index.html
  68. +4 −0 AndroidProjects/GCMAppEngineExample/war/stylesheets/main.css
  69. BIN AndroidProjects/WidgetAlarmManagerExample/bin/WidgetAlarmManagerExample.apk
  70. BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-hdpi/ic_action_search.png
  71. BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-hdpi/ic_launcher.png
  72. BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-ldpi/ic_launcher.png
  73. BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-mdpi/ic_action_search.png
  74. BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-mdpi/ic_launcher.png
  75. BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-xhdpi/ic_action_search.png
  76. BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-xhdpi/ic_launcher.png
View
0 AndroidProjects/GCMExample/.classpath → AndroidProjects/GCMAndroidExample/.classpath
File renamed without changes.
View
2 AndroidProjects/GCMExample/.project → AndroidProjects/GCMAndroidExample/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>GCMExample</name>
+ <name>GCMAndroidExample</name>
<comment></comment>
<projects>
</projects>
View
0 ...idProjects/GCMExample/AndroidManifest.xml → ...cts/GCMAndroidExample/AndroidManifest.xml
File renamed without changes.
View
8 ...ojects/GCMExample/bin/AndroidManifest.xml → ...GCMAndroidExample/bin/AndroidManifest.xml
@@ -5,15 +5,19 @@
<uses-sdk
android:minSdkVersion="8"
- android:targetSdkVersion="xx" />
+ android:targetSdkVersion="16" />
<!-- Permissions -->
<permission
android:name="com.rakesh.gcmexample.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.rakesh.gcmexample.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
-
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
+ <uses-permission android:name="android.permission.INTERNET" />
+ <!-- GCM requires a Google account. -->
+ <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
View
3 AndroidProjects/GCMAndroidExample/bin/jarlist.cache
@@ -0,0 +1,3 @@
+# cache for current jar dependecy. DO NOT EDIT.
+# format is <lastModified> <length> <SHA-1> <path>
+# Encoding is UTF-8
View
0 ...en/com/rakesh/gcmexample/BuildConfig.java → ...en/com/rakesh/gcmexample/BuildConfig.java
File renamed without changes.
View
0 ...e/gen/com/rakesh/gcmexample/Manifest.java → ...e/gen/com/rakesh/gcmexample/Manifest.java
File renamed without changes.
View
0 ...MExample/gen/com/rakesh/gcmexample/R.java → ...dExample/gen/com/rakesh/gcmexample/R.java
File renamed without changes.
View
0 ...idProjects/GCMExample/ic_launcher-web.png → ...cts/GCMAndroidExample/ic_launcher-web.png
File renamed without changes
View
0 ...ts/GCMExample/libs/android-support-v4.jar → ...ndroidExample/libs/android-support-v4.jar
File renamed without changes.
View
0 AndroidProjects/GCMExample/libs/gcm.jar → ...idProjects/GCMAndroidExample/libs/gcm.jar
File renamed without changes.
View
0 ...dProjects/GCMExample/proguard-project.txt → ...ts/GCMAndroidExample/proguard-project.txt
File renamed without changes.
View
0 ...oidProjects/GCMExample/project.properties → ...ects/GCMAndroidExample/project.properties
File renamed without changes.
View
0 ...le/res/drawable-hdpi/ic_action_search.png → ...le/res/drawable-hdpi/ic_action_search.png
File renamed without changes
View
0 ...Example/res/drawable-hdpi/ic_launcher.png → ...Example/res/drawable-hdpi/ic_launcher.png
File renamed without changes
View
0 ...Example/res/drawable-ldpi/ic_launcher.png → ...Example/res/drawable-ldpi/ic_launcher.png
File renamed without changes
View
0 ...le/res/drawable-mdpi/ic_action_search.png → ...le/res/drawable-mdpi/ic_action_search.png
File renamed without changes
View
0 ...Example/res/drawable-mdpi/ic_launcher.png → ...Example/res/drawable-mdpi/ic_launcher.png
File renamed without changes
View
0 ...e/res/drawable-xhdpi/ic_action_search.png → ...e/res/drawable-xhdpi/ic_action_search.png
File renamed without changes
View
0 ...xample/res/drawable-xhdpi/ic_launcher.png → ...xample/res/drawable-xhdpi/ic_launcher.png
File renamed without changes
View
0 ...CMExample/res/layout/activity_gcmmain.xml → ...idExample/res/layout/activity_gcmmain.xml
File renamed without changes.
View
0 .../GCMExample/res/menu/activity_gcmmain.xml → ...roidExample/res/menu/activity_gcmmain.xml
File renamed without changes.
View
0 ...ts/GCMExample/res/values-large/dimens.xml → ...ndroidExample/res/values-large/dimens.xml
File renamed without changes.
View
0 ...ects/GCMExample/res/values-v11/styles.xml → ...MAndroidExample/res/values-v11/styles.xml
File renamed without changes.
View
0 ...ects/GCMExample/res/values-v14/styles.xml → ...MAndroidExample/res/values-v14/styles.xml
File renamed without changes.
View
0 ...Projects/GCMExample/res/values/dimens.xml → ...s/GCMAndroidExample/res/values/dimens.xml
File renamed without changes.
View
0 ...rojects/GCMExample/res/values/strings.xml → .../GCMAndroidExample/res/values/strings.xml
File renamed without changes.
View
0 ...Projects/GCMExample/res/values/styles.xml → ...s/GCMAndroidExample/res/values/styles.xml
File renamed without changes.
View
0 ...m/rakesh/gcmexample/GCMIntentService.java → ...m/rakesh/gcmexample/GCMIntentService.java
File renamed without changes.
View
0 ...om/rakesh/gcmexample/GCMMainActivity.java → ...om/rakesh/gcmexample/GCMMainActivity.java
File renamed without changes.
View
0 ...le/src/com/rakesh/gcmexample/Utility.java → ...le/src/com/rakesh/gcmexample/Utility.java
File renamed without changes.
View
8 AndroidProjects/GCMAppEngineExample/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry exported="true" kind="con" path="com.google.appengine.eclipse.core.GAE_CONTAINER"/>
+ <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="war/WEB-INF/lib/gson-2.2.2.jar"/>
+ <classpathentry kind="output" path="war/WEB-INF/classes"/>
+</classpath>
View
44 AndroidProjects/GCMAppEngineExample/.project
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>GCMAppEngineExample</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.google.appengine.eclipse.core.gaeProjectChangeNotifier</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.google.appengine.eclipse.core.projectValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.google.appengine.eclipse.core.enhancerbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>com.google.appengine.eclipse.core.gaeNature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
View
9 AndroidProjects/GCMAppEngineExample/.settings/com.google.appengine.eclipse.core.prefs
@@ -0,0 +1,9 @@
+#Wed Jul 11 23:43:31 PDT 2012
+eclipse.preferences.version=1
+filesCopiedToWebInfLib=appengine-api-labs.jar|appengine-endpoints.jar|appengine-jsr107cache-1.7.0.jar|jsr107cache-1.1.jar|appengine-api-1.0-sdk-1.7.0.jar|geronimo-jpa_3.0_spec-1.1.1.jar|datanucleus-appengine-1.0.10.final.jar|geronimo-jta_1.1_spec-1.1.1.jar|datanucleus-core-1.1.5.jar|jdo2-api-2.3-eb.jar|datanucleus-jpa-1.1.5.jar
+gaeDatanucleusVersion=v1
+gaeDeployDialogSettings=
+gaeHrdEnabled=true
+gaeIsEclipseDefaultInstPath=true
+googleCloudSqlEnabled=false
+localDevMySqlEnabled=true
View
4 AndroidProjects/GCMAppEngineExample/.settings/com.google.gdt.eclipse.core.prefs
@@ -0,0 +1,4 @@
+#Wed Jul 11 21:35:19 PDT 2012
+eclipse.preferences.version=1
+warSrcDir=war
+warSrcDirIsOutput=true
View
8 AndroidProjects/GCMAppEngineExample/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Wed Jul 11 21:35:23 PDT 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
View
4 AndroidProjects/GCMAppEngineExample/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.6"/>
+</faceted-project>
View
15 AndroidProjects/GCMAppEngineExample/src/META-INF/jdoconfig.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
+
+ <persistence-manager-factory name="transactions-optional">
+ <property name="javax.jdo.PersistenceManagerFactoryClass"
+ value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/>
+ <property name="javax.jdo.option.ConnectionURL" value="appengine"/>
+ <property name="javax.jdo.option.NontransactionalRead" value="true"/>
+ <property name="javax.jdo.option.NontransactionalWrite" value="true"/>
+ <property name="javax.jdo.option.RetainValues" value="true"/>
+ <property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
+ </persistence-manager-factory>
+</jdoconfig>
View
15 AndroidProjects/GCMAppEngineExample/src/META-INF/persistence.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
+
+ <persistence-unit name="transactions-optional">
+ <provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</provider>
+ <properties>
+ <property name="datanucleus.NontransactionalRead" value="true"/>
+ <property name="datanucleus.NontransactionalWrite" value="true"/>
+ <property name="datanucleus.ConnectionURL" value="appengine"/>
+ </properties>
+ </persistence-unit>
+</persistence>
View
26 AndroidProjects/GCMAppEngineExample/src/guestbook/EntityFactory.java
@@ -0,0 +1,26 @@
+package guestbook;
+
+import java.util.Date;
+
+import com.google.appengine.api.datastore.Entity;
+
+public class EntityFactory {
+
+ static Entity createUserInfoEntity(String appId, String emailId, String phoneNo, String userId){
+ Entity userInfo = new Entity("UserInfo");
+ userInfo.setProperty("userId", userId);
+ userInfo.setProperty("appId", appId);
+ userInfo.setProperty("emailId", emailId);;
+ userInfo.setProperty("phoneNo", phoneNo);
+ return userInfo;
+ }
+ static Entity createMessageEntity(String fromAppId, String toEmailId, String subject, String message){
+ Entity messageEntity = new Entity("MessageEntity");
+ messageEntity.setProperty("fromAppId", fromAppId);
+ messageEntity.setProperty("toEmailId", toEmailId);
+ messageEntity.setProperty("subject", subject);
+ messageEntity.setProperty("message", message);
+ messageEntity.setProperty("date", new Date());
+ return messageEntity;
+ }
+}
View
41 AndroidProjects/GCMAppEngineExample/src/guestbook/GCMExampleServlet.java
@@ -0,0 +1,41 @@
+package guestbook;
+
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.google.appengine.api.datastore.DatastoreServiceFactory;
+
+@SuppressWarnings("serial")
+public class GCMExampleServlet extends HttpServlet {
+
+ private static final Logger log =
+ Logger.getLogger(GCMExampleServlet.class.getName());
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ String appId = req.getParameter("appId");
+ String emailId = req.getParameter("emailId");
+ String phoneNo = req.getParameter("phoneNo");
+ String userId = req.getParameter("userId");
+
+ log.info("appId :" +appId+", emailId : "+emailId + ", phoneNo : "+phoneNo+", userId : "+userId);
+
+ DatastoreServiceFactory.getDatastoreService().put(EntityFactory.createUserInfoEntity(appId, emailId, phoneNo, userId));
+ resp.setContentType("text/plain");
+ resp.getWriter().println("saved the user data");
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ // TODO Auto-generated method stub
+ super.doPost(req, resp);
+ }
+
+}
View
25 AndroidProjects/GCMAppEngineExample/src/guestbook/GuestbookServlet.java
@@ -0,0 +1,25 @@
+package guestbook;
+
+import java.io.IOException;
+import javax.servlet.http.*;
+
+import com.google.appengine.api.users.User;
+import com.google.appengine.api.users.UserService;
+import com.google.appengine.api.users.UserServiceFactory;
+
+@SuppressWarnings("serial")
+public class GuestbookServlet extends HttpServlet {
+ public void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws IOException {
+
+ UserService userService = UserServiceFactory.getUserService();
+ User user = userService.getCurrentUser();
+ if(user != null){
+ resp.setContentType("text/plain");
+ resp.getWriter().println("Hello, " + user.getNickname());
+ }
+ else{
+ resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
+ }
+ }
+}
View
56 AndroidProjects/GCMAppEngineExample/src/guestbook/SignGuestbookServlet.java
@@ -0,0 +1,56 @@
+package guestbook;
+
+import com.google.appengine.api.datastore.DatastoreService;
+import com.google.appengine.api.datastore.DatastoreServiceFactory;
+import com.google.appengine.api.datastore.Entity;
+import com.google.appengine.api.datastore.Key;
+import com.google.appengine.api.datastore.KeyFactory;
+import com.google.appengine.api.users.User;
+import com.google.appengine.api.users.UserService;
+import com.google.appengine.api.users.UserServiceFactory;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.logging.Logger;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class SignGuestbookServlet extends HttpServlet {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger log =
+ Logger.getLogger(SignGuestbookServlet.class.getName());
+
+ public void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws IOException {
+ UserService userService = UserServiceFactory.getUserService();
+ User user = userService.getCurrentUser();
+
+ // We have one entity group per Guestbook with all Greetings residing
+ // in the same entity group as the Guestbook to which they belong.
+ // This lets us run an ancestor query to retrieve all Greetings for a
+ // given Guestbook. However, the write rate to each Guestbook should be
+ // limited to ~1/second.
+ String guestbookName = req.getParameter("guestbookName");
+ Key guestbookKey = KeyFactory.createKey("Guestbook", guestbookName);
+ String content = req.getParameter("content");
+ Date date = new Date();
+ Entity greeting = new Entity("Greeting", guestbookKey);
+ greeting.setProperty("user", user);
+ greeting.setProperty("date", date);
+ greeting.setProperty("content", content);
+
+ DatastoreService datastore =
+ DatastoreServiceFactory.getDatastoreService();
+ datastore.put(greeting);
+
+ resp.sendRedirect("/guestbook.jsp?guestbookName="
+ + guestbookName);
+ }
+}
View
24 AndroidProjects/GCMAppEngineExample/src/log4j.properties
@@ -0,0 +1,24 @@
+# A default log4j configuration for log4j users.
+#
+# To use this configuration, deploy it into your application's WEB-INF/classes
+# directory. You are also encouraged to edit it as you like.
+
+# Configure the console as our one appender
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n
+
+# tighten logging on the DataNucleus Categories
+log4j.category.DataNucleus.JDO=WARN, A1
+log4j.category.DataNucleus.Persistence=WARN, A1
+log4j.category.DataNucleus.Cache=WARN, A1
+log4j.category.DataNucleus.MetaData=WARN, A1
+log4j.category.DataNucleus.General=WARN, A1
+log4j.category.DataNucleus.Utility=WARN, A1
+log4j.category.DataNucleus.Transaction=WARN, A1
+log4j.category.DataNucleus.Datastore=WARN, A1
+log4j.category.DataNucleus.ClassLoading=WARN, A1
+log4j.category.DataNucleus.Plugin=WARN, A1
+log4j.category.DataNucleus.ValueGeneration=WARN, A1
+log4j.category.DataNucleus.Enhancer=WARN, A1
+log4j.category.DataNucleus.SchemaTool=WARN, A1
View
10 ...idProjects/GCMAppEngineExample/war/WEB-INF/appengine-generated/datastore-indexes-auto.xml
@@ -0,0 +1,10 @@
+<!-- Indices written at Wed, 11 Jul 2012 23:31:54 PDT -->
+
+<datastore-indexes>
+
+ <!-- Used 1 time in query history -->
+ <datastore-index kind="Greeting" ancestor="true" source="auto">
+ <property name="date" direction="desc"/>
+ </datastore-index>
+
+</datastore-indexes>
View
BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/appengine-generated/local_db.bin
Binary file not shown.
View
11 AndroidProjects/GCMAppEngineExample/war/WEB-INF/appengine-web.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
+ <application>rakeshcusat</application>
+ <version>1</version>
+ <threadsafe>true</threadsafe>
+ <system-properties>
+ <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
+ </system-properties>
+ <sessions-enabled>true</sessions-enabled>
+ <async-session-persistence enabled="true" />
+</appengine-web-app>
View
15 AndroidProjects/GCMAppEngineExample/war/WEB-INF/classes/META-INF/jdoconfig.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
+
+ <persistence-manager-factory name="transactions-optional">
+ <property name="javax.jdo.PersistenceManagerFactoryClass"
+ value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/>
+ <property name="javax.jdo.option.ConnectionURL" value="appengine"/>
+ <property name="javax.jdo.option.NontransactionalRead" value="true"/>
+ <property name="javax.jdo.option.NontransactionalWrite" value="true"/>
+ <property name="javax.jdo.option.RetainValues" value="true"/>
+ <property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
+ </persistence-manager-factory>
+</jdoconfig>
View
15 AndroidProjects/GCMAppEngineExample/war/WEB-INF/classes/META-INF/persistence.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
+
+ <persistence-unit name="transactions-optional">
+ <provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</provider>
+ <properties>
+ <property name="datanucleus.NontransactionalRead" value="true"/>
+ <property name="datanucleus.NontransactionalWrite" value="true"/>
+ <property name="datanucleus.ConnectionURL" value="appengine"/>
+ </properties>
+ </persistence-unit>
+</persistence>
View
24 AndroidProjects/GCMAppEngineExample/war/WEB-INF/classes/log4j.properties
@@ -0,0 +1,24 @@
+# A default log4j configuration for log4j users.
+#
+# To use this configuration, deploy it into your application's WEB-INF/classes
+# directory. You are also encouraged to edit it as you like.
+
+# Configure the console as our one appender
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n
+
+# tighten logging on the DataNucleus Categories
+log4j.category.DataNucleus.JDO=WARN, A1
+log4j.category.DataNucleus.Persistence=WARN, A1
+log4j.category.DataNucleus.Cache=WARN, A1
+log4j.category.DataNucleus.MetaData=WARN, A1
+log4j.category.DataNucleus.General=WARN, A1
+log4j.category.DataNucleus.Utility=WARN, A1
+log4j.category.DataNucleus.Transaction=WARN, A1
+log4j.category.DataNucleus.Datastore=WARN, A1
+log4j.category.DataNucleus.ClassLoading=WARN, A1
+log4j.category.DataNucleus.Plugin=WARN, A1
+log4j.category.DataNucleus.ValueGeneration=WARN, A1
+log4j.category.DataNucleus.Enhancer=WARN, A1
+log4j.category.DataNucleus.SchemaTool=WARN, A1
View
BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/appengine-api-1.0-sdk-1.7.0.jar
Binary file not shown.
View
BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/appengine-api-labs.jar
Binary file not shown.
View
BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/appengine-endpoints.jar
Binary file not shown.
View
BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/appengine-jsr107cache-1.7.0.jar
Binary file not shown.
View
BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/datanucleus-appengine-1.0.10.final.jar
Binary file not shown.
View
BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/datanucleus-core-1.1.5.jar
Binary file not shown.
View
BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/datanucleus-jpa-1.1.5.jar
Binary file not shown.
View
BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/geronimo-jpa_3.0_spec-1.1.1.jar
Binary file not shown.
View
BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/geronimo-jta_1.1_spec-1.1.1.jar
Binary file not shown.
View
BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/gson-2.2.2.jar
Binary file not shown.
View
BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/jdo2-api-2.3-eb.jar
Binary file not shown.
View
BIN AndroidProjects/GCMAppEngineExample/war/WEB-INF/lib/jsr107cache-1.1.jar
Binary file not shown.
View
14 AndroidProjects/GCMAppEngineExample/war/WEB-INF/logging.properties
@@ -0,0 +1,14 @@
+# A default java.util.logging configuration.
+# (All App Engine logging is through java.util.logging by default).
+#
+# To use this configuration, copy it into your application's WEB-INF
+# folder and add the following to your appengine-web.xml:
+#
+# <system-properties>
+# <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
+# </system-properties>
+#
+
+# Set the default logging level for all loggers to WARNING
+.level = WARNING
+guestbook.level = INFO
View
42 AndroidProjects/GCMAppEngineExample/war/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <servlet>
+ <servlet-name>Guestbook</servlet-name>
+ <servlet-class>guestbook.GuestbookServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Guestbook</servlet-name>
+ <url-pattern>/guestbook</url-pattern>
+ </servlet-mapping>
+ <servlet>
+ <servlet-name>sign</servlet-name>
+ <servlet-class>guestbook.SignGuestbookServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>sign</servlet-name>
+ <url-pattern>/sign</url-pattern>
+ </servlet-mapping>
+ <servlet>
+ <servlet-name>GCMExampleServlet</servlet-name>
+ <servlet-class>guestbook.GCMExampleServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>GCMExampleServlet</servlet-name>
+ <url-pattern>/userinfo</url-pattern>
+ </servlet-mapping>
+ <welcome-file-list>
+ <welcome-file>guestbook.jsp</welcome-file>
+ </welcome-file-list>
+ <servlet>
+ <servlet-name>SystemServiceServlet</servlet-name>
+ <servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
+ <init-param>
+ <param-name>services</param-name>
+ <param-value/>
+ </init-param>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>SystemServiceServlet</servlet-name>
+ <url-pattern>/_ah/spi/*</url-pattern>
+ </servlet-mapping>
+</web-app>
View
BIN AndroidProjects/GCMAppEngineExample/war/favicon.ico
Binary file not shown.
View
88 AndroidProjects/GCMAppEngineExample/war/guestbook.jsp
@@ -0,0 +1,88 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ page import="java.util.List" %>
+<%@ page import="com.google.appengine.api.users.User" %>
+<%@ page import="com.google.appengine.api.users.UserService" %>
+<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
+<%@ page import="com.google.appengine.api.datastore.DatastoreServiceFactory" %>
+<%@ page import="com.google.appengine.api.datastore.DatastoreService" %>
+<%@ page import="com.google.appengine.api.datastore.Query" %>
+<%@ page import="com.google.appengine.api.datastore.Entity" %>
+<%@ page import="com.google.appengine.api.datastore.FetchOptions" %>
+<%@ page import="com.google.appengine.api.datastore.Key" %>
+<%@ page import="com.google.appengine.api.datastore.KeyFactory" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
+
+<html>
+ <head>
+ <link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
+ </head>
+
+ <body>
+
+<%
+ String guestbookName = request.getParameter("guestbookName");
+ if (guestbookName == null) {
+ guestbookName = "default";
+ }
+ pageContext.setAttribute("guestbookName", guestbookName);
+ UserService userService = UserServiceFactory.getUserService();
+ User user = userService.getCurrentUser();
+ if (user != null) {
+ pageContext.setAttribute("user", user);
+%>
+<p>Hello, ${fn:escapeXml(user.nickname)}! (You can
+<a href="<%= userService.createLogoutURL(request.getRequestURI()) %>">sign out</a>.)</p>
+<%
+ } else {
+%>
+<p>Hello!
+<a href="<%= userService.createLoginURL(request.getRequestURI()) %>">Sign in</a>
+to include your name with greetings you post.</p>
+<%
+ }
+%>
+
+<%
+ DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
+ Key guestbookKey = KeyFactory.createKey("Guestbook", guestbookName);
+ // Run an ancestor query to ensure we see the most up-to-date
+ // view of the Greetings belonging to the selected Guestbook.
+ Query query = new Query("Greeting", guestbookKey).addSort("date", Query.SortDirection.DESCENDING);
+ List<Entity> greetings = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(5));
+ if (greetings.isEmpty()) {
+ %>
+ <p>Guestbook '${fn:escapeXml(guestbookName)}' has no messages.</p>
+ <%
+ } else {
+ %>
+ <p>Messages in Guestbook '${fn:escapeXml(guestbookName)}'.</p>
+ <%
+ for (Entity greeting : greetings) {
+ pageContext.setAttribute("greeting_content",
+ greeting.getProperty("content"));
+ if (greeting.getProperty("user") == null) {
+ %>
+ <p>An anonymous person wrote:</p>
+ <%
+ } else {
+ pageContext.setAttribute("greeting_user",
+ greeting.getProperty("user"));
+ %>
+ <p><b>${fn:escapeXml(greeting_user.nickname)}</b> wrote:</p>
+ <%
+ }
+ %>
+ <blockquote>${fn:escapeXml(greeting_content)}</blockquote>
+ <%
+ }
+ }
+%>
+
+ <form action="/sign" method="post">
+ <div><textarea name="content" rows="3" cols="60"></textarea></div>
+ <div><input type="submit" value="Post Greeting" /></div>
+ <input type="hidden" name="guestbookName" value="${fn:escapeXml(guestbookName)}"/>
+ </form>
+
+ </body>
+</html>
View
27 AndroidProjects/GCMAppEngineExample/war/index.html
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!-- The HTML 4.01 Transitional DOCTYPE declaration-->
+<!-- above set at the top of the file will set -->
+<!-- the browser's rendering engine into -->
+<!-- "Quirks Mode". Replacing this declaration -->
+<!-- with a "Standards Mode" doctype is supported, -->
+<!-- but may lead to some differences in layout. -->
+
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <title>Hello App Engine</title>
+ </head>
+
+ <body>
+ <h1>Hello App Engine!</h1>
+
+ <table>
+ <tr>
+ <td colspan="2" style="font-weight:bold;">Available Servlets:</td>
+ </tr>
+ <tr>
+ <td><a href="guestbook">Guestbook</a></td>
+ </tr>
+ </table>
+ </body>
+</html>
View
4 AndroidProjects/GCMAppEngineExample/war/stylesheets/main.css
@@ -0,0 +1,4 @@
+body {
+ font-family: Verdana, Helvetica, sans-serif;
+ background-color: #FFFFCC;
+}
View
BIN AndroidProjects/WidgetAlarmManagerExample/bin/WidgetAlarmManagerExample.apk
Binary file not shown.
View
BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-hdpi/ic_action_search.png
Deleted file not rendered
View
BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-hdpi/ic_launcher.png
Deleted file not rendered
View
BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-ldpi/ic_launcher.png
Deleted file not rendered
View
BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-mdpi/ic_action_search.png
Deleted file not rendered
View
BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-mdpi/ic_launcher.png
Deleted file not rendered
View
BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-xhdpi/ic_action_search.png
Deleted file not rendered
View
BIN AndroidProjects/WidgetAlarmManagerExample/bin/res/drawable-xhdpi/ic_launcher.png
Deleted file not rendered

0 comments on commit de5b054

Please sign in to comment.