favorites.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 = {
  11. version: 4,
  12. name: 'waze_favorites',
  13. description: `List Waze app favorite places`,
  14. requiresBackup: true,
  15. // Run on a v3 lib / backup object.
  16. run (lib, { backup }) {
  17. return wazeReport(backup)
  18. },
  19. // Fields for apps report
  20. output: {
  21. 'Name': el => el.name,
  22. 'Modified Date': el => (new Date((el.modified_time) * 1000).toDateString()) + ' ' + (new Date((el.modified_time) * 1000).toTimeString()) ,
  23. 'Latitude': el => el.latitude / 1000000,
  24. 'Longitude': el => el.longitude / 1000000,
  25. 'Street': el => el.street,
  26. 'City': el => el.city,
  27. 'State': el => el.state,
  28. 'Country': el => el.country
  29. }
  30. }
  31. function KeyValue (property, plist) {
  32. this.key = property
  33. this.value = plist[property] ? plist[property] : 'N/A'
  34. }
  35. const wazeReport = (backup) => {
  36. return new Promise((resolve, reject) => {
  37. const query = `
  38. select FAVORITES.name, FAVORITES.created_time, FAVORITES.modified_time, FAVORITES.rank, PLACES.latitude, PLACES.longitude, PLACES.street, PLACES.city, PLACES.state, PLACES.country from FAVORITES
  39. left join PLACES on FAVORITES.place_id = PLACES.id
  40. order by rank `
  41. backup.openDatabase(database).then(database => {
  42. database.all(query, (err, rows) => {
  43. if (err) resolve(err)
  44. resolve(rows);
  45. })
  46. }).catch(reject)
  47. })
  48. }