Diff
Not logged in

Differences From Artifact [bd13af036a]:

To Artifact [0869346026]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65

66
67
68
69
70
71
72
73
74
75
76
77
78

79
80
81
82
83
84
85
..
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// Copyright 2015 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By contributing code to the SAFE Network Software, or to this project generally, you agree to be
// bound by the terms of the MaidSafe Contributor Agreement, version 1.0.  This, along with the
// Licenses can be found in the root directory of this project at LICENSE, COPYING and CONTRIBUTOR.
//
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.
//
// Please review the Licences for the specific language governing permissions and limitations
// relating to use of the SAFE Network Software.
................................................................................
    let services = vec![];
    let client = app.get_client();

    let (owners, private_signing_key) = {
        let client_guard = unwrap!(client.lock());

        let mut owners = BTreeSet::new();
        owners.insert(*try!(client_guard.get_public_signing_key()));

        let private_signing_key = try!(client_guard.get_secret_signing_key()).clone();
        (owners, private_signing_key)
    };

    let dns_operation = try!(DnsOperations::new(client.clone()));

    try!(dns_operation.register_dns(long_name,
                                    &msg_public_key,
                                    &msg_secret_key,
                                    &services,
                                    owners,
                                    &private_signing_key,
                                    None));

    Ok(())
}

/// Delete DNS.
#[no_mangle]

pub unsafe extern "C" fn dns_delete_long_name(app_handle: *const App,
                                              long_name: *const u8,
                                              long_name_len: usize)
                                              -> int32_t {
    helper::catch_unwind_i32(|| {
        trace!("FFI delete DNS.");
        let long_name = ffi_try!(helper::c_utf8_to_string(long_name, long_name_len));
................................................................................

/// Get all registered long names.
#[no_mangle]
pub unsafe extern "C" fn dns_get_long_names(app_handle: *const App,
                                            list_handle: *mut *mut StringList)
                                            -> int32_t {
    helper::catch_unwind_i32(|| {
        trace!("FFI Get all dns long names.");

        let list = ffi_try!(get_long_names(&*app_handle));
        *list_handle = ffi_try!(string_list::into_ptr(list));
        0
    })
}

fn delete_long_name(app: &App, long_name: &str) -> Result<(), FfiError> {
    let client = app.get_client();
    let signing_key = try!(unwrap!(client.lock()).get_secret_signing_key()).clone();
    let dns_ops = try!(DnsOperations::new(client));
    try!(dns_ops.delete_dns(long_name, &signing_key));

    Ok(())
}

fn get_long_names(app: &App) -> Result<Vec<String>, FfiError> {
    let dns_ops = try!(DnsOperations::new(app.get_client()));
    let list = try!(dns_ops.get_all_registered_names());
    Ok(list)
}

#[cfg(test)]
mod test {
    use core::utility;
    use ffi::test_utils;







|
|







 







|

|



|
>
|
|
|
|
|
|
|






>







 







|

|
|
|
|




|
|
|





|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Copyright 2015 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By contributing code to the SAFE Network Software, or to this project generally, you agree to be
// bound by the terms of the MaidSafe Contributor Agreement.  This, along with the Licenses can be
// found in the root directory of this project at LICENSE, COPYING and CONTRIBUTOR.
//
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.
//
// Please review the Licences for the specific language governing permissions and limitations
// relating to use of the SAFE Network Software.
................................................................................
    let services = vec![];
    let client = app.get_client();

    let (owners, private_signing_key) = {
        let client_guard = unwrap!(client.lock());

        let mut owners = BTreeSet::new();
        owners.insert(*client_guard.get_public_signing_key()?);

        let private_signing_key = client_guard.get_secret_signing_key()?.clone();
        (owners, private_signing_key)
    };

    let dns_operation = DnsOperations::new(client.clone())?;
    dns_operation
        .register_dns(long_name,
                      &msg_public_key,
                      &msg_secret_key,
                      &services,
                      owners,
                      &private_signing_key,
                      None)?;

    Ok(())
}

/// Delete DNS.
#[no_mangle]
#[cfg_attr(rustfmt, rustfmt_skip)]
pub unsafe extern "C" fn dns_delete_long_name(app_handle: *const App,
                                              long_name: *const u8,
                                              long_name_len: usize)
                                              -> int32_t {
    helper::catch_unwind_i32(|| {
        trace!("FFI delete DNS.");
        let long_name = ffi_try!(helper::c_utf8_to_string(long_name, long_name_len));
................................................................................

/// Get all registered long names.
#[no_mangle]
pub unsafe extern "C" fn dns_get_long_names(app_handle: *const App,
                                            list_handle: *mut *mut StringList)
                                            -> int32_t {
    helper::catch_unwind_i32(|| {
                                 trace!("FFI Get all dns long names.");

                                 let list = ffi_try!(get_long_names(&*app_handle));
                                 *list_handle = ffi_try!(string_list::into_ptr(list));
                                 0
                             })
}

fn delete_long_name(app: &App, long_name: &str) -> Result<(), FfiError> {
    let client = app.get_client();
    let signing_key = unwrap!(client.lock()).get_secret_signing_key()?.clone();
    let dns_ops = DnsOperations::new(client)?;
    dns_ops.delete_dns(long_name, &signing_key)?;

    Ok(())
}

fn get_long_names(app: &App) -> Result<Vec<String>, FfiError> {
    let dns_ops = DnsOperations::new(app.get_client())?;
    let list = dns_ops.get_all_registered_names()?;
    Ok(list)
}

#[cfg(test)]
mod test {
    use core::utility;
    use ffi::test_utils;