[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, debian, updated. upstream/0.9.5.5-717-g0f98819
Sebastian Krzyszkowiak
seba.dos1 at gmail.com
Sat Aug 6 08:17:37 UTC 2011
The following commit has been merged in the debian branch:
commit 6dd6a3e550c9b4281ef649194c543e2b0f961699
Author: Sebastian Krzyszkowiak <seba.dos1 at gmail.com>
Date: Sat Aug 1 16:58:59 2009 +0200
opimd: Queries: implement (Contact|Message|Call)Added signal
diff --git a/framework/subsystems/opimd/pimd_calls.py b/framework/subsystems/opimd/pimd_calls.py
index da7da21..f836f25 100644
--- a/framework/subsystems/opimd/pimd_calls.py
+++ b/framework/subsystems/opimd/pimd_calls.py
@@ -59,6 +59,13 @@ class CallQueryMatcher(object):
self.query_obj = query
+ def single_call_matches(self, call):
+ assert(self.query_obj, "Query object is empty, cannot match!")
+
+ if call:
+ return call.match_query(self.query_obj)
+ else:
+ return False
def match(self, calls):
"""Tries to match a given set of calls to the current query
@@ -73,10 +80,9 @@ class CallQueryMatcher(object):
# Match all calls
for (call_id, call) in enumerate(calls):
- if call:
- match = call.match_query(self.query_obj)
- if match > 0.0:
- matches.append((match, call_id))
+ match = self.single_call_matches(call)
+ if match:
+ matches.append((match, call_id))
result_count = len(matches)
# Sort matches by relevance and return the best hits
@@ -553,7 +559,7 @@ class SingleQueryHandler(object):
result = False
matcher = CallQueryMatcher(self.query)
- if matcher.single_call_matches():
+ if matcher.single_call_matches(self._calls[call_id]):
self.entries = matcher.match(self._calls)
# TODO Register with the new call to receive changes
@@ -622,8 +628,7 @@ class QueryManager(DBusFBObject):
if query_handler.check_new_call(call_id):
call = self._calls[call_id]
call_path = call['Path']
- # TODO Figure out how relative signals really work
- # self.callAdded(query_id, call_path)
+ self.CallAdded(call_path, rel_path='/' + str(query_id))
def check_query_id_ok( self, num_id ):
"""
@@ -632,6 +637,10 @@ class QueryManager(DBusFBObject):
if not num_id in self._queries:
raise InvalidQueryID( "Existing query IDs: %s" % self._queries.keys() )
+ @dbus_signal(_DIN_QUERY, "s", rel_path_keyword="rel_path")
+ def CallAdded(self, path, rel_path=None):
+ pass
+
@dbus_method(_DIN_QUERY, "", "i", rel_path_keyword="rel_path")
def GetResultCount(self, rel_path):
num_id = int(rel_path[1:])
@@ -801,7 +810,7 @@ class CallDomain(Domain):
result = call['Path']
# As we just added a new message, we check it against all queries to see if it matches
- #self.query_manager.check_new_call(call_id)
+ self.query_manager.check_new_call(call_id)
self.MissedCall(_DBUS_PATH_CALLS+ '/' + str(call_id))
return call_id
@@ -853,8 +862,7 @@ class CallDomain(Domain):
result = call['Path']
# As we just added a new call, we check it against all queries to see if it matches
- # XXX: I comment this out because it doesn't work : Charlie
- # self.query_manager.check_new_call(call_id)
+ self.query_manager.check_new_call(call_id)
return result
diff --git a/framework/subsystems/opimd/pimd_contacts.py b/framework/subsystems/opimd/pimd_contacts.py
index e06767e..3a19234 100644
--- a/framework/subsystems/opimd/pimd_contacts.py
+++ b/framework/subsystems/opimd/pimd_contacts.py
@@ -57,6 +57,13 @@ class ContactQueryMatcher(object):
self.query_obj = query
+ def single_contact_matches(self, contact):
+ assert(self.query_obj, "Query object is empty, cannot match!")
+
+ if contact:
+ return contact.match_query(self.query_obj)
+ else:
+ return False
def match(self, contacts):
"""Tries to match a given set of contacts to the current query
@@ -71,10 +78,9 @@ class ContactQueryMatcher(object):
# Match all contacts
for (contact_id, contact) in enumerate(contacts):
- if contact:
- match = contact.match_query(self.query_obj)
- if match > 0.0:
- matches.append((match, contact_id))
+ match = self.single_contact_matches(contact)
+ if match:
+ matches.append((match, contact_id))
result_count = len(matches)
# Sort matches by relevance and return the best hits
@@ -577,7 +583,7 @@ class SingleQueryHandler(object):
result = False
matcher = ContactQueryMatcher(self.query)
- if matcher.single_contact_matches():
+ if matcher.single_contact_matches(self._contacts[contact_id]):
self.entries = matcher.match(self._contacts)
# TODO Register with the new contact to receive changes
@@ -646,8 +652,7 @@ class QueryManager(DBusFBObject):
if query_handler.check_new_contact(contact_id):
contact = self._contacts[contact_id]
contact_path = contact['Path']
- # TODO Figure out how relative signals really work
- # self.ContactAdded(query_id, contact_path)
+ self.ContactAdded(contact_path, rel_path='/' + str(query_id))
def check_query_id_ok( self, num_id ):
"""
@@ -656,6 +661,10 @@ class QueryManager(DBusFBObject):
if not num_id in self._queries:
raise InvalidQueryID( "Existing query IDs: %s" % self._queries.keys() )
+ @dbus_signal(_DIN_QUERY, "s", rel_path_keyword="rel_path")
+ def ContactAdded(self, path, rel_path=None):
+ pass
+
@dbus_method(_DIN_QUERY, "", "i", rel_path_keyword="rel_path")
def GetResultCount(self, rel_path):
num_id = int(rel_path[1:])
@@ -831,8 +840,7 @@ class ContactDomain(Domain):
result = contact['Path']
# As we just added a new contact, we check it against all queries to see if it matches
- # XXX: I comment this out because it doesn't work : Charlie
- # self.query_manager.check_new_contact(contact_id)
+ self.query_manager.check_new_contact(contact_id)
return result
diff --git a/framework/subsystems/opimd/pimd_messages.py b/framework/subsystems/opimd/pimd_messages.py
index ed4463e..fe4aec0 100644
--- a/framework/subsystems/opimd/pimd_messages.py
+++ b/framework/subsystems/opimd/pimd_messages.py
@@ -60,8 +60,12 @@ class MessageQueryMatcher(object):
self.query_obj = query
def single_message_matches(self, message):
- #FIXME: IMPLEMENT ME!
- return False
+ assert(self.query_obj, "Query object is empty, cannot match!")
+
+ if message:
+ return message.match_query(self.query_obj)
+ else:
+ return False
def match(self, messages):
"""Tries to match a given set of messages to the current query
@@ -76,10 +80,9 @@ class MessageQueryMatcher(object):
# Match all messages
for (message_id, message) in enumerate(messages):
- if message:
- match = message.match_query(self.query_obj)
- if match > 0.0:
- matches.append((match, message_id))
+ match = self.single_message_matches(message)
+ if match:
+ matches.append((match, message_id))
result_count = len(matches)
# Sort matches by relevance and return the best hits
@@ -581,7 +584,7 @@ class SingleQueryHandler(object):
result = False
matcher = MessageQueryMatcher(self.query)
- if matcher.single_message_matches(message_id):
+ if matcher.single_message_matches(self._messages[message_id]):
self.entries = matcher.match(self._messages)
# TODO Register with the new message to receive changes
@@ -649,9 +652,8 @@ class QueryManager(DBusFBObject):
for (query_id, query_handler) in self._queries.items():
if query_handler.check_new_message(message_id):
message = self._messages[message_id]
- message_uri = message['Path']
- # TODO Figure out how relative signals really work
- # self.MessageAdded(query_id, message_uri)
+ message_path = message['Path']
+ self.MessageAdded(message_path, rel_path='/' + str(query_id))
def check_query_id_ok( self, query_id ):
"""
@@ -660,6 +662,10 @@ class QueryManager(DBusFBObject):
if not query_id in self._queries:
raise InvalidQueryID( "Existing query IDs: %s" % self._queries.keys() )
+ @dbus_signal(_DIN_QUERY, "s", rel_path_keyword="rel_path")
+ def MessageAdded(self, path, rel_path=None):
+ pass
+
@dbus_method(_DIN_QUERY, "", "i", rel_path_keyword="rel_path")
def GetResultCount(self, rel_path):
num_id = int(rel_path[1:])
@@ -939,7 +945,7 @@ class MessageDomain(Domain):
result = message['Path']
# As we just added a new message, we check it against all queries to see if it matches
- #self.query_manager.check_new_message(message_id)
+ self.query_manager.check_new_message(message_id)
self.IncomingMessage(_DBUS_PATH_MESSAGES+ '/' + str(message_id))
return message_id
--
FSO frameworkd Debian packaging
More information about the pkg-fso-commits
mailing list