summaryrefslogtreecommitdiffstats
path: root/debian/opensync/opensync-0.22/osengine/osengine_status.c
blob: bb9ee2bd640df154b732d69e1afe9ebc4abdc896 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * libosengine - A synchronization engine for the opensync framework
 * Copyright (C) 2004-2005  Armin Bauer <armin.bauer@opensync.org>
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 * 
 */
 
#include "engine.h"
#include "engine_internals.h"

void osync_status_conflict(OSyncEngine *engine, OSyncMapping *mapping)
{
	osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, engine, mapping);
	if (engine->conflict_callback)
		engine->conflict_callback(engine, mapping, engine->conflict_userdata);
	else
		osync_trace(TRACE_INTERNAL, "Conflict Ignored");
		
	osync_trace(TRACE_EXIT, "%s", __func__);
}

void osync_status_update_member(OSyncEngine *engine, OSyncClient *client, memberupdatetype type, OSyncError **error)
{
	osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, engine, client, type, error);
	if (engine->mebstat_callback) {
		OSyncMemberUpdate update;
		memset(&update, 0, sizeof(OSyncMemberUpdate));
		update.type = type;
		update.member = client->member;
		if (error)
			update.error = *error;
		else
			update.error = NULL;
		engine->mebstat_callback(&update, engine->mebstat_userdata);
	} else
		osync_trace(TRACE_INTERNAL, "Status Update Ignored");
		
	osync_trace(TRACE_EXIT, "%s", __func__);
}

void osync_status_update_change(OSyncEngine *engine, OSyncChange *change, changeupdatetype type, OSyncError **error)
{
	osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, engine, change, type, error);
	if (engine->changestat_callback) {
		OSyncChangeUpdate update;
		update.type = type;
		update.member_id = osync_member_get_id(osync_change_get_member(change));
		update.change = change;
		update.mapping_id = osync_change_get_mappingid(change);
		if (error)
			update.error = *error;
		else
			update.error = NULL;
		engine->changestat_callback(engine, &update, engine->changestat_userdata);
	} else
		osync_trace(TRACE_INTERNAL, "Status Update Ignored");
		
	osync_trace(TRACE_EXIT, "%s", __func__);
}

void osync_status_update_mapping(OSyncEngine *engine, OSyncMapping *mapping, mappingupdatetype type, OSyncError **error)
{
	osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, engine, mapping, type, error);
	if (engine->mapstat_callback) {
		OSyncMappingUpdate update;
		update.type = type;
		update.mapping = mapping;
		if (mapping->master)
			update.winner = osync_member_get_id(mapping->master->client->member);
		if (error)
			update.error = *error;
		else
			update.error = NULL;
		engine->mapstat_callback(&update, engine->mapstat_userdata);
	} else
		osync_trace(TRACE_INTERNAL, "Status Update Ignored");
		
	osync_trace(TRACE_EXIT, "%s", __func__);
}

void osync_status_update_engine(OSyncEngine *engine, engineupdatetype type, OSyncError **error)
{
	osync_trace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, engine, type, error);
	if (engine->engstat_callback) {
		OSyncEngineUpdate update;
		memset(&update, 0, sizeof(OSyncEngineUpdate));
		update.type = type;
		if (error)
			update.error = *error;
		else
			update.error = NULL;
		engine->engstat_callback(engine, &update, engine->engstat_userdata);
	} else
		osync_trace(TRACE_INTERNAL, "Status Update Ignored");
		
	osync_trace(TRACE_EXIT, "%s", __func__);
}