3 /// Helper program to isolate the actual syncing into its
4 /// own process. Communicates with the main barrydesktop
5 /// via wxWidgets IPC communication. This belongs in its
6 /// own process since the sync can hang, and may need to
7 /// be killed from the GUI.
11 Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/)
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 See the GNU General Public License in the COPYING file at the
23 root directory of this project for more details.
36 // command line arguments
37 string g_argv_version
, g_argv_group_name
;
38 OpenSync::Config::pst_type g_sync_types
= PST_DO_NOT_SET
;
40 class BarrySyncJail
: public OpenSync::SyncStatus
44 std::auto_ptr
<OpenSync::API
> m_engine
;
46 // communication variables
55 virtual bool OnInit();
59 // OpenSync::SyncStatus virtual overrides
61 // virtual void CheckSummary(OpenSync::SyncSummary &summary);
64 //////////////////////////////////////////////////////////////////////////////
67 BarrySyncJail::BarrySyncJail()
73 BarrySyncJail::~BarrySyncJail()
77 bool BarrySyncJail::OnInit()
79 cerr
<< "OnInit()" << endl
;
81 // load opensync engine
83 if( g_argv_version
== "0.22" )
84 m_engine
.reset( new OpenSync::OpenSync22
);
86 m_engine
.reset( new OpenSync::OpenSync40
);
89 catch( std::exception
&e
) {
90 cerr
<< e
.what() << endl
;
94 if( !m_engine
.get() ) {
95 cerr
<< "Unknown engine number: " << g_argv_version
<< endl
;
101 m_engine
->Discover(g_argv_group_name
);
102 m_engine
->Sync(g_argv_group_name
, *this, g_sync_types
);
104 catch( std::exception
&e
) {
105 cerr
<< e
.what() << endl
;
112 int BarrySyncJail::OnExit()
114 cerr
<< "OnExit()" << endl
;
120 // OpenSync::SyncStatus virtual overrides
124 void BarrySyncJail::CheckSummary(OpenSync::SyncSummary &summary)
126 cerr << "CheckSummary" << endl;
127 // FIXME: not currently supported... abort every time
128 // cerr << "FIXME: CheckSummary() not implemented, aborting" << endl;
134 int main(int argc
, char *argv
[])
136 cerr
<< "bsyncjail startup" << endl
;
139 cerr
<< "This is a helper program for barrydesktop, and\n"
140 "not intended to be called directly.\n" << endl
;
144 g_argv_version
= argv
[1];
145 g_argv_group_name
= argv
[2];
146 g_sync_types
= atoi(argv
[3]);