1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
crate::ix!();

//-------------------------------------------[.cpp/bitcoin/src/node/ui_interface.h]

/**
  | Current sync state passed to tip changed
  | callbacks.
  |
  */
pub enum SynchronizationState {
    INIT_REINDEX,
    INIT_DOWNLOAD,
    POST_INIT
}

pub fn get_synchronization_state(init: bool) -> SynchronizationState {
    
    todo!();
        /*
            if (!init) return SynchronizationState::POST_INIT;
        if (::fReindex) return SynchronizationState::INIT_REINDEX;
        return SynchronizationState::INIT_DOWNLOAD;
        */
}

/**
  | Signals for UI communication.
  |
  */
#[derive(Default,Clone)]
pub struct ClientUIInterface {

}

pub mod client_ui_interface {

    use super::*;

    macro_rules! add_signals_decl_wrapper {
        ($signal_name:ident, 
         $rtype:ty, 
         $($arg:ty: $argty:ty),*) => {
            /*
            
                rtype signal_name(__VA_ARGS__);                                                        
                using signal_name##Sig = rtype(__VA_ARGS__);                                           
                boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn);
            */
        }
    }

    /**
      | Show message box.
      |
      */
    add_signals_decl_wrapper!{
        ThreadSafeMessageBox, 
        bool, 
        message: &BilingualStr, 
        caption: &String, 
        style:   u32
    }

    /**
      | If possible, ask the user a question.
      | If not, falls back to ThreadSafeMessageBox(noninteractive_message,
      | caption, style) and returns false.
      |
      */
    add_signals_decl_wrapper!{
        ThreadSafeQuestion, 
        bool, 
        message: &BilingualStr, 
        noninteractive_message: &String, 
        caption: &String, 
        style: u32
    }

    /**
      | Progress message during initialization.
      |
      */
    add_signals_decl_wrapper!{
        InitMessage, 
        c_void, 
        message: &String
    }

    /**
      | Number of network connections changed.
      |
      */
    add_signals_decl_wrapper!{
        NotifyNumConnectionsChanged, 
        c_void, 
        new_num_connections: i32
    }

    /**
      | Network activity state changed.
      |
      */
    add_signals_decl_wrapper!{
        NotifyNetworkActiveChanged, 
        c_void, 
        network_active: bool
    }

    /**
      | Status bar alerts changed.
      |
      */
    add_signals_decl_wrapper!{
        NotifyAlertChanged, 
        c_void,
    }

    /**
      | Show progress e.g. for verifychain.
      | resume_possible indicates shutting
      | down now will result in the current progress
      | action resuming upon restart.
      |
      */
    add_signals_decl_wrapper!{
        ShowProgress, 
        c_void, 
        title: &String, 
        n_progress: i32, 
        resume_possible: bool
    }

    /**
      | New block has been accepted
      |
      */
    add_signals_decl_wrapper!{
        NotifyBlockTip, 
        c_void, 
        _0: SynchronizationState, 
        _1: *const CBlockIndex
    }

    /**
      | Best header has changed
      |
      */
    add_signals_decl_wrapper!{
        NotifyHeaderTip, 
        c_void, 
        _0: SynchronizationState, 
        _1: *const CBlockIndex
    }

    /**
      | Banlist did change.
      |
      */
    add_signals_decl_wrapper!{
        BannedListChanged, 
        c_void, 
        _0: c_void
    }
}


impl ClientUIInterface {

    pub fn thread_safe_message_box(&mut self, 
        message: &BilingualStr,
        caption: &str,
        style:   u32) -> bool {
        
        todo!();
        /*
            return g_ui_signals.ThreadSafeMessageBox(message, caption, style).value_or(false);
        */
    }
    
    pub fn thread_safe_question(&mut self, 
        message:                 &BilingualStr,
        non_interactive_message: &str,
        caption:                 &str,
        style:                   u32) -> bool {
        
        todo!();
        /*
            return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style).value_or(false);
        */
    }
    
    pub fn init_message(&mut self, message: &str)  {
        
        todo!();
        /*
            return g_ui_signals.InitMessage(message);
        */
    }
    
    pub fn notify_num_connections_changed(&mut self, new_num_connections: i32)  {
        
        todo!();
        /*
            return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections);
        */
    }
    
    pub fn notify_network_active_changed(&mut self, network_active: bool)  {
        
        todo!();
        /*
            return g_ui_signals.NotifyNetworkActiveChanged(networkActive);
        */
    }
    
    pub fn notify_alert_changed(&mut self)  {
        
        todo!();
        /*
            return g_ui_signals.NotifyAlertChanged();
        */
    }
    
    pub fn show_progress(&mut self, 
        title:           &str,
        n_progress:      i32,
        resume_possible: bool)  {
        
        todo!();
        /*
            return g_ui_signals.ShowProgress(title, nProgress, resume_possible);
        */
    }
    
    pub fn notify_block_tip(&mut self, 
        s: SynchronizationState,
        i: *const BlockIndex)  {
        
        todo!();
        /*
            return g_ui_signals.NotifyBlockTip(s, i);
        */
    }
    
    pub fn notify_header_tip(&mut self, 
        s: SynchronizationState,
        i: *const BlockIndex)  {
        
        todo!();
        /*
            return g_ui_signals.NotifyHeaderTip(s, i);
        */
    }
    
    pub fn banned_list_changed(&mut self)  {
        
        todo!();
        /*
            return g_ui_signals.BannedListChanged();
        */
    }
}