Skip to content

Commit 2e7a3d8

Browse files
Added ZWIDGETSNIPPET column to AppleNote objects and included it in HTML, CSV, and JSON outputs.
1 parent 1be02e6 commit 2e7a3d8

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

lib/AppleNote.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ class AppleNote < AppleCloudKitRecord
8181
:cloudkit_modify_device,
8282
:notestore,
8383
:is_pinned,
84-
:uuid
84+
:uuid,
85+
:widget_snippet
8586

8687
##
8788
# Creates a new AppleNote. Expects an Integer +z_pk+, an Integer +znote+ representing the ZICNOTEDATA.ZNOTE field,
@@ -97,6 +98,7 @@ def initialize(z_pk, znote, ztitle, zdata, creation_time, modify_time, account,
9798
@plaintext = nil
9899
@decompressed_data = nil
99100
@encrypted_data = nil
101+
@widget_snippet = nil
100102
@note_proto = nil
101103
@crypto_iv = nil
102104
@crypto_tag = nil
@@ -224,6 +226,7 @@ def self.to_csv_headers
224226
"Creation Time",
225227
"Modify Time",
226228
"Note Plaintext",
229+
"Widget Snippet",
227230
"Is Password protected",
228231
"Crypto Interations",
229232
"Crypto Salt (hex)",
@@ -254,6 +257,7 @@ def to_csv
254257
@creation_time,
255258
@modify_time,
256259
@plaintext,
260+
@widget_snippet,
257261
@is_password_protected,
258262
@crypto_iterations,
259263
get_crypto_salt_hex,
@@ -554,6 +558,17 @@ def generate_html(individual_files: false, use_uuid: false)
554558
}
555559
end
556560

561+
if @widget_snippet
562+
doc.div {
563+
doc.b {
564+
doc.text "Widget Snippet:"
565+
}
566+
567+
doc.text " "
568+
doc.text @widget_snippet
569+
}
570+
end
571+
557572
doc.div(class: "note-content") {
558573
# Handle the text to insert, only if we have plaintext to run
559574
if @plaintext
@@ -714,6 +729,7 @@ def prepare_json
714729
to_return[:is_password_protected] = @is_password_protected
715730
to_return[:title] = @title
716731
to_return[:plaintext] = @plaintext if @plaintext
732+
to_return[:widget_snippet] = @widget_snippet if @widget_snippet
717733
to_return[:html] = generate_html
718734
to_return[:note_proto] = @note_proto if @note_proto
719735

lib/AppleNoteStore.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,10 @@ def rip_note(note_id)
717717
server_share_column = "ZSERVERSHARE"
718718
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
719719

720+
# Set the ZWIDGETSNIPPET column, blank if earlier than iOS 17
721+
widget_snippet_column = ""
722+
widget_snippet_column = ", ZWIDGETSNIPPET" if @version >= AppleNoteStoreVersion::IOS_VERSION_17
723+
720724
# Set the ZUNAPPLIEDENCRYPTEDRECORD column to look at
721725
unapplied_encrypted_record_column = "ZUNAPPLIEDENCRYPTEDRECORD"
722726
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
@@ -751,7 +755,7 @@ def rip_note(note_id)
751755
"ZICCLOUDSYNCINGOBJECT.ZACCOUNT2, ZICCLOUDSYNCINGOBJECT.#{folder_field}, " +
752756
"ZICCLOUDSYNCINGOBJECT.#{server_record_column}, ZICCLOUDSYNCINGOBJECT.#{unapplied_encrypted_record_column}, " +
753757
"ZICCLOUDSYNCINGOBJECT.#{server_share_column}, ZICCLOUDSYNCINGOBJECT.ZISPINNED, " +
754-
"ZICCLOUDSYNCINGOBJECT.ZIDENTIFIER " +
758+
"ZICCLOUDSYNCINGOBJECT.ZIDENTIFIER #{widget_snippet_column} " +
755759
"FROM ZICNOTEDATA, ZICCLOUDSYNCINGOBJECT " +
756760
"WHERE ZICNOTEDATA.ZNOTE=? AND ZICCLOUDSYNCINGOBJECT.Z_PK=ZICNOTEDATA.ZNOTE"
757761

@@ -831,6 +835,11 @@ def rip_note(note_id)
831835
tmp_note.uuid = row["ZIDENTIFIER"]
832836
end
833837

838+
# Set the widget snippet, if it exists
839+
if row["ZWIDGETSNIPPET"]
840+
tmp_note.widget_snippet = row["ZWIDGETSNIPPET"]
841+
end
842+
834843
tmp_account.add_note(tmp_note) if tmp_account
835844
tmp_folder.add_note(tmp_note) if tmp_folder
836845

0 commit comments

Comments
 (0)