Mercurial > pidgin
comparison libpurple/purple-url-handler @ 30578:0accc8adb18a
merge of '2f6318bd834113559a405ec68cdb178f2180b680'
and '64e02b98551e11e093e4649f1516f3aceaa321e2'
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sun, 26 Sep 2010 20:16:15 +0000 |
parents | adef21420870 |
children | 380314aa5c1b |
comparison
equal
deleted
inserted
replaced
30577:7b761c8601f7 | 30578:0accc8adb18a |
---|---|
71 purple.PurpleAccountConnect(account) | 71 purple.PurpleAccountConnect(account) |
72 | 72 |
73 def findaccount(protocolname, accountname="", matcher=None): | 73 def findaccount(protocolname, accountname="", matcher=None): |
74 if matcher: | 74 if matcher: |
75 for account in cpurple.PurpleAccountsGetAll(): | 75 for account in cpurple.PurpleAccountsGetAll(): |
76 if accountname != "" and accountname != cpurple.PurpleAccountGetUsername(a): | 76 if (protocolname != cpurple.PurpleAccountGetProtocolID(account)) or \ |
77 (accountname != "" and accountname != cpurple.PurpleAccountGetUsername(account)): | |
77 continue | 78 continue |
78 if matcher(account): | 79 if matcher(account): |
79 bring_account_online(account) | 80 bring_account_online(account) |
80 return account | 81 return account |
81 account_not_found() | 82 account_not_found() |
180 elif command.lower() == "addbuddy": | 181 elif command.lower() == "addbuddy": |
181 addbuddy(account, screenname, params.get("group", "")) | 182 addbuddy(account, screenname, params.get("group", "")) |
182 | 183 |
183 def irc(uri): | 184 def irc(uri): |
184 protocol = "prpl-irc" | 185 protocol = "prpl-irc" |
185 match = re.match(r"^irc:(//([^/]*)/)?([^?]*)(\?(.*))?", uri) | 186 match = re.match(r"^irc:(//([^/]*))?/?([^?]*)(\?(.*))?", uri) |
186 if not match: | 187 if not match: |
187 print "Invalid irc URI: %s" % uri | 188 print "Invalid irc URI: %s" % uri |
188 return | 189 return |
189 | 190 |
190 server = urllib.unquote_plus(match.group(2)) or "" | 191 server = urllib.unquote_plus(match.group(2)) or "" |
205 key, value = extendlist(param.split("=", 1), 2, "") | 206 key, value = extendlist(param.split("=", 1), 2, "") |
206 params[key] = urllib.unquote_plus(value) | 207 params[key] = urllib.unquote_plus(value) |
207 | 208 |
208 def correct_server(account): | 209 def correct_server(account): |
209 username = cpurple.PurpleAccountGetUsername(account) | 210 username = cpurple.PurpleAccountGetUsername(account) |
210 return ("@" in username) and (server == (username.split("@"))[1]) | 211 return ((server == "") or ("@" in username) and (server == (username.split("@"))[1])) |
211 | 212 |
212 account = findaccount(protocol, matcher=correct_server) | 213 account = findaccount(protocol, matcher=correct_server) |
213 | 214 |
214 if (target != ""): | 215 if (target != ""): |
215 if (isnick): | 216 if (isnick): |