diff options
author | David Barksdale <amatus@amatus.name> | 2013-08-28 19:29:21 -0500 |
---|---|---|
committer | David Barksdale <amatus@amatus.name> | 2013-08-28 19:29:21 -0500 |
commit | e5a01c3d697562b734f11ac13f96b8a4a95de6cd (patch) | |
tree | 018c662e1b74192f4d77a56d9776841d3bd3ff27 /src/clojure/io | |
parent | 85e0a42e2a695b4eb58579aeba0756ff64615f03 (diff) |
Authenticator and SyncAdapter skeleton.
Diffstat (limited to 'src/clojure/io')
-rw-r--r-- | src/clojure/io/cons/carddav_sync/authentication_service.clj | 31 | ||||
-rw-r--r-- | src/clojure/io/cons/carddav_sync/authenticator.clj | 45 | ||||
-rw-r--r-- | src/clojure/io/cons/carddav_sync/log.clj | 4 | ||||
-rw-r--r-- | src/clojure/io/cons/carddav_sync/main.clj | 3 | ||||
-rw-r--r-- | src/clojure/io/cons/carddav_sync/sync_adapter.clj | 16 | ||||
-rw-r--r-- | src/clojure/io/cons/carddav_sync/sync_service.clj | 31 |
6 files changed, 128 insertions, 2 deletions
diff --git a/src/clojure/io/cons/carddav_sync/authentication_service.clj b/src/clojure/io/cons/carddav_sync/authentication_service.clj new file mode 100644 index 0000000..f339457 --- /dev/null +++ b/src/clojure/io/cons/carddav_sync/authentication_service.clj @@ -0,0 +1,31 @@ +(ns io.cons.carddav_sync.authentication_service + (:use io.cons.carddav_sync.log) + (:require io.cons.carddav_sync.authenticator) + (:gen-class + :extends android.app.Service + :exposes-methods {onCreate superOnCreate + onDestroy superOnDestroy} + :state state + :init init)) + +(defn -init + [] + [[] (atom nil)]) + +(defn -onCreate + [this] + (.superOnCreate this) + (log-i "Authentication Service created") + (swap! (.state this) + #(when-not % + (io.cons.carddav_sync.authenticator. this)))) + +(defn -onDestroy + [this] + (.superOnDestroy this) + (log-i "Authentication Service destroyed")) + +(defn -onBind + [this intent] + (log-i "Authentication onBind") + (.getIBinder @(.state this))) diff --git a/src/clojure/io/cons/carddav_sync/authenticator.clj b/src/clojure/io/cons/carddav_sync/authenticator.clj new file mode 100644 index 0000000..99aefe7 --- /dev/null +++ b/src/clojure/io/cons/carddav_sync/authenticator.clj @@ -0,0 +1,45 @@ +(ns io.cons.carddav_sync.authenticator + (:use io.cons.carddav_sync.log) + (:gen-class + :extends android.accounts.AbstractAccountAuthenticator + :state state + :init init)) + +(defn -init + [context] + [[context] nil]) + +(defn -addAccount + [this response accountType authTokenType requiredFeatures options] + (log-i "addAccount") + nil) + +(defn -confirmCredentials + [this response account options] + (log-i "confirmCredentials") + nil) + +(defn -editProperties + [this response accountType] + (log-i "editProperties") + nil) + +(defn -getAuthToken + [this response account authTokenType options] + (log-i "getAuthToken") + nil) + +(defn -getAuthTokenLabel + [this authTokenType] + (log-i "getAuthTokenLabel") + nil) + +(defn -hasFeatures + [this response account features] + (log-i "hasFeatures") + nil) + +(defn -updateCredentials + [this response account authTokenType options] + (log-i "updateCredentials") + nil) diff --git a/src/clojure/io/cons/carddav_sync/log.clj b/src/clojure/io/cons/carddav_sync/log.clj new file mode 100644 index 0000000..aff2f17 --- /dev/null +++ b/src/clojure/io/cons/carddav_sync/log.clj @@ -0,0 +1,4 @@ +(ns io.cons.carddav_sync.log + (:use neko.log)) + +(deflog "CardDAV-Sync") diff --git a/src/clojure/io/cons/carddav_sync/main.clj b/src/clojure/io/cons/carddav_sync/main.clj index c5f4048..f9d2a86 100644 --- a/src/clojure/io/cons/carddav_sync/main.clj +++ b/src/clojure/io/cons/carddav_sync/main.clj @@ -1,8 +1,7 @@ (ns io.cons.carddav_sync.main (:use [neko.activity :only [defactivity set-content-view!]] [neko.threading :only [on-ui]] - [neko.ui :only [make-ui]] - [neko.application :only [defapplication]])) + [neko.ui :only [make-ui]])) (defactivity io.cons.carddav_sync.MainActivity :def a diff --git a/src/clojure/io/cons/carddav_sync/sync_adapter.clj b/src/clojure/io/cons/carddav_sync/sync_adapter.clj new file mode 100644 index 0000000..21c8fff --- /dev/null +++ b/src/clojure/io/cons/carddav_sync/sync_adapter.clj @@ -0,0 +1,16 @@ +(ns io.cons.carddav_sync.sync_adapter + (:use io.cons.carddav_sync.log) + (:gen-class + :extends android.content.AbstractThreadedSyncAdapter + :state state + :init init)) + +(defn -init + ([context autoInitialize] + [[context autoInitialize] nil]) + ([context autoInitialize allowParallelSyncs] + [[context autoInitialize allowParallelSyncs] nil])) + +(defn -onPerformSync + [this account extras authority provider syncResult] + (log-i "Started sync")) diff --git a/src/clojure/io/cons/carddav_sync/sync_service.clj b/src/clojure/io/cons/carddav_sync/sync_service.clj new file mode 100644 index 0000000..e069f86 --- /dev/null +++ b/src/clojure/io/cons/carddav_sync/sync_service.clj @@ -0,0 +1,31 @@ +(ns io.cons.carddav_sync.sync_service + (:use io.cons.carddav_sync.log) + (:require io.cons.carddav_sync.sync_adapter) + (:gen-class + :extends android.app.Service + :exposes-methods {onCreate superOnCreate + onDestroy superOnDestroy} + :state state + :init init)) + +(defn -init + [] + [[] (atom nil)]) + +(defn -onCreate + [this] + (.superOnCreate this) + (log-i "Service created") + (swap! (.state this) + #(when-not % + (io.cons.carddav_sync.sync_adapter. + (.getApplicationContext this) true)))) + +(defn -onDestroy + [this] + (.superOnDestroy this) + (log-i "Service destroyed")) + +(defn -onBind + [this intent] + (.getSyncAdapterBinder @(.state this))) |