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-2013, 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.
37 // command line arguments
38 string g_argv_version
, g_argv_group_name
;
39 OpenSync::Config::pst_type g_sync_types
= PST_DO_NOT_SET
;
41 class BarrySyncJail
: public OpenSync::SyncStatus
45 std::auto_ptr
<OpenSync::API
> m_engine
;
47 // communication variables
56 virtual bool OnInit();
60 // OpenSync::SyncStatus virtual overrides
62 // virtual void CheckSummary(OpenSync::SyncSummary &summary);
65 //////////////////////////////////////////////////////////////////////////////
68 BarrySyncJail::BarrySyncJail()
74 BarrySyncJail::~BarrySyncJail()
78 bool BarrySyncJail::OnInit()
80 cerr
<< "OnInit()" << endl
;
82 // load opensync engine
84 if( g_argv_version
== "0.22" )
85 m_engine
.reset( new OpenSync::OpenSync22
);
87 m_engine
.reset( new OpenSync::OpenSync40
);
90 catch( std::exception
&e
) {
91 cerr
<< e
.what() << endl
;
95 if( !m_engine
.get() ) {
96 cerr
<< "Unknown engine number: " << g_argv_version
<< endl
;
102 m_engine
->Discover(g_argv_group_name
);
103 m_engine
->Sync(g_argv_group_name
, *this, g_sync_types
);
105 catch( std::exception
&e
) {
106 cerr
<< e
.what() << endl
;
113 int BarrySyncJail::OnExit()
115 cerr
<< "OnExit()" << endl
;
121 // OpenSync::SyncStatus virtual overrides
125 void BarrySyncJail::CheckSummary(OpenSync::SyncSummary &summary)
127 cerr << "CheckSummary" << endl;
128 // FIXME: not currently supported... abort every time
129 // cerr << "FIXME: CheckSummary() not implemented, aborting" << endl;
135 int main(int argc
, char *argv
[])
137 cerr
<< "bsyncjail startup" << endl
;
140 cerr
<< _C("This is a helper program for barrydesktop, and\n"
141 "is not intended to be called directly.\n") << endl
;
145 g_argv_version
= argv
[1];
146 g_argv_group_name
= argv
[2];
147 g_sync_types
= atoi(argv
[3]);