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
;
60 OSyncObjFormat
*m_pObjFormat
;
67 DatabaseSyncState(BarryEnvironment
*pEnv
, OSyncPluginInfo
*pi
,
68 const char *DBName
, const char *description
);
78 void ClearDirtyFlags();
80 unsigned long GetMappedRecordId(const std::string
&uid
);
82 const std::string
& GetDesc() const { return m_Desc
; }
83 const char* GetDBName() const { return m_DBName
; }
87 class BarryEnvironment
91 std::string m_ConfigData
;
94 // device communication
95 Barry::ProbeResult m_ProbeResult
;
96 Barry::Controller
*m_pCon
;
99 DatabaseSyncState m_CalendarSync
, m_ContactsSync
;
102 BarryEnvironment(OSyncPluginInfo
*pi
);
106 bool IsConnected() { return m_pCon
; }
110 void OpenDesktop(Barry::ProbeResult
&result
);
113 DatabaseSyncState
* GetSyncObject(OSyncChange
*change
);
115 void ParseConfig(const char *data
);
118 void ClearDirtyFlags(Barry::RecordStateTable
&table
, const std::string
&dbname
);
119 void ClearCalendarDirtyFlags();
120 void ClearContactsDirtyFlags();