mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-08-02 08:16:21 +00:00
style: apply clang-format and const qualifiers from master
This commit is contained in:
@@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
static sqlite3* g_chatlog_database;
|
static sqlite3* g_chatlog_database;
|
||||||
|
|
||||||
static void _add_to_db(ProfMessage* message, char* type, const Jid* const from_jid, const Jid* const to_jid);
|
static void _add_to_db(ProfMessage* message, const char* type, const Jid* const from_jid, const Jid* const to_jid);
|
||||||
static char* _get_db_filename(ProfAccount* account);
|
static char* _get_db_filename(ProfAccount* account);
|
||||||
static prof_msg_type_t _get_message_type_type(const char* const type);
|
static prof_msg_type_t _get_message_type_type(const char* const type);
|
||||||
static prof_enc_t _get_message_enc_type(const char* const encstr);
|
static prof_enc_t _get_message_enc_type(const char* const encstr);
|
||||||
@@ -147,7 +147,7 @@ _sqlite_init(ProfAccount* account)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* query = "CREATE TABLE IF NOT EXISTS `ChatLogs` ("
|
const char* query = "CREATE TABLE IF NOT EXISTS `ChatLogs` ("
|
||||||
"`id` INTEGER PRIMARY KEY AUTOINCREMENT, "
|
"`id` INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||||
"`from_jid` TEXT NOT NULL, "
|
"`from_jid` TEXT NOT NULL, "
|
||||||
"`to_jid` TEXT NOT NULL, "
|
"`to_jid` TEXT NOT NULL, "
|
||||||
@@ -251,7 +251,7 @@ _sqlite_add_incoming(ProfMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_log_database_add_outgoing(char* type, const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc)
|
_log_database_add_outgoing(const char* type, const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc)
|
||||||
{
|
{
|
||||||
ProfMessage* msg = message_init();
|
ProfMessage* msg = message_init();
|
||||||
|
|
||||||
@@ -350,8 +350,8 @@ _sqlite_get_previous_chat(const gchar* const contact_barejid, const gchar* start
|
|||||||
return DB_RESPONSE_ERROR;
|
return DB_RESPONSE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar* sort1 = from_start ? "ASC" : "DESC";
|
const gchar* sort1 = from_start ? "ASC" : "DESC";
|
||||||
gchar* sort2 = !flip ? "ASC" : "DESC";
|
const gchar* sort2 = !flip ? "ASC" : "DESC";
|
||||||
GDateTime* now = g_date_time_new_now_local();
|
GDateTime* now = g_date_time_new_now_local();
|
||||||
auto_gchar gchar* end_date_fmt = end_time ? g_strdup(end_time) : g_date_time_format_iso8601(now);
|
auto_gchar gchar* end_date_fmt = end_time ? g_strdup(end_time) : g_date_time_format_iso8601(now);
|
||||||
auto_sqlite gchar* query = sqlite3_mprintf("SELECT * FROM ("
|
auto_sqlite gchar* query = sqlite3_mprintf("SELECT * FROM ("
|
||||||
@@ -571,7 +571,7 @@ _get_message_enc_type(const char* const encstr)
|
|||||||
// --- Core write logic ---
|
// --- Core write logic ---
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_add_to_db(ProfMessage* message, char* type, const Jid* const from_jid, const Jid* const to_jid)
|
_add_to_db(ProfMessage* message, const char* type, const Jid* const from_jid, const Jid* const to_jid)
|
||||||
{
|
{
|
||||||
auto_gchar gchar* pref_dblog = prefs_get_string(PREF_DBLOG);
|
auto_gchar gchar* pref_dblog = prefs_get_string(PREF_DBLOG);
|
||||||
sqlite_int64 original_message_id = -1;
|
sqlite_int64 original_message_id = -1;
|
||||||
|
|||||||
@@ -268,7 +268,8 @@ main(int argc, char* argv[])
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Test group registry for easy extension */
|
/* Test group registry for easy extension */
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
const struct CMUnitTest* tests;
|
const struct CMUnitTest* tests;
|
||||||
size_t count;
|
size_t count;
|
||||||
|
|||||||
@@ -377,11 +377,6 @@ init_prof_test(void **state)
|
|||||||
"[notifications]\n"
|
"[notifications]\n"
|
||||||
"message=false\n"
|
"message=false\n"
|
||||||
"room=false\n");
|
"room=false\n");
|
||||||
const char *flatfile_env = getenv("PROF_FLATFILE");
|
|
||||||
if (flatfile_env && strcmp(flatfile_env, "1") == 0) {
|
|
||||||
fprintf(prc, "[logging]\ndblog=flatfile\n");
|
|
||||||
printf("[PROF_TEST] Wrote profrc with dblog=flatfile: %s\n", profrc_path);
|
|
||||||
}
|
|
||||||
fclose(prc);
|
fclose(prc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,17 +436,33 @@ prof_stop(void)
|
|||||||
{
|
{
|
||||||
if (fd > 0 && child_pid > 0) {
|
if (fd > 0 && child_pid > 0) {
|
||||||
prof_input("/quit");
|
prof_input("/quit");
|
||||||
sleep(1);
|
sleep_ms(QUIT_GRACE_MS);
|
||||||
waitpid(child_pid, NULL, 0);
|
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = 0;
|
fd = 0;
|
||||||
|
int exited = 0;
|
||||||
|
for (int i = 0; i < SHUTDOWN_POLL_MAX; i++) {
|
||||||
|
if (waitpid(child_pid, NULL, WNOHANG) != 0) {
|
||||||
|
exited = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sleep_ms(SHUTDOWN_POLL_MS);
|
||||||
|
}
|
||||||
|
if (!exited) {
|
||||||
|
kill(child_pid, SIGTERM);
|
||||||
|
for (int i = 0; i < SIGTERM_POLL_MAX; i++) {
|
||||||
|
if (waitpid(child_pid, NULL, WNOHANG) != 0) { exited = 1; break; }
|
||||||
|
sleep_ms(SHUTDOWN_POLL_MS);
|
||||||
|
}
|
||||||
|
if (!exited) {
|
||||||
|
kill(child_pid, SIGKILL);
|
||||||
|
waitpid(child_pid, NULL, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
child_pid = 0;
|
child_pid = 0;
|
||||||
}
|
}
|
||||||
/* Reset output buffer for clean restart */
|
/* Reset output buffer for clean restart */
|
||||||
output_len = 0;
|
output_len = 0;
|
||||||
output_buffer[0] = '\0';
|
output_buffer[0] = '\0';
|
||||||
/* Brief delay to let stabber release old connection state */
|
|
||||||
usleep(200000); /* 200ms */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -316,7 +316,8 @@ message_db_history_long_message(void **state)
|
|||||||
"<message id='long1' to='stabber@localhost' "
|
"<message id='long1' to='stabber@localhost' "
|
||||||
"from='buddy1@localhost/phone' type='chat'>"
|
"from='buddy1@localhost/phone' type='chat'>"
|
||||||
"<body>%s</body>"
|
"<body>%s</body>"
|
||||||
"</message>", body);
|
"</message>",
|
||||||
|
body);
|
||||||
stbbr_send(xml);
|
stbbr_send(xml);
|
||||||
|
|
||||||
assert_true(prof_output_exact("<< chat message: Buddy1/phone (win 2)"));
|
assert_true(prof_output_exact("<< chat message: Buddy1/phone (win 2)"));
|
||||||
|
|||||||
Reference in New Issue
Block a user