[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:55 UTC 2011
The following commit has been merged in the debian branch:
commit 6ca93f592cbb7b4a14bedae53977bd3b15695b19
Author: Sebastian Krzyszkowiak <seba.dos1 at gmail.com>
Date: Thu Aug 20 01:01:52 2009 +0200
opimd: use libphone-utils to normalize phone numbers, fix quering multiple values and fix entry paths
diff --git a/framework/subsystems/opimd/backend_manager.py b/framework/subsystems/opimd/backend_manager.py
index 20f3263..beb0429 100644
--- a/framework/subsystems/opimd/backend_manager.py
+++ b/framework/subsystems/opimd/backend_manager.py
@@ -107,10 +107,10 @@ class BackendManager(DBusFBObject):
logger.debug("not loading entries for backend %s, cause it was disabled in config", backend)
else:
logger.debug("loading entries for backend %s", backend)
- try:
- yield backend.load_entries()
- except:
- logger.error("Could not load entries for backend %s!", backend)
+# try:
+ yield backend.load_entries()
+# except:
+# logger.error("Could not load entries for backend %s!", backend)
init_all(backend).start()
diff --git a/framework/subsystems/opimd/helpers.py b/framework/subsystems/opimd/helpers.py
index 4cf80c3..6090196 100644
--- a/framework/subsystems/opimd/helpers.py
+++ b/framework/subsystems/opimd/helpers.py
@@ -12,7 +12,16 @@ GPLv2 or later
Helpers
"""
-from dbus import DBusException
+from dbus import DBusException, Array
+from phoneutils import normalize_number
+
+#----------------------------------------------------------------------------#
+def field_value_to_list(field_value):
+#----------------------------------------------------------------------------#
+ if isinstance(field_value, list) or isinstance(field_value, Array):
+ return field_value
+ else:
+ return [ field_value ]
#----------------------------------------------------------------------------#
def phone_number_to_tel_uri(phone_num):
@@ -33,8 +42,7 @@ def get_compare_for_tel(tel_value):
# Remove tel:
res = tel_value[4:]
- # Remove +, - and /
- res = res.translate({ord(u'-'):None, ord(u'/'):None})
+ res = normalize_number(res)
return res
diff --git a/framework/subsystems/opimd/opimd.py b/framework/subsystems/opimd/opimd.py
index 0fac96d..baad680 100644
--- a/framework/subsystems/opimd/opimd.py
+++ b/framework/subsystems/opimd/opimd.py
@@ -53,6 +53,8 @@ from backend_manager import BackendManager
from domain_manager import DomainManager
+import phoneutils
+
import logging
logger = logging.getLogger( MODULE_NAME )
@@ -83,6 +85,11 @@ def factory( prefix, subsystem ):
dbus_objects.append(backend_manager)
+ try:
+ phoneutils.init()
+ except:
+ logger.error('Failed to init libphone-utils!')
+
INIT = True
return dbus_objects
diff --git a/framework/subsystems/opimd/pimd_calls.py b/framework/subsystems/opimd/pimd_calls.py
index 8f51530..ebc28a9 100644
--- a/framework/subsystems/opimd/pimd_calls.py
+++ b/framework/subsystems/opimd/pimd_calls.py
@@ -215,7 +215,7 @@ class CallDomain(Domain, GenericDomain):
self._backends = {}
self._entries = []
self._new_missed_calls = 0
- self._dbus_path = _DIN_ENTRY
+ self._dbus_path = _DBUS_PATH_CALLS
self.query_manager = QueryManager(self._entries)
# Initialize the D-Bus-Interface
diff --git a/framework/subsystems/opimd/pimd_contacts.py b/framework/subsystems/opimd/pimd_contacts.py
index 2cc2573..2e0d37d 100644
--- a/framework/subsystems/opimd/pimd_contacts.py
+++ b/framework/subsystems/opimd/pimd_contacts.py
@@ -213,7 +213,7 @@ class ContactDomain(Domain, GenericDomain):
self._backends = {}
self._entries = []
- self._dbus_path = _DIN_ENTRY
+ self._dbus_path = _DBUS_PATH_CONTACTS
self.query_manager = QueryManager(self._entries)
# Initialize the D-Bus-Interface
diff --git a/framework/subsystems/opimd/pimd_dates.py b/framework/subsystems/opimd/pimd_dates.py
index c6847ef..1ea4c5f 100644
--- a/framework/subsystems/opimd/pimd_dates.py
+++ b/framework/subsystems/opimd/pimd_dates.py
@@ -290,7 +290,7 @@ class DateDomain(Domain, GenericDomain):
self._backends = {}
self._entries = []
- self._dbus_path = _DIN_ENTRY
+ self._dbus_path = _DBUS_PATH_DATES
self.query_manager = QueryManager(self._entries)
# Initialize the D-Bus-Interface
diff --git a/framework/subsystems/opimd/pimd_generic.py b/framework/subsystems/opimd/pimd_generic.py
index 66ce46c..d873d9e 100644
--- a/framework/subsystems/opimd/pimd_generic.py
+++ b/framework/subsystems/opimd/pimd_generic.py
@@ -151,27 +151,28 @@ class GenericEntry():
raise KeyError
for field in self._field_idx[field_name]:
if self._fields[field][3]==backend_name:
- self._fields[field][1]=entry_data[field_name]
+ for field_value in field_value_to_list(entry_data[field_name]):
+ self._fields[field][1]=field_value
else:
- self._fields.append([field_name, entry_data[field_name], '', backend_name])
- self._field_idx[field_name].append(len(self._fields)-1)
+ for field_value in field_value_to_list(entry_data[field_name]):
+ self._fields.append([field_name, field_value, '', backend_name])
+ self._field_idx[field_name].append(len(self._fields)-1)
except KeyError:
- field_value = entry_data[field_name]
+ for field_value in field_value_to_list(entry_data[field_name]):
- # We only generate compare values for specific fields
- compare_value = ""
+ # We only generate compare values for specific fields
+ compare_value = ""
- # TODO Do this in a more extensible way
- # if ("phone" in field_name) or (field_name == "Phone"): compare_value = get_compare_for_tel(field_value)
+ if str(field_value).startswith('tel:'): compare_value = get_compare_for_tel(field_value)
- our_field = [field_name, field_value, compare_value, backend_name]
+ our_field = [field_name, field_value, compare_value, backend_name]
- self._fields.append(our_field)
- field_idx = len(self._fields) - 1
+ self._fields.append(our_field)
+ field_idx = len(self._fields) - 1
- # Keep the index happy, too
- if not field_name in self._field_idx.keys(): self._field_idx[field_name] = []
- self._field_idx[field_name].append(field_idx)
+ # Keep the index happy, too
+ if not field_name in self._field_idx.keys(): self._field_idx[field_name] = []
+ self._field_idx[field_name].append(field_idx)
# for (field_idx, field) in enumerate(self._fields):
# print "%s: %s" % (field_idx, field)
@@ -217,7 +218,7 @@ class GenericEntry():
field_value = (self._fields[field_id])[1]
field_values.append(field_value)
- value = ','.join(field_values)
+# value = ','.join(field_values)
thesame = 1
prev = field_values[0]
@@ -323,6 +324,8 @@ class GenericEntry():
field_value = str(query_obj[field_name])
best_field_match = 0.0
+ if field_value.startswith('tel:'): field_value=get_compare_for_tel(field_value).replace('+','\+')
+
matcher = re.compile(field_value)
# Check if field value(s) of this entry match(es) the query field
@@ -809,4 +812,4 @@ class GenericDomain():
num_id = int(rel_path[1:])
self.update(num_id, data)
-'''
\ No newline at end of file
+'''
diff --git a/framework/subsystems/opimd/pimd_notes.py b/framework/subsystems/opimd/pimd_notes.py
index 82abbf9..7e46cff 100644
--- a/framework/subsystems/opimd/pimd_notes.py
+++ b/framework/subsystems/opimd/pimd_notes.py
@@ -213,7 +213,7 @@ class NoteDomain(Domain, GenericDomain):
self._backends = {}
self._entries = []
- self._dbus_path = _DIN_ENTRY
+ self._dbus_path = _DBUS_PATH_NOTES
self.query_manager = QueryManager(self._entries)
# Initialize the D-Bus-Interface
--
FSO frameworkd Debian packaging
More information about the pkg-fso-commits
mailing list