Fri, 18 Jan 2013 03:51:05 -0500
Move blist loading into purple_core_init.
The comments say we want to move this into purple_blist_init, but that
seems like it would be problematic. We need the UI ops to be set, which
moves blist init after UI init. But stuff needs blist signals to be
registered before UI init, etc., etc. It seemed like a pain to work that
all out. I made purple_blist_boot for purple_core_init to call after the
UI init happened. It could have been called _load, but I didn't want
people to accidentally continue calling it.
|
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 | ||
|
23563
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
61 | def account_not_found(): |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
62 | print "No matching account found." |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
63 | sys.exit(1) |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
64 | |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
65 | def bring_account_online(account): |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
66 | if not cpurple.PurpleAccountIsConnected(account): |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
67 | # The last argument is meant to be a GList * but the D-Bus binding |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
68 | # generator thing just wants a UInt32, which is pretty failing. |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
69 | # Happily, passing a 0 to mean an empty list turns out to work anyway. |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
70 | purple.PurpleAccountSetStatusList(account, "online", 1, 0) |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
71 | purple.PurpleAccountConnect(account) |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
72 | |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
73 | def findaccount(protocolname, accountname="", matcher=None): |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
74 | if matcher: |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
75 | for account in cpurple.PurpleAccountsGetAll(): |
|
31582
c561e11657b0
Fix some issues with purple-url-handler.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30530
diff
changeset
|
76 | if (protocolname != cpurple.PurpleAccountGetProtocolId(account)) or \ |
|
30530
8f5fecc9b6c8
Some fixes to IRC handling in purple-url-handler, mainly to fix
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
26065
diff
changeset
|
77 | (accountname != "" and accountname != cpurple.PurpleAccountGetUsername(account)): |
|
23563
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
78 | continue |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
79 | if matcher(account): |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
80 | bring_account_online(account) |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
81 | return account |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
82 | account_not_found() |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
83 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
84 | # 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
|
85 | 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
|
86 | if (account != 0): |
|
23563
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
87 | return account |
|
17323
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 | # 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
|
90 | 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
|
91 | if (account == 0): |
|
23563
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
92 | account_not_found() |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
93 | |
|
23563
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
94 | bring_account_online(account) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
95 | return account |
|
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 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
|
98 | # 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
|
99 | 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
|
100 | if message: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
101 | 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
|
102 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
103 | 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
|
104 | 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
|
105 | 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
|
106 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
107 | 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
|
108 | 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
|
109 | # 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
|
110 | 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
|
111 | if conversation: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
112 | 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
|
113 | break |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
114 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
115 | 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
|
116 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
117 | 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
|
118 | 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
|
119 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
120 | |
| 14582 | 121 | def aim(uri): |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
122 | protocol = "prpl-aim" |
| 16502 | 123 | match = re.match(r"^aim:([^?]*)(\?(.*))", uri) |
| 14582 | 124 | if not match: |
| 125 | print "Invalid aim URI: %s" % uri | |
| 126 | return | |
| 127 | ||
| 16502 | 128 | command = urllib.unquote_plus(match.group(1)) |
| 129 | paramstring = match.group(3) | |
| 14582 | 130 | params = {} |
| 131 | if paramstring: | |
| 132 | for param in paramstring.split("&"): | |
| 133 | key, value = extendlist(param.split("=", 1), 2, "") | |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
134 | params[key] = urllib.unquote_plus(value) |
| 14582 | 135 | accountname = params.get("account", "") |
| 136 | screenname = params.get("screenname", "") | |
| 137 | ||
| 138 | account = findaccount(protocol, accountname) | |
| 139 | ||
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
140 | if command.lower() == "goim": |
| 14582 | 141 | goim(account, screenname, params.get("message")) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
142 | elif command.lower() == "gochat": |
| 14582 | 143 | gochat(account, params) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
144 | elif command.lower() == "addbuddy": |
| 14582 | 145 | addbuddy(account, screenname, params.get("group", "")) |
| 146 | ||
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
147 | 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
|
148 | 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
|
149 | 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
|
150 | 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
|
151 | 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
|
152 | return |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
153 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
154 | 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
|
155 | 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
|
156 | 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
|
157 | |
| 14582 | 158 | def icq(uri): |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
159 | protocol = "prpl-icq" |
| 16502 | 160 | match = re.match(r"^icq:([^?]*)(\?(.*))", uri) |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
161 | if not match: |
| 16502 | 162 | print "Invalid icq URI: %s" % uri |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
163 | return |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
164 | |
| 16502 | 165 | command = urllib.unquote_plus(match.group(1)) |
| 166 | paramstring = match.group(3) | |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
167 | params = {} |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
168 | if paramstring: |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
169 | for param in paramstring.split("&"): |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
170 | key, value = extendlist(param.split("=", 1), 2, "") |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
171 | params[key] = urllib.unquote_plus(value) |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
172 | accountname = params.get("account", "") |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
173 | screenname = params.get("screenname", "") |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
174 | |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
175 | account = findaccount(protocol, accountname) |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
176 | |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
177 | if command.lower() == "goim": |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
178 | goim(account, screenname, params.get("message")) |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
179 | elif command.lower() == "gochat": |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
180 | gochat(account, params) |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
181 | elif command.lower() == "addbuddy": |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
182 | addbuddy(account, screenname, params.get("group", "")) |
| 14582 | 183 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
184 | 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
|
185 | protocol = "prpl-irc" |
|
30530
8f5fecc9b6c8
Some fixes to IRC handling in purple-url-handler, mainly to fix
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
26065
diff
changeset
|
186 | match = re.match(r"^irc:(//([^/]*))?/?([^?]*)(\?(.*))?", uri) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
187 | 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
|
188 | 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
|
189 | return |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
190 | |
|
31582
c561e11657b0
Fix some issues with purple-url-handler.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30530
diff
changeset
|
191 | server = urllib.unquote_plus(match.group(2) or "") |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
192 | 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
|
193 | 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
|
194 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
195 | modifiers = {} |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
196 | if target: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
197 | 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
|
198 | 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
|
199 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
200 | 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
|
201 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
202 | 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
|
203 | params = {} |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
204 | if paramstring: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
205 | 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
|
206 | 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
|
207 | 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
|
208 | |
|
23564
9ccc8c1ddc6b
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <resiak@pidgin.im>
parents:
23563
diff
changeset
|
209 | def correct_server(account): |
|
9ccc8c1ddc6b
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <resiak@pidgin.im>
parents:
23563
diff
changeset
|
210 | username = cpurple.PurpleAccountGetUsername(account) |
|
30530
8f5fecc9b6c8
Some fixes to IRC handling in purple-url-handler, mainly to fix
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
26065
diff
changeset
|
211 | return ((server == "") or ("@" in username) and (server == (username.split("@"))[1])) |
|
23564
9ccc8c1ddc6b
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <resiak@pidgin.im>
parents:
23563
diff
changeset
|
212 | |
|
9ccc8c1ddc6b
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <resiak@pidgin.im>
parents:
23563
diff
changeset
|
213 | account = findaccount(protocol, matcher=correct_server) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
214 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
215 | if (target != ""): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
216 | if (isnick): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
217 | goim(account, urllib.unquote_plus(target.split(",")[0]), params.get("msg")) |
|
23564
9ccc8c1ddc6b
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <resiak@pidgin.im>
parents:
23563
diff
changeset
|
218 | else: |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
219 | 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
|
220 | 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
|
221 | channel = "#" + channel |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
222 | 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
|
223 | |
| 14582 | 224 | def msnim(uri): |
| 225 | protocol = "prpl-msn" | |
| 226 | match = re.match(r"^msnim:([^?]*)(\?(.*))", uri) | |
| 227 | if not match: | |
| 228 | print "Invalid msnim URI: %s" % uri | |
| 229 | return | |
| 230 | ||
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
231 | command = urllib.unquote_plus(match.group(1)) |
| 14582 | 232 | paramstring = match.group(3) |
| 233 | params = {} | |
| 234 | if paramstring: | |
| 235 | for param in paramstring.split("&"): | |
| 236 | key, value = extendlist(param.split("=", 1), 2, "") | |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
237 | params[key] = urllib.unquote_plus(value) |
| 14582 | 238 | screenname = params.get("contact", "") |
| 239 | ||
| 240 | account = findaccount(protocol) | |
| 241 | ||
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
242 | if command.lower() == "chat": |
| 14582 | 243 | goim(account, screenname) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
244 | elif command.lower() == "add": |
| 14582 | 245 | addbuddy(account, screenname) |
| 246 | ||
|
17904
1128eede9349
explicit merge of 'c5abad45e8a7ccb777ff38f325d074314ca27dcb'
Jeff Connelly <jeff2@soc.pidgin.im>
diff
changeset
|
247 | def myim(uri): |
|
23565
3f1a5a63a051
Remove some tab literals from purple-url-handler, for consistency and for
Will Thompson <resiak@pidgin.im>
parents:
23564
diff
changeset
|
248 | protocol = "prpl-myspace" |
|
3f1a5a63a051
Remove some tab literals from purple-url-handler, for consistency and for
Will Thompson <resiak@pidgin.im>
parents:
23564
diff
changeset
|
249 | print "TODO: send uri: ", uri |
|
3f1a5a63a051
Remove some tab literals from purple-url-handler, for consistency and for
Will Thompson <resiak@pidgin.im>
parents:
23564
diff
changeset
|
250 | assert False, "Not implemented" |
|
16325
c444cb0defe2
Add stub for myim: URL handler.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16207
diff
changeset
|
251 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
252 | 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
|
253 | 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
|
254 | 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
|
255 | 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
|
256 | 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
|
257 | return |
|
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 | 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
|
260 | 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
|
261 | 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
|
262 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
263 | 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
|
264 | 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
|
265 | 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
|
266 | 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
|
267 | 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
|
268 | return |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
269 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
270 | 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
|
271 | if (tmp): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
272 | 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
|
273 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
274 | accountname = "" |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
275 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
276 | 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
|
277 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
278 | 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
|
279 | if (tmp): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
280 | 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
|
281 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
282 | command = "" |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
283 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
284 | 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
|
285 | params = {} |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
286 | if paramstring: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
287 | 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
|
288 | 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
|
289 | 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
|
290 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
291 | 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
|
292 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
293 | 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
|
294 | 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
|
295 | 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
|
296 | 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
|
297 | 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
|
298 | 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
|
299 | 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
|
300 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
301 | 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
|
302 | |
|
25327
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
303 | def gtalk(uri): |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
304 | protocol = "prpl-jabber" |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
305 | match = re.match(r"^gtalk:([^?]*)(\?(.*))", uri) |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
306 | if not match: |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
307 | print "Invalid gtalk URI: %s" % uri |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
308 | return |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
309 | |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
310 | command = urllib.unquote_plus(match.group(1)) |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
311 | paramstring = match.group(3) |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
312 | params = {} |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
313 | if paramstring: |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
314 | for param in paramstring.split("&"): |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
315 | key, value = extendlist(param.split("=", 1), 2, "") |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
316 | params[key] = urllib.unquote_plus(value) |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
317 | accountname = params.get("from_jid", "") |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
318 | jid = params.get("jid", "") |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
319 | |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
320 | account = findaccount(protocol, accountname) |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
321 | |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
322 | if command.lower() == "chat": |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
323 | goim(account, jid) |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
324 | elif command.lower() == "call": |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
325 | # XXX V&V prompt to establish call |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
326 | goim(account, jid) |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
327 | |
| 14582 | 328 | def ymsgr(uri): |
| 329 | protocol = "prpl-yahoo" | |
| 330 | match = re.match(r"^ymsgr:([^?]*)(\?([^&]*)(&(.*))?)", uri) | |
| 331 | if not match: | |
| 332 | print "Invalid ymsgr URI: %s" % uri | |
| 333 | return | |
| 334 | ||
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
335 | command = urllib.unquote_plus(match.group(1)) |
|
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
336 | screenname = urllib.unquote_plus(match.group(3)) |
| 14582 | 337 | paramstring = match.group(5) |
| 338 | params = {} | |
| 339 | if paramstring: | |
| 340 | for param in paramstring.split("&"): | |
| 341 | key, value = extendlist(param.split("=", 1), 2, "") | |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
342 | params[key] = urllib.unquote_plus(value) |
| 14582 | 343 | |
| 344 | account = findaccount(protocol) | |
| 345 | ||
|
14601
8aa717885b14
[gaim-migrate @ 17260]
Richard Laager <rlaager@pidgin.im>
parents:
14597
diff
changeset
|
346 | if command.lower() == "sendim": |
| 14582 | 347 | goim(account, screenname, params.get("m")) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
348 | elif command.lower() == "chat": |
| 14582 | 349 | gochat(account, {"room": screenname}) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
350 | elif command.lower() == "addfriend": |
| 14582 | 351 | addbuddy(account, screenname) |
| 352 | ||
| 353 | ||
| 354 | def main(argv=sys.argv): | |
|
23237
7ec42e06496f
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22141
diff
changeset
|
355 | if len(argv) != 2 or argv[1] == "--help" or argv[1] == "-h": |
| 14582 | 356 | print "Usage: %s URI" % argv[0] |
| 357 | 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
|
358 | |
|
7ec42e06496f
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22141
diff
changeset
|
359 | if len(argv) != 2: |
|
7ec42e06496f
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22141
diff
changeset
|
360 | sys.exit(1) |
|
7ec42e06496f
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22141
diff
changeset
|
361 | else: |
|
7ec42e06496f
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22141
diff
changeset
|
362 | return 0 |
| 14582 | 363 | |
| 364 | 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
|
365 | type = uri.split(":")[0] |
| 14582 | 366 | |
|
16207
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
367 | try: |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
368 | 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
|
369 | 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
|
370 | 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
|
371 | 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
|
372 | 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
|
373 | 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
|
374 | 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
|
375 | 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
|
376 | 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
|
377 | msnim(uri) |
|
16325
c444cb0defe2
Add stub for myim: URL handler.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16207
diff
changeset
|
378 | elif type == "myim": |
|
17904
1128eede9349
explicit merge of 'c5abad45e8a7ccb777ff38f325d074314ca27dcb'
Jeff Connelly <jeff2@soc.pidgin.im>
diff
changeset
|
379 | 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
|
380 | 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
|
381 | sip(uri) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
382 | 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
|
383 | xmpp(uri) |
|
25327
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
384 | elif type == "gtalk": |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
385 | gtalk(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
|
386 | 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
|
387 | 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
|
388 | else: |
|
17904
1128eede9349
explicit merge of 'c5abad45e8a7ccb777ff38f325d074314ca27dcb'
Jeff Connelly <jeff2@soc.pidgin.im>
diff
changeset
|
389 | 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
|
390 | except dbus.DBusException, e: |
|
312323547538
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <resiak@pidgin.im>
parents:
23237
diff
changeset
|
391 | 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
|
392 | sys.exit(1) |
| 14582 | 393 | |
| 394 | if __name__ == "__main__": | |
| 395 | main() |