text stringlengths 0 357 |
|---|
break; |
default: |
if (dc_param_get_int(param, DC_PARAM_CMD, 0)==DC_CMD_LOCATION_ONLY) { |
prefix = dc_stock_str(context, DC_STR_LOCATION); |
append_text = 0; |
} |
break; |
} |
if (append_text && prefix && text && text[0]) { |
ret = dc_mprintf("%s " DC_NDASH " %s", prefix, text); |
dc_truncate_n_unwrap_str(ret, approx_characters, 1/*unwrap*/); |
} |
else if (append_text && text && text[0]) { |
ret = dc_strdup(text); |
dc_truncate_n_unwrap_str(ret, approx_characters, 1/*unwrap*/); |
} |
else { |
ret = prefix; |
prefix = NULL; |
} |
/* cleanup */ |
free(prefix); |
free(pathNfilename); |
free(label); |
free(value); |
if (ret==NULL) { |
ret = dc_strdup(NULL); |
} |
return ret; |
} |
/** |
* Check if a message is still in creation. A message is in creation between |
* the calls to dc_prepare_msg() and dc_send_msg(). |
* |
* Typically, this is used for videos that are recoded by the UI before |
* they can be sent. |
* |
* @memberof dc_msg_t |
* @param msg The message object |
* @return 1=message is still in creation (dc_send_msg() was not called yet), |
* 0=message no longer in creation |
*/ |
int dc_msg_is_increation(const dc_msg_t* msg) |
{ |
if (msg==NULL || msg->magic!=DC_MSG_MAGIC || msg->context==NULL) { |
return 0; |
} |
return DC_MSG_NEEDS_ATTACHMENT(msg->type) && msg->state==DC_STATE_OUT_PREPARING; |
} |
void dc_msg_save_param_to_disk(dc_msg_t* msg) |
{ |
if (msg==NULL || msg->magic!=DC_MSG_MAGIC || msg->context==NULL || msg->context->sql==NULL) { |
return; |
} |
sqlite3_stmt* stmt = dc_sqlite3_prepare(msg->context->sql, |
"UPDATE msgs SET param=? WHERE id=?;"); |
sqlite3_bind_text(stmt, 1, msg->param->packed, -1, SQLITE_STATIC); |
sqlite3_bind_int (stmt, 2, msg->id); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
} |
/** |
* Set the text of a message object. |
* This does not alter any information in the database; this may be done by dc_send_msg() later. |
* |
* @memberof dc_msg_t |
* @param msg The message object. |
* @param text Message text. |
* @return None. |
*/ |
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); |
} |
/** |
* Set the file associated with a message object. |
* This does not alter any information in the database |
* nor copy or move the file or checks if the file exist. |
* All this can be done with dc_send_msg() later. |
* |
* @memberof dc_msg_t |
* @param msg The message object. |
* @param file If the message object is used in dc_send_msg() later, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.