Home · All Classes · Grouped Classes · Annotated · Functions

main.cpp Example File
ipc/cannonclient/main.cpp

    /****************************************************************************
    **
    ** This file is part of the Qtopia Phone Edition Package.
    **
    ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
    **
    ** $QT_EXTENDED_DUAL_LICENSE$
    **
    ****************************************************************************/

    #include <QtopiaApplication>
    #include <QDebug>
    #include <QtopiaIpcAdaptor>
    #include <QString>

    class CannonResultListener : public QObject
    {
        Q_OBJECT

    public:
        CannonResultListener(QObject *parent = 0);

    public slots:
        void missed();
        void hit();
    };

    CannonResultListener::CannonResultListener(QObject *parent)
        : QObject(parent)
    {

    }

    void CannonResultListener::missed()
    {
        qDebug() << "Cannon missed.";
        deleteLater();
    }

    void CannonResultListener::hit()
    {
        qDebug() << "Cannon HIT!!!";
        deleteLater();
    }

    int main( int argc, char **argv)
    {
        QtopiaApplication app(argc, argv);

        if (argc != 2) {
            qDebug() << "Please specify the cannonPower argument";
            return 0;
        }

        CannonResultListener *listener = new CannonResultListener;
        QtopiaIpcAdaptor *adaptor = new QtopiaIpcAdaptor("QPE/CannonExample");
        QtopiaIpcAdaptor::connect(adaptor, MESSAGE(missed()), listener, SLOT(missed()));
        QtopiaIpcAdaptor::connect(adaptor, MESSAGE(hit()), listener, SLOT(hit()));

        app.registerRunningTask("CannonResultListener", listener);

        adaptor->send(MESSAGE(shootCannon(int)), QString(argv[1]).toInt());

        app.exec();
        delete adaptor;
    }

    #include "main.moc"


Copyright © 2008 Nokia Trademarks
Qtopia 4.3.3