[evolution-data-server/intel-work-3-12] Bug 735659 - EBookSqlite: Revert ABI change introduced by commit d39cab3
- From: Mateusz Polrola <mpolrola src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/intel-work-3-12] Bug 735659 - EBookSqlite: Revert ABI change introduced by commit d39cab3
- Date: Thu, 20 Nov 2014 09:06:51 +0000 (UTC)
commit a02c510d95457ec04d82773284a2e4e6714536ec
Author: Mateusz Polrola <mateusz polrola gmail com>
Date: Wed Nov 19 14:58:24 2014 +0100
Bug 735659 - EBookSqlite: Revert ABI change introduced by commit d39cab3
Commit d39cab3 broken ABI, by adding additional parameter to
e_phone_number_get_national_number function.
This patch is implementing fix for bug 735659 without breaking ABI, by
removing leading zeros from phone numbers in EBookSqlite directly.
.../libebook-contacts/e-phone-number-private.cpp | 15 ++--------
.../libebook-contacts/e-phone-number-private.h | 3 +-
addressbook/libebook-contacts/e-phone-number.c | 6 +---
addressbook/libebook-contacts/e-phone-number.h | 3 +-
.../libedata-book/e-book-backend-sqlitedb.c | 2 +-
addressbook/libedata-book/e-book-sqlite.c | 29 +++++++++++++++----
tests/libebook-contacts/test-phone-number.c | 4 +-
7 files changed, 33 insertions(+), 29 deletions(-)
---
diff --git a/addressbook/libebook-contacts/e-phone-number-private.cpp
b/addressbook/libebook-contacts/e-phone-number-private.cpp
index a054d0e..f41e75b 100644
--- a/addressbook/libebook-contacts/e-phone-number-private.cpp
+++ b/addressbook/libebook-contacts/e-phone-number-private.cpp
@@ -29,7 +29,6 @@
/* C++ standard library */
#include <string>
-#include <sstream>
/* system headers */
#include <langinfo.h>
@@ -250,22 +249,14 @@ _e_phone_number_cxx_get_country_code (const EPhoneNumber *phone_number,
}
gchar *
-_e_phone_number_cxx_get_national_number (const EPhoneNumber *phone_number,
- gboolean with_leading_zeros)
+_e_phone_number_cxx_get_national_number (const EPhoneNumber *phone_number)
{
g_return_val_if_fail (NULL != phone_number, NULL);
std::string national_number;
- if (with_leading_zeros) {
- e_phone_number_util_get_instance ()->GetNationalSignificantNumber (
- phone_number->priv, &national_number);
- } else {
- std::ostringstream oss;
- oss << phone_number->priv.national_number();
- national_number = oss.str();
- }
-
+ e_phone_number_util_get_instance ()->GetNationalSignificantNumber (
+ phone_number->priv, &national_number);
if (!national_number.empty ())
return g_strdup (national_number.c_str ());
diff --git a/addressbook/libebook-contacts/e-phone-number-private.h
b/addressbook/libebook-contacts/e-phone-number-private.h
index 75aaa1a..ac5b701 100644
--- a/addressbook/libebook-contacts/e-phone-number-private.h
+++ b/addressbook/libebook-contacts/e-phone-number-private.h
@@ -61,8 +61,7 @@ E_PHONE_NUMBER_LOCAL gchar * _e_phone_number_cxx_to_string (const
EPhoneNumber
EPhoneNumberFormat format);
E_PHONE_NUMBER_LOCAL gint _e_phone_number_cxx_get_country_code (const EPhoneNumber
*phone_number,
EPhoneNumberCountrySource
*source);
-E_PHONE_NUMBER_LOCAL gchar * _e_phone_number_cxx_get_national_number (const EPhoneNumber
*phone_number,
- gboolean with_leading_zeros);
+E_PHONE_NUMBER_LOCAL gchar * _e_phone_number_cxx_get_national_number (const EPhoneNumber
*phone_number);
E_PHONE_NUMBER_LOCAL EPhoneNumberMatch _e_phone_number_cxx_compare (const EPhoneNumber
*first_number,
const EPhoneNumber
*second_number);
diff --git a/addressbook/libebook-contacts/e-phone-number.c b/addressbook/libebook-contacts/e-phone-number.c
index 02d5ffb..c167d86 100644
--- a/addressbook/libebook-contacts/e-phone-number.c
+++ b/addressbook/libebook-contacts/e-phone-number.c
@@ -271,13 +271,11 @@ e_phone_number_get_country_code (const EPhoneNumber *phone_number,
* Since: 3.8
**/
gchar *
-e_phone_number_get_national_number (const EPhoneNumber *phone_number,
- gboolean with_leading_zeros)
+e_phone_number_get_national_number (const EPhoneNumber *phone_number)
{
#ifdef ENABLE_PHONENUMBER
- return _e_phone_number_cxx_get_national_number (phone_number,
- with_leading_zeros);
+ return _e_phone_number_cxx_get_national_number (phone_number);
#else /* ENABLE_PHONENUMBER */
diff --git a/addressbook/libebook-contacts/e-phone-number.h b/addressbook/libebook-contacts/e-phone-number.h
index 5e8cbb8..5fef307 100644
--- a/addressbook/libebook-contacts/e-phone-number.h
+++ b/addressbook/libebook-contacts/e-phone-number.h
@@ -220,8 +220,7 @@ gchar * e_phone_number_to_string (const EPhoneNumber
*phone_number,
gint e_phone_number_get_country_code (const EPhoneNumber *phone_number,
EPhoneNumberCountrySource *source);
gchar * e_phone_number_get_national_number
- (const EPhoneNumber *phone_number,
- gboolean with_leading_zeros);
+ (const EPhoneNumber *phone_number);
EPhoneNumberMatch e_phone_number_compare (const EPhoneNumber *first_number,
const EPhoneNumber *second_number);
diff --git a/addressbook/libedata-book/e-book-backend-sqlitedb.c
b/addressbook/libedata-book/e-book-backend-sqlitedb.c
index 63bac53..7f5396c 100644
--- a/addressbook/libedata-book/e-book-backend-sqlitedb.c
+++ b/addressbook/libedata-book/e-book-backend-sqlitedb.c
@@ -2039,7 +2039,7 @@ convert_phone (const gchar *normal,
if (number) {
EPhoneNumberCountrySource source;
- national_number = e_phone_number_get_national_number (number, TRUE);
+ national_number = e_phone_number_get_national_number (number);
country_code = e_phone_number_get_country_code (number, &source);
e_phone_number_free (number);
diff --git a/addressbook/libedata-book/e-book-sqlite.c b/addressbook/libedata-book/e-book-sqlite.c
index 57dc516..89ef584 100644
--- a/addressbook/libedata-book/e-book-sqlite.c
+++ b/addressbook/libedata-book/e-book-sqlite.c
@@ -2989,7 +2989,6 @@ ebsql_new_internal (const gchar *path,
static gchar *
convert_phone (const gchar *normal,
const gchar *region_code,
- gboolean with_leading_zeros,
gint *out_country_code)
{
EPhoneNumber *number = NULL;
@@ -3006,7 +3005,7 @@ convert_phone (const gchar *normal,
if (number) {
EPhoneNumberCountrySource source;
- national_number = e_phone_number_get_national_number (number, with_leading_zeros);
+ national_number = e_phone_number_get_national_number (number);
country_code = e_phone_number_get_country_code (number, &source);
e_phone_number_free (number);
@@ -3020,6 +3019,22 @@ convert_phone (const gchar *normal,
return national_number;
}
+static gchar *
+remove_leading_zeros (gchar *number)
+{
+ gchar *trimmed = NULL;
+ gchar *tmp = number;
+
+ g_return_val_if_fail (NULL != number, NULL);
+
+ while ('0' == *tmp)
+ tmp++;
+ trimmed = g_strdup (tmp);
+ g_free (number);
+
+ return trimmed;
+}
+
typedef struct {
gint country_code;
gchar *national;
@@ -3168,7 +3183,6 @@ update_e164_attribute_params (EBookSqlite *ebsql,
number.national = convert_phone (
original_number,
ebsql->priv->region_code,
- TRUE,
&(number.country_code));
}
@@ -3348,7 +3362,8 @@ ebsql_run_multi_insert_one (EBookSqlite *ebsql,
str = convert_phone (
normal, ebsql->priv->region_code,
- FALSE, &country_code);
+ &country_code);
+ str = remove_leading_zeros (str);
/* :value_phone */
ret = sqlite3_bind_text (stmt, param_idx++, str, -1, g_free);
@@ -3659,7 +3674,8 @@ ebsql_run_insert (EBookSqlite *ebsql,
str = convert_phone (
normal, ebsql->priv->region_code,
- FALSE, &country_code);
+ &country_code);
+ str = remove_leading_zeros (str);
ret = sqlite3_bind_text (stmt, param_idx++, str, -1, g_free);
if (ret == SQLITE_OK)
@@ -4679,8 +4695,9 @@ query_preflight_check (PreflightContext *context,
/* Collect values we'll need later while generating field
* tests, no need to parse the phone number more than once
*/
- phone_test->national = e_phone_number_get_national_number (number,
FALSE);
+ phone_test->national = e_phone_number_get_national_number (number);
phone_test->country = e_phone_number_get_country_code (number,
&source);
+ phone_test->national = remove_leading_zeros (phone_test->national);
if (source == E_PHONE_NUMBER_COUNTRY_FROM_DEFAULT)
phone_test->country = 0;
diff --git a/tests/libebook-contacts/test-phone-number.c b/tests/libebook-contacts/test-phone-number.c
index e743b4e..886c9eb 100644
--- a/tests/libebook-contacts/test-phone-number.c
+++ b/tests/libebook-contacts/test-phone-number.c
@@ -195,7 +195,7 @@ test_parse_and_format (gconstpointer data)
test_data->country_code);
g_assert_cmpuint (source, ==, test_data->country_source);
- national = e_phone_number_get_national_number (parsed, TRUE);
+ national = e_phone_number_get_national_number (parsed);
g_assert_cmpstr (national, ==, test_data->national_number);
g_free (national);
@@ -267,7 +267,7 @@ test_parse_auto_region (void)
g_assert_cmpint (e_phone_number_get_country_code (parsed, &source), ==, 1);
g_assert_cmpuint (source, ==, E_PHONE_NUMBER_COUNTRY_FROM_DEFAULT);
- national = e_phone_number_get_national_number (parsed, TRUE);
+ national = e_phone_number_get_national_number (parsed);
g_assert_cmpstr (national, ==, "2125423789");
g_free (national);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]