diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..62edf8d --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +all: tests + +tests: test.m XMPPConnection.m XMPPStanza.m + objfw-compile -o $@ $^ -lidn -Wall -Werror diff --git a/XMPPConnection.m b/XMPPConnection.m index ea8c1de..c09cfb3 100644 --- a/XMPPConnection.m +++ b/XMPPConnection.m @@ -1,3 +1,5 @@ +#include +#include #import "XMPPConnection.h" #import "XMPPStanza.h" @@ -43,6 +45,27 @@ [super dealloc]; } +- (void)setUsername: (OFString*)username_ +{ + OFString *old = username; + char *node; + + Stringprep_rc rc; + if ((rc = stringprep_profile([username_ cString], &node, "Nodeprep", 0)) + != STRINGPREP_OK) { + of_log(@"Nodeprep failed: %s", stringprep_strerror(rc)); + assert(0); + } + + @try { + username = [[OFString alloc] initWithCString: node]; + } @finally { + free(node); + } + + [old release]; +} + - (void)_startStream { [sock writeFormat: @"\n"