diff libpurple/purple-url-handler @ 17405:0b0b2a86c379

propagate from branch 'org.maemo.garage.pidgin.pidgin.aop_menu' (head 24d32faecffc36ede5a0abf75df4c6db4f3eb5b7) to branch 'im.pidgin.pidgin' (head dc4f2ee34039521ae6a198fe7d62f4dca8a84589)
author Richard Laager <rlaager@wiktel.com>
date Fri, 25 May 2007 18:19:28 +0000
parents 5059a0a071a2
children 8a7238fb7905
line wrap: on
line diff
--- a/libpurple/purple-url-handler	Tue May 22 21:23:34 2007 +0000
+++ b/libpurple/purple-url-handler	Fri May 25 18:19:28 2007 +0000
@@ -44,12 +44,6 @@
     else:
         return list
 
-def convert(value):
-    try:
-        return int(value)
-    except:
-        return value
-
 def findaccount(protocolname, accountname=""):
     # prefer connected accounts
     account = cpurple.PurpleAccountsFindConnected(accountname, protocolname)
@@ -90,32 +84,6 @@
     cpurple.PurpleBlistRequestAddBuddy(account, screenname, group, alias)
 
 
-def aim(uri):
-    protocol = "prpl-aim"
-    match = re.match(r"^aim:([^?]*)(\?(.*))", uri)
-    if not match:
-        print "Invalid aim URI: %s" % uri
-        return
-
-    command = urllib.unquote_plus(match.group(1))
-    paramstring = match.group(3)
-    params = {}
-    if paramstring:
-        for param in paramstring.split("&"):
-            key, value = extendlist(param.split("=", 1), 2, "")
-            params[key] = urllib.unquote_plus(value)
-    accountname = params.get("account", "")
-    screenname = params.get("screenname", "")
-
-    account = findaccount(protocol, accountname)
-
-    if command.lower() == "goim":
-        goim(account, screenname, params.get("message"))
-    elif command.lower() == "gochat":
-        gochat(account, params)
-    elif command.lower() == "addbuddy":
-        addbuddy(account, screenname, params.get("group", ""))
-
 def gg(uri):
     protocol = "prpl-gg"
     match = re.match(r"^gg:(.*)", uri)
@@ -127,32 +95,6 @@
     account = findaccount(protocol)
     goim(account, screenname)
 
-def icq(uri):
-    protocol = "prpl-icq"
-    match = re.match(r"^icq:([^?]*)(\?(.*))", uri)
-    if not match:
-        print "Invalid icq URI: %s" % uri
-        return
-
-    command = urllib.unquote_plus(match.group(1))
-    paramstring = match.group(3)
-    params = {}
-    if paramstring:
-        for param in paramstring.split("&"):
-            key, value = extendlist(param.split("=", 1), 2, "")
-            params[key] = urllib.unquote_plus(value)
-    accountname = params.get("account", "")
-    screenname = params.get("screenname", "")
-
-    account = findaccount(protocol, accountname)
-
-    if command.lower() == "goim":
-        goim(account, screenname, params.get("message"))
-    elif command.lower() == "gochat":
-        gochat(account, params)
-    elif command.lower() == "addbuddy":
-        addbuddy(account, screenname, params.get("group", ""))
-
 def irc(uri):
     protocol = "prpl-irc"
     match = re.match(r"^irc:(//([^/]*)/)?([^?]*)(\?(.*))?", uri)
@@ -189,29 +131,6 @@
                 channel = "#" + channel
             gochat(account, {"server": server, "channel": channel, "password": params.get("key", "")}, params.get("msg"))
 
-def msnim(uri):
-    protocol = "prpl-msn"
-    match = re.match(r"^msnim:([^?]*)(\?(.*))", uri)
-    if not match:
-        print "Invalid msnim URI: %s" % uri
-        return
-
-    command = urllib.unquote_plus(match.group(1))
-    paramstring = match.group(3)
-    params = {}
-    if paramstring:
-        for param in paramstring.split("&"):
-            key, value = extendlist(param.split("=", 1), 2, "")
-            params[key] = urllib.unquote_plus(value)
-    screenname = params.get("contact", "")
-
-    account = findaccount(protocol)
-
-    if command.lower() == "chat":
-        goim(account, screenname)
-    elif command.lower() == "add":
-        addbuddy(account, screenname)
-
 def sip(uri):
     protocol = "prpl-simple"
     match = re.match(r"^sip:(.*)", uri)
@@ -263,32 +182,6 @@
     else:
         goim(account, screenname)
 
-def ymsgr(uri):
-    protocol = "prpl-yahoo"
-    match = re.match(r"^ymsgr:([^?]*)(\?([^&]*)(&(.*))?)", uri)
-    if not match:
-        print "Invalid ymsgr URI: %s" % uri
-        return
-
-    command = urllib.unquote_plus(match.group(1))
-    screenname = urllib.unquote_plus(match.group(3))
-    paramstring = match.group(5)
-    params = {}
-    if paramstring:
-        for param in paramstring.split("&"):
-            key, value = extendlist(param.split("=", 1), 2, "")
-            params[key] = urllib.unquote_plus(value)
-
-    account = findaccount(protocol)
-
-    if command.lower() == "sendim":
-        goim(account, screenname, params.get("m"))
-    elif command.lower() == "chat":
-        gochat(account, {"room": screenname})
-    elif command.lower() == "addfriend":
-        addbuddy(account, screenname)
-
-
 def main(argv=sys.argv):
     if len(argv) != 2:
         print "Usage: %s URI" % argv[0]
@@ -299,24 +192,16 @@
     type = uri.split(":")[0]
 
     try:
-        if type == "aim":
-            aim(uri)
-        elif type == "gg":
+        if type == "gg":
             gg(uri)
-        elif type == "icq":
-            icq(uri)
         elif type == "irc":
             irc(uri)
-        elif type == "msnim":
-            msnim(uri)
         elif type == "sip":
             sip(uri)
         elif type == "xmpp":
             xmpp(uri)
-        elif type == "ymsgr":
-            ymsgr(uri)
         else:
-            print "Unkown protocol: %s" % type
+            cpurple.PurpleGotProtocolHandlerUri(uri)
     except dbus.dbus_bindings.DBusException:
         print "ERROR: Is there a libpurple-powered client (e.g. Pidgin or Finch) running?"