3 // Container / environment class for the sync module.
7 Copyright (C) 2006-2013, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_SYNC_ENVIRONMENT_H__
23 #define __BARRY_SYNC_ENVIRONMENT_H__
25 #include <opensync/opensync.h>
26 #include <barry/barry.h>
32 struct DatabaseSyncState
35 // cache is a map of record ID to bool... the bool doesn't mean
36 // anything... the mere existence of the ID means it belongs
38 typedef std::map
<uint32_t, bool> cache_type
;
42 std::string m_CacheFilename
;
46 std::string m_MapFilename
;
52 Barry::RecordStateTable m_Table
;
60 DatabaseSyncState(OSyncMember
*pm
, const char *description
);
70 void ClearDirtyFlags();
72 std::string
Map2Uid(uint32_t recordId
) const;
73 unsigned long GetMappedRecordId(const std::string
&uid
);
77 struct BarryEnvironment
80 std::string m_password
;
86 std::string m_ConfigData
;
90 // device communication
91 std::auto_ptr
<Barry::DesktopConnector
> m_con
;
94 DatabaseSyncState m_CalendarSync
, m_ContactsSync
;
100 BarryEnvironment(OSyncMember
*pm
);
103 Barry::Mode::Desktop
* GetDesktop() { return &m_con
->GetDesktop(); }
104 void SetPassword(const std::string
&password
);
106 void Connect(const Barry::ProbeResult
&result
);
110 DatabaseSyncState
* GetSyncObject(OSyncChange
*change
);
112 void ParseConfig(const char *data
, int size
);
115 void ClearDirtyFlags(Barry::RecordStateTable
&table
, const std::string
&dbname
);
116 void ClearCalendarDirtyFlags();
117 void ClearContactsDirtyFlags();