@@ -124,18 +124,25 @@ void event_handler(psync_eventtype_t event, psync_eventdata_t eventdata){
124
124
std::cout <<" event" << event << std::endl;
125
125
}
126
126
127
- static void lib_setup_cripto (){
128
- if (psync_crypto_issetup ())
129
- std::cout << " crypto is setup, login result=" << psync_crypto_start (clib::pclsync_lib::get_lib ().get_crypto_pass ().c_str ()) << std::endl;
130
- else {
127
+ static int lib_setup_cripto (){
128
+ int ret = 0 ;
129
+ ret = psync_crypto_issetup ();
130
+ if (ret) {
131
+ ret = psync_crypto_start (clib::pclsync_lib::get_lib ().get_crypto_pass ().c_str ());
132
+ std::cout << " crypto is setup, login result=" << ret << std::endl;
133
+ } else {
131
134
std::cout << " crypto is not setup" << std::endl;
132
- if (psync_crypto_setup (clib::pclsync_lib::get_lib ().get_crypto_pass ().c_str (), " no hint" ))
135
+ ret = psync_crypto_setup (clib::pclsync_lib::get_lib ().get_crypto_pass ().c_str (), " no hint" );
136
+ if (ret)
133
137
std::cout << " crypto setup failed" << std::endl;
134
138
else {
135
- std::cout << " crypto setup successful, start=" << psync_crypto_start (clib::pclsync_lib::get_lib ().get_crypto_pass ().c_str ()) << std::endl;
136
- std::cout << " creating folder=" << psync_crypto_mkdir (0 , " Crypto" , NULL , NULL ) << std::endl;
139
+ ret = psync_crypto_start (clib::pclsync_lib::get_lib ().get_crypto_pass ().c_str ());
140
+ std::cout << " crypto setup successful, start=" << ret << std::endl;
141
+ ret = psync_crypto_mkdir (0 , " Crypto" , NULL , NULL ) ;
142
+ std::cout << " creating folder=" << ret << std::endl;
137
143
}
138
144
}
145
+ return ret;
139
146
clib::pclsync_lib::get_lib ().crypto_on_ = true ;
140
147
}
141
148
@@ -204,7 +211,7 @@ static void status_change(pstatus_t* status) {
204
211
int clib::pclsync_lib::statrt_crypto (const char * pass, void * rep) {
205
212
std::cout << " calling startcrypto pass: " <<pass << std::endl;
206
213
get_lib ().crypto_pass_ = pass;
207
- lib_setup_cripto ();
214
+ return lib_setup_cripto ();
208
215
}
209
216
int clib::pclsync_lib::stop_crypto (const char * path, void * rep) {
210
217
psync_crypto_stop ();
@@ -227,18 +234,22 @@ int clib::pclsync_lib::init()//std::string& username, std::string& password, std
227
234
psync_set_software_string (software_string.append (client_name).c_str ());
228
235
if (setup_crypto_ && crypto_pass_.empty () )
229
236
return 3 ;
230
- was_init_ = true ;
237
+
231
238
232
239
if (psync_init ()){
233
240
std::cout <<" init failed\n " ;
234
241
return 1 ;
235
242
}
236
243
244
+ was_init_ = true ;
237
245
if (!get_mount ().empty ())
238
246
psync_set_string_setting (" fsroot" ,get_mount ().c_str ());
239
247
240
248
// _tunnel = psync_ssl_tunnel_start("127.0.0.1", 9443, "62.210.116.50", 443);
249
+
241
250
251
+ int isfsautostart = psync_get_bool_setting (" autostartfs" );
252
+
242
253
psync_start_sync (status_change, event_handler);
243
254
char * username_old = psync_get_username ();
244
255
@@ -260,6 +271,27 @@ int clib::pclsync_lib::init()//std::string& username, std::string& password, std
260
271
return 0 ;
261
272
}
262
273
274
+ int clib::pclsync_lib::login (const char * user, const char * pass, int save) {
275
+ set_username (user);
276
+ set_password (pass);
277
+ set_savepass (bool (save));
278
+ psync_set_user_pass (user,pass, save);
279
+ return 0 ;
280
+ }
281
+
282
+ int clib::pclsync_lib::logout () {
283
+ set_password (" " );
284
+ psync_logout ();
285
+ return 0 ;
286
+ }
287
+
288
+ int clib::pclsync_lib::unlink () {
289
+ set_username (" " );
290
+ set_password (" " );
291
+ psync_unlink ();
292
+ return 0 ;
293
+ }
294
+
263
295
clib::pclsync_lib::pclsync_lib () : status_(new pstatus_struct_() ), was_init_(false ), setup_crypto_(false )
264
296
{}
265
297
0 commit comments