2 /// \file SyncStatusDlg.h
3 /// The dialog used during a sync, to display status messages
4 /// and error messages, and handle sync conflicts via callback.
8 Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
23 #ifndef __BARRYDESKTOP_SYNCSTATUSDLG_H__
24 #define __BARRYDESKTOP_SYNCSTATUSDLG_H__
29 #include "deviceset.h"
30 #include "exechelper.h"
33 #include "ConflictDlg.h"
37 class StatusConnection
: public wxConnection
, public OptOut::Element
43 StatusConnection(SyncStatusDlg
&dlg
, wxTextCtrl
&window
);
45 bool OnPoke(const wxString
&topic
, const wxString
&item
,
46 wxChar
*data
, int size
, wxIPCFormat format
);
48 // wxWidgets bug override - stop the 'delete this' behaviour,
49 // since sometimes events seem to come through after
50 // the delete... not sure why, and hard to debug.
51 // This is with wxWidgets 2.8.7.
53 // With this override, the container in SyncStatusDlg
54 // will handle all the deleting.
55 virtual bool OnDisconnect() { return true; }
58 class ConflictConnection
: public wxConnection
, public OptOut::Element
63 // conflict state machine
65 int m_current_sequenceID
;
67 int m_expected_total_changes
;
68 std::string m_supported_commands
;
69 std::vector
<OpenSync::SyncChange
> m_changes
;
72 ConflictDlg::AlwaysMemoryBlock m_always
;
75 ConflictConnection(SyncStatusDlg
&dlg
);
77 bool OnPoke(const wxString
&topic
, const wxString
&item
,
78 wxChar
*data
, int size
, wxIPCFormat format
);
79 wxChar
* OnRequest(const wxString
&topic
, const wxString
&item
,
80 int *size
, wxIPCFormat format
);
82 // wxWidgets bug override - stop the 'delete this' behaviour,
83 // since sometimes events seem to come through after
84 // the delete... not sure why, and hard to debug.
85 // This is with wxWidgets 2.8.7.
87 // With this override, the container in SyncStatusDlg
88 // will handle all the deleting.
89 virtual bool OnDisconnect() { return true; }
97 DECLARE_EVENT_TABLE() // sets to protected:
100 // external data sources
101 DeviceSet::subset_type m_subset
;
102 DeviceSet::subset_type::iterator m_next_device
, m_current_device
;
104 // for handling bsyncjail
105 ExecHelper m_jailexec
;
106 std::string m_device_id
;
109 // for handling run app
112 // connection holder, to make sure they get deleted if we
114 OptOut::Vector
<wxConnectionBase
> m_connections
;
120 wxStaticText
*m_short_status
;
122 wxTextCtrl
*m_status_edit
;
123 wxButton
*m_runapp_button
, *m_syncagain_button
, *m_killclose_button
;
124 wxButton
*m_details_button
;
128 void AddStatusSizer(wxSizer
*sizer
);
129 void AddButtonSizer(wxSizer
*sizer
);
131 // set buttons to "running" state
133 // set buttons to "close" state
137 void UpdateLastSyncTime();
140 SyncStatusDlg(wxWindow
*parent
, const DeviceSet::subset_type
&subset
);
145 void StartNextSync();
147 void Print(const std::string
&msg
, const wxColour
&colour
);
148 void Print(const wxString
&msg
, const wxColour
&colour
);
149 void ShortPrint(const std::string
&msg
);
150 void ShortPrint(const wxString
&msg
);
155 DeviceEntry
* GetCurrentDevice();
158 void OnSlowSync(); // called from StatusConnection
159 void OnInitDialog(wxInitDialogEvent
&event
);
160 void OnRunApp(wxCommandEvent
&event
);
161 void OnSyncAgain(wxCommandEvent
&event
);
162 void OnKillClose(wxCommandEvent
&event
);
163 void OnShowDetails(wxCommandEvent
&event
);
164 void OnExecTerminated(wxProcessEvent
&event
);
165 void OnTimer(wxTimerEvent
&event
);
167 // virtual overrides from wxServer
168 wxConnectionBase
* OnAcceptConnection(const wxString
&topic
);