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