diff -r c84cf270c54f -r 92ab7f8d0eab phoneuis/bubblemanager2/tsrc/bubbletest2/bubbletester.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phoneuis/bubblemanager2/tsrc/bubbletest2/bubbletester.cpp Fri Mar 19 09:28:42 2010 +0200 @@ -0,0 +1,141 @@ +/*! +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Animated icon. +* +*/ + +#include + +#include "bubbletester.h" + + +BubbleTester::BubbleTester() : mLocalSocket(new QLocalSocket()) +{ +} + +BubbleTester::~BubbleTester() +{ + mLocalSocket->disconnectFromServer(); + delete mLocalSocket; +} + +bool BubbleTester::connectToServer() +{ + mLocalSocket->connectToServer("bubbletestserver"); + + // This logic needs to be improved + bool success = mLocalSocket->waitForConnected(500); + + qDebug() << "Socket Connect status: " << success; + + if (success) { + connect(mLocalSocket, SIGNAL(readyRead()), this, SLOT(readData())); + } + + return success; +} + +void BubbleTester::readData() +{ + QByteArray inputByteArray = mLocalSocket->readAll(); + QDataStream inputDataStream(inputByteArray); + QString textDocument; + inputDataStream >> textDocument; + + QString errorStr; + int errorLine; + int errorColumn; + + if (!mDomDocument.setContent(textDocument, true, &errorStr, &errorLine, + &errorColumn)) { + qDebug() << "Cannot read tester data!"; + } else { + emit dataChanged(); + } +} + +QList BubbleTester::bubbles() +{ + QDomNodeList list = mDomDocument.elementsByTagName("bubble"); + + QList testBubbles; + + for (int i=0; i