Mercurial > pidgin
annotate libpurple/purple-url-handler @ 23419:0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
If there's no libpurple object on the bus, then we'll never get to the uber
exception handler that previously swallowed all exceptions and suggested that
maybe no client is running.
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Thu, 03 Jul 2008 15:38:49 +0000 |
parents | 4b4be7609072 |
children | 0c66344d0ed5 |
rev | line source |
---|---|
22013
fefe61275687
A small patch from shreevatsa: "Some of the Python scripts start with
Richard Laager <rlaager@wiktel.com>
parents:
17262
diff
changeset
|
1 #!/usr/bin/env python |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
2 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
3 import dbus |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
4 import re |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
5 import sys |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
6 import time |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
7 import urllib |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
8 |
23419
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
9 bus = dbus.SessionBus() |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
10 obj = None |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
11 try: |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
12 obj = bus.get_object("im.pidgin.purple.PurpleService", |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
13 "/im/pidgin/purple/PurpleObject") |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
14 except dbus.DBusException, e: |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
15 if e._dbus_error_name == "org.freedesktop.DBus.Error.ServiceUnknown": |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
16 print "Error: no libpurple-powered client is running. Try starting Pidgin or Finch." |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
17 sys.exit(1) |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
18 purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
19 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
20 class CheckedObject: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
21 def __init__(self, obj): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
22 self.obj = obj |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
23 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
24 def __getattr__(self, attr): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
25 return CheckedAttribute(self, attr) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
26 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
27 class CheckedAttribute: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
28 def __init__(self, cobj, attr): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
29 self.cobj = cobj |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
30 self.attr = attr |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
31 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
32 def __call__(self, *args): |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
33 # Redirect stderr to suppress the printing of an " Introspect error" |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
34 # message if nothing is listening on the bus. We print a friendly |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
35 # error message ourselves. |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
36 real_stderr = sys.stderr |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
37 sys.stderr = None |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
38 result = self.cobj.obj.__getattr__(self.attr)(*args) |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
39 sys.stderr = real_stderr |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
40 |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
41 # This can be useful for debugging. |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
42 # if (result == 0): |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
43 # print "Error: " + self.attr + " " + str(args) + " returned " + str(result) |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
44 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
45 return result |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
46 |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
47 cpurple = CheckedObject(purple) |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
48 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
49 def extendlist(list, length, fill): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
50 if len(list) < length: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
51 return list + [fill] * (length - len(list)) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
52 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
53 return list |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
54 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
55 def convert(value): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
56 try: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
57 return int(value) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
58 except: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
59 return value |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
60 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
61 def findaccount(protocolname, accountname=""): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
62 # prefer connected accounts |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
63 account = cpurple.PurpleAccountsFindConnected(accountname, protocolname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
64 if (account != 0): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
65 return account |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
66 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
67 # try to get any account and connect it |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
68 account = cpurple.PurpleAccountsFindAny(accountname, protocolname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
69 if (account == 0): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
70 print "No matching account found." |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
71 sys.exit(1) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
72 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
73 purple.PurpleAccountSetStatusVargs(account, "online", 1) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
74 purple.PurpleAccountConnect(account) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
75 return account |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
76 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
77 def goim(account, screenname, message=None): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
78 # XXX: 1 == PURPLE_CONV_TYPE_IM |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
79 conversation = cpurple.PurpleConversationNew(1, account, screenname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
80 if message: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
81 purple.PurpleConvSendConfirm(conversation, message) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
82 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
83 def gochat(account, params, message=None): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
84 connection = cpurple.PurpleAccountGetConnection(account) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
85 purple.ServJoinChat(connection, params) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
86 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
87 if message != None: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
88 for i in range(20): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
89 # XXX: 2 == PURPLE_CONV_TYPE_CHAT |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
90 conversation = purple.PurpleFindConversationWithAccount(2, params.get("channel", params.get("room")), account) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
91 if conversation: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
92 purple.PurpleConvSendConfirm(conversation, message) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
93 break |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
94 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
95 time.sleep(0.5) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
96 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
97 def addbuddy(account, screenname, group="", alias=""): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
98 cpurple.PurpleBlistRequestAddBuddy(account, screenname, group, alias) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
99 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
100 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
101 def aim(uri): |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
102 protocol = "prpl-aim" |
16452 | 103 match = re.match(r"^aim:([^?]*)(\?(.*))", uri) |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
104 if not match: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
105 print "Invalid aim URI: %s" % uri |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
106 return |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
107 |
16452 | 108 command = urllib.unquote_plus(match.group(1)) |
109 paramstring = match.group(3) | |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
110 params = {} |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
111 if paramstring: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
112 for param in paramstring.split("&"): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
113 key, value = extendlist(param.split("=", 1), 2, "") |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
114 params[key] = urllib.unquote_plus(value) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
115 accountname = params.get("account", "") |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
116 screenname = params.get("screenname", "") |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
117 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
118 account = findaccount(protocol, accountname) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
119 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
120 if command.lower() == "goim": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
121 goim(account, screenname, params.get("message")) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
122 elif command.lower() == "gochat": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
123 gochat(account, params) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
124 elif command.lower() == "addbuddy": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
125 addbuddy(account, screenname, params.get("group", "")) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
126 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
127 def gg(uri): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
128 protocol = "prpl-gg" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
129 match = re.match(r"^gg:(.*)", uri) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
130 if not match: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
131 print "Invalid gg URI: %s" % uri |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
132 return |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
133 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
134 screenname = urllib.unquote_plus(match.group(1)) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
135 account = findaccount(protocol) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
136 goim(account, screenname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
137 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
138 def icq(uri): |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
139 protocol = "prpl-icq" |
16452 | 140 match = re.match(r"^icq:([^?]*)(\?(.*))", uri) |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
141 if not match: |
16452 | 142 print "Invalid icq URI: %s" % uri |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
143 return |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
144 |
16452 | 145 command = urllib.unquote_plus(match.group(1)) |
146 paramstring = match.group(3) | |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
147 params = {} |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
148 if paramstring: |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
149 for param in paramstring.split("&"): |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
150 key, value = extendlist(param.split("=", 1), 2, "") |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
151 params[key] = urllib.unquote_plus(value) |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
152 accountname = params.get("account", "") |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
153 screenname = params.get("screenname", "") |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
154 |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
155 account = findaccount(protocol, accountname) |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
156 |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
157 if command.lower() == "goim": |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
158 goim(account, screenname, params.get("message")) |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
159 elif command.lower() == "gochat": |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
160 gochat(account, params) |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
161 elif command.lower() == "addbuddy": |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
162 addbuddy(account, screenname, params.get("group", "")) |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
163 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
164 def irc(uri): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
165 protocol = "prpl-irc" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
166 match = re.match(r"^irc:(//([^/]*)/)?([^?]*)(\?(.*))?", uri) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
167 if not match: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
168 print "Invalid irc URI: %s" % uri |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
169 return |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
170 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
171 server = urllib.unquote_plus(match.group(2)) or "" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
172 target = match.group(3) or "" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
173 query = match.group(5) or "" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
174 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
175 modifiers = {} |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
176 if target: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
177 for modifier in target.split(",")[1:]: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
178 modifiers[modifier] = True |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
179 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
180 isnick = modifiers.has_key("isnick") |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
181 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
182 paramstring = match.group(5) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
183 params = {} |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
184 if paramstring: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
185 for param in paramstring.split("&"): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
186 key, value = extendlist(param.split("=", 1), 2, "") |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
187 params[key] = urllib.unquote_plus(value) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
188 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
189 account = findaccount(protocol) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
190 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
191 if (target != ""): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
192 if (isnick): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
193 goim(account, urllib.unquote_plus(target.split(",")[0]), params.get("msg")) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
194 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
195 channel = urllib.unquote_plus(target.split(",")[0]) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
196 if channel[0] != "#": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
197 channel = "#" + channel |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
198 gochat(account, {"server": server, "channel": channel, "password": params.get("key", "")}, params.get("msg")) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
199 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
200 def msnim(uri): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
201 protocol = "prpl-msn" |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
202 match = re.match(r"^msnim:([^?]*)(\?(.*))", uri) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
203 if not match: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
204 print "Invalid msnim URI: %s" % uri |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
205 return |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
206 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
207 command = urllib.unquote_plus(match.group(1)) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
208 paramstring = match.group(3) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
209 params = {} |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
210 if paramstring: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
211 for param in paramstring.split("&"): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
212 key, value = extendlist(param.split("=", 1), 2, "") |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
213 params[key] = urllib.unquote_plus(value) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
214 screenname = params.get("contact", "") |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
215 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
216 account = findaccount(protocol) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
217 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
218 if command.lower() == "chat": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
219 goim(account, screenname) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
220 elif command.lower() == "add": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
221 addbuddy(account, screenname) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
222 |
17262
8a7238fb7905
explicit merge of 'dc4f2ee34039521ae6a198fe7d62f4dca8a84589'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
223 def myim(uri): |
16397
81015b477483
Add stub for myim: URL handler.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16145
diff
changeset
|
224 protocol = "prpl-myspace" |
81015b477483
Add stub for myim: URL handler.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16145
diff
changeset
|
225 print "TODO: send uri: ", uri |
81015b477483
Add stub for myim: URL handler.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16145
diff
changeset
|
226 assert False, "Not implemented" |
81015b477483
Add stub for myim: URL handler.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16145
diff
changeset
|
227 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
228 def sip(uri): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
229 protocol = "prpl-simple" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
230 match = re.match(r"^sip:(.*)", uri) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
231 if not match: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
232 print "Invalid sip URI: %s" % uri |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
233 return |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
234 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
235 screenname = urllib.unquote_plus(match.group(1)) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
236 account = findaccount(protocol) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
237 goim(account, screenname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
238 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
239 def xmpp(uri): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
240 protocol = "prpl-jabber" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
241 match = re.match(r"^xmpp:(//([^/?#]*)/?)?([^?#]*)(\?([^;#]*)(;([^#]*))?)?(#(.*))?", uri) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
242 if not match: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
243 print "Invalid xmpp URI: %s" % uri |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
244 return |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
245 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
246 tmp = match.group(2) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
247 if (tmp): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
248 accountname = urllib.unquote_plus(tmp) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
249 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
250 accountname = "" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
251 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
252 screenname = urllib.unquote_plus(match.group(3)) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
253 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
254 tmp = match.group(5) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
255 if (tmp): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
256 command = urllib.unquote_plus(tmp) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
257 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
258 command = "" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
259 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
260 paramstring = match.group(7) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
261 params = {} |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
262 if paramstring: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
263 for param in paramstring.split(";"): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
264 key, value = extendlist(param.split("=", 1), 2, "") |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
265 params[key] = urllib.unquote_plus(value) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
266 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
267 account = findaccount(protocol, accountname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
268 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
269 if command.lower() == "message": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
270 goim(account, screenname, params.get("body")) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
271 elif command.lower() == "join": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
272 room, server = screenname.split("@") |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
273 gochat(account, {"room": room, "server": server}) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
274 elif command.lower() == "roster": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
275 addbuddy(account, screenname, params.get("group", ""), params.get("name", "")) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
276 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
277 goim(account, screenname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
278 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
279 def ymsgr(uri): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
280 protocol = "prpl-yahoo" |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
281 match = re.match(r"^ymsgr:([^?]*)(\?([^&]*)(&(.*))?)", uri) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
282 if not match: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
283 print "Invalid ymsgr URI: %s" % uri |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
284 return |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
285 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
286 command = urllib.unquote_plus(match.group(1)) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
287 screenname = urllib.unquote_plus(match.group(3)) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
288 paramstring = match.group(5) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
289 params = {} |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
290 if paramstring: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
291 for param in paramstring.split("&"): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
292 key, value = extendlist(param.split("=", 1), 2, "") |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
293 params[key] = urllib.unquote_plus(value) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
294 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
295 account = findaccount(protocol) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
296 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
297 if command.lower() == "sendim": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
298 goim(account, screenname, params.get("m")) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
299 elif command.lower() == "chat": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
300 gochat(account, {"room": screenname}) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
301 elif command.lower() == "addfriend": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
302 addbuddy(account, screenname) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
303 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
304 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
305 def main(argv=sys.argv): |
23070
4b4be7609072
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22013
diff
changeset
|
306 if len(argv) != 2 or argv[1] == "--help" or argv[1] == "-h": |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
307 print "Usage: %s URI" % argv[0] |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
308 print "Example: %s \"xmpp:romeo@montague.net?message\"" % argv[0] |
23070
4b4be7609072
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22013
diff
changeset
|
309 |
4b4be7609072
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22013
diff
changeset
|
310 if len(argv) != 2: |
4b4be7609072
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22013
diff
changeset
|
311 sys.exit(1) |
4b4be7609072
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22013
diff
changeset
|
312 else: |
4b4be7609072
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22013
diff
changeset
|
313 return 0 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
314 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
315 uri = argv[1] |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
316 type = uri.split(":")[0] |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
317 |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
318 try: |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
319 if type == "aim": |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
320 aim(uri) |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
321 elif type == "gg": |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
322 gg(uri) |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
323 elif type == "icq": |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
324 icq(uri) |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
325 elif type == "irc": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
326 irc(uri) |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
327 elif type == "msnim": |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
328 msnim(uri) |
16397
81015b477483
Add stub for myim: URL handler.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16145
diff
changeset
|
329 elif type == "myim": |
17262
8a7238fb7905
explicit merge of 'dc4f2ee34039521ae6a198fe7d62f4dca8a84589'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
330 myim(uri) |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
331 elif type == "sip": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
332 sip(uri) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
333 elif type == "xmpp": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
334 xmpp(uri) |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
335 elif type == "ymsgr": |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
336 ymsgr(uri) |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
337 else: |
17262
8a7238fb7905
explicit merge of 'dc4f2ee34039521ae6a198fe7d62f4dca8a84589'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
338 print "Unknown protocol: %s" % type |
23419
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
339 except dbus.DBusException, e: |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
340 print "Error: %s" % (e.message) |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
341 sys.exit(1) |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
342 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
343 if __name__ == "__main__": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
344 main() |