+import_d() {
+ call_db=""
+ cd "$1" || abort "Can't change directory to \"$1\"!"
+ verbose "iPhone Backup directory is \"$1\"."
+ if [ -z "$call_db" ]; then
+ verbose "Locating SQLite call database(s) ..."
+ call_db=$(for f in `file * | fgrep SQLite | cut -d':' -f1`; do
+ sqlite3 "$f" ".schema" | fgrep "CREATE TABLE call (" >/dev/null;
+ [ $? -eq 0 ] && echo "$f"; done
+ )
+ fi
+ for f in $call_db; do
+ verbose "Found call database: \"$f\""
+ done
+
+ if [ -e "$CALL_LOG" ]; then
+ debug "Copying existing ASCII call log ..."
+ cp "$CALL_LOG" "$CALL_TMP" || abort "Can't copy old log file!"
+ fi
+ for f in $call_db; do
+ verbose "Dumping SQLite call databse \"$f\" ..."
+ sqlite3 "$f" "select * from call;" >>"$CALL_TMP"
+ done
+ verbose "Sorting plain ASCII call log ..."
+ sort -u "$CALL_TMP" >"$CALL_LOG"
+ rm -f "$CALL_TMP"
+ first_d=$(date -r `head -1 "$CALL_LOG" | cut -d'|' -f3` "+%Y-%m-%d %H:%M")
+ last_d=$(date -r `tail -1 "$CALL_LOG" | cut -d'|' -f3` "+%Y-%m-%d %H:%M")
+ message `wc -l "$CALL_LOG" | awk '{print \$1}'`" unique entries logged, from $first_d to $last_d."
+}