Diff
Not logged in

Differences From Artifact [bd13af036a]:

To Artifact [0869346026]:


     1      1   // Copyright 2015 MaidSafe.net limited.
     2      2   //
     3      3   // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
     4      4   // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
     5      5   // licence you accepted on initial access to the Software (the "Licences").
     6      6   //
     7      7   // By contributing code to the SAFE Network Software, or to this project generally, you agree to be
     8         -// bound by the terms of the MaidSafe Contributor Agreement, version 1.0.  This, along with the
     9         -// Licenses can be found in the root directory of this project at LICENSE, COPYING and CONTRIBUTOR.
            8  +// bound by the terms of the MaidSafe Contributor Agreement.  This, along with the Licenses can be
            9  +// found in the root directory of this project at LICENSE, COPYING and CONTRIBUTOR.
    10     10   //
    11     11   // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
    12     12   // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    13     13   // KIND, either express or implied.
    14     14   //
    15     15   // Please review the Licences for the specific language governing permissions and limitations
    16     16   // relating to use of the SAFE Network Software.
................................................................................
    52     52       let services = vec![];
    53     53       let client = app.get_client();
    54     54   
    55     55       let (owners, private_signing_key) = {
    56     56           let client_guard = unwrap!(client.lock());
    57     57   
    58     58           let mut owners = BTreeSet::new();
    59         -        owners.insert(*try!(client_guard.get_public_signing_key()));
           59  +        owners.insert(*client_guard.get_public_signing_key()?);
    60     60   
    61         -        let private_signing_key = try!(client_guard.get_secret_signing_key()).clone();
           61  +        let private_signing_key = client_guard.get_secret_signing_key()?.clone();
    62     62           (owners, private_signing_key)
    63     63       };
    64     64   
    65         -    let dns_operation = try!(DnsOperations::new(client.clone()));
    66         -    try!(dns_operation.register_dns(long_name,
    67         -                                    &msg_public_key,
    68         -                                    &msg_secret_key,
    69         -                                    &services,
    70         -                                    owners,
    71         -                                    &private_signing_key,
    72         -                                    None));
           65  +    let dns_operation = DnsOperations::new(client.clone())?;
           66  +    dns_operation
           67  +        .register_dns(long_name,
           68  +                      &msg_public_key,
           69  +                      &msg_secret_key,
           70  +                      &services,
           71  +                      owners,
           72  +                      &private_signing_key,
           73  +                      None)?;
    73     74   
    74     75       Ok(())
    75     76   }
    76     77   
    77     78   /// Delete DNS.
    78     79   #[no_mangle]
           80  +#[cfg_attr(rustfmt, rustfmt_skip)]
    79     81   pub unsafe extern "C" fn dns_delete_long_name(app_handle: *const App,
    80     82                                                 long_name: *const u8,
    81     83                                                 long_name_len: usize)
    82     84                                                 -> int32_t {
    83     85       helper::catch_unwind_i32(|| {
    84     86           trace!("FFI delete DNS.");
    85     87           let long_name = ffi_try!(helper::c_utf8_to_string(long_name, long_name_len));
................................................................................
    90     92   
    91     93   /// Get all registered long names.
    92     94   #[no_mangle]
    93     95   pub unsafe extern "C" fn dns_get_long_names(app_handle: *const App,
    94     96                                               list_handle: *mut *mut StringList)
    95     97                                               -> int32_t {
    96     98       helper::catch_unwind_i32(|| {
    97         -        trace!("FFI Get all dns long names.");
           99  +                                 trace!("FFI Get all dns long names.");
    98    100   
    99         -        let list = ffi_try!(get_long_names(&*app_handle));
   100         -        *list_handle = ffi_try!(string_list::into_ptr(list));
   101         -        0
   102         -    })
          101  +                                 let list = ffi_try!(get_long_names(&*app_handle));
          102  +                                 *list_handle = ffi_try!(string_list::into_ptr(list));
          103  +                                 0
          104  +                             })
   103    105   }
   104    106   
   105    107   fn delete_long_name(app: &App, long_name: &str) -> Result<(), FfiError> {
   106    108       let client = app.get_client();
   107         -    let signing_key = try!(unwrap!(client.lock()).get_secret_signing_key()).clone();
   108         -    let dns_ops = try!(DnsOperations::new(client));
   109         -    try!(dns_ops.delete_dns(long_name, &signing_key));
          109  +    let signing_key = unwrap!(client.lock()).get_secret_signing_key()?.clone();
          110  +    let dns_ops = DnsOperations::new(client)?;
          111  +    dns_ops.delete_dns(long_name, &signing_key)?;
   110    112   
   111    113       Ok(())
   112    114   }
   113    115   
   114    116   fn get_long_names(app: &App) -> Result<Vec<String>, FfiError> {
   115         -    let dns_ops = try!(DnsOperations::new(app.get_client()));
   116         -    let list = try!(dns_ops.get_all_registered_names());
          117  +    let dns_ops = DnsOperations::new(app.get_client())?;
          118  +    let list = dns_ops.get_all_registered_names()?;
   117    119       Ok(list)
   118    120   }
   119    121   
   120    122   #[cfg(test)]
   121    123   mod test {
   122    124       use core::utility;
   123    125       use ffi::test_utils;