Пример #1
0
void Conversation::messageReceived(const QXmppMessage &msg)
{
    if (msg.type() != QXmppMessage::Chat ||
        QXmppUtils::jidToBareJid(msg.from()) != m_jid)
        return;

    // handle chat state
    if (msg.state() != m_remoteState) {
        m_remoteState = msg.state();
        emit remoteStateChanged(m_remoteState);
    }

    // handle message body
    if (msg.body().isEmpty())
        return;

    HistoryMessage message;
    message.body = msg.body();
    message.date = msg.stamp();
    if (!message.date.isValid())
        message.date = m_client->serverTime();
    message.jid = m_jid;
    message.received = true;
    if (m_historyModel)
        m_historyModel->addMessage(message);
}
Пример #2
0
MainWindow::MainWindow(QWidget *parent) : KXmlGuiWindow(parent),
	onlineIcon(QLatin1String("liri-status-online")),
	offlineIcon(QLatin1String("liri-status-offline"))
{
	// create the user interface, the parent widget is "widget"
	QWidget *widget = new QWidget( this );
	ui = new Ui::MainWindow;
	ui->setupUi(widget);
	setCentralWidget( widget );
	setupActions();
	setupGUI();
	if (this->toolBar()) this->toolBar()->hide();

	ui->ReceiversView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);

	//create some objects
	dlist = new DBusServiceList();
	dconnection = new DaemonConnection(dlist);
	econnection = new ExecutionConnection(dlist);
	receiverlist = new ReceiverList();
	actionsmodel = new ActionsModel(dconnection, econnection);
	actionsmodelproxy = new KCategorizedSortFilterProxyModel();
	actionsmodelproxy->setCategorizedModel(true);
	actionsmodelproxy->setSourceModel(actionsmodel);

	// setup some connections
	connect(ui->btnReloadRemotes, SIGNAL(clicked(bool)), SLOT(btnReloadRemotes()));
	connect(ui->btnLiridShutdown, SIGNAL(clicked(bool)), SLOT(btnLiridShutdown()));
	connect(ui->btnReloadProfiles, SIGNAL(clicked(bool)), SLOT(btnReloadProfiles()));
	connect(ui->btnExecutionShutdown, SIGNAL(clicked(bool)), SLOT(btnExecutionShutdown()));
	
	connect(ui->btnLiridLogfile, SIGNAL(clicked(bool)), SLOT(btnLiridLogfile()));
	connect(ui->btnExecutionLogfile, SIGNAL(clicked(bool)), SLOT(btnExecutionLogfile()));

	connect(dconnection, SIGNAL( daemonStateChanged(int) ), SLOT( daemonStateChanged(int) ));
	connect(dconnection, SIGNAL( receiverStateChanged(int, int) ), SLOT( receiverStateChanged(int, int) ));
	connect(dconnection, SIGNAL( remoteStateChanged(int, int) ), SLOT( remoteStateChanged(int, int) ));
	
	connect(econnection, SIGNAL( executionStateChanged(int) ), SLOT( executionStateChanged(int) ));

	connect(&fwatcher, SIGNAL( fileChanged(const QString &) ), SLOT( halhelperLogfileChanged() ));

	if (dconnection->getReceiverListInterface()) {
		QList<int> instancelist = dconnection->getReceiverListInterface()->getAllInstances().value();
		foreach(int instanceNr, instancelist) {
			OrgLiriReceiverInterface * const ri = dconnection->getReceiverInterface(instanceNr);
			emit receiverStateChanged(instanceNr, ri->ReceiverState());
			emit remoteStateChanged(instanceNr, ri->RemoteState());
			dconnection->releaseReceiverInterface(instanceNr);
		}