diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-02-16 11:18:16 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-02-16 11:18:16 +0100 |
commit | 7ea6506c94edc7b7a5200538f5b32131c4f6d005 (patch) | |
tree | e8d49d1c14ddefe75ff0502a3eb7c0fab51aec21 /src | |
parent | 3266ae9f23cc4dff4190eb9b287a137f0ec8a10b (diff) | |
download | cmumble-7ea6506c94edc7b7a5200538f5b32131c4f6d005.tar.gz cmumble-7ea6506c94edc7b7a5200538f5b32131c4f6d005.tar.bz2 cmumble-7ea6506c94edc7b7a5200538f5b32131c4f6d005.zip |
Add verbose optionUDP
Disable all debug output using that flag for now.
Diffstat (limited to 'src')
-rw-r--r-- | src/cmumble.c | 27 | ||||
-rw-r--r-- | src/cmumble.h | 2 | ||||
-rw-r--r-- | src/connection.c | 3 | ||||
-rw-r--r-- | src/message.c | 4 |
4 files changed, 27 insertions, 9 deletions
diff --git a/src/cmumble.c b/src/cmumble.c index f37d782..61afdbc 100644 --- a/src/cmumble.c +++ b/src/cmumble.c @@ -52,7 +52,9 @@ cmumble_read_udp_data(struct cmumble *cm, guint8 *data, gsize size) switch ((data[0] >> 5) & 0x03) { case udp_ping: timestamp = decode_varint(&data[1], &num, size - 1); - g_print("received udp ping, timestamp: %ld\n", timestamp); + if (cm->verbose) + g_print("received udp ping, timestamp: %ld\n", + timestamp); break; case udp_voice_celt_alpha: case udp_voice_speex: @@ -74,8 +76,10 @@ recv_udp_tunnel(MumbleProto__UDPTunnel *tunnel, struct cmumble *cm) static void recv_version(MumbleProto__Version *version, struct cmumble *cm) { - g_print("version: 0x%x\n", version->version); - g_print("release: %s\n", version->release); + if (cm->verbose) { + g_print("version: 0x%x\n", version->version); + g_print("release: %s\n", version->release); + } } static void @@ -118,7 +122,8 @@ recv_server_sync(MumbleProto__ServerSync *sync, struct cmumble *cm) if (sync->welcome_text) g_print("Welcome Message: %s\n", sync->welcome_text); - g_print("got session: %d\n", cm->session); + if (cm->verbose) + g_print("got session: %d\n", cm->session); } static void @@ -141,8 +146,9 @@ static void recv_codec_version(MumbleProto__CodecVersion *codec, struct cmumble *cm) { - g_print("Codec Version: alpha: %d, beta: %d, pefer_alpha: %d\n", - codec->alpha, codec->beta, codec->prefer_alpha); + if (cm->verbose) + g_print("Codec Version: alpha: %d, beta: %d, pefer_alpha: %d\n", + codec->alpha, codec->beta, codec->prefer_alpha); } static void @@ -185,7 +191,8 @@ recv_user_state(MumbleProto__UserState *state, struct cmumble *cm) cm->user = user; cmumble_audio_create_playback_pipeline(cm, user); - g_print("receive user: %s\n", user->name); + if (cm->verbose) + g_print("receive user: %s\n", user->name); cm->users = g_list_prepend(cm->users, user); } @@ -297,6 +304,7 @@ cmumble_protocol_init(struct cmumble *cm) gchar *user = "unkown"; gchar *host = "localhost"; gint port = 64738; +gboolean verbose = FALSE; static GOptionEntry entries[] = { { @@ -311,6 +319,10 @@ static GOptionEntry entries[] = { "port", 'p', 0, G_OPTION_ARG_INT, &port, "port of the mumble server", "N" }, + { + "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, + "Turn on verbosity", NULL + }, { NULL } }; @@ -333,6 +345,7 @@ int main(int argc, char **argv) cm.user_name = user; cm.users = NULL; + cm.verbose = verbose; g_type_init(); cm.loop = g_main_loop_new(NULL, FALSE); diff --git a/src/cmumble.h b/src/cmumble.h index 0e0dd16..212991c 100644 --- a/src/cmumble.h +++ b/src/cmumble.h @@ -37,6 +37,8 @@ struct cmumble { struct cmumble_user *user; cryptState_t crypt; + + gboolean verbose; }; struct cmumble_user { diff --git a/src/connection.c b/src/connection.c index 7f4a312..ca624f9 100644 --- a/src/connection.c +++ b/src/connection.c @@ -91,7 +91,8 @@ do_udp_ping(struct cmumble *cm) send_udp(cm, data, pos); - g_print("udp ping sent: timestamp: %ld\n", tv.tv_sec); + if (cm->verbose) + g_print("udp ping sent: timestamp: %ld\n", tv.tv_sec); } void diff --git a/src/message.c b/src/message.c index a718f3b..54d9071 100644 --- a/src/message.c +++ b/src/message.c @@ -147,7 +147,9 @@ cmumble_recv_msg(struct cmumble *cm) return 0; } - g_print("debug: received message: %s type:%d, len:%d\n", messages[type].name, type, len); + if (cm->verbose) + g_print("debug: received message: %s type:%d, len:%d\n", + messages[type].name, type, len); if (cm->callbacks[type]) cm->callbacks[type](msg, cm); |