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 ); } }
Kopete::ChatSession::ChatSession( const Kopete::Contact *user, Kopete::ContactPtrList others, Kopete::Protocol *protocol, Kopete::ChatSession::Form form ) : QObject( user->account()) { d = new KMMPrivate; d->mUser = user; d->mProtocol = protocol; d->isEmpty = others.isEmpty(); d->mCanBeDeleted = true; d->refcount = 0; d->view = 0L; d->customDisplayName = false; d->mayInvite = false; d->form = form; d->warnGroupChat = true; if ( !others.isEmpty() ) { d->lastUrl = initLastUrl( others.first() ); } for ( int i = 0; others.size() != i; ++i ) addContact( others[i], true ); connect( Kopete::PluginManager::self(), SIGNAL(pluginLoaded(Kopete::Plugin*)), this, SLOT(clearChains()) ); connect( Kopete::PluginManager::self(), SIGNAL(pluginUnloaded(QString)), this, SLOT(clearChains()) ); connect( user, SIGNAL(contactDestroyed(Kopete::Contact*)), this, SLOT(slotMyselfDestroyed(Kopete::Contact*)) ); connect( user, SIGNAL(onlineStatusChanged(Kopete::Contact*,Kopete::OnlineStatus,Kopete::OnlineStatus)), this, SLOT(slotOnlineStatusChanged(Kopete::Contact*,Kopete::OnlineStatus,Kopete::OnlineStatus)) ); if( user->metaContact() ) connect( user->metaContact(), SIGNAL(photoChanged()), this, SIGNAL(photoChanged()) ); slotUpdateDisplayName(); }
Kopete::ChatSession::ChatSession( const Kopete::Contact *user, Kopete::ContactPtrList others, Kopete::Protocol *protocol, const char *name ) : QObject( user->account(), name ) { d = new KMMPrivate; d->mUser = user; d->mProtocol = protocol; d->isEmpty = others.isEmpty(); d->mCanBeDeleted = true; d->refcount = 0; d->view = 0L; d->customDisplayName = false; d->mayInvite = false; for ( Kopete::Contact *c = others.first(); c; c = others.next() ) addContact( c, true ); connect( user, SIGNAL( onlineStatusChanged( Kopete::Contact *, const Kopete::OnlineStatus &, const Kopete::OnlineStatus & ) ), this, SLOT( slotOnlineStatusChanged( Kopete::Contact *, const Kopete::OnlineStatus &, const Kopete::OnlineStatus & ) ) ); if( user->metaContact() ) connect( user->metaContact(), SIGNAL( photoChanged() ), this, SIGNAL( photoChanged() ) ); slotUpdateDisplayName(); }
void IRCUserContact::slotBanUserHostOnce() { if (mInfo.hostName.isEmpty()) return; Kopete::ContactPtrList members = mActiveManager->members(); QString channelName = static_cast<IRCContact*>(members.first())->nickName(); kircEngine()->mode(channelName, QString::fromLatin1("+b *!*%1@%2").arg(mInfo.userName, mInfo.hostName)); }
void IRCUserContact::slotBanDomainOnce() { if (mInfo.hostName.isEmpty()) return; Kopete::ContactPtrList members = mActiveManager->members(); QString channelName = static_cast<IRCContact*>(members.first())->nickName(); QString domain = mInfo.hostName.section('.', 1); kircEngine()->mode(channelName, QString::fromLatin1("+b *!*@*.%1").arg(domain)); }
YahooChatSession::YahooChatSession( Kopete::Protocol *protocol, const Kopete::Contact *user, Kopete::ContactPtrList others, const char *name ) : Kopete::ChatSession( user, others, protocol, name ) { kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl; Kopete::ChatSessionManager::self()->registerChatSession( this ); setInstance(protocol->instance()); // Add Actions new KAction( i18n( "Buzz Contact" ), QIconSet(BarIcon("bell")), "Ctrl+G", this, SLOT( slotBuzzContact() ), actionCollection(), "yahooBuzz" ) ; new KAction( i18n( "Show User Info" ), QIconSet(BarIcon("idea")), 0, this, SLOT( slotUserInfo() ), actionCollection(), "yahooShowInfo" ) ; new KAction( i18n( "Request Webcam" ), QIconSet(BarIcon("webcamreceive")), 0, this, SLOT( slotRequestWebcam() ), actionCollection(), "yahooRequestWebcam" ) ; new KAction( i18n( "Invite to view your Webcam" ), QIconSet(BarIcon("webcamsend")), 0, this, SLOT( slotInviteWebcam() ), actionCollection(), "yahooSendWebcam" ) ; new KAction( i18n( "Send File" ), QIconSet(BarIcon("attach")), 0, this, SLOT( slotSendFile() ), actionCollection(), "yahooSendFile" ); YahooContact *c = static_cast<YahooContact*>( others.first() ); connect( c, SIGNAL( displayPictureChanged() ), this, SLOT( slotDisplayPictureChanged() ) ); m_image = new QLabel( 0L, "kde toolbar widget" ); new KWidgetAction( m_image, i18n( "Yahoo Display Picture" ), 0, this, SLOT( slotDisplayPictureChanged() ), actionCollection(), "yahooDisplayPicture" ); if(c->hasProperty(Kopete::Global::Properties::self()->photo().key()) ) { connect( Kopete::ChatSessionManager::self() , SIGNAL(viewActivated(KopeteView* )) , this, SLOT(slotDisplayPictureChanged()) ); }
QPtrList<KAction> *IRCUserContact::customContextMenuActions( Kopete::ChatSession *manager ) { if( manager ) { QPtrList<KAction> *mCustomActions = new QPtrList<KAction> (); mActiveManager = manager; Kopete::ContactPtrList members = mActiveManager->members(); IRCChannelContact *isChannel = dynamic_cast<IRCChannelContact*>( members.first() ); if( !actionCtcpMenu ) { actionCtcpMenu = new KActionMenu(i18n("C&TCP"), 0, this ); actionCtcpMenu->insert( new KAction(i18n("&Version"), 0, this, SLOT(slotCtcpVersion()), actionCtcpMenu) ); actionCtcpMenu->insert( new KAction(i18n("&Ping"), 0, this, SLOT(slotCtcpPing()), actionCtcpMenu) ); actionModeMenu = new KActionMenu(i18n("&Modes"), 0, this, "actionModeMenu"); actionModeMenu->insert( new KAction(i18n("&Op"), 0, this, SLOT(slotOp()), actionModeMenu, "actionOp") ); actionModeMenu->insert( new KAction(i18n("&Deop"), 0, this, SLOT(slotDeop()), actionModeMenu, "actionDeop") ); actionModeMenu->insert( new KAction(i18n("&Voice"), 0, this, SLOT(slotVoice()), actionModeMenu, "actionVoice") ); actionModeMenu->insert( new KAction(i18n("Devoice"), 0, this, SLOT(slotDevoice()), actionModeMenu, "actionDevoice") ); actionModeMenu->setEnabled( false ); actionKick = new KAction(i18n("&Kick"), 0, this, SLOT(slotKick()), this); actionKick->setEnabled( false ); actionBanMenu = new KActionMenu(i18n("&Ban"), 0, this, "actionBanMenu"); actionBanMenu->insert( new KAction(i18n("Host (*!*@host.domain.net)"), 0, this, SLOT(slotBanHost()), actionBanMenu ) ); actionBanMenu->insert( new KAction(i18n("Domain (*!*@*.domain.net)"), 0, this, SLOT(slotBanDomain()), actionBanMenu ) ); actionBanMenu->insert( new KAction(i18n("User@Host (*!*[email protected])"), 0, this, SLOT(slotBanUserHost()), actionBanMenu ) ); actionBanMenu->insert( new KAction(i18n("User@Domain (*!*user@*.domain.net)"), 0, this, SLOT(slotBanUserDomain()), actionBanMenu ) ); actionBanMenu->setEnabled( false ); codecAction = new KCodecAction( i18n("&Encoding"), 0, this, "selectcharset" ); connect( codecAction, SIGNAL( activated( const QTextCodec * ) ), this, SLOT( setCodec( const QTextCodec *) ) ); codecAction->setCodec( codec() ); } mCustomActions->append( actionCtcpMenu ); mCustomActions->append( actionModeMenu ); mCustomActions->append( actionKick ); mCustomActions->append( actionBanMenu ); mCustomActions->append( codecAction ); if( isChannel ) { bool isOperator = ( manager->contactOnlineStatus( account()->myself() ).internalStatus() & IRCProtocol::Operator ); actionModeMenu->setEnabled(isOperator); actionBanMenu->setEnabled(isOperator); actionKick->setEnabled(isOperator); } return mCustomActions; }
void IRCUserContact::contactMode(const QString &mode) { Kopete::ContactPtrList members = mActiveManager->members(); QString channelName = static_cast<IRCContact*>(members.first())->nickName(); kircEngine()->mode(channelName, QString::fromLatin1("%1 %2").arg(mode).arg(m_nickName)); }
void IRCUserContact::slotKick() { Kopete::ContactPtrList members = mActiveManager->members(); QString channelName = static_cast<IRCContact*>(members.first())->nickName(); kircEngine()->kick(m_nickName, channelName, QString::null); }