11
11
public class CalendarFolder extends Folder {
12
12
13
13
private java .util .HashSet <FieldURI > props = new java .util .HashSet <FieldURI >();
14
+ private Connection conn ;
14
15
15
16
//**************************************************************************
16
17
//** Constructor
@@ -20,6 +21,7 @@ public class CalendarFolder extends Folder {
20
21
public CalendarFolder (Connection conn ) throws ExchangeException {
21
22
super ("calendar" , conn );
22
23
props .add (new FieldURI ("calendar:TimeZone" ));
24
+ this .conn = conn ;
23
25
}
24
26
25
27
/*
@@ -57,7 +59,7 @@ public CalendarEvent[] getEvents(int offset, int limit) throws ExchangeException
57
59
org .w3c .dom .Node [] nodes = javaxt .xml .DOM .getElementsByTagName ("CalendarItem" , xml );
58
60
59
61
for (org .w3c .dom .Node node : nodes ){
60
- events .add (new CalendarEvent (node ));
62
+ events .add (new CalendarEvent (node , conn ));
61
63
}
62
64
return events .toArray (new CalendarEvent [events .size ()]);
63
65
}
@@ -122,17 +124,167 @@ public CalendarEvent[] getEvents(javaxt.utils.Date start, javaxt.utils.Date end)
122
124
org .w3c .dom .Node [] nodes = javaxt .xml .DOM .getElementsByTagName ("CalendarItem" , xml );
123
125
124
126
for (org .w3c .dom .Node node : nodes ){
125
- CalendarEvent event = new CalendarEvent (node );
127
+ CalendarEvent event = new CalendarEvent (node , conn );
126
128
if (event .isAllDayEvent () && event .getStartTime ().compareTo (start , "days" )==-1 ){
127
129
128
130
}
129
131
else {
130
- events .add (new CalendarEvent (node ));
132
+ events .add (new CalendarEvent (node , conn ));
131
133
}
132
134
}
133
135
134
136
135
137
136
138
return events .toArray (new CalendarEvent [events .size ()]);
137
139
}
140
+
141
+
142
+
143
+ /*
144
+ public void sendSharingRequest(Mailbox recipient, Mailbox sender, Connection conn) throws ExchangeException {
145
+
146
+ if (true) throw new ExchangeException("not implemented");
147
+
148
+
149
+ javaxt.exchange.Email email = new javaxt.exchange.Email();
150
+ email.setSubject("I'd like to share my calendar with you");
151
+ email.setBody("<div style=\"color:blue;\"><span>Do you see this in blue?</div>", "HTML");
152
+ email.addRecipient("To", recipient);
153
+ email.setMessageClass("IPM.Sharing"); //"PidTagMessageClass", "IPM.Sharing"
154
+ //email.setMessageType("Sharing"); //"PidNameContentClass", "Sharing"
155
+
156
+
157
+ //Create attachment
158
+ StringBuffer str = new StringBuffer();
159
+ str.append("<?xml version=\"1.0\"?>");
160
+ str.append("<SharingMessage xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ");
161
+ str.append("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" ");
162
+ str.append("xmlns=\"http://schemas.microsoft.com/sharing/2008\">");
163
+ str.append("<DataType>calendar</DataType>");
164
+ str.append("<Initiator>");
165
+ str.append("<Name>" + sender.getName() + "</Name>");
166
+ str.append("<SmtpAddress>" + sender.getEmailAddress() + "</SmtpAddress>");
167
+ //str.append("<EntryId>" + sender.getEntryID() + "</EntryId>");
168
+ str.append("</Initiator>");
169
+ str.append("<Invitation>");
170
+ str.append("<Providers>");
171
+ str.append("<Provider Type=\"ms-exchange-internal\" TargetRecipients=\"" + recipient.getEmailAddress() + "\">");
172
+ str.append("<FolderId xmlns=\"http://schemas.microsoft.com/exchange/sharing/2008\">");
173
+ str.append(this.getID());
174
+ str.append("</FolderId>");
175
+ str.append("<MailboxId xmlns=\"http://schemas.microsoft.com/exchange/sharing/2008\">");
176
+ str.append(sender.getID());
177
+ str.append("</MailboxId>");
178
+ str.append("</Provider>");
179
+ str.append("</Providers>");
180
+ str.append("</Invitation>");
181
+ str.append("</SharingMessage>");
182
+ //email.addAttachment(str.toString());
183
+
184
+
185
+
186
+ java.util.HashMap<String, String> headers = new java.util.HashMap<String, String>();
187
+
188
+
189
+
190
+ // X-MS-Exchange-Organization-AuthAs: Internal
191
+ // X-MS-Exchange-Organization-AuthMechanism: 04
192
+ // X-MS-Exchange-Organization-AuthSource: exchange2010.example.com
193
+ // X-MS-Has-Attach: yes
194
+ // X-MS-Exchange-Organization-SCL: -1
195
+ // X-MS-TNEF-Correlator:
196
+ // x-sharing-capabilities: 402B0
197
+ // x-sharing-flavor: 310
198
+ // x-sharing-provider-guid: AEF0060000000000C000000000000046
199
+ // x-sharing-provider-name: Microsoft Exchange
200
+ // x-sharing-provider-url: http://www.microsoft.com/exchange/
201
+ // x-sharing-remote-path:
202
+ // x-sharing-remote-name: =?iso-8859-1?Q?Jane=B4s_her_share_calendar?=
203
+ // x-sharing-remote-uid: 00000000BC5AB69D4370454FB480A15DB2A7E93C0100DCB29F06B087BB439B542470E7A5D6E300002DAFEAEA0000
204
+ // x-sharing-remote-store-uid: 0000000038A1BB1005E5101AA1BB08002B2A56C20000454D534D44422E444C4C00000000000000001B55FA20AA6611CD9BC800AA002FC45A0C00000045584348414E474532303130002F6F3D4669727374204F7267616E697A6174696F6E2F6F753D45786368616E67652041646D696E6973747261746976652047726F7570202846594449424F484632335350444C54292F636E3D526563697069656E74732F636E3D4A616E6520446F6534633900
205
+ // x-sharing-remote-type: IPF.Appointment
206
+
207
+
208
+
209
+ // Section 2.2.2
210
+ headers.put("x-sharing-capabilities", "40290"); //Test representation of SharingCapabilities value
211
+ headers.put("x-sharing-flavor", "20310"); //Text representation of SharingFlavor value [MS-OXSHARE] 2.2.2.6
212
+
213
+
214
+
215
+ headers.put("x-sharing-local-type", "IPF.Appointment"); //MUST be set to same value as PidLidSharingLocalType
216
+ headers.put("x-sharing-provider-guid", "AEF0060000000000C000000000000046"); //Constant Required Value [MS-OXSHARE] 2.2.2.13
217
+ headers.put("x-sharing-provider-name", "Microsoft Exchange"); //Constant Required Value [MS-OXSHARE] 2.2.2.15]
218
+ headers.put("x-sharing-provider-url", "HTTP://www.microsoft.com/exchange"); //Constant Required Value [MS-OXSHARE] 2.2.2.17
219
+
220
+ // Section 2.2.3
221
+ headers.put("x-sharing-remote-name", "Calendar"); //MUST be set to same value as PidLidSharingRemoteName
222
+ headers.put("x-sharing-remote-store-uid", sender.getID()); //MUST be set to same value as PidLidSharingRemoteStoreUid
223
+ headers.put("x-sharing-remote-type", "IPF.Appointment"); //Constant Required Value [MS-OXSHARE] 2.2.3.6
224
+ headers.put("x-sharing-remote-uid", this.getID()); //Must be set to same value as PidLidSharingRemoteUid
225
+
226
+
227
+
228
+
229
+
230
+ String action = "SendOnly";
231
+
232
+ //Send the message and create a copy in the "sentitems" folder
233
+ StringBuffer msg = new StringBuffer();
234
+ msg.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
235
+ msg.append("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\" xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\">");
236
+ msg.append("<soap:Body>");
237
+ msg.append("<m:CreateItem MessageDisposition=\"" + action + "\">");
238
+
239
+
240
+
241
+ msg.append("<m:SavedItemFolderId>");
242
+
243
+ String folderName = "drafts";
244
+ if (action.equals("SendOnly") || action.equals("SendAndSaveCopy")) folderName = "sentitems";
245
+ msg.append("<t:DistinguishedFolderId Id=\"" + folderName + "\" />");
246
+
247
+ msg.append("</m:SavedItemFolderId>");
248
+ msg.append("<m:Items>");
249
+
250
+
251
+
252
+
253
+ String messageType = "Message";
254
+
255
+ msg.append("<t:" + messageType + ">");
256
+ msg.append("<t:ItemClass>" + email.getMessageClass() + "</t:ItemClass>"); //<--New for sharing requests
257
+ msg.append("<t:Subject>" + email.getSubject() + "</t:Subject>");
258
+ msg.append("<t:Sensitivity>" + email.getSensitivity() + "</t:Sensitivity>");
259
+
260
+
261
+ //Set body
262
+ if (email.getBody()!=null){
263
+ msg.append("<t:Body BodyType=\"" + email.getBodyType() + "\">");
264
+ //msg.append(wrap(body));
265
+ msg.append("</t:Body>");
266
+ };
267
+
268
+
269
+ msg.append("<t:Importance>" + email.getImportance() + "</t:Importance>");
270
+
271
+
272
+ msg.append("<t:ToRecipients>");
273
+ msg.append(recipient.toXML("t"));
274
+ msg.append("</t:ToRecipients>");
275
+
276
+
277
+ msg.append("</t:" + messageType + ">");
278
+
279
+
280
+
281
+ msg.append("</m:Items>");
282
+ msg.append("</m:CreateItem>");
283
+ msg.append("</soap:Body>");
284
+ msg.append("</soap:Envelope>");
285
+
286
+ conn.execute(msg.toString(), headers);
287
+
288
+ }
289
+ */
138
290
}
0 commit comments