1

I have a socket connection App in my BB 10 cascades, when ever socket connection is closed i need to show a dialog box and when pressed on OK button app need to close.

please find my code here...

void SocketBase::writeLine(QTcpSocket *socket, const QString &line)
{
if (socket->state() != QAbstractSocket::ConnectedState)
{
       onOkAlert("Please check your internet connection and restart the app again");
}
}

void SocketBase::onOkAlert(const QString &message) {

dialog = new SystemDialog(tr("OK"), 0); 
dialog->setTitle(tr("Alert")); 
dialog->setBody(message); 

 bool success=      QObject::connect(dialog,SIGNAL(finished(bb::system::SystemUiResult::Type)),
                        this,
                SLOT(onDialogFinishe(bb::system::SystemUiResult::Type)));
 if(success){
 dialog->show();
}

}

and I also added at top of my class,

using namespace bb::data;
using namespace bb::cascades;
using namespace bb::system;
SystemDialog *dialog;

and my socketBase.h is like,

    class SocketBase: public QObject{
     Q_OBJECT
    public:
SocketBase(const QString &ipAddr, const ushort port) :
        mIP(ipAddr), mPort(port) {
    mRunThread = false;
}
enum Identity {
    BAD_IDENTITY, SERVER, CLIENT
};
virtual void startThread() = 0;
virtual void stopThread() = 0;
virtual Identity getIdentity() = 0;
 Q_INVOKABLE void showDialog(int id);
 void onOkAlert(const QString &message);

 private slots:
     void onAPPFinished();
     void onDialogFinishe(bb::system::SystemUiResult::Type);
     }

here is the app termination code

 void SocketBase::onDialogFinishe(bb::system::SystemUiResult::Type)
{
qDebug()<<" dialog->result():::"<<dialog->result();
    if(dialog->result()==2)
    {
        qDebug()<<"::: Terminate App :::";
        bb::Application::exit(0);
    }

}

what is wrong in my code, please help!!!

Sharath
  • 315
  • 1
  • 3
  • 13
  • What happens currently? Does it give an error? Does it display the dialog? You havn't pasted the code you are using to close the app, is the app getting to the method onDialogFinishe()? – hyarion Oct 16 '13 at 14:25
  • dialog box is displayed but when ok button pressed onDialogFinishe() is not called – Sharath Oct 17 '13 at 05:53

0 Answers0