Wed, 05 Sep 2007 22:32:14 +0000
propagate from branch 'im.pidgin.pidgin' (head 0853a065e5c3fcb5a6bb13fc23bec44ecf510ecd)
to branch 'im.pidgin.soc.2007.xmpp' (head b273d0db2bdd4a80d0fb22d32fe186e1f496933f)
| 14582 | 1 | #!/usr/bin/python |
| 2 | ||
| 3 | import dbus | |
| 4 | import re | |
| 5 | import sys | |
| 6 | import time | |
| 7 | import urllib | |
| 8 | ||
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
9 | obj = dbus.SessionBus().get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
10 | purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") |
| 14582 | 11 | |
| 12 | class CheckedObject: | |
| 13 | def __init__(self, obj): | |
| 14 | self.obj = obj | |
| 15 | ||
| 16 | def __getattr__(self, attr): | |
| 17 | return CheckedAttribute(self, attr) | |
| 18 | ||
| 19 | class CheckedAttribute: | |
| 20 | def __init__(self, cobj, attr): | |
| 21 | self.cobj = cobj | |
| 22 | self.attr = attr | |
| 23 | ||
| 24 | 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
|
25 | # 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
|
26 | # 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
|
27 | # 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
|
28 | 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
|
29 | sys.stderr = None |
| 14582 | 30 | 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
|
31 | 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
|
32 | |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
33 | # 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
|
34 | # 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
|
35 | # 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
|
36 | |
| 14582 | 37 | return result |
| 38 | ||
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
39 | cpurple = CheckedObject(purple) |
| 14582 | 40 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
41 | 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
|
42 | 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
|
43 | 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
|
44 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
45 | return list |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
46 | |
| 14582 | 47 | def convert(value): |
| 48 | try: | |
| 49 | return int(value) | |
| 50 | except: | |
| 51 | return value | |
| 52 | ||
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
53 | 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
|
54 | # 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
|
55 | 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
|
56 | 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
|
57 | return account |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
58 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
59 | # 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
|
60 | 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
|
61 | 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
|
62 | 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
|
63 | 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
|
64 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
65 | 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
|
66 | 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
|
67 | return account |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
68 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
69 | 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
|
70 | # 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
|
71 | 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
|
72 | if message: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
73 | 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
|
74 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
75 | 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
|
76 | 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
|
77 | 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
|
78 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
79 | 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
|
80 | 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
|
81 | # 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
|
82 | 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
|
83 | if conversation: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
84 | 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
|
85 | break |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
86 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
87 | 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
|
88 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
89 | 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
|
90 | 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
|
91 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
92 | |
| 14582 | 93 | def aim(uri): |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
94 | protocol = "prpl-aim" |
| 16502 | 95 | match = re.match(r"^aim:([^?]*)(\?(.*))", uri) |
| 14582 | 96 | if not match: |
| 97 | print "Invalid aim URI: %s" % uri | |
| 98 | return | |
| 99 | ||
| 16502 | 100 | command = urllib.unquote_plus(match.group(1)) |
| 101 | paramstring = match.group(3) | |
| 14582 | 102 | params = {} |
| 103 | if paramstring: | |
| 104 | for param in paramstring.split("&"): | |
| 105 | key, value = extendlist(param.split("=", 1), 2, "") | |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
106 | params[key] = urllib.unquote_plus(value) |
| 14582 | 107 | accountname = params.get("account", "") |
| 108 | screenname = params.get("screenname", "") | |
| 109 | ||
| 110 | account = findaccount(protocol, accountname) | |
| 111 | ||
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
112 | if command.lower() == "goim": |
| 14582 | 113 | goim(account, screenname, params.get("message")) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
114 | elif command.lower() == "gochat": |
| 14582 | 115 | gochat(account, params) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
116 | elif command.lower() == "addbuddy": |
| 14582 | 117 | addbuddy(account, screenname, params.get("group", "")) |
| 118 | ||
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
119 | 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
|
120 | 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
|
121 | 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
|
122 | 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
|
123 | 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
|
124 | return |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
125 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
126 | 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
|
127 | 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
|
128 | 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
|
129 | |
| 14582 | 130 | def icq(uri): |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
131 | protocol = "prpl-icq" |
| 16502 | 132 | match = re.match(r"^icq:([^?]*)(\?(.*))", uri) |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
133 | if not match: |
| 16502 | 134 | print "Invalid icq URI: %s" % uri |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
135 | return |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
136 | |
| 16502 | 137 | command = urllib.unquote_plus(match.group(1)) |
| 138 | paramstring = match.group(3) | |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
139 | params = {} |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
140 | if paramstring: |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
141 | for param in paramstring.split("&"): |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
142 | key, value = extendlist(param.split("=", 1), 2, "") |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
143 | params[key] = urllib.unquote_plus(value) |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
144 | accountname = params.get("account", "") |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
145 | screenname = params.get("screenname", "") |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
146 | |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
147 | account = findaccount(protocol, accountname) |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
148 | |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
149 | if command.lower() == "goim": |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
150 | goim(account, screenname, params.get("message")) |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
151 | elif command.lower() == "gochat": |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
152 | gochat(account, params) |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
153 | elif command.lower() == "addbuddy": |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
154 | addbuddy(account, screenname, params.get("group", "")) |
| 14582 | 155 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
156 | 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
|
157 | 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
|
158 | 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
|
159 | 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
|
160 | 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
|
161 | return |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
162 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
163 | 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
|
164 | 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
|
165 | 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
|
166 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
167 | modifiers = {} |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
168 | if target: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
169 | 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
|
170 | 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
|
171 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
172 | 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
|
173 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
174 | 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
|
175 | params = {} |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
176 | if paramstring: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
177 | 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
|
178 | 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
|
179 | 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
|
180 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
181 | 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
|
182 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
183 | if (target != ""): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
184 | if (isnick): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
185 | 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
|
186 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
187 | 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
|
188 | 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
|
189 | channel = "#" + channel |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
190 | 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
|
191 | |
| 14582 | 192 | def msnim(uri): |
| 193 | protocol = "prpl-msn" | |
| 194 | match = re.match(r"^msnim:([^?]*)(\?(.*))", uri) | |
| 195 | if not match: | |
| 196 | print "Invalid msnim URI: %s" % uri | |
| 197 | return | |
| 198 | ||
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
199 | command = urllib.unquote_plus(match.group(1)) |
| 14582 | 200 | paramstring = match.group(3) |
| 201 | params = {} | |
| 202 | if paramstring: | |
| 203 | for param in paramstring.split("&"): | |
| 204 | key, value = extendlist(param.split("=", 1), 2, "") | |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
205 | params[key] = urllib.unquote_plus(value) |
| 14582 | 206 | screenname = params.get("contact", "") |
| 207 | ||
| 208 | account = findaccount(protocol) | |
| 209 | ||
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
210 | if command.lower() == "chat": |
| 14582 | 211 | goim(account, screenname) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
212 | elif command.lower() == "add": |
| 14582 | 213 | addbuddy(account, screenname) |
| 214 | ||
|
17904
1128eede9349
explicit merge of 'c5abad45e8a7ccb777ff38f325d074314ca27dcb'
Jeff Connelly <jeff2@soc.pidgin.im>
diff
changeset
|
215 | def myim(uri): |
|
16325
c444cb0defe2
Add stub for myim: URL handler.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16207
diff
changeset
|
216 | protocol = "prpl-myspace" |
|
c444cb0defe2
Add stub for myim: URL handler.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16207
diff
changeset
|
217 | print "TODO: send uri: ", uri |
|
c444cb0defe2
Add stub for myim: URL handler.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16207
diff
changeset
|
218 | assert False, "Not implemented" |
|
c444cb0defe2
Add stub for myim: URL handler.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16207
diff
changeset
|
219 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
220 | 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
|
221 | 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
|
222 | 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
|
223 | 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
|
224 | 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
|
225 | return |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
226 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
227 | 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
|
228 | 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
|
229 | 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
|
230 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
231 | 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
|
232 | 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
|
233 | 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
|
234 | 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
|
235 | 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
|
236 | return |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
237 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
238 | 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
|
239 | if (tmp): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
240 | 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
|
241 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
242 | accountname = "" |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
243 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
244 | 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
|
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(5) |
|
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 | 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
|
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 | command = "" |
|
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 | 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
|
253 | params = {} |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
254 | if paramstring: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
255 | 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
|
256 | 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
|
257 | 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
|
258 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
259 | 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
|
260 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
261 | 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
|
262 | 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
|
263 | 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
|
264 | 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
|
265 | 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
|
266 | 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
|
267 | 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
|
268 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
269 | 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
|
270 | |
| 14582 | 271 | def ymsgr(uri): |
| 272 | protocol = "prpl-yahoo" | |
| 273 | match = re.match(r"^ymsgr:([^?]*)(\?([^&]*)(&(.*))?)", uri) | |
| 274 | if not match: | |
| 275 | print "Invalid ymsgr URI: %s" % uri | |
| 276 | return | |
| 277 | ||
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
278 | command = urllib.unquote_plus(match.group(1)) |
|
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
279 | screenname = urllib.unquote_plus(match.group(3)) |
| 14582 | 280 | paramstring = match.group(5) |
| 281 | params = {} | |
| 282 | if paramstring: | |
| 283 | for param in paramstring.split("&"): | |
| 284 | key, value = extendlist(param.split("=", 1), 2, "") | |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
285 | params[key] = urllib.unquote_plus(value) |
| 14582 | 286 | |
| 287 | account = findaccount(protocol) | |
| 288 | ||
|
14601
8aa717885b14
[gaim-migrate @ 17260]
Richard Laager <rlaager@pidgin.im>
parents:
14597
diff
changeset
|
289 | if command.lower() == "sendim": |
| 14582 | 290 | goim(account, screenname, params.get("m")) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
291 | elif command.lower() == "chat": |
| 14582 | 292 | gochat(account, {"room": screenname}) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
293 | elif command.lower() == "addfriend": |
| 14582 | 294 | addbuddy(account, screenname) |
| 295 | ||
| 296 | ||
| 297 | def main(argv=sys.argv): | |
| 298 | if len(argv) != 2: | |
| 299 | print "Usage: %s URI" % argv[0] | |
| 300 | print "Example: %s \"xmpp:romeo@montague.net?message\"" % argv[0] | |
| 301 | return | |
| 302 | ||
| 303 | 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
|
304 | type = uri.split(":")[0] |
| 14582 | 305 | |
|
16207
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
306 | try: |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
307 | 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
|
308 | 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
|
309 | 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
|
310 | 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
|
311 | 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
|
312 | 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
|
313 | 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
|
314 | 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
|
315 | 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
|
316 | msnim(uri) |
|
16325
c444cb0defe2
Add stub for myim: URL handler.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16207
diff
changeset
|
317 | elif type == "myim": |
|
17904
1128eede9349
explicit merge of 'c5abad45e8a7ccb777ff38f325d074314ca27dcb'
Jeff Connelly <jeff2@soc.pidgin.im>
diff
changeset
|
318 | 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
|
319 | 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
|
320 | sip(uri) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
321 | 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
|
322 | 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
|
323 | 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
|
324 | 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
|
325 | else: |
|
17904
1128eede9349
explicit merge of 'c5abad45e8a7ccb777ff38f325d074314ca27dcb'
Jeff Connelly <jeff2@soc.pidgin.im>
diff
changeset
|
326 | print "Unknown protocol: %s" % type |
|
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 | except dbus.dbus_bindings.DBusException: |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
328 | print "ERROR: Is there a libpurple-powered client (e.g. Pidgin or Finch) running?" |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
329 | |
| 14582 | 330 | |
| 331 | if __name__ == "__main__": | |
| 332 | main() |