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, 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; }
99 // external data sources
100 DeviceSet::subset_type m_subset
;
101 DeviceSet::subset_type::iterator m_next_device
, m_current_device
;
103 // for handling bsyncjail
104 ExecHelper m_jailexec
;
105 std::string m_device_id
;
108 // for handling run app
111 // connection holder, to make sure they get deleted if we
113 OptOut::Vector
<wxConnectionBase
> m_connections
;
119 wxStaticText
*m_short_status
;
121 wxTextCtrl
*m_status_edit
;
122 wxButton
*m_runapp_button
, *m_syncagain_button
, *m_killclose_button
;
123 wxButton
*m_details_button
;
127 void AddStatusSizer(wxSizer
*sizer
);
128 void AddButtonSizer(wxSizer
*sizer
);
130 // set buttons to "running" state
132 // set buttons to "close" state
138 SyncStatusDlg(wxWindow
*parent
, const DeviceSet::subset_type
&subset
);
143 void StartNextSync();
145 void Print(const std::string
&msg
, const wxColour
&colour
);
146 void Print(const wxString
&msg
, const wxColour
&colour
);
147 void ShortPrint(const std::string
&msg
);
148 void ShortPrint(const wxString
&msg
);
153 DeviceEntry
* GetCurrentDevice();
156 void OnSlowSync(); // called from StatusConnection
157 void OnInitDialog(wxInitDialogEvent
&event
);
158 void OnRunApp(wxCommandEvent
&event
);
159 void OnSyncAgain(wxCommandEvent
&event
);
160 void OnKillClose(wxCommandEvent
&event
);
161 void OnShowDetails(wxCommandEvent
&event
);
162 void OnExecTerminated(wxProcessEvent
&event
);
163 void OnTimer(wxTimerEvent
&event
);
165 // virtual overrides from wxServer
166 wxConnectionBase
* OnAcceptConnection(const wxString
&topic
);