Permalink
Browse files

corrected .gitignore

Did not ignore files
project.properties
proguard.cfg
The comments in them said
# This file must be checked in Version Control Systems.
  • Loading branch information...
1 parent 778007e commit ef8b69c74d3469f8158d85ab7a77f5a7cf1fa808 @sasinda sasinda committed Jun 4, 2012
View
@@ -44,8 +44,8 @@
<modules>
<module>xwiki-rest-model</module>
<module>xwiki-android-rest</module>
- <module>xwiki-android-components</module>
<module>xwiki-android-core</module>
+ <module>xwiki-android-components</module>
<module>xwiki-android-client</module>
<module>xwiki-android-test-rest</module>
<module>xwiki-android-tests-instrumentation</module>
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ *
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.xwiki.android</groupId>
+ <artifactId>xwiki-android</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>xwiki-android-core</artifactId>
+ <packaging>apklib</packaging>
+ <name>XWiki android core lib</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.xwiki.android</groupId>
+ <artifactId>xwiki-android-rest</artifactId>
+ <type>apklib</type>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.j256.ormlite</groupId>
+ <artifactId>ormlite-core</artifactId>
+ <version>4.40</version>
+ </dependency>
+ <dependency>
+ <groupId>com.j256.ormlite</groupId>
+ <artifactId>ormlite-android</artifactId>
+ <version>4.40</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <sourceDirectory>src</sourceDirectory>
+ </build>
+
+</project>
@@ -0,0 +1,135 @@
+package org.xwiki.android.context;
+
+import java.util.Map;
+import android.content.Context;
+import android.content.SharedPreferences;
+
+/**
+ * Provides Application wise configuration data
+ * You need to call commit to persist the data.
+ * Uses
+ * @see android.content.SharedPreferences
+ * @see android.content.SharedPreferences.Editor
+ * This class instance is a singleton
+ * @author sasinda
+ *
+ */
+//TODO: Consider revisioning. Is a singleton needed. What happens when multiple threads share same pref.
+public class ConfigSourceProvider implements SharedPreferences,SharedPreferences.Editor{
+ public static final String FILE_CONFIG="/data/config";
+
+ private SharedPreferences pref;
+ private SharedPreferences.Editor editor;
+ private static ConfigSourceProvider singleton;
+
+ private ConfigSourceProvider(){}
+ private ConfigSourceProvider(Context ctx){
+ //init
+ pref=ctx.getSharedPreferences(FILE_CONFIG, android.content.Context.MODE_WORLD_READABLE);
+ editor=pref.edit();
+ //clean up context obj
+ }
+ /*
+ * package lvl method
+ * Use XwikiContext.getConfigSourceProvider to get an instance.
+ */
+ static ConfigSourceProvider getInstance(Context appCtx){
+ if(singleton==null){
+ singleton=new ConfigSourceProvider(appCtx);
+ }
+ return singleton;
+ }
+
+ /**
+ * Handy reInitialize method if the stream to the config file is lost.
+ * @param appCtx
+ */
+ public void reInitialize(Context ctx){
+ //init
+ pref=ctx.getSharedPreferences("/data/config", android.content.Context.MODE_WORLD_READABLE);
+ editor=pref.edit();
+ }
+ @Override
+ public Editor putString(String key, String value) {
+ return editor.putString(key, value);
+ }
+ @Override
+ public Editor putInt(String key, int value) {
+ return editor.putInt(key, value);
+ }
+ @Override
+ public Editor putLong(String key, long value) {
+ return editor.putLong(key, value);
+
+ }
+ @Override
+ public Editor putFloat(String key, float value) {
+ return editor.putFloat(key, value);
+ }
+ @Override
+ public Editor putBoolean(String key, boolean value) {
+ return editor.putBoolean(key, value);
+ }
+ @Override
+ public Editor remove(String key) {
+ return editor.remove(key);
+ }
+ @Override
+ public Editor clear() {
+ return editor.clear();
+ }
+ @Override
+ public boolean commit() {
+ return editor.commit();
+ }
+ @Override
+ public Map<String, ?> getAll() {
+ return pref.getAll();
+ }
+ @Override
+ public String getString(String key, String defValue) {
+ return pref.getString(key, defValue);
+ }
+ @Override
+ public int getInt(String key, int defValue) {
+ return pref.getInt(key, defValue);
+ }
+ @Override
+ public long getLong(String key, long defValue) {
+ return pref.getLong(key, defValue);
+ }
+ @Override
+ public float getFloat(String key, float defValue) {
+ return pref.getFloat(key, defValue);
+ }
+ @Override
+ public boolean getBoolean(String key, boolean defValue) {
+ return pref.getBoolean(key, defValue);
+ }
+ @Override
+ public boolean contains(String key) {
+ return pref.contains(key);
+ }
+
+ /*
+ * not used. You can get the same methods in the Config Class
+ * @see android.content.SharedPreferences#edit()
+ */
+ @Override
+ public Editor edit() {
+ return pref.edit();
+ }
+ @Override
+ public void registerOnSharedPreferenceChangeListener(
+ OnSharedPreferenceChangeListener listener) {
+ pref.registerOnSharedPreferenceChangeListener(listener);
+
+ }
+ @Override
+ public void unregisterOnSharedPreferenceChangeListener(
+ OnSharedPreferenceChangeListener listener) {
+ pref.unregisterOnSharedPreferenceChangeListener(listener);
+
+ }
+
+}
@@ -0,0 +1,39 @@
+package org.xwiki.android.context;
+
+import java.util.Hashtable;
+
+import org.xwiki.android.entity.User;
+
+public class UserSession extends Hashtable {
+
+ private String userName;
+ private String password;
+ private User user;
+
+ UserSession(){}//make constructing a new UserSession() prohibited outside package.
+
+ public String getUserName(){
+ return userName;
+ }
+ /**
+ * Read pwd from persistant store. Decrypt it and return.
+ * Does not store plain text pwd in memory for enhanced security.
+ * @return password of current user plain text.
+ */
+ public String getPassword(){
+ //TODO: read pwd from a uri and return decrypted pwd.
+ return password;
+ }
+
+ public User getUser(){
+ return user;
+ }
+
+ //package level set methods
+ void initilize(User u){
+ user=u;
+ //TODO:have logic to decrypt when encryption is enabled.
+ password=u.getEncryptedPassword();
+ userName=u.getUserName();
+ }
+}
@@ -0,0 +1,36 @@
+package org.xwiki.android.context;
+
+import java.util.Hashtable;
+
+import android.content.Context;
+/**
+ *
+ * @author sasinda
+ *
+ *Singleton class for holding application context data.
+ *you can put context wise data as key value pairs using java.util.Map interface methods.
+ */
+public class XAContext extends Hashtable<String,Object> {
+
+ private static XAContext ctx=null;//singleton
+ private XAContext(){};//disable constructor
+
+ //singleton private vars
+ UserSession currSession;
+
+ public static XAContext getInstance(){
+ if(ctx==null){
+ ctx=new XAContext();
+ ctx.currSession=new UserSession();
+ }
+ return ctx;
+ }
+ public UserSession getUserSession(){
+ return currSession;
+ }
+
+ public ConfigSourceProvider getConfigSourceProvider(Context appCtx){
+ return ConfigSourceProvider.getInstance(appCtx);
+ }
+
+}
@@ -0,0 +1,11 @@
+package org.xwiki.android.context;
+
+import org.xwiki.android.entity.User;
+
+public class XAContextInitializer {
+
+ public static void updateToAuthenticatedState(User u){
+ XAContext ctx=XAContext.getInstance();
+ ctx.getUserSession().initilize(u);
+ }
+}
@@ -0,0 +1,53 @@
+package org.xwiki.android.dal;
+
+import java.sql.SQLException;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.util.Log;
+
+import org.xwiki.android.core.*;
+import org.xwiki.android.entity.LoginAttempt;
+import org.xwiki.android.entity.User;
+
+import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
+import com.j256.ormlite.support.ConnectionSource;
+import com.j256.ormlite.table.TableUtils;
+
+public class XORMOpenHelper extends OrmLiteSqliteOpenHelper {
+ private static final String DATABASE_NAME="XWikiDB.db";
+ private static final int DATABASE_VERSION = 1;
+
+ /**
+ * This is called when the database is first created. Add logic to create all db tables for defined entities.
+ */
+ @Override
+ public void onCreate(SQLiteDatabase database,
+ ConnectionSource connectionSource) {
+ // TODO Auto-generated method stub
+ try{
+ Log.i(XORMOpenHelper.class.getSimpleName(), "onCreate(): create Database");
+ //add TableUtils.createTable(connectionSource, MyEntity.class); for all your entities
+ TableUtils.createTable(connectionSource, User.class);
+ TableUtils.createTable(connectionSource, LoginAttempt.class);
+
+ } catch (SQLException e){
+ Log.e(XORMOpenHelper.class.getName(), "Can't create database", e);
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase database,
+ ConnectionSource connectionSource, int oldVersion, int newVersion) {
+ // TODO Auto-generated method stub
+
+
+ }
+
+ public XORMOpenHelper(Context context) {
+ super(context, DATABASE_NAME, null, DATABASE_VERSION, R.raw.ormlite_config );
+ }
+
+}
@@ -0,0 +1,40 @@
+package org.xwiki.android.entity;
+
+import java.util.Date;
+
+import com.j256.ormlite.field.DatabaseField;
+import com.j256.ormlite.table.DatabaseTable;
+
+@DatabaseTable(tableName="C_LoginAttempt_LOG")
+public class LoginAttempt {
+ @DatabaseField
+ int _id;
+ @DatabaseField
+ String userName;
+ @DatabaseField
+ String wikiRealm;
+ @DatabaseField
+ Date time;
+ @DatabaseField
+ String status;
+ @DatabaseField
+ int responseCode;
+
+ public static final String STATUS_SUCCEED="s";
+ public static final String STATUS_FAILURE="f";
+
+ public LoginAttempt() { }//for ormlite
+
+ public LoginAttempt(String userName, String wikiRealm, Date time,
+ String status, int responseCode) {
+ super();
+ this.userName = userName;
+ this.wikiRealm = wikiRealm;
+ this.time = time;
+ this.status = status;
+ this.responseCode = responseCode;
+ }
+
+
+
+}
Oops, something went wrong.

0 comments on commit ef8b69c

Please sign in to comment.