Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 8fcf67645bc10a386cd127bfd18908fb0702f010 @pegli committed Sep 29, 2011
Showing with 1,967 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +8 −0 mobile/android/.classpath
  3. +5 −0 mobile/android/.gitignore
  4. +17 −0 mobile/android/.project
  5. +7 −0 mobile/android/.settings/org.eclipse.jdt.apt.core.prefs
  6. +3 −0 mobile/android/.settings/org.eclipse.jdt.core.prefs
  7. +1 −0 mobile/android/LICENSE
  8. +6 −0 mobile/android/assets/README
  9. +3 −0 mobile/android/build.properties
  10. +10 −0 mobile/android/build.xml
  11. BIN mobile/android/dist/keychain.jar
  12. +39 −0 mobile/android/documentation/index.md
  13. +66 −0 mobile/android/example/app.js
  14. +1 −0 mobile/android/hooks/README
  15. +35 −0 mobile/android/hooks/add.py
  16. +19 −0 mobile/android/hooks/install.py
  17. +34 −0 mobile/android/hooks/remove.py
  18. +18 −0 mobile/android/hooks/uninstall.py
  19. +17 −0 mobile/android/manifest
  20. +3 −0 mobile/android/platform/README
  21. +75 −0 mobile/android/src/com/obscure/keychain/KeychainItemProxy.java
  22. +53 −0 mobile/android/src/com/obscure/keychain/KeychainModule.java
  23. +11 −0 mobile/android/timodule.xml
  24. +4 −0 mobile/ios/.gitignore
  25. +2 −0 mobile/ios/Classes/.gitignore
  26. +13 −0 mobile/ios/Classes/ComObscureKeychainModule.h
  27. +105 −0 mobile/ios/Classes/ComObscureKeychainModule.m
  28. +9 −0 mobile/ios/Classes/ComObscureKeychainModuleAssets.h
  29. +15 −0 mobile/ios/Classes/ComObscureKeychainModuleAssets.m
  30. +74 −0 mobile/ios/Classes/KeychainItemWrapper.h
  31. +319 −0 mobile/ios/Classes/KeychainItemWrapper.m
  32. +19 −0 mobile/ios/Classes/KeychainItemWrapperProxy.h
  33. +65 −0 mobile/ios/Classes/KeychainItemWrapperProxy.m
  34. +4 −0 mobile/ios/ComObscureKeychain_Prefix.pch
  35. +62 −0 mobile/ios/LICENSE
  36. 0 mobile/ios/README
  37. +6 −0 mobile/ios/assets/README
  38. +196 −0 mobile/ios/build.py
  39. +39 −0 mobile/ios/documentation/index.md
  40. +66 −0 mobile/ios/example/app.js
  41. +1 −0 mobile/ios/hooks/README
  42. +35 −0 mobile/ios/hooks/add.py
  43. +19 −0 mobile/ios/hooks/install.py
  44. +34 −0 mobile/ios/hooks/remove.py
  45. +18 −0 mobile/ios/hooks/uninstall.py
  46. +349 −0 mobile/ios/keychain.xcodeproj/project.pbxproj
  47. +7 −0 mobile/ios/keychain.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  48. +13 −0 mobile/ios/manifest
  49. +27 −0 mobile/ios/module.xcconfig
  50. +3 −0 mobile/ios/platform/README
  51. +11 −0 mobile/ios/timodule.xml
  52. +19 −0 mobile/ios/titanium.xcconfig
@@ -0,0 +1,2 @@
+.svn
+.DS_Store
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="build/.apt_generated"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="/opt/android-sdk/platforms/android-7/android.jar"/> <classpathentry kind="lib" path="/opt/android-sdk/add-ons/addon_google_apis_google_inc_7/libs/maps.jar"/> <classpathentry kind="lib" path="/Library/Application Support/Titanium/mobilesdk/osx/1.7.1/android/titanium.jar"/> <classpathentry kind="lib" path="/Library/Application Support/Titanium/mobilesdk/osx/1.7.1/android/js.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
@@ -0,0 +1,5 @@
+tmp
+bin
+build
+*.zip
+.apt_generated
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>titanium-keychain</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,7 @@
+#Thu Sep 02 15:18:34 CDT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.apt.aptEnabled=true
+org.eclipse.jdt.apt.genSrcDir=.apt_generated
+org.eclipse.jdt.apt.reconcileEnabled=true
+
+org.eclipse.jdt.apt.processorOptions/kroll.jsonFile=keychain.json
@@ -0,0 +1,3 @@
+#Thu Sep 02 15:18:34 CDT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.processAnnotations=enabled
@@ -0,0 +1 @@
+TODO: place your license here and we'll include it in the module distribution
@@ -0,0 +1,6 @@
+Place your assets like PNG files in this directory and they will be packaged with your module.
+
+If you create a file named com.obscure.keychain.js in this directory, it will be
+compiled and used as your module. This allows you to run pure Javascript
+modules that are pre-compiled.
+
@@ -0,0 +1,3 @@
+titanium.platform=/Library/Application Support/Titanium/mobilesdk/osx/1.7.1/android
+android.platform=/opt/android-sdk/platforms/android-7
+google.apis=/opt/android-sdk/add-ons/addon_google_apis_google_inc_7
@@ -0,0 +1,10 @@
+<project name="keychain" default="dist">
+ <description>
+ Ant build script for Titanium Android module keychain
+ </description>
+
+ <property name="ti.module.root" location="${basedir}"/>
+ <property file="build.properties" />
+
+ <import file="${titanium.platform}/../module/android/build.xml"/>
+</project>
Binary file not shown.
@@ -0,0 +1,39 @@
+# keychain Module
+
+## Description
+
+TODO: Enter your module description here
+
+## Accessing the keychain Module
+
+To access this module from JavaScript, you would do the following:
+
+ var keychain = require("com.obscure.keychain");
+
+The keychain variable is a reference to the Module object.
+
+## Reference
+
+TODO: If your module has an API, you should document
+the reference here.
+
+### ___PROJECTNAMEASIDENTIFIER__.function
+
+TODO: This is an example of a module function.
+
+### ___PROJECTNAMEASIDENTIFIER__.property
+
+TODO: This is an example of a module property.
+
+## Usage
+
+TODO: Enter your usage example here
+
+## Author
+
+TODO: Enter your author name, email and other contact
+details you want to share here.
+
+## License
+
+TODO: Enter your license/legal information here.
@@ -0,0 +1,66 @@
+// This is a test harness for your module
+// You should do something interesting in this harness
+// to test out the module and to provide instructions
+// to users on how to use it by example.
+
+
+// open a single window
+var window = Ti.UI.createWindow({
+ backgroundColor:'white',
+});
+var label = Ti.UI.createLabel({
+ top: 20,
+ height: 30,
+ left: 10,
+ right: 10,
+ text: 'keychain test',
+});
+window.add(label);
+
+var button1 = Ti.UI.createButton({
+ title: 'set account',
+ top: 60,
+ height: 30,
+ width: 100,
+});
+button1.addEventListener('click', function() {
+ keychainItem.account = 'pegli';
+ Ti.API.info("new account = "+keychainItem.account);
+ label.text = "new account = "+keychainItem.account;
+});
+window.add(button1);
+
+var button2 = Ti.UI.createButton({
+ title: 'set password',
+ top: 100,
+ height: 30,
+ width: 100,
+});
+button2.addEventListener('click', function() {
+ keychainItem.valueData = 'supersecret';
+ Ti.API.info("new password = "+keychainItem.valueData);
+ label.text = "new password = "+keychainItem.valueData;
+});
+window.add(button2);
+
+var button3 = Ti.UI.createButton({
+ title: 'reset keychain item',
+ top: 140,
+ height: 30,
+ width: 100,
+});
+button3.addEventListener('click', function() {
+ keychainItem.reset();
+ Ti.API.info("reset item, account = "+keychainItem.account);
+ label.text = "reset item, account = "+keychainItem.account;
+});
+window.add(button3);
+
+window.open();
+
+// TODO: write your module tests here
+var keychain = require('com.obscure.keychain');
+Ti.API.info("module is => " + keychain);
+
+var keychainItem = keychain.createKeychainItem('mylogin');
+Ti.API.info("account = " + keychainItem.account + "; password = " + keychainItem.valueData);
@@ -0,0 +1 @@
+These files are not yet supported as of 1.4.0 but will be in a near future release.
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+#
+# This is the module project add hook that will be
+# called when your module is added to a project
+#
+import os, sys
+
+def dequote(s):
+ if s[0:1] == '"':
+ return s[1:-1]
+ return s
+
+def main(args,argc):
+ # You will get the following command line arguments
+ # in the following order:
+ #
+ # project_dir = the full path to the project root directory
+ # project_type = the type of project (desktop, mobile, ipad)
+ # project_name = the name of the project
+ #
+ project_dir = dequote(os.path.expanduser(args[1]))
+ project_type = dequote(args[2])
+ project_name = dequote(args[3])
+
+ # TODO: write your add hook here (optional)
+
+
+ # exit
+ sys.exit(0)
+
+
+
+if __name__ == '__main__':
+ main(sys.argv,len(sys.argv))
+
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+#
+# This is the module install hook that will be
+# called when your module is first installed
+#
+import os, sys
+
+def main(args,argc):
+
+ # TODO: write your install hook here (optional)
+
+ # exit
+ sys.exit(0)
+
+
+
+if __name__ == '__main__':
+ main(sys.argv,len(sys.argv))
+
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+#
+# This is the module project remove hook that will be
+# called when your module is remove from a project
+#
+import os, sys
+
+def dequote(s):
+ if s[0:1] == '"':
+ return s[1:-1]
+ return s
+
+def main(args,argc):
+ # You will get the following command line arguments
+ # in the following order:
+ #
+ # project_dir = the full path to the project root directory
+ # project_type = the type of project (desktop, mobile, ipad)
+ # project_name = the name of the project
+ #
+ project_dir = dequote(os.path.expanduser(args[1]))
+ project_type = dequote(args[2])
+ project_name = dequote(args[3])
+
+ # TODO: write your remove hook here (optional)
+
+ # exit
+ sys.exit(0)
+
+
+
+if __name__ == '__main__':
+ main(sys.argv,len(sys.argv))
+
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+#
+# This is the module uninstall hook that will be
+# called when your module is uninstalled
+#
+import os, sys
+
+def main(args,argc):
+
+ # TODO: write your uninstall hook here (optional)
+
+ # exit
+ sys.exit(0)
+
+
+if __name__ == '__main__':
+ main(sys.argv,len(sys.argv))
+
@@ -0,0 +1,17 @@
+#
+# this is your module manifest and used by Titanium
+# during compilation, packaging, distribution, etc.
+#
+version: 1.0
+description: Keychain access module for iPhone
+author: Paul Mietz Egli
+license: Apache 2.0
+copyright: Copyright (c) 2011 Paul Mietz Egli
+
+
+# these should not be edited
+name: keychain
+moduleid: com.obscure.keychain
+guid: eb0a9be8-02b5-43a2-a115-a220b293d202
+platform: android
+minsdk: 1.7.1
@@ -0,0 +1,3 @@
+You can place platform-specific files here in sub-folders named "android" and/or "iphone", just as you can with normal Titanium Mobile SDK projects. Any folders and files you place here will be merged with the platform-specific files in a Titanium Mobile project that uses this module.
+
+When a Titanium Mobile project that uses this module is built, the files from this platform/ folder will be treated the same as files (if any) from the Titanium Mobile project's platform/ folder.
@@ -0,0 +1,75 @@
+package com.obscure.keychain;
+
+import org.appcelerator.kroll.KrollModule;
+import org.appcelerator.kroll.KrollProxy;
+import org.appcelerator.kroll.annotations.Kroll;
+import org.appcelerator.titanium.TiContext;
+import org.appcelerator.titanium.util.TiConfig;
+
+import android.content.ContextWrapper;
+import android.content.SharedPreferences;
+
+// This proxy can be created by calling Keychain.createExample({message: "hello world"})
+@Kroll.proxy(creatableInModule = KeychainModule.class)
+public class KeychainItemProxy extends KrollProxy {
+ // Standard Debugging variables
+ private static final String LCAT = "KeychainItemProxy";
+ private static final boolean DBG = TiConfig.LOGD;
+
+ private static final String ACCOUNT_KEY = "keychain.account";
+ private static final String VALUE_DATA_KEY = "keychain.valueData";
+
+ private SharedPreferences sharedPrefs;
+ private ContextWrapper androidContext;
+
+ // Constructor
+ public KeychainItemProxy(TiContext tiContext) {
+ super(tiContext);
+ androidContext = context.getAndroidContext();
+ }
+
+ @Override
+ public void handleCreationArgs(KrollModule createdInModule, Object[] args) {
+ super.handleCreationArgs(createdInModule, args);
+ if (args != null && args.length > 0) {
+ String name = String.format("keychain.%s", (String) args[0]);
+ sharedPrefs = androidContext.getSharedPreferences(name, 0);
+ }
+ }
+
+ @Kroll.getProperty
+ @Kroll.method
+ public String getAccount() {
+ return sharedPrefs.getString(ACCOUNT_KEY, null);
+ }
+
+ @Kroll.setProperty
+ @Kroll.method
+ public void setAccount(String value) {
+ SharedPreferences.Editor editor = sharedPrefs.edit();
+ editor.putString(ACCOUNT_KEY, value);
+ editor.commit();
+ }
+
+ @Kroll.getProperty
+ @Kroll.method
+ public String getValueData() {
+ return sharedPrefs.getString(VALUE_DATA_KEY, null);
+ }
+
+ @Kroll.setProperty
+ @Kroll.method
+ public void setValueData(String value) {
+ SharedPreferences.Editor editor = sharedPrefs.edit();
+ editor.putString(VALUE_DATA_KEY, value);
+ editor.commit();
+ }
+
+ @Kroll.method
+ public void reset() {
+ SharedPreferences.Editor editor = sharedPrefs.edit();
+ editor.remove(ACCOUNT_KEY);
+ editor.remove(VALUE_DATA_KEY);
+ editor.commit();
+ }
+}
Oops, something went wrong.

0 comments on commit 8fcf676

Please sign in to comment.