summaryrefslogtreecommitdiff
path: root/src/clojure/io/cons/carddav_sync/authentication_service.clj
blob: f3394571749a593d95912d55fb7d3f0bcea0b398 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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)))