Home · All Classes · Grouped Classes · Annotated · Functions

main.cpp Example File
ipc/cannonserver/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>
    #include <QtGlobal>
    #include <cstdlib>

    class CannonListener : public QtopiaIpcAdaptor
    {
        Q_OBJECT

    public:
        CannonListener(QObject *parent = 0);

    public slots:
        void shootCannon(int);

    signals:
        void missed();
        void hit();
    };

    CannonListener::CannonListener(QObject *parent)
        : QtopiaIpcAdaptor("QPE/CannonExample", parent)
    {
        publishAll(QtopiaIpcAdaptor::SignalsAndSlots);
    }

    void CannonListener::shootCannon(int power)
    {
        int pwr = power % 100;
        int roll = qrand() % 100;

        if (pwr >= roll)
            emit hit();
        else
            emit missed();

        deleteLater();
    }

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

        CannonListener *listener = new CannonListener;
        app.registerRunningTask("CannonListener", listener);

        app.exec();
    }

    #include "main.moc"


Copyright © 2008 Nokia Trademarks
Qtopia 4.3.3