[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: [PATCH] i18n KSirc
From: Toshitaka Fujioka <toshitaka () kde ! gr ! jp>
Date: 2002-03-09 15:40:22
[Download RAW message or body]
Hello,
The attached patch is i18n patch for KSirc.
KSirc can read/write of non-latin1 character and connect to non-latin1
channel.
You can set Options -> Set Encoding -> your encoding or RMB click on doc
icon in kicker -> Set Encoding -> your encoding.
I added one i18n string (Set Encoding).
Please review.
--
Toshitaka Fujioka
http://www.kde.org The K Desktop Environment Project
fujioka@kde.org
http://www.kde.gr.jp Japan KDE User's Group
toshitaka@kde.gr.jp
-- A journey of a thousand miles must begin with a single step. Lao-zi --
["kdenetwork-ksirc-i18n-20020310.diff" (text/x-diff)]
Index: chanparser.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/chanparser.cpp,v
retrieving revision 1.52
diff -u -3 -d -p -r1.52 chanparser.cpp
--- chanparser.cpp 2001/12/02 18:59:47 1.52
+++ chanparser.cpp 2002/03/09 15:33:28
@@ -12,6 +12,7 @@
#include <qapplication.h>
#include <klocale.h>
#include <kmessagebox.h>
+#include <kdebug.h>
// Static parser table is "initialized"
QDict<parseFunc> ChannelParser::parserTable;
@@ -128,11 +129,12 @@ parseResult * ChannelParser::parseSSFESt
{
string.remove(0, 4); // strip off the first 4 characters
+ QCString c_string = string.local8Bit();
const char *status;
if(string.length() < 8)
return new parseError("", "Unable to parse status string");
- status = string.ascii()+8;
+ status = (const char*)(c_string) + 8;
char nick[101], modes[101], chan[101], chanmode[101];
int away = 0;
modes[0] = 0x0; modes[1] = 0x0; // No mode set for user
@@ -176,8 +178,8 @@ parseResult * ChannelParser::parseSSFESt
}
}
- top->channelButtons->setNick(nick);
- QString channelMode = chanmode;
+ top->channelButtons->setNick( QString::fromLocal8Bit(nick) );
+ QString channelMode = QString::fromLocal8Bit( chanmode );
if (channelMode.findRev("t") != -1)
top->channelButtons->setProtectMode(true);
else top->channelButtons->setProtectMode(false);
@@ -194,7 +196,7 @@ parseResult * ChannelParser::parseSSFESt
top->channelButtons->setMenuItemMode(3, true);
else top->channelButtons->setMenuItemMode(3, false);
- QString nickModes = modes;
+ QString nickModes = QString::fromLocal8Bit( modes );
if (nickModes.findRev("i") != -1)
top->channelButtons->setMenuItemMode(4, true);
else top->channelButtons->setMenuItemMode(4, false);
@@ -205,8 +207,9 @@ parseResult * ChannelParser::parseSSFESt
top->channelButtons->setMenuItemMode(6, true);
else top->channelButtons->setMenuItemMode(6, false);
- QString status_line = chan;
- status_line += QString(" (") + chanmode + ") " + nick + " (" + modes + ") ";
+ QString status_line = QString::fromLocal8Bit( chan );
+ status_line += QString(" (") + QString::fromLocal8Bit( chanmode ) + ") "
+ + QString::fromLocal8Bit( nick ) + " (" + QString::fromLocal8Bit( \
modes ) + ") ";
/*
* Go srearching for key and limit messages
@@ -234,7 +237,7 @@ parseResult * ChannelParser::parseSSFESt
status_line += "T: " + QString("<No Topic Set>");
}
- if(strcmp(top->caption, status_line) != 0){
+ if(qstrcmp( (const char*)(top->caption.local8Bit()), (const \
char*)(status_line.local8Bit()) ) != 0){ if(nick[0] == '@' || (nick[0] == '*' && \
nick[1] == '@')) { // If we're an op,,
// update the nicks popup menu
@@ -270,15 +273,15 @@ parseResult * ChannelParser::parseSSFEOu
parseResult * ChannelParser::parseSSFEMsg(QString string)
{
-
- if(string.length() > 100)
+ QCString c_string = string.local8Bit();
+ if(c_string.length() > 100)
return new parseError(QString::null, QString("String length for nick is greater \
than 100 characters, insane, too big"));
- int l = string.length();
+ int l = c_string.length();
if (l <= 0)
return new parseError(string, QString("String not long enough"));
char *nick = new char[l + 1];
- int found = sscanf(string.ascii(), "`t` %s", nick);
+ int found = sscanf( (const char*)c_string, "`t` %s", nick);
if(found < 1) {
delete nick;
@@ -348,7 +351,7 @@ parseResult * ChannelParser::parseSSFERe
{
if(top->channel_name[0] == '#'){
- QString str = "/join " + QString(top->channel_name) + "\n";
+ QString str = "/join " + top->channel_name + "\n";
emit top->outputLine(str);
}
@@ -372,6 +375,7 @@ parseResult * ChannelParser::parseINFOEr
parseResult * ChannelParser::parseINFONicks(QString in_string)
{
QString string = in_string;
+ QCString c_string = string.local8Bit();
char *nick;
char *place_holder;
@@ -381,15 +385,15 @@ parseResult * ChannelParser::parseINFONi
bool clear_box = FALSE;
// Check to see if it's a continued line
- if(string[1] == 'C'){
- string[1] = '!';
+ if(c_string[1] == 'C'){
+ c_string[1] = '!';
clear_box = TRUE;
}
- if(string[1] == '#'){
- string[1] = '!';
+ if(c_string[1] == '#'){
+ c_string[1] = '!';
clear_box = FALSE;
}
- else if(string[1] == 'c'){
+ else if(c_string[1] == 'c'){
if(current_item > 0)
top->nicks->setCurrentItem(current_item);
top->nicks->setTopItem(top_item);
@@ -400,17 +404,17 @@ parseResult * ChannelParser::parseINFONi
// Get the channel name portion of the string
// Search for the first space, since : can be embeded into channel names.
- count = sscanf(string, "*!* Users on %100[^ ]", channel_name);
+ count = sscanf(c_string, "*!* Users on %100[^ ]", channel_name);
if(count < 1){
- return new parseError(string, QString("Could not find channel name"));
+ return new parseError(QString::fromLocal8Bit( c_string ), QString("Could not \
find channel name")); }
// Remove the : from the end.
channel_name[strlen(channel_name)-1] = 0x0;
- if (strcasecmp(channel_name,top->channel_name) != 0){
- string.remove(0,3);
- return new parseSucc(string,ksopts->infoColor,top->pix_info);
+ if (strcasecmp(channel_name, (const char*)( (top->channel_name).local8Bit() )) != \
0){ + c_string.remove(0,3);
+ return new parseSucc(QString::fromLocal8Bit( c_string ), ksopts->infoColor, \
top->pix_info); }
if(clear_box == TRUE){
@@ -419,12 +423,12 @@ parseResult * ChannelParser::parseINFONi
top->nicks->clear();
}
- int start = string.find(": ", 0, FALSE); // Find start of nicks
+ int start = c_string.find(": ", 0, FALSE); // Find start of nicks
if (start < 0)
- return new parseError(string, QString("Could not find start of nicks"));
+ return new parseError( QString::fromLocal8Bit( c_string ), QString("Could not \
find start of nicks"));
- place_holder = new char[string.length()];
- strcpy(place_holder, string.ascii()+start+2);
+ place_holder = new char[c_string.length()];
+ qstrcpy( place_holder, (const char*)(c_string)+start+2 );
nick = strtok(place_holder, " ");
while(nick != 0x0){ // While there's nick to go...
@@ -454,7 +458,7 @@ parseResult * ChannelParser::parseINFONi
nick++; // Move ahead to next character
}
- irc->setText(nick);
+ irc->setText( QString::fromLocal8Bit( nick ) );
top->nicks->inSort(irc);
nick = strtok(NULL, " ");
}
@@ -465,23 +469,25 @@ parseResult * ChannelParser::parseINFONi
parseResult * ChannelParser::parseINFOJoin(QString string)
{
+ QCString c_string = string.local8Bit();
char nick[101], channel[101];
- string.remove(0, 4); // strip *>* to save a few compares
- if(sscanf(string, "You have joined channel %100s", channel) > 0){
- QString chan = QString(channel).lower();
- if(strcasecmp(top->channel_name, chan) == 0)
+ c_string.remove(0, 4); // strip *>* to save a few compares
+ if(sscanf((const char*)c_string, "You have joined channel %100s", channel) > 0){
+ QString chan = QString::fromLocal8Bit( channel );
+ chan = chan.lower();
+ if(strcasecmp((const char*)top->channel_name.local8Bit(), (const \
char*)chan.local8Bit()) == 0) top->show();
emit top->open_toplevel(chan);
- return new parseSucc(" " + string, ksopts->channelColor, top->pix_greenp);
+ return new parseSucc(" " + QString::fromLocal8Bit( c_string ), \
ksopts->channelColor, top->pix_greenp); }
- else if(sscanf(string, "%100s %*s has joined channel %100s", nick, channel) > 0){
- if(strcasecmp(top->channel_name, channel) != 0){
- return new parseWrongChannel(" " + string, ksopts->errorColor, \
top->pix_greenp); + else if(sscanf((const char*)c_string, "%100s %*s has joined \
channel %100s", nick, channel) > 0){ + if(strcasecmp((const \
char*)top->channel_name.local8Bit(), channel) != 0){ + return new \
parseWrongChannel(" " + QString::fromLocal8Bit( c_string ), ksopts->errorColor, \
top->pix_greenp); }
// nicks->insertItem(s3, 0); // add the sucker
top->nicks->inSort(nick);
- top->addCompleteNick(nick);
+ top->addCompleteNick( QString::fromLocal8Bit( nick ) );
return new parseSucc(" " + string, ksopts->channelColor, top->pix_greenp);
}
@@ -490,11 +496,12 @@ parseResult * ChannelParser::parseINFOJo
parseResult * ChannelParser::parseINFOPart(QString string)
{
+ QCString c_string = string.local8Bit();
char nick[101], channel[101];
bool foundNick = false;
- string.remove(0, 4); // clear junk
+ c_string.remove(0, 4); // clear junk
// Multiple type of parts, a signoff or a /part
// Each get's get nick in a diffrent localtion
@@ -504,7 +511,8 @@ parseResult * ChannelParser::parseINFOPa
// 3. /kick, kicked off the channel, nick after "kicked off \w+$"
//
- if(sscanf(string, "Signoff: %100s", nick) >= 1)
+ kdDebug() << "String: " << string << endl;
+ if(sscanf((const char*)c_string, "Signoff: %100s", nick) >= 1)
{
foundNick = true;
}
@@ -512,9 +520,9 @@ parseResult * ChannelParser::parseINFOPa
* Check for "You" before everyone else or else the next
* case will match it
*/
- else if(sscanf(string, "You have left channel %100s", channel))
+ else if(sscanf((const char*)c_string, "You have left channel %100s", channel))
{
- if(strcasecmp(top->channel_name, channel) == 0)
+ if(strcasecmp((const char*)top->channel_name.local8Bit(), channel) == 0)
{
QApplication::postEvent(top, new QCloseEvent());
// WE'RE DEAD
@@ -524,10 +532,10 @@ parseResult * ChannelParser::parseINFOPa
/*
* Same as above, check your own state first
*/
- else if(sscanf(string, "You have been kicked off channel %100s", channel) >= 1)
+ else if(sscanf((const char*)c_string, "You have been kicked off channel %100s", \
channel) >= 1) {
- if(strcasecmp(top->channel_name, channel) != 0)
- return new parseWrongChannel(string, ksopts->errorColor, top->pix_madsmile);
+ if(strcasecmp((const char*)top->channel_name.local8Bit(), channel) != 0)
+ return new parseWrongChannel( QString::fromLocal8Bit( c_string ), \
ksopts->errorColor, top->pix_madsmile); if (ksopts->autoRejoin == TRUE)
{
QString str = "/join " + QString(top->channel_name) + "\n";
@@ -540,9 +548,10 @@ parseResult * ChannelParser::parseINFOPa
else
{
if(top->KickWinOpen != false)
- return new parseError(" " + string, QString("Kick window open"));
+ return new parseError(" " + QString::fromLocal8Bit( c_string ), \
QString("Kick window open")); top->KickWinOpen = true;
- int result = KMessageBox::questionYesNo(top, string, i18n("You Have Been \
Kicked"), i18n("Rejoin"), i18n("Leave")); + int result = \
KMessageBox::questionYesNo(top, QString::fromLocal8Bit( c_string ), i18n("You Have \
Been Kicked"), + i18n("Rejoin"), \
i18n("Leave")); if (result == KMessageBox::Yes)
{
QString str = "/join " + QString(top->channel_name) + "\n";
@@ -551,7 +560,7 @@ parseResult * ChannelParser::parseINFOPa
top->ticker->show();
else*/
top->show();
- return new parseSucc(" " + string, ksopts->channelColor, top->pix_greenp);
+ return new parseSucc(" " + QString::fromLocal8Bit( c_string ), \
ksopts->channelColor, top->pix_greenp); }
else
{
@@ -561,9 +570,9 @@ parseResult * ChannelParser::parseINFOPa
}
}
}
- else if(sscanf(string, "%100s has left channel %100s", nick, channel) >= 2)
+ else if(sscanf((const char*)c_string, "%100s has left channel %100s", nick, \
channel) >= 2) {
- if(strcasecmp(top->channel_name, channel) == 0)
+ if(strcasecmp( (const char*)top->channel_name.local8Bit(), channel ) == 0)
{
foundNick = true;
}
@@ -571,9 +580,9 @@ parseResult * ChannelParser::parseINFOPa
return new parseWrongChannel(QString::null);
}
}
- else if(sscanf(string, "%100s has been kicked off channel %100s", nick, channel) \
>= 2) + else if(sscanf( (const char*)c_string, "%100s has been kicked off channel \
> %100s", nick, channel ) >= 2)
{
- if(strcasecmp(top->channel_name, channel) == 0)
+ if(strcasecmp( (const char*)top->channel_name.local8Bit(), channel ) == 0)
{
foundNick = true;
}
@@ -583,14 +592,14 @@ parseResult * ChannelParser::parseINFOPa
}
}
else{ // uhoh, something we missed?
- return new parseError(" " + string, QString("Failed to parse \
part/kick/leave/quit message")); + return new parseError(" " + \
QString::fromLocal8Bit( c_string ), QString("Failed to parse part/kick/leave/quit \
message")); }
if (foundNick)
{
- int index = top->nicks->findNick(nick);
+ int index = top->nicks->findNick( QString::fromLocal8Bit( nick ) );
if(index >= 0){
top->nicks->removeItem(index);
- return new parseSucc(" " + string, ksopts->channelColor, top->pix_greenp);
+ return new parseSucc(" " + QString::fromLocal8Bit( c_string ), \
ksopts->channelColor, top->pix_greenp); }
else{
return new parseSucc(QString::null);
@@ -601,34 +610,35 @@ parseResult * ChannelParser::parseINFOPa
parseResult * ChannelParser::parseINFOChangeNick(QString string)
{
+ QCString c_string = string.local8Bit();
char old_nick[101], new_nick[101];
- string.remove(0, 4); // Remove the leading *N* and space
- int found = sscanf(string, "%100s is now known as %100s", old_nick, new_nick);
+ c_string.remove(0, 4); // Remove the leading *N* and space
+ int found = sscanf( (const char*)c_string, "%100s is now known as %100s", \
old_nick, new_nick); if(found < 0){
- return new parseError(" Unable to parse: " + string, QString("Unable to parse \
change nick code")); + return new parseError(" Unable to parse: " + \
QString::fromLocal8Bit( c_string ), QString("Unable to parse change nick code")); }
// If we have a window open talking to the nick
// Change the nick to the new one.
- if((top->channel_name[0] != '#') &&
- (strcasecmp(top->channel_name, old_nick) == 0)){
- QString snew_nick = new_nick;
+ if((top->channel_name.local8Bit()[0] != '#') &&
+ (strcasecmp( (const char*)top->channel_name.local8Bit(), old_nick ) == 0)){
+ QString snew_nick = QString::fromLocal8Bit( new_nick );
- top->control_message(CHANGE_CHANNEL, snew_nick.lower());
+ top->control_message(CHANGE_CHANNEL, QString::fromLocal8Bit( snew_nick \
).lower()); }
// search the list for the nick and remove it
// since the list is source we should do a binary search...
- found = top->nicks->findNick(old_nick);
+ found = top->nicks->findNick( QString::fromLocal8Bit( old_nick ) );
if(found >= 0){ // If the nick's in the nick list, change it and display the \
change int selection = top->nicks->currentItem();
bool isOp = top->nicks->isTop(found); // Are they an op?
top->nicks->removeItem(found); // remove old nick
- top->changeCompleteNick(old_nick, new_nick);
+ top->changeCompleteNick( QString::fromLocal8Bit( old_nick ), \
QString::fromLocal8Bit( new_nick ) ); if(isOp == TRUE){
nickListItem *irc = new nickListItem();
- irc->setText(new_nick);
+ irc->setText( QString::fromLocal8Bit( new_nick ) );
irc->setOp(TRUE);
top->nicks->inSort(irc);
}
@@ -640,7 +650,7 @@ parseResult * ChannelParser::parseINFOCh
top->nicks->setCurrentItem(selection);
top->nicks->repaint(TRUE);
// We're done, so let's finish up
- return new parseSucc(" " + string, ksopts->channelColor, top->pix_greenp);
+ return new parseSucc(" " + QString::fromLocal8Bit( c_string ), \
ksopts->channelColor, top->pix_greenp); }
else {
return new parseSucc(QString::null);
@@ -659,7 +669,8 @@ parseResult * ChannelParser::parseINFOMo
// Strip off leading sirc info
- string.remove(0, 4);
+ QCString c_string = string.local8Bit();
+ c_string.remove(0, 4);
/*
@@ -669,17 +680,17 @@ parseResult * ChannelParser::parseINFOMo
char *next_arg; //, *next_token;
int found = 0;
- if(string.find("for user") >= 0)
- return new parseSucc(" " + string, ksopts->infoColor, top->pix_bluep);
+ if(c_string.find("for user") >= 0)
+ return new parseSucc(" " + QString::fromLocal8Bit( c_string ), \
ksopts->infoColor, top->pix_bluep);
/*
* We need to 2 scanf's, one for the case of arguments, and one for no args.
*/
- found = sscanf(string, "Mode change \"%1023s %1023[^\"]\" on channel %100s", \
modes, args, channel); + found = sscanf( (const char*)c_string, "Mode change \
\"%1023s %1023[^\"]\" on channel %100s", modes, args, channel); if(found < 3){
- found = sscanf(string, "Mode change \"%1023[^\" ]\" on channel %100s", modes, \
channel); + found = sscanf( (const char*)c_string, "Mode change \"%1023[^\" ]\" on \
channel %100s", modes, channel); if(found < 2)
- return new parseError(" Failed to parse mode change: " + string, \
QString::null); + return new parseError(" Failed to parse mode change: " + \
QString::fromLocal8Bit( c_string ), QString::null); /*
* But in a null so incase we try and read an arg we don't barf
*/
@@ -717,7 +728,7 @@ parseResult * ChannelParser::parseINFOMo
case 'k': // kcik, arg is nick
mode.append(fmode);
if(next_arg == NULL)
- return new parseError(" Unable to parse mode change: " + string, \
QString::null); + return new parseError(" Unable to parse mode change: " + \
QString::fromLocal8Bit( c_string ), QString::null); arg.append(next_arg);
next_arg = strtok(NULL, " ");
break;
@@ -761,7 +772,7 @@ parseResult * ChannelParser::parseINFOMo
continue;
}
- int offset = top->nicks->findNick(arg.at(i));
+ int offset = top->nicks->findNick( QString::fromLocal8Bit( arg.at(i) ) );
if(offset >= 0){
nickListItem *irc = new nickListItem();
*irc = *top->nicks->item(offset);
@@ -805,7 +816,7 @@ parseResult * ChannelParser::parseINFOMo
continue;
}
- int offset = top->nicks->findNick(arg.at(i));
+ int offset = top->nicks->findNick( QString::fromLocal8Bit( arg.at(i) ) );
if(offset >= 0){
nickListItem *irc = new nickListItem();
*irc = *top->nicks->item(offset);
@@ -823,7 +834,7 @@ parseResult * ChannelParser::parseINFOMo
/*
* We're all done, so output the message and be done with it
*/
- return new parseSucc(" " + string, ksopts->infoColor, top->pix_info);
+ return new parseSucc(" " + QString::fromLocal8Bit( c_string ), ksopts->infoColor, \
top->pix_info); }
parseResult * ChannelParser::parseCTCPAction(QString string)
@@ -836,34 +847,35 @@ parseResult * ChannelParser::parseCTCPAc
parseResult * ChannelParser::parseINFOTopic(QString string)
{
+ QCString c_string = string.local8Bit();
char channel[101];
- string.remove(0, 4); // Remove the leading *T* and space
+ c_string.remove(0, 4); // Remove the leading *T* and space
// *T* Topic for #kde: Don't use koffice! You will get into deep emotional \
problems!
- int found = sscanf(string, "Topic for %100[^:]: ", channel);
+ int found = sscanf( (const char*)c_string, "Topic for %100[^:]: ", channel);
if(found == 1){
// If this is the correct channel, set the status line for the topic
- if(strcasecmp(top->channel_name, channel) == 0){
- int start = string.find(": ")+1;
- int end = string.length() - start;
- QString topic = string.mid(start, end);
+ if(strcasecmp( (const char*)top->channel_name.local8Bit(), channel ) == 0){
+ int start = c_string.find(": ")+1;
+ int end = c_string.length() - start;
+ QCString topic = c_string.mid(start, end);
topic.replace(QRegExp("~~"), "~");
- top->setTopic( topic );
+ top->setTopic( QString::fromLocal8Bit( topic ) );
}
}
else {
- found = sscanf(string, "%*s has changed the topic on channel %100s to", \
channel); + found = sscanf( (const char*)c_string, "%*s has changed the topic on \
channel %100s to", channel); if(found == 1){
- if(strcasecmp(top->channel_name, channel) == 0){
- int start = string.find(" \"")+2;
- int end = string.length() - start - 1; // 1 to remove trailing "
- QString topic = string.mid(start, end);
+ if(strcasecmp( (const char*)top->channel_name.local8Bit(), channel ) == 0){
+ int start = c_string.find(" \"")+2;
+ int end = c_string.length() - start - 1; // 1 to remove trailing "
+ QCString topic = c_string.mid(start, end);
topic.replace(QRegExp("~~"), "~");
- top->setTopic( topic );
+ top->setTopic( QString::fromLocal8Bit( topic ) );
QString cmd = "/eval &dostatus();\n";
top->sirc_write(cmd);
}
}
}
- return new parseSucc(" " + string, ksopts->infoColor, top->pix_bball);
+ return new parseSucc(" " + QString::fromLocal8Bit( c_string ), ksopts->infoColor, \
top->pix_bball); }
Index: dsirc
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/dsirc,v
retrieving revision 1.42
diff -u -3 -d -p -r1.42 dsirc
--- dsirc 2001/12/02 16:39:45 1.42
+++ dsirc 2002/03/09 15:33:40
@@ -315,7 +315,7 @@ sub dostatus {
for($i=0; $i<=$#channels; $i++){
$s = " [sirc] ";
$t = $channels[$i];
- $t =~ tr/A-Z/a-z/;
+### $t =~ tr/A-Z/a-z/;
$s.="*" if $umode =~ /o/;
$s.="\@" if $t && $haveops{$t};
$s.=$nick;
@@ -1688,7 +1688,7 @@ sub signoffs {
sub modestripper {
local($chnl, $what)=@_;
- $chnl =~ tr/A-Z/a-z/;
+### $chnl =~ tr/A-Z/a-z/;
local($how, $modes, @args)=('+', split(/ +/, $what));
foreach $m (split(//, $modes)) {
if ($m =~ /[\-\+]/) {
@@ -1944,7 +1944,7 @@ sub donumeric {
local($g, $c, $m)=split(/ +/, $args, 3);
$m =~ s/^://;
$m =~ s/ $//;
- $c =~ tr/A-Z/a-z/;
+### $c =~ tr/A-Z/a-z/;
if (grep(&eq($_, $c), @channels)) {
if (defined($mode{$c})) {
&tell("*\cb+\cb* Mode for channel $c is \"$m\"");
@@ -1998,7 +1998,7 @@ sub donumeric {
else { # KSIRC MOD
&tell("~${c}~*\cb#\cb* Users on $c: $r"); # KSIRC MOD
} # KSIRC MOD
- $c =~ tr/A-Z/a-z/;
+### $c =~ tr/A-Z/a-z/;
$haveops{$c}=1 if ($r =~ /\@${n}( |$)/i);
&dostatus if &eq($c, $talkchannel);
} elsif ($cmd eq '366'){ # KSIRC MOD
@@ -2247,7 +2247,7 @@ while (1) {
} else {
$talkchannel='';
}
- $channel =~ tr/A-Z/a-z/;
+### $channel =~ tr/A-Z/a-z/;
&dohooks("kick", $newarg, $channel, $args);
delete $mode{$channel};
delete $limit{$channel};
Index: iocontroller.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/iocontroller.cpp,v
retrieving revision 1.42
diff -u -3 -d -p -r1.42 iocontroller.cpp
--- iocontroller.cpp 2002/02/19 21:12:46 1.42
+++ iocontroller.cpp 2002/03/09 15:33:45
@@ -71,6 +71,8 @@
#include "ksircprocess.h"
#include "messageReceiver.h"
+#include <qtextcodec.h>
+
#include <kdebug.h>
#include <kprocess.h>
#include <kstandarddirs.h>
@@ -87,6 +89,7 @@ KSircIOController::KSircIOController(KPr
ksircproc = _ksircproc; // save ksircproce
send_buf = 0x0;
+ readError = false;
// Connect the data arrived
// to sirc receive for adding
@@ -151,8 +154,19 @@ void KSircIOController::stdout_read(KPro
int pos,pos2,pos3;
QString name, line;
- QString buffer(QString::fromLocal8Bit(_buffer, buflen));
- // kdDebug() << "<-- read: " << buffer;
+ QTextCodec *codec = 0;
+ if ( readError )
+ codec = QTextCodec::codecForLocale(); // stderr is locale
+ else
+ codec = QTextCodec::codecForName( ksopts->useEncoding.latin1() );
+
+ readError = false;
+ QString buffer = "";
+ if ( codec )
+ buffer = codec->makeDecoder()->toUnicode( _buffer, buflen );
+
+ kdDebug() << "Read Buffer: " << buffer << endl;
+
name = "!default";
if(holder.length() > 0){
@@ -226,6 +240,8 @@ KSircIOController::~KSircIOController()
void KSircIOController::stderr_read(KProcess *p, char *b, int l)
{
+ kdDebug() << "Error" << endl;
+ readError = true;
stdout_read(p, b, l);
}
@@ -238,14 +254,18 @@ void KSircIOController::stdin_write(QStr
}
// kdDebug() << "--> wrote: " << s;
buffer += s;
+ kdDebug() << "Write Buffer: " << buffer << endl;
+ QTextCodec *codec = QTextCodec::codecForName( ksopts->useEncoding.latin1() );
+ QCString tmpBuffer = codec->fromUnicode( buffer );
+
if(proc_CTS == TRUE){
- int len = buffer.length();
+ int len = tmpBuffer.length();
if(send_buf != 0x0){
qWarning("KProcess barfed in all clear signal again");
delete[] send_buf;
}
send_buf = new char[len];
- strncpy(send_buf, buffer.local8Bit(), len);
+ strncpy(send_buf, (const char*)tmpBuffer, len);
if(proc->writeStdin(send_buf, len) == FALSE){
kdDebug() << "Failed to write but CTS HIGH! Setting low!: " << s << endl;
}
@@ -255,7 +275,7 @@ void KSircIOController::stdin_write(QStr
proc_CTS = FALSE;
}
- if(buffer.length() > 5000){
+ if(tmpBuffer.length() > 5000){
kdDebug() << "IOController: KProcess barfing again!\n";
}
// write(sirc_stdin, s, s.length());
Index: iocontroller.h
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/iocontroller.h,v
retrieving revision 1.8
diff -u -3 -d -p -r1.8 iocontroller.h
--- iocontroller.h 2001/09/01 14:45:52 1.8
+++ iocontroller.h 2002/03/09 15:33:45
@@ -38,6 +38,7 @@ private:
QString buffer;
static int counter;
+ bool readError;
};
#endif
Index: ksirc.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ksirc.cpp,v
retrieving revision 1.67
diff -u -3 -d -p -r1.67 ksirc.cpp
--- ksirc.cpp 2002/02/28 10:57:55 1.67
+++ ksirc.cpp 2002/03/09 15:33:46
@@ -103,7 +103,7 @@ int main( int argc, char ** argv )
QCString server = args->getOption( "server" );
if ( !nickName.isEmpty() )
- ksopts->nick = nickName;
+ ksopts->nick = QString::fromLocal8Bit( nickName );
if ( !server.isEmpty() )
sc->new_ksircprocess( QString::fromLocal8Bit( server ) );
Index: ksircprocess.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ksircprocess.cpp,v
retrieving revision 1.97
diff -u -3 -d -p -r1.97 ksircprocess.cpp
--- ksircprocess.cpp 2002/02/27 12:08:42 1.97
+++ ksircprocess.cpp 2002/03/09 15:33:50
@@ -141,15 +141,15 @@ KSircProcess::KSircProcess( const QStrin
//
if((qsNick.isEmpty() == FALSE)){
QString env = "SIRCNICK=" + qsNick;
- putenv(qstrdup(env.ascii()));
+ putenv(qstrdup(env.latin1()));
}
if((qsAltNick.isEmpty() == FALSE)){
QString env = "BACKUPNICK=" + qsAltNick;
- putenv(qstrdup(env.ascii()));
+ putenv(qstrdup(env.latin1()));
}
if((qsRealname.isEmpty() == FALSE)){
QString env = "SIRCNAME=" + qsRealname;
- putenv(qstrdup(env.ascii()));
+ putenv(qstrdup(env.latin1()));
}
QString env = "SIRCLIB=" + KGlobal::dirs()->findResourceDir("appdata", \
"ksirc.pl");
Index: ksopts.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ksopts.cpp,v
retrieving revision 1.7
diff -u -3 -d -p -r1.7 ksopts.cpp
--- ksopts.cpp 2002/02/25 18:02:21 1.7
+++ ksopts.cpp 2002/03/09 15:33:51
@@ -2,6 +2,8 @@
#include <unistd.h>
#include <pwd.h>
+#include <qtextcodec.h>
+
#include <kapplication.h>
#include <kconfig.h>
@@ -102,6 +104,12 @@ void KSOptions::load( int sections )
backgroundFile = conf->readEntry( "BackgroundFile", backgroundFile );
logging = conf->readBoolEntry( "Logging", logging );
beepOnMsg = conf->readBoolEntry( "BeepOnMessage", false );
+
+ QString codecName = QTextCodec::codecForLocale()->name();
+ codecName = codecName.lower();
+ if ( codecName == "eucjp" )
+ codecName = QString::fromLatin1( "jis7" ); // Japanese standard network \
codec name is jis7(iso-2022-jp) + useEncoding = conf->readEntry( "Encoding", \
codecName ); }
if ( sections & Startup )
Index: ksopts.h
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ksopts.h,v
retrieving revision 1.5
diff -u -3 -d -p -r1.5 ksopts.h
--- ksopts.h 2001/12/09 23:16:03 1.5
+++ ksopts.h 2002/03/09 15:33:51
@@ -30,6 +30,7 @@ public:
int windowLength;
QString backgroundFile;
bool logging;
+ QString useEncoding;
};
class KSOStartup
Index: servercontroller.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/servercontroller.cpp,v
retrieving revision 1.139
diff -u -3 -d -p -r1.139 servercontroller.cpp
--- servercontroller.cpp 2002/02/28 10:43:33 1.139
+++ servercontroller.cpp 2002/03/09 15:34:05
@@ -84,6 +84,7 @@
#include <kstdaccel.h>
#include <kstandarddirs.h>
#include <khelpmenu.h>
+#include <kcharsets.h>
#include <qfile.h>
@@ -151,6 +152,12 @@ servercontroller::servercontroller( QWid
this, SLOT(font_prefs()));
options->insertItem(i18n("&Filter Rule Editor..."),
this, SLOT(filter_rule_editor()));
+
+ encoding = new QPopupMenu();
+ options->insertItem( i18n( "&Set Encoding" ), encoding );
+ encodingList();
+ connect( encoding, SIGNAL( activated( int ) ), this, SLOT( setEncoding( int ) ) );
+
options->insertSeparator();
options->insertItem(i18n("&Preferences..."),
this, SLOT(general_prefs()));
@@ -236,7 +243,7 @@ void servercontroller::new_ksircprocess(
// do the dirty work here.
ProcMessage(str, ProcCommand::addTopLevel, QString("no_channel"));
- KSircProcess *proc = new KSircProcess(pukeSocket, (char *) str.ascii(), 0, \
(QString(name()) + "_" + str + "_ksp").ascii() ); // Create proc + KSircProcess \
*proc = new KSircProcess(pukeSocket, (char *) str.latin1(), 0, (QString(name()) + "_" \
+ str + "_ksp").latin1() ); // Create proc //this->insertChild(proc); \
// Add it to out inheritance tree so we can retreive child widgets from it. \
objFinder::insert(proc); proc_list.insert(str, proc); // Add \
proc to hash @@ -643,6 +650,28 @@ QListViewItem * servercontroller::findCh
return 0L;
}
+void servercontroller::setEncoding( int pos )
+{
+ QStringList _strList = KGlobal::charsets()->descriptiveEncodingNames();
+ QString _encodingName = KGlobal::charsets()->encodingForName( *_strList.at( pos \
) ); + kdDebug() << "Encoding: " << _encodingName << endl;
+
+ ksopts->useEncoding = _encodingName;
+
+ KConfig *kConfig = kapp->config();
+ kConfig->setGroup( "General" );
+ kConfig->writeEntry( "Encoding", _encodingName );
+ kConfig->sync();
+}
+
+void servercontroller::encodingList()
+{
+ QStringList _strList = KGlobal::charsets()->descriptiveEncodingNames();
+
+ for ( unsigned int i = 0; i < _strList.count(); ++i )
+ encoding->insertItem( *_strList.at( i ), i );
+}
+
scInside::scInside ( QWidget * parent, const char * name, WFlags
f )
: QFrame(parent, name, f)
@@ -686,6 +715,12 @@ dockServerController::dockServerControll
sc, SLOT(font_prefs()));
pop->insertItem(i18n("&Filter Rule Editor..."),
sc, SLOT(filter_rule_editor()));
+
+ encoding = new QPopupMenu();
+ pop->insertItem( i18n( "&Set Encoding" ), encoding );
+ encodingList();
+ connect( encoding, SIGNAL( activated( int ) ), sc, SLOT( setEncoding( int ) ) );
+
pop->insertItem(SmallIcon("configure"), i18n("&Preferences..."),
sc, SLOT(general_prefs()));
pop->insertSeparator();
@@ -700,6 +735,14 @@ dockServerController::dockServerControll
dockServerController::~dockServerController()
{
sc = 0x0;
+}
+
+void dockServerController::encodingList()
+{
+ QStringList _strList = KGlobal::charsets()->descriptiveEncodingNames();
+
+ for ( unsigned int i = 0; i < _strList.count(); ++i )
+ encoding->insertItem( *_strList.at( i ), i );
}
#include "servercontroller.moc"
Index: servercontroller.h
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/servercontroller.h,v
retrieving revision 1.52
diff -u -3 -d -p -r1.52 servercontroller.h
--- servercontroller.h 2001/12/09 14:35:18 1.52
+++ servercontroller.h 2002/03/09 15:34:05
@@ -84,7 +84,10 @@ public:
~dockServerController();
private:
+ void encodingList();
+
servercontroller *sc;
+ QPopupMenu *encoding;
};
class servercontroller : public KMainWindow
@@ -161,6 +164,7 @@ public slots:
protected slots:
void WindowSelected(QListViewItem *);
+ void setEncoding( int pos );
protected:
@@ -175,6 +179,7 @@ protected:
private:
void saveSessionConfig();
+ void encodingList();
// La raison d'etre. We don't run ConnectionTree outr selves, but
// we get it from out helper class scInside.
@@ -188,7 +193,7 @@ private:
// Hold a list of all KSircProcess's for access latter. Index by server
// name
QDict<KSircProcess> proc_list;
- QPopupMenu *options, *connections;
+ QPopupMenu *options, *connections, *encoding;
int join_id, server_id;
int open_toplevels;
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic