summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2013-11-18 14:17:56 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2013-11-18 14:17:56 +0100
commitca84213fa8c98c225a0fe0acc90431f76f6944a7 (patch)
tree67d14a64d1e70c66eae537b18f5be2893d44639e /src
parenta70acff952f417ac4f9df750bd59aa4c9cdb01d4 (diff)
downloadcmumble-ca84213fa8c98c225a0fe0acc90431f76f6944a7.tar.gz
cmumble-ca84213fa8c98c225a0fe0acc90431f76f6944a7.tar.bz2
cmumble-ca84213fa8c98c225a0fe0acc90431f76f6944a7.zip
Implement channel join
Diffstat (limited to 'src')
-rw-r--r--src/cmumble.c4
-rw-r--r--src/commands.c32
2 files changed, 35 insertions, 1 deletions
diff --git a/src/cmumble.c b/src/cmumble.c
index 8d5c495..c566780 100644
--- a/src/cmumble.c
+++ b/src/cmumble.c
@@ -156,6 +156,10 @@ recv_user_state(MumbleProto__UserState *state, struct cmumble *cm)
user = find_user(cm, state->session);
if (user) {
/* update */
+
+ if (state->has_channel_id)
+ user->channel = find_channel(cm, state->channel_id);
+
return;
}
diff --git a/src/commands.c b/src/commands.c
index 5209504..6295281 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -9,6 +9,34 @@
#include <readline/history.h>
static void
+join_channel(struct cmumble *cm,
+ int argc, char **argv)
+{
+ MumbleProto__UserState state;
+ char *end;
+ long num;
+
+ if (argc < 1) {
+ g_print("usage: join <channel-number>");
+ return;
+ }
+
+ num = strtol(argv[1], &end, 10);
+ if (end == argv[1]) {
+ g_print("usage: join <channel-number>");
+ return;
+ }
+
+ mumble_proto__user_state__init(&state);
+ state.channel_id = num;
+ state.has_channel_id = 1;
+ state.session = cm->session;
+ state.has_session = 1;
+
+ cmumble_send_msg(cm, &state.base);
+}
+
+static void
list_users(struct cmumble *cm,
int argc, char **argv)
{
@@ -18,7 +46,8 @@ list_users(struct cmumble *cm,
for (l = cm->users; l; l = l->next) {
user = l->data;
- g_print("%4d: %s\n", user->session, user->name);
+ g_print("%4d: %s (channel: %s)\n", user->session, user->name,
+ user->channel->name);
}
}
@@ -95,6 +124,7 @@ msg(struct cmumble *cm,
}
static const struct cmumble_command commands[] = {
+ { "join", join_channel, "join channel [by id]" },
{ "lu", list_users, "list users" },
{ "lc", list_channels, "list channels" },
{ "clear", clear, "clear screen" },