waze_places.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. const log = require('../util/log')
  2. const path = require('path')
  3. const sqlite3 = require('sqlite3')
  4. const bplist = require('bplist-parser')
  5. const fs = require('fs')
  6. const plist = require('plist')
  7. // Derive filenames based on domain + file path
  8. const fileHash = require('../util/backup_filehash')
  9. const database = fileHash('Documents/user.db', 'AppDomain-com.waze.iphone')
  10. module.exports.name = 'waze_places'
  11. module.exports.description = 'List Waze app places'
  12. // Specify this reporter requires a backup.
  13. // The second parameter to func() is now a backup instead of the path to one.
  14. module.exports.requiresBackup = true
  15. // Specify this reporter supports the promises API for allowing chaining of reports.
  16. module.exports.usesPromises = true
  17. module.exports.func = function (program, backup, resolve, reject) {
  18. wazeReport(backup)
  19. .then((items) => {
  20. var result = program.formatter.format(items, {
  21. program: program,
  22. columns: {
  23. 'Name': el => el.name,
  24. 'Created Date': el => (new Date((el.created_time) * 1000).toDateString()) + ' ' + (new Date((el.created_time) * 1000).toTimeString()) ,
  25. 'Latitude': el => el.latitude / 1000000,
  26. 'Longitude': el => el.longitude / 1000000,
  27. 'Street': el => el.street,
  28. 'City': el => el.city,
  29. 'State': el => el.state,
  30. 'Country': el => el.country
  31. }
  32. })
  33. resolve(result)
  34. })
  35. .catch(reject)
  36. }
  37. function KeyValue (property, plist) {
  38. this.key = property
  39. this.value = plist[property] ? plist[property] : 'N/A'
  40. }
  41. const wazeReport = (backup) => {
  42. return new Promise((resolve, reject) => {
  43. var wazedb = backup.getDatabase(database)
  44. try {
  45. const query = `
  46. select * from PLACES
  47. order by id
  48. `
  49. wazedb.all(query, async function (err, rows) {
  50. if (err) reject(err)
  51. resolve(rows)
  52. })
  53. } catch (e) {
  54. reject(e)
  55. }
  56. })
  57. }