aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/conduits
diff options
context:
space:
mode:
authorJeff Cai <jeff.cai@sun.com>2009-11-30 18:04:18 +0800
committerJeff Cai <jeff.cai@sun.com>2009-11-30 18:11:36 +0800
commit9cd8dede8bd6eac41f7486d95336909051d9b4c2 (patch)
treed5973656d5a1c94fb3ad012f772cc2317e1ea8b2 /calendar/conduits
parente3561c50baeaf9d7f24892c3e72cd46eab91d111 (diff)
downloadgsoc2013-evolution-9cd8dede8bd6eac41f7486d95336909051d9b4c2.tar
gsoc2013-evolution-9cd8dede8bd6eac41f7486d95336909051d9b4c2.tar.gz
gsoc2013-evolution-9cd8dede8bd6eac41f7486d95336909051d9b4c2.tar.bz2
gsoc2013-evolution-9cd8dede8bd6eac41f7486d95336909051d9b4c2.tar.lz
gsoc2013-evolution-9cd8dede8bd6eac41f7486d95336909051d9b4c2.tar.xz
gsoc2013-evolution-9cd8dede8bd6eac41f7486d95336909051d9b4c2.tar.zst
gsoc2013-evolution-9cd8dede8bd6eac41f7486d95336909051d9b4c2.zip
Fixed bug 364618, solve the chinese character issue.
Diffstat (limited to 'calendar/conduits')
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c30
-rw-r--r--calendar/conduits/common/libecalendar-common-conduit.c8
-rw-r--r--calendar/conduits/common/libecalendar-common-conduit.h4
-rw-r--r--calendar/conduits/memo/memo-conduit.c29
-rw-r--r--calendar/conduits/todo/todo-conduit.c45
5 files changed, 75 insertions, 41 deletions
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index 677c234b6a..6aa88387b4 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -305,6 +305,8 @@ struct _ECalConduitContext {
GList *locals;
EPilotMap *map;
+
+ gchar *pilot_charset;
};
static ECalConduitContext *
@@ -947,19 +949,19 @@ local_record_from_comp (ECalLocalRecord *local, ECalComponent *comp, ECalConduit
}
/*Category support*/
- e_pilot_local_category_to_remote(&(local->local.category), comp, &(ctxt->ai.category));
+ e_pilot_local_category_to_remote(&(local->local.category), comp, &(ctxt->ai.category), ctxt->pilot_charset);
/* STOP: don't replace these with g_strdup, since free_Appointment
uses free to deallocate */
e_cal_component_get_summary (comp, &summary);
if (summary.value)
- local->appt->description = e_pilot_utf8_to_pchar (summary.value);
+ local->appt->description = e_pilot_utf8_to_pchar (summary.value, ctxt->pilot_charset);
e_cal_component_get_description_list (comp, &d_list);
if (d_list) {
description = (ECalComponentText *) d_list->data;
if (description && description->value)
- local->appt->note = e_pilot_utf8_to_pchar (description->value);
+ local->appt->note = e_pilot_utf8_to_pchar (description->value, ctxt->pilot_charset);
else
local->appt->note = NULL;
} else {
@@ -1200,7 +1202,8 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
ECalComponent *in_comp,
ECal *client,
icaltimezone *timezone,
- struct CategoryAppInfo *category)
+ struct CategoryAppInfo *category,
+ const gchar *pilot_charset)
{
ECalComponent *comp;
struct Appointment appt;
@@ -1243,12 +1246,12 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
e_cal_component_set_last_modified (comp, &now);
- summary.value = txt = e_pilot_utf8_from_pchar (appt.description);
+ summary.value = txt = e_pilot_utf8_from_pchar (appt.description, pilot_charset);
e_cal_component_set_summary (comp, &summary);
free (txt);
/*Category support*/
- e_pilot_remote_category_to_local(remote->category, comp, category);
+ e_pilot_remote_category_to_local(remote->category, comp, category, pilot_charset);
/* The iCal description field */
if (!appt.note) {
@@ -1257,7 +1260,7 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
GSList l;
ECalComponentText text;
- text.value = txt = e_pilot_utf8_from_pchar (appt.note);
+ text.value = txt = e_pilot_utf8_from_pchar (appt.note, pilot_charset);
text.altrep = NULL;
l.data = &text;
l.next = NULL;
@@ -1511,6 +1514,12 @@ pre_sync (GnomePilotConduit *conduit,
LOG (g_message ( "pre_sync: Calendar Conduit v.%s", CONDUIT_VERSION ));
ctxt->dbi = dbi;
+#ifdef PILOT_LINK_0_12
+ if(NULL == dbi->pilotInfo->pilot_charset)
+ ctxt->pilot_charset = NULL;
+ else
+ ctxt->pilot_charset = g_strdup(dbi->pilotInfo->pilot_charset);
+#endif
ctxt->client = NULL;
/* Get the timezone */
@@ -1696,6 +1705,8 @@ post_sync (GnomePilotConduit *conduit,
if (e_cal_get_changes (ctxt->client, change_id, &changed, NULL))
e_cal_free_change_list (changed);
g_free (change_id);
+ if (ctxt->pilot_charset)
+ g_free (ctxt->pilot_charset);
LOG (g_message ( "---------------------------------------------------------\n" ));
@@ -1895,7 +1906,7 @@ add_record (GnomePilotConduitSyncAbs *conduit,
LOG (g_message ( "add_record: adding %s to desktop\n", print_remote (remote) ));
- comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->client, ctxt->timezone, &(ctxt->ai.category));
+ comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->client, ctxt->timezone, &(ctxt->ai.category), ctxt->pilot_charset);
/* Give it a new UID otherwise it will be the uid of the default comp */
uid = e_cal_component_gen_uid ();
@@ -1927,7 +1938,8 @@ replace_record (GnomePilotConduitSyncAbs *conduit,
LOG (g_message ("replace_record: replace %s with %s\n",
print_local (local), print_remote (remote)));
- new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->client, ctxt->timezone, &(ctxt->ai.category));
+ new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->client, ctxt->timezone, &(ctxt->ai.category),
+ctxt->pilot_charset);
g_object_unref (local->comp);
local->comp = new_comp;
diff --git a/calendar/conduits/common/libecalendar-common-conduit.c b/calendar/conduits/common/libecalendar-common-conduit.c
index eee54e71fc..5a082461c6 100644
--- a/calendar/conduits/common/libecalendar-common-conduit.c
+++ b/calendar/conduits/common/libecalendar-common-conduit.c
@@ -126,7 +126,7 @@ e_pilot_add_category_if_possible(gchar *cat_to_add, struct CategoryAppInfo *cate
/*
*conversion from an evolution category to a palm category
*/
-void e_pilot_local_category_to_remote(gint * pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category)
+void e_pilot_local_category_to_remote(gint * pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category, const gchar *pilot_charset)
{
GSList *c_list = NULL;
gchar * category_string;
@@ -134,7 +134,7 @@ void e_pilot_local_category_to_remote(gint * pilotCategory, ECalComponent *comp,
e_cal_component_get_categories_list (comp, &c_list);
if (c_list) {
/* list != 0, so at least 1 category is assigned */
- category_string = e_pilot_utf8_to_pchar((const gchar *)c_list->data);
+ category_string = e_pilot_utf8_to_pchar((const gchar *)c_list->data, pilot_charset);
if (c_list->next != 0) {
LOG (g_message ("Note: item has more categories in evolution, first chosen"));
}
@@ -162,13 +162,13 @@ void e_pilot_local_category_to_remote(gint * pilotCategory, ECalComponent *comp,
/*
*conversion from a palm category to an evolution category
*/
-void e_pilot_remote_category_to_local(gint pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category)
+void e_pilot_remote_category_to_local(gint pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category, const gchar *pilot_charset)
{
gchar *category_string = NULL;
if (pilotCategory != 0) {
/* pda has category assigned */
- category_string = e_pilot_utf8_from_pchar(category->name[pilotCategory]);
+ category_string = e_pilot_utf8_from_pchar(category->name[pilotCategory], pilot_charset);
LOG(g_message("Category: %s\n", category_string));
diff --git a/calendar/conduits/common/libecalendar-common-conduit.h b/calendar/conduits/common/libecalendar-common-conduit.h
index 2eeb8b2723..071403ac58 100644
--- a/calendar/conduits/common/libecalendar-common-conduit.h
+++ b/calendar/conduits/common/libecalendar-common-conduit.h
@@ -25,8 +25,8 @@
#define PILOT_MAX_CATEGORIES 16
gint e_pilot_add_category_if_possible(gchar *cat_to_add, struct CategoryAppInfo *category);
-void e_pilot_local_category_to_remote(gint * pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category);
-void e_pilot_remote_category_to_local(gint pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category);
+void e_pilot_local_category_to_remote(gint * pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category, const gchar *pilot_charset);
+void e_pilot_remote_category_to_local(gint pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category, const gchar *pilot_charset);
gboolean e_pilot_setup_get_bool (const gchar *path, const gchar *key, gboolean def);
void e_pilot_setup_set_bool (const gchar *path, const gchar *key, gboolean value);
diff --git a/calendar/conduits/memo/memo-conduit.c b/calendar/conduits/memo/memo-conduit.c
index 2a1b190423..5b25ca6da9 100644
--- a/calendar/conduits/memo/memo-conduit.c
+++ b/calendar/conduits/memo/memo-conduit.c
@@ -225,6 +225,7 @@ struct _EMemoConduitContext {
GList *locals;
EPilotMap *map;
+ gchar *pilot_charset;
};
static EMemoConduitContext *
@@ -243,6 +244,7 @@ e_memo_context_new (guint32 pilot_id)
ctxt->changed = NULL;
ctxt->locals = NULL;
ctxt->map = NULL;
+ ctxt->pilot_charset = NULL;
return ctxt;
}
@@ -576,7 +578,7 @@ local_record_from_comp (EMemoLocalRecord *local, ECalComponent *comp, EMemoCondu
}
/*Category support*/
- e_pilot_local_category_to_remote(&(local->local.category), comp, &(ctxt->ai.category));
+ e_pilot_local_category_to_remote(&(local->local.category), comp, &(ctxt->ai.category), ctxt->pilot_charset);
/* STOP: don't replace these with g_strdup, since free_Memo
uses free to deallocate */
@@ -585,7 +587,7 @@ local_record_from_comp (EMemoLocalRecord *local, ECalComponent *comp, EMemoCondu
if (d_list) {
description = (ECalComponentText *) d_list->data;
if (description && description->value) {
- local->memo->text = e_pilot_utf8_to_pchar (description->value);
+ local->memo->text = e_pilot_utf8_to_pchar (description->value, ctxt->pilot_charset);
}
else{
local->memo->text = NULL;
@@ -645,7 +647,8 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
GnomePilotRecord *remote,
ECalComponent *in_comp,
icaltimezone *timezone,
- struct MemoAppInfo *ai)
+ struct MemoAppInfo *ai,
+ const gchar *pilot_charset)
{
ECalComponent *comp;
struct Memo memo;
@@ -690,7 +693,7 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
e_cal_component_set_last_modified (comp, &now);
/*Category support*/
- e_pilot_remote_category_to_local(remote->category, comp, &(ai->category));
+ e_pilot_remote_category_to_local(remote->category, comp, &(ai->category), pilot_charset);
/* The iCal description field */
if (!memo.text) {
@@ -724,10 +727,10 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
}
- sumText.value = txt3 = e_pilot_utf8_from_pchar(txt2);
+ sumText.value = txt3 = e_pilot_utf8_from_pchar(txt2, pilot_charset);
sumText.altrep = NULL;
- text.value = txt = e_pilot_utf8_from_pchar (memo.text);
+ text.value = txt = e_pilot_utf8_from_pchar (memo.text, pilot_charset);
text.altrep = NULL;
l.data = &text;
l.next = NULL;
@@ -807,6 +810,13 @@ pre_sync (GnomePilotConduit *conduit,
ctxt->dbi = dbi;
ctxt->client = NULL;
+#ifdef PILOT_LINK_0_12
+ if(NULL == dbi->pilotInfo->pilot_charset)
+ ctxt->pilot_charset = NULL;
+ else
+ ctxt->pilot_charset = g_strdup(dbi->pilotInfo->pilot_charset);
+#endif
+
if (start_calendar_server (ctxt) != 0) {
WARN(_("Could not start evolution-data-server"));
gnome_pilot_conduit_error (conduit, _("Could not start evolution-data-server"));
@@ -973,7 +983,8 @@ post_sync (GnomePilotConduit *conduit,
if (e_cal_get_changes (ctxt->client, change_id, &changed, NULL))
e_cal_free_change_list (changed);
g_free (change_id);
-
+ if (ctxt->pilot_charset)
+ g_free (ctxt->pilot_charset);
LOG (g_message ( "---------------------------------------------------------\n" ));
return 0;
@@ -1174,7 +1185,7 @@ add_record (GnomePilotConduitSyncAbs *conduit,
LOG (g_message ( "add_record: adding %s to desktop\n", print_remote (remote) ));
- comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->timezone, &(ctxt->ai));
+ comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->timezone, &(ctxt->ai), ctxt->pilot_charset);
/* Give it a new UID otherwise it will be the uid of the default comp */
uid = e_cal_component_gen_uid ();
@@ -1204,7 +1215,7 @@ replace_record (GnomePilotConduitSyncAbs *conduit,
LOG (g_message ("replace_record: replace %s with %s\n",
print_local (local), print_remote (remote)));
- new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->timezone, &(ctxt->ai));
+ new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->timezone, &(ctxt->ai), ctxt->pilot_charset);
g_object_unref (local->comp);
local->comp = new_comp;
diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c
index fd1e906da7..3620582d80 100644
--- a/calendar/conduits/todo/todo-conduit.c
+++ b/calendar/conduits/todo/todo-conduit.c
@@ -286,6 +286,7 @@ struct _EToDoConduitContext {
GList *locals;
EPilotMap *map;
+ gchar *pilot_charset;
};
static EToDoConduitContext *
@@ -305,6 +306,7 @@ e_todo_context_new (guint32 pilot_id)
ctxt->changed = NULL;
ctxt->locals = NULL;
ctxt->map = NULL;
+ ctxt->pilot_charset = NULL;
return ctxt;
}
@@ -391,7 +393,7 @@ print_local (EToDoLocalRecord *local)
return buff;
}
-static gchar *print_remote (GnomePilotRecord *remote)
+static gchar *print_remote (GnomePilotRecord *remote, const gchar *pilot_charset)
{
static gchar buff[ 4096 ];
struct ToDo todo;
@@ -425,9 +427,9 @@ static gchar *print_remote (GnomePilotRecord *remote)
todo.priority,
todo.complete,
todo.description ?
- e_pilot_utf8_from_pchar(todo.description) : "",
+ e_pilot_utf8_from_pchar(todo.description, pilot_charset) : "",
todo.note ?
- e_pilot_utf8_from_pchar(todo.note) : "",
+ e_pilot_utf8_from_pchar(todo.note, pilot_charset) : "",
remote->category);
free_ToDo (&todo);
@@ -707,19 +709,19 @@ local_record_from_comp (EToDoLocalRecord *local, ECalComponent *comp, EToDoCondu
}
/*Category support*/
- e_pilot_local_category_to_remote(&(local->local.category), comp, &(ctxt->ai.category));
+ e_pilot_local_category_to_remote(&(local->local.category), comp, &(ctxt->ai.category), ctxt->pilot_charset);
/* STOP: don't replace these with g_strdup, since free_ToDo
uses free to deallocate */
e_cal_component_get_summary (comp, &summary);
if (summary.value)
- local->todo->description = e_pilot_utf8_to_pchar (summary.value);
+ local->todo->description = e_pilot_utf8_to_pchar (summary.value, ctxt->pilot_charset);
e_cal_component_get_description_list (comp, &d_list);
if (d_list) {
description = (ECalComponentText *) d_list->data;
if (description && description->value)
- local->todo->note = e_pilot_utf8_to_pchar (description->value);
+ local->todo->note = e_pilot_utf8_to_pchar (description->value, ctxt->pilot_charset);
else
local->todo->note = NULL;
} else {
@@ -814,7 +816,8 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
GnomePilotRecord *remote,
ECalComponent *in_comp,
icaltimezone *timezone,
- struct ToDoAppInfo *ai)
+ struct ToDoAppInfo *ai,
+ const gchar *pilot_charset)
{
ECalComponent *comp;
struct ToDo todo;
@@ -861,12 +864,12 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
e_cal_component_set_last_modified (comp, &now);
- summary.value = txt = e_pilot_utf8_from_pchar (todo.description);
+ summary.value = txt = e_pilot_utf8_from_pchar (todo.description, pilot_charset);
e_cal_component_set_summary (comp, &summary);
free (txt);
/*Category support*/
- e_pilot_remote_category_to_local(remote->category, comp, &(ai->category));
+ e_pilot_remote_category_to_local(remote->category, comp, &(ai->category), pilot_charset);
/* The iCal description field */
if (!todo.note) {
@@ -875,7 +878,7 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
GSList l;
ECalComponentText text;
- text.value = txt = e_pilot_utf8_from_pchar (todo.note);
+ text.value = txt = e_pilot_utf8_from_pchar (todo.note, pilot_charset);
text.altrep = NULL;
l.data = &text;
l.next = NULL;
@@ -1002,6 +1005,13 @@ pre_sync (GnomePilotConduit *conduit,
ctxt->dbi = dbi;
ctxt->client = NULL;
+#ifdef PILOT_LINK_0_12
+ if(NULL == dbi->pilotInfo->pilot_charset)
+ ctxt->pilot_charset = NULL;
+ else
+ ctxt->pilot_charset = g_strdup(dbi->pilotInfo->pilot_charset);
+#endif
+
/* Get the timezone */
ctxt->timezone = get_default_timezone ();
if (ctxt->timezone == NULL)
@@ -1162,7 +1172,8 @@ post_sync (GnomePilotConduit *conduit,
if (e_cal_get_changes (ctxt->client, change_id, &changed, NULL))
e_cal_free_change_list (changed);
g_free (change_id);
-
+ if (ctxt->pilot_charset)
+ g_free (ctxt->pilot_charset);
LOG (g_message ( "---------------------------------------------------------\n" ));
return 0;
@@ -1329,7 +1340,7 @@ compare (GnomePilotConduitSyncAbs *conduit,
gint retval = 0;
LOG (g_message ("compare: local=%s remote=%s...\n",
- print_local (local), print_remote (remote)));
+ print_local (local), print_remote (remote, ctxt->pilot_charset)));
g_return_val_if_fail (local!=NULL,-1);
g_return_val_if_fail (remote!=NULL,-1);
@@ -1359,9 +1370,9 @@ add_record (GnomePilotConduitSyncAbs *conduit,
g_return_val_if_fail (remote != NULL, -1);
- LOG (g_message ( "add_record: adding %s to desktop\n", print_remote (remote) ));
+ LOG (g_message ( "add_record: adding %s to desktop\n", print_remote (remote, ctxt->pilot_charset) ));
- comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->timezone, &(ctxt->ai));
+ comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->timezone, &(ctxt->ai), ctxt->pilot_charset);
/* Give it a new UID otherwise it will be the uid of the default comp */
uid = e_cal_component_gen_uid ();
@@ -1390,9 +1401,9 @@ replace_record (GnomePilotConduitSyncAbs *conduit,
g_return_val_if_fail (remote != NULL, -1);
LOG (g_message ("replace_record: replace %s with %s\n",
- print_local (local), print_remote (remote)));
+ print_local (local), print_remote (remote, ctxt->pilot_charset)));
- new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->timezone, &(ctxt->ai));
+ new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->timezone, &(ctxt->ai), ctxt->pilot_charset);
g_object_unref (local->comp);
local->comp = new_comp;
@@ -1452,7 +1463,7 @@ match (GnomePilotConduitSyncAbs *conduit,
const gchar *uid;
LOG (g_message ("match: looking for local copy of %s\n",
- print_remote (remote)));
+ print_remote (remote, ctxt->pilot_charset)));
g_return_val_if_fail (local != NULL, -1);
g_return_val_if_fail (remote != NULL, -1);