diff --git a/protocols/oscar/aim/aimaccount.cpp b/protocols/oscar/aim/aimaccount.cpp index 9f4841ee8..592f4fca4 100644 --- a/protocols/oscar/aim/aimaccount.cpp +++ b/protocols/oscar/aim/aimaccount.cpp @@ -1,708 +1,706 @@ /* aimaccount.cpp - Oscar Protocol Plugin, AIM part Kopete (c) 2002-2007 by the Kopete developers ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ************************************************************************* */ #include "aimaccount.h" #include #include #include #include #include #include #include #include #include #include "kopetepassword.h" #include "kopetestdaction.h" #include "kopeteuiglobal.h" #include "kopetecontactlist.h" #include "kopetemetacontact.h" #include "kopeteprotocol.h" #include "kopetechatsessionmanager.h" #include "kopeteview.h" #include "aimprotocol.h" #include "aimchatsession.h" #include "aimcontact.h" #include "icqcontact.h" #include "aimuserinfo.h" #include "aimjoinchat.h" #include "oscarmyselfcontact.h" #include "oscarutils.h" #include "client.h" #include "contactmanager.h" #include "oscarsettings.h" #include "oscarstatusmanager.h" const Oscar::DWORD AIM_ONLINE = 0x0; const Oscar::DWORD AIM_AWAY = 0x1; namespace Kopete { class MetaContact; } AIMMyselfContact::AIMMyselfContact( AIMAccount *acct ) : OscarMyselfContact( acct ) { m_acct = acct; } void AIMMyselfContact::userInfoUpdated() { Oscar::DWORD extendedStatus = details().extendedStatus(); kDebug( OSCAR_AIM_DEBUG ) << "extendedStatus is " << QString::number( extendedStatus, 16 ); AIMProtocol* p = static_cast(protocol()); Oscar::Presence presence = p->statusManager()->presenceOf( extendedStatus, details().userClass() ); setOnlineStatus( p->statusManager()->onlineStatusOf( presence ) ); setStatusMessage( static_cast( account() )->engine()->statusMessage() ); } void AIMMyselfContact::setOwnProfile( const QString& newProfile ) { m_profileString = newProfile; if ( m_acct->isConnected() ) m_acct->engine()->updateProfile( newProfile ); } QString AIMMyselfContact::userProfile() { return m_profileString; } Kopete::ChatSession* AIMMyselfContact::manager( Kopete::Contact::CanCreateFlags canCreate ) { return manager( canCreate, 0, QString() ); } Kopete::ChatSession* AIMMyselfContact::manager( Kopete::Contact::CanCreateFlags canCreate, Oscar::WORD exchange, const QString& room ) { kDebug(OSCAR_AIM_DEBUG) ; Kopete::ContactPtrList chatMembers; chatMembers.append( this ); Kopete::ChatSession* genericManager = nullptr; genericManager = Kopete::ChatSessionManager::self()->findChatSession( account()->myself(), chatMembers, protocol() ); AIMChatSession* session = dynamic_cast( genericManager ); if ( !session && canCreate == Contact::CanCreate ) { session = new AIMChatSession( this, chatMembers, account()->protocol(), exchange, room ); session->setEngine( m_acct->engine() ); - connect( session, SIGNAL(messageSent(Kopete::Message&,Kopete::ChatSession*)), - this, SLOT(sendMessage(Kopete::Message&,Kopete::ChatSession*)) ); + connect(session, &AIMChatSession::messageSent, this, &AIMMyselfContact::sendMessage); m_chatRoomSessions.append( session ); } return session; } void AIMMyselfContact::chatSessionDestroyed( Kopete::ChatSession* session ) { m_chatRoomSessions.removeAll( session ); } void AIMMyselfContact::sendMessage( Kopete::Message& message, Kopete::ChatSession* session ) { kDebug(OSCAR_AIM_DEBUG) << "sending a message"; //TODO: remove duplication - factor into a message utils class or something Oscar::Message msg; QString s; if (message.plainBody().isEmpty()) // no text, do nothing return; //okay, now we need to change the message.escapedBody from real HTML to aimhtml. //looking right now for docs on that "format". //looks like everything except for alignment codes comes in the format of spans //font-style:italic -> //font-weight:600 -> (anything > 400 should be , 400 is not bold) //text-decoration:underline -> //font-family: -> //font-size:xxpt -> s=message.escapedBody(); s.replace ( QRegExp( QString::fromLatin1("([^<]*)")), QString::fromLatin1("")); s.replace ( QRegExp( QString::fromLatin1("")), QString::fromLatin1("")); s.replace ( QRegExp( QString::fromLatin1("")), QString::fromLatin1("")); s.replace ( QRegExp( QString::fromLatin1("")), QString::fromLatin1("")); s.replace ( QRegExp( QString::fromLatin1("")), QString::fromLatin1("")); s.replace ( QRegExp( QString::fromLatin1("")), QString::fromLatin1("")); s.replace ( QRegExp( QString::fromLatin1("")), QString::fromLatin1("")); s.replace ( QRegExp( QString::fromLatin1("")), QString::fromLatin1("")); s.replace ( QRegExp( QString::fromLatin1("")), QString::fromLatin1("\\2")); //okay now change the to //0-9 are size 1 s.replace ( QRegExp ( QString::fromLatin1("")), QString::fromLatin1("")); //10-11 are size 2 s.replace ( QRegExp ( QString::fromLatin1("")), QString::fromLatin1("")); //12-13 are size 3 s.replace ( QRegExp ( QString::fromLatin1("")), QString::fromLatin1("")); //14-16 are size 4 s.replace ( QRegExp ( QString::fromLatin1("")), QString::fromLatin1("")); //17-22 are size 5 s.replace ( QRegExp ( QString::fromLatin1("")), QString::fromLatin1("")); //23-29 are size 6 s.replace ( QRegExp ( QString::fromLatin1("")),QString::fromLatin1("")); //30- (and any I missed) are size 7 s.replace ( QRegExp ( QString::fromLatin1("")),QString::fromLatin1("")); s.replace ( QRegExp ( QString::fromLatin1("")), QString::fromLatin1("
") ); kDebug(14190) << "sending " << s << endl; msg.setSender( contactId() ); msg.setText( Oscar::Message::UserDefined, s, m_acct->defaultCodec() ); msg.setTimestamp(message.timestamp()); msg.setChannel(0x03); msg.addProperty( Oscar::Message::ChatRoom ); AIMChatSession* aimSession = dynamic_cast( session ); if ( !aimSession ) { kWarning(OSCAR_AIM_DEBUG) << "couldn't convert to AIM chat room session!"; session->messageSucceeded(); return; } msg.setExchange( aimSession->exchange() ); msg.setChatRoom( aimSession->roomName() ); m_acct->engine()->sendMessage( msg ); //session->appendMessage( message ); session->messageSucceeded(); } AIMAccount::AIMAccount(Kopete::Protocol *parent, QString accountID) : OscarAccount(parent, accountID, false) { kDebug(14152) << accountID << ": Called."; AIMMyselfContact* mc = new AIMMyselfContact( this ); setMyself( mc ); mc->setOnlineStatus( protocol()->statusManager()->onlineStatusOf( Oscar::Presence( Oscar::Presence::Offline ) ) ); QString profile = configGroup()->readEntry( "Profile", i18n( "Visit the Kopete website at http://kopete.kde.org") ); mc->setOwnProfile( profile ); mInitialStatusMessage.clear(); m_joinChatDialog = 0; QObject::connect( engine(), SIGNAL(chatRoomConnected(Oscar::WORD,QString)), this, SLOT(connectedToChatRoom(Oscar::WORD,QString)) ); QObject::connect( engine(), SIGNAL(userJoinedChat(Oscar::WORD,QString,QString)), this, SLOT(userJoinedChat(Oscar::WORD,QString,QString)) ); QObject::connect( engine(), SIGNAL(userLeftChat(Oscar::WORD,QString,QString)), this, SLOT(userLeftChat(Oscar::WORD,QString,QString)) ); // Create actions mJoinChatAction = new QAction( i18n( "Join Chat..." ), this ); - QObject::connect( mJoinChatAction, SIGNAL(triggered(bool)), this, SLOT(slotJoinChat()) ); + QObject::connect(mJoinChatAction, &QAction::triggered, this, &AIMAccount::slotJoinChat); mEditInfoAction = new QAction( QIcon::fromTheme("user-properties"), i18n( "Edit User Info..." ), this ); - QObject::connect( mEditInfoAction, SIGNAL(triggered(bool)), this, SLOT(slotEditInfo()) ); + QObject::connect(mEditInfoAction, &QAction::triggered, this, &AIMAccount::slotEditInfo); mActionInvisible = new KToggleAction( i18n( "In&visible" ), this ); - QObject::connect( mActionInvisible, SIGNAL(triggered(bool)), this, SLOT(slotToggleInvisible()) ); + QObject::connect(mActionInvisible, &KToggleAction::triggered, this, &AIMAccount::slotToggleInvisible); } AIMAccount::~AIMAccount() { } AIMProtocol* AIMAccount::protocol() const { return static_cast(OscarAccount::protocol()); } Oscar::Presence AIMAccount::presence() { return protocol()->statusManager()->presenceOf( myself()->onlineStatus() ); } OscarContact *AIMAccount::createNewContact( const QString &contactId, Kopete::MetaContact *parentContact, const OContact& ssiItem ) { if ( QRegExp("[\\d]+").exactMatch( contactId ) ) { ICQContact* contact = new ICQContact( this, contactId, parentContact, QString() ); contact->setSSIItem( ssiItem ); if ( engine()->isActive() ) contact->loggedIn(); return contact; } else { AIMContact* contact = new AIMContact( this, contactId, parentContact, QString() ); contact->setSSIItem( ssiItem ); return contact; } } void AIMAccount::fillActionMenu( KActionMenu *actionMenu ) { Kopete::Account::fillActionMenu( actionMenu ); actionMenu->addSeparator(); mJoinChatAction->setEnabled( isConnected() ); actionMenu->addAction( mJoinChatAction ); mEditInfoAction->setEnabled( isConnected() ); actionMenu->addAction( mEditInfoAction ); Oscar::Presence pres( presence().type(), presence().flags() | Oscar::Presence::Invisible ); mActionInvisible->setIcon( QIcon( protocol()->statusManager()->onlineStatusOf( pres ).iconFor( this ) ) ); mActionInvisible->setChecked( (presence().flags() & Oscar::Presence::Invisible) == Oscar::Presence::Invisible ); actionMenu->addAction( mActionInvisible ); } void AIMAccount::setPresenceFlags( Oscar::Presence::Flags flags, const QString &message ) { Oscar::Presence pres = presence(); kDebug(OSCAR_AIM_DEBUG) << "new flags=" << (int)flags << ", old type=" << (int)pres.flags() << ", new message=" << message << endl; setPresenceTarget( Oscar::Presence( pres.type(), flags ), message ); } void AIMAccount::setPresenceType( Oscar::Presence::Type type, const QString &message ) { Oscar::Presence pres = presence(); kDebug(OSCAR_AIM_DEBUG) << "new type=" << (int)type << ", old type=" << (int)pres.type() << ", new message=" << message << endl; setPresenceTarget( Oscar::Presence( type, pres.flags() ), message ); } void AIMAccount::setPresenceTarget( const Oscar::Presence &newPres, const QString &message ) { bool targetIsOffline = (newPres.type() == Oscar::Presence::Offline); bool accountIsOffline = ( presence().type() == Oscar::Presence::Offline || myself()->onlineStatus() == protocol()->statusManager()->connectingStatus() ); if ( targetIsOffline ) { OscarAccount::disconnect(); // allow toggling invisibility when offline myself()->setOnlineStatus( protocol()->statusManager()->onlineStatusOf( newPres ) ); } else if ( accountIsOffline ) { mInitialStatusMessage = message; OscarAccount::connect( protocol()->statusManager()->onlineStatusOf( newPres ) ); } else { engine()->setStatus( protocol()->statusManager()->oscarStatusOf( newPres ), message ); } } void AIMAccount::setOnlineStatus( const Kopete::OnlineStatus& status, const Kopete::StatusMessage &reason, const OnlineStatusOptions& options ) { if ( status.status() == Kopete::OnlineStatus::Invisible ) { // called from outside, i.e. not by our custom action menu entry... if ( presence().type() == Oscar::Presence::Offline ) { // ...when we are offline go online invisible. setPresenceTarget( Oscar::Presence( Oscar::Presence::Online, Oscar::Presence::Invisible ) ); } else { // ...when we are not offline set invisible. setPresenceFlags( Oscar::Presence::Invisible ); } } else { Oscar::Presence pres = protocol()->statusManager()->presenceOf( status ); if ( options & Kopete::Account::KeepSpecialFlags ) pres.setFlags( presence().flags() ); setPresenceTarget( pres, reason.message() ); } } void AIMAccount::setStatusMessage( const Kopete::StatusMessage& statusMessage ) { setOnlineStatus( myself()->onlineStatus(), statusMessage, Kopete::Account::KeepSpecialFlags ); } void AIMAccount::setUserProfile(const QString &profile) { kDebug(14152) << "called."; AIMMyselfContact* aimmc = dynamic_cast( myself() ); if ( aimmc ) aimmc->setOwnProfile( profile ); configGroup()->writeEntry( QString::fromLatin1( "Profile" ), profile ); } void AIMAccount::slotEditInfo() { if ( !isConnected() ) { KMessageBox::sorry( Kopete::UI::Global::mainWidget(), i18n( "Editing your user info is not possible because " "you are not connected." ), i18n( "Unable to edit user info" ) ); return; } QPointer myInfo = new AIMUserInfoDialog(static_cast( myself() ), this); myInfo->exec(); // This is a modal dialog delete myInfo; } void AIMAccount::slotToggleInvisible() { using namespace AIM; if ( (presence().flags() & Presence::Invisible) == Presence::Invisible ) setPresenceFlags( presence().flags() & ~Presence::Invisible ); else setPresenceFlags( presence().flags() | Presence::Invisible ); } void AIMAccount::slotJoinChat() { if ( !isConnected() ) { KMessageBox::sorry( Kopete::UI::Global::mainWidget(), i18n( "Joining an AIM chat room is not possible because " "you are not connected." ), i18n( "Unable to Join AIM Chat Room" ) ); return; } //get the exchange info //create the dialog //join the chat room if ( !m_joinChatDialog ) { m_joinChatDialog = new AIMJoinChatUI( this, Kopete::UI::Global::mainWidget() ); - QObject::connect( m_joinChatDialog, SIGNAL(closing(int)), - this, SLOT(joinChatDialogClosed(int)) ); + QObject::connect(m_joinChatDialog, &AIMJoinChatUI::closing, this, &AIMAccount::joinChatDialogClosed); QList list = engine()->chatExchangeList(); m_joinChatDialog->setExchangeList( list ); m_joinChatDialog->show(); } else m_joinChatDialog->raise(); } void AIMAccount::joinChatDialogClosed( int code ) { if ( code == QDialog::Accepted ) { //join the chat kDebug(14152) << "chat accepted."; engine()->joinChatRoom( m_joinChatDialog->roomName(), m_joinChatDialog->exchange().toInt() ); } m_joinChatDialog->delayedDestruct(); m_joinChatDialog = nullptr; } void AIMAccount::loginActions() { OscarAccount::loginActions(); using namespace AIM::PrivacySettings; int privacySetting = this->configGroup()->readEntry( "PrivacySetting", int(AllowAll) ); this->setPrivacySettings( privacySetting ); } void AIMAccount::disconnected( DisconnectReason reason ) { kDebug( OSCAR_AIM_DEBUG ) << "Attempting to set status offline"; Oscar::Presence pres( Oscar::Presence::Offline, presence().flags() ); myself()->setOnlineStatus( protocol()->statusManager()->onlineStatusOf( pres ) ); QHash contactList = contacts(); foreach( Kopete::Contact* c, contactList ) { OscarContact* oc = dynamic_cast( c ); if ( oc ) oc->userOffline( oc->contactId() ); } OscarAccount::disconnected( reason ); } void AIMAccount::messageReceived( const Oscar::Message& message ) { kDebug(14152) << " Got a message, calling OscarAccount::messageReceived"; // Want to call the parent to do everything else if ( message.channel() != 0x0003 ) { OscarAccount::messageReceived(message); // Check to see if our status is away, and send an away message // Might be duplicate code from the parent class to get some needed information // Perhaps a refactoring is needed. kDebug(14152) << "Checking to see if I'm online.."; if( myself()->onlineStatus().status() == Kopete::OnlineStatus::Away || myself()->onlineStatus().status() == Kopete::OnlineStatus::Busy) { QString sender = Oscar::normalize( message.sender() ); AIMContact* aimSender = dynamic_cast ( contacts().value( sender ) ); //should exist now if ( !aimSender ) { kWarning(OSCAR_RAW_DEBUG) << "For some reason, could not get the contact " << "That this message is from: " << message.sender() << ", Discarding message" << endl; return; } // Create, or get, a chat session with the contact Kopete::ChatSession* chatSession = aimSender->manager( Kopete::Contact::CanCreate ); Q_UNUSED(chatSession); // get the away message we have set QString msg = engine()->statusMessage(); kDebug(14152) << "Got away message: " << msg; // Create the message Kopete::Message chatMessage( myself(), aimSender ); chatMessage.setHtmlBody( msg ); chatMessage.setDirection( Kopete::Message::Outbound ); kDebug(14152) << "Sending autoresponse"; // Send the message aimSender->sendAutoResponse( chatMessage ); } } else { kDebug(OSCAR_AIM_DEBUG) << "have chat message"; //handle chat room messages separately QList chats = Kopete::ChatSessionManager::self()->sessions(); QList::iterator it, itEnd = chats.end(); for ( it = chats.begin(); it != itEnd; ++it ) { Kopete::ChatSession* kcs = ( *it ); AIMChatSession* session = dynamic_cast( kcs ); if ( !session ) continue; if ( session->exchange() == message.exchange() && Oscar::normalize( session->roomName() ) == Oscar::normalize( message.chatRoom() ) ) { kDebug(OSCAR_AIM_DEBUG) << "found chat session for chat room"; OscarContact* ocSender = static_cast(contacts().value( Oscar::normalize( message.sender() ) )); //sanitize; QString sanitizedMsg = sanitizedMessage( message.text( defaultCodec() ) ); Kopete::Message chatMessage( ocSender, myself() ); chatMessage.setDirection( Kopete::Message::Inbound ); chatMessage.setHtmlBody( sanitizedMsg ); chatMessage.setTimestamp( message.timestamp() ); session->appendMessage( chatMessage ); } } } } void AIMAccount::connectedToChatRoom( Oscar::WORD exchange, const QString& room ) { kDebug(OSCAR_AIM_DEBUG) << "Creating chat room session"; Kopete::ContactPtrList emptyList; AIMMyselfContact* me = static_cast( myself() ); AIMChatSession* session = static_cast( me->manager( Kopete::Contact::CanCreate, exchange, room ) ); session->setDisplayName( room ); if ( session->view( true ) ) session->raiseView(); } void AIMAccount::userJoinedChat( Oscar::WORD exchange, const QString& room, const QString& contact ) { if ( Oscar::normalize( contact ) == Oscar::normalize( myself()->contactId() ) ) return; kDebug(OSCAR_AIM_DEBUG) << "user " << contact << " has joined the chat"; QList chats = Kopete::ChatSessionManager::self()->sessions(); QList::iterator it, itEnd = chats.end(); for ( it = chats.begin(); it != itEnd; ++it ) { Kopete::ChatSession* kcs = ( *it ); AIMChatSession* session = dynamic_cast( kcs ); if ( !session ) continue; kDebug(OSCAR_AIM_DEBUG) << session->exchange() << " " << exchange; kDebug(OSCAR_AIM_DEBUG) << session->roomName() << " " << room; if ( session->exchange() == exchange && session->roomName() == room ) { kDebug(OSCAR_AIM_DEBUG) << "found correct chat session"; Kopete::Contact* c = contacts().value( Oscar::normalize( contact ) ); if ( !c ) { Kopete::MetaContact* mc = addContact( Oscar::normalize( contact ), contact, 0, Kopete::Account::Temporary ); if ( !mc ) kWarning(OSCAR_AIM_DEBUG) << "Unable to add contact for chat room"; c = mc->contacts().first(); c->setNickName( contact ); } kDebug(OSCAR_AIM_DEBUG) << "adding contact"; Kopete::OnlineStatus status = protocol()->statusManager()->onlineStatusOf( Oscar::Presence( Oscar::Presence::Online ) ); session->addContact( c, status, true /* suppress */ ); } } } void AIMAccount::userLeftChat( Oscar::WORD exchange, const QString& room, const QString& contact ) { if ( Oscar::normalize( contact ) == Oscar::normalize( myself()->contactId() ) ) return; QList chats = Kopete::ChatSessionManager::self()->sessions(); QList::iterator it, itEnd = chats.end(); for ( it = chats.begin(); it != itEnd; ++it ) { Kopete::ChatSession* kcs = ( *it ); AIMChatSession* session = dynamic_cast( kcs ); if ( !session ) continue; if ( session->exchange() == exchange && session->roomName() == room ) { //delete temp contact Kopete::Contact* c = contacts().value( Oscar::normalize( contact ) ); if ( !c ) { kWarning(OSCAR_AIM_DEBUG) << "couldn't find the contact that's left the chat!"; continue; } session->removeContact( c ); Kopete::MetaContact* mc = c->metaContact(); if ( mc->isTemporary() ) { mc->removeContact( c ); delete c; delete mc; } } } } void AIMAccount::connectWithPassword( const QString &password ) { if ( password.isNull() ) return; kDebug(14152) << "accountId='" << accountId() << "'"; Kopete::OnlineStatus status = initialStatus(); if ( status == Kopete::OnlineStatus() && status.status() == Kopete::OnlineStatus::Unknown ) //use default online in case of invalid online status for connecting status = Kopete::OnlineStatus( Kopete::OnlineStatus::Online ); Oscar::Presence pres = protocol()->statusManager()->presenceOf( status ); bool accountIsOffline = ( presence().type() == Oscar::Presence::Offline || myself()->onlineStatus() == protocol()->statusManager()->connectingStatus() ); if ( accountIsOffline ) { kDebug(14152) << "Logging in as " << accountId(); myself()->setOnlineStatus( protocol()->statusManager()->connectingStatus() ); // Get the screen name for this account QString screenName = accountId(); QString server = configGroup()->readEntry( "Server", QString::fromLatin1( "login.oscar.aol.com" ) ); uint port = configGroup()->readEntry( "Port", 5190 ); //set up the settings for the account Oscar::Settings* oscarSettings = engine()->clientSettings(); oscarSettings->setFileProxy( configGroup()->readEntry( "FileProxy", true ) ); oscarSettings->setFirstPort( configGroup()->readEntry( "FirstPort", 5190 ) ); oscarSettings->setLastPort( configGroup()->readEntry( "LastPort", 5199 ) ); oscarSettings->setTimeout( configGroup()->readEntry( "Timeout", 10 ) ); Oscar::DWORD status = protocol()->statusManager()->oscarStatusOf( pres ); updateVersionUpdaterStamp(); engine()->start( server, port, accountId(), password.left(16) ); engine()->setStatus( status, mInitialStatusMessage ); engine()->connectToServer( server, port, false, QString() ); mInitialStatusMessage.clear(); } } void AIMAccount::setPrivacySettings( int privacy ) { using namespace AIM::PrivacySettings; Oscar::BYTE privacyByte = 0x01; Oscar::DWORD userClasses = 0xFFFFFFFF; switch ( privacy ) { case AllowAll: privacyByte = 0x01; break; case BlockAll: privacyByte = 0x02; break; case AllowPremitList: privacyByte = 0x03; break; case BlockDenyList: privacyByte = 0x04; break; case AllowMyContacts: privacyByte = 0x05; break; case BlockAIM: privacyByte = 0x01; userClasses = 0x00000004; break; } engine()->setPrivacyTLVs( privacyByte, userClasses ); } diff --git a/protocols/oscar/aim/aimcontact.cpp b/protocols/oscar/aim/aimcontact.cpp index b851edd15..e6c5e058e 100644 --- a/protocols/oscar/aim/aimcontact.cpp +++ b/protocols/oscar/aim/aimcontact.cpp @@ -1,242 +1,242 @@ /* aimcontact.cpp - Oscar Protocol Plugin Copyright (c) 2003 by Will Stephenson Copyright (c) 2006,2007 by Roman Jarosz Kopete (c) 2002-2007 by the Kopete developers ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ************************************************************************* */ #include "aimcontact.h" #include #include #include #include #include #include "kopeteuiglobal.h" //liboscar #include "oscarutils.h" #include "contactmanager.h" #include "aimprotocol.h" #include "aimuserinfo.h" #include "aimaccount.h" #include "oscarstatusmanager.h" AIMContact::AIMContact( Kopete::Account* account, const QString& name, Kopete::MetaContact* parent, const QString& icon ) : AIMContactBase(account, name, parent, icon ) { mProtocol=static_cast(protocol()); setPresenceTarget( Oscar::Presence( Oscar::Presence::Offline ) ); m_infoDialog = nullptr; m_warnUserAction = nullptr; QObject::connect( mAccount->engine(), SIGNAL(receivedUserInfo(QString,UserDetails)), this, SLOT(userInfoUpdated(QString,UserDetails)) ); QObject::connect( mAccount->engine(), SIGNAL(userIsOffline(QString)), this, SLOT(userOffline(QString)) ); QObject::connect( mAccount->engine(), SIGNAL(receivedProfile(QString,QString)), this, SLOT(updateProfile(QString,QString)) ); QObject::connect( mAccount->engine(), SIGNAL(userWarned(QString,quint16,quint16)), this, SLOT(gotWarning(QString,quint16,quint16)) ); } AIMContact::~AIMContact() { } bool AIMContact::isReachable() { return true; } QList *AIMContact::customContextMenuActions() { QList *actions = new QList(); if ( !m_warnUserAction ) { m_warnUserAction = new QAction( i18n( "&Warn User" ), this ); //, "warnAction" ); - QObject::connect( m_warnUserAction, SIGNAL(triggered(bool)), this, SLOT(warnUser()) ); + QObject::connect(m_warnUserAction, &QAction::triggered, this, &AIMContact::warnUser); } m_actionVisibleTo = new KToggleAction(i18n("Always &Visible To"), this ); //, "actionVisibleTo"); - QObject::connect( m_actionVisibleTo, SIGNAL(triggered(bool)), this, SLOT(slotVisibleTo()) ); + QObject::connect(m_actionVisibleTo, &KToggleAction::triggered, this, &AIMContact::slotVisibleTo); m_actionInvisibleTo = new KToggleAction(i18n("Always &Invisible To"), this ); //, "actionInvisibleTo"); - QObject::connect( m_actionInvisibleTo, SIGNAL(triggered(bool)), this, SLOT(slotInvisibleTo()) ); + QObject::connect(m_actionInvisibleTo, &KToggleAction::triggered, this, &AIMContact::slotInvisibleTo); bool on = account()->isConnected(); m_warnUserAction->setEnabled( on ); m_actionVisibleTo->setEnabled(on); m_actionInvisibleTo->setEnabled(on); ContactManager* ssi = account()->engine()->ssiManager(); m_actionVisibleTo->setChecked( ssi->findItem( m_ssiItem.name(), ROSTER_VISIBLE )); m_actionInvisibleTo->setChecked( ssi->findItem( m_ssiItem.name(), ROSTER_INVISIBLE )); actions->append( m_warnUserAction ); actions->append(m_actionVisibleTo); actions->append(m_actionInvisibleTo); // temporary action collection, used to apply Kiosk policy to the actions KActionCollection tempCollection((QObject*)0); tempCollection.addAction(QLatin1String("aimContactWarn"), m_warnUserAction); tempCollection.addAction(QLatin1String("oscarContactAlwaysVisibleTo"), m_actionVisibleTo); tempCollection.addAction(QLatin1String("oscarContactAlwaysInvisibleTo"), m_actionInvisibleTo); return actions; } int AIMContact::warningLevel() const { return m_warningLevel; } void AIMContact::setSSIItem( const OContact& ssiItem ) { if ( ssiItem.type() != 0xFFFF && ssiItem.waitingAuth() == false && onlineStatus().status() == Kopete::OnlineStatus::Unknown ) { //make sure they're offline setPresenceTarget( Oscar::Presence( Oscar::Presence::Offline ) ); } AIMContactBase::setSSIItem( ssiItem ); } void AIMContact::slotUserInfo() { if ( !m_infoDialog) { m_infoDialog = new AIMUserInfoDialog( this, static_cast( account() ), Kopete::UI::Global::mainWidget() ); if( !m_infoDialog ) return; - connect( m_infoDialog, SIGNAL(finished()), this, SLOT(closeUserInfoDialog()) ); + connect(m_infoDialog, &AIMUserInfoDialog::finished, this, &AIMContact::closeUserInfoDialog); m_infoDialog->show(); if ( mAccount->isConnected() ) { mAccount->engine()->requestAIMProfile( contactId() ); mAccount->engine()->requestAIMAwayMessage( contactId() ); } } else m_infoDialog->raise(); } void AIMContact::userInfoUpdated( const QString& contact, const UserDetails& details ) { if ( Oscar::normalize( contact ) != Oscar::normalize( contactId() ) ) return; kDebug(OSCAR_RAW_DEBUG) << contact; setNickName( contact ); kDebug( OSCAR_AIM_DEBUG ) << "extendedStatus is " << details.extendedStatus(); Oscar::Presence presence = mProtocol->statusManager()->presenceOf( details.extendedStatus(), details.userClass() ); setPresenceTarget( presence ); m_mobile = ( presence.flags() & Oscar::Presence::Wireless ); setAwayMessage( details.personalMessage() ); if ( presence.type() != Oscar::Presence::Online && m_details.awaySinceTime() < details.awaySinceTime() ) //prevent cyclic away message requests { mAccount->engine()->requestAIMAwayMessage( contactId() ); } OscarContact::userInfoUpdated( contact, details ); } void AIMContact::userOnline( const QString& userId ) { if ( Oscar::normalize( userId ) == Oscar::normalize( contactId() ) ) { kDebug(OSCAR_RAW_DEBUG) << "Getting more contact info"; setPresenceTarget( Oscar::Presence( Oscar::Presence::Online ) ); } } void AIMContact::userOffline( const QString& userId ) { if ( Oscar::normalize( userId ) == Oscar::normalize( contactId() ) ) { m_details.clear(); kDebug(OSCAR_AIM_DEBUG) << "Setting " << userId << " offline"; setPresenceTarget( Oscar::Presence( Oscar::Presence::Offline ) ); removeProperty( mProtocol->statusMessage ); } } void AIMContact::updateProfile( const QString& contact, const QString& profile ) { if ( Oscar::normalize( contact ) != Oscar::normalize( contactId() ) ) return; setProperty( mProtocol->clientProfile, profile ); emit updatedProfile(); } void AIMContact::gotWarning( const QString& contact, quint16 increase, quint16 newLevel ) { //somebody just got bitchslapped! :O Q_UNUSED( increase ); if ( Oscar::normalize( contact ) == Oscar::normalize( contactId() ) ) m_warningLevel = newLevel; //TODO add a KNotify event after merge to HEAD } void AIMContact::closeUserInfoDialog() { m_infoDialog->deleteLater(); m_infoDialog = nullptr; } void AIMContact::warnUser() { QString nick = displayName(); QString message = i18n( "Would you like to warn %1 anonymously or with your name?
" \ "(Warning a user on AIM will result in a \"Warning Level\"" \ " increasing for the user you warn. Once this level has reached a" \ " certain point, they will not be able to sign on. Please do not abuse" \ " this function, it is meant for legitimate practices.)
", nick ); int result = KMessageBox::questionYesNoCancel( Kopete::UI::Global::mainWidget(), message, i18n( "Warn User %1?", nick ), KGuiItem( i18n( "Warn Anonymously" ) ), KGuiItem( i18n( "Warn" ) ) ); if ( result == KMessageBox::Yes ) mAccount->engine()->sendWarning( contactId(), true); else if ( result == KMessageBox::No ) mAccount->engine()->sendWarning( contactId(), false); } void AIMContact::slotVisibleTo() { account()->engine()->setVisibleTo( contactId(), m_actionVisibleTo->isChecked() ); } void AIMContact::slotInvisibleTo() { account()->engine()->setInvisibleTo( contactId(), m_actionInvisibleTo->isChecked() ); } diff --git a/protocols/oscar/aim/aimjoinchat.cpp b/protocols/oscar/aim/aimjoinchat.cpp index 665167779..3b3f50e58 100644 --- a/protocols/oscar/aim/aimjoinchat.cpp +++ b/protocols/oscar/aim/aimjoinchat.cpp @@ -1,97 +1,97 @@ // aimjoinchat.cpp // Copyright (C) 2005 Matt Rogers // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA // 02110-1301 USA #include "aimjoinchat.h" #include #include #include "ui_aimjoinchatbase.h" #include "aimaccount.h" AIMJoinChatUI::AIMJoinChatUI( AIMAccount* account, QWidget* parent ) : KDialog( parent ) { setCaption( i18n( "Join AIM Chat Room" ) ); setButtons( KDialog::Cancel | KDialog::User1 ); setDefaultButton( KDialog::User1 ); setButtonGuiItem( KDialog::User1, KGuiItem( i18n("Join") ) ); showButtonSeparator( true ); kDebug(OSCAR_AIM_DEBUG) << "Account " << account->accountId() << " joining a chat room" << endl; m_account = account; QWidget* w = new QWidget( this ); m_joinUI = new Ui::AIMJoinChatBase(); m_joinUI->setupUi( w ); setMainWidget( w ); - QObject::connect( this, SIGNAL(user1Clicked()), this, SLOT(joinChat()) ); - QObject::connect( this, SIGNAL(cancelClicked()), this, SLOT(closeClicked()) ); + QObject::connect(this, &AIMJoinChatUI::user1Clicked, this, &AIMJoinChatUI::joinChat); + QObject::connect(this, &AIMJoinChatUI::cancelClicked, this, &AIMJoinChatUI::closeClicked); } AIMJoinChatUI::~AIMJoinChatUI() { m_exchanges.clear(); delete m_joinUI; } void AIMJoinChatUI::setExchangeList( const QList& list ) { m_exchanges = list; QStringList exchangeList; QList::const_iterator it = list.begin(); while ( it != list.end() ) { exchangeList.append( QString::number( ( *it ) ) ); ++it; } m_joinUI->exchange->insertItems( 0, exchangeList ); } void AIMJoinChatUI::joinChat() { m_roomName = m_joinUI->roomName->text(); int item = m_joinUI->exchange->currentIndex(); m_exchange = m_joinUI->exchange->itemText( item ); emit closing( QDialog::Accepted ); } void AIMJoinChatUI::closeClicked() { //hmm, do nothing? emit closing( QDialog::Rejected ); } QString AIMJoinChatUI::roomName() const { return m_roomName; } QString AIMJoinChatUI::exchange() const { return m_exchange; } diff --git a/protocols/oscar/aim/aimuserinfo.cpp b/protocols/oscar/aim/aimuserinfo.cpp index 7a1067243..957e00a13 100644 --- a/protocols/oscar/aim/aimuserinfo.cpp +++ b/protocols/oscar/aim/aimuserinfo.cpp @@ -1,226 +1,227 @@ /* oscaruserinfo.cpp - Oscar Protocol Plugin Copyright (c) 2002 by Tom Linsky Kopete (c) 2002 by the Kopete developers ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ************************************************************************* */ #include "aimuserinfo.h" #include "aimaccount.h" #include "aimcontact.h" #include "aimprotocol.h" #include "ui_aiminfobase.h" #include #include #include #include #include #include - +#include #include #include #include #include #include -AIMUserInfoDialog::AIMUserInfoDialog( Kopete::Contact *c, AIMAccount *acc, QWidget *parent ) +AIMUserInfoDialog::AIMUserInfoDialog(AIMContact *c, AIMAccount *acc, QWidget *parent) : KDialog( parent ) { setCaption( i18n( "User Information on %1" , c->displayName() ) ); setButtons( KDialog::Cancel | KDialog::Ok ); setDefaultButton(KDialog::Ok); showButtonSeparator(true); kDebug(14200) << "for contact '" << c->contactId() << "'"; m_contact = c; mAccount = acc; QWidget* w = new QWidget( this ); mMainWidget = new Ui::AIMUserInfoWidget(); mMainWidget->setupUi( w ); setMainWidget( w ); - QObject::connect(this, SIGNAL(okClicked()), this, SLOT(slotSaveClicked())); - QObject::connect(this, SIGNAL(user1Clicked()), this, SLOT(slotUpdateClicked())); - QObject::connect(this, SIGNAL(cancelClicked()), this, SLOT(slotCloseClicked())); - QObject::connect(c, SIGNAL(updatedProfile()), this, SLOT(slotUpdateProfile())); - QObject::connect(c, SIGNAL(statusMessageChanged(Kopete::Contact*)), this, SLOT(slotUpdateProfile())); + QObject::connect(this, &AIMUserInfoDialog::okClicked, this, &AIMUserInfoDialog::slotSaveClicked); + QObject::connect(this, &AIMUserInfoDialog::user1Clicked, this, &AIMUserInfoDialog::slotUpdateClicked); + QObject::connect(this, &AIMUserInfoDialog::cancelClicked, this, &AIMUserInfoDialog::slotCloseClicked); + QObject::connect(c, &AIMContact::updatedProfile, this, &AIMUserInfoDialog::slotUpdateProfile); + QObject::connect(c, &AIMContact::statusMessageChanged, this, &AIMUserInfoDialog::slotUpdatedStatus); mMainWidget->txtScreenName->setText( c->contactId() ); mMainWidget->txtNickName->setText( c->customName() ); if(m_contact == mAccount->myself()) // edit own account profile { mMainWidget->lblWarnLevel->hide(); mMainWidget->txtWarnLevel->hide(); mMainWidget->lblIdleTime->hide(); mMainWidget->txtIdleTime->hide(); mMainWidget->lblOnlineSince->hide(); mMainWidget->txtOnlineSince->hide(); mMainWidget->txtAwayMessage->hide(); mMainWidget->lblAwayMessage->hide(); userInfoView=0L; mMainWidget->userInfoFrame->setFrameStyle(QFrame::NoFrame | QFrame::Plain); QVBoxLayout *l = new QVBoxLayout(mMainWidget->userInfoFrame); l->setContentsMargins( 0, 0, 0, 0 ); userInfoEdit = new KTextEdit(QString(), mMainWidget->userInfoFrame); AIMMyselfContact* aimmc = dynamic_cast( c ); if ( aimmc ) userInfoEdit->setPlainText( aimmc->userProfile() ); else userInfoEdit->setPlainText( QString() ); setButtonText(Ok, i18n("&Save Profile")); showButton(User1, false); l->addWidget(userInfoEdit); } else { userInfoEdit=0L; mMainWidget->userInfoFrame->setFrameStyle(QFrame::NoFrame | QFrame::Plain); QVBoxLayout *l = new QVBoxLayout(mMainWidget->userInfoFrame); l->setContentsMargins( 0, 0, 0, 0 ); userInfoView = new QTextBrowser(mMainWidget->userInfoFrame); userInfoView->setObjectName("userInfoView"); - //KF5 PORT ME userInfoView->setNotifyClick(true); - QObject::connect( - userInfoView, SIGNAL(urlClick(QString)), - this, SLOT(slotUrlClicked(QString))); - QObject::connect( - userInfoView, SIGNAL(mailClick(QString,QString)), - this, SLOT(slotMailClicked(QString,QString))); + userInfoView->setOpenLinks(true); + QObject::connect(userInfoView, &QTextBrowser::anchorClicked, this, &AIMUserInfoDialog::slotUrlClicked); + // This is not doing anything at present as in their slots they are unused. + // QObject::connect(userInfoView, SIGNAL(mailClick(QString,QString)), this, SLOT(slotMailClicked(QString,QString))); showButton(Cancel, false); setButtonText(Ok, i18n("&Close")); setEscapeButton(Ok); l->addWidget(userInfoView); if(m_contact->isOnline()) { // Update the user view to indicate that we're requesting the user's profile userInfoView->setPlainText(i18n("Requesting User Profile, please wait...")); } - QTimer::singleShot(0, this, SLOT(slotUpdateProfile())); + QTimer::singleShot(0, this, &AIMUserInfoDialog::slotUpdateProfile); } } AIMUserInfoDialog::~AIMUserInfoDialog() { delete mMainWidget; kDebug(14200) << "Called."; } void AIMUserInfoDialog::slotUpdateClicked() { kDebug(14200) << "Called."; QString newNick = mMainWidget->txtNickName->text(); QString currentNick = m_contact->displayName(); if ( newNick != currentNick ) { - //m_contact->rename(newNick); - //emit updateNickname(newNick); + m_contact->setNickName(newNick); + emit updateNickname(newNick); setCaption(i18n("User Information on %1", newNick)); } } void AIMUserInfoDialog::slotSaveClicked() { kDebug(14200) << "Called."; if (userInfoEdit) { // editable mode, set profile QString newNick = mMainWidget->txtNickName->text(); QString currentNick = m_contact->displayName(); if(!newNick.isEmpty() && ( newNick != currentNick ) ) { - //m_contact->rename(newNick); - //emit updateNickname(newNick); + m_contact->setNickName(newNick); + emit updateNickname(newNick); setCaption(i18n("User Information on %1", newNick)); } mAccount->setUserProfile(userInfoEdit->toPlainText()); } emit closing(); } void AIMUserInfoDialog::slotCloseClicked() { kDebug(14200) << "Called."; emit closing(); } void AIMUserInfoDialog::slotUpdateProfile() { kDebug(14152) << "Got User Profile."; AIMProtocol* p = static_cast( mAccount->protocol() ); QString awayMessage = m_contact->property( p->statusMessage ).value().toString(); mMainWidget->txtAwayMessage->setHtml( awayMessage ); if ( awayMessage.isNull() ) { mMainWidget->txtAwayMessage->hide(); mMainWidget->lblAwayMessage->hide(); } else { mMainWidget->txtAwayMessage->show(); mMainWidget->lblAwayMessage->show(); } QString onlineSince = m_contact->property("onlineSince").value().toString(); - //QString onlineSince = m_details.onlineSinceTime().toString(); mMainWidget->txtOnlineSince->setText( onlineSince ); AIMContact* c = static_cast( m_contact ); mMainWidget->txtIdleTime->setText(c->formattedIdleTime()); mMainWidget->txtWarnLevel->setText(QString::number(c->warningLevel())); QString contactProfile = m_contact->property( p->clientProfile ).value().toString(); if ( contactProfile.isNull() ) { contactProfile = i18n("No user information provided"); } if(userInfoEdit) { userInfoEdit->setPlainText(contactProfile); } else if(userInfoView) { userInfoView->setHtml(contactProfile); } } -//KRun changed, so comment it so it compiles FIXME -void AIMUserInfoDialog::slotUrlClicked(const QString &url) +void AIMUserInfoDialog::slotUpdatedStatus(const Kopete::Contact* contact) +{ + Q_UNUSED(contact); + slotUpdateProfile(); +} + +void AIMUserInfoDialog::slotUrlClicked(const QUrl &url) { - Q_UNUSED(url); - //new KRun(KUrl(url)); + QDesktopServices::openUrl(url); } +//KRun changed, so comment it so it compiles FIXME void AIMUserInfoDialog::slotMailClicked(const QString&, const QString &address) { Q_UNUSED(address); //new KRun(KUrl(address)); } diff --git a/protocols/oscar/aim/aimuserinfo.h b/protocols/oscar/aim/aimuserinfo.h index 02ec43945..d12ef336e 100644 --- a/protocols/oscar/aim/aimuserinfo.h +++ b/protocols/oscar/aim/aimuserinfo.h @@ -1,57 +1,59 @@ /* oscaruserinfo.h - Oscar Protocol Plugin Copyright (c) 2002 by Tom Linsky Kopete (c) 2002 by the Kopete developers ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ************************************************************************* */ #ifndef AIMUSERINFO_H #define AIMUSERINFO_H #include +#include "aimcontact.h" namespace Kopete { class Contact; } namespace Ui { class AIMUserInfoWidget; } class QTextBrowser; class KTextEdit; class AIMAccount; class AIMUserInfoDialog : public KDialog { Q_OBJECT public: - AIMUserInfoDialog(Kopete::Contact *c, AIMAccount *acc, QWidget *parent = nullptr); + AIMUserInfoDialog(AIMContact *c, AIMAccount *acc, QWidget *parent = nullptr); ~AIMUserInfoDialog(); private: AIMAccount *mAccount; - Kopete::Contact* m_contact; + AIMContact* m_contact; Ui::AIMUserInfoWidget *mMainWidget; QTextBrowser *userInfoView; KTextEdit *userInfoEdit; private Q_SLOTS: void slotSaveClicked(); void slotCloseClicked(); void slotUpdateClicked(); void slotUpdateProfile(); - void slotUrlClicked(const QString&); + void slotUpdatedStatus(const Kopete::Contact*); + void slotUrlClicked(const QUrl&); void slotMailClicked(const QString&, const QString&); Q_SIGNALS: -// void updateNickname(const QString &); + void updateNickname(const QString &); void closing(); }; #endif diff --git a/protocols/oscar/aim/icqcontact.cpp b/protocols/oscar/aim/icqcontact.cpp index 436cc8bc8..06deb2252 100644 --- a/protocols/oscar/aim/icqcontact.cpp +++ b/protocols/oscar/aim/icqcontact.cpp @@ -1,187 +1,187 @@ /* icqontact.cpp - Oscar Protocol Plugin Copyright (c) 2003 by Stefan Gehn Copyright (c) 2003 by Olivier Goffart Copyright (c) 2006,2007 by Roman Jarosz Kopete (c) 2003-2007 by the Kopete developers ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ************************************************************************* */ #include "icqcontact.h" #include #include #include #include #include #include "kopetemetacontact.h" #include "aimprotocol.h" #include "aimaccount.h" #include "oscarutils.h" #include "contactmanager.h" #include "oscarstatusmanager.h" ICQContact::ICQContact( Kopete::Account* account, const QString &name, Kopete::MetaContact *parent, const QString& icon ) : ICQContactBase( account, name, parent, icon ) { mProtocol = static_cast(protocol()); setPresenceTarget( Oscar::Presence( Oscar::Presence::Offline, Oscar::Presence::ICQ ) ); QObject::connect( mAccount->engine(), SIGNAL(loggedIn()), this, SLOT(loggedIn()) ); //QObject::connect( mAccount->engine(), SIGNAL(userIsOnline(QString)), this, SLOT(userOnline(QString,UserDetails)) ); QObject::connect( mAccount->engine(), SIGNAL(userIsOffline(QString)), this, SLOT(userOffline(QString)) ); QObject::connect( mAccount->engine(), SIGNAL(receivedUserInfo(QString,UserDetails)), this, SLOT(userInfoUpdated(QString,UserDetails)) ); } ICQContact::~ICQContact() { } void ICQContact::setSSIItem( const OContact& ssiItem ) { if ( ssiItem.waitingAuth() ) setOnlineStatus( mProtocol->statusManager()->waitingForAuth() ); if ( ssiItem.type() != 0xFFFF && ssiItem.waitingAuth() == false && onlineStatus().status() == Kopete::OnlineStatus::Unknown ) { //make sure they're offline setPresenceTarget( Oscar::Presence( Oscar::Presence::Offline, Oscar::Presence::ICQ ) ); } ICQContactBase::setSSIItem( ssiItem ); } void ICQContact::userInfoUpdated( const QString& contact, const UserDetails& details ) { //kDebug(OSCAR_AIM_DEBUG) << contact << contactId(); if ( Oscar::normalize( contact ) != Oscar::normalize( contactId() ) ) return; // invalidate old away message if user was offline if ( !isOnline() ) removeProperty( mProtocol->statusMessage ); kDebug( OSCAR_AIM_DEBUG ) << "extendedStatus is " << details.extendedStatus(); Oscar::Presence presence = mProtocol->statusManager()->presenceOf( details.extendedStatus(), details.userClass() ); setPresenceTarget( presence ); setAwayMessage( details.personalMessage() ); if ( presence.type() != Oscar::Presence::Online && m_details.awaySinceTime() < details.awaySinceTime() ) //prevent cyclic away message requests { mAccount->engine()->requestAIMAwayMessage( contactId() ); } //TODO: don't know if we need this in aim // if ( details.dcOutsideSpecified() ) // { // if ( details.dcExternalIp().isUnspecified() ) // removeProperty( mProtocol->ipAddress ); // else // setProperty( mProtocol->ipAddress, details.dcExternalIp().toString() ); // } if ( details.capabilitiesSpecified() ) setProperty( mProtocol->clientFeatures, details.clientName() ); OscarContact::userInfoUpdated( contact, details ); } void ICQContact::userOnline( const QString& userId ) { if ( Oscar::normalize( userId ) != Oscar::normalize( contactId() ) ) return; kDebug(OSCAR_AIM_DEBUG) << "Setting " << userId << " online"; setPresenceTarget( Oscar::Presence( Oscar::Presence::Online, Oscar::Presence::ICQ ) ); } void ICQContact::userOffline( const QString& userId ) { if ( Oscar::normalize( userId ) != Oscar::normalize( contactId() ) ) return; m_details.clear(); kDebug(OSCAR_AIM_DEBUG) << "Setting " << userId << " offline"; if ( m_ssiItem.waitingAuth() ) setOnlineStatus( mProtocol->statusManager()->waitingForAuth() ); else setPresenceTarget( Oscar::Presence( Oscar::Presence::Offline, Oscar::Presence::ICQ ) ); removeProperty( mProtocol->statusMessage ); } void ICQContact::loggedIn() { if ( metaContact()->isTemporary() ) return; if ( m_ssiItem.waitingAuth() ) setOnlineStatus( mProtocol->statusManager()->waitingForAuth() ); } bool ICQContact::isReachable() { return true; } QList *ICQContact::customContextMenuActions() { QList *actions = new QList(); m_actionVisibleTo = new KToggleAction(i18n("Always &Visible To"), this ); //, "actionVisibleTo"); - QObject::connect( m_actionVisibleTo, SIGNAL(triggered(bool)), this, SLOT(slotVisibleTo()) ); + QObject::connect(m_actionVisibleTo, &KToggleAction::triggered, this, &ICQContact::slotVisibleTo); m_actionInvisibleTo = new KToggleAction(i18n("Always &Invisible To"), this ); //, "actionInvisibleTo"); - QObject::connect( m_actionInvisibleTo, SIGNAL(triggered(bool)), this, SLOT(slotInvisibleTo()) ); + QObject::connect(m_actionInvisibleTo, &KToggleAction::triggered, this, &ICQContact::slotInvisibleTo); bool on = account()->isConnected(); m_actionVisibleTo->setEnabled(on); m_actionInvisibleTo->setEnabled(on); ContactManager* ssi = account()->engine()->ssiManager(); m_actionVisibleTo->setChecked( ssi->findItem( m_ssiItem.name(), ROSTER_VISIBLE )); m_actionInvisibleTo->setChecked( ssi->findItem( m_ssiItem.name(), ROSTER_INVISIBLE )); actions->append(m_actionVisibleTo); actions->append(m_actionInvisibleTo); // temporary action collection, used to apply Kiosk policy to the actions KActionCollection tempCollection((QObject*)0); tempCollection.addAction(QLatin1String("oscarContactAlwaysVisibleTo"), m_actionVisibleTo); tempCollection.addAction(QLatin1String("oscarContactAlwaysInvisibleTo"), m_actionInvisibleTo); return actions; } void ICQContact::slotVisibleTo() { account()->engine()->setVisibleTo( contactId(), m_actionVisibleTo->isChecked() ); } void ICQContact::slotInvisibleTo() { account()->engine()->setInvisibleTo( contactId(), m_actionInvisibleTo->isChecked() ); } diff --git a/protocols/oscar/aim/ui/aimaddcontactpage.cpp b/protocols/oscar/aim/ui/aimaddcontactpage.cpp index 0b1c9cd47..28bac46cd 100644 --- a/protocols/oscar/aim/ui/aimaddcontactpage.cpp +++ b/protocols/oscar/aim/ui/aimaddcontactpage.cpp @@ -1,102 +1,102 @@ /*************************************************************************** description ------------------- begin : copyright : (C) 2002 by nbetcher email : nbetcher@usinternet.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "aimaddcontactpage.h" #include "ui_aimaddcontactui.h" #include "kopeteaccount.h" #include #include "oscarutils.h" AIMAddContactPage::AIMAddContactPage(bool connected, QWidget *parent) : AddContactPage(parent) { m_gui = 0; if(connected) { m_gui = new Ui::aimAddContactUI(); m_gui->setupUi(this); - connect( m_gui->icqRadioButton, SIGNAL(toggled(bool)), m_gui->icqEdit, SLOT(setEnabled(bool)) ); - connect( m_gui->aimRadioButton, SIGNAL(toggled(bool)), m_gui->aimEdit, SLOT(setEnabled(bool)) ); + connect(m_gui->icqRadioButton, &QRadioButton::toggled, m_gui->icqEdit, &QLineEdit::setEnabled); + connect(m_gui->aimRadioButton, &QRadioButton::toggled, m_gui->aimEdit, &QLineEdit::setEnabled); m_gui->aimEdit->setFocus(); canadd = true; } else { QVBoxLayout *layout = new QVBoxLayout( this ); layout->setContentsMargins( 0, 0, 0, 0 ); layout->addWidget( new QLabel(i18n("You need to be connected to be able to add contacts.\nConnect to the AIM network and try again."), this) ); canadd = false; } } AIMAddContactPage::~AIMAddContactPage() { delete m_gui; } bool AIMAddContactPage::validateData() { if ( !canadd ) return false; if ( !m_gui ) return false; if ( m_gui->icqRadioButton->isChecked() ) { ulong uin = m_gui->icqEdit->text().toULong(); if ( uin < 1000 ) { KMessageBox::sorry( this, i18n("You must enter a valid ICQ number."), i18n("ICQ Plugin") ); return false; } return true; } else if ( m_gui->aimRadioButton->isChecked() ) { QRegExp rx("^[0-9]*$"); if ( rx.exactMatch( m_gui->aimEdit->text() ) ) { KMessageBox::sorry( this, i18n("You must enter a valid AOL screen name."), i18n("No Screen Name") ); return false; } return true; } return false; } bool AIMAddContactPage::apply(Kopete::Account *account, Kopete::MetaContact *metaContact) { if ( m_gui->icqRadioButton->isChecked() ) { QString contactId = Oscar::normalize( m_gui->icqEdit->text() ); return account->addContact( contactId, metaContact, Kopete::Account::ChangeKABC ); } else if ( m_gui->aimRadioButton->isChecked() ) { QString contactId = Oscar::normalize( m_gui->aimEdit->text() ); return account->addContact( contactId, metaContact, Kopete::Account::ChangeKABC ); } return false; } diff --git a/protocols/oscar/aim/ui/aimeditaccountwidget.cpp b/protocols/oscar/aim/ui/aimeditaccountwidget.cpp index 060d62297..14c824ce9 100644 --- a/protocols/oscar/aim/ui/aimeditaccountwidget.cpp +++ b/protocols/oscar/aim/ui/aimeditaccountwidget.cpp @@ -1,228 +1,228 @@ #include "aimeditaccountwidget.h" #include "ui_aimeditaccountui.h" #include #include #include #include #include #include #include #include #include #include #include "kopetepassword.h" #include "kopetepasswordwidget.h" #include "aimprotocol.h" #include "aimaccount.h" #include "oscarprivacyengine.h" AIMEditAccountWidget::AIMEditAccountWidget( AIMProtocol *protocol, Kopete::Account *account, QWidget *parent ) : QWidget( parent ), KopeteEditAccountWidget( account ) { //kDebug(14152) << "Called."; mAccount = dynamic_cast( account ); mProtocol = protocol; m_visibleEngine = 0; m_invisibleEngine = 0; // create the gui (generated from a .ui file) mGui = new Ui::aimEditAccountUI(); mGui->setupUi( this ); // Read in the settings from the account if it exists if ( mAccount ) { mGui->mPasswordWidget->load( &mAccount->password() ); mGui->edtAccountId->setText( account->accountId() ); //Remove me after we can change Account IDs (Matt) mGui->edtAccountId->setReadOnly( true ); mGui->mAutoLogon->setChecked( account->excludeConnect() ); QString serverEntry = account->configGroup()->readEntry( "Server", "login.oscar.aol.com" ); int portEntry = account->configGroup()->readEntry( "Port", 5190 ); if ( serverEntry != "login.oscar.aol.com" || portEntry != 5190 ) mGui->optionOverrideServer->setChecked( true ); else mGui->optionOverrideServer->setChecked( false ); mGui->edtServerAddress->setText( serverEntry ); mGui->sbxServerPort->setValue( portEntry ); using namespace AIM::PrivacySettings; int privacySetting = mAccount->configGroup()->readEntry( "PrivacySetting", int(AllowAll) ); switch( privacySetting ) { case AllowAll: mGui->rbAllowAll->setChecked( true ); break; case AllowMyContacts: mGui->rbAllowMyContacts->setChecked( true ); break; case AllowPremitList: mGui->rbAllowPerimtList->setChecked( true ); break; case BlockAll: mGui->rbBlockAll->setChecked( true ); break; case BlockAIM: mGui->rbBlockAIM->setChecked( true ); break; case BlockDenyList: mGui->rbBlockDenyList->setChecked( true ); break; default: mGui->rbAllowAll->setChecked( true ); } //set filetransfer stuff bool configChecked = mAccount->configGroup()->readEntry( "FileProxy", true ); mGui->chkFileProxy->setChecked( configChecked ); int configValue = mAccount->configGroup()->readEntry( "FirstPort", 5190 ); mGui->sbxFirstPort->setValue( configValue ); //mGui->sbxFirstPort->setDisabled( configChecked ); configValue = mAccount->configGroup()->readEntry( "LastPort", 5199 ); mGui->sbxLastPort->setValue( configValue ); //mGui->sbxLastPort->setDisabled( configChecked ); configValue = mAccount->configGroup()->readEntry( "Timeout", 10 ); mGui->sbxTimeout->setValue( configValue ); if ( mAccount->engine()->isActive() ) { m_visibleEngine = new OscarPrivacyEngine( mAccount, OscarPrivacyEngine::Visible ); m_visibleEngine->setAllContactsView( mGui->visibleAllContacts ); m_visibleEngine->setContactsView( mGui->visibleContacts ); - QObject::connect( mGui->visibleAdd, SIGNAL(clicked()), m_visibleEngine, SLOT(slotAdd()) ); - QObject::connect( mGui->visibleRemove, SIGNAL(clicked()), m_visibleEngine, SLOT(slotRemove()) ); + QObject::connect(mGui->visibleAdd, &QPushButton::clicked, m_visibleEngine, &OscarPrivacyEngine::slotAdd); + QObject::connect(mGui->visibleRemove, &QPushButton::clicked, m_visibleEngine, &OscarPrivacyEngine::slotRemove); m_invisibleEngine = new OscarPrivacyEngine( mAccount, OscarPrivacyEngine::Invisible ); m_invisibleEngine->setAllContactsView( mGui->invisibleAllContacts ); m_invisibleEngine->setContactsView( mGui->invisibleContacts ); - QObject::connect( mGui->invisibleAdd, SIGNAL(clicked()), m_invisibleEngine, SLOT(slotAdd()) ); - QObject::connect( mGui->invisibleRemove, SIGNAL(clicked()), m_invisibleEngine, SLOT(slotRemove()) ); + QObject::connect(mGui->invisibleAdd, &QPushButton::clicked, m_invisibleEngine, &OscarPrivacyEngine::slotAdd); + QObject::connect(mGui->invisibleRemove, &QPushButton::clicked, m_invisibleEngine, &OscarPrivacyEngine::slotRemove); } // Hide the register UI if editing an existing account mGui->registrationGroupBox->hide(); } - QObject::connect( mGui->buttonRegister, SIGNAL(clicked()), this, SLOT(slotOpenRegister()) ); + QObject::connect(mGui->buttonRegister, &QPushButton::clicked, this, &AIMEditAccountWidget::slotOpenRegister); if ( !mAccount || !mAccount->engine()->isActive() ) { mGui->visibleTab->setEnabled( false ); mGui->invisibleTab->setEnabled( false ); } /* Set tab order to password custom widget correctly */ QWidget::setTabOrder( mGui->edtAccountId, mGui->mPasswordWidget->mRemembered ); QWidget::setTabOrder( mGui->mPasswordWidget->mRemembered, mGui->mPasswordWidget->mPassword ); QWidget::setTabOrder( mGui->mPasswordWidget->mPassword, mGui->mAutoLogon ); } AIMEditAccountWidget::~AIMEditAccountWidget() { delete m_visibleEngine; delete m_invisibleEngine; delete mGui; } Kopete::Account *AIMEditAccountWidget::apply() { kDebug( 14152 ) << "Called."; // If this is a new account, create it if ( !mAccount ) { kDebug( 14152 ) << "creating a new account"; QString newId = mGui->edtAccountId->text(); mAccount = new AIMAccount( mProtocol, newId ); } mGui->mPasswordWidget->save( &mAccount->password() ); mAccount->setExcludeConnect( mGui->mAutoLogon->isChecked() ); // save the autologon choice if ( mGui->optionOverrideServer->isChecked() ) { static_cast( mAccount )->setServerAddress( mGui->edtServerAddress->text().trimmed() ); static_cast( mAccount )->setServerPort( mGui->sbxServerPort->value() ); } else { static_cast( mAccount )->setServerAddress( "login.oscar.aol.com" ); static_cast( mAccount )->setServerPort( 5190 ); } using namespace AIM::PrivacySettings; int privacySetting = AllowAll; if ( mGui->rbAllowAll->isChecked() ) privacySetting = AllowAll; else if ( mGui->rbAllowMyContacts->isChecked() ) privacySetting = AllowMyContacts; else if ( mGui->rbAllowPerimtList->isChecked() ) privacySetting = AllowPremitList; else if ( mGui->rbBlockAll->isChecked() ) privacySetting = BlockAll; else if ( mGui->rbBlockAIM->isChecked() ) privacySetting = BlockAIM; else if ( mGui->rbBlockDenyList->isChecked() ) privacySetting = BlockDenyList; mAccount->configGroup()->writeEntry( "PrivacySetting", privacySetting ); mAccount->setPrivacySettings( privacySetting ); //set filetransfer stuff bool configChecked = mGui->chkFileProxy->isChecked(); mAccount->configGroup()->writeEntry( "FileProxy", configChecked ); int configValue = mGui->sbxFirstPort->value(); mAccount->configGroup()->writeEntry( "FirstPort", configValue ); configValue = mGui->sbxLastPort->value(); mAccount->configGroup()->writeEntry( "LastPort", configValue ); configValue = mGui->sbxTimeout->value(); mAccount->configGroup()->writeEntry( "Timeout", configValue ); if ( mAccount->engine()->isActive() ) { if ( m_visibleEngine ) m_visibleEngine->storeChanges(); if ( m_invisibleEngine ) m_invisibleEngine->storeChanges(); } return mAccount; } bool AIMEditAccountWidget::validateData() { //kDebug(14152) << "Called."; QString userName = mGui->edtAccountId->text(); QString server = mGui->edtServerAddress->text(); int port = mGui->sbxServerPort->value(); if ( userName.length() < 1 ) return false; if ( port < 1 ) return false; if ( server.length() < 1 ) return false; // Seems good to me //kDebug(14152) << "Account data validated successfully."; return true; } void AIMEditAccountWidget::slotOpenRegister() { KToolInvocation::invokeBrowser( QString::fromLatin1("http://my.screenname.aol.com/_cqr/login/login.psp?siteId=snshomepage&mcState=initialized&createSn=1") ); }