Mercurial > pidgin
annotate libpurple/purple-url-handler @ 22790:946f1bb22adb
Always top-align the logs in the log-viewer.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 29 Apr 2008 21:44:54 +0000 |
parents | fefe61275687 |
children | 4b4be7609072 |
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 |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
9 obj = dbus.SessionBus().get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
10 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
|
11 |
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
|
12 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
|
13 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
|
14 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
|
15 |
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
|
16 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
|
17 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
|
18 |
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 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
|
20 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
|
21 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
|
22 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
|
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 __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
|
25 # 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
|
26 # 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
|
27 # 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
|
28 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
|
29 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
|
30 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
|
31 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
|
32 |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
33 # 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
|
34 # 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
|
35 # 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
|
36 |
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
|
37 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
|
38 |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
39 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
|
40 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
41 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
|
42 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
|
43 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
|
44 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
45 return list |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
46 |
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
|
47 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
53 def findaccount(protocolname, accountname=""): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
54 # 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
|
55 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
|
56 if (account != 0): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
57 return account |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
58 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
59 # 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
|
60 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
|
61 if (account == 0): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
62 print "No matching account found." |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
63 sys.exit(1) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
64 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
65 purple.PurpleAccountSetStatusVargs(account, "online", 1) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
66 purple.PurpleAccountConnect(account) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
67 return account |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
68 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
69 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
|
70 # 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
|
71 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
|
72 if message: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
73 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
|
74 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
75 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
|
76 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
|
77 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
|
78 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
79 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
|
80 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
|
81 # 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
|
82 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
|
83 if conversation: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
84 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
|
85 break |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
86 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
87 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
|
88 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
89 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
|
90 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
|
91 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
92 |
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
|
93 def aim(uri): |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
94 protocol = "prpl-aim" |
16452 | 95 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
|
96 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
|
97 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
|
98 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
|
99 |
16452 | 100 command = urllib.unquote_plus(match.group(1)) |
101 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
110 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
|
111 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 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
|
123 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
|
124 return |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
125 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
126 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
|
127 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
|
128 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
|
129 |
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
|
130 def icq(uri): |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
131 protocol = "prpl-icq" |
16452 | 132 match = re.match(r"^icq:([^?]*)(\?(.*))", uri) |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
133 if not match: |
16452 | 134 print "Invalid icq URI: %s" % uri |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
135 return |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
136 |
16452 | 137 command = urllib.unquote_plus(match.group(1)) |
138 paramstring = match.group(3) | |
16143
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
139 params = {} |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
140 if paramstring: |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
141 for param in paramstring.split("&"): |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
142 key, value = extendlist(param.split("=", 1), 2, "") |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
143 params[key] = urllib.unquote_plus(value) |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
144 accountname = params.get("account", "") |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
145 screenname = params.get("screenname", "") |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
146 |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
147 account = findaccount(protocol, accountname) |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
148 |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
149 if command.lower() == "goim": |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
150 goim(account, screenname, params.get("message")) |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
151 elif command.lower() == "gochat": |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
152 gochat(account, params) |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
153 elif command.lower() == "addbuddy": |
598b1b15b199
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents:
15884
diff
changeset
|
154 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
|
155 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
156 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
|
157 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
|
158 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
|
159 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
|
160 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
|
161 return |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
162 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
163 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
|
164 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
|
165 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
|
166 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
167 modifiers = {} |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
168 if target: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
169 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
|
170 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
|
171 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
172 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
|
173 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
174 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
|
175 params = {} |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
176 if paramstring: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
177 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
|
178 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
|
179 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
|
180 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
181 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
|
182 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
183 if (target != ""): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
184 if (isnick): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
185 goim(account, urllib.unquote_plus(target.split(",")[0]), params.get("msg")) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
186 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
187 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
|
188 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
|
189 channel = "#" + channel |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
190 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
|
191 |
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
|
192 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
|
193 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
|
194 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
|
195 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
|
196 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
|
197 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
|
198 |
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
|
199 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
|
200 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
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
208 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
|
209 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
210 if 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
|
211 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
|
212 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
|
213 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
|
214 |
17262
8a7238fb7905
explicit merge of 'dc4f2ee34039521ae6a198fe7d62f4dca8a84589'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
215 def myim(uri): |
16397
81015b477483
Add stub for myim: URL handler.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16145
diff
changeset
|
216 protocol = "prpl-myspace" |
81015b477483
Add stub for myim: URL handler.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16145
diff
changeset
|
217 print "TODO: send uri: ", uri |
81015b477483
Add stub for myim: URL handler.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16145
diff
changeset
|
218 assert False, "Not implemented" |
81015b477483
Add stub for myim: URL handler.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16145
diff
changeset
|
219 |
17226
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
220 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
|
221 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
|
222 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
|
223 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
|
224 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
|
225 return |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
226 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
227 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
|
228 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
|
229 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
|
230 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
231 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
|
232 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
|
233 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
|
234 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
|
235 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
|
236 return |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
237 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
238 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
|
239 if (tmp): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
240 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
|
241 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
242 accountname = "" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
243 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
244 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
|
245 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
246 tmp = match.group(5) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
247 if (tmp): |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
248 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
|
249 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
250 command = "" |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
251 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
252 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
|
253 params = {} |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
254 if paramstring: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
255 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
|
256 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
|
257 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
|
258 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
259 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
|
260 |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
261 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
|
262 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
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 else: |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
269 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
|
270 |
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
|
271 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
|
272 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
|
273 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
|
274 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
|
275 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
|
276 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
|
277 |
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
|
278 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
|
279 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
|
280 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
|
281 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
|
282 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
|
283 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
|
284 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
|
285 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
|
286 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
287 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
|
288 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
289 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
|
290 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
|
291 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
|
292 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
|
293 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
|
294 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
|
295 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
296 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
297 def main(argv=sys.argv): |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
298 if len(argv) != 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
|
299 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
|
300 print "Example: %s \"xmpp:romeo@montague.net?message\"" % 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
|
301 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
|
302 |
c6e563dfaa7a
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
303 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
|
304 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
|
305 |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
306 try: |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
307 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
|
308 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
|
309 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
|
310 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
|
311 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
|
312 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
|
313 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
|
314 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
|
315 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
|
316 msnim(uri) |
16397
81015b477483
Add stub for myim: URL handler.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16145
diff
changeset
|
317 elif type == "myim": |
17262
8a7238fb7905
explicit merge of 'dc4f2ee34039521ae6a198fe7d62f4dca8a84589'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
318 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
|
319 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
|
320 sip(uri) |
5059a0a071a2
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <stu@nosnilmot.com>
parents:
17037
diff
changeset
|
321 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
|
322 xmpp(uri) |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
323 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
|
324 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
|
325 else: |
17262
8a7238fb7905
explicit merge of 'dc4f2ee34039521ae6a198fe7d62f4dca8a84589'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
326 print "Unknown protocol: %s" % type |
16145
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
327 except dbus.dbus_bindings.DBusException: |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
328 print "ERROR: Is there a libpurple-powered client (e.g. Pidgin or Finch) running?" |
d06673964ff9
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@wiktel.com>
parents:
16143
diff
changeset
|
329 |
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
|
330 |
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 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
|
332 main() |