1use crate::{ffi, AskPasswordFlags, MountOperationResult, PasswordSave};
6use glib::{
7 object::ObjectType as _,
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GMountOperation")]
16 pub struct MountOperation(Object<ffi::GMountOperation, ffi::GMountOperationClass>);
17
18 match fn {
19 type_ => || ffi::g_mount_operation_get_type(),
20 }
21}
22
23impl MountOperation {
24 pub const NONE: Option<&'static MountOperation> = None;
25
26 #[doc(alias = "g_mount_operation_new")]
27 pub fn new() -> MountOperation {
28 unsafe { from_glib_full(ffi::g_mount_operation_new()) }
29 }
30}
31
32impl Default for MountOperation {
33 fn default() -> Self {
34 Self::new()
35 }
36}
37
38pub trait MountOperationExt: IsA<MountOperation> + 'static {
39 #[doc(alias = "g_mount_operation_get_anonymous")]
40 #[doc(alias = "get_anonymous")]
41 #[doc(alias = "anonymous")]
42 fn is_anonymous(&self) -> bool {
43 unsafe {
44 from_glib(ffi::g_mount_operation_get_anonymous(
45 self.as_ref().to_glib_none().0,
46 ))
47 }
48 }
49
50 #[doc(alias = "g_mount_operation_get_choice")]
51 #[doc(alias = "get_choice")]
52 fn choice(&self) -> i32 {
53 unsafe { ffi::g_mount_operation_get_choice(self.as_ref().to_glib_none().0) }
54 }
55
56 #[doc(alias = "g_mount_operation_get_domain")]
57 #[doc(alias = "get_domain")]
58 fn domain(&self) -> Option<glib::GString> {
59 unsafe {
60 from_glib_none(ffi::g_mount_operation_get_domain(
61 self.as_ref().to_glib_none().0,
62 ))
63 }
64 }
65
66 #[cfg(feature = "v2_58")]
67 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
68 #[doc(alias = "g_mount_operation_get_is_tcrypt_hidden_volume")]
69 #[doc(alias = "get_is_tcrypt_hidden_volume")]
70 #[doc(alias = "is-tcrypt-hidden-volume")]
71 fn is_tcrypt_hidden_volume(&self) -> bool {
72 unsafe {
73 from_glib(ffi::g_mount_operation_get_is_tcrypt_hidden_volume(
74 self.as_ref().to_glib_none().0,
75 ))
76 }
77 }
78
79 #[cfg(feature = "v2_58")]
80 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
81 #[doc(alias = "g_mount_operation_get_is_tcrypt_system_volume")]
82 #[doc(alias = "get_is_tcrypt_system_volume")]
83 #[doc(alias = "is-tcrypt-system-volume")]
84 fn is_tcrypt_system_volume(&self) -> bool {
85 unsafe {
86 from_glib(ffi::g_mount_operation_get_is_tcrypt_system_volume(
87 self.as_ref().to_glib_none().0,
88 ))
89 }
90 }
91
92 #[doc(alias = "g_mount_operation_get_password")]
93 #[doc(alias = "get_password")]
94 fn password(&self) -> Option<glib::GString> {
95 unsafe {
96 from_glib_none(ffi::g_mount_operation_get_password(
97 self.as_ref().to_glib_none().0,
98 ))
99 }
100 }
101
102 #[doc(alias = "g_mount_operation_get_password_save")]
103 #[doc(alias = "get_password_save")]
104 #[doc(alias = "password-save")]
105 fn password_save(&self) -> PasswordSave {
106 unsafe {
107 from_glib(ffi::g_mount_operation_get_password_save(
108 self.as_ref().to_glib_none().0,
109 ))
110 }
111 }
112
113 #[cfg(feature = "v2_58")]
114 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
115 #[doc(alias = "g_mount_operation_get_pim")]
116 #[doc(alias = "get_pim")]
117 fn pim(&self) -> u32 {
118 unsafe { ffi::g_mount_operation_get_pim(self.as_ref().to_glib_none().0) }
119 }
120
121 #[doc(alias = "g_mount_operation_get_username")]
122 #[doc(alias = "get_username")]
123 fn username(&self) -> Option<glib::GString> {
124 unsafe {
125 from_glib_none(ffi::g_mount_operation_get_username(
126 self.as_ref().to_glib_none().0,
127 ))
128 }
129 }
130
131 #[doc(alias = "g_mount_operation_reply")]
132 fn reply(&self, result: MountOperationResult) {
133 unsafe {
134 ffi::g_mount_operation_reply(self.as_ref().to_glib_none().0, result.into_glib());
135 }
136 }
137
138 #[doc(alias = "g_mount_operation_set_anonymous")]
139 #[doc(alias = "anonymous")]
140 fn set_anonymous(&self, anonymous: bool) {
141 unsafe {
142 ffi::g_mount_operation_set_anonymous(
143 self.as_ref().to_glib_none().0,
144 anonymous.into_glib(),
145 );
146 }
147 }
148
149 #[doc(alias = "g_mount_operation_set_choice")]
150 #[doc(alias = "choice")]
151 fn set_choice(&self, choice: i32) {
152 unsafe {
153 ffi::g_mount_operation_set_choice(self.as_ref().to_glib_none().0, choice);
154 }
155 }
156
157 #[doc(alias = "g_mount_operation_set_domain")]
158 #[doc(alias = "domain")]
159 fn set_domain(&self, domain: Option<&str>) {
160 unsafe {
161 ffi::g_mount_operation_set_domain(
162 self.as_ref().to_glib_none().0,
163 domain.to_glib_none().0,
164 );
165 }
166 }
167
168 #[cfg(feature = "v2_58")]
169 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
170 #[doc(alias = "g_mount_operation_set_is_tcrypt_hidden_volume")]
171 #[doc(alias = "is-tcrypt-hidden-volume")]
172 fn set_is_tcrypt_hidden_volume(&self, hidden_volume: bool) {
173 unsafe {
174 ffi::g_mount_operation_set_is_tcrypt_hidden_volume(
175 self.as_ref().to_glib_none().0,
176 hidden_volume.into_glib(),
177 );
178 }
179 }
180
181 #[cfg(feature = "v2_58")]
182 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
183 #[doc(alias = "g_mount_operation_set_is_tcrypt_system_volume")]
184 #[doc(alias = "is-tcrypt-system-volume")]
185 fn set_is_tcrypt_system_volume(&self, system_volume: bool) {
186 unsafe {
187 ffi::g_mount_operation_set_is_tcrypt_system_volume(
188 self.as_ref().to_glib_none().0,
189 system_volume.into_glib(),
190 );
191 }
192 }
193
194 #[doc(alias = "g_mount_operation_set_password")]
195 #[doc(alias = "password")]
196 fn set_password(&self, password: Option<&str>) {
197 unsafe {
198 ffi::g_mount_operation_set_password(
199 self.as_ref().to_glib_none().0,
200 password.to_glib_none().0,
201 );
202 }
203 }
204
205 #[doc(alias = "g_mount_operation_set_password_save")]
206 #[doc(alias = "password-save")]
207 fn set_password_save(&self, save: PasswordSave) {
208 unsafe {
209 ffi::g_mount_operation_set_password_save(
210 self.as_ref().to_glib_none().0,
211 save.into_glib(),
212 );
213 }
214 }
215
216 #[cfg(feature = "v2_58")]
217 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
218 #[doc(alias = "g_mount_operation_set_pim")]
219 #[doc(alias = "pim")]
220 fn set_pim(&self, pim: u32) {
221 unsafe {
222 ffi::g_mount_operation_set_pim(self.as_ref().to_glib_none().0, pim);
223 }
224 }
225
226 #[doc(alias = "g_mount_operation_set_username")]
227 #[doc(alias = "username")]
228 fn set_username(&self, username: Option<&str>) {
229 unsafe {
230 ffi::g_mount_operation_set_username(
231 self.as_ref().to_glib_none().0,
232 username.to_glib_none().0,
233 );
234 }
235 }
236
237 #[doc(alias = "aborted")]
238 fn connect_aborted<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
239 unsafe extern "C" fn aborted_trampoline<P: IsA<MountOperation>, F: Fn(&P) + 'static>(
240 this: *mut ffi::GMountOperation,
241 f: glib::ffi::gpointer,
242 ) {
243 let f: &F = &*(f as *const F);
244 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
245 }
246 unsafe {
247 let f: Box_<F> = Box_::new(f);
248 connect_raw(
249 self.as_ptr() as *mut _,
250 c"aborted".as_ptr() as *const _,
251 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
252 aborted_trampoline::<Self, F> as *const (),
253 )),
254 Box_::into_raw(f),
255 )
256 }
257 }
258
259 #[doc(alias = "ask-password")]
260 fn connect_ask_password<F: Fn(&Self, &str, &str, &str, AskPasswordFlags) + 'static>(
261 &self,
262 f: F,
263 ) -> SignalHandlerId {
264 unsafe extern "C" fn ask_password_trampoline<
265 P: IsA<MountOperation>,
266 F: Fn(&P, &str, &str, &str, AskPasswordFlags) + 'static,
267 >(
268 this: *mut ffi::GMountOperation,
269 message: *mut std::ffi::c_char,
270 default_user: *mut std::ffi::c_char,
271 default_domain: *mut std::ffi::c_char,
272 flags: ffi::GAskPasswordFlags,
273 f: glib::ffi::gpointer,
274 ) {
275 let f: &F = &*(f as *const F);
276 f(
277 MountOperation::from_glib_borrow(this).unsafe_cast_ref(),
278 &glib::GString::from_glib_borrow(message),
279 &glib::GString::from_glib_borrow(default_user),
280 &glib::GString::from_glib_borrow(default_domain),
281 from_glib(flags),
282 )
283 }
284 unsafe {
285 let f: Box_<F> = Box_::new(f);
286 connect_raw(
287 self.as_ptr() as *mut _,
288 c"ask-password".as_ptr() as *const _,
289 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
290 ask_password_trampoline::<Self, F> as *const (),
291 )),
292 Box_::into_raw(f),
293 )
294 }
295 }
296
297 #[doc(alias = "reply")]
303 fn connect_reply<F: Fn(&Self, MountOperationResult) + 'static>(&self, f: F) -> SignalHandlerId {
304 unsafe extern "C" fn reply_trampoline<
305 P: IsA<MountOperation>,
306 F: Fn(&P, MountOperationResult) + 'static,
307 >(
308 this: *mut ffi::GMountOperation,
309 result: ffi::GMountOperationResult,
310 f: glib::ffi::gpointer,
311 ) {
312 let f: &F = &*(f as *const F);
313 f(
314 MountOperation::from_glib_borrow(this).unsafe_cast_ref(),
315 from_glib(result),
316 )
317 }
318 unsafe {
319 let f: Box_<F> = Box_::new(f);
320 connect_raw(
321 self.as_ptr() as *mut _,
322 c"reply".as_ptr() as *const _,
323 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
324 reply_trampoline::<Self, F> as *const (),
325 )),
326 Box_::into_raw(f),
327 )
328 }
329 }
330
331 #[doc(alias = "show-unmount-progress")]
338 fn connect_show_unmount_progress<F: Fn(&Self, &str, i64, i64) + 'static>(
339 &self,
340 f: F,
341 ) -> SignalHandlerId {
342 unsafe extern "C" fn show_unmount_progress_trampoline<
343 P: IsA<MountOperation>,
344 F: Fn(&P, &str, i64, i64) + 'static,
345 >(
346 this: *mut ffi::GMountOperation,
347 message: *mut std::ffi::c_char,
348 time_left: i64,
349 bytes_left: i64,
350 f: glib::ffi::gpointer,
351 ) {
352 let f: &F = &*(f as *const F);
353 f(
354 MountOperation::from_glib_borrow(this).unsafe_cast_ref(),
355 &glib::GString::from_glib_borrow(message),
356 time_left,
357 bytes_left,
358 )
359 }
360 unsafe {
361 let f: Box_<F> = Box_::new(f);
362 connect_raw(
363 self.as_ptr() as *mut _,
364 c"show-unmount-progress".as_ptr() as *const _,
365 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
366 show_unmount_progress_trampoline::<Self, F> as *const (),
367 )),
368 Box_::into_raw(f),
369 )
370 }
371 }
372
373 #[doc(alias = "anonymous")]
374 fn connect_anonymous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
375 unsafe extern "C" fn notify_anonymous_trampoline<
376 P: IsA<MountOperation>,
377 F: Fn(&P) + 'static,
378 >(
379 this: *mut ffi::GMountOperation,
380 _param_spec: glib::ffi::gpointer,
381 f: glib::ffi::gpointer,
382 ) {
383 let f: &F = &*(f as *const F);
384 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
385 }
386 unsafe {
387 let f: Box_<F> = Box_::new(f);
388 connect_raw(
389 self.as_ptr() as *mut _,
390 c"notify::anonymous".as_ptr() as *const _,
391 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
392 notify_anonymous_trampoline::<Self, F> as *const (),
393 )),
394 Box_::into_raw(f),
395 )
396 }
397 }
398
399 #[doc(alias = "choice")]
400 fn connect_choice_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
401 unsafe extern "C" fn notify_choice_trampoline<
402 P: IsA<MountOperation>,
403 F: Fn(&P) + 'static,
404 >(
405 this: *mut ffi::GMountOperation,
406 _param_spec: glib::ffi::gpointer,
407 f: glib::ffi::gpointer,
408 ) {
409 let f: &F = &*(f as *const F);
410 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
411 }
412 unsafe {
413 let f: Box_<F> = Box_::new(f);
414 connect_raw(
415 self.as_ptr() as *mut _,
416 c"notify::choice".as_ptr() as *const _,
417 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
418 notify_choice_trampoline::<Self, F> as *const (),
419 )),
420 Box_::into_raw(f),
421 )
422 }
423 }
424
425 #[doc(alias = "domain")]
426 fn connect_domain_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
427 unsafe extern "C" fn notify_domain_trampoline<
428 P: IsA<MountOperation>,
429 F: Fn(&P) + 'static,
430 >(
431 this: *mut ffi::GMountOperation,
432 _param_spec: glib::ffi::gpointer,
433 f: glib::ffi::gpointer,
434 ) {
435 let f: &F = &*(f as *const F);
436 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
437 }
438 unsafe {
439 let f: Box_<F> = Box_::new(f);
440 connect_raw(
441 self.as_ptr() as *mut _,
442 c"notify::domain".as_ptr() as *const _,
443 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
444 notify_domain_trampoline::<Self, F> as *const (),
445 )),
446 Box_::into_raw(f),
447 )
448 }
449 }
450
451 #[cfg(feature = "v2_58")]
452 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
453 #[doc(alias = "is-tcrypt-hidden-volume")]
454 fn connect_is_tcrypt_hidden_volume_notify<F: Fn(&Self) + 'static>(
455 &self,
456 f: F,
457 ) -> SignalHandlerId {
458 unsafe extern "C" fn notify_is_tcrypt_hidden_volume_trampoline<
459 P: IsA<MountOperation>,
460 F: Fn(&P) + 'static,
461 >(
462 this: *mut ffi::GMountOperation,
463 _param_spec: glib::ffi::gpointer,
464 f: glib::ffi::gpointer,
465 ) {
466 let f: &F = &*(f as *const F);
467 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
468 }
469 unsafe {
470 let f: Box_<F> = Box_::new(f);
471 connect_raw(
472 self.as_ptr() as *mut _,
473 c"notify::is-tcrypt-hidden-volume".as_ptr() as *const _,
474 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
475 notify_is_tcrypt_hidden_volume_trampoline::<Self, F> as *const (),
476 )),
477 Box_::into_raw(f),
478 )
479 }
480 }
481
482 #[cfg(feature = "v2_58")]
483 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
484 #[doc(alias = "is-tcrypt-system-volume")]
485 fn connect_is_tcrypt_system_volume_notify<F: Fn(&Self) + 'static>(
486 &self,
487 f: F,
488 ) -> SignalHandlerId {
489 unsafe extern "C" fn notify_is_tcrypt_system_volume_trampoline<
490 P: IsA<MountOperation>,
491 F: Fn(&P) + 'static,
492 >(
493 this: *mut ffi::GMountOperation,
494 _param_spec: glib::ffi::gpointer,
495 f: glib::ffi::gpointer,
496 ) {
497 let f: &F = &*(f as *const F);
498 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
499 }
500 unsafe {
501 let f: Box_<F> = Box_::new(f);
502 connect_raw(
503 self.as_ptr() as *mut _,
504 c"notify::is-tcrypt-system-volume".as_ptr() as *const _,
505 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
506 notify_is_tcrypt_system_volume_trampoline::<Self, F> as *const (),
507 )),
508 Box_::into_raw(f),
509 )
510 }
511 }
512
513 #[doc(alias = "password")]
514 fn connect_password_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
515 unsafe extern "C" fn notify_password_trampoline<
516 P: IsA<MountOperation>,
517 F: Fn(&P) + 'static,
518 >(
519 this: *mut ffi::GMountOperation,
520 _param_spec: glib::ffi::gpointer,
521 f: glib::ffi::gpointer,
522 ) {
523 let f: &F = &*(f as *const F);
524 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
525 }
526 unsafe {
527 let f: Box_<F> = Box_::new(f);
528 connect_raw(
529 self.as_ptr() as *mut _,
530 c"notify::password".as_ptr() as *const _,
531 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
532 notify_password_trampoline::<Self, F> as *const (),
533 )),
534 Box_::into_raw(f),
535 )
536 }
537 }
538
539 #[doc(alias = "password-save")]
540 fn connect_password_save_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
541 unsafe extern "C" fn notify_password_save_trampoline<
542 P: IsA<MountOperation>,
543 F: Fn(&P) + 'static,
544 >(
545 this: *mut ffi::GMountOperation,
546 _param_spec: glib::ffi::gpointer,
547 f: glib::ffi::gpointer,
548 ) {
549 let f: &F = &*(f as *const F);
550 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
551 }
552 unsafe {
553 let f: Box_<F> = Box_::new(f);
554 connect_raw(
555 self.as_ptr() as *mut _,
556 c"notify::password-save".as_ptr() as *const _,
557 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
558 notify_password_save_trampoline::<Self, F> as *const (),
559 )),
560 Box_::into_raw(f),
561 )
562 }
563 }
564
565 #[cfg(feature = "v2_58")]
566 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
567 #[doc(alias = "pim")]
568 fn connect_pim_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
569 unsafe extern "C" fn notify_pim_trampoline<P: IsA<MountOperation>, F: Fn(&P) + 'static>(
570 this: *mut ffi::GMountOperation,
571 _param_spec: glib::ffi::gpointer,
572 f: glib::ffi::gpointer,
573 ) {
574 let f: &F = &*(f as *const F);
575 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
576 }
577 unsafe {
578 let f: Box_<F> = Box_::new(f);
579 connect_raw(
580 self.as_ptr() as *mut _,
581 c"notify::pim".as_ptr() as *const _,
582 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
583 notify_pim_trampoline::<Self, F> as *const (),
584 )),
585 Box_::into_raw(f),
586 )
587 }
588 }
589
590 #[doc(alias = "username")]
591 fn connect_username_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
592 unsafe extern "C" fn notify_username_trampoline<
593 P: IsA<MountOperation>,
594 F: Fn(&P) + 'static,
595 >(
596 this: *mut ffi::GMountOperation,
597 _param_spec: glib::ffi::gpointer,
598 f: glib::ffi::gpointer,
599 ) {
600 let f: &F = &*(f as *const F);
601 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
602 }
603 unsafe {
604 let f: Box_<F> = Box_::new(f);
605 connect_raw(
606 self.as_ptr() as *mut _,
607 c"notify::username".as_ptr() as *const _,
608 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
609 notify_username_trampoline::<Self, F> as *const (),
610 )),
611 Box_::into_raw(f),
612 )
613 }
614 }
615}
616
617impl<O: IsA<MountOperation>> MountOperationExt for O {}