places.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const log = require('../../../util/log')
  2. const path = require('path')
  3. const sqlite3 = require('sqlite3')
  4. const fs = require('fs')
  5. // Derive filenames based on domain + file path
  6. const fileHash = require('../../../util/backup_filehash')
  7. const database = fileHash('Documents/user.db', 'AppDomain-com.waze.iphone')
  8. module.exports = {
  9. version: 4,
  10. name: 'waze_places',
  11. description: `List Waze app places`,
  12. requiresBackup: true,
  13. // Run on a v3 lib / backup object.
  14. run (lib, { backup }) {
  15. return wazeReport(backup)
  16. },
  17. // Fields for apps report
  18. output: {
  19. 'Name': el => el.name,
  20. 'Created Date': el => (new Date((el.created_time) * 1000).toDateString()) + ' ' + (new Date((el.created_time) * 1000).toTimeString()) ,
  21. 'Latitude': el => el.latitude / 1000000,
  22. 'Longitude': el => el.longitude / 1000000,
  23. 'Street': el => el.street,
  24. 'City': el => el.city,
  25. 'State': el => el.state,
  26. 'Country': el => el.country
  27. }
  28. }
  29. function KeyValue (property, plist) {
  30. this.key = property
  31. this.value = plist[property] ? plist[property] : 'N/A'
  32. }
  33. const wazeReport = (backup) => {
  34. return new Promise((resolve, reject) => {
  35. backup.openDatabase(database)
  36. .then(db => {
  37. const query = `
  38. select * from PLACES
  39. order by id
  40. `
  41. db.all(query, async function (err, rows) {
  42. if (err) reject(err)
  43. resolve(rows)
  44. })
  45. }).catch(reject)
  46. })
  47. }