changed API commands which modify and list the address book per discussi... #489

Merged
Atheros1 merged 1 commits from master into master 2013-09-06 21:08:22 +02:00
Showing only changes of commit 477568f501 - Show all commits

View File

@ -195,7 +195,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
streamNumber, 'enabled': shared.config.getboolean(addressInKeysFile, 'enabled'), 'chan': chan}, indent=4, separators=(',', ': ')) streamNumber, 'enabled': shared.config.getboolean(addressInKeysFile, 'enabled'), 'chan': chan}, indent=4, separators=(',', ': '))
data += ']}' data += ']}'
return data return data
elif method == 'listAddressBook' or method == 'listAddressbook': elif method == 'listAddressBookEntries' or method == 'listAddressbook': # the listAddressbook alias should be removed eventually.
queryreturn = sqlQuery('''SELECT label, address from addressbook''') queryreturn = sqlQuery('''SELECT label, address from addressbook''')
data = '{"addresses":[' data = '{"addresses":['
for row in queryreturn: for row in queryreturn:
@ -206,7 +206,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
data += json.dumps({'label':label.encode('base64'), 'address': address}, indent=4, separators=(',', ': ')) data += json.dumps({'label':label.encode('base64'), 'address': address}, indent=4, separators=(',', ': '))
data += ']}' data += ']}'
return data return data
elif method == 'addAddressBook' or method == 'addAddressbook': elif method == 'addAddressBookEntry' or method == 'addAddressbook': # the addAddressbook alias should be deleted eventually.
if len(params) != 2: if len(params) != 2:
raise APIError(0, "I need label and address") raise APIError(0, "I need label and address")
address, label = params address, label = params
@ -222,7 +222,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
shared.UISignalQueue.put(('rerenderSentToLabels','')) shared.UISignalQueue.put(('rerenderSentToLabels',''))
shared.UISignalQueue.put(('rerenderAddressBook','')) shared.UISignalQueue.put(('rerenderAddressBook',''))
return "Added address %s to address book" % address return "Added address %s to address book" % address
elif method == 'deleteAddressBook' or method == 'deleteAddressbook': elif method == 'deleteAddressBookEntry' or method == 'deleteAddressbook': # The deleteAddressbook alias should be deleted eventually.
if len(params) != 1: if len(params) != 1:
raise APIError(0, "I need an address") raise APIError(0, "I need an address")
address, = params address, = params