annotate libpurple/purple-url-handler @ 16143:598b1b15b199

Trac Ticket #149 from JensenDied This patch does a rename of our DBus stuff.
author Richard Laager <rlaager@wiktel.com>
date Sun, 15 Apr 2007 18:09:14 +0000
parents c6e563dfaa7a
children d06673964ff9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15885
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
1 #!/usr/bin/python
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: 15885
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: 15885
diff changeset
10 purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
15885
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):
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 result = self.cobj.obj.__getattr__(self.attr)(*args)
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 if result == 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
27 raise "Error: " + self.attr + " " + str(args) + " returned " + str(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
28 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
29
16143
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
30 cpurple = CheckedObject(purple)
15885
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 extendlist(list, length, fill):
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
33 if len(list) < length:
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
34 return list + [fill] * (length - len(list))
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
35 else:
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
36 return list
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
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 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
39 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
40 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
41 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
42 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
43
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
44 def findaccount(protocolname, 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
45 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
46 # prefer connected accounts
16143
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
47 account = cpurple.PurpleAccountsFindConnected(accountname, protocolname)
15885
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 return 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
49 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
50 # try to get any account and connect it
16143
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
51 account = cpurple.PurpleAccountsFindAny(accountname, protocolname)
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
52 purple.PurpleAccountSetStatusVargs(account, "online", 1)
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
53 purple.PurpleAccountConnect(account)
15885
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
54 return 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
55
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 def goim(account, screenname, message=None):
16143
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
57 # XXX: 1 == PURPLE_CONV_TYPE_IM
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
58 conversation = cpurple.PurpleConversationNew(1, account, screenname)
15885
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 if message:
16143
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
60 purple.PurpleConvSendConfirm(conversation, message)
15885
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
61
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
62 def gochat(account, params, message=None):
16143
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
63 connection = cpurple.PurpleAccountGetConnection(account)
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
64 purple.ServJoinChat(connection, params)
15885
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
65
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
66 if message != None:
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
67 for i in range(20):
16143
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
68 # XXX: 2 == PURPLE_CONV_TYPE_CHAT
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
69 conversation = purple.PurpleFindConversationWithAccount(2, params.get("channel", params.get("room")), account)
15885
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
70 if conversation:
16143
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
71 purple.PurpleConvSendConfirm(conversation, message)
15885
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
72 break
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
73 else:
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
74 time.sleep(0.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
75
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
76 def addbuddy(account, screenname, group="", alias=""):
16143
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
77 cpurple.PurpleBlistRequestAddBuddy(account, screenname, group, alias)
15885
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
78
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
79
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
80 def aim(uri):
16143
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
81 protocol = "prpl-aim"
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
82 match = re.match(r"^(aim):([^?]*)(\?(.*))", uri)
15885
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
83 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
84 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
85 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
86
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
87 command = urllib.unquote_plus(match.group(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
88 paramstring = match.group(4)
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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96
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 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
98
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 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
100 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
101 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
102 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
103 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
104 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
105
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 def gg(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
107 protocol = "prpl-gg"
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 match = re.match(r"^gg:(.*)", 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
109 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
110 print "Invalid gg 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
111 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
112
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 screenname = 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
114 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
115 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
116
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 def icq(uri):
16143
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
118 protocol = "prpl-icq"
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
119 match = re.match(r"^(icq):([^?]*)(\?(.*))", uri)
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
120 if not match:
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
121 print "Invalid aim URI: %s" % uri
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
122 return
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
123
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
124 command = urllib.unquote_plus(match.group(2))
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
125 paramstring = match.group(4)
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
126 params = {}
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
127 if paramstring:
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
128 for param in paramstring.split("&"):
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
129 key, value = extendlist(param.split("=", 1), 2, "")
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
130 params[key] = urllib.unquote_plus(value)
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
131 accountname = params.get("account", "")
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
132 screenname = params.get("screenname", "")
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
133
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
134 account = findaccount(protocol, accountname)
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
135
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
136 if command.lower() == "goim":
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
137 goim(account, screenname, params.get("message"))
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
138 elif command.lower() == "gochat":
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
139 gochat(account, params)
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
140 elif command.lower() == "addbuddy":
598b1b15b199 Trac Ticket #149 from JensenDied
Richard Laager <rlaager@wiktel.com>
parents: 15885
diff changeset
141 addbuddy(account, screenname, params.get("group", ""))
15885
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
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 def irc(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
144 protocol = "prpl-irc"
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 match = re.match(r"^irc:(//([^/]*)/)?([^?]*)(\?(.*))?", 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
146 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
147 print "Invalid irc 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
148 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
149
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
150 server = urllib.unquote_plus(match.group(2)) or ""
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
151 target = match.group(3) or ""
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
152 query = match.group(5) or ""
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
153
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
154 modifiers = {}
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 if target:
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
156 for modifier in target.split(",")[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
157 modifiers[modifier] = True
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
158
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
159 isnick = modifiers.has_key("isnick")
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
160
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
161 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
162 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
163 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
164 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
165 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
166 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
167
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
168 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
169
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
170 if (target != ""):
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
171 if (isnick):
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
172 goim(account, urllib.unquote_plus(target.split(",")[0]), params.get("msg"))
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
173 else:
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
174 channel = urllib.unquote_plus(target.split(",")[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
175 if channel[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
176 channel = "#" + channel
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
177 gochat(account, {"server": server, "channel": channel, "password": params.get("key", "")}, params.get("msg"))
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
178
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
179 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
180 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
181 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
182 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
183 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
184 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
185
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
186 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
187 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
188 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
189 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
190 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
191 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
192 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
193 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
194
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 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
196
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 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
198 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
199 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
200 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
201
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 def sip(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
203 protocol = "prpl-simple"
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 match = re.match(r"^sip:(.*)", 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
205 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
206 print "Invalid sip 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
207 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
208
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 screenname = 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
210 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
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
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 def xmpp(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
214 protocol = "prpl-jabber"
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
215 match = re.match(r"^xmpp:((//)?([^/?#]*))?(/?([^?#]*))(\?([^;#]*)(;([^#]*))?)?(#(.*))?", 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
216 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
217 print "Invalid xmpp 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
218 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
219
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
220 tmp = 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
221 if (tmp):
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
222 accountname = urllib.unquote_plus(tmp)
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
223 else:
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
224 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
225
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
226 screenname = urllib.unquote_plus(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
227
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 tmp = match.group(7)
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 if (tmp):
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 command = urllib.unquote_plus(tmp)
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 else:
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 command = ""
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 paramstring = match.group(9)
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 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
236 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
237 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
238 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
239 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
240
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 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
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 if command.lower() == "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
244 goim(account, screenname, params.get("body"))
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 elif command.lower() == "join":
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 room, server = screenname.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
247 gochat(account, {"room": room, "server": server})
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 elif command.lower() == "roster":
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 addbuddy(account, screenname, params.get("group", ""), params.get("name", ""))
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
250 else:
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
251 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
252
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
253 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
254 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
255 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
256 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
257 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
258 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
259
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
260 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
261 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
262 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
263 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
264 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
265 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
266 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
267 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
268
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
269 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
270
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 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
272 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
273 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
274 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
275 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
276 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
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
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 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
280 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
281 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
282 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
283 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
284
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 uri = argv[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
286 type = uri.split(":")[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
287
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 if type == "aim":
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 aim(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
290 elif type == "gg":
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 gg(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
292 elif type == "icq":
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 icq(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
294 elif type == "irc":
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 irc(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
296 elif type == "msnim":
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 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
298 elif type == "sip":
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 sip(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
300 elif type == "xmpp":
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 xmpp(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
302 elif type == "ymsgr":
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 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
304 else:
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 print "Unkown protocol: %s" % type
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
306
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
307 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
308 main()