Mercurial > firefox-enso
annotate enso_pyxpcom.py @ 3:21f5e1dc0a4c default tip
text selection for firefox will return the full contents of the current text field if no text is selected. also, the seldict contains references to the currently-focused element and window, if any.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Fri, 09 May 2008 12:59:10 -0700 |
parents | 4f22928c7a2c |
children |
rev | line source |
---|---|
0
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
1 from xpcom import components, verbose |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
2 import sys, os |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
3 import logging |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
4 import platform |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
5 |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
6 _ensoStarted = False |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
7 |
1 | 8 ENSO_PATH = os.path.join(os.getenv("HOME"), "Documents/enso-svn") |
9 LOGGING_FILE = os.path.join(os.getenv("HOME"), "enso_pyxpcom.log") | |
10 | |
2
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
11 def getFuelApplication(): |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
12 from xpcom import components |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
13 fuel_cls = components.classes["@mozilla.org/fuel/application;1"] |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
14 fuel_abs = fuel_cls.createInstance() |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
15 fuel_if = components.interfaces.fuelIApplication |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
16 return fuel_abs.queryInterface(fuel_if) |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
17 |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
18 def getCommandDispatcher(): |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
19 ci = components.interfaces |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
20 cc = components.classes |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
21 |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
22 Application = getFuelApplication() |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
23 document = Application.activeWindow.activeTab.document |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
24 |
3
21f5e1dc0a4c
text selection for firefox will return the full contents of the current text field if no text is selected. also, the seldict contains references to the currently-focused element and window, if any.
Atul Varma <varmaa@toolness.com>
parents:
2
diff
changeset
|
25 mediator = cc["@mozilla.org/appshell/window-mediator;1"].getService( |
21f5e1dc0a4c
text selection for firefox will return the full contents of the current text field if no text is selected. also, the seldict contains references to the currently-focused element and window, if any.
Atul Varma <varmaa@toolness.com>
parents:
2
diff
changeset
|
26 ci.nsIWindowMediator |
21f5e1dc0a4c
text selection for firefox will return the full contents of the current text field if no text is selected. also, the seldict contains references to the currently-focused element and window, if any.
Atul Varma <varmaa@toolness.com>
parents:
2
diff
changeset
|
27 ) |
2
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
28 window = mediator.getMostRecentWindow("navigator:browser") |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
29 return window.document.commandDispatcher |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
30 |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
31 def firefoxSelectionHook(): |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
32 import AppKit |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
33 |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
34 app = AppKit.NSWorkspace.sharedWorkspace().activeApplication() |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
35 if app["NSApplicationProcessIdentifier"] == os.getpid(): |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
36 return getFirefoxSelection() |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
37 else: |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
38 from enso.platform.osx import selection |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
39 |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
40 return selection._old_get() |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
41 |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
42 def getFirefoxSelection(): |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
43 text = "" |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
44 dispatcher = getCommandDispatcher() |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
45 |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
46 if dispatcher.focusedElement: |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
47 start = dispatcher.focusedElement.selectionStart |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
48 end = dispatcher.focusedElement.selectionEnd |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
49 if start != end: |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
50 text = dispatcher.focusedElement.value[start:end] |
3
21f5e1dc0a4c
text selection for firefox will return the full contents of the current text field if no text is selected. also, the seldict contains references to the currently-focused element and window, if any.
Atul Varma <varmaa@toolness.com>
parents:
2
diff
changeset
|
51 else: |
21f5e1dc0a4c
text selection for firefox will return the full contents of the current text field if no text is selected. also, the seldict contains references to the currently-focused element and window, if any.
Atul Varma <varmaa@toolness.com>
parents:
2
diff
changeset
|
52 text = dispatcher.focusedElement.value |
2
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
53 elif dispatcher.focusedWindow: |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
54 sel = dispatcher.focusedWindow.getSelection() |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
55 if sel.rangeCount >= 1: |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
56 text = sel.toString() |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
57 |
3
21f5e1dc0a4c
text selection for firefox will return the full contents of the current text field if no text is selected. also, the seldict contains references to the currently-focused element and window, if any.
Atul Varma <varmaa@toolness.com>
parents:
2
diff
changeset
|
58 return {"text" : text, |
21f5e1dc0a4c
text selection for firefox will return the full contents of the current text field if no text is selected. also, the seldict contains references to the currently-focused element and window, if any.
Atul Varma <varmaa@toolness.com>
parents:
2
diff
changeset
|
59 "dom.element" : dispatcher.focusedElement, |
21f5e1dc0a4c
text selection for firefox will return the full contents of the current text field if no text is selected. also, the seldict contains references to the currently-focused element and window, if any.
Atul Varma <varmaa@toolness.com>
parents:
2
diff
changeset
|
60 "dom.window" : dispatcher.focusedWindow} |
2
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
61 |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
62 def installFirefoxSelectionHook(): |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
63 from enso.platform.osx import selection |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
64 |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
65 selection._old_get = selection.get |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
66 selection.get = firefoxSelectionHook |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
67 |
0
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
68 def getAbout(): |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
69 global _ensoStarted |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
70 |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
71 if not _ensoStarted: |
1 | 72 logging.info("Importing Enso.") |
73 sys.path.append(ENSO_PATH) | |
74 | |
75 import enso | |
2
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
76 |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
77 logging.info("Installing Firefox selection hook.") |
4f22928c7a2c
Added firefox selection context, so it's now possible to use enso in firefox (otherwise, the command-c injection wasn't working b/c I guess you can't inject events into your own process).
Atul Varma <varmaa@toolness.com>
parents:
1
diff
changeset
|
78 installFirefoxSelectionHook() |
0
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
79 logging.info("Launching Enso.") |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
80 _ensoStarted = True |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
81 enso.run() |
1 | 82 |
0
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
83 return "Enso is running." |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
84 |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
85 class ShutdownObserver: |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
86 _com_interfaces_ = components.interfaces.nsIObserver |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
87 |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
88 def observe(self, subject, topic, data): |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
89 print "quit-application received; calling sys.exitfunc()." |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
90 sys.exitfunc() |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
91 |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
92 class AboutPython: |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
93 _com_interfaces_ = components.interfaces.nsIAboutModule |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
94 _reg_contractid_ = '@mozilla.org/network/protocol/about;1?what=enso' |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
95 _reg_clsid_ = '{6d5d462e-6de7-4bca-bbc6-c488d481351c}' |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
96 _reg_desc_ = "about:enso handler" |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
97 |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
98 def __init__(self): |
1 | 99 logging.basicConfig(level=logging.INFO, |
100 filename=LOGGING_FILE, | |
101 filemode="w") | |
0
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
102 logging.info("Setting shutdown observer.") |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
103 observerService = components.classes["@mozilla.org/observer-service;1"].getService(components.interfaces.nsIObserverService) |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
104 observerService.addObserver(ShutdownObserver(), "quit-application", False) |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
105 |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
106 def newChannel(self, aURI): |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
107 ioService = components.classes["@mozilla.org/network/io-service;1"] \ |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
108 .getService(); |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
109 |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
110 istream = components.classes["@mozilla.org/io/string-input-stream;1"] \ |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
111 .createInstance() |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
112 |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
113 about = getAbout() |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
114 istream.setData(about, len(about)) |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
115 |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
116 channel = components.classes["@mozilla.org/network/input-stream-channel;1"] \ |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
117 .createInstance(components.interfaces.nsIInputStreamChannel) |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
118 |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
119 channel.setURI(aURI) |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
120 #channel.contentType = "text/html" |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
121 channel.contentStream = istream |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
122 return channel |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
123 |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
124 def getURIFlags(self, aURI): |
b1c0ab5d5f14
Origination, originally taken from the about:python source code from pyxpcom.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
125 return 0; |