OpenSync  0.22
osengine_status.c
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.
14  *
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
18  *
19  */
20 
21 #include "engine.h"
22 #include "engine_internals.h"
23 
24 void osync_status_conflict(OSyncEngine *engine, OSyncMapping *mapping)
25 {
26  osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, engine, mapping);
27  if (engine->conflict_callback)
28  engine->conflict_callback(engine, mapping, engine->conflict_userdata);
29  else
30  osync_trace(TRACE_INTERNAL, "Conflict Ignored");
31 
32  osync_trace(TRACE_EXIT, "%s", __func__);
33 }
34 
35 void osync_status_update_member(OSyncEngine *engine, OSyncClient *client, memberupdatetype type, OSyncError **error)
36 {
37  osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, engine, client, type, error);
38  if (engine->mebstat_callback) {
39  OSyncMemberUpdate update;
40  memset(&update, 0, sizeof(OSyncMemberUpdate));
41  update.type = type;
42  update.member = client->member;
43  if (error)
44  update.error = *error;
45  else
46  update.error = NULL;
47  engine->mebstat_callback(&update, engine->mebstat_userdata);
48  } else
49  osync_trace(TRACE_INTERNAL, "Status Update Ignored");
50 
51  osync_trace(TRACE_EXIT, "%s", __func__);
52 }
53 
54 void osync_status_update_change(OSyncEngine *engine, OSyncChange *change, changeupdatetype type, OSyncError **error)
55 {
56  osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, engine, change, type, error);
57  if (engine->changestat_callback) {
58  OSyncChangeUpdate update;
59  update.type = type;
61  update.change = change;
62  update.mapping_id = osync_change_get_mappingid(change);
63  if (error)
64  update.error = *error;
65  else
66  update.error = NULL;
67  engine->changestat_callback(engine, &update, engine->changestat_userdata);
68  } else
69  osync_trace(TRACE_INTERNAL, "Status Update Ignored");
70 
71  osync_trace(TRACE_EXIT, "%s", __func__);
72 }
73 
74 void osync_status_update_mapping(OSyncEngine *engine, OSyncMapping *mapping, mappingupdatetype type, OSyncError **error)
75 {
76  osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, engine, mapping, type, error);
77  if (engine->mapstat_callback) {
78  OSyncMappingUpdate update;
79  update.type = type;
80  update.mapping = mapping;
81  if (mapping->master)
82  update.winner = osync_member_get_id(mapping->master->client->member);
83  if (error)
84  update.error = *error;
85  else
86  update.error = NULL;
87  engine->mapstat_callback(&update, engine->mapstat_userdata);
88  } else
89  osync_trace(TRACE_INTERNAL, "Status Update Ignored");
90 
91  osync_trace(TRACE_EXIT, "%s", __func__);
92 }
93 
94 void osync_status_update_engine(OSyncEngine *engine, engineupdatetype type, OSyncError **error)
95 {
96  osync_trace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, engine, type, error);
97  if (engine->engstat_callback) {
98  OSyncEngineUpdate update;
99  memset(&update, 0, sizeof(OSyncEngineUpdate));
100  update.type = type;
101  if (error)
102  update.error = *error;
103  else
104  update.error = NULL;
105  engine->engstat_callback(engine, &update, engine->engstat_userdata);
106  } else
107  osync_trace(TRACE_INTERNAL, "Status Update Ignored");
108 
109  osync_trace(TRACE_EXIT, "%s", __func__);
110 }