diff options
Diffstat (limited to 'kopete/libkopete/kopetecommandhandler.cpp')
-rw-r--r-- | kopete/libkopete/kopetecommandhandler.cpp | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/kopete/libkopete/kopetecommandhandler.cpp b/kopete/libkopete/kopetecommandhandler.cpp index b761ec08..cd4dcd8c 100644 --- a/kopete/libkopete/kopetecommandhandler.cpp +++ b/kopete/libkopete/kopetecommandhandler.cpp @@ -15,14 +15,14 @@ */ #include <kapplication.h> -#include <qregexp.h> +#include <tqregexp.h> #include <kdebug.h> #include <klocale.h> #include <kprocess.h> #include <kdeversion.h> #include <kxmlguiclient.h> #include <kaction.h> -#include <qdom.h> +#include <tqdom.h> #include "kopetechatsessionmanager.h" #include "kopeteprotocol.h" @@ -36,36 +36,36 @@ using Kopete::CommandList; -typedef QMap<QObject*, CommandList> PluginCommandMap; -typedef QMap<QString,QString> CommandMap; +typedef TQMap<TQObject*, CommandList> PluginCommandMap; +typedef TQMap<TQString,TQString> CommandMap; typedef QPair<Kopete::ChatSession*, Kopete::Message::MessageDirection> ManagerPair; -class KopeteCommandGUIClient : public QObject, public KXMLGUIClient +class KopeteCommandGUIClient : public TQObject, public KXMLGUIClient { public: - KopeteCommandGUIClient( Kopete::ChatSession *manager ) : QObject(manager), KXMLGUIClient(manager) + KopeteCommandGUIClient( Kopete::ChatSession *manager ) : TQObject(manager), KXMLGUIClient(manager) { - setXMLFile( QString::fromLatin1("kopetecommandui.rc") ); + setXMLFile( TQString::fromLatin1("kopetecommandui.rc") ); - QDomDocument doc = domDocument(); - QDomNode menu = doc.documentElement().firstChild().firstChild().firstChild(); + TQDomDocument doc = domDocument(); + TQDomNode menu = doc.documentElement().firstChild().firstChild().firstChild(); CommandList mCommands = Kopete::CommandHandler::commandHandler()->commands( manager->protocol() ); - for( QDictIterator<Kopete::Command> it( mCommands ); it.current(); ++it ) + for( TQDictIterator<Kopete::Command> it( mCommands ); it.current(); ++it ) { KAction *a = static_cast<KAction*>( it.current() ); actionCollection()->insert( a ); - QDomElement newNode = doc.createElement( QString::fromLatin1("Action") ); - newNode.setAttribute( QString::fromLatin1("name"), - QString::fromLatin1( a->name() ) ); + TQDomElement newNode = doc.createElement( TQString::fromLatin1("Action") ); + newNode.setAttribute( TQString::fromLatin1("name"), + TQString::fromLatin1( a->name() ) ); bool added = false; - for( QDomElement n = menu.firstChild().toElement(); + for( TQDomElement n = menu.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if( QString::fromLatin1(a->name()) < n.attribute(QString::fromLatin1("name"))) + if( TQString::fromLatin1(a->name()) < n.attribute(TQString::fromLatin1("name"))) { menu.insertBefore( newNode, n ); added = true; @@ -87,14 +87,14 @@ struct CommandHandlerPrivate { PluginCommandMap pluginCommands; Kopete::CommandHandler *s_handler; - QMap<KProcess*,ManagerPair> processMap; + TQMap<KProcess*,ManagerPair> processMap; bool inCommand; - QPtrList<KAction> m_commands; + TQPtrList<KAction> m_commands; }; CommandHandlerPrivate *Kopete::CommandHandler::p = 0L; -Kopete::CommandHandler::CommandHandler() : QObject( qApp ) +Kopete::CommandHandler::CommandHandler() : TQObject( qApp ) { p->s_handler = this; p->inCommand = false; @@ -103,41 +103,41 @@ Kopete::CommandHandler::CommandHandler() : QObject( qApp ) mCommands.setAutoDelete( true ); p->pluginCommands.insert( this, mCommands ); - registerCommand( this, QString::fromLatin1("help"), SLOT( slotHelpCommand( const QString &, Kopete::ChatSession * ) ), + registerCommand( this, TQString::fromLatin1("help"), TQT_SLOT( slotHelpCommand( const TQString &, Kopete::ChatSession * ) ), i18n( "USAGE: /help [<command>] - Used to list available commands, or show help for a specified command." ), 0, 1 ); - registerCommand( this, QString::fromLatin1("close"), SLOT( slotCloseCommand( const QString &, Kopete::ChatSession * ) ), + registerCommand( this, TQString::fromLatin1("close"), TQT_SLOT( slotCloseCommand( const TQString &, Kopete::ChatSession * ) ), i18n( "USAGE: /close - Closes the current view." ) ); // FIXME: What's the difference with /close? The help doesn't explain it - Martijn - registerCommand( this, QString::fromLatin1("part"), SLOT( slotPartCommand( const QString &, Kopete::ChatSession * ) ), + registerCommand( this, TQString::fromLatin1("part"), TQT_SLOT( slotPartCommand( const TQString &, Kopete::ChatSession * ) ), i18n( "USAGE: /part - Closes the current view." ) ); - registerCommand( this, QString::fromLatin1("clear"), SLOT( slotClearCommand( const QString &, Kopete::ChatSession * ) ), + registerCommand( this, TQString::fromLatin1("clear"), TQT_SLOT( slotClearCommand( const TQString &, Kopete::ChatSession * ) ), i18n( "USAGE: /clear - Clears the active view's chat buffer." ) ); - //registerCommand( this, QString::fromLatin1("me"), SLOT( slotMeCommand( const QString &, Kopete::ChatSession * ) ), + //registerCommand( this, TQString::fromLatin1("me"), TQT_SLOT( slotMeCommand( const TQString &, Kopete::ChatSession * ) ), // i18n( "USAGE: /me <text> - Formats message as in '<nickname> went to the store'." ) ); - registerCommand( this, QString::fromLatin1("away"), SLOT( slotAwayCommand( const QString &, Kopete::ChatSession * ) ), + registerCommand( this, TQString::fromLatin1("away"), TQT_SLOT( slotAwayCommand( const TQString &, Kopete::ChatSession * ) ), i18n( "USAGE: /away [<reason>] - Marks you as away/back for the current account only." ) ); - registerCommand( this, QString::fromLatin1("awayall"), SLOT( slotAwayAllCommand( const QString &, Kopete::ChatSession * ) ), + registerCommand( this, TQString::fromLatin1("awayall"), TQT_SLOT( slotAwayAllCommand( const TQString &, Kopete::ChatSession * ) ), i18n( "USAGE: /awayall [<reason>] - Marks you as away/back for all accounts." ) ); - registerCommand( this, QString::fromLatin1("say"), SLOT( slotSayCommand( const QString &, Kopete::ChatSession * ) ), + registerCommand( this, TQString::fromLatin1("say"), TQT_SLOT( slotSayCommand( const TQString &, Kopete::ChatSession * ) ), i18n( "USAGE: /say <text> - Say text in this chat. This is the same as just typing a message, but is very " "useful for scripts." ), 1 ); - registerCommand( this, QString::fromLatin1("exec"), SLOT( slotExecCommand( const QString &, Kopete::ChatSession * ) ), + registerCommand( this, TQString::fromLatin1("exec"), TQT_SLOT( slotExecCommand( const TQString &, Kopete::ChatSession * ) ), i18n( "USAGE: /exec [-o] <command> - Executes the specified command and displays the output in the chat buffer. " "If -o is specified, the output is sent to all members of the chat."), 1 ); - connect( Kopete::PluginManager::self(), SIGNAL( pluginLoaded( Kopete::Plugin*) ), - this, SLOT(slotPluginLoaded(Kopete::Plugin*) ) ); + connect( Kopete::PluginManager::self(), TQT_SIGNAL( pluginLoaded( Kopete::Plugin*) ), + this, TQT_SLOT(slotPluginLoaded(Kopete::Plugin*) ) ); - connect( Kopete::ChatSessionManager::self(), SIGNAL( viewCreated( KopeteView * ) ), - this, SLOT( slotViewCreated( KopeteView* ) ) ); + connect( Kopete::ChatSessionManager::self(), TQT_SIGNAL( viewCreated( KopeteView * ) ), + this, TQT_SLOT( slotViewCreated( KopeteView* ) ) ); } Kopete::CommandHandler::~CommandHandler() @@ -156,45 +156,45 @@ Kopete::CommandHandler *Kopete::CommandHandler::commandHandler() return p->s_handler; } -void Kopete::CommandHandler::registerCommand( QObject *parent, const QString &command, const char* handlerSlot, - const QString &help, uint minArgs, int maxArgs, const KShortcut &cut, const QString &pix ) +void Kopete::CommandHandler::registerCommand( TQObject *parent, const TQString &command, const char* handlerSlot, + const TQString &help, uint minArgs, int maxArgs, const KShortcut &cut, const TQString &pix ) { - QString lowerCommand = command.lower(); + TQString lowerCommand = command.lower(); Kopete::Command *mCommand = new Kopete::Command( parent, lowerCommand, handlerSlot, help, - Normal, QString::null, minArgs, maxArgs, cut, pix); + Normal, TQString::null, minArgs, maxArgs, cut, pix); p->pluginCommands[ parent ].insert( lowerCommand, mCommand ); } -void Kopete::CommandHandler::unregisterCommand( QObject *parent, const QString &command ) +void Kopete::CommandHandler::unregisterCommand( TQObject *parent, const TQString &command ) { if( p->pluginCommands[ parent ].find(command) ) p->pluginCommands[ parent ].remove( command ); } -void Kopete::CommandHandler::registerAlias( QObject *parent, const QString &alias, const QString &formatString, - const QString &help, CommandType type, uint minArgs, int maxArgs, const KShortcut &cut, const QString &pix ) +void Kopete::CommandHandler::registerAlias( TQObject *parent, const TQString &alias, const TQString &formatString, + const TQString &help, CommandType type, uint minArgs, int maxArgs, const KShortcut &cut, const TQString &pix ) { - QString lowerAlias = alias.lower(); + TQString lowerAlias = alias.lower(); Kopete::Command *mCommand = new Kopete::Command( parent, lowerAlias, 0L, help, type, formatString, minArgs, maxArgs, cut, pix ); p->pluginCommands[ parent ].insert( lowerAlias, mCommand ); } -void Kopete::CommandHandler::unregisterAlias( QObject *parent, const QString &alias ) +void Kopete::CommandHandler::unregisterAlias( TQObject *parent, const TQString &alias ) { if( p->pluginCommands[ parent ].find(alias) ) p->pluginCommands[ parent ].remove( alias ); } -bool Kopete::CommandHandler::processMessage( const QString &msg, Kopete::ChatSession *manager ) +bool Kopete::CommandHandler::processMessage( const TQString &msg, Kopete::ChatSession *manager ) { if( p->inCommand ) return false; - QRegExp splitRx( QString::fromLatin1("^/([\\S]+)(.*)") ); - QString command; - QString args; + TQRegExp splitRx( TQString::fromLatin1("^/([\\S]+)(.*)") ); + TQString command; + TQString args; if(splitRx.search(msg) != -1) { command = splitRx.cap(1); @@ -222,21 +222,21 @@ bool Kopete::CommandHandler::processMessage( const QString &msg, Kopete::ChatSes bool Kopete::CommandHandler::processMessage( Kopete::Message &msg, Kopete::ChatSession *manager ) { - QString messageBody = msg.plainBody(); + TQString messageBody = msg.plainBody(); return processMessage( messageBody, manager ); } -void Kopete::CommandHandler::slotHelpCommand( const QString &args, Kopete::ChatSession *manager ) +void Kopete::CommandHandler::slotHelpCommand( const TQString &args, Kopete::ChatSession *manager ) { - QString output; + TQString output; if( args.isEmpty() ) { int commandCount = 0; output = i18n( "Available Commands:\n" ); CommandList mCommands = commands( manager->myself()->protocol() ); - QDictIterator<Kopete::Command> it( mCommands ); + TQDictIterator<Kopete::Command> it( mCommands ); for( ; it.current(); ++it ) { output.append( it.current()->command().upper() + '\t' ); @@ -250,7 +250,7 @@ void Kopete::CommandHandler::slotHelpCommand( const QString &args, Kopete::ChatS } else { - QString command = parseArguments( args ).front().lower(); + TQString command = parseArguments( args ).front().lower(); Kopete::Command *c = commands( manager->myself()->protocol() )[ command ]; if( c && !c->help().isNull() ) output = c->help(); @@ -262,7 +262,7 @@ void Kopete::CommandHandler::slotHelpCommand( const QString &args, Kopete::ChatS manager->appendMessage(msg); } -void Kopete::CommandHandler::slotSayCommand( const QString &args, Kopete::ChatSession *manager ) +void Kopete::CommandHandler::slotSayCommand( const TQString &args, Kopete::ChatSession *manager ) { //Just say whatever is passed Kopete::Message msg(manager->myself(), manager->members(), args, @@ -270,23 +270,23 @@ void Kopete::CommandHandler::slotSayCommand( const QString &args, Kopete::ChatSe manager->sendMessage(msg); } -void Kopete::CommandHandler::slotExecCommand( const QString &args, Kopete::ChatSession *manager ) +void Kopete::CommandHandler::slotExecCommand( const TQString &args, Kopete::ChatSession *manager ) { if( !args.isEmpty() ) { KProcess *proc = 0L; - if ( kapp->authorize( QString::fromLatin1( "shell_access" ) ) ) + if ( kapp->authorize( TQString::fromLatin1( "shell_access" ) ) ) proc = new KProcess(manager); if( proc ) { - *proc << QString::fromLatin1("sh") << QString::fromLatin1("-c"); + *proc << TQString::fromLatin1("sh") << TQString::fromLatin1("-c"); - QStringList argsList = parseArguments( args ); - if( argsList.front() == QString::fromLatin1("-o") ) + TQStringList argsList = parseArguments( args ); + if( argsList.front() == TQString::fromLatin1("-o") ) { p->processMap.insert( proc, ManagerPair(manager, Kopete::Message::Outbound) ); - *proc << args.section(QRegExp(QString::fromLatin1("\\s+")), 1); + *proc << args.section(TQRegExp(TQString::fromLatin1("\\s+")), 1); } else { @@ -294,8 +294,8 @@ void Kopete::CommandHandler::slotExecCommand( const QString &args, Kopete::ChatS *proc << args; } - connect(proc, SIGNAL(receivedStdout(KProcess *, char *, int)), this, SLOT(slotExecReturnedData(KProcess *, char *, int))); - connect(proc, SIGNAL(receivedStderr(KProcess *, char *, int)), this, SLOT(slotExecReturnedData(KProcess *, char *, int))); + connect(proc, TQT_SIGNAL(receivedStdout(KProcess *, char *, int)), this, TQT_SLOT(slotExecReturnedData(KProcess *, char *, int))); + connect(proc, TQT_SIGNAL(receivedStderr(KProcess *, char *, int)), this, TQT_SLOT(slotExecReturnedData(KProcess *, char *, int))); proc->start( KProcess::NotifyOnExit, KProcess::AllOutput ); } else @@ -308,19 +308,19 @@ void Kopete::CommandHandler::slotExecCommand( const QString &args, Kopete::ChatS } } -void Kopete::CommandHandler::slotClearCommand( const QString &, Kopete::ChatSession *manager ) +void Kopete::CommandHandler::slotClearCommand( const TQString &, Kopete::ChatSession *manager ) { if( manager->view() ) manager->view()->clear(); } -void Kopete::CommandHandler::slotPartCommand( const QString &, Kopete::ChatSession *manager ) +void Kopete::CommandHandler::slotPartCommand( const TQString &, Kopete::ChatSession *manager ) { if( manager->view() ) manager->view()->closeView(); } -void Kopete::CommandHandler::slotAwayCommand( const QString &args, Kopete::ChatSession *manager ) +void Kopete::CommandHandler::slotAwayCommand( const TQString &args, Kopete::ChatSession *manager ) { bool goAway = !manager->account()->isAway(); @@ -330,7 +330,7 @@ void Kopete::CommandHandler::slotAwayCommand( const QString &args, Kopete::ChatS manager->account()->setAway( goAway, args ); } -void Kopete::CommandHandler::slotAwayAllCommand( const QString &args, Kopete::ChatSession *manager ) +void Kopete::CommandHandler::slotAwayAllCommand( const TQString &args, Kopete::ChatSession *manager ) { if( manager->account()->isAway() ) Kopete::AccountManager::self()->setAvailableAll(); @@ -344,7 +344,7 @@ void Kopete::CommandHandler::slotAwayAllCommand( const QString &args, Kopete::Ch } } -void Kopete::CommandHandler::slotCloseCommand( const QString &, Kopete::ChatSession *manager ) +void Kopete::CommandHandler::slotCloseCommand( const TQString &, Kopete::ChatSession *manager ) { if( manager->view() ) manager->view()->closeView(); @@ -353,7 +353,7 @@ void Kopete::CommandHandler::slotCloseCommand( const QString &, Kopete::ChatSess void Kopete::CommandHandler::slotExecReturnedData(KProcess *proc, char *buff, int bufflen ) { kdDebug(14010) << k_funcinfo << endl; - QString buffer = QString::fromLocal8Bit( buff, bufflen ); + TQString buffer = TQString::fromLocal8Bit( buff, bufflen ); ManagerPair mgrPair = p->processMap[ proc ]; Kopete::Message msg( mgrPair.first->myself(), mgrPair.first->members(), buffer, mgrPair.second, Kopete::Message::PlainText ); if( mgrPair.second == Kopete::Message::Outbound ) @@ -368,10 +368,10 @@ void Kopete::CommandHandler::slotExecFinished(KProcess *proc) p->processMap.remove( proc ); } -QStringList Kopete::CommandHandler::parseArguments( const QString &args ) +TQStringList Kopete::CommandHandler::parseArguments( const TQString &args ) { - QStringList arguments; - QRegExp quotedArgs( QString::fromLatin1("\"(.*)\"") ); + TQStringList arguments; + TQRegExp quotedArgs( TQString::fromLatin1("\"(.*)\"") ); quotedArgs.setMinimal( true ); if ( quotedArgs.search( args ) != -1 ) @@ -380,14 +380,14 @@ QStringList Kopete::CommandHandler::parseArguments( const QString &args ) arguments.append( quotedArgs.cap(i) ); } - QStringList otherArgs = QStringList::split( QRegExp(QString::fromLatin1("\\s+")), args.section( quotedArgs, 0 ) ); - for( QStringList::Iterator it = otherArgs.begin(); it != otherArgs.end(); ++it ) + TQStringList otherArgs = TQStringList::split( TQRegExp(TQString::fromLatin1("\\s+")), args.section( quotedArgs, 0 ) ); + for( TQStringList::Iterator it = otherArgs.begin(); it != otherArgs.end(); ++it ) arguments.append( *it ); return arguments; } -bool Kopete::CommandHandler::commandHandled( const QString &command ) +bool Kopete::CommandHandler::commandHandled( const TQString &command ) { for( PluginCommandMap::Iterator it = p->pluginCommands.begin(); it != p->pluginCommands.end(); ++it ) { @@ -398,7 +398,7 @@ bool Kopete::CommandHandler::commandHandled( const QString &command ) return false; } -bool Kopete::CommandHandler::commandHandledByProtocol( const QString &command, Kopete::Protocol *protocol ) +bool Kopete::CommandHandler::commandHandledByProtocol( const TQString &command, Kopete::Protocol *protocol ) { // Make sure the protocol is not NULL if(!protocol) @@ -406,7 +406,7 @@ bool Kopete::CommandHandler::commandHandledByProtocol( const QString &command, K // Fetch the commands for the protocol CommandList commandList = commands( protocol ); - QDictIterator<Kopete::Command> it ( commandList ); + TQDictIterator<Kopete::Command> it ( commandList ); // Loop through commands and check if they match the supplied command for( ; it.current(); ++it ) @@ -453,7 +453,7 @@ CommandList Kopete::CommandHandler::commands( Kopete::Protocol *protocol ) void Kopete::CommandHandler::addCommands( CommandList &from, CommandList &to, CommandType type ) { - QDictIterator<Kopete::Command> itDict( from ); + TQDictIterator<Kopete::Command> itDict( from ); for( ; itDict.current(); ++itDict ) { if( !to[ itDict.currentKey() ] && @@ -469,17 +469,17 @@ void Kopete::CommandHandler::slotViewCreated( KopeteView *view ) void Kopete::CommandHandler::slotPluginLoaded( Kopete::Plugin *plugin ) { - connect( plugin, SIGNAL( destroyed( QObject * ) ), this, SLOT( slotPluginDestroyed( QObject * ) ) ); + connect( plugin, TQT_SIGNAL( destroyed( TQObject * ) ), this, TQT_SLOT( slotPluginDestroyed( TQObject * ) ) ); if( !p->pluginCommands.contains( plugin ) ) { - //Create a QDict optomized for a larger # of commands, and case insensitive + //Create a TQDict optomized for a larger # of commands, and case insensitive CommandList mCommands(31, false); mCommands.setAutoDelete( true ); p->pluginCommands.insert( plugin, mCommands ); } } -void Kopete::CommandHandler::slotPluginDestroyed( QObject *plugin ) +void Kopete::CommandHandler::slotPluginDestroyed( TQObject *plugin ) { p->pluginCommands.remove( static_cast<Kopete::Plugin*>(plugin) ); } |