text stringlengths 0 357 |
|---|
* - DC_CHAT_TYPE_GROUP (120) - a group chat, chats_contacts contain all group |
* members, incl. DC_CONTACT_ID_SELF |
* |
* - DC_CHAT_TYPE_VERIFIED_GROUP (130) - a verified group chat. In verified groups, |
* all members are verified and encryption is always active and cannot be disabled. |
* |
* @memberof dc_chat_t |
* @param chat The chat object. |
* @return Chat type. |
*/ |
int dc_chat_get_type(const dc_chat_t* chat) |
{ |
if (chat==NULL || chat->magic!=DC_CHAT_MAGIC) { |
return DC_CHAT_TYPE_UNDEFINED; |
} |
return chat->type; |
} |
/** |
* Get name of a chat. For one-to-one chats, this is the name of the contact. |
* For group chats, this is the name given eg. to dc_create_group_chat() or |
* received by a group-creation message. |
* |
* To change the name, use dc_set_chat_name() |
* |
* See also: dc_chat_get_subtitle() |
* |
* @memberof dc_chat_t |
* @param chat The chat object. |
* @return Chat name as a string. Must be free()'d after usage. Never NULL. |
*/ |
char* dc_chat_get_name(const dc_chat_t* chat) |
{ |
if (chat==NULL || chat->magic!=DC_CHAT_MAGIC) { |
return dc_strdup("Err"); |
} |
return dc_strdup(chat->name); |
} |
/** |
* Get a subtitle for a chat. The subtitle is eg. the email-address or the |
* number of group members. |
* |
* See also: dc_chat_get_name() |
* |
* @memberof dc_chat_t |
* @param chat The chat object to calulate the subtitle for. |
* @return Subtitle as a string. Must be free()'d after usage. Never NULL. |
*/ |
char* dc_chat_get_subtitle(const dc_chat_t* chat) |
{ |
/* returns either the address or the number of chat members */ |
char* ret = NULL; |
if (chat==NULL || chat->magic!=DC_CHAT_MAGIC) { |
return dc_strdup("Err"); |
} |
if (chat->type==DC_CHAT_TYPE_SINGLE && dc_param_exists(chat->param, DC_PARAM_SELFTALK)) |
{ |
ret = dc_stock_str(chat->context, DC_STR_SELFTALK_SUBTITLE); |
} |
else if (chat->type==DC_CHAT_TYPE_SINGLE) |
{ |
int r; |
sqlite3_stmt* stmt = dc_sqlite3_prepare(chat->context->sql, |
"SELECT c.addr FROM chats_contacts cc " |
" LEFT JOIN contacts c ON c.id=cc.contact_id " |
" WHERE cc.chat_id=?;"); |
sqlite3_bind_int(stmt, 1, chat->id); |
r = sqlite3_step(stmt); |
if (r==SQLITE_ROW) { |
ret = dc_strdup((const char*)sqlite3_column_text(stmt, 0)); |
} |
sqlite3_finalize(stmt); |
} |
else if (DC_CHAT_TYPE_IS_MULTI(chat->type)) |
{ |
int cnt = 0; |
if (chat->id==DC_CHAT_ID_DEADDROP) |
{ |
ret = dc_stock_str(chat->context, DC_STR_DEADDROP); /* typically, the subtitle for the deaddropn is not displayed at all */ |
} |
else |
{ |
cnt = dc_get_chat_contact_cnt(chat->context, chat->id); |
ret = dc_stock_str_repl_int(chat->context, DC_STR_MEMBER, cnt /*SELF is included in group chats (if not removed)*/); |
} |
} |
return ret? ret : dc_strdup("Err"); |
} |
/** |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.