speed_dial.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const plist = require('../../util/plist')
  2. const fs = require('fs')
  3. // Derive filenames based on domain + file path
  4. const fileHash = require('../../util/backup_filehash')
  5. const file = fileHash('Library/Preferences/com.apple.mobilephone.speeddial.plist')
  6. module.exports = {
  7. version: 4,
  8. name: 'phone.speed_dial',
  9. description: `Show Speed dial contact information`,
  10. requiresBackup: true,
  11. // Run on a v3 lib / backup object.
  12. run (lib, { backup }) {
  13. return speedDialReport(backup)
  14. },
  15. // Public facing properties
  16. output: {
  17. actionType: el => {
  18. // Preprocess action type
  19. if (el.ActionType) {
  20. if (el.ActionType.indexOf('ActionType') !== -1) {
  21. return el.ActionType.split('ActionType')[0]
  22. } else {
  23. return el.ActionType
  24. }
  25. } else {
  26. return 'N/A'
  27. }
  28. },
  29. contactName: el => el.Name,
  30. value: el => el.Value
  31. }
  32. }
  33. const speedDialReport = (backup) => {
  34. return new Promise((resolve, reject) => {
  35. try {
  36. var filename = backup.getFileName(file)
  37. let speeddialPlist = plist.parseFile(filename)
  38. resolve(speeddialPlist)
  39. } catch (e) {
  40. reject(e)
  41. }
  42. })
  43. }