c_path stringclasses 26
values | c_func stringlengths 79 17.1k | rust_path stringlengths 34 53 | rust_func stringlengths 53 16.4k | rust_context stringlengths 0 36.3k | rust_imports stringlengths 0 2.09k | rustrepotrans_file stringlengths 56 77 |
|---|---|---|---|---|---|---|
projects/deltachat-core/c/dc_oauth2.c | char* dc_get_oauth2_addr(dc_context_t* context, const char* addr,
const char* code)
{
char* access_token = NULL;
char* addr_out = NULL;
oauth2_t* oauth2 = NULL;
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC
|| (oauth2=get_info(addr))==NULL || oauth2->get_userinfo==NULL) {... | projects/deltachat-core/rust/oauth2.rs | pub(crate) async fn get_oauth2_addr(
context: &Context,
addr: &str,
code: &str,
) -> Result<Option<String>> {
let socks5_enabled = context.get_config_bool(Config::Socks5Enabled).await?;
let oauth2 = match Oauth2::from_address(context, addr, socks5_enabled).await {
Some(o) => o,
None ... | pub async fn get_config_bool(&self, key: Config) -> Result<bool> {
Ok(self.get_config_bool_opt(key).await?.unwrap_or_default())
}
async fn get_addr(&self, context: &Context, access_token: &str) -> Option<String> {
let userinfo_url = self.get_userinfo.unwrap_or("");
let userinfo_url = replac... | use std::collections::HashMap;
use anyhow::Result;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use serde::Deserialize;
use crate::config::Config;
use crate::context::Context;
use crate::provider;
use crate::provider::Oauth2Authorizer;
use crate::socks::Socks5Config;
use crate::tools::time;
use super:... | projects__deltachat-core__rust__oauth2__.rs__function__3.txt |
projects/deltachat-core/c/dc_tools.c | int dc_get_filemeta(const void* buf_start, size_t buf_bytes, uint32_t* ret_width, uint32_t *ret_height)
{
/* Strategy:
reading GIF dimensions requires the first 10 bytes of the file
reading PNG dimensions requires the first 24 bytes of the file
reading JPEG dimensions requires scanning through jpeg chunks
In all f... | projects/deltachat-core/rust/tools.rs | pub fn get_filemeta(buf: &[u8]) -> Result<(u32, u32)> {
let image = image::io::Reader::new(Cursor::new(buf)).with_guessed_format()?;
let dimensions = image.into_dimensions()?;
Ok(dimensions)
} | use std::borrow::Cow;
use std::io::{Cursor, Write};
use std::mem;
use std::path::{Path, PathBuf};
use std::str::from_utf8;
use std::time::Duration;
use std::time::SystemTime as Time;
use std::time::SystemTime;
use anyhow::{bail, Context as _, Result};
use base64::Engine as _;
use chrono::{Local, NaiveDateTime, NaiveTim... | projects__deltachat-core__rust__tools__.rs__function__17.txt | |
projects/deltachat-core/c/dc_chatlist.c | dc_lot_t* dc_chatlist_get_summary(const dc_chatlist_t* chatlist, size_t index, dc_chat_t* chat /*may be NULL*/)
{
/* The summary is created by the chat, not by the last message.
This is because we may want to display drafts here or stuff as
"is typing".
Also, sth. as "No messages" would not work if the summary come... | projects/deltachat-core/rust/chatlist.rs | pub async fn get_summary(
&self,
context: &Context,
index: usize,
chat: Option<&Chat>,
) -> Result<Summary> {
// The summary is created by the chat, not by the last message.
// This is because we may want to display drafts here or stuff as
// "is typing".
... | pub fn get(&self, key: Param) -> Option<&str> {
self.inner.get(&key).map(|s| s.as_str())
}
pub struct Context {
pub(crate) inner: Arc<InnerContext>,
}
pub struct Chatlist {
/// Stores pairs of `chat_id, message_id`
ids: Vec<(ChatId, Option<MsgId>)>,
}
pub async fn get_summary2(
contex... | use anyhow::{ensure, Context as _, Result};
use once_cell::sync::Lazy;
use crate::chat::{update_special_chat_names, Chat, ChatId, ChatVisibility};
use crate::constants::{
Blocked, Chattype, DC_CHAT_ID_ALLDONE_HINT, DC_CHAT_ID_ARCHIVED_LINK, DC_GCL_ADD_ALLDONE_HINT,
DC_GCL_ARCHIVED_ONLY, DC_GCL_FOR_FORWARDING, D... | projects__deltachat-core__rust__chatlist__.rs__function__7.txt |
projects/deltachat-core/c/dc_configure.c | * Frees the process allocated with dc_alloc_ongoing() - independingly of dc_shall_stop_ongoing.
* If dc_alloc_ongoing() fails, this function MUST NOT be called.
*/
void dc_free_ongoing(dc_context_t* context)
{
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) {
return;
}
context->ongoing_running = 0;
c... | projects/deltachat-core/rust/context.rs | pub(crate) async fn free_ongoing(&self) {
let mut s = self.running_state.write().await;
if let RunningState::ShallStop { request } = *s {
info!(self, "Ongoing stopped in {:?}", time_elapsed(&request));
}
*s = RunningState::Stopped;
} | macro_rules! info {
($ctx:expr, $msg:expr) => {
info!($ctx, $msg,)
};
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {{
let formatted = format!($msg, $($args),*);
let full = format!("{file}:{line}: {msg}",
file = file!(),
line ... | use std::collections::{BTreeMap, HashMap};
use std::ffi::OsString;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
use anyhow::{bail, ensure, Context as _, Result};
use async_channel::{self as channel, Receiver, Sender};
us... | projects__deltachat-core__rust__context__.rs__function__38.txt |
projects/deltachat-core/c/dc_param.c | int32_t dc_param_get_int(const dc_param_t* param, int key, int32_t def)
{
if (param==NULL || key==0) {
return def;
}
char* str = dc_param_get(param, key, NULL);
if (str==NULL) {
return def;
}
int32_t ret = atol(str);
free(str);
return ret;
} | projects/deltachat-core/rust/param.rs | pub fn get_int(&self, key: Param) -> Option<i32> {
self.get(key).and_then(|s| s.parse().ok())
} | pub fn get(&self, key: Param) -> Option<&str> {
self.inner.get(&key).map(|s| s.as_str())
}
pub struct Params {
inner: BTreeMap<Param, String>,
} | use std::collections::BTreeMap;
use std::fmt;
use std::path::PathBuf;
use std::str;
use anyhow::{bail, Error, Result};
use num_traits::FromPrimitive;
use serde::{Deserialize, Serialize};
use crate::blob::BlobObject;
use crate::context::Context;
use crate::mimeparser::SystemMessage;
use std::path::Path;
use std::str::Fr... | projects__deltachat-core__rust__param__.rs__function__11.txt |
projects/deltachat-core/c/dc_chat.c | static uint32_t get_draft_msg_id(dc_context_t* context, uint32_t chat_id)
{
uint32_t draft_msg_id = 0;
sqlite3_stmt* stmt = dc_sqlite3_prepare(context->sql,
"SELECT id FROM msgs WHERE chat_id=? AND state=?;");
sqlite3_bind_int(stmt, 1, chat_id);
sqlite3_bind_int(stmt, 2, DC_STATE_OUT_DRAFT);
if (sqlite3_step(st... | projects/deltachat-core/rust/chat.rs | async fn get_draft_msg_id(self, context: &Context) -> Result<Option<MsgId>> {
let msg_id: Option<MsgId> = context
.sql
.query_get_value(
"SELECT id FROM msgs WHERE chat_id=? AND state=?;",
(self, MessageState::OutDraft),
)
.await?;
... | pub struct Context {
pub(crate) inner: Arc<InnerContext>,
}
ub struct InnerContext {
/// Blob directory path
pub(crate) blobdir: PathBuf,
pub(crate) sql: Sql,
pub(crate) smeared_timestamp: SmearedTimestamp,
/// The global "ongoing" process state.
///
/// This is a global mutex-like stat... | use std::cmp;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::time::Duration;
use anyhow::{anyhow, bail, ensure, Context as _, Result};
use deltachat_contact_tools::{strip_rtlo_characters, ContactAddress};
use deltachat_derive::{FromSql, ToSql};
us... | projects__deltachat-core__rust__chat__.rs__function__32.txt |
projects/deltachat-core/c/dc_msg.c | int dc_msg_is_info(const dc_msg_t* msg)
{
if (msg==NULL || msg->magic!=DC_MSG_MAGIC) {
return 0;
}
int cmd = dc_param_get_int(msg->param, DC_PARAM_CMD, 0);
if (msg->from_id==DC_CONTACT_ID_INFO
|| msg->to_id==DC_CONTACT_ID_INFO
|| (cmd && cmd!=DC_CMD_AUTOCRYPT_SETUP_MESSAGE)) {
return 1;
}
return 0;
} | projects/deltachat-core/rust/message.rs | pub fn is_info(&self) -> bool {
let cmd = self.param.get_cmd();
self.from_id == ContactId::INFO
|| self.to_id == ContactId::INFO
|| cmd != SystemMessage::Unknown && cmd != SystemMessage::AutocryptSetupMessage
} | pub fn get_cmd(&self) -> SystemMessage {
self.get_int(Param::Cmd)
.and_then(SystemMessage::from_i32)
.unwrap_or_default()
}
pub struct Message {
/// Message ID.
pub(crate) id: MsgId,
/// `From:` contact ID.
pub(crate) from_id: ContactId,
/// ID of the first con... | use std::collections::BTreeSet;
use std::path::{Path, PathBuf};
use anyhow::{ensure, format_err, Context as _, Result};
use deltachat_contact_tools::{parse_vcard, VcardContact};
use deltachat_derive::{FromSql, ToSql};
use serde::{Deserialize, Serialize};
use tokio::{fs, io};
use crate::blob::BlobObject;
use crate::chat... | projects__deltachat-core__rust__message__.rs__function__56.txt |
projects/deltachat-core/c/dc_simplify.c | static int is_plain_quote(const char* buf)
{
if (buf[0]=='>') {
return 1;
}
return 0;
} | projects/deltachat-core/rust/simplify.rs | fn is_plain_quote(buf: &str) -> bool {
buf.starts_with('>')
} | projects__deltachat-core__rust__simplify__.rs__function__14.txt | ||
projects/deltachat-core/c/dc_chat.c | * If the group is already _promoted_ (any message was sent to the group),
* all group members are informed by a special status message that is sent automatically by this function.
*
* Sends out #DC_EVENT_CHAT_MODIFIED and #DC_EVENT_MSGS_CHANGED if a status message was sent.
*
* @memberof dc_context_t
* @param con... | projects/deltachat-core/rust/chat.rs | pub async fn remove_contact_from_chat(
context: &Context,
chat_id: ChatId,
contact_id: ContactId,
) -> Result<()> {
ensure!(
!chat_id.is_special(),
"bad chat_id, can not be special chat: {}",
chat_id
);
ensure!(
!contact_id.is_special() || contact_id == ContactId:... | async fn set_group_explicitly_left(context: &Context, grpid: &str) -> Result<()> {
if !is_group_explicitly_left(context, grpid).await? {
context
.sql
.execute("INSERT INTO leftgrps (grpid) VALUES(?);", (grpid,))
.await?;
}
Ok(())
}
pub async fn send_msg(context:... | use std::cmp;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::time::Duration;
use anyhow::{anyhow, bail, ensure, Context as _, Result};
use deltachat_contact_tools::{strip_rtlo_characters, ContactAddress};
use deltachat_derive::{FromSql, ToSql};
us... | projects__deltachat-core__rust__chat__.rs__function__133.txt |
projects/deltachat-core/c/dc_chat.c | int dc_chat_is_self_talk(const dc_chat_t* chat)
{
if (chat==NULL || chat->magic!=DC_CHAT_MAGIC) {
return 0;
}
return dc_param_exists(chat->param, DC_PARAM_SELFTALK);
} | projects/deltachat-core/rust/chat.rs | pub fn is_self_talk(&self) -> bool {
self.param.exists(Param::Selftalk)
} | pub fn exists(&self, key: Param) -> bool {
self.inner.contains_key(&key)
}
pub struct Chat {
/// Database ID.
pub id: ChatId,
/// Chat type, e.g. 1:1 chat, group chat, mailing list.
pub typ: Chattype,
/// Chat name.
pub name: String,
/// Whether the chat is archived or pinned... | use std::cmp;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::time::Duration;
use anyhow::{anyhow, bail, ensure, Context as _, Result};
use deltachat_contact_tools::{strip_rtlo_characters, ContactAddress};
use deltachat_derive::{FromSql, ToSql};
us... | projects__deltachat-core__rust__chat__.rs__function__61.txt |
projects/deltachat-core/c/dc_msg.c | void dc_msg_set_file(dc_msg_t* msg, const char* file, const char* filemime)
{
if (msg==NULL || msg->magic!=DC_MSG_MAGIC) {
return;
}
dc_param_set(msg->param, DC_PARAM_FILE, file);
dc_param_set_optional(msg->param, DC_PARAM_MIMETYPE, filemime);
} | projects/deltachat-core/rust/message.rs | pub fn set_file(&mut self, file: impl ToString, filemime: Option<&str>) {
if let Some(name) = Path::new(&file.to_string()).file_name() {
if let Some(name) = name.to_str() {
self.param.set(Param::Filename, name);
}
}
self.param.set(Param::File, file);
... | pub fn set(&mut self, key: Param, value: impl ToString) -> &mut Self {
self.inner.insert(key, value.to_string());
self
}
pub fn set_optional(&mut self, key: Param, value: Option<impl ToString>) -> &mut Self {
if let Some(value) = value {
self.set(key, value)
} else {
... | use std::collections::BTreeSet;
use std::path::{Path, PathBuf};
use anyhow::{ensure, format_err, Context as _, Result};
use deltachat_contact_tools::{parse_vcard, VcardContact};
use deltachat_derive::{FromSql, ToSql};
use serde::{Deserialize, Serialize};
use tokio::{fs, io};
use crate::blob::BlobObject;
use crate::chat... | projects__deltachat-core__rust__message__.rs__function__68.txt |
projects/deltachat-core/c/dc_chat.c | int dc_is_contact_in_chat(dc_context_t* context, uint32_t chat_id, uint32_t contact_id)
{
/* this function works for group and for normal chats, however, it is more useful for group chats.
DC_CONTACT_ID_SELF may be used to check, if the user itself is in a group chat (DC_CONTACT_ID_SELF is not added to normal chats) ... | projects/deltachat-core/rust/chat.rs | pub async fn is_contact_in_chat(
context: &Context,
chat_id: ChatId,
contact_id: ContactId,
) -> Result<bool> {
// this function works for group and for normal chats, however, it is more useful
// for group chats.
// ContactId::SELF may be used to check, if the user itself is in a group
// c... | pub async fn exists(&self, sql: &str, params: impl rusqlite::Params + Send) -> Result<bool> {
let count = self.count(sql, params).await?;
Ok(count > 0)
}
pub struct Context {
pub(crate) inner: Arc<InnerContext>,
}
pub struct InnerContext {
/// Blob directory path
pub(crate) blobdir: Pa... | use std::cmp;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::time::Duration;
use anyhow::{anyhow, bail, ensure, Context as _, Result};
use deltachat_contact_tools::{strip_rtlo_characters, ContactAddress};
use deltachat_derive::{FromSql, ToSql};
us... | projects__deltachat-core__rust__chat__.rs__function__103.txt |
projects/deltachat-core/c/dc_context.c | * The returned string must be free()'d.
*/
char* dc_get_blobdir(const dc_context_t* context)
{
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) {
return dc_strdup(NULL);
}
return dc_strdup(context->blobdir);
} | projects/deltachat-core/rust/context.rs | pub fn get_blobdir(&self) -> &Path {
self.blobdir.as_path()
} | pub struct Context {
pub(crate) inner: Arc<InnerContext>,
}
pub struct InnerContext {
/// Blob directory path
pub(crate) blobdir: PathBuf,
pub(crate) sql: Sql,
pub(crate) smeared_timestamp: SmearedTimestamp,
/// The global "ongoing" process state.
///
/// This is a global mutex-like sta... | use std::collections::{BTreeMap, HashMap};
use std::ffi::OsString;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
use anyhow::{bail, ensure, Context as _, Result};
use async_channel::{self as channel, Receiver, Sender};
us... | projects__deltachat-core__rust__context__.rs__function__29.txt |
projects/deltachat-core/c/dc_e2ee.c | static int has_decrypted_pgp_armor(const char* str__, int str_bytes)
{
const unsigned char* str_end = (const unsigned char*)str__+str_bytes;
const unsigned char* p=(const unsigned char*)str__;
while (p < str_end) {
if (*p > ' ') {
break;
}
p++;
str_bytes--;
}
if (str_bytes>26 && strncmp((const char*)p, ... | projects/deltachat-core/rust/decrypt.rs | fn has_decrypted_pgp_armor(input: &[u8]) -> bool {
if let Some(index) = input.iter().position(|b| *b > b' ') {
if input.len() - index > 26 {
let start = index;
let end = start + 27;
return &input[start..end] == b"-----BEGIN PGP MESSAGE-----";
}
}
false
} | use std::collections::HashSet;
use std::str::FromStr;
use anyhow::Result;
use deltachat_contact_tools::addr_cmp;
use mailparse::ParsedMail;
use crate::aheader::Aheader;
use crate::authres::handle_authres;
use crate::authres::{self, DkimResults};
use crate::context::Context;
use crate::headerdef::{HeaderDef, HeaderDefMa... | projects__deltachat-core__rust__decrypt__.rs__function__8.txt | |
projects/deltachat-core/c/dc_tools.c | int dc_write_file(dc_context_t* context, const char* pathNfilename, const void* buf, size_t buf_bytes)
{
int success = 0;
char* pathNfilename_abs = NULL;
if ((pathNfilename_abs=dc_get_abs_path(context, pathNfilename))==NULL) {
goto cleanup;
}
FILE* f = fopen(pathNfilename_abs, "wb");
if (f) {
if (fwrite(b... | projects/deltachat-core/rust/tools.rs | pub(crate) async fn write_file(
context: &Context,
path: impl AsRef<Path>,
buf: &[u8],
) -> Result<(), io::Error> {
let path_abs = get_abs_path(context, path.as_ref());
fs::write(&path_abs, buf).await.map_err(|err| {
warn!(
context,
"Cannot write {} bytes to \"{}\": {... | pub(crate) fn get_abs_path(context: &Context, path: &Path) -> PathBuf {
if let Ok(p) = path.strip_prefix("$BLOBDIR") {
context.get_blobdir().join(p)
} else {
path.into()
}
}
pub struct Context {
pub(crate) inner: Arc<InnerContext>,
} | use std::borrow::Cow;
use std::io::{Cursor, Write};
use std::mem;
use std::path::{Path, PathBuf};
use std::str::from_utf8;
use std::time::Duration;
use std::time::SystemTime as Time;
use std::time::SystemTime;
use anyhow::{bail, Context as _, Result};
use base64::Engine as _;
use chrono::{Local, NaiveDateTime, NaiveTim... | projects__deltachat-core__rust__tools__.rs__function__23.txt |
projects/deltachat-core/c/dc_msg.c | int dc_msg_get_height(const dc_msg_t* msg)
{
if (msg==NULL || msg->magic!=DC_MSG_MAGIC) {
return 0;
}
return dc_param_get_int(msg->param, DC_PARAM_HEIGHT, 0);
} | projects/deltachat-core/rust/message.rs | pub fn get_height(&self) -> i32 {
self.param.get_int(Param::Height).unwrap_or_default()
} | pub fn get_int(&self, key: Param) -> Option<i32> {
self.get(key).and_then(|s| s.parse().ok())
}
pub struct Message {
/// Message ID.
pub(crate) id: MsgId,
/// `From:` contact ID.
pub(crate) from_id: ContactId,
/// ID of the first contact in the `To:` header.
pub(crate) to_id: Cont... | use std::collections::BTreeSet;
use std::path::{Path, PathBuf};
use anyhow::{ensure, format_err, Context as _, Result};
use deltachat_contact_tools::{parse_vcard, VcardContact};
use deltachat_derive::{FromSql, ToSql};
use serde::{Deserialize, Serialize};
use tokio::{fs, io};
use crate::blob::BlobObject;
use crate::chat... | projects__deltachat-core__rust__message__.rs__function__44.txt |
projects/deltachat-core/c/dc_chat.c | uint32_t dc_chat_get_id(const dc_chat_t* chat)
{
if (chat==NULL || chat->magic!=DC_CHAT_MAGIC) {
return 0;
}
return chat->id;
} | projects/deltachat-core/rust/chat.rs | pub fn get_id(&self) -> ChatId {
self.id
} | pub struct Chat {
/// Database ID.
pub id: ChatId,
/// Chat type, e.g. 1:1 chat, group chat, mailing list.
pub typ: Chattype,
/// Chat name.
pub name: String,
/// Whether the chat is archived or pinned.
pub visibility: ChatVisibility,
/// Group ID. For [`Chattype::Mailinglist`] -... | use std::cmp;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::time::Duration;
use anyhow::{anyhow, bail, ensure, Context as _, Result};
use deltachat_contact_tools::{strip_rtlo_characters, ContactAddress};
use deltachat_derive::{FromSql, ToSql};
us... | projects__deltachat-core__rust__chat__.rs__function__69.txt |
projects/deltachat-core/c/dc_msg.c | void dc_msg_set_text(dc_msg_t* msg, const char* text)
{
if (msg==NULL || msg->magic!=DC_MSG_MAGIC) {
return;
}
free(msg->text);
msg->text = dc_strdup(text);
} | projects/deltachat-core/rust/message.rs | pub fn set_text(&mut self, text: String) {
self.text = text;
} | pub struct Message {
/// Message ID.
pub(crate) id: MsgId,
/// `From:` contact ID.
pub(crate) from_id: ContactId,
/// ID of the first contact in the `To:` header.
pub(crate) to_id: ContactId,
/// ID of the chat message belongs to.
pub(crate) chat_id: ChatId,
/// Type of the messa... | use std::collections::BTreeSet;
use std::path::{Path, PathBuf};
use anyhow::{ensure, format_err, Context as _, Result};
use deltachat_contact_tools::{parse_vcard, VcardContact};
use deltachat_derive::{FromSql, ToSql};
use serde::{Deserialize, Serialize};
use tokio::{fs, io};
use crate::blob::BlobObject;
use crate::chat... | projects__deltachat-core__rust__message__.rs__function__66.txt |
projects/deltachat-core/c/dc_chat.c | uint32_t dc_get_chat_id_by_grpid(dc_context_t* context, const char* grpid, int* ret_blocked, int* ret_verified)
{
uint32_t chat_id = 0;
sqlite3_stmt* stmt = NULL;
if(ret_blocked) { *ret_blocked = 0; }
if(ret_verified) { *ret_verified = 0; }
if (context==NULL || grpid==NULL) {
goto cleanup;
}
stmt = d... | projects/deltachat-core/rust/chat.rs | pub(crate) async fn get_chat_id_by_grpid(
context: &Context,
grpid: &str,
) -> Result<Option<(ChatId, bool, Blocked)>> {
context
.sql
.query_row_optional(
"SELECT id, blocked, protected FROM chats WHERE grpid=?;",
(grpid,),
|row| {
let chat... | pub async fn query_row_optional<T, F>(
&self,
sql: &str,
params: impl rusqlite::Params + Send,
f: F,
) -> Result<Option<T>>
where
F: Send + FnOnce(&rusqlite::Row) -> rusqlite::Result<T>,
T: Send + 'static,
{
self.call(move |conn| match conn.query_row(s... | use std::cmp;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::time::Duration;
use anyhow::{anyhow, bail, ensure, Context as _, Result};
use deltachat_contact_tools::{strip_rtlo_characters, ContactAddress};
use deltachat_derive::{FromSql, ToSql};
us... | projects__deltachat-core__rust__chat__.rs__function__142.txt |
projects/deltachat-core/c/dc_strencode.c | int dc_needs_ext_header(const char* to_check)
{
if (to_check) {
while (*to_check)
{
if (!isalnum(*to_check) && *to_check!='-' && *to_check!='_' && *to_check!='.' && *to_check!='~' && *to_check!='%') {
return 1;
}
to_check++;
}
}
return 0;
} | projects/deltachat-core/rust/mimefactory.rs | fn needs_encoding(to_check: &str) -> bool {
!to_check.chars().all(|c| {
c.is_ascii_alphanumeric() || c == '-' || c == '_' || c == '.' || c == '~' || c == '%'
})
} | use deltachat_contact_tools::ContactAddress;
use mailparse::{addrparse_header, MailHeaderMap};
use std::str;
use super::*;
use crate::chat::{
add_contact_to_chat, create_group_chat, remove_contact_from_chat, send_text_msg, ChatId,
ProtectionStatus,
};
use crate::chatlist::Chatlist;
use crate::consta... | projects__deltachat-core__rust__mimefactory__.rs__function__26.txt | |
projects/deltachat-core/c/dc_msg.c | void dc_set_msg_failed(dc_context_t* context, uint32_t msg_id, const char* error)
{
dc_msg_t* msg = dc_msg_new_untyped(context);
sqlite3_stmt* stmt = NULL;
if (!dc_msg_load_from_db(msg, context, msg_id)) {
goto cleanup;
}
if (DC_STATE_OUT_PREPARING==msg->state ||
DC_STATE_OUT_PENDING ==msg->state ||
... | projects/deltachat-core/rust/message.rs | pub(crate) async fn set_msg_failed(
context: &Context,
msg: &mut Message,
error: &str,
) -> Result<()> {
if msg.state.can_fail() {
msg.state = MessageState::OutFailed;
warn!(context, "{} failed: {}", msg.id, error);
} else {
warn!(
context,
"{} seems t... | pub fn can_fail(self) -> bool {
use MessageState::*;
matches!(
self,
OutPreparing | OutPending | OutDelivered | OutMdnRcvd // OutMdnRcvd can still fail because it could be a group message and only some recipients failed.
)
}
macro_rules! warn {
($ctx:expr, $msg:e... | use std::collections::BTreeSet;
use std::path::{Path, PathBuf};
use anyhow::{ensure, format_err, Context as _, Result};
use deltachat_contact_tools::{parse_vcard, VcardContact};
use deltachat_derive::{FromSql, ToSql};
use serde::{Deserialize, Serialize};
use tokio::{fs, io};
use crate::blob::BlobObject;
use crate::chat... | projects__deltachat-core__rust__message__.rs__function__92.txt |
projects/deltachat-core/c/dc_chat.c | * using dc_set_chat_profile_image().
* For normal chats, this is the image set by each remote user on their own
* using dc_set_config(context, "selfavatar", image).
*
* @memberof dc_chat_t
* @param chat The chat object.
* @return Path and file if the profile image, if any.
* NULL otherwise.
* Must be fr... | projects/deltachat-core/rust/chat.rs | pub async fn get_profile_image(&self, context: &Context) -> Result<Option<PathBuf>> {
if let Some(image_rel) = self.param.get(Param::ProfileImage) {
if !image_rel.is_empty() {
return Ok(Some(get_abs_path(context, Path::new(&image_rel))));
}
} else if self.id.is_ar... | pub async fn get_chat_contacts(context: &Context, chat_id: ChatId) -> Result<Vec<ContactId>> {
// Normal chats do not include SELF. Group chats do (as it may happen that one is deleted from a
// groupchat but the chats stays visible, moreover, this makes displaying lists easier)
let list = context
... | use std::cmp;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::time::Duration;
use anyhow::{anyhow, bail, ensure, Context as _, Result};
use deltachat_contact_tools::{strip_rtlo_characters, ContactAddress};
use deltachat_derive::{FromSql, ToSql};
us... | projects__deltachat-core__rust__chat__.rs__function__73.txt |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 2