$ git clone http://tcclient.ion.nu/tc_client.git
commit 3a416e91da3f3f9d811727e505ba43c293bdd47a
Author: Alicia <...>
Date: Fri Apr 10 21:47:59 2015 +0200
tc_client-gtk: copied and adjusted the code for keeping track of our own nickname from cursedchat.
diff --git a/ChangeLog b/ChangeLog
index 2f1aabf..cc5ae03 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
0.31:
Fixed the issue where messages would show up on kanji on some platforms (a proper fix instead of the earlier android & apple workaround)
tc_client-gtk: added a margin to the autoscroll code, which should make scrolling work better when resizing the window or panes.
+tc_client-gtk: copied and adjusted the code for keeping track of our own nickname from cursedchat.
modbot: added a little note about the video being pre-approved when requesting an already approved video.
0.30:
Adjusted the configure script for compatibility with shells that still interpret escaped characters in single-quotes (contributed by Jade)
diff --git a/utilities/gtk/camviewer.c b/utilities/gtk/camviewer.c
index dd65a8d..e2c708b 100644
--- a/utilities/gtk/camviewer.c
+++ b/utilities/gtk/camviewer.c
@@ -1,6 +1,7 @@
/*
tc_client-gtk, a graphical user interface for tc_client
Copyright (C) 2015 alicia@ion.nu
+ Copyright (C) 2015 Pamela Hiatt
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -77,6 +78,7 @@ int tc_client[2];
int tc_client_in[2];
const char* channel=0;
const char* mycolor=0;
+char* nickname=0;
void updatescaling(struct viddata* data, unsigned int width, unsigned int height)
{
@@ -166,6 +168,13 @@ gboolean handledata(GIOChannel* iochannel, GIOCondition condition, gpointer data
}
return 1;
}
+ if(!strncmp(buf, "Connection ID: ", 15)) // Our initial nickname is "guest-" plus our connection ID
+ {
+ unsigned int length=strlen(&buf[15]);
+ nickname=malloc(length+strlen("guest-")+1);
+ sprintf(nickname, "guest-%s", &(buf[15]));
+ return 1;
+ }
// Start streams once we're properly connected
if(!strncmp(buf, "Currently on cam: ", 18))
{
@@ -274,6 +283,12 @@ gboolean handledata(GIOChannel* iochannel, GIOCondition condition, gpointer data
cam->nick=strdup(&space[21]);
gtk_label_set_text(GTK_LABEL(cam->label), cam->nick);
}
+ // If it was us, keep track of the new nickname
+ if(!strcmp(nickname, nick))
+ {
+ free(nickname);
+ nickname=strdup(&space[21]);
+ }
}
}
free(color);
@@ -357,7 +372,7 @@ gboolean handledata(GIOChannel* iochannel, GIOCondition condition, gpointer data
struct camera* cam=camera_new();
cam->frame=av_frame_alloc();
cam->dstframe=av_frame_alloc();
- cam->nick=strdup("You");
+ cam->nick=strdup(nickname);
cam->id=strdup("out");
cam->vctx=avcodec_alloc_context3(data->vdecoder);
avcodec_open2(cam->vctx, data->vdecoder, 0);
@@ -676,11 +691,11 @@ void sendmessage(GtkEntry* entry, struct viddata* data)
gtk_entry_set_text(entry, "");
return;
}
- char text[strlen("[00:00] ")+strlen("You: ")+strlen(msg)+1];
+ char text[strlen("[00:00] ")+strlen(nickname)+strlen(": ")+strlen(msg)+1];
time_t timestamp=time(0);
struct tm* t=localtime(×tamp);
sprintf(text, "[%02i:%02i] ", t->tm_hour, t->tm_min);
- sprintf(&text[8], "You: %s", msg);
+ sprintf(&text[8], "%s: %s", nickname, msg);
if(config_get_bool("enable_logging")){logger_write(text, channel, 0);}
printchat_color(data, text, mycolor, 8);
gtk_entry_set_text(entry, "");