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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/*
This file is part of libqopensync.
Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <opensync/file.h>
#include <opensync/opensync.h>
#include "syncchange.h"
using namespace QSync;
SyncChange::SyncChange()
{
}
SyncChange::SyncChange( OSyncChange *change )
{
mSyncChange = change;
}
SyncChange::~SyncChange()
{
}
bool SyncChange::isValid() const
{
return ( mSyncChange != 0 );
}
void SyncChange::setUid( const TQString &uid )
{
osync_change_set_uid( mSyncChange, uid.utf8() );
}
TQString SyncChange::uid() const
{
return TQString::fromUtf8( osync_change_get_uid( mSyncChange ) );
}
void SyncChange::setHash( const TQString &hash )
{
osync_change_set_hash( mSyncChange, hash.utf8() );
}
TQString SyncChange::hash() const
{
return TQString::fromUtf8( osync_change_get_hash( mSyncChange ) );
}
void SyncChange::setData( const TQString &data )
{
osync_change_set_data( mSyncChange, const_cast<char*>( data.utf8().data() ), data.utf8().size(), true );
}
TQString SyncChange::data() const
{
int size = osync_change_get_datasize( mSyncChange );
TQString content;
if ( objectFormatName() == "file" ) {
fileFormat *format = (fileFormat*)osync_change_get_data( mSyncChange );
if ( format )
content = TQString::fromUtf8( format->data, format->size );
} else
content = TQString::fromUtf8( osync_change_get_data( mSyncChange ), size );
return content;
}
bool SyncChange::hasData() const
{
return osync_change_has_data( mSyncChange );
}
TQString SyncChange::objectFormatName() const
{
OSyncObjFormat *format = osync_change_get_objformat( mSyncChange );
Q_ASSERT( format );
return TQString::fromUtf8( osync_objformat_get_name( format ) );
}
Member SyncChange::member() const
{
OSyncMember *omember = osync_change_get_member( mSyncChange );
Member m;
m.mMember = omember;
return m;
}
void SyncChange::setChangeType( Type changeType )
{
OSyncChangeType ochangeType;
switch ( changeType ) {
case AddedChange:
ochangeType = CHANGE_ADDED;
break;
case UnmodifiedChange:
ochangeType = CHANGE_UNMODIFIED;
break;
case DeletedChange:
ochangeType = CHANGE_DELETED;
break;
case ModifiedChange:
ochangeType = CHANGE_MODIFIED;
break;
case UnknownChange:
default:
ochangeType = CHANGE_UNKNOWN;
break;
}
osync_change_set_changetype( mSyncChange, ochangeType );
}
SyncChange::Type SyncChange::changeType() const
{
OSyncChangeType ochangeType = osync_change_get_changetype( mSyncChange );
switch ( ochangeType ) {
case CHANGE_ADDED:
return AddedChange;
break;
case CHANGE_UNMODIFIED:
return UnmodifiedChange;
break;
case CHANGE_DELETED:
return DeletedChange;
break;
case CHANGE_MODIFIED:
return ModifiedChange;
break;
case CHANGE_UNKNOWN:
default:
return UnknownChange;
break;
}
}
|