@@ -14,6 +14,15 @@ pub mod qobject {
1414 Downgrade ,
1515 }
1616
17+ #[ qenum]
18+ #[ namespace = "InstallStatus" ]
19+ enum InstallStatus {
20+ OkToInstall ,
21+ DependencyIssue ,
22+ DiskSpaceInsufficient ,
23+ Other ,
24+ }
25+
1726 impl cxx_qt:: Threading for DebInstaller { }
1827
1928 extern "RustQt" {
@@ -29,6 +38,7 @@ pub mod qobject {
2938 #[ qproperty( bool , finished) ]
3039 #[ qproperty( QString , path) ]
3140 #[ qproperty( InstallAction , action) ]
41+ #[ qproperty( InstallStatus , status) ]
3242 type DebInstaller = super :: DebInstallerRust ;
3343
3444 #[ qinvokable]
@@ -50,9 +60,12 @@ use core::pin::Pin;
5060use cxx_qt:: Threading ;
5161use cxx_qt_lib:: QString ;
5262use gettextrs:: pgettext;
53- use oma_pm:: apt:: { AptConfig , OmaApt , OmaAptArgs } ;
63+ use oma_pm:: apt:: { AptConfig , OmaApt , OmaAptArgs , OmaAptError } ;
5464
55- use crate :: { Progress , cxx_qt_bridge:: qobject:: InstallAction } ;
65+ use crate :: {
66+ Progress ,
67+ cxx_qt_bridge:: qobject:: { InstallAction , InstallStatus } ,
68+ } ;
5669
5770pub struct DebInstallerRust {
5871 pub package : QString ,
@@ -65,6 +78,7 @@ pub struct DebInstallerRust {
6578 pub progress : f32 ,
6679 pub is_installing : bool ,
6780 pub finished : bool ,
81+ pub status : InstallStatus ,
6882}
6983
7084impl Default for DebInstallerRust {
@@ -80,6 +94,7 @@ impl Default for DebInstallerRust {
8094 is_installing : false ,
8195 finished : false ,
8296 action : InstallAction :: Install ,
97+ status : InstallStatus :: OkToInstall ,
8398 }
8499 }
85100}
@@ -125,6 +140,27 @@ impl qobject::DebInstaller {
125140 } ;
126141
127142 this. as_mut ( ) . set_action ( action) ;
143+ let result = apt
144+ . install ( & [ pkg] , true )
145+ . and_then ( |_| apt. resolve ( false , false ) ) ;
146+
147+ let mut status = InstallStatus :: OkToInstall ;
148+
149+ if let Err ( e) = result {
150+ match e {
151+ OmaAptError :: DependencyIssue { .. } => {
152+ status = InstallStatus :: DependencyIssue ;
153+ }
154+ OmaAptError :: DiskSpaceInsufficient ( _, _) => {
155+ status = InstallStatus :: DiskSpaceInsufficient ;
156+ }
157+ _ => {
158+ status = InstallStatus :: Other ;
159+ }
160+ }
161+ }
162+
163+ this. as_mut ( ) . set_status ( status) ;
128164 }
129165 }
130166
0 commit comments