Added OSYNC_TEST_EXPORT to export symbols in test mode - required for windows port
[opensync.git] / opensync / engine / opensync_status.c
blobe2ab25c5542c334debdebb5a7f10fea50b13d102
1 /*
2 * libosengine - A synchronization engine for the opensync framework
3 * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "opensync.h"
22 #include "opensync_internals.h"
24 #include "opensync-client.h"
25 #include "opensync-engine.h"
26 #include "opensync-group.h"
27 #include "opensync-format.h"
28 #include "opensync-data.h"
30 #include "opensync_engine_internals.h"
31 #include "opensync_engine_private.h" /* FIXME: Access private struct from OSyncEngine */
33 #include "opensync_mapping_engine_internals.h"
35 void osync_status_free_member_update(OSyncMemberUpdate *update)
37 osync_assert(update);
39 if (update->objtype)
40 g_free(update->objtype);
42 osync_member_unref(update->member);
44 if (update->error)
45 osync_error_unref(&update->error);
47 g_free(update);
50 void osync_status_free_engine_update(OSyncEngineUpdate *update)
52 osync_assert(update);
54 if (update->error)
55 osync_error_unref(&update->error);
57 g_free(update);
60 void osync_status_free_change_update(OSyncChangeUpdate *update)
62 osync_assert(update);
64 osync_member_unref(update->member);
66 if (update->change)
67 osync_change_unref(update->change);
69 if (update->error)
70 osync_error_unref(&update->error);
72 g_free(update);
75 void osync_status_free_mapping_update(OSyncMappingUpdate *update)
77 osync_assert(update);
79 //osync_member_unref(update->member);
81 if (update->error)
82 osync_error_unref(&update->error);
84 g_free(update);
87 void osync_status_conflict(OSyncEngine *engine, OSyncMappingEngine *mapping_engine)
89 osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, engine, mapping_engine);
91 osync_assert_msg(engine->conflict_callback, "No conflict handler registered! OpenSync frontend very likely broken!");
93 engine->conflict_callback(engine, mapping_engine, engine->conflict_userdata);
95 osync_trace(TRACE_EXIT, "%s", __func__);
98 void osync_status_update_member(OSyncEngine *engine, OSyncMember *member, OSyncMemberEvent type, const char *objtype, OSyncError *error)
100 osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %s, %p)", __func__, engine, member, type, objtype, error);
102 if (engine->mebstat_callback) {
103 OSyncMemberUpdate *update = g_malloc0(sizeof(OSyncMemberUpdate));
104 if (!update)
105 return;
107 update->type = type;
109 update->member = member;
110 osync_member_ref(member);
112 update->error = error;
113 osync_error_ref(&error);
115 update->objtype = g_strdup(objtype);
117 engine->mebstat_callback(update, engine->mebstat_userdata);
119 osync_status_free_member_update(update);
120 } else
121 osync_trace(TRACE_INTERNAL, "Status Update Ignored");
123 osync_trace(TRACE_EXIT, "%s", __func__);
126 void osync_status_update_change(OSyncEngine *engine, OSyncChange *change, OSyncMember *member, OSyncMapping *mapping, OSyncChangeEvent type, OSyncError *error)
128 osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %i, %p)", __func__, engine, change, member, mapping, type, error);
130 if (engine->changestat_callback) {
131 OSyncChangeUpdate *update = g_malloc0(sizeof(OSyncChangeUpdate));
132 if (!update)
133 return;
135 update->type = type;
137 update->change = change;
138 osync_change_ref(change);
140 update->member = member;
141 osync_member_ref(member);
143 update->error = error;
144 osync_error_ref(&error);
146 engine->changestat_callback(update, engine->changestat_userdata);
148 osync_status_free_change_update(update);
149 } else
150 osync_trace(TRACE_INTERNAL, "Status Update Ignored");
152 osync_trace(TRACE_EXIT, "%s", __func__);
155 void osync_status_update_mapping(OSyncEngine *engine, OSyncMappingEngine *mapping, OSyncMappingEvent type, OSyncError *error)
157 osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, engine, mapping, type, error);
159 if (engine->mapstat_callback) {
160 OSyncMappingUpdate *update = g_malloc0(sizeof(OSyncMappingUpdate));
161 if (!update)
162 return;
164 update->type = type;
166 update->mapping = mapping->mapping;
168 update->error = error;
169 osync_error_ref(&error);
171 engine->mapstat_callback(update, engine->mapstat_userdata);
173 osync_status_free_mapping_update(update);
174 } else
175 osync_trace(TRACE_INTERNAL, "Status Update Ignored");
177 osync_trace(TRACE_EXIT, "%s", __func__);
180 void osync_status_update_engine(OSyncEngine *engine, OSyncEngineEvent type, OSyncError *error)
182 osync_trace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, engine, type, error);
184 if (engine->engstat_callback) {
185 OSyncEngineUpdate *update = g_malloc0(sizeof(OSyncEngineUpdate));
186 if (!update)
187 return;
189 update->type = type;
191 update->error = error;
192 osync_error_ref(&error);
194 engine->engstat_callback(update, engine->engstat_userdata);
196 osync_status_free_engine_update(update);
197 } else
198 osync_trace(TRACE_INTERNAL, "Status Update Ignored");
200 osync_trace(TRACE_EXIT, "%s", __func__);