Mercurial > pidgin
annotate libpurple/purple-url-handler @ 25500:7f984048ab31
Czech, Norwegian Nynorsk, and Slovenian translations updated.
Fixes #8481, #8482, #8484.
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Sun, 22 Feb 2009 16:05:36 +0000 |
parents | 0009541d4ec2 |
children | 971b89243a20 |
rev | line source |
---|---|
22013
fefe61275687
A small patch from shreevatsa: "Some of the Python scripts start with
Richard Laager <rlaager@wiktel.com>
parents:
17262
diff
changeset
|
1 #!/usr/bin/env python |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
2 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
3 import dbus |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
4 import re |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
5 import sys |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
6 import time |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
7 import urllib |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
8 |
23419
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
9 bus = dbus.SessionBus() |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
10 obj = None |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
11 try: |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
12 obj = bus.get_object("im.pidgin.purple.PurpleService", |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
13 "/im/pidgin/purple/PurpleObject") |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
14 except dbus.DBusException, e: |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
15 if e._dbus_error_name == "org.freedesktop.DBus.Error.ServiceUnknown": |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
16 print "Error: no libpurple-powered client is running. Try starting Pidgin or Finch." |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
17 sys.exit(1) |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
18 purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
19 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
20 class CheckedObject: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
21 def __init__(self, obj): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
22 self.obj = obj |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
23 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
24 def __getattr__(self, attr): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
25 return CheckedAttribute(self, attr) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
26 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
27 class CheckedAttribute: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
28 def __init__(self, cobj, attr): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
29 self.cobj = cobj |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
30 self.attr = attr |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
31 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
32 def __call__(self, *args): |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
33 # Redirect stderr to suppress the printing of an " Introspect error" |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
34 # message if nothing is listening on the bus. We print a friendly |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
35 # error message ourselves. |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
36 real_stderr = sys.stderr |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
37 sys.stderr = None |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
38 result = self.cobj.obj.__getattr__(self.attr)(*args) |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
39 sys.stderr = real_stderr |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
40 |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
41 # This can be useful for debugging. |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
42 # if (result == 0): |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
43 # print "Error: " + self.attr + " " + str(args) + " returned " + str(result) |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
44 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
45 return result |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
46 |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
47 cpurple = CheckedObject(purple) |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
48 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
49 def extendlist(list, length, fill): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
50 if len(list) < length: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
51 return list + [fill] * (length - len(list)) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
52 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
53 return list |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
54 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
55 def convert(value): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
56 try: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
57 return int(value) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
58 except: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
59 return value |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
60 |
23420
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
61 def account_not_found(): |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
62 print "No matching account found." |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
63 sys.exit(1) |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
64 |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
65 def bring_account_online(account): |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
66 if not cpurple.PurpleAccountIsConnected(account): |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
67 # The last argument is meant to be a GList * but the D-Bus binding |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
68 # generator thing just wants a UInt32, which is pretty failing. |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
69 # Happily, passing a 0 to mean an empty list turns out to work anyway. |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
70 purple.PurpleAccountSetStatusList(account, "online", 1, 0) |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
71 purple.PurpleAccountConnect(account) |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
72 |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
73 def findaccount(protocolname, accountname="", matcher=None): |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
74 if matcher: |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
75 for account in cpurple.PurpleAccountsGetAll(): |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
76 if accountname != "" and accountname != cpurple.PurpleAccountGetUsername(a): |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
77 continue |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
78 if matcher(account): |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
79 bring_account_online(account) |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
80 return account |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
81 account_not_found() |
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
82 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
83 # prefer connected accounts |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
84 account = cpurple.PurpleAccountsFindConnected(accountname, protocolname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
85 if (account != 0): |
23420
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
86 return account |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
87 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
88 # try to get any account and connect it |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
89 account = cpurple.PurpleAccountsFindAny(accountname, protocolname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
90 if (account == 0): |
23420
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
91 account_not_found() |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
92 |
23420
0c66344d0ed5
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <will.thompson@collabora.co.uk>
parents:
23419
diff
changeset
|
93 bring_account_online(account) |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
94 return account |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
95 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
96 def goim(account, screenname, message=None): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
97 # XXX: 1 == PURPLE_CONV_TYPE_IM |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
98 conversation = cpurple.PurpleConversationNew(1, account, screenname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
99 if message: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
100 purple.PurpleConvSendConfirm(conversation, message) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
101 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
102 def gochat(account, params, message=None): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
103 connection = cpurple.PurpleAccountGetConnection(account) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
104 purple.ServJoinChat(connection, params) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
105 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
106 if message != None: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
107 for i in range(20): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
108 # XXX: 2 == PURPLE_CONV_TYPE_CHAT |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
109 conversation = purple.PurpleFindConversationWithAccount(2, params.get("channel", params.get("room")), account) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
110 if conversation: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
111 purple.PurpleConvSendConfirm(conversation, message) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
112 break |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
113 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
114 time.sleep(0.5) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
115 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
116 def addbuddy(account, screenname, group="", alias=""): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
117 cpurple.PurpleBlistRequestAddBuddy(account, screenname, group, alias) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
118 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
119 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
120 def aim(uri): |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
121 protocol = "prpl-aim" |
16452 | 122 match = re.match(r"^aim:([^?]*)(\?(.*))", uri) |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
123 if not match: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
124 print "Invalid aim URI: %s" % uri |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
125 return |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
126 |
16452 | 127 command = urllib.unquote_plus(match.group(1)) |
128 paramstring = match.group(3) | |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
129 params = {} |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
130 if paramstring: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
131 for param in paramstring.split("&"): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
132 key, value = extendlist(param.split("=", 1), 2, "") |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
133 params[key] = urllib.unquote_plus(value) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
134 accountname = params.get("account", "") |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
135 screenname = params.get("screenname", "") |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
136 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
137 account = findaccount(protocol, accountname) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
138 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
139 if command.lower() == "goim": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
140 goim(account, screenname, params.get("message")) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
141 elif command.lower() == "gochat": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
142 gochat(account, params) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
143 elif command.lower() == "addbuddy": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
144 addbuddy(account, screenname, params.get("group", "")) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
145 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
146 def gg(uri): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
147 protocol = "prpl-gg" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
148 match = re.match(r"^gg:(.*)", uri) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
149 if not match: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
150 print "Invalid gg URI: %s" % uri |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
151 return |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
152 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
153 screenname = urllib.unquote_plus(match.group(1)) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
154 account = findaccount(protocol) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
155 goim(account, screenname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
156 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
157 def icq(uri): |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
158 protocol = "prpl-icq" |
16452 | 159 match = re.match(r"^icq:([^?]*)(\?(.*))", uri) |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
160 if not match: |
16452 | 161 print "Invalid icq URI: %s" % uri |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
162 return |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
163 |
16452 | 164 command = urllib.unquote_plus(match.group(1)) |
165 paramstring = match.group(3) | |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
166 params = {} |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
167 if paramstring: |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
168 for param in paramstring.split("&"): |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
169 key, value = extendlist(param.split("=", 1), 2, "") |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
170 params[key] = urllib.unquote_plus(value) |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
171 accountname = params.get("account", "") |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
172 screenname = params.get("screenname", "") |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
173 |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
174 account = findaccount(protocol, accountname) |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
175 |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
176 if command.lower() == "goim": |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
177 goim(account, screenname, params.get("message")) |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
178 elif command.lower() == "gochat": |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
179 gochat(account, params) |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
180 elif command.lower() == "addbuddy": |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
181 addbuddy(account, screenname, params.get("group", "")) |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
182 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
183 def irc(uri): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
184 protocol = "prpl-irc" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
185 match = re.match(r"^irc:(//([^/]*)/)?([^?]*)(\?(.*))?", uri) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
186 if not match: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
187 print "Invalid irc URI: %s" % uri |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
188 return |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
189 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
190 server = urllib.unquote_plus(match.group(2)) or "" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
191 target = match.group(3) or "" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
192 query = match.group(5) or "" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
193 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
194 modifiers = {} |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
195 if target: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
196 for modifier in target.split(",")[1:]: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
197 modifiers[modifier] = True |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
198 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
199 isnick = modifiers.has_key("isnick") |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
200 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
201 paramstring = match.group(5) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
202 params = {} |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
203 if paramstring: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
204 for param in paramstring.split("&"): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
205 key, value = extendlist(param.split("=", 1), 2, "") |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
206 params[key] = urllib.unquote_plus(value) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
207 |
23421
668b62240235
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <will.thompson@collabora.co.uk>
parents:
23420
diff
changeset
|
208 def correct_server(account): |
668b62240235
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <will.thompson@collabora.co.uk>
parents:
23420
diff
changeset
|
209 username = cpurple.PurpleAccountGetUsername(account) |
25371
0009541d4ec2
In the course of looking at purple-url-handler to compose a response to a
Richard Laager <rlaager@wiktel.com>
parents:
24889
diff
changeset
|
210 user_split = (username.split("@")) |
0009541d4ec2
In the course of looking at purple-url-handler to compose a response to a
Richard Laager <rlaager@wiktel.com>
parents:
24889
diff
changeset
|
211 # Not all accounts have a split, so append an empty string so the |
0009541d4ec2
In the course of looking at purple-url-handler to compose a response to a
Richard Laager <rlaager@wiktel.com>
parents:
24889
diff
changeset
|
212 # [1] doesn't throw an IndexError. |
0009541d4ec2
In the course of looking at purple-url-handler to compose a response to a
Richard Laager <rlaager@wiktel.com>
parents:
24889
diff
changeset
|
213 user_split.append("") |
0009541d4ec2
In the course of looking at purple-url-handler to compose a response to a
Richard Laager <rlaager@wiktel.com>
parents:
24889
diff
changeset
|
214 return (server == user_split[1]) |
23421
668b62240235
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <will.thompson@collabora.co.uk>
parents:
23420
diff
changeset
|
215 |
668b62240235
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <will.thompson@collabora.co.uk>
parents:
23420
diff
changeset
|
216 account = findaccount(protocol, matcher=correct_server) |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
217 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
218 if (target != ""): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
219 if (isnick): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
220 goim(account, urllib.unquote_plus(target.split(",")[0]), params.get("msg")) |
23421
668b62240235
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <will.thompson@collabora.co.uk>
parents:
23420
diff
changeset
|
221 else: |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
222 channel = urllib.unquote_plus(target.split(",")[0]) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
223 if channel[0] != "#": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
224 channel = "#" + channel |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
225 gochat(account, {"server": server, "channel": channel, "password": params.get("key", "")}, params.get("msg")) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
226 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
227 def msnim(uri): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
228 protocol = "prpl-msn" |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
229 match = re.match(r"^msnim:([^?]*)(\?(.*))", uri) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
230 if not match: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
231 print "Invalid msnim URI: %s" % uri |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
232 return |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
233 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
234 command = urllib.unquote_plus(match.group(1)) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
235 paramstring = match.group(3) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
236 params = {} |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
237 if paramstring: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
238 for param in paramstring.split("&"): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
239 key, value = extendlist(param.split("=", 1), 2, "") |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
240 params[key] = urllib.unquote_plus(value) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
241 screenname = params.get("contact", "") |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
242 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
243 account = findaccount(protocol) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
244 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
245 if command.lower() == "chat": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
246 goim(account, screenname) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
247 elif command.lower() == "add": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
248 addbuddy(account, screenname) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
249 |
17262
8a7238fb7905
explicit merge of 'dc4f2ee34039521ae6a198fe7d62f4dca8a84589'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
250 def myim(uri): |
23422
ab1f79d3ceeb
Remove some tab literals from purple-url-handler, for consistency and for
Will Thompson <will.thompson@collabora.co.uk>
parents:
23421
diff
changeset
|
251 protocol = "prpl-myspace" |
ab1f79d3ceeb
Remove some tab literals from purple-url-handler, for consistency and for
Will Thompson <will.thompson@collabora.co.uk>
parents:
23421
diff
changeset
|
252 print "TODO: send uri: ", uri |
ab1f79d3ceeb
Remove some tab literals from purple-url-handler, for consistency and for
Will Thompson <will.thompson@collabora.co.uk>
parents:
23421
diff
changeset
|
253 assert False, "Not implemented" |
16397
81015b477483
Add stub for myim: URL handler.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16145
diff
changeset
|
254 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
255 def sip(uri): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
256 protocol = "prpl-simple" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
257 match = re.match(r"^sip:(.*)", uri) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
258 if not match: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
259 print "Invalid sip URI: %s" % uri |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
260 return |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
261 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
262 screenname = urllib.unquote_plus(match.group(1)) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
263 account = findaccount(protocol) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
264 goim(account, screenname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
265 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
266 def xmpp(uri): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
267 protocol = "prpl-jabber" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
268 match = re.match(r"^xmpp:(//([^/?#]*)/?)?([^?#]*)(\?([^;#]*)(;([^#]*))?)?(#(.*))?", uri) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
269 if not match: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
270 print "Invalid xmpp URI: %s" % uri |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
271 return |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
272 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
273 tmp = match.group(2) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
274 if (tmp): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
275 accountname = urllib.unquote_plus(tmp) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
276 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
277 accountname = "" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
278 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
279 screenname = urllib.unquote_plus(match.group(3)) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
280 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
281 tmp = match.group(5) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
282 if (tmp): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
283 command = urllib.unquote_plus(tmp) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
284 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
285 command = "" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
286 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
287 paramstring = match.group(7) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
288 params = {} |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
289 if paramstring: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
290 for param in paramstring.split(";"): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
291 key, value = extendlist(param.split("=", 1), 2, "") |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
292 params[key] = urllib.unquote_plus(value) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
293 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
294 account = findaccount(protocol, accountname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
295 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
296 if command.lower() == "message": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
297 goim(account, screenname, params.get("body")) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
298 elif command.lower() == "join": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
299 room, server = screenname.split("@") |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
300 gochat(account, {"room": room, "server": server}) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
301 elif command.lower() == "roster": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
302 addbuddy(account, screenname, params.get("group", ""), params.get("name", "")) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
303 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
304 goim(account, screenname) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
305 |
24889
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
306 def gtalk(uri): |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
307 protocol = "prpl-jabber" |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
308 match = re.match(r"^gtalk:([^?]*)(\?(.*))", uri) |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
309 if not match: |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
310 print "Invalid gtalk URI: %s" % uri |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
311 return |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
312 |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
313 command = urllib.unquote_plus(match.group(1)) |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
314 paramstring = match.group(3) |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
315 params = {} |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
316 if paramstring: |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
317 for param in paramstring.split("&"): |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
318 key, value = extendlist(param.split("=", 1), 2, "") |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
319 params[key] = urllib.unquote_plus(value) |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
320 accountname = params.get("from_jid", "") |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
321 jid = params.get("jid", "") |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
322 |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
323 account = findaccount(protocol, accountname) |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
324 |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
325 if command.lower() == "chat": |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
326 goim(account, jid) |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
327 elif command.lower() == "call": |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
328 # XXX V&V prompt to establish call |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
329 goim(account, jid) |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
330 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
331 def ymsgr(uri): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
332 protocol = "prpl-yahoo" |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
333 match = re.match(r"^ymsgr:([^?]*)(\?([^&]*)(&(.*))?)", uri) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
334 if not match: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
335 print "Invalid ymsgr URI: %s" % uri |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
336 return |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
337 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
338 command = urllib.unquote_plus(match.group(1)) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
339 screenname = urllib.unquote_plus(match.group(3)) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
340 paramstring = match.group(5) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
341 params = {} |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
342 if paramstring: |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
343 for param in paramstring.split("&"): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
344 key, value = extendlist(param.split("=", 1), 2, "") |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
345 params[key] = urllib.unquote_plus(value) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
346 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
347 account = findaccount(protocol) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
348 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
349 if command.lower() == "sendim": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
350 goim(account, screenname, params.get("m")) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
351 elif command.lower() == "chat": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
352 gochat(account, {"room": screenname}) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
353 elif command.lower() == "addfriend": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
354 addbuddy(account, screenname) |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
355 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
356 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
357 def main(argv=sys.argv): |
23070
4b4be7609072
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22013
diff
changeset
|
358 if len(argv) != 2 or argv[1] == "--help" or argv[1] == "-h": |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
359 print "Usage: %s URI" % argv[0] |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
360 print "Example: %s \"xmpp:romeo@montague.net?message\"" % argv[0] |
23070
4b4be7609072
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22013
diff
changeset
|
361 |
4b4be7609072
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22013
diff
changeset
|
362 if len(argv) != 2: |
4b4be7609072
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22013
diff
changeset
|
363 sys.exit(1) |
4b4be7609072
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22013
diff
changeset
|
364 else: |
4b4be7609072
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22013
diff
changeset
|
365 return 0 |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
366 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
367 uri = argv[1] |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
368 type = uri.split(":")[0] |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
369 |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
370 try: |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
371 if type == "aim": |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
372 aim(uri) |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
373 elif type == "gg": |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
374 gg(uri) |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
375 elif type == "icq": |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
376 icq(uri) |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
377 elif type == "irc": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
378 irc(uri) |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
379 elif type == "msnim": |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
380 msnim(uri) |
16397
81015b477483
Add stub for myim: URL handler.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16145
diff
changeset
|
381 elif type == "myim": |
17262
8a7238fb7905
explicit merge of 'dc4f2ee34039521ae6a198fe7d62f4dca8a84589'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
382 myim(uri) |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
383 elif type == "sip": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
384 sip(uri) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
385 elif type == "xmpp": |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
386 xmpp(uri) |
24889
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
387 elif type == "gtalk": |
c260fe3ac5c8
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <paul@darkrain42.org>
parents:
23422
diff
changeset
|
388 gtalk(uri) |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
389 elif type == "ymsgr": |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
390 ymsgr(uri) |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
391 else: |
17262
8a7238fb7905
explicit merge of 'dc4f2ee34039521ae6a198fe7d62f4dca8a84589'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
392 print "Unknown protocol: %s" % type |
23419
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
393 except dbus.DBusException, e: |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
394 print "Error: %s" % (e.message) |
0565c227608d
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23070
diff
changeset
|
395 sys.exit(1) |
15884
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
396 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
397 if __name__ == "__main__": |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
398 main() |