[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: [PATCH] i18n KSirc
From: Simon Hausmann <hausmann () kde ! org>
Date: 2002-03-09 16:04:58
[Download RAW message or body]
On Sun, Mar 10, 2002 at 12:40:22AM +0900, Toshitaka Fujioka wrote:
> 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.
Interesting, Lars asked me for the same feature in Nuernberg, being
able to select the encoding even per channel.
I actually implemented it but the patch got a bit too big for my
taste and I was planning on applying it after 3.0 -- I attached that
patch.
Now your patch is even bigger -- btw, the QPopupMenu is leaked and
encodingList() should be const :) -- and touches a lot more of
ksirc's touchy code. The string handling has always been a bit
whacky in the past.
In my opinion it is too late to apply such changes to ksirc. It's
definitely a good feature to include after 3.0 I think. (but that's
just MHO, CC'ing the maintainer and malte)
Simon
P.S.: BTW, in Nuernberg we tried setting the locale to Hebrew (il)
and we were able to send and receive hebrew -- not that I could
understand the glyphs, but they looked non-ascii and Lars
confirmed it :) . The channel and nickname were ASCII though.
["ksirc_encoding_patch.txt" (text/plain)]
Index: baserules.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/baserules.cpp,v
retrieving revision 1.13
diff -u -p -b -r1.13 baserules.cpp
--- baserules.cpp 2001/09/01 14:45:52 1.13
+++ baserules.cpp 2002/02/27 11:45:54
@@ -4,7 +4,7 @@
#include <stdio.h>
-void KSMBaseRules::sirc_receive(QString, bool)
+void KSMBaseRules::sirc_receive(QCString, bool)
{
}
Index: baserules.h
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/baserules.h,v
retrieving revision 1.6
diff -u -p -b -r1.6 baserules.h
--- baserules.h 2001/09/01 14:45:52 1.6
+++ baserules.h 2002/02/27 11:45:54
@@ -15,7 +15,7 @@ public:
{
}
- virtual void sirc_receive(QString str, bool broadcast);
+ virtual void sirc_receive(QCString str, bool broadcast);
virtual void control_message(int, QString);
Index: chanparser.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/chanparser.cpp,v
retrieving revision 1.52
diff -u -p -b -r1.52 chanparser.cpp
--- chanparser.cpp 2001/12/02 18:59:47 1.52
+++ chanparser.cpp 2002/02/27 11:45:54
@@ -336,7 +336,7 @@ parseResult * ChannelParser::parseSSFEPr
// cerr << "Entered: " << sp->text() << endl;
prompt = sp->text();
prompt += "\n";
- emit top->outputLine(prompt);
+ emit top->outputLine(prompt.local8Bit());
delete sp;
prompt_active = FALSE;
}
@@ -348,7 +348,7 @@ parseResult * ChannelParser::parseSSFERe
{
if(top->channel_name[0] == '#'){
- QString str = "/join " + QString(top->channel_name) + "\n";
+ QCString str = "/join " + QCString(top->channel_name) + "\n";
emit top->outputLine(str);
}
@@ -530,7 +530,7 @@ parseResult * ChannelParser::parseINFOPa
return new parseWrongChannel(string, ksopts->errorColor, top->pix_madsmile);
if (ksopts->autoRejoin == TRUE)
{
- QString str = "/join " + QString(top->channel_name) + "\n";
+ QCString str = "/join " + QCString(top->channel_name) + "\n";
emit top->outputLine(str);
/* if(top->ticker)
top->ticker->show();
@@ -545,7 +545,7 @@ parseResult * ChannelParser::parseINFOPa
int result = KMessageBox::questionYesNo(top, string, i18n("You Have Been \
Kicked"), i18n("Rejoin"), i18n("Leave")); if (result == KMessageBox::Yes)
{
- QString str = "/join " + QString(top->channel_name) + "\n";
+ QCString str = "/join " + QCString(top->channel_name) + "\n";
emit top->outputLine(str);
/* if(top->ticker)
top->ticker->show();
Index: ioBroadcast.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ioBroadcast.cpp,v
retrieving revision 1.21
diff -u -p -b -r1.21 ioBroadcast.cpp
--- ioBroadcast.cpp 2001/12/13 20:13:01 1.21
+++ ioBroadcast.cpp 2002/02/27 11:45:54
@@ -27,7 +27,7 @@ KSircIOBroadcast::~KSircIOBroadcast()
{
}
-void KSircIOBroadcast::sirc_receive(QString str, bool)
+void KSircIOBroadcast::sirc_receive(QCString str, bool)
{
QDictIterator<KSircMessageReceiver> it(proc->getWindowList());
Index: ioBroadcast.h
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ioBroadcast.h,v
retrieving revision 1.10
diff -u -p -b -r1.10 ioBroadcast.h
--- ioBroadcast.h 2001/09/01 14:45:52 1.10
+++ ioBroadcast.h 2002/02/27 11:45:54
@@ -13,7 +13,7 @@ public:
}
virtual ~KSircIOBroadcast();
- virtual void sirc_receive(QString str, bool broadcast);
+ virtual void sirc_receive(QCString str, bool broadcast);
virtual void control_message(int, QString);
virtual filterRuleList *defaultRules();
Index: ioDCC.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ioDCC.cpp,v
retrieving revision 1.23
diff -u -p -b -r1.23 ioDCC.cpp
--- ioDCC.cpp 2001/12/02 16:47:51 1.23
+++ ioDCC.cpp 2002/02/27 11:45:54
@@ -20,7 +20,7 @@ KSircIODCC::~KSircIODCC()
delete pending;
}
-void KSircIODCC::sirc_receive(QString str, bool )
+void KSircIODCC::sirc_receive(QCString str, bool )
{
// Parse the string to find out what type it is.
// Note the order here.
@@ -236,7 +236,7 @@ void KSircIODCC::control_message(int, QS
void KSircIODCC::cancelTransfer(QString filename)
{
if(DlgList[filename]){
- emit outputLine(DCCStatus[filename]->cancelMessage);
+ emit outputLine(DCCStatus[filename]->cancelMessage.local8Bit());
delete DlgList[filename];
DlgList.remove(filename);
delete DCCStatus[filename];
@@ -254,7 +254,7 @@ void KSircIODCC::getFile()
if(DlgList[filename]->isVisible() == FALSE)
DlgList[filename]->show();
QString command = "/dcc get " + nick + " " + filename + "\n";
- emit outputLine(command);
+ emit outputLine(command.latin1());
for(uint i = 0; i < pending->fileListing()->count(); i++)
if(QString(pending->fileListing()->text(i)) == (nick + " offered " + filename))
pending->fileListing()->removeItem(i);
@@ -271,7 +271,7 @@ void KSircIODCC::forgetFile()
pos = text.find(" ", pos+1) + 1;
QString filename = text.mid(pos, text.length() - pos);
QString command = "/dcc close get " + nick + " " + filename + "\n";
- emit outputLine(command);
+ emit outputLine(command.latin1());
for(uint i = 0; i < pending->fileListing()->count(); i++)
if(QString(pending->fileListing()->text(i)) == (nick + " offered " + filename))
pending->fileListing()->removeItem(i);
Index: ioDCC.h
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ioDCC.h,v
retrieving revision 1.12
diff -u -p -b -r1.12 ioDCC.h
--- ioDCC.h 2001/09/01 14:45:52 1.12
+++ ioDCC.h 2002/02/27 11:45:54
@@ -35,7 +35,7 @@ public:
}
virtual ~KSircIODCC();
- virtual void sirc_receive(QString, bool broadcast);
+ virtual void sirc_receive(QCString, bool broadcast);
virtual void control_message(int, QString);
virtual filterRuleList *defaultRules();
@@ -45,7 +45,7 @@ protected slots:
void forgetFile();
signals:
- void outputLine(QString);
+ void outputLine(QCString);
private:
// QDict<QProgressDialog> DlgList;
Index: ioDiscard.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ioDiscard.cpp,v
retrieving revision 1.7
diff -u -p -b -r1.7 ioDiscard.cpp
--- ioDiscard.cpp 2001/09/01 14:45:52 1.7
+++ ioDiscard.cpp 2002/02/27 11:45:54
@@ -14,7 +14,7 @@ KSircIODiscard::~KSircIODiscard()
{
}
-void KSircIODiscard::sirc_receive(QString, bool)
+void KSircIODiscard::sirc_receive(QCString, bool)
{
}
Index: ioDiscard.h
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ioDiscard.h,v
retrieving revision 1.6
diff -u -p -b -r1.6 ioDiscard.h
--- ioDiscard.h 2001/09/01 14:45:52 1.6
+++ ioDiscard.h 2002/02/27 11:45:54
@@ -11,7 +11,7 @@ public:
}
virtual ~KSircIODiscard();
- virtual void sirc_receive(QString, bool broadcast);
+ virtual void sirc_receive(QCString, bool broadcast);
virtual void control_message(int, QString);
private:
Index: ioLAG.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ioLAG.cpp,v
retrieving revision 1.10
diff -u -p -b -r1.10 ioLAG.cpp
--- ioLAG.cpp 2001/09/01 14:45:52 1.10
+++ ioLAG.cpp 2002/02/27 11:45:54
@@ -29,7 +29,7 @@ KSircIOLAG::~KSircIOLAG()
killTimers();
}
-void KSircIOLAG::sirc_receive(QString str, bool)
+void KSircIOLAG::sirc_receive(QCString str, bool)
{
if(str.contains("*L*")){
@@ -54,7 +54,7 @@ void KSircIOLAG::control_message(int, QS
void KSircIOLAG::timerEvent ( QTimerEvent * )
{
- QString cmd = "/lag\n";
+ QCString cmd = "/lag\n";
emit outputLine(cmd);
}
Index: ioLAG.h
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ioLAG.h,v
retrieving revision 1.6
diff -u -p -b -r1.6 ioLAG.h
--- ioLAG.h 2001/09/01 14:45:52 1.6
+++ ioLAG.h 2002/02/27 11:45:54
@@ -13,7 +13,7 @@ public:
KSircIOLAG(KSircProcess *_proc);
virtual ~KSircIOLAG();
- virtual void sirc_receive(QString, bool broadcast);
+ virtual void sirc_receive(QCString, bool broadcast);
virtual void control_message(int, QString);
protected slots:
@@ -22,7 +22,7 @@ protected:
virtual void timerEvent ( QTimerEvent * );
signals:
- void outputLine(QString);
+ void outputLine(QCString);
private:
KSircProcess *proc;
Index: ioNotify.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ioNotify.cpp,v
retrieving revision 1.11
diff -u -p -b -r1.11 ioNotify.cpp
--- ioNotify.cpp 2001/09/01 14:45:52 1.11
+++ ioNotify.cpp 2002/02/27 11:45:54
@@ -24,7 +24,7 @@ KSircIONotify::~KSircIONotify()
{
}
-void KSircIONotify::sirc_receive(QString str, bool)
+void KSircIONotify::sirc_receive(QCString str, bool)
{
if(str.contains("*)*")){
int s1, s2;
Index: ioNotify.h
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ioNotify.h,v
retrieving revision 1.5
diff -u -p -b -r1.5 ioNotify.h
--- ioNotify.h 2001/09/01 14:45:52 1.5
+++ ioNotify.h 2002/02/27 11:45:54
@@ -13,7 +13,7 @@ public:
KSircIONotify(KSircProcess *_proc);
virtual ~KSircIONotify();
- virtual void sirc_receive(QString, bool broadcast);
+ virtual void sirc_receive(QCString, bool broadcast);
virtual void control_message(int, QString);
virtual filterRuleList *defaultRules();
Index: iocontroller.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/iocontroller.cpp,v
retrieving revision 1.42
diff -u -p -b -r1.42 iocontroller.cpp
--- iocontroller.cpp 2002/02/19 21:12:46 1.42
+++ iocontroller.cpp 2002/02/27 11:45:54
@@ -149,14 +149,18 @@ void KSircIOController::stdout_read(KPro
*/
int pos,pos2,pos3;
- QString name, line;
+ QCString name, line;
- QString buffer(QString::fromLocal8Bit(_buffer, buflen));
- // kdDebug() << "<-- read: " << buffer;
+ //QString buffer(QString::fromLocal8Bit(_buffer, buflen));
+ QCString buffer(_buffer, buflen);
+ kdDebug() << "<-- read: " << buffer;
name = "!default";
if(holder.length() > 0){
+holder.append( "\n" );
buffer.prepend(holder);
holder.truncate(0);
}
@@ -165,7 +169,9 @@ void KSircIOController::stdout_read(KPro
pos = buffer.findRev('\n', pos2);
if(pos != -1){
holder = buffer.mid(pos+1, pos2-pos-1);
- buffer.truncate(pos);
+ buffer.truncate(pos);
}
}
@@ -180,6 +186,7 @@ void KSircIOController::stdout_read(KPro
rec->control_message(STOP_UPDATES, "");
do{
pos2 = buffer.find('\n', pos);
@@ -229,7 +236,7 @@ void KSircIOController::stderr_read(KPro
stdout_read(p, b, l);
}
-void KSircIOController::stdin_write(QString s)
+void KSircIOController::stdin_write(QCString s)
{
if (!proc->isRunning())
{
@@ -245,7 +252,8 @@ void KSircIOController::stdin_write(QStr
delete[] send_buf;
}
send_buf = new char[len];
- strncpy(send_buf, buffer.local8Bit(), len);
+ //strncpy(send_buf, buffer.local8Bit(), len);
+ strncpy(send_buf, buffer.data(), len);
if(proc->writeStdin(send_buf, len) == FALSE){
kdDebug() << "Failed to write but CTS HIGH! Setting low!: " << s << endl;
}
@@ -267,7 +275,7 @@ void KSircIOController::sircDied(KProces
kdDebug() << "IOController: KProcess died!\n";
ksircproc->TopList["!all"]->sirc_receive("*E* DSIRC IS DEAD");
ksircproc->TopList["!all"]->sirc_receive("*E* KSIRC WINDOW HALTED");
- ksircproc->TopList["!all"]->sirc_receive("*E* Tried to run: " + \
KGlobal::dirs()->findExe("dsirc") + "\n"); + \
ksircproc->TopList["!all"]->sirc_receive("*E* Tried to run: " + \
KGlobal::dirs()->findExe("dsirc").local8Bit() + "\n"); \
ksircproc->TopList["!all"]->sirc_receive("*E* DID YOU READ THE INSTALL \
INTRUCTIONS?"); }
@@ -277,8 +285,7 @@ void KSircIOController::procCTS ( KProce
delete[] send_buf;
send_buf = 0x0;
if(!buffer.isEmpty()){
- QString str = "";
- stdin_write(str);
+ stdin_write(QCString());
}
}
#include "iocontroller.moc"
Index: iocontroller.h
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/iocontroller.h,v
retrieving revision 1.8
diff -u -p -b -r1.8 iocontroller.h
--- iocontroller.h 2001/09/01 14:45:52 1.8
+++ iocontroller.h 2002/02/27 11:45:54
@@ -20,7 +20,7 @@ public slots:
virtual void stdout_read(KProcess *proc, char *_buffer, int buflen);
virtual void stderr_read(KProcess *proc, char *_buffer, int buflen);
- virtual void stdin_write(QString);
+ virtual void stdin_write(QCString);
virtual void sircDied(KProcess *);
@@ -29,13 +29,13 @@ protected slots:
virtual void procCTS(KProcess *);
private:
- QString holder;
+ QCString holder;
bool proc_CTS;
KProcess *proc;
KSircProcess *ksircproc;
char *send_buf;
- QString buffer;
+ QCString buffer;
static int counter;
};
Index: ksircprocess.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/ksircprocess.cpp,v
retrieving revision 1.95
diff -u -p -b -r1.95 ksircprocess.cpp
--- ksircprocess.cpp 2002/02/20 19:49:47 1.95
+++ ksircprocess.cpp 2002/02/27 11:45:54
@@ -198,14 +198,14 @@ KSircProcess::KSircProcess( const QStrin
KSircIODCC *dcc = new KSircIODCC(this);
TopList.insert("!dcc", dcc);
dcc = static_cast<KSircIODCC *>( TopList["!dcc"] ); // g++ bug
- connect(dcc, SIGNAL(outputLine(QString)),
- iocontrol, SLOT(stdin_write(QString)));
+ connect(dcc, SIGNAL(outputLine(QCString)),
+ iocontrol, SLOT(stdin_write(QCString)));
KSircIOLAG *lag = new KSircIOLAG(this);
TopList.insert("!lag", lag);
lag = static_cast<KSircIOLAG*>( TopList["!lag"] ); // g++ bug!
- connect(lag, SIGNAL(outputLine(QString)),
- iocontrol, SLOT(stdin_write(QString)));
+ connect(lag, SIGNAL(outputLine(QCString)),
+ iocontrol, SLOT(stdin_write(QCString)));
KSircIONotify *notify = new KSircIONotify(this);
TopList.insert("!notify", notify);
@@ -222,10 +222,10 @@ KSircProcess::KSircProcess( const QStrin
proc->start(KProcess::NotifyOnExit, KProcess::All);
// Intial commands to load ASAP.
// turn on sirc ssfe mode
- QString command = "/eval $ssfe=1\n";
+ QCString command = "/eval $ssfe=1\n";
iocontrol->stdin_write(command);
- command = "/eval $version .= \"+4KSIRC/" + QString(KSIRC_VERSION) + "\"\n";
+ command = "/eval $version .= \"+4KSIRC/" + QCString(KSIRC_VERSION) + "\"\n";
iocontrol->stdin_write(command);
command = "/load " + locate("appdata", "filters.pl") + "\n";
iocontrol->stdin_write(command);
@@ -355,8 +355,8 @@ void KSircProcess::new_toplevel(QString
// Connect needed signals. For a message window we never want it
// becomming the default so we ignore focusIn events into it.
- connect(wm, SIGNAL(outputLine(QString)),
- iocontrol, SLOT(stdin_write(QString)));
+ connect(wm, SIGNAL(outputLine(QCString)),
+ iocontrol, SLOT(stdin_write(QCString)));
connect(wm, SIGNAL(open_toplevel(QString)),
this,SLOT(new_toplevel(QString)));
connect(wm, SIGNAL(closing(KSircTopLevel *, QString)),
@@ -408,7 +408,7 @@ void KSircProcess::close_toplevel(KSircT
if (!it.current())
{
// No top-level windows left.
- QString command = "/quit\n"; // "/signoff" ?
+ QCString command = "/quit\n"; // "/signoff" ?
iocontrol->stdin_write(command); // kill sirc
delete guardedwm;
delete this; // Delete ourself, WARNING MUST RETURN SINCE WE NO
@@ -485,7 +485,7 @@ void KSircProcess::recvChangeChannel(con
void KSircProcess::filters_update()
{
- QString command, next_part, key, data;
+ QCString command, next_part, key, data;
command = "/crule\n";
iocontrol->stdin_write(command);
QDictIterator<KSircMessageReceiver> it(TopList);
@@ -523,16 +523,16 @@ void KSircProcess::filters_update()
for(int number = 1; number <= max; number++){
command.truncate(0);
key.sprintf("name-%d", number);
- next_part.sprintf("/ksircappendrule DESC==%s !!! ", \
kConfig->readEntry(key).ascii()); + next_part.sprintf("/ksircappendrule DESC==%s \
!!! ", kConfig->readEntry(QString::fromLatin1(key)).ascii()); command += next_part;
key.sprintf("search-%d", number);
- next_part.sprintf("SEARCH==%s !!! ", kConfig->readEntry(key).ascii());
+ next_part.sprintf("SEARCH==%s !!! ", \
kConfig->readEntry(QString::fromLatin1(key)).ascii()); command += next_part;
key.sprintf("from-%d", number);
- next_part.sprintf("FROM==%s !!! ", kConfig->readEntry(key).ascii());
+ next_part.sprintf("FROM==%s !!! ", \
kConfig->readEntry(QString::fromLatin1(key)).ascii()); command += next_part;
key.sprintf("to-%d", number);
- next_part.sprintf("TO==\"%s\"\n", kConfig->readEntry(key).ascii());
+ next_part.sprintf("TO==\"%s\"\n", \
kConfig->readEntry(QString::fromLatin1(key)).ascii()); command += next_part;
iocontrol->stdin_write(command);
}
Index: messageReceiver.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/messageReceiver.cpp,v
retrieving revision 1.15
diff -u -p -b -r1.15 messageReceiver.cpp
--- messageReceiver.cpp 2001/09/01 14:45:52 1.15
+++ messageReceiver.cpp 2002/02/27 11:45:54
@@ -1,5 +1,9 @@
#include "messageReceiver.h"
+#include <qtextcodec.h>
+
+#include <assert.h>
+
KSircMessageReceiver::KSircMessageReceiver( KSircProcess * _proc )
{
proc = _proc;
@@ -24,3 +28,45 @@ filterRuleList *KSircMessageReceiver::de
{
return new filterRuleList();
}
+
+UnicodeMessageReceiver::UnicodeMessageReceiver( KSircProcess *process )
+ : KSircMessageReceiver( process ), m_encoder( 0 )
+{
+}
+
+void UnicodeMessageReceiver::sirc_receive( QCString str, bool broadcast )
+{
+ assert( encoder() );
+ sirc_receive( encoder()->toUnicode( str ), broadcast );
+ // qDebug( "sirc_receiver: '%s'", str.data() );
+ // sirc_receive( QString::fromLocal8Bit( str ), broadcast );
+}
+
+void UnicodeMessageReceiver::setEncoding( const QString &encoding )
+{
+ m_encoding = encoding;
+ m_encoder = 0;
+}
+
+QString UnicodeMessageReceiver::encoding() const
+{
+ if ( m_encoding.isEmpty() )
+ return QTextCodec::codecForLocale()->mimeName();
+ return m_encoding;
+}
+
+QTextCodec *UnicodeMessageReceiver::encoder() const
+{
+ if ( m_encoding.isEmpty() )
+ return QTextCodec::codecForLocale();
+
+ if ( !m_encoder )
+ {
+ const_cast<UnicodeMessageReceiver *>( this )->m_encoder = QTextCodec::codecForName( \
m_encoding ); +qDebug( "codeforname( %s ) -> %p", m_encoding.ascii(), (void \
*)m_encoder ); + assert( m_encoder );
+ }
+
+ return m_encoder;
+}
+
Index: messageReceiver.h
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/messageReceiver.h,v
retrieving revision 1.14
diff -u -p -b -r1.14 messageReceiver.h
--- messageReceiver.h 2001/09/30 14:10:26 1.14
+++ messageReceiver.h 2002/02/27 11:45:54
@@ -6,6 +6,7 @@
#include <qptrlist.h>
class KSircProcess;
+class QTextCodec;
struct filterRule {
const char *desc;
@@ -22,7 +23,7 @@ public:
KSircMessageReceiver(KSircProcess *_proc);
virtual ~KSircMessageReceiver();
- virtual void sirc_receive(QString str, bool broadcast = false) = 0;
+ virtual void sirc_receive(QCString str, bool broadcast = false) = 0;
virtual void control_message(int, QString) = 0;
@@ -37,6 +38,26 @@ private:
KSircProcess *proc;
bool broadcast;
+};
+
+class UnicodeMessageReceiver : public KSircMessageReceiver
+{
+public:
+ UnicodeMessageReceiver( KSircProcess *process );
+
+ virtual void sirc_receive(QCString str, bool broadcast = false);
+
+ virtual void sirc_receive(QString str, bool broadcast = false) = 0;
+
+protected:
+ void setEncoding( const QString &encoding );
+ QString encoding() const;
+
+ QTextCodec *encoder() const;
+
+private:
+ QString m_encoding;
+ QTextCodec *m_encoder;
};
#endif
Index: toplevel.cpp
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/toplevel.cpp,v
retrieving revision 1.203
diff -u -p -b -r1.203 toplevel.cpp
--- toplevel.cpp 2002/01/02 00:24:23 1.203
+++ toplevel.cpp 2002/02/27 11:45:54
@@ -50,6 +50,7 @@
#include <qclipboard.h>
#include <qregexp.h>
#include <qcursor.h>
+#include <qtextcodec.h>
#include <kapplication.h>
#include <kdebug.h>
@@ -62,6 +63,8 @@
#include <ktempfile.h>
#include <kio/netaccess.h>
#include <kstatusbar.h>
+#include <kcharsets.h>
+#include <kaction.h>
extern DisplayMgr *displayMgr;
@@ -84,7 +87,7 @@ KSircTopLevel::initColors()
KSircTopLevel::KSircTopLevel(KSircProcess *_proc, const QString &cname, const char * \
name) : KMainWindow(0, name, 0/*no WDestructiveClose !*/),
- KSircMessageReceiver(_proc),
+ UnicodeMessageReceiver(_proc),
channel_name(cname)
{
// prevent us from being quitted when closing a channel-window. Only
@@ -138,6 +141,15 @@ KSircTopLevel::KSircTopLevel(KSircProces
beepitem = file->insertItem(i18n("Bee&p on Change"), this, SLOT(toggleBeep()), \
CTRL + Key_P); file->setItemChecked(beepitem, ksopts->beepOnMsg);
+ encodingAction = new KSelectAction( i18n( "Select &Encoding" ), 0, this );
+ encodingAction->setText( i18n( "Set &Encoding" ) );
+ connect( encodingAction, SIGNAL( activated() ), this, SLOT( setEncoding() ) );
+ QStringList encodings = KGlobal::charsets()->descriptiveEncodingNames();
+ encodings.prepend( QString::fromLatin1( "Default" ) );
+ encodingAction->setItems( encodings );
+ encodingAction->plug( file );
+ encodingAction->setCurrentItem( 0 );
+
file->insertSeparator();
file->insertItem(i18n("&Close"), this, SLOT(terminate()), CTRL + Key_W );
@@ -375,7 +387,7 @@ KSircTopLevel::~KSircTopLevel()
if ( isPublicChat() ) {
kdDebug() << "*** parting channel: " << channel_name << endl;
- QString str = QString("/part ") + channel_name + "\n";
+ QCString str = QCString("/part ") + channel_name.ascii() + "\n";
emit outputLine(str);
}
@@ -397,6 +409,15 @@ void KSircTopLevel::setMode(QString mode
linee->setFocus();
}
+void KSircTopLevel::setEncoding()
+{
+ int index = encodingAction->currentItem();
+ if ( index == 0 ) // default (locale) encoding
+ UnicodeMessageReceiver::setEncoding( QString::null );
+ else
+ UnicodeMessageReceiver::setEncoding( KGlobal::charsets()->encodingForName( \
encodingAction->currentText() ) ); +}
+
void KSircTopLevel::insertText()
{
linee->setText(linee->text() + selector->currentText());
@@ -600,7 +621,7 @@ void KSircTopLevel::sirc_write(const QSt
return;
}
else {
- emit outputLine(plain + "\n");
+ emit outputLine(plain.ascii() + QCString("\n"));
emit open_toplevel(name);
}
// Finish sending /join
@@ -642,7 +663,7 @@ void KSircTopLevel::sirc_write(const QSt
// Write out line
scrollToBottom();
- emit outputLine(command);
+ emit outputLine(encoder()->fromUnicode( command ) );
}
bool KSircTopLevel::parse_input(const QString &string)
@@ -826,12 +847,12 @@ void KSircTopLevel::gotFocus()
if(have_focus == 0){
if(channel_name[0] == '#'){
QString str = QString("/join %1\n").arg(channel_name);
- emit outputLine(str);
+ emit outputLine(str.ascii());
emit outputLine("/eval $query=''\n");
}
else if (channel_name[0] != '!')
{
- emit outputLine(QString("/eval $query='%1'\n").arg(channel_name));
+ emit outputLine(QString("/eval $query='%1'\n").arg(channel_name).ascii());
}
have_focus = 1;
emit currentWindow(this);
Index: toplevel.h
===================================================================
RCS file: /home/kde/kdenetwork/ksirc/toplevel.h,v
retrieving revision 1.82
diff -u -p -b -r1.82 toplevel.h
--- toplevel.h 2002/02/19 21:04:03 1.82
+++ toplevel.h 2002/02/27 11:45:54
@@ -16,6 +16,7 @@ class UserControlMenu;
class ChannelParser;
class charSelector;
class LogFile;
+class KSelectAction;
class QPopupMenu;
@@ -46,7 +47,7 @@ class kstInside : QHBox
//class KSTicker;
class KSircTopLevel : public KMainWindow,
- public KSircMessageReceiver
+ public UnicodeMessageReceiver
{
Q_OBJECT;
friend class ChannelParser;
@@ -93,7 +94,7 @@ signals:
* output a new line. The line is correctly
* linefeed terminated, etc.
*/
- void outputLine(QString);
+ void outputLine(QCString);
/**
* open a new toplevel widget with for the
* channel/user QString.
@@ -321,11 +322,11 @@ private slots:
void setTopicIntern( const QString &topic );
void insertText();
void setMode(QString, int, QString currentNick=0);
+ void setEncoding();
private:
void scrollToBottom();
-
bool continued_line;
charSelector *selector;
chanButtons *channelButtons;
@@ -483,6 +484,8 @@ private:
KSircTopic *ksTopic;
LogFile *logFile;
+
+ KSelectAction *encodingAction;
};
#endif
>> 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