Skip to content

Commit

Permalink
Added ZWIDGETSNIPPET column to AppleNote objects and included it in H…
Browse files Browse the repository at this point in the history
…TML, CSV, and JSON outputs.
  • Loading branch information
threeplanetssoftware committed Dec 19, 2024
1 parent 1be02e6 commit 2e7a3d8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
18 changes: 17 additions & 1 deletion lib/AppleNote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class AppleNote < AppleCloudKitRecord
:cloudkit_modify_device,
:notestore,
:is_pinned,
:uuid
:uuid,
:widget_snippet

##
# Creates a new AppleNote. Expects an Integer +z_pk+, an Integer +znote+ representing the ZICNOTEDATA.ZNOTE field,
Expand All @@ -97,6 +98,7 @@ def initialize(z_pk, znote, ztitle, zdata, creation_time, modify_time, account,
@plaintext = nil
@decompressed_data = nil
@encrypted_data = nil
@widget_snippet = nil
@note_proto = nil
@crypto_iv = nil
@crypto_tag = nil
Expand Down Expand Up @@ -224,6 +226,7 @@ def self.to_csv_headers
"Creation Time",
"Modify Time",
"Note Plaintext",
"Widget Snippet",
"Is Password protected",
"Crypto Interations",
"Crypto Salt (hex)",
Expand Down Expand Up @@ -254,6 +257,7 @@ def to_csv
@creation_time,
@modify_time,
@plaintext,
@widget_snippet,
@is_password_protected,
@crypto_iterations,
get_crypto_salt_hex,
Expand Down Expand Up @@ -554,6 +558,17 @@ def generate_html(individual_files: false, use_uuid: false)
}
end

if @widget_snippet
doc.div {
doc.b {
doc.text "Widget Snippet:"
}

doc.text " "
doc.text @widget_snippet
}
end

doc.div(class: "note-content") {
# Handle the text to insert, only if we have plaintext to run
if @plaintext
Expand Down Expand Up @@ -714,6 +729,7 @@ def prepare_json
to_return[:is_password_protected] = @is_password_protected
to_return[:title] = @title
to_return[:plaintext] = @plaintext if @plaintext
to_return[:widget_snippet] = @widget_snippet if @widget_snippet
to_return[:html] = generate_html
to_return[:note_proto] = @note_proto if @note_proto

Expand Down
11 changes: 10 additions & 1 deletion lib/AppleNoteStore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,10 @@ def rip_note(note_id)
server_share_column = "ZSERVERSHARE"
server_share_column = server_share_column + "DATA" if @version >= AppleNoteStoreVersion::IOS_VERSION_12 # In iOS 11 this was ZSERVERRECORD, in 12 and later it became ZSERVERRECORDDATA

# Set the ZWIDGETSNIPPET column, blank if earlier than iOS 17
widget_snippet_column = ""
widget_snippet_column = ", ZWIDGETSNIPPET" if @version >= AppleNoteStoreVersion::IOS_VERSION_17

# Set the ZUNAPPLIEDENCRYPTEDRECORD column to look at
unapplied_encrypted_record_column = "ZUNAPPLIEDENCRYPTEDRECORD"
unapplied_encrypted_record_column = unapplied_encrypted_record_column + "DATA" if @version >= AppleNoteStoreVersion::IOS_VERSION_18 # In iOS 17 this was ZUNAPPLIEDENCRYPTEDRECORD, in 18 and later it becomes ZUNAPPLIEDENCRYPTEDRECORDDATA
Expand Down Expand Up @@ -751,7 +755,7 @@ def rip_note(note_id)
"ZICCLOUDSYNCINGOBJECT.ZACCOUNT2, ZICCLOUDSYNCINGOBJECT.#{folder_field}, " +
"ZICCLOUDSYNCINGOBJECT.#{server_record_column}, ZICCLOUDSYNCINGOBJECT.#{unapplied_encrypted_record_column}, " +
"ZICCLOUDSYNCINGOBJECT.#{server_share_column}, ZICCLOUDSYNCINGOBJECT.ZISPINNED, " +
"ZICCLOUDSYNCINGOBJECT.ZIDENTIFIER " +
"ZICCLOUDSYNCINGOBJECT.ZIDENTIFIER #{widget_snippet_column} " +
"FROM ZICNOTEDATA, ZICCLOUDSYNCINGOBJECT " +
"WHERE ZICNOTEDATA.ZNOTE=? AND ZICCLOUDSYNCINGOBJECT.Z_PK=ZICNOTEDATA.ZNOTE"

Expand Down Expand Up @@ -831,6 +835,11 @@ def rip_note(note_id)
tmp_note.uuid = row["ZIDENTIFIER"]
end

# Set the widget snippet, if it exists
if row["ZWIDGETSNIPPET"]
tmp_note.widget_snippet = row["ZWIDGETSNIPPET"]
end

tmp_account.add_note(tmp_note) if tmp_account
tmp_folder.add_note(tmp_note) if tmp_folder

Expand Down

0 comments on commit 2e7a3d8

Please sign in to comment.