Private() { protocol = new FakeProtocol( KComponentData(QCString("test-kopete-message")), 0L, "test-kopete-message"); account = new FakeAccount(protocol, QString("testaccount"), 0); // Create fake meta/contacts myselfMetaContact = new Kopete::MetaContact(); myself = new FakeContact(account, "bob@localhost", myselfMetaContact); myself->setNickName("Bob"); otherMetaContact = new Kopete::MetaContact(); other = new FakeContact(account, "audrey@localhost", otherMetaContact); other->setNickName("Audrey"); myselfMetaContact->setDisplayName("Bob"); myselfMetaContact->setDisplayNameSource(Kopete::MetaContact::SourceCustom); otherMetaContact->setDisplayName("Audrey"); otherMetaContact->setDisplayNameSource(Kopete::MetaContact::SourceCustom); Kopete::ContactPtrList contactList; contactList.append(other); // Create fakeChatSession fakeChatSession = Kopete::ChatSessionManager::self()->create(myself, contactList, 0); fakeChatSession->setDisplayName("Test Session"); // Create testStyle testStyle = new ChatWindowStyle(QString(SRCDIR)+QString("/TestStyle")); }
Kopete::ChatSession * GroupWiseContact::manager( Kopete::Contact::CanCreateFlags canCreate ) { //kDebug() << "called, canCreate: " << canCreate; Kopete::ContactPtrList chatMembers; chatMembers.append( this ); return account()->chatSession( chatMembers, QString("")/*FIXME Check this is right*/, canCreate ); }
void FacebookContact::receivedMessage( const QString &message ) { Kopete::ContactPtrList contactList; contactList.append( account()->myself() ); // Create a Kopete::Message Kopete::Message newMessage( this, contactList ); newMessage.setPlainBody( message ); newMessage.setDirection( Kopete::Message::Inbound ); // Add it to the manager manager(CanCreate)->appendMessage(newMessage); }
void TestbedContact::receivedMessage( const QString &message ) { // Create a Kopete::Message Kopete::Message *newMessage; Kopete::ContactPtrList contactList; account(); contactList.append( account()->myself() ); newMessage = new Kopete::Message( this, contactList, message, Kopete::Message::Inbound ); // Add it to the manager manager()->appendMessage (*newMessage); delete newMessage; }
Kopete::ChatSession * WlmContact::manager (Kopete::Contact::CanCreateFlags canCreate) { Kopete::ContactPtrList chatmembers; chatmembers.append (this); Kopete::ChatSession * _manager = Kopete::ChatSessionManager::self ()-> findChatSession (account ()->myself (), chatmembers, protocol ()); WlmChatSession *manager = qobject_cast <WlmChatSession *>(_manager); if (!manager && canCreate == Kopete::Contact::CanCreate) { manager = new WlmChatSession (protocol (), account ()->myself (), chatmembers); } return manager; }
void FacebookAccount::slotMessageAvailable( const Facebook::ChatMessage &message ) { QFont msgFont; QDateTime msgDT; Kopete::ContactPtrList justMe; // outgoing or incoming if ( message.from() == m_service->userId() ) { kDebug(FBDBG) << "got own sent message back (ack)"; // outgoing, we get our own messages back // we should use this for confirmation or something // like that } else if ( message.to() == m_service->userId() ) { // incoming if( !contact( message.from() ) ) { // this would be rare... receiving a message from unknown buddy kDebug(FBDBG) << "Adding contact " << message.from(); addContact( message.from(), message.from(), 0L, Kopete::Account::Temporary ); } if (message.time().toTime_t() == 0) msgDT = QDateTime( QDate::currentDate(), QTime::currentTime(), Qt::LocalTime ); else msgDT = message.time(); Kopete::ChatSession *mm = contact(message.from())->manager(Kopete::Contact::CanCreate); // Tell the message manager that the buddy is done typing mm->receivedTypingMsg(contact(message.from()), false); justMe.append(myself()); Kopete::Message kmsg(contact(message.from()), justMe); kmsg.setTimestamp( msgDT ); kmsg.setPlainBody( message.text() ); kmsg.setDirection( Kopete::Message::Inbound ); mm->appendMessage(kmsg); } }
Kopete::ChatSession* FacebookContact::manager( CanCreateFlags canCreateFlags ) { kDebug( FBDBG ) ; Kopete::ContactPtrList chatmembers; chatmembers.append (this); Kopete::ChatSession * m_msgManager = Kopete::ChatSessionManager::self()->findChatSession (account()->myself(), chatmembers, protocol()); FacebookChatSession *manager = qobject_cast <FacebookChatSession *>(m_msgManager); if (!manager && canCreateFlags == Kopete::Contact::CanCreate) { //Kopete::ChatSession::Form form = ( m_type == Group ? // Kopete::ChatSession::Chatroom : Kopete::ChatSession::Small ); //m_msgManager = Kopete::ChatSessionManager::self()->create(account()->myself(), contacts, protocol(), form ); m_msgManager = new FacebookChatSession(protocol(), account()->myself(), chatmembers, static_cast<FacebookAccount *>( account() )->service() ); connect(m_msgManager, SIGNAL(destroyed()), this, SLOT(slotChatSessionDestroyed())); } return m_msgManager; }
Kopete::ChatSession *JabberGroupMemberContact::manager ( Kopete::Contact::CanCreateFlags canCreate ) { if ( mManager ) return mManager; if ( !mManager && !canCreate ) return 0; Kopete::ContactPtrList chatMembers; chatMembers.append ( this ); /* * FIXME: We might have to use the groupchat contact here instead of * the global myself() instance for a correct representation. */ mManager = new JabberChatSession ( protocol(), static_cast<JabberBaseContact *>(account()->myself()), chatMembers ); connect ( mManager, SIGNAL (destroyed(QObject*)), this, SLOT (slotChatSessionDeleted()) ); return mManager; }