2 * e-editor-web-extension.c
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with the program; if not, see <http://www.gnu.org/licenses/>
19 #include "evolution-config.h"
23 #include <glib/gstdio.h>
26 #include <webkit2/webkit-web-extension.h>
27 #include <camel/camel.h>
29 #include <webkitdom/webkitdom.h>
31 #include "web-extensions/e-dom-utils.h"
33 #include "e-editor-page.h"
34 #include "e-composer-dom-functions.h"
35 #include "e-dialogs-dom-functions.h"
36 #include "e-editor-dom-functions.h"
37 #include "e-editor-undo-redo-manager.h"
39 #include "e-editor-web-extension.h"
41 #define E_EDITOR_WEB_EXTENSION_GET_PRIVATE(obj) \
42 (G_TYPE_INSTANCE_GET_PRIVATE \
43 ((obj), E_TYPE_EDITOR_WEB_EXTENSION, EEditorWebExtensionPrivate))
45 struct _EEditorWebExtensionPrivate
{
46 WebKitWebExtension
*wk_extension
;
48 GDBusConnection
*dbus_connection
;
49 guint registration_id
;
51 GHashTable
*editor_pages
; /* guint64 *webpage_id ~> EEditorPage * */
54 static CamelDataCache
*emd_global_http_cache
= NULL
;
56 static const gchar
*introspection_xml
=
58 " <interface name='" E_WEBKIT_EDITOR_WEB_EXTENSION_INTERFACE
"'>"
59 "<!-- ********************************************************* -->"
61 "<!-- ********************************************************* -->"
62 " <signal name='SelectionChanged'>"
63 " <arg type='t' name='page_id' direction='out'/>"
64 " <arg type='i' name='alignment' direction='out'/>"
65 " <arg type='i' name='block_format' direction='out'/>"
66 " <arg type='b' name='indented' direction='out'/>"
67 " <arg type='i' name='style_flags' direction='out'/>"
68 " <arg type='i' name='font_size' direction='out'/>"
69 " <arg type='s' name='font_color' direction='out'/>"
71 " <signal name='ContentChanged'>"
72 " <arg type='t' name='page_id' direction='out'/>"
74 " <signal name='UndoRedoStateChanged'>"
75 " <arg type='t' name='page_id' direction='out'/>"
76 " <arg type='b' name='can_undo' direction='out'/>"
77 " <arg type='b' name='can_redo' direction='out'/>"
79 " <signal name='UserChangedDefaultColors'>"
80 " <arg type='b' name='suppress_color_changes' direction='out'/>"
82 "<!-- ********************************************************* -->"
84 "<!-- ********************************************************* -->"
85 "<!-- ********************************************************* -->"
86 "<!-- FOR TESTING ONLY -->"
87 "<!-- ********************************************************* -->"
88 " <method name='TestHTMLEqual'>"
89 " <arg type='t' name='page_id' direction='in'/>"
90 " <arg type='s' name='html1' direction='in'/>"
91 " <arg type='s' name='html2' direction='in'/>"
92 " <arg type='b' name='equal' direction='out'/>"
94 "<!-- ********************************************************* -->"
96 "<!-- ********************************************************* -->"
97 " <method name='ElementHasAttribute'>"
98 " <arg type='t' name='page_id' direction='in'/>"
99 " <arg type='s' name='element_id' direction='in'/>"
100 " <arg type='s' name='attribute' direction='in'/>"
101 " <arg type='b' name='has_attribute' direction='out'/>"
103 " <method name='ElementGetAttribute'>"
104 " <arg type='t' name='page_id' direction='in'/>"
105 " <arg type='s' name='element_id' direction='in'/>"
106 " <arg type='s' name='attribute' direction='in'/>"
107 " <arg type='s' name='value' direction='out'/>"
109 " <method name='ElementGetAttributeBySelector'>"
110 " <arg type='t' name='page_id' direction='in'/>"
111 " <arg type='s' name='selector' direction='in'/>"
112 " <arg type='s' name='attribute' direction='in'/>"
113 " <arg type='s' name='value' direction='out'/>"
115 " <method name='ElementRemoveAttribute'>"
116 " <arg type='t' name='page_id' direction='in'/>"
117 " <arg type='s' name='element_id' direction='in'/>"
118 " <arg type='s' name='attribute' direction='in'/>"
120 " <method name='ElementRemoveAttributeBySelector'>"
121 " <arg type='t' name='page_id' direction='in'/>"
122 " <arg type='s' name='selector' direction='in'/>"
123 " <arg type='s' name='attribute' direction='in'/>"
125 " <method name='ElementSetAttribute'>"
126 " <arg type='t' name='page_id' direction='in'/>"
127 " <arg type='s' name='element_id' direction='in'/>"
128 " <arg type='s' name='attribute' direction='in'/>"
129 " <arg type='s' name='value' direction='in'/>"
131 " <method name='ElementSetAttributeBySelector'>"
132 " <arg type='t' name='page_id' direction='in'/>"
133 " <arg type='s' name='selector' direction='in'/>"
134 " <arg type='s' name='attribute' direction='in'/>"
135 " <arg type='s' name='value' direction='in'/>"
137 " <method name='ElementGetTagName'>"
138 " <arg type='t' name='page_id' direction='in'/>"
139 " <arg type='s' name='element_id' direction='in'/>"
140 " <arg type='s' name='tag_name' direction='out'/>"
142 "<!-- ********************************************************* -->"
143 "<!-- Functions that are specific to composer -->"
144 "<!-- ********************************************************* -->"
145 " <method name='RemoveImageAttributesFromElementBySelector'>"
146 " <arg type='t' name='page_id' direction='in'/>"
147 " <arg type='s' name='selector' direction='in'/>"
149 "<!-- ********************************************************* -->"
150 "<!-- Functions that are used in EEditorCellDialog -->"
151 "<!-- ********************************************************* -->"
152 " <method name='EEditorCellDialogMarkCurrentCellElement'>"
153 " <arg type='t' name='page_id' direction='in'/>"
154 " <arg type='s' name='element_id' direction='in'/>"
156 " <method name='EEditorCellDialogSaveHistoryOnExit'>"
157 " <arg type='t' name='page_id' direction='in'/>"
159 " <method name='EEditorCellDialogSetElementVAlign'>"
160 " <arg type='t' name='page_id' direction='in'/>"
161 " <arg type='s' name='value' direction='in'/>"
162 " <arg type='i' name='scope' direction='in'/>"
164 " <method name='EEditorCellDialogSetElementAlign'>"
165 " <arg type='t' name='page_id' direction='in'/>"
166 " <arg type='s' name='value' direction='in'/>"
167 " <arg type='i' name='scope' direction='in'/>"
169 " <method name='EEditorCellDialogSetElementNoWrap'>"
170 " <arg type='t' name='page_id' direction='in'/>"
171 " <arg type='b' name='value' direction='in'/>"
172 " <arg type='i' name='scope' direction='in'/>"
174 " <method name='EEditorCellDialogSetElementHeaderStyle'>"
175 " <arg type='t' name='page_id' direction='in'/>"
176 " <arg type='b' name='value' direction='in'/>"
177 " <arg type='i' name='scope' direction='in'/>"
179 " <method name='EEditorCellDialogSetElementWidth'>"
180 " <arg type='t' name='page_id' direction='in'/>"
181 " <arg type='s' name='value' direction='in'/>"
182 " <arg type='i' name='scope' direction='in'/>"
184 " <method name='EEditorCellDialogSetElementColSpan'>"
185 " <arg type='t' name='page_id' direction='in'/>"
186 " <arg type='i' name='value' direction='in'/>"
187 " <arg type='i' name='scope' direction='in'/>"
189 " <method name='EEditorCellDialogSetElementRowSpan'>"
190 " <arg type='t' name='page_id' direction='in'/>"
191 " <arg type='i' name='value' direction='in'/>"
192 " <arg type='i' name='scope' direction='in'/>"
194 " <method name='EEditorCellDialogSetElementBgColor'>"
195 " <arg type='t' name='page_id' direction='in'/>"
196 " <arg type='s' name='value' direction='in'/>"
197 " <arg type='i' name='scope' direction='in'/>"
199 "<!-- ********************************************************* -->"
200 "<!-- Functions that are used in EEditorHRuleDialog -->"
201 "<!-- ********************************************************* -->"
202 " <method name='EEditorHRuleDialogFindHRule'>"
203 " <arg type='t' name='page_id' direction='in'/>"
204 " <arg type='b' name='created_new_hr' direction='out'/>"
206 " <method name='EEditorHRuleDialogOnClose'>"
207 " <arg type='t' name='page_id' direction='in'/>"
209 "<!-- ********************************************************* -->"
210 "<!-- Functions that are used in EEditorImageDialog -->"
211 "<!-- ********************************************************* -->"
212 " <method name='EEditorImageDialogMarkImage'>"
213 " <arg type='t' name='page_id' direction='in'/>"
215 " <method name='EEditorImageDialogSaveHistoryOnExit'>"
216 " <arg type='t' name='page_id' direction='in'/>"
218 " <method name='EEditorImageDialogSetElementUrl'>"
219 " <arg type='t' name='page_id' direction='in'/>"
220 " <arg type='s' name='value' direction='in'/>"
222 " <method name='EEditorImageDialogGetElementUrl'>"
223 " <arg type='t' name='page_id' direction='in'/>"
224 " <arg type='s' name='value' direction='out'/>"
226 " <method name='ImageElementSetWidth'>"
227 " <arg type='t' name='page_id' direction='in'/>"
228 " <arg type='s' name='element_id' direction='in'/>"
229 " <arg type='i' name='value' direction='in'/>"
231 " <method name='ImageElementGetWidth'>"
232 " <arg type='t' name='page_id' direction='in'/>"
233 " <arg type='s' name='element_id' direction='in'/>"
234 " <arg type='i' name='value' direction='out'/>"
236 " <method name='ImageElementSetHeight'>"
237 " <arg type='t' name='page_id' direction='in'/>"
238 " <arg type='s' name='element_id' direction='in'/>"
239 " <arg type='i' name='value' direction='in'/>"
241 " <method name='ImageElementGetHeight'>"
242 " <arg type='t' name='page_id' direction='in'/>"
243 " <arg type='s' name='element_id' direction='in'/>"
244 " <arg type='i' name='value' direction='out'/>"
246 " <method name='ImageElementGetNaturalWidth'>"
247 " <arg type='t' name='page_id' direction='in'/>"
248 " <arg type='s' name='element_id' direction='in'/>"
249 " <arg type='i' name='value' direction='out'/>"
251 " <method name='ImageElementGetNaturalHeight'>"
252 " <arg type='t' name='page_id' direction='in'/>"
253 " <arg type='s' name='element_id' direction='in'/>"
254 " <arg type='i' name='value' direction='out'/>"
256 " <method name='ImageElementSetHSpace'>"
257 " <arg type='t' name='page_id' direction='in'/>"
258 " <arg type='s' name='element_id' direction='in'/>"
259 " <arg type='i' name='value' direction='in'/>"
261 " <method name='ImageElementGetHSpace'>"
262 " <arg type='t' name='page_id' direction='in'/>"
263 " <arg type='s' name='element_id' direction='in'/>"
264 " <arg type='i' name='value' direction='out'/>"
266 " <method name='ImageElementSetVSpace'>"
267 " <arg type='t' name='page_id' direction='in'/>"
268 " <arg type='s' name='element_id' direction='in'/>"
269 " <arg type='i' name='value' direction='in'/>"
271 " <method name='ImageElementGetVSpace'>"
272 " <arg type='t' name='page_id' direction='in'/>"
273 " <arg type='s' name='element_id' direction='in'/>"
274 " <arg type='i' name='value' direction='out'/>"
276 "<!-- ********************************************************* -->"
277 "<!-- Functions that are used in EEditorLinkDialog -->"
278 "<!-- ********************************************************* -->"
279 " <method name='EEditorLinkDialogOk'>"
280 " <arg type='t' name='page_id' direction='in'/>"
281 " <arg type='s' name='url' direction='in'/>"
282 " <arg type='s' name='inner_text' direction='in'/>"
284 " <method name='EEditorLinkDialogShow'>"
285 " <arg type='t' name='page_id' direction='in'/>"
286 " <arg type='s' name='url' direction='out'/>"
287 " <arg type='s' name='inner_text' direction='out'/>"
289 " <method name='EEditorLinkDialogOnOpen'>"
290 " <arg type='t' name='page_id' direction='in'/>"
292 " <method name='EEditorLinkDialogOnClose'>"
293 " <arg type='t' name='page_id' direction='in'/>"
295 " <method name='EEditorLinkDialogUnlink'>"
296 " <arg type='t' name='page_id' direction='in'/>"
298 "<!-- ********************************************************* -->"
299 "<!-- Functions that are used in EEditorPageDialog -->"
300 "<!-- ********************************************************* -->"
301 " <method name='EEditorPageDialogSaveHistory'>"
302 " <arg type='t' name='page_id' direction='in'/>"
304 " <method name='EEditorPageDialogSaveHistoryOnExit'>"
305 " <arg type='t' name='page_id' direction='in'/>"
307 "<!-- ********************************************************* -->"
308 "<!-- Functions that are used in EEditorSpellCheckDialog -->"
309 "<!-- ********************************************************* -->"
310 " <method name='EEditorSpellCheckDialogNext'>"
311 " <arg type='t' name='page_id' direction='in'/>"
312 " <arg type='s' name='word' direction='in'/>"
313 " <arg type='as' name='languages' direction='in'/>"
314 " <arg type='s' name='next_word' direction='out'/>"
316 " <method name='EEditorSpellCheckDialogPrev'>"
317 " <arg type='t' name='page_id' direction='in'/>"
318 " <arg type='s' name='word' direction='in'/>"
319 " <arg type='as' name='languages' direction='in'/>"
320 " <arg type='s' name='prev_word' direction='out'/>"
322 "<!-- ********************************************************* -->"
323 "<!-- Functions that are used in EEditorTableDialog -->"
324 "<!-- ********************************************************* -->"
325 " <method name='EEditorTableDialogSetRowCount'>"
326 " <arg type='t' name='page_id' direction='in'/>"
327 " <arg type='u' name='value' direction='in'/>"
329 " <method name='EEditorTableDialogGetRowCount'>"
330 " <arg type='t' name='page_id' direction='in'/>"
331 " <arg type='u' name='value' direction='out'/>"
333 " <method name='EEditorTableDialogSetColumnCount'>"
334 " <arg type='t' name='page_id' direction='in'/>"
335 " <arg type='u' name='value' direction='in'/>"
337 " <method name='EEditorTableDialogGetColumnCount'>"
338 " <arg type='t' name='page_id' direction='in'/>"
339 " <arg type='u' name='value' direction='out'/>"
341 " <method name='EEditorTableDialogShow'>"
342 " <arg type='t' name='page_id' direction='in'/>"
343 " <arg type='b' name='created_new_table' direction='out'/>"
345 " <method name='EEditorTableDialogSaveHistoryOnExit'>"
346 " <arg type='t' name='page_id' direction='in'/>"
348 "<!-- ********************************************************* -->"
349 "<!-- Functions that are used in EEditorActions -->"
350 "<!-- ********************************************************* -->"
351 " <method name='TableCellElementGetNoWrap'>"
352 " <arg type='t' name='page_id' direction='in'/>"
353 " <arg type='s' name='element_id' direction='in'/>"
354 " <arg type='b' name='no_wrap' direction='out'/>"
356 " <method name='TableCellElementGetRowSpan'>"
357 " <arg type='t' name='page_id' direction='in'/>"
358 " <arg type='s' name='element_id' direction='in'/>"
359 " <arg type='i' name='row_span' direction='out'/>"
361 " <method name='TableCellElementGetColSpan'>"
362 " <arg type='t' name='page_id' direction='in'/>"
363 " <arg type='s' name='element_id' direction='in'/>"
364 " <arg type='i' name='col_span' direction='out'/>"
366 " <method name='EEditorDialogDeleteCellContents'>"
367 " <arg type='t' name='page_id' direction='in'/>"
369 " <method name='EEditorDialogDeleteColumn'>"
370 " <arg type='t' name='page_id' direction='in'/>"
372 " <method name='EEditorDialogDeleteRow'>"
373 " <arg type='t' name='page_id' direction='in'/>"
375 " <method name='EEditorDialogDeleteTable'>"
376 " <arg type='t' name='page_id' direction='in'/>"
378 " <method name='EEditorDialogInsertColumnAfter'>"
379 " <arg type='t' name='page_id' direction='in'/>"
381 " <method name='EEditorDialogInsertColumnBefore'>"
382 " <arg type='t' name='page_id' direction='in'/>"
384 " <method name='EEditorDialogInsertRowAbove'>"
385 " <arg type='t' name='page_id' direction='in'/>"
387 " <method name='EEditorDialogInsertRowBelow'>"
388 " <arg type='t' name='page_id' direction='in'/>"
390 " <method name='EEditorActionsSaveHistoryForCut'>"
391 " <arg type='t' name='page_id' direction='in'/>"
393 "<!-- ********************************************************* -->"
394 "<!-- Functions that are used in EEditorView -->"
395 "<!-- ********************************************************* -->"
396 " <method name='SetPastingContentFromItself'>"
397 " <arg type='t' name='page_id' direction='in'/>"
398 " <arg type='b' name='value' direction='in'/>"
400 " <method name='SetEditorHTMLMode'>"
401 " <arg type='t' name='page_id' direction='in'/>"
402 " <arg type='b' name='html_mode' direction='in'/>"
403 " <arg type='b' name='convert' direction='in'/>"
405 " <method name='SetConvertInSitu'>"
406 " <arg type='t' name='page_id' direction='in'/>"
407 " <arg type='b' name='value' direction='in'/>"
408 " <arg type='n' name='start_at_bottom' direction='in'/>"
409 " <arg type='n' name='top_signature' direction='in'/>"
411 " <method name='DOMForceSpellCheck'>"
412 " <arg type='t' name='page_id' direction='in'/>"
414 " <method name='DOMTurnSpellCheckOff'>"
415 " <arg type='t' name='page_id' direction='in'/>"
417 " <method name='DOMScrollToCaret'>"
418 " <arg type='t' name='page_id' direction='in'/>"
420 " <method name='DOMEmbedStyleSheet'>"
421 " <arg type='t' name='page_id' direction='in'/>"
422 " <arg type='s' name='style_sheet_content' direction='in'/>"
424 " <method name='DOMRemoveEmbeddedStyleSheet'>"
425 " <arg type='t' name='page_id' direction='in'/>"
427 " <method name='DOMSaveSelection'>"
428 " <arg type='t' name='page_id' direction='in'/>"
430 " <method name='DOMRestoreSelection'>"
431 " <arg type='t' name='page_id' direction='in'/>"
433 " <method name='DOMUndo'>"
434 " <arg type='t' name='page_id' direction='in'/>"
436 " <method name='DOMRedo'>"
437 " <arg type='t' name='page_id' direction='in'/>"
439 " <method name='DOMQuoteAndInsertTextIntoSelection'>"
440 " <arg type='t' name='page_id' direction='in'/>"
441 " <arg type='s' name='text' direction='in'/>"
442 " <arg type='b' name='is_html' direction='in'/>"
444 " <method name='DOMConvertAndInsertHTMLIntoSelection'>"
445 " <arg type='t' name='page_id' direction='in'/>"
446 " <arg type='s' name='text' direction='in'/>"
447 " <arg type='b' name='is_html' direction='in'/>"
449 " <method name='DOMCheckIfConversionNeeded'>"
450 " <arg type='t' name='page_id' direction='in'/>"
451 " <arg type='b' name='conversion_needed' direction='out'/>"
453 " <method name='DOMGetContent'>"
454 " <arg type='t' name='page_id' direction='in'/>"
455 " <arg type='s' name='from_domain' direction='in'/>"
456 " <arg type='i' name='flags' direction='in'/>"
457 " <arg type='s' name='content' direction='out'/>"
458 " <arg type='v' name='inline_images' direction='out'/>"
460 " <method name='DOMInsertHTML'>"
461 " <arg type='t' name='page_id' direction='in'/>"
462 " <arg type='s' name='html' direction='in'/>"
464 " <method name='DOMConvertContent'>"
465 " <arg type='t' name='page_id' direction='in'/>"
466 " <arg type='s' name='preffered_text' direction='in'/>"
467 " <arg type='n' name='start_at_bottom' direction='in'/>"
468 " <arg type='n' name='top_signature' direction='in'/>"
470 " <method name='DOMAddNewInlineImageIntoList'>"
471 " <arg type='t' name='page_id' direction='in'/>"
472 " <arg type='s' name='filename' direction='in'/>"
473 " <arg type='s' name='cid_src' direction='in'/>"
474 " <arg type='s' name='src' direction='in'/>"
476 " <method name='DOMReplaceImageSrc'>"
477 " <arg type='t' name='page_id' direction='in'/>"
478 " <arg type='s' name='selector' direction='in'/>"
479 " <arg type='s' name='uri' direction='in'/>"
481 " <method name='DOMMoveSelectionOnPoint'>"
482 " <arg type='t' name='page_id' direction='in'/>"
483 " <arg type='i' name='x' direction='in'/>"
484 " <arg type='i' name='y' direction='in'/>"
485 " <arg type='b' name='cancel_if_not_collapsed' direction='in'/>"
487 " <method name='DOMInsertSmiley'>"
488 " <arg type='t' name='page_id' direction='in'/>"
489 " <arg type='s' name='smiley_name' direction='in'/>"
491 " <method name='DOMLastDropOperationDidCopy'>"
492 " <arg type='t' name='page_id' direction='in'/>"
494 "<!-- ********************************************************* -->"
495 "<!-- Functions that are used in EEditorSelection -->"
496 "<!-- ********************************************************* -->"
497 " <method name='DOMSelectionIndent'>"
498 " <arg type='t' name='page_id' direction='in'/>"
500 " <method name='DOMSelectionInsertImage'>"
501 " <arg type='t' name='page_id' direction='in'/>"
502 " <arg type='s' name='uri' direction='in'/>"
504 " <method name='DOMInsertReplaceAllHistoryEvent'>"
505 " <arg type='t' name='page_id' direction='in'/>"
506 " <arg type='s' name='search_text' direction='in'/>"
507 " <arg type='s' name='replacement' direction='in'/>"
509 " <method name='DOMSelectionReplace'>"
510 " <arg type='t' name='page_id' direction='in'/>"
511 " <arg type='s' name='replacement' direction='in'/>"
513 " <method name='DOMSelectionSetAlignment'>"
514 " <arg type='t' name='page_id' direction='in'/>"
515 " <arg type='i' name='alignment' direction='in'/>"
517 " <method name='DOMSelectionSetBold'>"
518 " <arg type='t' name='page_id' direction='in'/>"
519 " <arg type='b' name='bold' direction='in'/>"
521 " <method name='DOMSelectionSetBlockFormat'>"
522 " <arg type='t' name='page_id' direction='in'/>"
523 " <arg type='i' name='block_format' direction='in'/>"
525 " <method name='DOMSelectionSetFontColor'>"
526 " <arg type='t' name='page_id' direction='in'/>"
527 " <arg type='s' name='color' direction='in'/>"
529 " <method name='DOMSelectionSetFontSize'>"
530 " <arg type='t' name='page_id' direction='in'/>"
531 " <arg type='i' name='font_size' direction='in'/>"
533 " <method name='DOMSelectionSetItalic'>"
534 " <arg type='t' name='page_id' direction='in'/>"
535 " <arg type='b' name='italic' direction='in'/>"
537 " <method name='DOMSelectionSetMonospaced'>"
538 " <arg type='t' name='page_id' direction='in'/>"
539 " <arg type='b' name='monospaced' direction='in'/>"
541 " <method name='DOMSelectionSetStrikethrough'>"
542 " <arg type='t' name='page_id' direction='in'/>"
543 " <arg type='b' name='strikethrough' direction='in'/>"
545 " <method name='DOMSelectionSetSubscript'>"
546 " <arg type='t' name='page_id' direction='in'/>"
547 " <arg type='b' name='subscript' direction='in'/>"
549 " <method name='DOMSelectionSetSuperscript'>"
550 " <arg type='t' name='page_id' direction='in'/>"
551 " <arg type='b' name='superscript' direction='in'/>"
553 " <method name='DOMSelectionSetUnderline'>"
554 " <arg type='t' name='page_id' direction='in'/>"
555 " <arg type='b' name='underline' direction='in'/>"
557 " <method name='DOMSelectionUnindent'>"
558 " <arg type='t' name='page_id' direction='in'/>"
560 " <method name='DOMSelectionWrap'>"
561 " <arg type='t' name='page_id' direction='in'/>"
563 " <method name='DOMGetCaretWord'>"
564 " <arg type='t' name='page_id' direction='in'/>"
565 " <arg type='s' name='word' direction='out'/>"
567 " <method name='DOMReplaceCaretWord'>"
568 " <arg type='t' name='page_id' direction='in'/>"
569 " <arg type='s' name='replacement' direction='in'/>"
571 "<!-- ********************************************************* -->"
572 "<!-- Functions that are used in EComposerPrivate -->"
573 "<!-- ********************************************************* -->"
574 " <method name='DOMInsertSignature'>"
575 " <arg type='t' name='page_id' direction='in'/>"
576 " <arg type='s' name='content' direction='in'/>"
577 " <arg type='b' name='is_html' direction='in'/>"
578 " <arg type='s' name='signature_id' direction='in'/>"
579 " <arg type='b' name='set_signature_from_message' direction='in'/>"
580 " <arg type='b' name='check_if_signature_is_changed' direction='in'/>"
581 " <arg type='b' name='ignore_next_signature_change' direction='in'/>"
582 " <arg type='n' name='start_at_bottom' direction='in'/>"
583 " <arg type='n' name='top_signature' direction='in'/>"
584 " <arg type='s' name='new_signature_id' direction='out'/>"
585 " <arg type='b' name='out_set_signature_from_message' direction='out'/>"
586 " <arg type='b' name='out_check_if_signature_is_changed' direction='out'/>"
587 " <arg type='b' name='out_ignore_next_signature_change' direction='out'/>"
589 " <method name='DOMGetActiveSignatureUid'>"
590 " <arg type='t' name='page_id' direction='in'/>"
591 " <arg type='s' name='uid' direction='out'/>"
593 "<!-- ********************************************************* -->"
594 "<!-- Functions that are used in External Editor plugin -->"
595 "<!-- ********************************************************* -->"
596 " <method name='DOMGetCaretPosition'>"
597 " <arg type='t' name='page_id' direction='in'/>"
598 " <arg type='u' name='position' direction='out'/>"
600 " <method name='DOMGetCaretOffset'>"
601 " <arg type='t' name='page_id' direction='in'/>"
602 " <arg type='u' name='offset' direction='out'/>"
604 " <method name='DOMClearUndoRedoHistory'>"
605 " <arg type='t' name='page_id' direction='in'/>"
610 G_DEFINE_TYPE (EEditorWebExtension
, e_editor_web_extension
, G_TYPE_OBJECT
)
613 get_editor_page (EEditorWebExtension
*extension
,
616 g_return_val_if_fail (E_IS_EDITOR_WEB_EXTENSION (extension
), NULL
);
618 return g_hash_table_lookup (extension
->priv
->editor_pages
, &page_id
);
622 get_editor_page_or_return_dbus_error (GDBusMethodInvocation
*invocation
,
623 EEditorWebExtension
*extension
,
626 WebKitWebPage
*web_page
;
627 EEditorPage
*editor_page
;
629 g_return_val_if_fail (E_IS_EDITOR_WEB_EXTENSION (extension
), NULL
);
631 web_page
= webkit_web_extension_get_page (extension
->priv
->wk_extension
, page_id
);
633 g_dbus_method_invocation_return_error (
634 invocation
, G_DBUS_ERROR
, G_DBUS_ERROR_INVALID_ARGS
,
635 "Invalid page ID: %" G_GUINT64_FORMAT
, page_id
);
640 editor_page
= get_editor_page (extension
, page_id
);
642 g_dbus_method_invocation_return_error (
643 invocation
, G_DBUS_ERROR
, G_DBUS_ERROR_INVALID_ARGS
,
644 "Invalid page ID: %" G_GUINT64_FORMAT
, page_id
);
651 handle_method_call (GDBusConnection
*connection
,
653 const char *object_path
,
654 const char *interface_name
,
655 const char *method_name
,
656 GVariant
*parameters
,
657 GDBusMethodInvocation
*invocation
,
661 EEditorWebExtension
*extension
= E_EDITOR_WEB_EXTENSION (user_data
);
662 WebKitDOMDocument
*document
;
663 EEditorPage
*editor_page
;
665 if (g_strcmp0 (interface_name
, E_WEBKIT_EDITOR_WEB_EXTENSION_INTERFACE
) != 0)
668 if (camel_debug ("webkit:editor"))
669 printf ("EEditorWebExtension - %s - %s\n", G_STRFUNC
, method_name
);
671 if (g_strcmp0 (method_name
, "TestHTMLEqual") == 0) {
672 gboolean equal
= FALSE
;
673 const gchar
*html1
= NULL
, *html2
= NULL
;
675 g_variant_get (parameters
, "(t&s&s)", &page_id
, &html1
, &html2
);
677 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
681 document
= e_editor_page_get_document (editor_page
);
682 equal
= e_editor_dom_test_html_equal (document
, html1
, html2
);
684 g_dbus_method_invocation_return_value (invocation
, g_variant_new ("(b)", equal
));
685 } else if (g_strcmp0 (method_name
, "ElementHasAttribute") == 0) {
686 gboolean value
= FALSE
;
687 const gchar
*element_id
, *attribute
;
688 WebKitDOMElement
*element
;
691 parameters
, "(t&s&s)", &page_id
, &element_id
, &attribute
);
693 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
697 document
= e_editor_page_get_document (editor_page
);
698 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
700 value
= webkit_dom_element_has_attribute (element
, attribute
);
702 g_dbus_method_invocation_return_value (
703 invocation
, g_variant_new ("(b)", value
));
704 } else if (g_strcmp0 (method_name
, "ElementGetAttribute") == 0) {
705 const gchar
*element_id
, *attribute
;
707 WebKitDOMElement
*element
;
710 parameters
, "(t&s&s)", &page_id
, &element_id
, &attribute
);
712 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
716 document
= e_editor_page_get_document (editor_page
);
717 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
719 value
= webkit_dom_element_get_attribute (element
, attribute
);
721 g_dbus_method_invocation_return_value (
725 g_variant_new_take_string (
726 value
? value
: g_strdup (""))));
727 } else if (g_strcmp0 (method_name
, "ElementGetAttributeBySelector") == 0) {
728 const gchar
*attribute
, *selector
;
730 WebKitDOMElement
*element
;
733 parameters
, "(t&s&s)", &page_id
, &selector
, &attribute
);
735 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
739 document
= e_editor_page_get_document (editor_page
);
740 element
= webkit_dom_document_query_selector (document
, selector
, NULL
);
742 value
= webkit_dom_element_get_attribute (element
, attribute
);
744 g_dbus_method_invocation_return_value (
748 g_variant_new_take_string (
749 value
? value
: g_strdup (""))));
750 } else if (g_strcmp0 (method_name
, "ElementRemoveAttribute") == 0) {
751 const gchar
*element_id
, *attribute
;
752 WebKitDOMElement
*element
;
755 parameters
, "(t&s&s)", &page_id
, &element_id
, &attribute
);
757 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
761 document
= e_editor_page_get_document (editor_page
);
762 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
764 webkit_dom_element_remove_attribute (element
, attribute
);
766 g_dbus_method_invocation_return_value (invocation
, NULL
);
767 } else if (g_strcmp0 (method_name
, "ElementRemoveAttributeBySelector") == 0) {
768 const gchar
*attribute
, *selector
;
769 WebKitDOMElement
*element
;
772 parameters
, "(t&s&s)", &page_id
, &selector
, &attribute
);
774 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
778 document
= e_editor_page_get_document (editor_page
);
779 element
= webkit_dom_document_query_selector (document
, selector
, NULL
);
781 webkit_dom_element_remove_attribute (element
, attribute
);
783 g_dbus_method_invocation_return_value (invocation
, NULL
);
784 } else if (g_strcmp0 (method_name
, "ElementSetAttribute") == 0) {
785 const gchar
*element_id
, *attribute
, *value
;
786 WebKitDOMElement
*element
;
791 &page_id
, &element_id
, &attribute
, &value
);
793 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
797 document
= e_editor_page_get_document (editor_page
);
798 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
800 webkit_dom_element_set_attribute (
801 element
, attribute
, value
, NULL
);
803 g_dbus_method_invocation_return_value (invocation
, NULL
);
804 } else if (g_strcmp0 (method_name
, "ElementSetAttributeBySelector") == 0) {
805 const gchar
*attribute
, *selector
, *value
;
806 WebKitDOMElement
*element
;
809 parameters
, "(t&s&s&s)", &page_id
, &selector
, &attribute
, &value
);
811 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
815 document
= e_editor_page_get_document (editor_page
);
816 element
= webkit_dom_document_query_selector (document
, selector
, NULL
);
818 if (g_strcmp0 (selector
, "body") == 0 &&
819 g_strcmp0 (attribute
, "link") == 0)
820 e_editor_dom_set_link_color (editor_page
, value
);
821 else if (g_strcmp0 (selector
, "body") == 0 &&
822 g_strcmp0 (attribute
, "vlink") == 0)
823 e_editor_dom_set_visited_link_color (editor_page
, value
);
825 webkit_dom_element_set_attribute (
826 element
, attribute
, value
, NULL
);
829 g_dbus_method_invocation_return_value (invocation
, NULL
);
830 } else if (g_strcmp0 (method_name
, "ElementGetTagName") == 0) {
831 const gchar
*element_id
;
833 WebKitDOMElement
*element
;
835 g_variant_get (parameters
, "(t&s)", &page_id
, &element_id
);
837 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
841 document
= e_editor_page_get_document (editor_page
);
842 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
844 value
= webkit_dom_element_get_tag_name (element
);
846 g_dbus_method_invocation_return_value (
850 g_variant_new_take_string (
851 value
? value
: g_strdup (""))));
852 } else if (g_strcmp0 (method_name
, "RemoveImageAttributesFromElementBySelector") == 0) {
853 const gchar
*selector
;
854 WebKitDOMElement
*element
;
856 g_variant_get (parameters
, "(t&s)", &page_id
, &selector
);
858 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
862 document
= e_editor_page_get_document (editor_page
);
863 element
= webkit_dom_document_query_selector (document
, selector
, NULL
);
865 webkit_dom_element_remove_attribute (element
, "background");
866 webkit_dom_element_remove_attribute (element
, "data-uri");
867 webkit_dom_element_remove_attribute (element
, "data-inline");
868 webkit_dom_element_remove_attribute (element
, "data-name");
871 g_dbus_method_invocation_return_value (invocation
, NULL
);
872 } else if (g_strcmp0 (method_name
, "EEditorCellDialogMarkCurrentCellElement") == 0) {
873 const gchar
*element_id
;
875 g_variant_get (parameters
, "(t&s)", &page_id
, &element_id
);
877 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
881 e_dialogs_dom_cell_mark_current_cell_element (editor_page
, element_id
);
883 g_dbus_method_invocation_return_value (invocation
, NULL
);
884 } else if (g_strcmp0 (method_name
, "EEditorCellDialogSaveHistoryOnExit") == 0) {
885 g_variant_get (parameters
, "(t)", &page_id
);
887 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
891 e_dialogs_dom_cell_save_history_on_exit (editor_page
);
893 g_dbus_method_invocation_return_value (invocation
, NULL
);
894 } else if (g_strcmp0 (method_name
, "EEditorCellDialogSetElementVAlign") == 0) {
896 EContentEditorScope scope
;
898 g_variant_get (parameters
, "(t&si)", &page_id
, &value
, &scope
);
900 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
904 e_dialogs_dom_cell_set_element_v_align (editor_page
, value
, scope
);
906 g_dbus_method_invocation_return_value (invocation
, NULL
);
907 } else if (g_strcmp0 (method_name
, "EEditorCellDialogSetElementAlign") == 0) {
909 EContentEditorScope scope
;
911 g_variant_get (parameters
, "(t&si)", &page_id
, &value
, &scope
);
913 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
917 e_dialogs_dom_cell_set_element_align (editor_page
, value
, scope
);
919 g_dbus_method_invocation_return_value (invocation
, NULL
);
920 } else if (g_strcmp0 (method_name
, "EEditorCellDialogSetElementNoWrap") == 0) {
922 EContentEditorScope scope
;
924 g_variant_get (parameters
, "(tbi)", &page_id
, &value
, &scope
);
926 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
930 e_dialogs_dom_cell_set_element_no_wrap (editor_page
, value
, scope
);
932 g_dbus_method_invocation_return_value (invocation
, NULL
);
933 } else if (g_strcmp0 (method_name
, "EEditorCellDialogSetElementHeaderStyle") == 0) {
935 EContentEditorScope scope
;
937 g_variant_get (parameters
, "(tbi)", &page_id
, &value
, &scope
);
939 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
943 e_dialogs_dom_cell_set_element_header_style (editor_page
, value
, scope
);
945 g_dbus_method_invocation_return_value (invocation
, NULL
);
946 } else if (g_strcmp0 (method_name
, "EEditorCellDialogSetElementWidth") == 0) {
948 EContentEditorScope scope
;
950 g_variant_get (parameters
, "(t&si)", &page_id
, &value
, &scope
);
952 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
956 e_dialogs_dom_cell_set_element_width (editor_page
, value
, scope
);
958 g_dbus_method_invocation_return_value (invocation
, NULL
);
959 } else if (g_strcmp0 (method_name
, "EEditorCellDialogSetElementColSpan") == 0) {
961 EContentEditorScope scope
;
963 g_variant_get (parameters
, "(tii)", &page_id
, &value
, &scope
);
965 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
969 e_dialogs_dom_cell_set_element_col_span (editor_page
, value
, scope
);
971 g_dbus_method_invocation_return_value (invocation
, NULL
);
972 } else if (g_strcmp0 (method_name
, "EEditorCellDialogSetElementRowSpan") == 0) {
974 EContentEditorScope scope
;
976 g_variant_get (parameters
, "(tii)", &page_id
, &value
, &scope
);
978 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
982 e_dialogs_dom_cell_set_element_row_span (editor_page
, value
, scope
);
984 g_dbus_method_invocation_return_value (invocation
, NULL
);
985 } else if (g_strcmp0 (method_name
, "EEditorCellDialogSetElementBgColor") == 0) {
987 EContentEditorScope scope
;
989 g_variant_get (parameters
, "(t&si)", &page_id
, &value
, &scope
);
991 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
995 e_dialogs_dom_cell_set_element_bg_color (editor_page
, value
, scope
);
997 g_dbus_method_invocation_return_value (invocation
, NULL
);
998 } else if (g_strcmp0 (method_name
, "EEditorHRuleDialogFindHRule") == 0) {
999 gboolean created_new_hr
= FALSE
;
1000 g_variant_get (parameters
, "(t)", &page_id
);
1002 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1006 created_new_hr
= e_dialogs_dom_h_rule_find_hrule (editor_page
);
1008 g_dbus_method_invocation_return_value (
1009 invocation
, g_variant_new ("(b)", created_new_hr
));
1010 } else if (g_strcmp0 (method_name
, "EEditorHRuleDialogOnClose") == 0) {
1011 g_variant_get (parameters
, "(t)", &page_id
);
1013 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1017 e_dialogs_dom_h_rule_dialog_on_close (editor_page
);
1019 g_dbus_method_invocation_return_value (invocation
, NULL
);
1020 } else if (g_strcmp0 (method_name
, "EEditorImageDialogMarkImage") == 0) {
1021 g_variant_get (parameters
, "(t)", &page_id
);
1023 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1027 e_dialogs_dom_image_mark_image (editor_page
);
1029 g_dbus_method_invocation_return_value (invocation
, NULL
);
1030 } else if (g_strcmp0 (method_name
, "EEditorImageDialogSaveHistoryOnExit") == 0) {
1031 g_variant_get (parameters
, "(t)", &page_id
);
1033 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1037 e_dialogs_dom_image_save_history_on_exit (editor_page
);
1039 g_dbus_method_invocation_return_value (invocation
, NULL
);
1040 } else if (g_strcmp0 (method_name
, "EEditorImageDialogSetElementUrl") == 0) {
1043 g_variant_get (parameters
, "(t&s)", &page_id
, &value
);
1045 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1049 e_dialogs_dom_image_set_element_url (editor_page
, value
);
1051 g_dbus_method_invocation_return_value (invocation
, NULL
);
1052 } else if (g_strcmp0 (method_name
, "EEditorImageDialogGetElementUrl") == 0) {
1055 g_variant_get (parameters
, "(t)", &page_id
);
1057 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1061 value
= e_dialogs_dom_image_get_element_url (editor_page
);
1063 g_dbus_method_invocation_return_value (
1067 g_variant_new_take_string (
1068 value
? value
: g_strdup (""))));
1069 } else if (g_strcmp0 (method_name
, "ImageElementSetWidth") == 0) {
1070 const gchar
*element_id
;
1072 WebKitDOMElement
*element
;
1075 parameters
, "(t&si)", &page_id
, &element_id
, &value
);
1077 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1081 document
= e_editor_page_get_document (editor_page
);
1082 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
1084 webkit_dom_html_image_element_set_width (
1085 WEBKIT_DOM_HTML_IMAGE_ELEMENT (element
), value
);
1087 g_dbus_method_invocation_return_value (invocation
, NULL
);
1088 } else if (g_strcmp0 (method_name
, "ImageElementGetWidth") == 0) {
1089 const gchar
*element_id
;
1091 WebKitDOMElement
*element
;
1094 parameters
, "(t&s)", &page_id
, &element_id
);
1096 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1100 document
= e_editor_page_get_document (editor_page
);
1101 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
1103 value
= webkit_dom_html_image_element_get_width (
1104 WEBKIT_DOM_HTML_IMAGE_ELEMENT (element
));
1106 g_dbus_method_invocation_return_value (
1107 invocation
, g_variant_new ("(i)", value
));
1108 } else if (g_strcmp0 (method_name
, "ImageElementSetHeight") == 0) {
1109 const gchar
*element_id
;
1111 WebKitDOMElement
*element
;
1114 parameters
, "(t&si)", &page_id
, &element_id
, &value
);
1116 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1120 document
= e_editor_page_get_document (editor_page
);
1121 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
1123 webkit_dom_html_image_element_set_width (
1124 WEBKIT_DOM_HTML_IMAGE_ELEMENT (element
), value
);
1126 g_dbus_method_invocation_return_value (invocation
, NULL
);
1127 } else if (g_strcmp0 (method_name
, "ImageElementGetHeight") == 0) {
1128 const gchar
*element_id
;
1130 WebKitDOMElement
*element
;
1133 parameters
, "(t&s)", &page_id
, &element_id
);
1135 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1139 document
= e_editor_page_get_document (editor_page
);
1140 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
1142 value
= webkit_dom_html_image_element_get_height (
1143 WEBKIT_DOM_HTML_IMAGE_ELEMENT (element
));
1145 g_dbus_method_invocation_return_value (
1146 invocation
, g_variant_new ("(i)", value
));
1147 } else if (g_strcmp0 (method_name
, "ImageElementGetNaturalWidth") == 0) {
1148 const gchar
*element_id
;
1150 WebKitDOMElement
*element
;
1153 parameters
, "(t&s)", &page_id
, &element_id
);
1155 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1159 document
= e_editor_page_get_document (editor_page
);
1160 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
1162 value
= webkit_dom_html_image_element_get_natural_width (
1163 WEBKIT_DOM_HTML_IMAGE_ELEMENT (element
));
1165 g_dbus_method_invocation_return_value (
1166 invocation
, g_variant_new ("(i)", value
));
1167 } else if (g_strcmp0 (method_name
, "ImageElementGetNaturalHeight") == 0) {
1168 const gchar
*element_id
;
1170 WebKitDOMElement
*element
;
1173 parameters
, "(t&s)", &page_id
, &element_id
);
1175 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1179 document
= e_editor_page_get_document (editor_page
);
1180 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
1182 value
= webkit_dom_html_image_element_get_natural_height (
1183 WEBKIT_DOM_HTML_IMAGE_ELEMENT (element
));
1185 g_dbus_method_invocation_return_value (
1186 invocation
, g_variant_new ("(i)", value
));
1187 } else if (g_strcmp0 (method_name
, "ImageElementSetHSpace") == 0) {
1188 const gchar
*element_id
;
1190 WebKitDOMElement
*element
;
1193 parameters
, "(t&si)", &page_id
, &element_id
, &value
);
1195 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1199 document
= e_editor_page_get_document (editor_page
);
1200 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
1202 webkit_dom_html_image_element_set_hspace (
1203 WEBKIT_DOM_HTML_IMAGE_ELEMENT (element
), value
);
1205 g_dbus_method_invocation_return_value (invocation
, NULL
);
1206 } else if (g_strcmp0 (method_name
, "ImageElementGetHSpace") == 0) {
1207 const gchar
*element_id
;
1209 WebKitDOMElement
*element
;
1212 parameters
, "(t&s)", &page_id
, &element_id
);
1214 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1218 document
= e_editor_page_get_document (editor_page
);
1219 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
1221 value
= webkit_dom_html_image_element_get_hspace (
1222 WEBKIT_DOM_HTML_IMAGE_ELEMENT (element
));
1224 g_dbus_method_invocation_return_value (
1225 invocation
, g_variant_new ("(i)", value
));
1226 } else if (g_strcmp0 (method_name
, "ImageElementSetVSpace") == 0) {
1227 const gchar
*element_id
;
1229 WebKitDOMElement
*element
;
1232 parameters
, "(t&si)", &page_id
, &element_id
, &value
);
1234 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1238 document
= e_editor_page_get_document (editor_page
);
1239 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
1241 webkit_dom_html_image_element_set_vspace (
1242 WEBKIT_DOM_HTML_IMAGE_ELEMENT (element
), value
);
1244 g_dbus_method_invocation_return_value (invocation
, NULL
);
1245 } else if (g_strcmp0 (method_name
, "ImageElementGetVSpace") == 0) {
1246 const gchar
*element_id
;
1248 WebKitDOMElement
*element
;
1251 parameters
, "(t&s)", &page_id
, &element_id
);
1253 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1257 document
= e_editor_page_get_document (editor_page
);
1258 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
1260 value
= webkit_dom_html_image_element_get_vspace (
1261 WEBKIT_DOM_HTML_IMAGE_ELEMENT (element
));
1263 g_dbus_method_invocation_return_value (
1264 invocation
, g_variant_new ("(i)", value
));
1265 } else if (g_strcmp0 (method_name
, "EEditorLinkDialogOk") == 0) {
1266 const gchar
*url
, *inner_text
;
1268 g_variant_get (parameters
, "(t&s&s)", &page_id
, &url
, &inner_text
);
1270 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1274 e_dialogs_dom_link_commit (editor_page
, url
, inner_text
);
1276 g_dbus_method_invocation_return_value (invocation
, NULL
);
1277 } else if (g_strcmp0 (method_name
, "EEditorLinkDialogShow") == 0) {
1278 g_variant_get (parameters
, "(t)", &page_id
);
1280 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1284 g_dbus_method_invocation_return_value (
1285 invocation
, e_dialogs_dom_link_show (editor_page
));
1286 } else if (g_strcmp0 (method_name
, "EEditorPageDialogSaveHistory") == 0) {
1287 g_variant_get (parameters
, "(t)", &page_id
);
1289 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1293 e_dialogs_dom_page_save_history (editor_page
);
1295 g_dbus_method_invocation_return_value (invocation
, NULL
);
1296 } else if (g_strcmp0 (method_name
, "EEditorPageDialogSaveHistoryOnExit") == 0) {
1297 g_variant_get (parameters
, "(t)", &page_id
);
1299 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1303 e_dialogs_dom_page_save_history_on_exit (editor_page
);
1305 g_dbus_method_invocation_return_value (invocation
, NULL
);
1306 } else if (g_strcmp0 (method_name
, "EEditorSpellCheckDialogNext") == 0) {
1307 const gchar
*from_word
= NULL
;
1308 const gchar
* const *languages
= NULL
;
1309 gchar
*value
= NULL
;
1311 g_variant_get (parameters
, "(t&s^as)", &page_id
, &from_word
, &languages
);
1313 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1317 value
= e_dialogs_dom_spell_check_next (editor_page
, from_word
, languages
);
1319 g_dbus_method_invocation_return_value (
1323 g_variant_new_take_string (
1324 value
? value
: g_strdup (""))));
1325 } else if (g_strcmp0 (method_name
, "EEditorSpellCheckDialogPrev") == 0) {
1326 const gchar
*from_word
= NULL
;
1327 const gchar
* const *languages
= NULL
;
1328 gchar
*value
= NULL
;
1330 g_variant_get (parameters
, "(t&s^as)", &page_id
, &from_word
, &languages
);
1332 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1336 value
= e_dialogs_dom_spell_check_prev (editor_page
, from_word
, languages
);
1338 g_dbus_method_invocation_return_value (
1342 g_variant_new_take_string (
1343 value
? value
: g_strdup (""))));
1344 } else if (g_strcmp0 (method_name
, "EEditorTableDialogSetRowCount") == 0) {
1347 g_variant_get (parameters
, "(tu)", &page_id
, &value
);
1349 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1353 e_dialogs_dom_table_set_row_count (editor_page
, value
);
1355 g_dbus_method_invocation_return_value (invocation
, NULL
);
1356 } else if (g_strcmp0 (method_name
, "EEditorTableDialogGetRowCount") == 0) {
1359 g_variant_get (parameters
, "(t)", &page_id
);
1361 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1365 value
= e_dialogs_dom_table_get_row_count (editor_page
);
1367 g_dbus_method_invocation_return_value (
1368 invocation
, g_variant_new ("(u)", value
));
1369 } else if (g_strcmp0 (method_name
, "EEditorTableDialogSetColumnCount") == 0) {
1372 g_variant_get (parameters
, "(tu)", &page_id
, &value
);
1374 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1378 e_dialogs_dom_table_set_column_count (editor_page
, value
);
1380 g_dbus_method_invocation_return_value (invocation
, NULL
);
1381 } else if (g_strcmp0 (method_name
, "EEditorTableDialogGetColumnCount") == 0) {
1384 g_variant_get (parameters
, "(t)", &page_id
);
1386 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1390 value
= e_dialogs_dom_table_get_column_count (editor_page
);
1392 g_dbus_method_invocation_return_value (
1393 invocation
, g_variant_new ("(u)", value
));
1394 } else if (g_strcmp0 (method_name
, "EEditorTableDialogShow") == 0) {
1395 gboolean created_new_table
;
1397 g_variant_get (parameters
, "(t)", &page_id
);
1399 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1403 created_new_table
= e_dialogs_dom_table_show (editor_page
);
1405 g_dbus_method_invocation_return_value (
1406 invocation
, g_variant_new ("(b)", created_new_table
));
1407 } else if (g_strcmp0 (method_name
, "EEditorTableDialogSaveHistoryOnExit") == 0) {
1408 g_variant_get (parameters
, "(t)", &page_id
);
1410 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1414 e_dialogs_dom_table_save_history_on_exit (editor_page
);
1416 g_dbus_method_invocation_return_value (invocation
, NULL
);
1417 } else if (g_strcmp0 (method_name
, "EEditorDialogDeleteCellContents") == 0) {
1418 g_variant_get (parameters
, "(t)", &page_id
);
1420 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1424 e_editor_dom_delete_cell_contents (editor_page
);
1426 g_dbus_method_invocation_return_value (invocation
, NULL
);
1427 } else if (g_strcmp0 (method_name
, "EEditorDialogDeleteColumn") == 0) {
1428 g_variant_get (parameters
, "(t)", &page_id
);
1430 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1434 e_editor_dom_delete_column (editor_page
);
1436 g_dbus_method_invocation_return_value (invocation
, NULL
);
1437 } else if (g_strcmp0 (method_name
, "EEditorDialogDeleteRow") == 0) {
1438 g_variant_get (parameters
, "(t)", &page_id
);
1440 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1444 e_editor_dom_delete_row (editor_page
);
1446 g_dbus_method_invocation_return_value (invocation
, NULL
);
1447 } else if (g_strcmp0 (method_name
, "EEditorDialogDeleteTable") == 0) {
1448 g_variant_get (parameters
, "(t)", &page_id
);
1450 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1454 e_editor_dom_delete_table (editor_page
);
1456 g_dbus_method_invocation_return_value (invocation
, NULL
);
1457 } else if (g_strcmp0 (method_name
, "EEditorDialogInsertColumnAfter") == 0) {
1458 g_variant_get (parameters
, "(t)", &page_id
);
1460 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1464 e_editor_dom_insert_column_after (editor_page
);
1466 g_dbus_method_invocation_return_value (invocation
, NULL
);
1467 } else if (g_strcmp0 (method_name
, "EEditorDialogInsertColumnBefore") == 0) {
1468 g_variant_get (parameters
, "(t)", &page_id
);
1470 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1474 e_editor_dom_insert_column_before (editor_page
);
1476 g_dbus_method_invocation_return_value (invocation
, NULL
);
1477 } else if (g_strcmp0 (method_name
, "EEditorDialogInsertRowAbove") == 0) {
1478 g_variant_get (parameters
, "(t)", &page_id
);
1480 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1484 e_editor_dom_insert_row_above (editor_page
);
1486 g_dbus_method_invocation_return_value (invocation
, NULL
);
1487 } else if (g_strcmp0 (method_name
, "EEditorDialogInsertRowBelow") == 0) {
1488 g_variant_get (parameters
, "(t)", &page_id
);
1490 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1494 e_editor_dom_insert_row_below (editor_page
);
1496 g_dbus_method_invocation_return_value (invocation
, NULL
);
1497 } else if (g_strcmp0 (method_name
, "EEditorLinkDialogOnOpen") == 0) {
1498 g_variant_get (parameters
, "(t)", &page_id
);
1500 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1504 e_dialogs_dom_link_dialog_on_open (editor_page
);
1506 g_dbus_method_invocation_return_value (invocation
, NULL
);
1507 } else if (g_strcmp0 (method_name
, "EEditorLinkDialogOnClose") == 0) {
1508 g_variant_get (parameters
, "(t)", &page_id
);
1510 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1514 e_dialogs_dom_link_dialog_on_close (editor_page
);
1516 g_dbus_method_invocation_return_value (invocation
, NULL
);
1517 } else if (g_strcmp0 (method_name
, "EEditorLinkDialogUnlink") == 0) {
1518 EEditorUndoRedoManager
*manager
;
1520 g_variant_get (parameters
, "(t)", &page_id
);
1522 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1526 manager
= e_editor_page_get_undo_redo_manager (editor_page
);
1527 /* Remove the history event that was saved when the dialog was opened */
1528 e_editor_undo_redo_manager_remove_current_history_event (manager
);
1530 e_editor_dom_selection_unlink (editor_page
);
1532 g_dbus_method_invocation_return_value (invocation
, NULL
);
1533 } else if (g_strcmp0 (method_name
, "EEditorActionsSaveHistoryForCut") == 0) {
1534 g_variant_get (parameters
, "(t)", &page_id
);
1536 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1540 e_editor_dom_save_history_for_cut (editor_page
);
1542 g_dbus_method_invocation_return_value (invocation
, NULL
);
1543 } else if (g_strcmp0 (method_name
, "TableCellElementGetNoWrap") == 0) {
1544 const gchar
*element_id
;
1545 gboolean value
= FALSE
;
1546 WebKitDOMElement
*element
;
1548 g_variant_get (parameters
, "(t&s)", &page_id
, &element_id
);
1550 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1554 document
= e_editor_page_get_document (editor_page
);
1555 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
1557 value
= webkit_dom_html_table_cell_element_get_no_wrap (
1558 WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (element
));
1560 g_dbus_method_invocation_return_value (
1561 invocation
, g_variant_new ("(b)", value
));
1562 } else if (g_strcmp0 (method_name
, "TableCellElementGetRowSpan") == 0) {
1563 const gchar
*element_id
;
1565 WebKitDOMElement
*element
;
1567 g_variant_get (parameters
, "(t&s)", &page_id
, &element_id
);
1569 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1573 document
= e_editor_page_get_document (editor_page
);
1574 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
1576 value
= webkit_dom_html_table_cell_element_get_row_span (
1577 WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (element
));
1579 g_dbus_method_invocation_return_value (
1580 invocation
, g_variant_new ("(i)", value
));
1581 } else if (g_strcmp0 (method_name
, "TableCellElementGetColSpan") == 0) {
1582 const gchar
*element_id
;
1584 WebKitDOMElement
*element
;
1586 g_variant_get (parameters
, "(t&s)", &page_id
, &element_id
);
1588 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1592 document
= e_editor_page_get_document (editor_page
);
1593 element
= webkit_dom_document_get_element_by_id (document
, element_id
);
1595 value
= webkit_dom_html_table_cell_element_get_col_span (
1596 WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (element
));
1598 g_dbus_method_invocation_return_value (
1599 invocation
, g_variant_new ("(i)", value
));
1600 } else if (g_strcmp0 (method_name
, "DOMSaveSelection") == 0) {
1601 g_variant_get (parameters
, "(t)", &page_id
);
1603 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1607 e_editor_dom_selection_save (editor_page
);
1608 g_dbus_method_invocation_return_value (invocation
, NULL
);
1609 } else if (g_strcmp0 (method_name
, "DOMRestoreSelection") == 0) {
1610 g_variant_get (parameters
, "(t)", &page_id
);
1612 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1616 e_editor_dom_selection_restore (editor_page
);
1617 g_dbus_method_invocation_return_value (invocation
, NULL
);
1618 } else if (g_strcmp0 (method_name
, "DOMUndo") == 0) {
1619 EEditorUndoRedoManager
*manager
;
1621 g_variant_get (parameters
, "(t)", &page_id
);
1623 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1627 manager
= e_editor_page_get_undo_redo_manager (editor_page
);
1629 e_editor_undo_redo_manager_undo (manager
);
1631 g_dbus_method_invocation_return_value (invocation
, NULL
);
1632 } else if (g_strcmp0 (method_name
, "DOMRedo") == 0) {
1633 EEditorUndoRedoManager
*manager
;
1635 g_variant_get (parameters
, "(t)", &page_id
);
1637 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1641 manager
= e_editor_page_get_undo_redo_manager (editor_page
);
1643 e_editor_undo_redo_manager_redo (manager
);
1645 g_dbus_method_invocation_return_value (invocation
, NULL
);
1646 } else if (g_strcmp0 (method_name
, "DOMTurnSpellCheckOff") == 0) {
1647 g_variant_get (parameters
, "(t)", &page_id
);
1649 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1653 e_editor_dom_turn_spell_check_off (editor_page
);
1654 g_dbus_method_invocation_return_value (invocation
, NULL
);
1655 } else if (g_strcmp0 (method_name
, "DOMQuoteAndInsertTextIntoSelection") == 0) {
1656 gboolean is_html
= FALSE
;
1659 g_variant_get (parameters
, "(t&sb)", &page_id
, &text
, &is_html
);
1661 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1665 e_editor_dom_quote_and_insert_text_into_selection (editor_page
, text
, is_html
);
1666 g_dbus_method_invocation_return_value (invocation
, NULL
);
1667 } else if (g_strcmp0 (method_name
, "DOMConvertAndInsertHTMLIntoSelection") == 0) {
1671 g_variant_get (parameters
, "(t&sb)", &page_id
, &text
, &is_html
);
1673 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1677 e_editor_dom_convert_and_insert_html_into_selection (editor_page
, text
, is_html
);
1678 g_dbus_method_invocation_return_value (invocation
, NULL
);
1679 } else if (g_strcmp0 (method_name
, "DOMEmbedStyleSheet") == 0) {
1680 const gchar
*style_sheet_content
;
1682 g_variant_get (parameters
, "(t&s)", &page_id
, &style_sheet_content
);
1684 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1688 e_editor_dom_embed_style_sheet (editor_page
, style_sheet_content
);
1689 g_dbus_method_invocation_return_value (invocation
, NULL
);
1690 } else if (g_strcmp0 (method_name
, "DOMRemoveEmbeddedStyleSheet") == 0) {
1691 g_variant_get (parameters
, "(t)", &page_id
);
1693 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1697 e_editor_dom_remove_embedded_style_sheet (editor_page
);
1698 g_dbus_method_invocation_return_value (invocation
, NULL
);
1699 } else if (g_strcmp0 (method_name
, "SetPastingContentFromItself") == 0) {
1700 gboolean value
= FALSE
;
1702 g_variant_get (parameters
, "(tb)", &page_id
, &value
);
1704 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1708 e_editor_page_set_pasting_content_from_itself (editor_page
, value
);
1710 g_dbus_method_invocation_return_value (invocation
, NULL
);
1711 } else if (g_strcmp0 (method_name
, "SetEditorHTMLMode") == 0) {
1712 gboolean html_mode
= FALSE
;
1713 gboolean convert
= FALSE
;
1715 g_variant_get (parameters
, "(tbb)", &page_id
, &html_mode
, &convert
);
1717 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1721 convert
= convert
&& e_editor_page_get_html_mode (editor_page
) && !html_mode
;
1722 e_editor_page_set_html_mode (editor_page
, html_mode
);
1725 e_editor_dom_convert_when_changing_composer_mode (editor_page
);
1727 e_editor_dom_process_content_after_mode_change (editor_page
);
1729 g_dbus_method_invocation_return_value (invocation
, NULL
);
1730 } else if (g_strcmp0 (method_name
, "SetConvertInSitu") == 0) {
1731 gboolean value
= FALSE
;
1732 gint16 start_at_bottom
= -1, top_signature
= -1;
1734 g_variant_get (parameters
, "(tbnn)", &page_id
, &value
, &start_at_bottom
, &top_signature
);
1736 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1740 e_editor_page_set_convert_in_situ (editor_page
, value
, start_at_bottom
, top_signature
);
1742 g_dbus_method_invocation_return_value (invocation
, NULL
);
1743 } else if (g_strcmp0 (method_name
, "DOMForceSpellCheck") == 0) {
1744 g_variant_get (parameters
, "(t)", &page_id
);
1746 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1750 e_editor_dom_force_spell_check (editor_page
);
1751 g_dbus_method_invocation_return_value (invocation
, NULL
);
1752 } else if (g_strcmp0 (method_name
, "DOMCheckIfConversionNeeded") == 0) {
1753 gboolean conversion_needed
;
1755 g_variant_get (parameters
, "(t)", &page_id
);
1757 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1761 conversion_needed
= e_editor_dom_check_if_conversion_needed (editor_page
);
1762 g_dbus_method_invocation_return_value (
1763 invocation
, g_variant_new ("(b)", conversion_needed
));
1764 } else if (g_strcmp0 (method_name
, "DOMGetContent") == 0) {
1765 EContentEditorGetContentFlags flags
;
1766 const gchar
*from_domain
;
1767 gchar
*value
= NULL
;
1768 GVariant
*inline_images
= NULL
;
1770 g_variant_get (parameters
, "(t&si)", &page_id
, &from_domain
, &flags
);
1772 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1776 if ((flags
& E_CONTENT_EDITOR_GET_INLINE_IMAGES
) && from_domain
&& *from_domain
)
1777 inline_images
= e_editor_dom_get_inline_images_data (editor_page
, from_domain
);
1779 if ((flags
& E_CONTENT_EDITOR_GET_TEXT_HTML
) &&
1780 !(flags
& E_CONTENT_EDITOR_GET_PROCESSED
)) {
1781 value
= e_editor_dom_process_content_for_draft (
1782 editor_page
, (flags
& E_CONTENT_EDITOR_GET_BODY
));
1783 } else if ((flags
& E_CONTENT_EDITOR_GET_TEXT_HTML
) &&
1784 (flags
& E_CONTENT_EDITOR_GET_PROCESSED
) &&
1785 !(flags
& E_CONTENT_EDITOR_GET_BODY
)) {
1786 value
= e_editor_dom_process_content_to_html_for_exporting (editor_page
);
1787 } else if ((flags
& E_CONTENT_EDITOR_GET_TEXT_PLAIN
) &&
1788 (flags
& E_CONTENT_EDITOR_GET_PROCESSED
) &&
1789 !(flags
& E_CONTENT_EDITOR_GET_BODY
)) {
1790 value
= e_editor_dom_process_content_to_plain_text_for_exporting (editor_page
);
1791 } else if ((flags
& E_CONTENT_EDITOR_GET_TEXT_PLAIN
) &&
1792 (flags
& E_CONTENT_EDITOR_GET_BODY
) &&
1793 !(flags
& E_CONTENT_EDITOR_GET_PROCESSED
)) {
1794 if (flags
& E_CONTENT_EDITOR_GET_EXCLUDE_SIGNATURE
)
1795 value
= e_composer_dom_get_raw_body_content_without_signature (editor_page
);
1797 value
= e_composer_dom_get_raw_body_content (editor_page
);
1799 g_warning ("Unsupported flags combination (%d) in (%s)", flags
, G_STRFUNC
);
1802 if ((flags
& E_CONTENT_EDITOR_GET_INLINE_IMAGES
) && from_domain
&& *from_domain
&& inline_images
)
1803 e_editor_dom_restore_images (editor_page
, inline_images
);
1805 /* If no inline images are requested we still have to return
1806 * something even it won't be used at all. */
1807 g_dbus_method_invocation_return_value (
1812 inline_images
? inline_images
: g_variant_new_int32 (0)));
1815 } else if (g_strcmp0 (method_name
, "DOMInsertHTML") == 0) {
1818 g_variant_get (parameters
, "(t&s)", &page_id
, &html
);
1820 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1824 e_editor_dom_insert_html (editor_page
, html
);
1825 g_dbus_method_invocation_return_value (invocation
, NULL
);
1826 } else if (g_strcmp0 (method_name
, "DOMConvertContent") == 0) {
1827 const gchar
*preferred_text
;
1828 gint64 start_at_bottom
= -1, top_signature
= -1;
1830 g_variant_get (parameters
, "(t&snn)", &page_id
, &preferred_text
, &start_at_bottom
, &top_signature
);
1832 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1836 e_editor_dom_convert_content (editor_page
, preferred_text
, start_at_bottom
, top_signature
);
1837 g_dbus_method_invocation_return_value (invocation
, NULL
);
1838 } else if (g_strcmp0 (method_name
, "DOMAddNewInlineImageIntoList") == 0) {
1839 const gchar
*cid_uri
, *src
, *filename
;
1841 g_variant_get (parameters
, "(t&s&s&s)", &page_id
, &filename
, &cid_uri
, &src
);
1843 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1847 e_editor_page_add_new_inline_image_into_list (
1848 editor_page
, cid_uri
, src
);
1850 g_dbus_method_invocation_return_value (invocation
, NULL
);
1851 } else if (g_strcmp0 (method_name
, "DOMReplaceImageSrc") == 0) {
1852 const gchar
*selector
, *uri
;
1854 g_variant_get (parameters
, "(t&s&s)", &page_id
, &selector
, &uri
);
1856 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1860 e_editor_dom_replace_image_src (editor_page
, selector
, uri
);
1862 g_dbus_method_invocation_return_value (invocation
, NULL
);
1863 } else if (g_strcmp0 (method_name
, "DOMInsertSmiley") == 0) {
1864 const gchar
*smiley_name
;
1866 g_variant_get (parameters
, "(t&s)", &page_id
, &smiley_name
);
1868 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1872 e_editor_dom_insert_smiley_by_name (editor_page
, smiley_name
);
1873 g_dbus_method_invocation_return_value (invocation
, NULL
);
1874 } else if (g_strcmp0 (method_name
, "DOMMoveSelectionOnPoint") == 0) {
1875 gboolean cancel_if_not_collapsed
;
1878 g_variant_get (parameters
, "(tiib)", &page_id
, &x
, &y
, &cancel_if_not_collapsed
);
1880 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1884 if (cancel_if_not_collapsed
) {
1885 if (e_editor_dom_selection_is_collapsed (editor_page
))
1886 e_editor_dom_selection_set_on_point (editor_page
, x
, y
);
1888 e_editor_dom_selection_set_on_point (editor_page
, x
, y
);
1890 g_dbus_method_invocation_return_value (invocation
, NULL
);
1891 } else if (g_strcmp0 (method_name
, "DOMSelectionIndent") == 0) {
1892 g_variant_get (parameters
, "(t)", &page_id
);
1894 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1898 e_editor_dom_selection_indent (editor_page
);
1899 g_dbus_method_invocation_return_value (invocation
, NULL
);
1900 } else if (g_strcmp0 (method_name
, "DOMSelectionSave") == 0) {
1901 g_variant_get (parameters
, "(t)", &page_id
);
1903 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1907 e_editor_dom_selection_save (editor_page
);
1908 g_dbus_method_invocation_return_value (invocation
, NULL
);
1909 } else if (g_strcmp0 (method_name
, "DOMSelectionRestore") == 0) {
1910 g_variant_get (parameters
, "(t)", &page_id
);
1912 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1916 e_editor_dom_selection_restore (editor_page
);
1917 g_dbus_method_invocation_return_value (invocation
, NULL
);
1918 } else if (g_strcmp0 (method_name
, "DOMSelectionInsertImage") == 0) {
1921 g_variant_get (parameters
, "(t&s)", &page_id
, &uri
);
1923 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1927 e_editor_dom_insert_image (editor_page
, uri
);
1929 g_dbus_method_invocation_return_value (invocation
, NULL
);
1930 } else if (g_strcmp0 (method_name
, "DOMInsertReplaceAllHistoryEvent") == 0) {
1931 const gchar
*replacement
, *search_text
;
1933 g_variant_get (parameters
, "(t&s&s)", &page_id
, &search_text
, &replacement
);
1935 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1939 e_editor_dom_insert_replace_all_history_event (editor_page
, search_text
, replacement
);
1940 g_dbus_method_invocation_return_value (invocation
, NULL
);
1941 } else if (g_strcmp0 (method_name
, "DOMSelectionReplace") == 0) {
1942 const gchar
*replacement
;
1944 g_variant_get (parameters
, "(t&s)", &page_id
, &replacement
);
1946 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1950 e_editor_dom_selection_replace (editor_page
, replacement
);
1951 g_dbus_method_invocation_return_value (invocation
, NULL
);
1952 } else if (g_strcmp0 (method_name
, "DOMSelectionSetAlignment") == 0) {
1953 EContentEditorAlignment alignment
;
1955 g_variant_get (parameters
, "(ti)", &page_id
, &alignment
);
1957 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1961 e_editor_dom_selection_set_alignment (editor_page
, alignment
);
1962 e_editor_page_set_alignment (editor_page
, alignment
);
1963 g_dbus_method_invocation_return_value (invocation
, NULL
);
1964 } else if (g_strcmp0 (method_name
, "DOMSelectionSetBold") == 0) {
1967 g_variant_get (parameters
, "(tb)", &page_id
, &bold
);
1969 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1973 e_editor_page_set_bold (editor_page
, bold
);
1974 g_dbus_method_invocation_return_value (invocation
, NULL
);
1975 } else if (g_strcmp0 (method_name
, "DOMSelectionSetBlockFormat") == 0) {
1976 EContentEditorBlockFormat block_format
;
1978 g_variant_get (parameters
, "(ti)", &page_id
, &block_format
);
1980 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1984 e_editor_dom_selection_set_block_format (editor_page
, block_format
);
1985 g_dbus_method_invocation_return_value (invocation
, NULL
);
1986 } else if (g_strcmp0 (method_name
, "DOMSelectionSetFontColor") == 0) {
1989 g_variant_get (parameters
, "(t&s)", &page_id
, &color
);
1991 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
1995 e_editor_dom_selection_set_font_color (editor_page
, color
);
1996 g_dbus_method_invocation_return_value (invocation
, NULL
);
1997 } else if (g_strcmp0 (method_name
, "DOMSelectionSetFontSize") == 0) {
1998 EContentEditorFontSize font_size
;
2000 g_variant_get (parameters
, "(ti)", &page_id
, &font_size
);
2002 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2006 e_editor_dom_selection_set_font_size (editor_page
, font_size
);
2007 g_dbus_method_invocation_return_value (invocation
, NULL
);
2008 } else if (g_strcmp0 (method_name
, "DOMSelectionSetItalic") == 0) {
2011 g_variant_get (parameters
, "(tb)", &page_id
, &italic
);
2013 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2017 e_editor_page_set_italic (editor_page
, italic
);
2018 g_dbus_method_invocation_return_value (invocation
, NULL
);
2019 } else if (g_strcmp0 (method_name
, "DOMSelectionSetMonospaced") == 0) {
2020 gboolean monospaced
;
2022 g_variant_get (parameters
, "(tb)", &page_id
, &monospaced
);
2024 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2028 e_editor_page_set_monospace (editor_page
, monospaced
);
2029 g_dbus_method_invocation_return_value (invocation
, NULL
);
2030 } else if (g_strcmp0 (method_name
, "DOMSelectionSetStrikethrough") == 0) {
2031 gboolean strikethrough
;
2033 g_variant_get (parameters
, "(tb)", &page_id
, &strikethrough
);
2035 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2039 e_editor_page_set_strikethrough (editor_page
, strikethrough
);
2040 g_dbus_method_invocation_return_value (invocation
, NULL
);
2041 } else if (g_strcmp0 (method_name
, "DOMSelectionSetSubscript") == 0) {
2044 g_variant_get (parameters
, "(tb)", &page_id
, &subscript
);
2046 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2050 e_editor_dom_selection_set_subscript (editor_page
, subscript
);
2051 g_dbus_method_invocation_return_value (invocation
, NULL
);
2052 } else if (g_strcmp0 (method_name
, "DOMSelectionSetSuperscript") == 0) {
2053 gboolean superscript
;
2055 g_variant_get (parameters
, "(tb)", &page_id
, &superscript
);
2057 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2061 e_editor_dom_selection_set_superscript (editor_page
, superscript
);
2062 g_dbus_method_invocation_return_value (invocation
, NULL
);
2063 } else if (g_strcmp0 (method_name
, "DOMSelectionSetUnderline") == 0) {
2066 g_variant_get (parameters
, "(tb)", &page_id
, &underline
);
2068 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2072 e_editor_page_set_underline (editor_page
, underline
);
2073 g_dbus_method_invocation_return_value (invocation
, NULL
);
2074 } else if (g_strcmp0 (method_name
, "DOMSelectionUnindent") == 0) {
2075 g_variant_get (parameters
, "(t)", &page_id
);
2077 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2081 e_editor_dom_selection_unindent (editor_page
);
2082 g_dbus_method_invocation_return_value (invocation
, NULL
);
2083 } else if (g_strcmp0 (method_name
, "DOMSelectionWrap") == 0) {
2084 g_variant_get (parameters
, "(t)", &page_id
);
2086 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2090 e_editor_dom_selection_wrap (editor_page
);
2091 g_dbus_method_invocation_return_value (invocation
, NULL
);
2092 } else if (g_strcmp0 (method_name
, "DOMGetCaretWord") == 0) {
2095 g_variant_get (parameters
, "(t)", &page_id
);
2097 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2101 word
= e_editor_dom_get_caret_word (editor_page
);
2103 g_dbus_method_invocation_return_value (
2107 g_variant_new_take_string (
2108 word
? word
: g_strdup (""))));
2109 } else if (g_strcmp0 (method_name
, "DOMReplaceCaretWord") == 0) {
2110 const gchar
*replacement
= NULL
;
2112 g_variant_get (parameters
, "(t&s)", &page_id
, &replacement
);
2114 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2118 e_editor_dom_replace_caret_word (editor_page
, replacement
);
2120 g_dbus_method_invocation_return_value (invocation
, NULL
);
2121 } else if (g_strcmp0 (method_name
, "DOMInsertSignature") == 0) {
2122 gboolean is_html
, set_signature_from_message
;
2123 gboolean check_if_signature_is_changed
, ignore_next_signature_change
;
2124 gint16 start_at_bottom
= -1, top_signature
= -1;
2125 const gchar
*content
, *signature_id
;
2126 gchar
*new_signature_id
= NULL
;
2135 &set_signature_from_message
,
2136 &check_if_signature_is_changed
,
2137 &ignore_next_signature_change
,
2141 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2145 new_signature_id
= e_composer_dom_insert_signature (
2150 &set_signature_from_message
,
2151 &check_if_signature_is_changed
,
2152 &ignore_next_signature_change
,
2156 g_dbus_method_invocation_return_value (
2160 new_signature_id
? new_signature_id
: "",
2161 set_signature_from_message
,
2162 check_if_signature_is_changed
,
2163 ignore_next_signature_change
));
2165 g_free (new_signature_id
);
2166 } else if (g_strcmp0 (method_name
, "DOMGetActiveSignatureUid") == 0) {
2169 g_variant_get (parameters
, "(t)", &page_id
);
2171 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2175 value
= e_composer_dom_get_active_signature_uid (editor_page
);
2177 g_dbus_method_invocation_return_value (
2181 g_variant_new_take_string (
2182 value
? value
: g_strdup (""))));
2183 } else if (g_strcmp0 (method_name
, "DOMLastDropOperationDidCopy") == 0) {
2184 EEditorUndoRedoManager
*manager
;
2186 g_variant_get (parameters
, "(t)", &page_id
);
2188 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2192 manager
= e_editor_page_get_undo_redo_manager (editor_page
);
2194 e_editor_undo_redo_manager_last_drop_operation_did_copy (manager
);
2196 g_dbus_method_invocation_return_value (invocation
, NULL
);
2197 } else if (g_strcmp0 (method_name
, "DOMGetCaretPosition") == 0) {
2200 g_variant_get (parameters
, "(t)", &page_id
);
2202 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2206 value
= e_editor_dom_get_caret_position (editor_page
);
2208 g_dbus_method_invocation_return_value (
2210 g_variant_new ("(u)", value
));
2211 } else if (g_strcmp0 (method_name
, "DOMGetCaretOffset") == 0) {
2214 g_variant_get (parameters
, "(t)", &page_id
);
2216 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2220 value
= e_editor_dom_get_caret_offset (editor_page
);
2222 g_dbus_method_invocation_return_value (
2224 g_variant_new ("(u)", value
));
2225 } else if (g_strcmp0 (method_name
, "DOMClearUndoRedoHistory") == 0) {
2226 EEditorUndoRedoManager
*manager
;
2228 g_variant_get (parameters
, "(t)", &page_id
);
2230 editor_page
= get_editor_page_or_return_dbus_error (invocation
, extension
, page_id
);
2234 manager
= e_editor_page_get_undo_redo_manager (editor_page
);
2236 e_editor_undo_redo_manager_clean_history (manager
);
2238 g_dbus_method_invocation_return_value (invocation
, NULL
);
2240 g_warning ("UNKNOWN METHOD '%s'", method_name
);
2246 g_warning ("Cannot obtain WebKitWebPage for %" G_GUINT64_FORMAT
, page_id
);
2250 web_page_gone_cb (gpointer user_data
,
2251 GObject
*gone_web_page
)
2253 EEditorWebExtension
*extension
= user_data
;
2254 GHashTableIter iter
;
2255 gpointer key
, value
;
2257 g_return_if_fail (E_IS_EDITOR_WEB_EXTENSION (extension
));
2259 g_hash_table_iter_init (&iter
, extension
->priv
->editor_pages
);
2260 while (g_hash_table_iter_next (&iter
, &key
, &value
)) {
2261 EEditorPage
*editor_page
= E_EDITOR_PAGE (value
);
2262 WebKitWebPage
*web_page
= e_editor_page_get_web_page (editor_page
);
2264 if ((gpointer
) web_page
== gone_web_page
) {
2265 g_hash_table_remove (extension
->priv
->editor_pages
, key
);
2271 static const GDBusInterfaceVTable interface_vtable
= {
2278 e_editor_web_extension_dispose (GObject
*object
)
2280 EEditorWebExtension
*extension
= E_EDITOR_WEB_EXTENSION (object
);
2282 if (extension
->priv
->dbus_connection
) {
2283 g_dbus_connection_unregister_object (
2284 extension
->priv
->dbus_connection
,
2285 extension
->priv
->registration_id
);
2286 extension
->priv
->registration_id
= 0;
2287 extension
->priv
->dbus_connection
= NULL
;
2290 g_hash_table_remove_all (extension
->priv
->editor_pages
);
2292 g_clear_object (&extension
->priv
->wk_extension
);
2294 /* Chain up to parent's dispose() method. */
2295 G_OBJECT_CLASS (e_editor_web_extension_parent_class
)->dispose (object
);
2299 e_editor_web_extension_finalize (GObject
*object
)
2301 EEditorWebExtension
*extension
= E_EDITOR_WEB_EXTENSION (object
);
2303 if (extension
->priv
->editor_pages
) {
2304 g_hash_table_destroy (extension
->priv
->editor_pages
);
2305 extension
->priv
->editor_pages
= NULL
;
2308 /* Chain up to parent's finalize() method. */
2309 G_OBJECT_CLASS (e_editor_web_extension_parent_class
)->finalize (object
);
2313 e_editor_web_extension_class_init (EEditorWebExtensionClass
*class)
2315 GObjectClass
*object_class
= G_OBJECT_CLASS (class);
2317 object_class
->dispose
= e_editor_web_extension_dispose
;
2318 object_class
->finalize
= e_editor_web_extension_finalize
;
2320 g_type_class_add_private (object_class
, sizeof(EEditorWebExtensionPrivate
));
2324 e_editor_web_extension_init (EEditorWebExtension
*extension
)
2326 extension
->priv
= E_EDITOR_WEB_EXTENSION_GET_PRIVATE (extension
);
2327 extension
->priv
->editor_pages
= g_hash_table_new_full (g_int64_hash
, g_int64_equal
, g_free
, g_object_unref
);
2331 e_editor_web_extension_create_instance (gpointer data
)
2333 return g_object_new (E_TYPE_EDITOR_WEB_EXTENSION
, NULL
);
2336 EEditorWebExtension
*
2337 e_editor_web_extension_get_default (void)
2339 static GOnce once_init
= G_ONCE_INIT
;
2340 return E_EDITOR_WEB_EXTENSION (g_once (&once_init
, e_editor_web_extension_create_instance
, NULL
));
2344 image_exists_in_cache (const gchar
*image_uri
)
2348 gboolean exists
= FALSE
;
2350 if (!emd_global_http_cache
)
2353 hash
= g_compute_checksum_for_string (G_CHECKSUM_MD5
, image_uri
, -1);
2354 filename
= camel_data_cache_get_filename (
2355 emd_global_http_cache
, "http", hash
);
2357 if (filename
!= NULL
) {
2360 exists
= g_file_test (filename
, G_FILE_TEST_EXISTS
);
2361 if (exists
&& g_stat (filename
, &st
) == 0) {
2362 exists
= st
.st_size
!= 0;
2375 redirect_http_uri (EEditorWebExtension
*extension
,
2376 WebKitWebPage
*web_page
,
2377 WebKitURIRequest
*request
)
2382 gboolean image_exists
;
2383 EEditorPage
*editor_page
;
2384 EImageLoadingPolicy image_policy
;
2386 editor_page
= get_editor_page (extension
, webkit_web_page_get_id (web_page
));
2387 g_return_val_if_fail (E_IS_EDITOR_PAGE (editor_page
), FALSE
);
2389 uri
= webkit_uri_request_get_uri (request
);
2391 /* Check Evolution's cache */
2392 image_exists
= image_exists_in_cache (uri
);
2394 /* If the URI is not cached and we are not allowed to load it
2395 * then redirect to invalid URI, so that webkit would display
2396 * a native placeholder for it. */
2397 image_policy
= e_editor_page_get_image_loading_policy (editor_page
);
2398 if (!image_exists
&& !e_editor_page_get_force_image_load (editor_page
) &&
2399 (image_policy
== E_IMAGE_LOADING_POLICY_NEVER
)) {
2403 new_uri
= g_strconcat ("evo-", uri
, NULL
);
2404 soup_uri
= soup_uri_new (new_uri
);
2407 new_uri
= soup_uri_to_string (soup_uri
, FALSE
);
2408 webkit_uri_request_set_uri (request
, new_uri
);
2409 soup_uri_free (soup_uri
);
2417 web_page_send_request_cb (WebKitWebPage
*web_page
,
2418 WebKitURIRequest
*request
,
2419 WebKitURIResponse
*redirected_response
,
2420 EEditorWebExtension
*extension
)
2422 const char *request_uri
;
2423 const char *page_uri
;
2424 gboolean uri_is_http
;
2426 request_uri
= webkit_uri_request_get_uri (request
);
2427 page_uri
= webkit_web_page_get_uri (web_page
);
2429 /* Always load the main resource. */
2430 if (g_strcmp0 (request_uri
, page_uri
) == 0)
2434 g_str_has_prefix (request_uri
, "http:") ||
2435 g_str_has_prefix (request_uri
, "https:") ||
2436 g_str_has_prefix (request_uri
, "evo-http:") ||
2437 g_str_has_prefix (request_uri
, "evo-https:");
2440 !redirect_http_uri (extension
, web_page
, request
))
2447 web_page_document_loaded_cb (WebKitWebPage
*web_page
,
2450 WebKitDOMDocument
*document
;
2451 WebKitDOMRange
*range
= NULL
;
2452 WebKitDOMDOMWindow
*dom_window
;
2453 WebKitDOMDOMSelection
*dom_selection
;
2455 g_return_if_fail (WEBKIT_IS_WEB_PAGE (web_page
));
2457 document
= webkit_web_page_get_dom_document (web_page
);
2461 dom_window
= webkit_dom_document_get_default_view (document
);
2462 dom_selection
= webkit_dom_dom_window_get_selection (dom_window
);
2464 /* Make sure there is a cursor located in the body after the document loads. */
2465 if (!webkit_dom_dom_selection_get_anchor_node (dom_selection
) &&
2466 !webkit_dom_dom_selection_get_focus_node (dom_selection
)) {
2467 range
= webkit_dom_document_caret_range_from_point (document
, 0, 0);
2468 webkit_dom_dom_selection_remove_all_ranges (dom_selection
);
2469 webkit_dom_dom_selection_add_range (dom_selection
, range
);
2472 g_clear_object (&range
);
2473 g_clear_object (&dom_selection
);
2474 g_clear_object (&dom_window
);
2478 web_page_created_cb (WebKitWebExtension
*wk_extension
,
2479 WebKitWebPage
*web_page
,
2480 EEditorWebExtension
*extension
)
2482 EEditorPage
*editor_page
;
2485 g_return_if_fail (WEBKIT_IS_WEB_PAGE (web_page
));
2486 g_return_if_fail (E_IS_EDITOR_WEB_EXTENSION (extension
));
2488 ppage_id
= g_new (guint64
, 1);
2489 *ppage_id
= webkit_web_page_get_id (web_page
);
2491 editor_page
= e_editor_page_new (web_page
, extension
);
2492 g_hash_table_insert (extension
->priv
->editor_pages
, ppage_id
, editor_page
);
2494 g_object_weak_ref (G_OBJECT (web_page
), web_page_gone_cb
, extension
);
2497 web_page
, "send-request",
2498 G_CALLBACK (web_page_send_request_cb
), extension
);
2501 web_page
, "document-loaded",
2502 G_CALLBACK (web_page_document_loaded_cb
), NULL
);
2506 e_editor_web_extension_initialize (EEditorWebExtension
*extension
,
2507 WebKitWebExtension
*wk_extension
)
2509 g_return_if_fail (E_IS_EDITOR_WEB_EXTENSION (extension
));
2511 extension
->priv
->wk_extension
= g_object_ref (wk_extension
);
2513 if (emd_global_http_cache
== NULL
) {
2514 emd_global_http_cache
= camel_data_cache_new (
2515 e_get_user_cache_dir (), NULL
);
2517 if (emd_global_http_cache
) {
2518 /* cache expiry - 2 hour access, 1 day max */
2519 camel_data_cache_set_expire_age (
2520 emd_global_http_cache
, 24 * 60 * 60);
2521 camel_data_cache_set_expire_access (
2522 emd_global_http_cache
, 2 * 60 * 60);
2527 wk_extension
, "page-created",
2528 G_CALLBACK (web_page_created_cb
), extension
);
2532 e_editor_web_extension_dbus_register (EEditorWebExtension
*extension
,
2533 GDBusConnection
*connection
)
2535 GError
*error
= NULL
;
2536 static GDBusNodeInfo
*introspection_data
= NULL
;
2538 g_return_if_fail (E_IS_EDITOR_WEB_EXTENSION (extension
));
2539 g_return_if_fail (G_IS_DBUS_CONNECTION (connection
));
2541 if (!introspection_data
) {
2542 introspection_data
=
2543 g_dbus_node_info_new_for_xml (introspection_xml
, NULL
);
2545 extension
->priv
->registration_id
=
2546 g_dbus_connection_register_object (
2548 E_WEBKIT_EDITOR_WEB_EXTENSION_OBJECT_PATH
,
2549 introspection_data
->interfaces
[0],
2555 if (!extension
->priv
->registration_id
) {
2556 g_warning ("Failed to register object: %s\n", error
->message
);
2557 g_error_free (error
);
2559 extension
->priv
->dbus_connection
= connection
;
2560 g_object_add_weak_pointer (
2561 G_OBJECT (connection
),
2562 (gpointer
*) &extension
->priv
->dbus_connection
);
2568 e_editor_web_extension_get_connection (EEditorWebExtension
*extension
)
2570 g_return_val_if_fail (E_IS_EDITOR_WEB_EXTENSION (extension
), NULL
);
2572 return extension
->priv
->dbus_connection
;