• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/libkopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • libkopete
kopetecommandhandler.cpp
Go to the documentation of this file.
1 /*
2  kopetecommandhandler.cpp - Command Handler
3 
4  Copyright (c) 2003 by Jason Keirstead <jason@keirstead.org>
5  Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
6 
7  *************************************************************************
8  * *
9  * This library is free software; you can redistribute it and/or *
10  * modify it under the terms of the GNU Lesser General Public *
11  * License as published by the Free Software Foundation; either *
12  * version 2 of the License, or (at your option) any later version. *
13  * *
14  *************************************************************************
15 */
16 
17 #include <qregexp.h>
18 #include <QList>
19 #include <QApplication>
20 #include <kdebug.h>
21 #include <klocale.h>
22 #include <kdeversion.h>
23 #include <kxmlguiclient.h>
24 #include <kaction.h>
25 #include <qdom.h>
26 #include <kauthorized.h>
27 #include <kactioncollection.h>
28 #include <ktoolinvocation.h>
29 #include <kprocess.h>
30 
31 #include "kopetechatsessionmanager.h"
32 #include "kopeteprotocol.h"
33 #include "kopetepluginmanager.h"
34 #include "kopeteview.h"
35 #include "kopeteaccountmanager.h"
36 #include "kopeteaccount.h"
37 #include "kopetecommandhandler.h"
38 #include "kopetecontact.h"
39 #include "kopetecommand.h"
40 #include "kopeteonlinestatusmanager.h"
41 
42 using Kopete::CommandList;
43 
44 typedef QMap<QObject*, CommandList> PluginCommandMap;
45 typedef QMap<QString,QString> CommandMap;
46 typedef QPair<Kopete::ChatSession*, Kopete::Message::MessageDirection> ManagerPair;
47 
48 class KopeteCommandGUIClient : public QObject, public KXMLGUIClient
49 {
50  public:
51  KopeteCommandGUIClient( Kopete::ChatSession *manager ) : QObject(manager), KXMLGUIClient(manager)
52  {
53  setXMLFile( QString::fromLatin1("kopetecommandui.rc") );
54 
55  QDomDocument doc = domDocument();
56  QDomNode menu = doc.documentElement().firstChild().firstChild().firstChild();
57  CommandList mCommands = Kopete::CommandHandler::commandHandler()->commands(
58  manager->protocol()
59  );
60 
61  CommandList::Iterator it, itEnd = mCommands.end();
62  for( it = mCommands.begin(); it != itEnd; ++it )
63  {
64  KAction *a = static_cast<KAction*>( it.value() );
65  actionCollection()->addAction( a->objectName(), a );
66  QDomElement newNode = doc.createElement( QString::fromLatin1("Action") );
67  newNode.setAttribute( QString::fromLatin1("name"), a->objectName() );
68 
69  bool added = false;
70  for( QDomElement n = menu.firstChild().toElement();
71  !n.isNull(); n = n.nextSibling().toElement() )
72  {
73  if( a->objectName() < n.attribute(QString::fromLatin1("name")))
74  {
75  menu.insertBefore( newNode, n );
76  added = true;
77  break;
78  }
79  }
80 
81  if( !added )
82  {
83  menu.appendChild( newNode );
84  }
85  }
86 
87  setDOMDocument( doc );
88  }
89 };
90 
91 struct CommandHandlerPrivate
92 {
93  PluginCommandMap pluginCommands;
94  Kopete::CommandHandler *s_handler;
95  QMap<KProcess*,ManagerPair> processMap;
96  bool inCommand;
97  QList<KAction *> m_commands;
98 };
99 
100 CommandHandlerPrivate *Kopete::CommandHandler::p = 0L;
101 
102 Kopete::CommandHandler::CommandHandler() : QObject( qApp )
103 {
104  p->s_handler = this;
105  p->inCommand = false;
106 
107  CommandList mCommands;
108  mCommands.reserve(31);
109  p->pluginCommands.insert( this, mCommands );
110 
111  registerCommand( this, QString::fromLatin1("help"), SLOT(slotHelpCommand(QString,Kopete::ChatSession*)),
112  i18n( "USAGE: /help [<command>] - Used to list available commands, or show help for a specified command." ), 0, 1 );
113 
114  registerCommand( this, QString::fromLatin1("url"), SLOT(slotOpenLastUrl(QString,Kopete::ChatSession*)),
115  i18n( "USAGE: /url - Opens last URL for current chat in default browser." ) );
116 
117  registerCommand( this, QString::fromLatin1("close"), SLOT(slotCloseCommand(QString,Kopete::ChatSession*)),
118  i18n( "USAGE: /close - Closes the current view." ) );
119 
120  // FIXME: What's the difference with /close? The help doesn't explain it - Martijn
121  registerCommand( this, QString::fromLatin1("part"), SLOT(slotPartCommand(QString,Kopete::ChatSession*)),
122  i18n( "USAGE: /part - Closes the current view." ) );
123 
124  registerCommand( this, QString::fromLatin1("clear"), SLOT(slotClearCommand(QString,Kopete::ChatSession*)),
125  i18n( "USAGE: /clear - Clears the active view's chat buffer." ) );
126 
127  //registerCommand( this, QString::fromLatin1("me"), SLOT(slotMeCommand(QString,Kopete::ChatSession*)),
128  // i18n( "USAGE: /me <text> - Formats message as in '<nickname> went to the store'." ) );
129 
130  registerCommand( this, QString::fromLatin1("away"), SLOT(slotAwayCommand(QString,Kopete::ChatSession*)),
131  i18n( "USAGE: /away [<reason>] - Marks you as away/back for the current account only." ) );
132 
133  registerCommand( this, QString::fromLatin1("awayall"), SLOT(slotAwayAllCommand(QString,Kopete::ChatSession*)),
134  i18n( "USAGE: /awayall [<reason>] - Marks you as away/back for all accounts." ) );
135 
136  registerCommand( this, QString::fromLatin1("say"), SLOT(slotSayCommand(QString,Kopete::ChatSession*)),
137  i18n( "USAGE: /say <text> - Say text in this chat. This is the same as just typing a message, but is very "
138  "useful for scripts." ), 1 );
139 
140  registerCommand( this, QString::fromLatin1("exec"), SLOT(slotExecCommand(QString,Kopete::ChatSession*)),
141  i18n( "USAGE: /exec [-o] <command> - Executes the specified command and displays the output in the chat buffer. "
142  "If -o is specified, the output is sent to all members of the chat."), 1 );
143 
144  connect( Kopete::PluginManager::self(), SIGNAL(pluginLoaded(Kopete::Plugin*)),
145  this, SLOT(slotPluginLoaded(Kopete::Plugin*)) );
146 
147  connect( Kopete::ChatSessionManager::self(), SIGNAL(viewCreated(KopeteView*)),
148  this, SLOT(slotViewCreated(KopeteView*)) );
149 }
150 
151 Kopete::CommandHandler::~CommandHandler()
152 {
153  CommandList commandList = p->pluginCommands[this];
154  while (!commandList.isEmpty())
155  {
156  Kopete::Command *value = *commandList.begin();
157  commandList.erase(commandList.begin());
158  delete value;
159  }
160 
161  delete p;
162 }
163 
164 Kopete::CommandHandler *Kopete::CommandHandler::commandHandler()
165 {
166  if( !p )
167  {
168  p = new CommandHandlerPrivate;
169  p->s_handler = new Kopete::CommandHandler();
170  }
171 
172  return p->s_handler;
173 }
174 
175 void Kopete::CommandHandler::registerCommand( QObject *parent, const QString &command, const char* handlerSlot,
176  const QString &help, uint minArgs, int maxArgs, const KShortcut &cut, const QString &pix )
177 {
178  const QString lowerCommand = command.toLower();
179 
180  Kopete::Command *mCommand = new Kopete::Command( parent, lowerCommand, handlerSlot, help,
181  Normal, QString::null, minArgs, maxArgs, cut, pix); //krazy:exclude=nullstrassign for old broken gcc
182  p->pluginCommands[ parent ].insert( lowerCommand, mCommand );
183 }
184 
185 void Kopete::CommandHandler::unregisterCommand( QObject *parent, const QString &command )
186 {
187  if( p->pluginCommands[ parent ].contains(command) )
188  p->pluginCommands[ parent ].remove( command );
189 }
190 
191 void Kopete::CommandHandler::registerAlias( QObject *parent, const QString &alias, const QString &formatString,
192  const QString &help, CommandType type, uint minArgs, int maxArgs, const KShortcut &cut, const QString &pix )
193 {
194  const QString lowerAlias = alias.toLower();
195 
196  Kopete::Command *mCommand = new Kopete::Command( parent, lowerAlias, 0L, help, type,
197  formatString, minArgs, maxArgs, cut, pix );
198  p->pluginCommands[ parent ].insert( lowerAlias, mCommand );
199 }
200 
201 void Kopete::CommandHandler::unregisterAlias( QObject *parent, const QString &alias )
202 {
203  if( p->pluginCommands[ parent ].contains(alias) )
204  p->pluginCommands[ parent ].remove( alias );
205 }
206 
207 bool Kopete::CommandHandler::processMessage( const QString &msg, Kopete::ChatSession *manager )
208 {
209  if( p->inCommand )
210  return false;
211  QRegExp splitRx( QString::fromLatin1("^/([\\S]+)(.*)") );
212  QString command;
213  QString args;
214  if(splitRx.indexIn(msg) != -1)
215  {
216  command = splitRx.cap(1);
217  args = splitRx.cap(2).mid(1);
218  }
219  else
220  return false;
221 
222  CommandList mCommands = commands( manager->protocol() );
223  Kopete::Command *c = mCommands.value(command);
224  if(c)
225  {
226  kDebug(14010) << "Handled Command";
227  if( c->type() != SystemAlias && c->type() != UserAlias )
228  p->inCommand = true;
229 
230  c->processCommand( args, manager );
231  p->inCommand = false;
232 
233  return true;
234  }
235 
236  return false;
237 }
238 
239 bool Kopete::CommandHandler::processMessage( Kopete::Message &msg, Kopete::ChatSession *manager )
240 {
241  const QString messageBody = msg.plainBody();
242 
243  return processMessage( messageBody, manager );
244 }
245 
246 void Kopete::CommandHandler::slotHelpCommand( const QString &args, Kopete::ChatSession *manager )
247 {
248  QString output;
249  if( args.isEmpty() )
250  {
251  int commandCount = 0;
252  output = i18n( "Available Commands:\n" );
253 
254  CommandList mCommands = commands( manager->myself()->protocol() );
255  CommandList::Iterator it, itEnd = mCommands.end();
256  for( it = mCommands.begin(); it != itEnd; ++it )
257  {
258  output.append( it.value()->command().toUpper() + '\t' );
259  if( commandCount++ == 5 )
260  {
261  commandCount = 0;
262  output.append( '\n' );
263  }
264  }
265  output.append( i18n( "\nType /help <command> for more information." ) );
266  }
267  else
268  {
269  const QString command = parseArguments( args ).front().toLower();
270  Kopete::Command *c = commands( manager->myself()->protocol() ).value( command );
271  if( c && !c->help().isNull() )
272  output = c->help();
273  else
274  output = i18n("There is no help available for '%1'.", command );
275  }
276 
277  Kopete::Message msg(manager->myself(), manager->members());
278  msg.setDirection( Kopete::Message::Internal );
279  msg.setPlainBody( output );
280 
281  manager->appendMessage(msg);
282 }
283 
284 void Kopete::CommandHandler::slotSayCommand( const QString &args, Kopete::ChatSession *manager )
285 {
286  //Just say whatever is passed
287  Kopete::Message msg(manager->myself(), manager->members());
288  msg.setPlainBody( args );
289  msg.setDirection( Kopete::Message::Outbound );
290 
291  manager->sendMessage(msg);
292 }
293 
294 void Kopete::CommandHandler::slotExecCommand( const QString &args, Kopete::ChatSession *manager )
295 {
296  if( !args.isEmpty() )
297  {
298  KProcess *proc = 0L;
299  if ( KAuthorized::authorizeKAction( "shell_access" ) )
300  proc = new KProcess(manager);
301  if( proc )
302  {
303  *proc << QString::fromLatin1("sh") << QString::fromLatin1("-c");
304 
305  QStringList argsList = parseArguments( args );
306  if( argsList.front() == QString::fromLatin1("-o") )
307  {
308  p->processMap.insert( proc, ManagerPair(manager, Kopete::Message::Outbound) );
309  *proc << args.section(QRegExp(QString::fromLatin1("\\s+")), 1);
310  }
311  else
312  {
313  p->processMap.insert( proc, ManagerPair(manager, Kopete::Message::Internal) );
314  *proc << args;
315  }
316 
317  connect(proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(slotExecError(QProcess::ProcessError)));
318  connect(proc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotExecFinished()));
319 
320  proc->setOutputChannelMode(KProcess::MergedChannels);
321  proc->setNextOpenMode(QIODevice::ReadOnly);
322  proc->clearEnvironment();
323  proc->start();
324  proc->closeWriteChannel();
325  }
326  else
327  {
328  Kopete::Message msg(manager->myself(), manager->members() );
329  msg.setDirection( Kopete::Message::Internal );
330  msg.setPlainBody( i18n( "ERROR: Shell access has been restricted on your system. The /exec command will not function." ) );
331  manager->sendMessage( msg );
332  }
333  }
334 }
335 
336 void Kopete::CommandHandler::slotClearCommand( const QString &, Kopete::ChatSession *manager )
337 {
338  if( manager->view() )
339  manager->view()->clear();
340 }
341 
342 void Kopete::CommandHandler::slotPartCommand( const QString &, Kopete::ChatSession *manager )
343 {
344  if( manager->view() )
345  manager->view()->closeView();
346 }
347 
348 void Kopete::CommandHandler::slotAwayCommand( const QString &args, Kopete::ChatSession *manager )
349 {
350  const bool goAway = !manager->account()->isAway();
351 
352  if( args.isEmpty() )
353  manager->account()->setOnlineStatus( OnlineStatusManager::self()->onlineStatus(manager->account()->protocol() , goAway ? OnlineStatusManager::Away : OnlineStatusManager::Online) );
354  else
355  manager->account()->setOnlineStatus( OnlineStatusManager::self()->onlineStatus(manager->account()->protocol() , goAway ? OnlineStatusManager::Away : OnlineStatusManager::Online) , args);
356 }
357 
358 void Kopete::CommandHandler::slotAwayAllCommand( const QString &args, Kopete::ChatSession *manager )
359 {
360  if( manager->account()->isAway() ) {
361  Kopete::AccountManager::self()->setOnlineStatus( Kopete::OnlineStatusManager::Online );
362  }
363  else {
364  Kopete::AccountManager::self()->setOnlineStatus( Kopete::OnlineStatusManager::Away, args );
365  }
366 }
367 
368 void Kopete::CommandHandler::slotOpenLastUrl( const QString &, Kopete::ChatSession *manager )
369 {
370  QString tempstr = manager->lastUrl();
371  if ( !tempstr.isEmpty() ) {
372  //now there is no difference whether it is a brwserUrl or a mailtoUrl
373  KToolInvocation::invokeBrowser( tempstr );
374  }
375 }
376 
377 void Kopete::CommandHandler::slotCloseCommand( const QString &, Kopete::ChatSession *manager )
378 {
379  if( manager->view() )
380  manager->view()->closeView();
381 }
382 
383 void Kopete::CommandHandler::slotExecError( QProcess::ProcessError error )
384 {
385  kDebug(14010);
386  KProcess *proc = static_cast<KProcess *>(sender());
387  if (error == QProcess::FailedToStart) {
388  ManagerPair &mgrPair = p->processMap[ proc ];
389  Kopete::Message msg( mgrPair.first->myself(), mgrPair.first->members() );
390  msg.setDirection( Kopete::Message::Internal );
391  msg.setPlainBody( i18n( "ERROR: Failed to start process from /exec command." ) );
392  mgrPair.first->sendMessage( msg );
393  } else {
394  const QString &buffer = QString::fromUtf8(proc->readAll());
395  if (!buffer.isEmpty())
396  slotExecSendMessage(proc, buffer);
397  }
398  disconnect(proc, 0, 0, 0);
399  p->processMap.remove(proc);
400  proc->deleteLater();
401 }
402 
403 void Kopete::CommandHandler::slotExecFinished()
404 {
405  kDebug(14010);
406  KProcess *proc = static_cast<KProcess *>(sender());
407  const QString &buffer = QString::fromUtf8(proc->readAll());
408  if (!buffer.isEmpty())
409  slotExecSendMessage(proc, buffer);
410  disconnect(proc, 0, 0, 0);
411  p->processMap.remove(proc);
412  proc->deleteLater();
413 }
414 
415 void Kopete::CommandHandler::slotExecSendMessage( KProcess *proc, const QString &buffer )
416 {
417  kDebug(14010);
418  ManagerPair &mgrPair = p->processMap[ proc ];
419  Kopete::Message msg( mgrPair.first->myself(), mgrPair.first->members());
420  msg.setDirection( mgrPair.second );
421  msg.setPlainBody( buffer );
422 
423  if( mgrPair.second == Kopete::Message::Outbound )
424  mgrPair.first->sendMessage( msg );
425  else
426  mgrPair.first->appendMessage( msg );
427 }
428 
429 QStringList Kopete::CommandHandler::parseArguments( const QString &args )
430 {
431  QStringList arguments;
432  QRegExp quotedArgs( QString::fromLatin1("\"(.*)\"") );
433  quotedArgs.setMinimal( true );
434 
435  if ( quotedArgs.indexIn( args ) != -1 )
436  {
437  for( int i = 0; i< quotedArgs.numCaptures(); i++ )
438  arguments.append( quotedArgs.cap(i) );
439  }
440 
441  const QStringList otherArgs = args.section( quotedArgs, 0 ).split( QRegExp(QString::fromLatin1("\\s+")), QString::SkipEmptyParts);
442  for( QStringList::ConstIterator it = otherArgs.constBegin(); it != otherArgs.constEnd(); ++it )
443  arguments.append( *it );
444 
445  return arguments;
446 }
447 
448 bool Kopete::CommandHandler::commandHandled( const QString &command )
449 {
450  for( PluginCommandMap::Iterator it = p->pluginCommands.begin(); it != p->pluginCommands.end(); ++it )
451  {
452  if( it.value().value( command ) )
453  return true;
454  }
455 
456  return false;
457 }
458 
459 bool Kopete::CommandHandler::commandHandledByProtocol( const QString &command, Kopete::Protocol *protocol )
460 {
461  // Make sure the protocol is not NULL
462  if(!protocol)
463  return false;
464 
465  // Fetch the commands for the protocol
466  CommandList commandList = commands( protocol );
467  CommandList::Iterator it, itEnd = commandList.end();
468 
469  // Loop through commands and check if they match the supplied command
470  for( it = commandList.begin(); it != itEnd; ++it )
471  {
472  if( it.value()->command().toLower() == command )
473  return true;
474  }
475 
476  // No commands found
477  return false;
478 }
479 
480 CommandList Kopete::CommandHandler::commands( Kopete::Protocol *protocol )
481 {
482  CommandList commandList;
483  commandList.reserve(63);
484 
485  //Add plugin user aliases first
486  addCommands( p->pluginCommands[protocol], commandList, UserAlias );
487 
488  //Add plugin system aliases next
489  addCommands( p->pluginCommands[protocol], commandList, SystemAlias );
490 
491  //Add the commands for this protocol next
492  addCommands( p->pluginCommands[protocol], commandList );
493 
494  //Add plugin commands
495  for( PluginCommandMap::Iterator it = p->pluginCommands.begin(); it != p->pluginCommands.end(); ++it )
496  {
497  if( !it.key()->inherits("Kopete::Protocol") && it.key()->inherits("Kopete::Plugin") )
498  addCommands( it.value(), commandList );
499  }
500 
501  //Add global user aliases first
502  addCommands( p->pluginCommands[this], commandList, UserAlias );
503 
504  //Add global system aliases next
505  addCommands( p->pluginCommands[this], commandList, SystemAlias );
506 
507  //Add the internal commands *last*
508  addCommands( p->pluginCommands[this], commandList );
509 
510  return commandList;
511 }
512 
513 void Kopete::CommandHandler::addCommands( CommandList &from, CommandList &to, CommandType type )
514 {
515  CommandList::Iterator itDict, itDictEnd = from.end();
516  for( itDict = from.begin(); itDict != itDictEnd; ++itDict )
517  {
518  if( !to.value( itDict.key() ) &&
519  ( type == Undefined || itDict.value()->type() == type ) )
520  to.insert( itDict.key(), itDict.value() );
521  }
522 }
523 
524 void Kopete::CommandHandler::slotViewCreated( KopeteView *view )
525 {
526  new KopeteCommandGUIClient( view->msgManager() );
527 }
528 
529 void Kopete::CommandHandler::slotPluginLoaded( Kopete::Plugin *plugin )
530 {
531  connect( plugin, SIGNAL(destroyed(QObject*)), this, SLOT(slotPluginDestroyed(QObject*)) );
532  if( !p->pluginCommands.contains( plugin ) )
533  {
534  //Create a QDict optomized for a larger # of commands, and case insensitive
535  CommandList mCommands;
536  mCommands.reserve(31);
537  p->pluginCommands.insert( plugin, mCommands );
538  }
539 }
540 
541 void Kopete::CommandHandler::slotPluginDestroyed( QObject *plugin )
542 {
543  p->pluginCommands.remove( static_cast<Kopete::Plugin*>(plugin) );
544 }
545 
546 #include "kopetecommandhandler.moc"
547 
548 // vim: set noet ts=4 sts=4 sw=4:
549 
Kopete::CommandHandler::processMessage
bool processMessage(Message &msg, ChatSession *manager)
Process a message to see if any commands should be handled.
Definition: kopetecommandhandler.cpp:239
Kopete::CommandHandler::CommandType
CommandType
an enum defining the type of a command
Definition: kopetecommandhandler.h:58
Kopete::Account::protocol
Protocol * protocol() const
Definition: kopeteaccount.cpp:216
KopeteView::clear
virtual void clear()
Clear the buffer.
Definition: kopeteview.cpp:31
QRegExp::cap
QString cap(int nth) const
kopetechatsessionmanager.h
QString::append
QString & append(QChar ch)
KopeteView::closeView
virtual bool closeView(bool force=false)=0
Close this view.
Kopete::CommandHandler::commandHandledByProtocol
bool commandHandledByProtocol(const QString &command, Protocol *protocol)
Check if a command is already handled by a spesific protocol.
Definition: kopetecommandhandler.cpp:459
KopeteView::msgManager
Kopete::ChatSession * msgManager() const
Get the message manager.
Definition: kopeteview.cpp:26
Kopete::Command
Definition: kopetecommand.h:32
QDomNode::appendChild
QDomNode appendChild(const QDomNode &newChild)
kopeteaccount.h
QRegExp::setMinimal
void setMinimal(bool minimal)
QString::split
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
Kopete::Protocol
base class of every protocol.
Definition: kopeteprotocol.h:62
QMap< QObject *, CommandList >
QHash::reserve
void reserve(int size)
kopetecommandhandler.h
Kopete::CommandHandler::registerCommand
void registerCommand(QObject *parent, const QString &command, const char *handlerSlot, const QString &help=QString(), uint minArgs=0, int maxArgs=-1, const KShortcut &cut=KShortcut(), const QString &pix=QString())
Register a command with the command handler.
Definition: kopetecommandhandler.cpp:175
CommandMap
QMap< QString, QString > CommandMap
Definition: kopetecommandhandler.cpp:45
QDomDocument::documentElement
QDomElement documentElement() const
QDomNode
QRegExp::numCaptures
int numCaptures() const
Kopete::ChatSession
Definition: kopetechatsession.h:74
Kopete::Message::Outbound
Message sent by the user.
Definition: kopetemessage.h:91
Kopete::AccountManager::self
static AccountManager * self()
Retrieve the instance of AccountManager.
Definition: kopeteaccountmanager.cpp:77
Kopete::CommandHandler::parseArguments
static QStringList parseArguments(const QString &args)
Parses a string of command arguments into a QStringList.
Definition: kopetecommandhandler.cpp:429
Kopete::Message::Internal
(Default) Message which are not sent via the network. This is just a notification a plugin can show i...
Definition: kopetemessage.h:92
QString::isNull
bool isNull() const
Kopete::ChatSession::appendMessage
void appendMessage(Kopete::Message &msg)
Show a message to the chatwindow, or append it to the queue.
Definition: kopetechatsession.cpp:310
ManagerPair
QPair< Kopete::ChatSession *, Kopete::Message::MessageDirection > ManagerPair
Definition: kopetecommandhandler.cpp:46
QDomNode::toElement
QDomElement toElement() const
QRegExp::indexIn
int indexIn(const QString &str, int offset, CaretMode caretMode) const
QRegExp
Kopete::Message::setDirection
void setDirection(MessageDirection direction)
Set the message direction.
Definition: kopetemessage.cpp:585
Kopete::Contact::protocol
Protocol * protocol() const
Get the protocol that the contact belongs to.
Definition: kopetecontact.cpp:533
QList::append
void append(const T &value)
Kopete::CommandHandler::registerAlias
void registerAlias(QObject *parent, const QString &alias, const QString &formatString, const QString &help=QString(), CommandType=SystemAlias, uint minArgs=0, int maxArgs=-1, const KShortcut &cut=KShortcut(), const QString &pix=QString())
Register a command alias.
Definition: kopetecommandhandler.cpp:191
QString::fromUtf8
QString fromUtf8(const char *str, int size)
QString::insert
QString & insert(int position, QChar ch)
QObject
QDomElement::setAttribute
void setAttribute(const QString &name, const QString &value)
Kopete::Account::setOnlineStatus
virtual void setOnlineStatus(const Kopete::OnlineStatus &status, const Kopete::StatusMessage &reason=Kopete::StatusMessage(), const OnlineStatusOptions &options=None)=0
Reimplement this function to set the online status.
kopeteprotocol.h
QString::isEmpty
bool isEmpty() const
QHash::begin
iterator begin()
Kopete::ChatSession::sendMessage
void sendMessage(Kopete::Message &message)
Send a message to the user.
Definition: kopetechatsession.cpp:281
QList::front
T & front()
Kopete::Message::setPlainBody
void setPlainBody(const QString &body)
Sets the body of the message.
Definition: kopetemessage.cpp:234
Kopete::Account::isAway
bool isAway
Definition: kopeteaccount.h:82
QString
QList< KAction * >
Kopete::CommandHandler::unregisterAlias
void unregisterAlias(QObject *parent, const QString &alias)
Unregister an alias.
Definition: kopetecommandhandler.cpp:201
QStringList
PluginCommandMap
QMap< QObject *, CommandList > PluginCommandMap
Definition: kopetecommandhandler.cpp:44
QPair
Kopete::Plugin
Base class for all plugins or protocols.
Definition: kopeteplugin.h:84
QString::toLower
QString toLower() const
QHash::value
const T value(const Key &key) const
QDomDocument
Kopete::Command::help
const QString & help() const
Returns the help string for this command.
Definition: kopetecommand.h:86
Kopete::CommandList
QMultiHash< QString, Command * > CommandList
Definition: kopetecommandhandler.h:39
QDomNode::isNull
bool isNull() const
Kopete::PluginManager::self
static PluginManager * self()
Retrieve the plugin loader instance.
Definition: kopetepluginmanager.cpp:104
Kopete::ChatSessionManager::self
static ChatSessionManager * self()
Definition: kopetechatsessionmanager.cpp:39
QObject::QObject
QObject(QObject *parent)
QDomNode::firstChild
QDomNode firstChild() const
QString::mid
QString mid(int position, int n) const
Kopete::ChatSession::account
Account * account() const
get the account
Definition: kopetechatsession.cpp:668
Kopete::OnlineStatusManager::Online
Definition: kopeteonlinestatusmanager.h:67
Kopete::ChatSession::myself
const Contact * myself() const
Get the local user in the session.
Definition: kopetechatsession.cpp:215
Kopete::OnlineStatusManager::Away
Definition: kopeteonlinestatusmanager.h:65
Kopete::ChatSession::members
const ContactPtrList & members() const
Get a list of all contacts in the session.
Definition: kopetechatsession.cpp:210
kopeteaccountmanager.h
KAction
Kopete::CommandHandler::commandHandled
bool commandHandled(const QString &command)
Check if a command is already handled.
Definition: kopetecommandhandler.cpp:448
Kopete::AccountManager::setOnlineStatus
void setOnlineStatus(uint category, const Kopete::StatusMessage &statusMessage, uint flags, bool forced)
Set all accounts a status in the specified category.
Definition: kopeteaccountmanager.cpp:119
QList::ConstIterator
typedef ConstIterator
QString::section
QString section(QChar sep, int start, int end, QFlags< QString::SectionFlag > flags) const
Kopete::CommandHandler
Definition: kopetecommandhandler.h:48
Kopete::ChatSession::lastUrl
const QString lastUrl()
returns lastUrl for current ChatSession can be empty
Definition: kopetechatsession.cpp:154
QString::fromLatin1
QString fromLatin1(const char *str, int size)
kopeteview.h
Kopete::OnlineStatusManager::self
static OnlineStatusManager * self()
Definition: kopeteonlinestatusmanager.cpp:49
QMap< QObject *, CommandList >::Iterator
typedef Iterator
Kopete::ChatSession::protocol
Protocol * protocol() const
Get the protocol being used.
Definition: kopetechatsession.cpp:220
QHash::end
iterator end()
QList::constEnd
const_iterator constEnd() const
QDomDocument::createElement
QDomElement createElement(const QString &tagName)
QList::constBegin
const_iterator constBegin() const
Kopete::Message::plainBody
QString plainBody() const
Get the message body back as plain text.
Definition: kopetemessage.cpp:366
Kopete::ChatSession::view
KopeteView * view(bool canCreate=false, const QString &requestedPlugin=QString())
the manager's view
Definition: kopetechatsession.cpp:641
KopeteView
Definition: kopeteview.h:40
QDomElement
QHash::Iterator
typedef Iterator
QDomNode::insertBefore
QDomNode insertBefore(const QDomNode &newChild, const QDomNode &refChild)
Kopete::CommandHandler::commandHandler
static CommandHandler * commandHandler()
Returns a pointer to the command handler.
Definition: kopetecommandhandler.cpp:164
Kopete::Message
Representation of a message in Kopete.
Definition: kopetemessage.h:82
kopetepluginmanager.h
kopetecontact.h
kopeteonlinestatusmanager.h
QMultiHash
Kopete::CommandHandler::unregisterCommand
void unregisterCommand(QObject *parent, const QString &command)
Unregister a command.
Definition: kopetecommandhandler.cpp:185
kopetecommand.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal