Commit 37b8f101 authored by Og B. Maciel's avatar Og B. Maciel

Dbus work done by Luiz Armesto.

svn path=/trunk/; revision=644
parent b904f620
2008-09-24 Og Maciel <ogmaciel@gnome.org>
* src/daemon/alarm.py, dbus_manager.py: Added new method call to dbus.
* src/lib/actions.py, dbus_actions.py: Fixed new methods to be dbus aware.
2008-09-23 Og Maciel <ogmaciel@gnome.org>
* src/gui/widgets/calendarwidget.py: New calendaring widget for the main dialog.
......
......@@ -35,7 +35,6 @@ class Alarm(object):
def start(self):
start_delay = self.gconf_client.get_int(GCONF_PATH + 'delay') * 60000
print start_delay
if self.gconf_client.get_bool(GCONF_ALARM_PATH + 'show_startup_notification'):
timeout_add(start_delay, self.show_pay_notification)
timeout_add(start_delay + 12000, self.verify_due)
......
......@@ -5,7 +5,7 @@ __all__ = ['Server', 'get_interface', 'verify_service']
import dbus
import dbus.service
from lib import common
from lib import common, scheduler
from lib.utils import force_string
from lib.utils import get_dbus_interface as get_interface
from lib.utils import verify_dbus_service as verify_service
......@@ -55,26 +55,39 @@ class Server(dbus.service.Object):
self.parent.client_pid = pid
return self.parent.client_pid
@dbus.service.method(common.DBUS_INTERFACE, in_signature='iii', out_signature='a(sis)')
def get_monthly_totals(self, status, month, year):
# Return a list of categories and totals for the given month
ret = []
records = self.actions.get_monthly_totals(status, month, year)
for record in records:
ret.append(record)
return ret
@dbus.service.method(common.DBUS_INTERFACE, in_signature='iii', out_signature='aa{ss}')
def get_monthly_bills(self, status, month, year):
ret = []
records = self.actions.get_monthly_bills(status, month, year)
for record in records:
ret.append(force_string(record))
return ret
@dbus.service.method(common.DBUS_INTERFACE, in_signature='a{ss}', out_signature='aa{ss}')
def get_bills(self, kwargs):
""" Returns one or more records that meet the criteria passed """
print kwargs
ret = []
records = self.actions.get_bills(kwargs)
for record in records:
ret.append(force_string(record))
print ret
return ret
@dbus.service.method(common.DBUS_INTERFACE, in_signature='s', out_signature='aa{ss}')
def get_bills_(self, kwargs):
""" Returns one or more records that meet the criteria passed """
#print kwargs
ret = []
records = self.actions.get_bills(kwargs)
for record in records:
ret.append(force_string(record))
print ret
return ret
@dbus.service.method(common.DBUS_INTERFACE, in_signature='a{ss}', out_signature='a{ss}')
......@@ -104,23 +117,19 @@ class Server(dbus.service.Object):
@dbus.service.method(common.DBUS_INTERFACE, in_signature='a{ss}', out_signature='aa{ss}')
def get_categories(self, kwargs):
""" Returns one or more records that meet the criteria passed """
print kwargs
ret = []
records = self.actions.get_categories(kwargs)
for record in records:
ret.append(force_string(record))
print ret
return ret
@dbus.service.method(common.DBUS_INTERFACE, in_signature='s', out_signature='aa{ss}')
def get_categories_(self, kwargs):
""" Returns one or more records that meet the criteria passed """
#print kwargs
ret = []
records = self.actions.get_categories(kwargs)
for record in records:
ret.append(force_string(record))
print ret
return ret
@dbus.service.method(common.DBUS_INTERFACE, in_signature='a{ss}', out_signature='a{ss}')
......
......@@ -94,9 +94,9 @@ class Actions(object):
self.edit_bill(bill)
return self.dal.delete(CategoriesTable, key)
"""
if not '--standalone' in sys.argv \
and not sys.argv[0].endswith('billreminderd') \
and verify_dbus_service(common.DBUS_INTERFACE):
from lib.dbus_actions import Actions
"""
......@@ -33,6 +33,9 @@ class Actions(object):
return False
def _correct_type(self, record):
if not isinstance(record, dict):
return record
if 'Id' in record.keys():
record['Id'] = int(record['Id'])
if 'dueDate' in record.keys():
......@@ -43,44 +46,36 @@ class Actions(object):
record['paid'] = int(record['paid'])
if 'alarm' in record.keys():
record['alarm'] = int(record['alarm'])
if 'caId' in record.keys():
record['caId'] = int(record['caId'])
if 'catId' in record.keys():
record['catId'] = int(record['catId'])
return record
def get_monthly_totals(self, status, month, year):
# Return a list of categories and totals for the given month
# Delimeters for our search
firstOfMonth = scheduler.first_of_month(month, year)
lastOfMonth = scheduler.last_of_month(month, year)
# Determine status criteria
status = status < 2 and ' = %s' % status or ' in (0,1)'
#try:
ret = []
records = self.dbus_interface.get_monthly_totals(status, month, year)
for record in records:
record = self._correct_type(record)
ret.append(record)
return ret
#except dbus.DBusException:
# if self.__init__():
# return self.get_monthly_totals(status, month, year)
stmt = 'select categoryName, sum(amountDue) as amount, color' \
' from br_billstable, br_categoriestable where' \
' paid %s' \
' and dueDate >= ? and dueDate <= ?' \
' and br_categoriestable.Id = br_billstable.catId' \
' GROUP BY catId, color' \
' ORDER BY dueDate ASC' % status
params = [firstOfMonth, lastOfMonth]
records = self.executeSql(stmt, params)
return records
def get_monthly_bills(self, status, month, year):
# Delimeters for our search
firstOfMonth = scheduler.first_of_month(month, year)
lastOfMonth = scheduler.last_of_month(month, year)
# Determine status criteria
status = status < 2 and ' = %s' % status or ' in (0,1)'
records = self.get_bills('paid %s' \
' and dueDate >= %s and dueDate <= %s' \
' ORDER BY dueDate DESC' % (status, firstOfMonth, lastOfMonth))
return records
try:
ret = []
records = self.dbus_interface.get_monthly_bills(status, month, year)
for record in records:
record = self._correct_type(record)
ret.append(record)
return ret
except dbus.DBusException:
if self.__init__():
return self.get_monthly_bills(status, month, year)
def get_bills(self, kwargs):
""" Returns one or more records that meet the criteria passed """
try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment