Merge branch 'cleanup-debug-output' into 'master'
Clean up debug output Closes #16 See merge request lupine/purple-plugin-delta!13
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
#include <connection.h>
|
||||
#include <debug.h>
|
||||
#include <eventloop.h>
|
||||
#include <util.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "delta-connection.h"
|
||||
#include "libdelta.h"
|
||||
#include "util.h"
|
||||
|
||||
void delta_recv_im(DeltaConnectionData *conn, uint32_t msg_id);
|
||||
|
||||
@@ -137,7 +138,7 @@ delta_process_fresh_messages(void *data)
|
||||
dc_array_t *fresh_msgs = dc_get_fresh_msgs(pr->conn->mailbox);
|
||||
size_t fresh_count = dc_array_get_cnt(fresh_msgs);
|
||||
|
||||
printf("*** fresh_count: %zu\n", fresh_count);
|
||||
purple_debug_info(PLUGIN_ID, "fresh_count: %zu\n", fresh_count);
|
||||
|
||||
for(size_t i = 0; i < fresh_count; i++) {
|
||||
delta_recv_im(pr->conn, dc_array_get_id(fresh_msgs, i));
|
||||
@@ -164,7 +165,7 @@ delta_process_http_get_cb(
|
||||
g_assert(pr->http_wait != NULL);
|
||||
|
||||
if (len == 0) {
|
||||
printf("Failed to GET %s: %s\n", pr->http_url, error_message);
|
||||
purple_debug_info("Failed to GET %s: %s\n", pr->http_url, error_message);
|
||||
pr->http_response = NULL;
|
||||
goto out;
|
||||
}
|
||||
@@ -225,21 +226,21 @@ my_delta_handler(dc_context_t* mailbox, int event, uintptr_t data1, uintptr_t da
|
||||
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
printf("my_delta_handler(mailbox, %d, %lu, %lu)\n", event, data1, data2);
|
||||
purple_debug_info(PLUGIN_ID, "Event %d received from Delta. Args: %" PRIuPTR ", %" PRIuPTR "\n", event, data1, data2);
|
||||
|
||||
switch (event) {
|
||||
case DC_EVENT_SMTP_MESSAGE_SENT:
|
||||
case DC_EVENT_IMAP_CONNECTED:
|
||||
case DC_EVENT_SMTP_CONNECTED:
|
||||
case DC_EVENT_INFO:
|
||||
printf("INFO: %s\n", (char *)data2);
|
||||
purple_debug_info(PLUGIN_ID, "INFO from Delta: %s\n", (char *)data2);
|
||||
break;
|
||||
case DC_EVENT_WARNING:
|
||||
printf("WARNING: %s\n", (char *)data2);
|
||||
purple_debug_info(PLUGIN_ID, "WARNING from Delta: %s\n", (char *)data2);
|
||||
break;
|
||||
case DC_EVENT_ERROR:
|
||||
case DC_EVENT_ERROR_NETWORK:
|
||||
printf("ERROR: %d: %s\n", (int)data1, (char *)data2);
|
||||
purple_debug_info(PLUGIN_ID, "ERROR from Delta: %d: %s\n", (int)data1, (char *)data2);
|
||||
break;
|
||||
|
||||
case DC_EVENT_MSGS_CHANGED:
|
||||
@@ -261,7 +262,7 @@ my_delta_handler(dc_context_t* mailbox, int event, uintptr_t data1, uintptr_t da
|
||||
case DC_EVENT_MSG_READ:
|
||||
case DC_EVENT_CHAT_MODIFIED:
|
||||
case DC_EVENT_CONTACTS_CHANGED:
|
||||
debug("TODO!\n");
|
||||
purple_debug_info(PLUGIN_ID, "Event %d is TODO\n", event);
|
||||
break;
|
||||
|
||||
case DC_EVENT_CONFIGURE_PROGRESS:
|
||||
@@ -271,7 +272,7 @@ my_delta_handler(dc_context_t* mailbox, int event, uintptr_t data1, uintptr_t da
|
||||
break;
|
||||
|
||||
case DC_EVENT_HTTP_GET:
|
||||
printf("HTTP GET requested: %s\n", (char *)data1);
|
||||
purple_debug_info(PLUGIN_ID, "HTTP GET requested: %s\n", (char *)data1);
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
@@ -296,16 +297,16 @@ my_delta_handler(dc_context_t* mailbox, int event, uintptr_t data1, uintptr_t da
|
||||
break;
|
||||
case DC_EVENT_IS_OFFLINE:
|
||||
if ( conn->pc == NULL || !PURPLE_CONNECTION_IS_CONNECTED(conn->pc) ) {
|
||||
debug("Telling Delta we are offline\n");
|
||||
purple_debug_info(PLUGIN_ID, "Telling Delta we are offline\n");
|
||||
out = 1;
|
||||
} else {
|
||||
debug("Telling Delta we are online\n");
|
||||
purple_debug_info(PLUGIN_ID, "Telling Delta we are online\n");
|
||||
}
|
||||
break;
|
||||
case DC_EVENT_GET_STRING:
|
||||
break;
|
||||
default:
|
||||
printf("Unknown event: %d\n", event);
|
||||
purple_debug_info(PLUGIN_ID, "Unknown Delta event: %d\n", event);
|
||||
}
|
||||
|
||||
return out;
|
||||
@@ -337,10 +338,10 @@ delta_connection_free(PurpleConnection *pc)
|
||||
|
||||
// TODO: correctly handle join failing
|
||||
if (pthread_join(conn->imap_thread, NULL) != 0) {
|
||||
debug("joining imap thread failed!\n");
|
||||
purple_debug_info(PLUGIN_ID, "joining imap thread failed\n");
|
||||
}
|
||||
if (pthread_join(conn->smtp_thread, NULL) != 0) {
|
||||
debug("joining smtp thread failed!\n");
|
||||
purple_debug_info(PLUGIN_ID, "joining smtp thread failed\n");
|
||||
}
|
||||
|
||||
dc_stop_ongoing_process(conn->mailbox);
|
||||
@@ -371,7 +372,7 @@ delta_connection_start_login(PurpleConnection *pc)
|
||||
);
|
||||
|
||||
if (!dc_open(mailbox, dbname, NULL)) {
|
||||
debug("dc_open returned false...?\n");
|
||||
purple_debug_info(PLUGIN_ID, "dc_open returned false...?\n");
|
||||
}
|
||||
|
||||
conn->mailbox = mailbox;
|
||||
@@ -426,7 +427,7 @@ delta_recv_im(DeltaConnectionData *conn, uint32_t msg_id)
|
||||
|
||||
dc_contact_t *contact = dc_get_contact(mailbox, contact_id);
|
||||
if (contact == NULL) {
|
||||
debug("Unknown contact! FIXME!\n");
|
||||
purple_debug_info(PLUGIN_ID, "Receiving IM: unknown contact: %d\n", contact_id);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@@ -78,8 +78,6 @@ delta_init_plugin(PurplePlugin *plugin)
|
||||
PurplePluginProtocolInfo *extra = (PurplePluginProtocolInfo *)plugin->info->extra_info;
|
||||
GList *opts = NULL;
|
||||
|
||||
debug("Starting up\n");
|
||||
|
||||
opts = g_list_prepend(opts, str_opt("Display Name", PLUGIN_ACCOUNT_OPT_DISPLAY_NAME, NULL));
|
||||
|
||||
opts = g_list_prepend(opts, str_opt("IMAP Server Host", PLUGIN_ACCOUNT_OPT_IMAP_SERVER_HOST, NULL));
|
||||
@@ -106,8 +104,6 @@ delta_init_plugin(PurplePlugin *plugin)
|
||||
static void
|
||||
delta_destroy_plugin(PurplePlugin *plugin) {
|
||||
UNUSED(plugin);
|
||||
|
||||
debug("Shutting down\n");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@@ -27,4 +27,6 @@
|
||||
#define PLUGIN_ACCOUNT_OPT_SMTP_USER "send_user"
|
||||
#define PLUGIN_ACCOUNT_OPT_SMTP_PASS "send_pw"
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
#endif
|
||||
|
11
util.c
11
util.c
@@ -1,11 +0,0 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include "libdelta.h"
|
||||
#include "util.h"
|
||||
|
||||
void
|
||||
debug(const char *str)
|
||||
{
|
||||
purple_debug_info(PLUGIN_ID, str);
|
||||
}
|
||||
|
Reference in New Issue
Block a user