Repository navigation
Expand file tree
/
Copy pathCODING
More file actions
178 lines (131 loc) · 7.38 KB
/
Copy pathCODING
File metadata and controls
178 lines (131 loc) · 7.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
Every Mail.app method which is to be swizzled, has to be prefixed
with MA (MailApp).
There's a folder in Resources which is called old. This folder
is used to diff the a modified xib with the latest xib.
It's used for localizeXIB.
DON'T EVER DELETE THIS FOLDER!
* Reverse Engineering *
- Sometimes it's not to easy to find out what happens to an
object you created. In that case you can over release it,
using autorelease or release. This way, the object will be
ending up an NSZombie, which can later be tracked using Instruments
allocation tool. (VERY HELPFUL)
- clearCachedDecrypted is called everytime the message is unlodaed.
we should better cache it.
- Mail internally seems to use firstChildPart to determine the charset of the message.
- Log all messages -> instrumentObjcMessageSends(YES) writes to /tmp/msgSends-
_getSomeCharsetFromPartTree -> exists only internally
- -[Message setNumberOfAttachments:isSigned:isEncrypted:] is only called for
encrypted messages, strangely enough.
Still have to find out what usually sets the number.
Mail.app uses -[MessageStore setNumberOfAttachments:isSigned:isEncrypted:forMessage:] to set the number
of attachments for every message, but this is only called when the message comes in
and never touched again, except for encrypted messages.
So to always work, GPGMail forces Mail.app to update the number for every message, each time
it's parsed or the number is different, by recalculating the number.
* Committing *
- Always use git -p <filename>. This let's you decide for each file
what lines should be added to a commit.
- Use this to create commits which only fix one problem at a time.
* Other *
- Mail.app comes with a lot of general class enhancements. It's best to look
them through to find helpful ones.
@interface NSData (MessageAdditions)
- (id)initWithDataConvertingLineEndingsFromUnixToNetwork:(id)arg1;
- (id)initWithDataConvertingLineEndingsFromNetworkToUnix:(id)arg1;
- (id)dataByConvertingLineEndingsFromUnixToNetwork;
// To detect if the data contains real message headers.
- (struct _NSRange)rangeOfRFC822HeaderData;
* Data Detectors *
<
8000
/div>
- Extremely hard to implement native ones.
- Enabling Javascript in WebViews works
[[WebView preferences] setJavaScriptEnabled:YES]
- Using Javascript to emulate the bevaiour might be rather easy.
* Mountain Lion *
- MimePart, MimeBody and other very important classes from Message.framework
are now in CoreMessage.framework
- MessageStore does no longer exist but was replaced by MessageDataSource.
- On Mountain Lion compiled GPGMail doesn't load, where on Lion compiled GPGMail loads
- Check Framework dependencies.
- Update Header files for Mountain Lion
* OpenPGP | S/MIME co-existence
1.) A new message (not reply) is created check if the there's a key for signing
for the address in either OpenPGP or S/MIME. Choose the method to enable accordingly.
If there are keys for either method, check the entries which method was last used
to sign with this key.
If again both methods are found check which was used more often.
Once a user changes the method manually, NEVER automatically manipulate that
choice again.
[ComposeBackEnd type] defines whether the message is replied|forwared|replied-to-all|new
- 5 -> New message
- 1 -> Reply
- 2 -> Reply to all
- 3 -> Forward
- 4 -> Reply to already open mesage? (Mail.app was closed with this reply open and it's restored.)
once a user enters addresses a dictionary is checked to see if the last time
the user sent to these addresses decided to encrypt or not and sets that status.
If no message was sent yet to that user, don't encrypt.
If there's one key for signing for each method but the recipients can only be found for one encryption method
automatically select that encryption method.
If a user replies to a message, check if the message was signed and set signed.
If a user replies to a message, check if the message was encrypted and set encrypted.
Don't set something which the old message was not.
User defaults should look like this
[address][sign][SMIME][addresses][did-sign] = counter
[address][sign][PGP][addresses][did-not-sign] = counter
[address][sign][addresses][last-used-method] = 'SMIME' | 'PGP'
[address][sign][addresses][last-status] = 'did sign' | 'did not sign'
[address][encrypt][SMIME][addresses][did-encrypt] = counter
[address][encrypt][PGP][addresses][did-not-encrypt] = counter
[address][encrypt][addresses][last-used-method] = 'SMIME' | 'PGP'
[address][encrypt][addresses][last-status] = 'did encrypt' | 'did not encrypt'
* Indexing encrypted messages
Message.h
- (id)stringForIndexing;
- (id)stringForIndexingUpdatingBodyFlags:(BOOL)arg1;
might be relevant.
* Access struct instance variables of Mail Classes *
Copy the struct definition you want to use into your header file
using a typedef. After that you can access the struct data using the following
code.
StructType structVar;
object_getInstanceVariable(self, "<instance-variable-name>", (void **)&structVar);
Very nice!
* XPC Services for sandboxed Mail.app >= 10.8 *
Bad Apple which really doesn't like plugins for Mail.app has disabled mach lookup names
for Mail.app
Our XPC Service has to use a mach name since it's running as a launchd item instead
as part of an app (otherwise it would have to live inside Mail.app and we certainly
don't want to mess with that!).
BUT fortunately for us, Apple has introduced an two exceptions for mach lookup names.
One can be found in the file /System/Library/Sandbox/Profiles/application.sb (which contains
the rules which are evaluated for each available entitlement) and one can be found
in the entitlements Mail.app is signed with directly.
Use "codesign --display --entitlements - /Applications/Mail.app" to display the available
entitlements and check for "mach-lookup" to find interesting ones.
In the application.sb file there's a mach-lookup allow rule, which allows every app to lookup
mach services which end in _OpenStep.
Mail.app's entitlements allow every mach service which only has numbers as its name.
So as long as Apple doesn't remove these rules and our xpc service has a matching name
we're mighty mighty fine :)!
* Additional documentation for NSXPCConnection *
NSXPCConnection invokes error, interruption or invalidation handlers
for specific errors which are documented, but as not much as one would want.
This is a list of all the available handlers and when they are invoked:
- invalidationHandler:
- invoked when there's a problem establishing a connection:
- the xpc service was unloaded or is being unloaded while a message
is waiting for a response
- the xpc service is not loaded at all -> in that case it's invoked
immediately after calling resume.
- remoteObjectProxy errorHandler:
- when the xpc service crashes (e.g. overrelease or other BAD EXC failure in the xpc service)
- when the xpc service is killed (also with -9)
- when the xpc service is unloaded with `launchctl unload`
- when the xpc service is unloaded with `launchctl remove`
- interruptionHandler:
- when the connection was already invalidated (call to invalidate)
and the xpc service is killed.
- everytime remoteObjectProxy errorHandler is invoked.
* Class weak linking for Mavericks *
http://www.sealiesoftware.com/blog/archive/2010/4/8/Do-it-yourself_Objective-C_weak_import.html