3 // Container / environment class for the sync module.
7 Copyright (C) 2006-2007, 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 <opensync/plugin/opensync_plugin_info.h>
27 #include <barry/barry.h>
32 class BarryEnvironment
;
34 class DatabaseSyncState
37 BarryEnvironment
*m_pEnv
;
40 // cache is a map of record ID to bool... the bool doesn't mean
41 // anything... the mere existence of the ID means it belongs
43 typedef std::map
<uint32_t, bool> cache_type
;
47 std::string m_CacheFilename
;
51 std::string m_MapFilename
;
55 Barry::RecordStateTable m_Table
;
59 // external OpenSync data
60 OSyncObjFormat
*m_pObjFormat
;
61 OSyncObjTypeSink
*m_pSink
;
68 DatabaseSyncState(BarryEnvironment
*pEnv
, OSyncPluginInfo
*pi
,
69 const char *DBName
, const char *description
);
79 void ClearDirtyFlags();
81 unsigned long GetMappedRecordId(const std::string
&uid
);
83 const std::string
& GetDesc() const { return m_Desc
; }
84 const char* GetDBName() const { return m_DBName
; }
88 class BarryEnvironment
92 std::string m_ConfigData
;
95 // device communication
96 Barry::ProbeResult m_ProbeResult
;
97 Barry::Controller
*m_pCon
;
100 DatabaseSyncState m_CalendarSync
, m_ContactsSync
;
103 BarryEnvironment(OSyncPluginInfo
*pi
);
107 bool IsConnected() { return m_pCon
; }
111 void OpenDesktop(Barry::ProbeResult
&result
);
114 DatabaseSyncState
* GetSyncObject(OSyncChange
*change
);
116 void ParseConfig(const char *data
);
119 void ClearDirtyFlags(Barry::RecordStateTable
&table
, const std::string
&dbname
);
120 void ClearCalendarDirtyFlags();
121 void ClearContactsDirtyFlags();