Documentation ¶
Overview ¶
Package smsbackuprestore contains types, type methods, and functions for parsing SMS Backup & Restore Android app XML output and generating delimited data and decoding images from MMS messages.
Index ¶
- func CleanupMessageBody(body string) string
- func DecodeImages(m *Messages, mainOutputDir string) (numImagesIdentified, numImagesSuccessfullyWritten int, errors []error)
- func GenerateCallOutput(c *Calls, outputDir string) error
- func GenerateMMSOutput(m *Messages, outputDir string) error
- func GenerateSMSOutput(m *Messages, outputDir string) error
- func GetFileExtensionFromContentType(contentType string) string
- func NormalizePhoneNumber(number string) string
- func RemoveCommasBeforeSuffixes(contacts string) string
- func ReplaceAllBytesSubmatchFunc(re *regexp.Regexp, b []byte, repl func([][]byte) []byte) []byte
- type Address
- type AndroidTS
- type BoolValue
- type Call
- type CallType
- type Calls
- type MMS
- type Messages
- type Part
- type PhoneNumber
- type ReadStatus
- type SMS
- type SMSMessageType
- type SMSStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupMessageBody ¶
CleanupMessageBody removes newlines and tabs from strings.
func DecodeImages ¶
func DecodeImages(m *Messages, mainOutputDir string) (numImagesIdentified, numImagesSuccessfullyWritten int, errors []error)
DecodeImages identifies base64-encoded images in backed-up MMS messages and decodes them and outputs them to files with a unique file name tied to the MMS and part index numbers.
func GenerateCallOutput ¶
GenerateCallOutput outputs a tab-delimited file named "calls.tsv" containing parsed calls from the backup file.
func GenerateMMSOutput ¶
GenerateMMSOutput outputs a tab-delimited file named "mms.tsv" containing parsed MMS messages from the backup file.
func GenerateSMSOutput ¶
GenerateSMSOutput outputs a tab-delimited file named "sms.tsv" containing parsed SMS messages from the backup file.
func GetFileExtensionFromContentType ¶
GetFileExtensionFromContentType determines the file extension of the base64-encoded file based on the content type.
func NormalizePhoneNumber ¶
NormalizePhoneNumber attempts to normalize phone numbers in the format 13125551212, ignoring input with multiple numbers delimited by a tilde ('~') character.
func RemoveCommasBeforeSuffixes ¶
RemoveCommasBeforeSuffixes recursively strips commas before suffixes such as M.D. to prevent contact names from being split by a comma in the middle of a name and suffix.
The list is by no means comprehensive but includes the following common suffixes: - MD - DO - NP - RN - JR - SR - II - III - INC - LLP - LLC - LPN - ACSW - LCSW - MA - PHD
func ReplaceAllBytesSubmatchFunc ¶
ReplaceAllBytesSubmatchFunc replaces all bytes in the byte slice that match the specified pattern.
This is being done in an attempt to render emoji's properly due to SMS Backup & Restore app rendering of emoji's as HTML entitites in decimal (SLOW).
Function is based on http://elliot.land/post/go-replace-string-with-regular-expression-callback
Types ¶
type Address ¶
type Address struct { XMLName xml.Name `xml:"addr"` Address PhoneNumber `xml:"address,string,attr"` }
type Call ¶
type Call struct { XMLName xml.Name `xml:"call"` Number PhoneNumber `xml:"number,string,attr"` Duration int `xml:"duration,string,attr"` Date AndroidTS `xml:"date,string,attr"` // consider reading in as int Type CallType `xml:"type,string,attr"` ReadableDate string `xml:"readable_date,attr"` ContactName string `xml:"contact_name,attr"` }
type CallType ¶
type CallType int
func (CallType) String ¶
String method for CallType type converts integer to human-readable status
See http://synctech.com.au/wp-content/uploads/2017/12/calls.xsl
Type: 1 = Incoming, 2 = Outgoing, 3 = Missed, 4 = Voicemail, 5 = Rejected, 6 = Refused List
type Calls ¶
type Calls struct { XMLName xml.Name `xml:"calls"` Count string `xml:"count,attr"` BackupSet string `xml:"backup_set,attr"` BackupDate AndroidTS `xml:"backup_date,string,attr"` Calls []Call `xml:"call"` }
func (*Calls) PrintCallCountQC ¶
func (c *Calls) PrintCallCountQC()
PrintCallCountQC performs basic count validation and prints the results to stdout.
type MMS ¶
type MMS struct { XMLName xml.Name `xml:"mms"` TextOnly BoolValue `xml:"text_only,string,attr"` Read ReadStatus `xml:"read,string,attr"` Date int `xml:"date,attr"` Locked BoolValue `xml:"locked,string,attr"` DateSent AndroidTS `xml:"date_sent,string,attr"` ReadableDate string `xml:"readable_date,attr"` ContactName string `xml:"contact_name,attr"` Seen BoolValue `xml:"seen,string,attr"` FromAddress PhoneNumber `xml:"from_address,string,attr"` Address PhoneNumber `xml:"address,string,attr"` MessageClassifier string `xml:"m_cls,attr"` MessageSize string `xml:"m_size,attr"` Parts []Part `xml:"parts>part"` Addresses []Address `xml:"addrs>addr"` }
type Messages ¶
type Messages struct { XMLName xml.Name `xml:"smses"` Count string `xml:"count,attr"` BackupSet string `xml:"backup_set,attr"` BackupDate AndroidTS `xml:"backup_date,string,attr"` SMS []SMS `xml:"sms"` MMS []MMS `xml:"mms"` }
func (*Messages) PrintMessageCountQC ¶
func (m *Messages) PrintMessageCountQC()
PrintMessageCountQC performs basic count validation and prints the results to stdout.
type Part ¶
type Part struct { XMLName xml.Name `xml:"part"` ContentType string `xml:"ct,attr"` Name string `xml:"name,attr"` FileName string `xml:"fn,attr"` ContentDisplay string `xml:"cd,attr"` Text string `xml:"text,attr"` Base64Data string `xml:"data,attr"` }
func (Part) DecodeAndWriteImage ¶
DecodeAndWriteImage decodes and writes base64-encoded image to file output path specified as parameter.
type PhoneNumber ¶
type PhoneNumber string
func (PhoneNumber) String ¶
func (p PhoneNumber) String() string
String method for PhoneNumber type attempts to normalize phone number by calling NormalizePhoneNumber().
type ReadStatus ¶
type ReadStatus int
func (ReadStatus) String ¶
func (rs ReadStatus) String() string
String method for ReadStatus type converts integer/boolean to human-readable read status
See http://synctech.com.au/fields-in-xml-backup-files/
Read: Read Message = 1, Unread Message = 0
type SMS ¶
type SMS struct { XMLName xml.Name `xml:"sms"` Protocol string `xml:"protocol,attr"` Address PhoneNumber `xml:"address,string,attr"` Type SMSMessageType `xml:"type,string,attr"` Subject string `xml:"subject,attr"` Body string `xml:"body,attr"` ServiceCenter PhoneNumber `xml:"service_center,string,attr"` Status SMSStatus `xml:"status,string,attr"` Read ReadStatus `xml:"read,string,attr"` Date AndroidTS `xml:"date,string,attr"` // consider reading in as int Locked BoolValue `xml:"locked,string,attr"` DateSent AndroidTS `xml:"date_sent,string,attr"` ReadableDate string `xml:"readable_date,attr"` ContactName string `xml:"contact_name,attr"` }
type SMSMessageType ¶
type SMSMessageType int
func (SMSMessageType) String ¶
func (smt SMSMessageType) String() string
String method for SMSMessageType type converts integer to human-readable message type
See http://synctech.com.au/fields-in-xml-backup-files/
Type: 1 = Received, 2 = Sent, 3 = Draft, 4 = Outbox, 5 = Failed, 6 = Queued