gardesk/garfield / 6d17a19

Browse files

fix portal response to use proper string array type

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
6d17a19c6d6fc17dc84c03411f8d99a64dc0f371
Parents
587b538
Tree
ec0ddf5

2 changed files

StatusFile+-
M garfield-portal/src/file_chooser.rs 6 1
M garfield-portal/src/request.rs 8 4
garfield-portal/src/file_chooser.rsmodified
@@ -105,6 +105,9 @@ impl FileChooser {
105
         }
105
         }
106
 
106
 
107
         tracing::info!("garfield stdout closed, got {} paths", paths.len());
107
         tracing::info!("garfield stdout closed, got {} paths", paths.len());
108
+        for (i, path) in paths.iter().enumerate() {
109
+            tracing::info!("  path[{}]: {:?}", i, path);
110
+        }
108
 
111
 
109
         // Now remove from manager and check status
112
         // Now remove from manager and check status
110
         let request = self.request_manager.remove(&handle.as_ref()).await;
113
         let request = self.request_manager.remove(&handle.as_ref()).await;
@@ -123,7 +126,9 @@ impl FileChooser {
123
             (ResponseCode::Cancelled as u32, HashMap::new())
126
             (ResponseCode::Cancelled as u32, HashMap::new())
124
         } else {
127
         } else {
125
             tracing::info!("Returning {} selected paths", paths.len());
128
             tracing::info!("Returning {} selected paths", paths.len());
126
-            (ResponseCode::Success as u32, build_file_chooser_response(paths))
129
+            let response = build_file_chooser_response(paths);
130
+            tracing::info!("Response: {:?}", response);
131
+            (ResponseCode::Success as u32, response)
127
         }
132
         }
128
     }
133
     }
129
 
134
 
garfield-portal/src/request.rsmodified
@@ -104,14 +104,18 @@ pub enum ResponseCode {
104
 pub fn build_file_chooser_response(
104
 pub fn build_file_chooser_response(
105
     paths: Vec<String>,
105
     paths: Vec<String>,
106
 ) -> HashMap<String, Value<'static>> {
106
 ) -> HashMap<String, Value<'static>> {
107
+    use zbus::zvariant::Array;
108
+
107
     let mut results = HashMap::new();
109
     let mut results = HashMap::new();
108
 
110
 
109
-    // Convert paths to file:// URIs
111
+    // Convert paths to file:// URIs as a proper string array (as)
110
-    let uris: Vec<Value> = paths
112
+    let uris: Vec<String> = paths
111
         .into_iter()
113
         .into_iter()
112
-        .map(|p| Value::from(format!("file://{}", p)))
114
+        .map(|p| format!("file://{}", p))
113
         .collect();
115
         .collect();
114
 
116
 
115
-    results.insert("uris".to_string(), Value::Array(uris.into()));
117
+    // Create array with proper 's' (string) signature
118
+    let uri_array = Array::from(uris);
119
+    results.insert("uris".to_string(), Value::Array(uri_array));
116
     results
120
     results
117
 }
121
 }