mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 01:46:34 +03:00
Remove dc_open call
A new context is now created by calling Context::new and therefore you always have a valid context. This is much more in Rust style and will allow a lot of furture simplifications on the context itself. The FFI layer has not yet been adjusted in this commit and thus will fail.
This commit is contained in:
committed by
Floris Bruynooghe
parent
e5699e8ba9
commit
afc9a31080
@@ -15,8 +15,8 @@ extern crate rusqlite;
|
||||
|
||||
use std::borrow::Cow::{self, Borrowed, Owned};
|
||||
use std::io::{self, Write};
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::ptr;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
|
||||
@@ -44,7 +44,7 @@ use self::cmdline::*;
|
||||
|
||||
// Event Handler
|
||||
|
||||
unsafe extern "C" fn receive_event(
|
||||
fn receive_event(
|
||||
_context: &Context,
|
||||
event: Event,
|
||||
data1: uintptr_t,
|
||||
@@ -387,15 +387,15 @@ impl Highlighter for DcHelper {
|
||||
impl Helper for DcHelper {}
|
||||
|
||||
fn main_0(args: Vec<String>) -> Result<(), failure::Error> {
|
||||
let mut context = dc_context_new(Some(receive_event), ptr::null_mut(), Some("CLI".into()));
|
||||
|
||||
if args.len() == 2 {
|
||||
if unsafe { !dc_open(&mut context, &args[1], None) } {
|
||||
println!("Error: Cannot open {}.", args[0],);
|
||||
}
|
||||
} else if args.len() != 1 {
|
||||
if args.len() < 2 {
|
||||
println!("Error: Bad arguments, expected [db-name].");
|
||||
return Err(format_err!("No db-name specified"));
|
||||
}
|
||||
let context = Context::new(
|
||||
Box::new(receive_event),
|
||||
"CLI".into(),
|
||||
Path::new(&args[1]).to_path_buf(),
|
||||
)?;
|
||||
|
||||
println!("Delta Chat Core is awaiting your commands.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user