/*
* Copyright (C) 2010 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
*
* 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 St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include "exampledialog.h"
#include <KDebug>

namespace Test {

ExampleDialog::ExampleDialog(QWidget* parent)
    : QDialog(parent),
      m_dbusConnection(QLatin1String("none"))
{
    setupUi(this);
}

ExampleDialog::~ExampleDialog(){}


bool ExampleDialog::registerExample()
{
    m_example = new Example;
    bool ret = m_dbusConnection.registerObject(QLatin1String("/"), m_example);

    if (!ret) {
        kDebug() << "m_dbusConnection.registerObject: FAIL";
        return false;
    }
    else
        kDebug() << "m_dbusConnection.RegisteredObject: SUCCESS";
    if (m_dbusConnection.objectRegisteredAt(QLatin1String("/")) != m_example) {
        kDebug() << "m_dbusConnection.objectRegisteredAt: FAIL";
        return false;
    }
    else
        kDebug() << "m_dbusConnection.objectRegisteredAt: SUCCESS";

    connect(m_example, SIGNAL(Pong()), this, SLOT(onPong()));
    return true;
}


void ExampleDialog::useExample()
{
    m_exampleClient = new OrgFreedesktopTelepathyQt4ExampleInterface(QLatin1String(""), QLatin1String("/"), m_dbusConnection, 0);
    connect(m_pingButton, SIGNAL(clicked(bool)), m_exampleClient, SLOT(Ping()));
}

void ExampleDialog::onPong()
{
    kDebug();
}


} // end namespace Test
