Ejemplo n.º 1
0
void MessageSession::resetResource()
{
	m_want_upgrade = true;
	setJid(m_jid.bareJID());
	foreach(MessageFilter *filter, m_filters)
		filter->reset();
}
Ejemplo n.º 2
0
void LiveRosterItem::setRosterItem(const RosterItem &i)
{
	setJid(i.jid());
	setName(i.name());
	setGroups(i.groups());
	setSubscription(i.subscription());
	setAsk(i.ask());
	setIsPush(i.isPush());
}
Ejemplo n.º 3
0
void MessageSession::handleMessage(const Message &message_orig)
{
	Message message = message_orig;
	if(m_want_upgrade && message.from().bare() == m_jid.full())
		setJid(message.from());
	if(m_thread.isEmpty())
	{
		if(message.thread().trimmed().isEmpty())
			message.setThread(m_thread = QLatin1String(Util::randomHash()));
		else
			m_thread = message.thread();
	}
	filter(message);
	if(!message.body().isEmpty())
		emit messageReceived(message);
}
Ejemplo n.º 4
0
Message::Message( QString j, MType t, QWidget *parent, const char *name )
	: QWidget( parent, name )
{
	QSettings settings;
	settings.setPath( "qtlen.sf.net", "QTlen" );
	
	settings.beginGroup( "/window/message" );
	
	resize( settings.readNumEntry( "/width", 400 ),
			settings.readNumEntry( "/height", 450 ) );
	
	settings.resetGroup();
	
	setIcon( QPixmap("msg.png") );
	
	setJid( takeJid( j ) );
	setMType( t );
	
	QBoxLayout *mainLayout = new QVBoxLayout( this, 0, -1, "Main layout for message widget" );
	
	QBoxLayout *topLayout = new QHBoxLayout( this );
	mainLayout->addLayout( topLayout );
	
	QLabel *label = new QLabel( mtype == Message::New ? tr("To:") : tr("From:"), this );
	topLayout->addWidget( label );
	
	QString contactName = roster_manager->getContactName( jid );
	destination = new QLineEdit( contactName.isEmpty() ? jid : contactName+" <"+jid+">", this );
	topLayout->addWidget( destination );
	if( mtype == Message::Revice )
		destination->setReadOnly( true );
	
	QString captionText = tr("Message ");
	captionText += mtype == Message::New ? tr("to: ") : tr("from: ");
	captionText += contactName.isEmpty() ? jid : contactName;
	setCaption( captionText );

	topLayout = new QHBoxLayout( this );
	mainLayout->addLayout( topLayout );
	
	if( mtype == Message::New )
	{
		label = new QLabel( tr("Send as:"), this );
		topLayout->addWidget( label );

		sendAs = new QComboBox( this );
		sendAs->insertItem( takePixmap( "msg" ), tr("Normal") );
		sendAs->insertItem( takePixmap( "msg-chat" ), tr("Chat") );
		sendAs->setCurrentItem( 0 );
		sendAs->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Fixed );
		topLayout->addWidget( sendAs );
	}
	else if( mtype == Message::Revice )
	{
		QBoxLayout *datetimeLayout = new QHBoxLayout( this );
		mainLayout->addLayout( datetimeLayout );

		label = new QLabel( tr("Time:"), this );
		datetimeLayout->addWidget( label );

		datetimeEdit = new QLineEdit( this );
		datetimeEdit->setReadOnly( true );

		datetimeLayout->addWidget( datetimeEdit );
	}

	message = new QTextEdit( this );
	message->setTextFormat( Qt::PlainText );
	mainLayout->addWidget( message );
	if( mtype == Message::Revice )
		message->setReadOnly( true );

	QBoxLayout *buttomLayout = new QHBoxLayout( this );
	mainLayout->addLayout( buttomLayout );

	QPushButton *exitButton = new QPushButton( QIconSet( takePixmap( "close" ) ), tr("Exit"), this );
	exitButton->setFixedWidth( 100 );
	buttomLayout->addWidget( exitButton );

	buttomLayout->addStretch();

	if(destination->text().isEmpty())
		destination->setFocus();
	else
		message->setFocus();

	QPushButton *sendButton = new QPushButton( QIconSet( takePixmap( "send" ) ), mtype == Message::New ? tr("Send") : tr("Reply"), this );
	sendButton->setFixedWidth( 100 );
	buttomLayout->addWidget( sendButton );

	if( t == Message::New )
	connect( sendButton, SIGNAL( released() ),
			SLOT( send() ));
	else
	connect( sendButton, SIGNAL( released() ),
			SLOT( reply() ));

	connect( destination, SIGNAL( textChanged( const QString & ) ),
			SLOT( changeCaption( const QString & ) ) );

	connect( exitButton, SIGNAL( released() ),
			SLOT(close()) );
}