annotate src/gaim-remote.py @ 12964:c0f68043854a

[gaim-migrate @ 15317] A GG status fix from Bartosz Oler. This should fix SF Bug #1410147. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Fri, 20 Jan 2006 01:55:50 +0000
parents 2e4e02b72e43
children ac5bc9a7b603
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
1 #!/usr/bin/python
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
2
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
3 import dbus
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
4 import re
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
5 import urllib
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
6 import sys
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
7
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
8 import xml.dom.minidom
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
9
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
10 xml.dom.minidom.Element.all = xml.dom.minidom.Element.getElementsByTagName
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
11
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
12 obj = dbus.SessionBus().get_object("org.gaim.GaimService", "/org/gaim/GaimObject")
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
13 gaim = dbus.Interface(obj, "org.gaim.GaimInterface")
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
14
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
15 class CheckedObject:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
16 def __init__(self, obj):
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
17 self.obj = obj
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
18
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
19 def __getattr__(self, attr):
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
20 return CheckedAttribute(self, attr)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
21
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
22 class CheckedAttribute:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
23 def __init__(self, cobj, attr):
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
24 self.cobj = cobj
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
25 self.attr = attr
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
26
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
27 def __call__(self, *args):
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
28 result = self.cobj.obj.__getattr__(self.attr)(*args)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
29 if result == 0:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
30 raise "Error: " + self.attr + " " + str(args) + " returned " + str(result)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
31 return result
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
32
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
33 cgaim = CheckedObject(gaim)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
34
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
35 urlregexp = r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?"
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
36
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
37 def extendlist(list, length, fill):
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
38 if len(list) < length:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
39 return list + [fill] * (length - len(list))
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
40 else:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
41 return list
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
42
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
43 def convert(value):
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
44 try:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
45 return int(value)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
46 except:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
47 return value
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
48
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
49 def findaccount(accountname, protocolname):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
50 try:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
51 # prefer connected accounts
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
52 account = cgaim.GaimAccountsFindConnected(accountname, protocolname)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
53 return account
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
54 except:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
55 # try to get any account and connect it
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
56 account = cgaim.GaimAccountsFindAny(accountname, protocolname)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
57 print gaim.GaimAccountGetUsername(account)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
58 gaim.GaimAccountSetStatusVargs(account, "online", 1)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
59 gaim.GaimAccountConnect(account)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
60 return account
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
61
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
62
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
63 def execute(uri):
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
64 match = re.match(urlregexp, uri)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
65 protocol = match.group(2)
12684
2e4e02b72e43 [gaim-migrate @ 15027]
Richard Laager <rlaager@wiktel.com>
parents: 11331
diff changeset
66 if protocol == "aim" or protocol == "icq":
2e4e02b72e43 [gaim-migrate @ 15027]
Richard Laager <rlaager@wiktel.com>
parents: 11331
diff changeset
67 protocol = "oscar"
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
68 if protocol is not None:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
69 protocol = "prpl-" + protocol
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
70 command = match.group(5)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
71 paramstring = match.group(7)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
72 params = {}
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
73 if paramstring is not None:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
74 for param in paramstring.split("&"):
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
75 key, value = extendlist(param.split("=",1), 2, "")
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
76 params[key] = urllib.unquote(value)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
77
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
78 accountname = params.get("account", "")
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
79
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
80 if command == "goim":
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
81 print params
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
82 account = findaccount(accountname, protocol)
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
83 conversation = cgaim.GaimConversationNew(1, account, params["screenname"])
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
84 if "message" in params:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
85 im = cgaim.GaimConversationGetImData(conversation)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
86 gaim.GaimConvImSend(im, params["message"])
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
87 return None
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
88
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
89 elif command == "gochat":
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
90 account = findaccount(accountname, protocol)
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
91 connection = cgaim.GaimAccountGetConnection(account)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
92 return gaim.ServJoinChat(connection, params)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
93
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
94 elif command == "addbuddy":
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
95 account = findaccount(accountname, protocol)
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
96 return cgaim.GaimBlistRequestAddBuddy(account, params["screenname"],
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
97 params.get("group", ""), "")
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
98
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
99 elif command == "setstatus":
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
100 if "account" in params:
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
101 accounts = [cgaim.GaimAccountsFindAny(accountname, protocol)]
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
102 else:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
103 accounts = gaim.GaimAccountsGetAllActive()
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
104
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
105 for account in accounts:
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
106 status = cgaim.GaimAccountGetStatus(account, params["status"])
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
107 for key, value in params.items():
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
108 if key not in ["status", "account"]:
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
109 gaim.GaimStatusSetAttrString(status, key, value)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
110 gaim.GaimAccountSetStatusVargs(account, params["status"], 1)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
111 return None
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
112
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
113 elif command == "getinfo":
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
114 account = findaccount(accountname, protocol)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
115 connection = cgaim.GaimAccountGetConnection(account)
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
116 return gaim.ServGetInfo(connection, params["screenname"])
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
117
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
118 elif command == "quit":
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
119 return gaim.GaimCoreQuit()
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
120
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
121 elif command == "uri":
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
122 return None
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
123
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
124 else:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
125 match = re.match(r"(\w+)\s*\(([^)]*)\)", command)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
126 if match is not None:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
127 name = match.group(1)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
128 argstr = match.group(2)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
129 if argstr == "":
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
130 args = []
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
131 else:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
132 args = argstr.split(",")
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
133 fargs = []
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
134 for arg in args:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
135 fargs.append(convert(arg.strip()))
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
136 return gaim.__getattr__(name)(*fargs)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
137 else:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
138 # introspect the object to get parameter names and types
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
139 # this is slow because the entire introspection info must be downloaded
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
140 data = dbus.Interface(obj, "org.freedesktop.DBus.Introspectable").\
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
141 Introspect()
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
142 introspect = xml.dom.minidom.parseString(data).documentElement
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
143 for method in introspect.all("method"):
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
144 if command == method.getAttribute("name"):
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
145 methodparams = []
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
146 for arg in method.all("arg"):
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
147 if arg.getAttribute("direction") == "in":
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
148 value = params[arg.getAttribute("name")]
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
149 type = arg.getAttribute("type")
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
150 if type == "s":
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
151 methodparams.append(value)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
152 elif type == "i":
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
153 methodparams.append(int(value))
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
154 else:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
155 raise "Don't know how to handle type \"%s\"" % type
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
156 return gaim.__getattr__(command)(*methodparams)
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
157 raise "Unknown command: %s" % command
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
158
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
159
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
160 if len(sys.argv) == 1:
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
161 print """This program uses DBus to communicate with gaim.
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
162
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
163 Usage:
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
164
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
165 %s "command1" "command2" ...
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
166
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
167 Each command is of one of the three types:
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
168
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
169 [protocol:]commandname?param1=value1&param2=value2&...
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
170 FunctionName?param1=value1&param2=value2&...
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
171 FunctionName(value1,value2,...)
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
172
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
173 The second and third form are provided for completeness but their use
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
174 is not recommended; use gaim-send or gaim-send-async instead. The
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
175 second form uses introspection to find out the parameter names and
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
176 their types, therefore it is rather slow.
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
177
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
178 Examples of commands:
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
179
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
180 jabber:goim?screenname=testone@localhost&message=hi
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
181 jabber:gochat?room=TestRoom&server=conference.localhost
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
182 jabber:getinfo?screenname=testone@localhost
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
183 jabber:addbuddy?screenname=my friend
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
184
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
185 setstatus?status=away&message=don't disturb
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
186 quit
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
187
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
188 GaimAccountsFindConnected?name=&protocol=prpl-jabber
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
189 GaimAccountFindConnected(,prpl-jabber)
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
190 """ % sys.argv[0]
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
191
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
192 for arg in sys.argv[1:]:
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
193 print execute(arg)
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
194
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents:
diff changeset
195