lib: set ProbeResult's constructor to private
[barry.git] / opensync-plugin / src / environment.h
blob4f92e752bbb7cebb7271b58f207de516c14d9a44
1 //
2 // \file environment.h
3 // Container / environment class for the sync module.
4 //
6 /*
7 Copyright (C) 2006-2010, 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>
27 #include <string>
28 #include <memory>
29 #include "idmap.h"
32 struct DatabaseSyncState
34 public:
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
37 // in the cache
38 typedef std::map<uint32_t, bool> cache_type;
40 public:
41 // cache data
42 std::string m_CacheFilename;
43 cache_type m_Cache;
45 // id map data
46 std::string m_MapFilename;
47 idmap m_IdMap;
49 // device data
50 unsigned int m_dbId;
51 std::string m_dbName;
52 Barry::RecordStateTable m_Table;
54 bool m_Sync;
56 private:
57 std::string m_Desc;
59 public:
60 DatabaseSyncState(OSyncMember *pm, const char *description);
61 ~DatabaseSyncState();
63 bool LoadCache();
64 bool SaveCache();
66 bool LoadMap();
67 bool SaveMap();
69 void CleanupMap();
70 void ClearDirtyFlags();
72 std::string Map2Uid(uint32_t recordId) const;
73 unsigned long GetMappedRecordId(const std::string &uid);
77 struct BarryEnvironment
79 public:
80 OSyncMember *member;
82 // user config data
83 std::string m_ConfigData;
84 uint32_t m_pin;
85 bool m_DebugMode;
86 std::string m_password;
88 // device communication
89 Barry::IConverter m_IConverter;
90 std::auto_ptr<Barry::ProbeResult> m_ProbeResult;
91 Barry::Controller *m_pCon;
92 Barry::Mode::Desktop *m_pDesktop;
94 // sync data
95 DatabaseSyncState m_CalendarSync, m_ContactsSync;
97 protected:
98 void DoConnect();
100 public:
101 BarryEnvironment(OSyncMember *pm);
102 ~BarryEnvironment();
104 void Connect(const Barry::ProbeResult &result);
105 void Reconnect();
106 void Disconnect();
108 DatabaseSyncState* GetSyncObject(OSyncChange *change);
110 void ParseConfig(const char *data, int size);
111 void BuildConfig();
113 void ClearDirtyFlags(Barry::RecordStateTable &table, const std::string &dbname);
114 void ClearCalendarDirtyFlags();
115 void ClearContactsDirtyFlags();
118 #endif