本文整理汇总了C++中kopete::Message类的典型用法代码示例。如果您正苦于以下问题:C++ Message类的具体用法?C++ Message怎么用?C++ Message使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send
void SMSClient::send(const Kopete::Message& msg)
{
kdWarning( 14160 ) << k_funcinfo << "m_account = " << m_account << " (should be non-zero!!)" << endl;
if (!m_account) return;
m_msg = msg;
KConfigGroup* c = m_account->configGroup();
QString provider = c->readEntry(QString("%1:%2").arg("SMSClient").arg("ProviderName"), QString::null);
if (provider.isNull())
{
KMessageBox::error(Kopete::UI::Global::mainWidget(), i18n("No provider configured"), i18n("Could Not Send Message"));
return;
}
QString programName = c->readEntry(QString("%1:%2").arg("SMSClient").arg("ProgramName"). QString::null);
if (programName.isNull())
programName = "/usr/bin/sms_client";
KProcess* p = new KProcess;
QString message = msg.plainBody();
QString nr = msg.to().first()->contactId();
*p << programName;
*p << provider + ":" + nr;
*p << message;
QObject::connect(p, SIGNAL(processExited(KProcess *)), this, SLOT(slotSendFinished(KProcess*)));
QObject::connect(p, SIGNAL(receivedStdout(KProcess*, char*, int)), this, SLOT(slotReceivedOutput(KProcess*, char*, int)));
QObject::connect(p, SIGNAL(receivedStderr(KProcess*, char*, int)), this, SLOT(slotReceivedOutput(KProcess*, char*, int)));
p->start(KProcess::Block, KProcess::AllOutput);
}
示例2: messageReceived
void Kopete::ChatSession::appendMessage( Kopete::Message &msg )
{
msg.setManager( this );
if ( msg.direction() == Kopete::Message::Inbound )
{
QString nick=myself()->property(Kopete::Global::Properties::self()->nickName()).value().toString();
if ( KopetePrefs::prefs()->highlightEnabled() && !nick.isEmpty() &&
msg.plainBody().contains( QRegExp( QString::fromLatin1( "\\b(%1)\\b" ).arg( nick ), false ) ) )
{
msg.setImportance( Kopete::Message::Highlight );
}
emit messageReceived( msg, this );
}
// outbound messages here are ones the user has sent that are now
// getting reflected back to the chatwindow. they should go down
// the incoming chain.
Kopete::Message::MessageDirection chainDirection = msg.direction();
if( chainDirection == Kopete::Message::Outbound )
chainDirection = Kopete::Message::Inbound;
chainForDirection( chainDirection )->processMessage( msg );
// emit messageAppended( msg, this );
}
示例3: messageReceived
void Kopete::ChatSession::appendMessage( Kopete::Message &msg )
{
msg.setManager( this );
if ( msg.direction() == Kopete::Message::Inbound )
{
const QString nick = myself()->nickName();
if ( Kopete::BehaviorSettings::self()->highlightEnabled() && !nick.isEmpty() )
{
const QString nickNameRegExp = QString::fromLatin1( "(^|[\\W])(%1)([\\W]|$)" ).arg( QRegExp::escape( nick ) );
if ( msg.plainBody().contains( QRegExp( nickNameRegExp, Qt::CaseInsensitive ) ) )
{
msg.setImportance( Kopete::Message::Highlight );
}
}
emit messageReceived( msg, this );
}
// outbound messages here are ones the user has sent that are now
// getting reflected back to the chatwindow. they should go down
// the incoming chain.
Kopete::Message::MessageDirection chainDirection = msg.direction();
if( chainDirection == Kopete::Message::Outbound )
chainDirection = Kopete::Message::Inbound;
chainForDirection( chainDirection )->processMessage( msg );
//looking for urls in the message
urlSearch( msg );
// emit messageAppended( msg, this );
}
示例4: while
QStringList Kopete::ChatSession::findUrls(const Kopete::Message &msg )
{
Kopete::Message message = msg;
//we check the message for every pattern
QString tempstr = message.plainBody();
QStringList regexppatterns = message.regexpPatterns();
QRegExp linkregexp;
QMap<int,QString> mapUrl;
for (int i = 0; i < regexppatterns.size(); ++i) {
linkregexp.setPattern(regexppatterns[i]);
int pos = 0;
while ((pos = linkregexp.indexIn(tempstr, pos)) != -1) {
mapUrl.insert(pos,linkregexp.cap(0));
pos += linkregexp.matchedLength(); }
}
//we use QMap to sort links as they are in the message (if there are many links in one message)
//lasturllist[0] - is the earliest
QStringList lasturllist;
QMapIterator< int, QString > i(mapUrl);
while (i.hasNext()) { i.next(); lasturllist << i.value(); }
lasturllist.replaceInStrings(" ", "");
//add "http://" to link if needed to open it with a browser
lasturllist.replaceInStrings(QRegExp( regexppatterns[1] ), QLatin1String("\\1http://\\2\\3" ));
return lasturllist;
}
示例5: slotTranslateChat
void TranslatorGUIClient::slotTranslateChat()
{
if ( !m_manager->view() )
return;
Kopete::Message msg = m_manager->view()->currentMessage();
QString body = msg.plainBody();
if ( body.isEmpty() )
return;
QString src_lang = TranslatorPlugin::plugin()->m_myLang;
QString dst_lang;
QList<Kopete::Contact*> list = m_manager->members();
Kopete::MetaContact *to = list.first()->metaContact();
dst_lang = to->pluginData( TranslatorPlugin::plugin(), "languageKey" );
if ( dst_lang.isEmpty() || dst_lang == "null" )
{
kDebug( 14308 ) << "Cannot determine dst Metacontact language (" << to->displayName() << ")";
return;
}
// We search for src_dst
TranslatorPlugin::plugin()->translateMessage( body, src_lang, dst_lang, this, SLOT(messageTranslated(QVariant)) );
}
示例6: slotOutgoingMessage
void NowListeningPlugin::slotOutgoingMessage(Kopete::Message& msg)
{
// Only do stuff if autoadvertising is on
if(!NowListeningConfig::self()->chatAdvertising())
return;
QString originalBody = msg.plainBody();
// If it is a /media message, don't process it
if(originalBody.startsWith(NowListeningConfig::self()->header()))
return;
// What will be sent
QString newBody;
// Getting the list of contacts the message will be sent to to determine if at least
// one of them has never gotten the current music information.
Kopete::ContactPtrList dest = msg.to();
bool mustSendAnyway = false;
for( Kopete::Contact *c = dest.first() ; c ; c = dest.next() )
{
const QString& cId = c->contactId();
if( 0 == d->m_musicSentTo.contains( cId ) )
{
mustSendAnyway = true;
// The contact will get the music information so we put it in the list.
d->m_musicSentTo.push_back( cId );
}
}
bool newTrack = newTrackPlaying();
// We must send the music information if someone has never gotten it or the track(s)
// has changed since it was last sent.
if ( mustSendAnyway || newTrack )
{
QString advert = mediaPlayerAdvert(false); // false since newTrackPlaying() did the update
if( !advert.isEmpty() )
newBody = originalBody + "<br>" + advert;
// If we send because the information has changed since it was last sent, we must
// rebuild the list of contacts the latest information was sent to.
if( newTrack )
{
d->m_musicSentTo.clear();
for( Kopete::Contact *c = dest.first() ; c ; c = dest.next() )
{
d->m_musicSentTo.push_back( c->contactId() );
}
}
}
// If the body has been modified, change the message
if( !newBody.isEmpty() )
{
msg.setBody( newBody, Kopete::Message::RichText );
}
}
示例7: chatSession
bool Kopete::Transfer::showHtmlMessage( QString text ) const
{
Kopete::ChatSession *cs = chatSession();
if (! cs)
return false;
Kopete::Message msg;
msg.setHtmlBody( text );
cs->appendMessage( msg );
return true;
}
示例8: newMessage
void
WlmContact::receivedMessage (const QString & message)
{
// Create a Kopete::Message
Kopete::ContactPtrList contactList;
account ();
contactList.append (account ()->myself ());
Kopete::Message newMessage (this, contactList);
newMessage.setPlainBody (message);
newMessage.setDirection (Kopete::Message::Inbound);
// Add it to the manager
manager ()->appendMessage (newMessage);
}
示例9: gg_send_message
int
GaduSession::sendMessage( uin_t recipient, const Kopete::Message& msg, int msgClass )
{
QString sendMsg;
QCString cpMsg;
KGaduMessage* gadumessage;
if ( isConnected() ) {
gadumessage = rtf->convertToGaduMessage( msg );
if ( gadumessage ) {
const void* data = (const void*)gadumessage->rtf.data();
cpMsg = textcodec->fromUnicode( gadumessage->message );
int o;
o = gg_send_message_richtext( session_, msgClass, recipient, (const unsigned char *)cpMsg.data(), (const unsigned char*) data, gadumessage->rtf.size() );
gadumessage->rtf.resize(0);
delete gadumessage;
return o;
}
else {
sendMsg = msg.plainBody();
sendMsg.replace( QString::fromAscii( "\n" ), QString::fromAscii( "\r\n" ) );
cpMsg = textcodec->fromUnicode( sendMsg );
return gg_send_message( session_, msgClass, recipient, (const unsigned char *)cpMsg.data() );
}
}
else {
emit error( i18n("Not Connected"), i18n("You are not connected to the server.") );
}
return 1;
}
示例10: sendMessage
int MeanwhileSession::sendMessage(Kopete::Message &message)
{
HERE;
MeanwhileContact *contact =
static_cast<MeanwhileContact *>(message.to().first());
if (!contact) {
mwDebug() << "No target for message!" <<endl;
return 0;
}
struct mwIdBlock target = { strdup(contact->meanwhileId().toAscii()), 0L };
struct mwConversation *conv;
conv = mwServiceIm_getConversation(imService, &target);
free(target.user);
if (conv == 0L) {
mwDebug() << "No target for conversation with '"
<< contact->meanwhileId() << "'" << endl;
return 0;
}
struct ConversationData *convdata = (struct ConversationData *)
mwConversation_getClientData(conv);
if (convdata == 0L) {
convdata = createConversationData(conv, contact, true);
if (convdata == 0L) {
mwDebug() << "No memory for conversation data!" << endl;
return 0;
}
}
/* if there's other messages in the queue, or the conversation isn't open,
* then append to the queue instead of sending right away */
if ((convdata->queue && !convdata->queue->isEmpty()) ||
!mwConversation_isOpen(conv)) {
convdata->queue->append(message);
mwConversation_open(conv);
} else if (!mwConversation_send(conv, mwImSend_PLAIN,
message.plainBody().toAscii())) {
convdata->chat->appendMessage(message);
convdata->chat->messageSucceeded();
}
return 1;
}
示例11: messageTranslated
void TranslatorGUIClient::messageTranslated( const QVariant &result )
{
QString translated = result.toString();
if ( translated.isEmpty() )
{
kDebug( 14308 ) << "Empty string returned";
return;
}
//if the user close the window before the translation arrive, return
if ( !m_manager->view() )
return;
Kopete::Message msg = m_manager->view()->currentMessage();
msg.setPlainBody( translated );
m_manager->view()->setCurrentMessage( msg );
}
示例12: file
void Kopete::ChatSession::urlSearch( const Kopete::Message &msg )
{
//if there are any urls in the message
QStringList lasturls = findUrls(msg);
if ( !lasturls.empty() ) {
//set lasturl for message's chatsession
msg.manager()->setLastUrl( lasturls.last() );
//saving new url(s) found in message //file named contactId.lasturls.txt in proper folder
QString urlfilename = Kopete::ChatSession::getUrlsFileName( msg.manager()->members().first() );
QFile file( urlfilename );
file.open( QIODevice::Append );
QTextStream stream( &file );
for (int i = 0; i < lasturls.size(); ++i)
stream << lasturls.at(i) << "\n";
file.close();
}
}
示例13: sendAutoResponse
void AIMContact::sendAutoResponse(Kopete::Message& msg)
{
// The target time is 2 minutes later than the last message
int delta = m_lastAutoresponseTime.secsTo( QDateTime::currentDateTime() );
kdDebug(14152) << k_funcinfo << "Last autoresponse time: " << m_lastAutoresponseTime << endl;
kdDebug(14152) << k_funcinfo << "Current time: " << QDateTime::currentDateTime() << endl;
kdDebug(14152) << k_funcinfo << "Difference: " << delta << endl;
// Check to see if we're past that time
if(delta > 120)
{
kdDebug(14152) << k_funcinfo << "Sending auto response" << endl;
// This code was yoinked straight from OscarContact::slotSendMsg()
// If only that slot wasn't private, but I'm not gonna change it right now.
Oscar::Message message;
if ( m_details.hasCap( CAP_UTF8 ) )
{
message.setText( Oscar::Message::UCS2, msg.plainBody() );
}
else
{
QTextCodec* codec = contactCodec();
message.setText( Oscar::Message::UserDefined, msg.plainBody(), codec );
}
message.setTimestamp( msg.timestamp() );
message.setSender( mAccount->accountId() );
message.setReceiver( mName );
message.setType( 0x01 );
// isAuto defaults to false
mAccount->engine()->sendMessage( message, true);
kdDebug(14152) << k_funcinfo << "Sent auto response" << endl;
manager(Kopete::Contact::CanCreate)->appendMessage(msg);
manager(Kopete::Contact::CanCreate)->messageSucceeded();
// Update the last autoresponse time
m_lastAutoresponseTime = QDateTime::currentDateTime();
}
else
{
kdDebug(14152) << k_funcinfo << "Not enough time since last autoresponse, NOT sending" << endl;
}
}
示例14: slotQuote
void HistoryGUIClient::slotQuote()
{
KopeteView *m_currentView = m_manager->view ( true );
if ( !m_currentView )
return;
m_logger->setPositionToLast();
QList<Kopete::Message> msgs = m_logger->readMessages (
HistoryConfig::number_ChatWindow(), /*mb.first()*/ 0L,
HistoryLogger::AntiChronological, true );
Kopete::Message msg = m_manager->view()->currentMessage();
QString body = msgs.isEmpty() ? "" : msgs.last().plainBody();
kDebug(14310) << "Quoting last message " << body;
body = body.replace('\n', "\n> ");
body.prepend ("> ");
body.append ("\n");
msg.setPlainBody ( body );
m_manager->view()->setCurrentMessage ( msg );
}
示例15: messageSent
void Kopete::ChatSession::sendMessage( Kopete::Message &message )
{
message.setManager( this );
Kopete::Message sentMessage = message;
if ( !Kopete::CommandHandler::commandHandler()->processMessage( message, this ) )
{
emit messageSent( sentMessage, this );
if ( ( !account()->isAway() || Kopete::BehaviorSettings::self()->enableEventsWhileAway() ) && !account()->isBusy() )
{
KNotification::event(QString::fromLatin1( "kopete_outgoing" ), i18n( "Outgoing Message Sent" ) );
}
}
else
{
messageSucceeded();
}
}