@@ -33,9 +33,18 @@ enum DetailedConnectivity {
33
33
#[ default]
34
34
Uninitialized ,
35
35
Connecting ,
36
+
37
+ /// Connection is just established, but there may be work to do.
38
+ Connected ,
39
+
40
+ /// There is actual work to do, e.g. there are messages in SMTP queue
41
+ /// or we detected a message that should be downloaded.
36
42
Working ,
43
+
37
44
InterruptingIdle ,
38
- Connected ,
45
+
46
+ /// Connection is established and is idle.
47
+ Idle ,
39
48
40
49
/// The folder was configured not to be watched or configured_*_folder is not set
41
50
NotConfigured ,
@@ -54,6 +63,8 @@ impl DetailedConnectivity {
54
63
// Just don't return a connectivity, probably the folder is configured not to be
55
64
// watched or there is e.g. no "Sent" folder, so we are not interested in it
56
65
DetailedConnectivity :: NotConfigured => None ,
66
+
67
+ DetailedConnectivity :: Idle => Some ( Connectivity :: Connected ) ,
57
68
}
58
69
}
59
70
@@ -65,7 +76,8 @@ impl DetailedConnectivity {
65
76
DetailedConnectivity :: Connecting => "<span class=\" yellow dot\" ></span>" . to_string ( ) ,
66
77
DetailedConnectivity :: Working
67
78
| DetailedConnectivity :: InterruptingIdle
68
- | DetailedConnectivity :: Connected => "<span class=\" green dot\" ></span>" . to_string ( ) ,
79
+ | DetailedConnectivity :: Connected
80
+ | DetailedConnectivity :: Idle => "<span class=\" green dot\" ></span>" . to_string ( ) ,
69
81
}
70
82
}
71
83
@@ -75,9 +87,9 @@ impl DetailedConnectivity {
75
87
DetailedConnectivity :: Uninitialized => "Not started" . to_string ( ) ,
76
88
DetailedConnectivity :: Connecting => stock_str:: connecting ( context) . await ,
77
89
DetailedConnectivity :: Working => stock_str:: updating ( context) . await ,
78
- DetailedConnectivity :: InterruptingIdle | DetailedConnectivity :: Connected => {
79
- stock_str :: connected ( context ) . await
80
- }
90
+ DetailedConnectivity :: InterruptingIdle
91
+ | DetailedConnectivity :: Connected
92
+ | DetailedConnectivity :: Idle => stock_str :: connected ( context ) . await ,
81
93
DetailedConnectivity :: NotConfigured => "Not configured" . to_string ( ) ,
82
94
}
83
95
}
@@ -94,9 +106,9 @@ impl DetailedConnectivity {
94
106
// We don't know any more than that the last message was sent successfully;
95
107
// since sending the last message, connectivity could have changed, which we don't notice
96
108
// until another message is sent
97
- DetailedConnectivity :: InterruptingIdle | DetailedConnectivity :: Connected => {
98
- stock_str :: last_msg_sent_successfully ( context ) . await
99
- }
109
+ DetailedConnectivity :: InterruptingIdle
110
+ | DetailedConnectivity :: Connected
111
+ | DetailedConnectivity :: Idle => stock_str :: last_msg_sent_successfully ( context ) . await ,
100
112
DetailedConnectivity :: NotConfigured => "Not configured" . to_string ( ) ,
101
113
}
102
114
}
@@ -108,8 +120,9 @@ impl DetailedConnectivity {
108
120
DetailedConnectivity :: Connecting => false ,
109
121
DetailedConnectivity :: Working => false ,
110
122
DetailedConnectivity :: InterruptingIdle => false ,
111
- DetailedConnectivity :: Connected => true ,
123
+ DetailedConnectivity :: Connected => false , // Just connected, there may still be work to do.
112
124
DetailedConnectivity :: NotConfigured => true ,
125
+ DetailedConnectivity :: Idle => true ,
113
126
}
114
127
}
115
128
}
@@ -141,6 +154,9 @@ impl ConnectivityStore {
141
154
pub ( crate ) async fn set_not_configured ( & self , context : & Context ) {
142
155
self . set ( context, DetailedConnectivity :: NotConfigured ) . await ;
143
156
}
157
+ pub ( crate ) async fn set_idle ( & self , context : & Context ) {
158
+ self . set ( context, DetailedConnectivity :: Idle ) . await ;
159
+ }
144
160
145
161
async fn get_detailed ( & self ) -> DetailedConnectivity {
146
162
self . 0 . lock ( ) . await . deref ( ) . clone ( )
@@ -164,6 +180,7 @@ pub(crate) async fn idle_interrupted(inbox: ConnectivityStore, oboxes: Vec<Conne
164
180
// return Connected until DC is completely done with fetching folders; this also
165
181
// includes scan_folders() which happens on the inbox thread.
166
182
if * connectivity_lock == DetailedConnectivity :: Connected
183
+ || * connectivity_lock == DetailedConnectivity :: Idle
167
184
|| * connectivity_lock == DetailedConnectivity :: NotConfigured
168
185
{
169
186
* connectivity_lock = DetailedConnectivity :: InterruptingIdle ;
@@ -172,7 +189,9 @@ pub(crate) async fn idle_interrupted(inbox: ConnectivityStore, oboxes: Vec<Conne
172
189
173
190
for state in oboxes {
174
191
let mut connectivity_lock = state. 0 . lock ( ) . await ;
175
- if * connectivity_lock == DetailedConnectivity :: Connected {
192
+ if * connectivity_lock == DetailedConnectivity :: Connected
193
+ || * connectivity_lock == DetailedConnectivity :: Idle
194
+ {
176
195
* connectivity_lock = DetailedConnectivity :: InterruptingIdle ;
177
196
}
178
197
}
0 commit comments