finished QNetworkAccessManager signal is not shooting in expansion bb10

Hi all

I created plugin (native extension) network in which there is a file moc also to load the slot of signal feature. This extension is done following tasks:

1 entry for Javascript.

var jsonData = {"url": "'https://cors-test.appspot.com/test ', "timeOutValue": 4"};

2 launches a thread extension and call the function of demand on the system from here. Here is the code snippet for same.

void* SignalThread(void* parent) {
    TemplateJS *pParent = static_cast(parent);

    int argc = 0;
    char **argv = NULL;
    QCoreApplication QCoreApplication(argc, argv);
    webworks::TemplateNDK *m_signalHandler = new webworks::TemplateNDK(pParent);
    m_signalHandler->doNetworkRequest();

    QCoreApplication::exec(); //When I try to remove this line extension stops working and when I try to implement quit, application closes.
    delete m_signalHandler;
    return NULL;
}

bool TemplateJS::StartThread(){

    pthread_attr_t thread_attr;
    pthread_attr_init(&thread_attr);
    pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);

    pthread_t m_thread;
    pthread_create(&m_thread, &thread_attr, SignalThread, static_cast(this));
    pthread_attr_destroy(&thread_attr);
    if (!m_thread) {
        return true;
    } else {
        return false;
    }
}

3 doNetworkRequest function more sends the network request to URL and receive the answer in the slot and return to Javascript application

4. If no reply is received between the value of timeout then extension sends "operation cancelled" as info application javascript error

JavaScript application performs tasks:

1. the request is to have two buttons

2. the two buttons are hitting the same function and component the same post.

Question:

This extension works great for first time response and sends to javascript, but when to call the same function second time in the same application, extension sends "operation cancelled" in javascript. For example: if I click on the Test button it sent a response but if I click the Test1 button after getting response Test button it returns the message "transaction cancelled".

If timeout is removed from the extension, then it returns nothing and stuck somewhere.

What I found in the extension is, connect statement returns true both times.

QObject::connect (_networkAccessManager, SIGNAL (finished(QNetworkReply*)),
This, SLOT (onRequestFinished(QNetworkReply*)));

By extension, control comes after below line. But not a response to the onRequestFinished location.

Answer QNetworkReply * = _networkAccessManager-> get (request);

Please let me know what I am doing wrong.

This is a very urgent and major of my application implementation.

Help, please

Thanks in advance.

Question is due to every javascript function call new pthread is be created every time and existing thread is never destroyed. However, I assumed that this local variable of pthread_t destroyed but it is not run like that. If trying to kill thread existing manually using pthread_cancel(), application crashes. Application of network function is called in this thread and QNetworkAccessManager slot is never get called except for the first time.

To solve it, I used a public global variable that allow to create the thread only once and give the signal for the following applications when native code receives a StartThread function call. For signalling, used pthread mutex lock and characteristic signal.

Here is the code for the function StartThread:

bool TemplateJS::StartThread()
{

    parseJsonParams();

    if (!g1.g_isSignalThreadCreated) {
        g1.g_isSignalThreadCreated = true;

        pthread_attr_t thread_attr;
        pthread_attr_init(&thread_attr);
        pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
        pthread_t m_thread;
        pthread_create(&m_thread, &thread_attr, SignalThread, static_cast(this));
        pthread_attr_destroy(&thread_attr);

    } else {
        pthread_mutex_lock(&mutex);
        pthread_cond_signal(&cond);
        pthread_mutex_unlock(&mutex);

    }
    return true;
}

And here's the code must call after event notification.

void TemplateNDK::Workerthread_waitForNextTime()
    {
        pthread_mutex_lock(&mutex);
        pthread_cond_wait(&cond, &mutex);
        pthread_mutex_unlock(&mutex);

        //keeps waiting here until get Signal from StartThread.
        doNetworkRequest();
    }

Tags: BlackBerry Developers

Similar Questions

  • InvokeTargetReply finished() signal not shooting?

    I have a problem like that in the original post in this thread:

    http://supportforums.BlackBerry.com/T5/native-development/invokation-framework-slot-for-signal-Finis...

    The poster of thread apparently solved their problem for their use case by invoking a card instead of an application, but this solution is not suitable for my use case - I simply invoke a basic application, by using a reusable code taken right out of BlackBerry tutorials, and apparently, so the launch of base app, finished() signal is not emitted.  This seems so basic that I expect others have run across it, and there is a subtle touch that is not sufficiently covered in the tutorials.

    Code:

    void ApplicationUI::launchCoreApp() {
    
        qDebug() << "The launchCoreApp() method was called";
    
        bb::system::InvokeManager invokemanager;
        bb::system::InvokeRequest request;
    
        request.setAction("bb.action.OPEN");
        request.setTarget("sys.browser");
        request.setUri("http://www.blackberry.com");
    
        bb::system::InvokeTargetReply *reply = invokemanager.invoke(request);
    
        if(reply) {
            if(reply->isFinished()) {
                qDebug() << "In launchCoreApp(), reply finished before we could connect signal to handler slot";
            } else {
                qDebug() << "In launchCoreApp(), connecting reply finished signal to handler slot";
                bool ok = connect(reply, SIGNAL(finished()), this, SLOT(onInvokeTargetFinished()));
                Q_ASSERT(ok);
            }
    
        }
    
    }
    
    void ApplicationUI::onInvokeTargetFinished() {
        qDebug() << "The onInvokeTargetFinished() slot was reached";
    }
    

    Note that this is just a test code and I didn't intend to instantiate a new InvokeManager on each call to the launchCoreApp() function - I just need to see how things work.

    So, when I run the above, launches the browser and goes to the provided URI, my debug console told me that the value of reply-> isFinished() is false, so my code takes the branch to connect the finished() signal to the onInvokeTargetFinished() slot.

    However, the slot is apparently never called, not the browser launch and not when I close the browser.

    It's reusable code light directly from the tutorials and docs, but it doesn't seem to work as announced.

    When subtle I'm missing?

    Where in the lifecycle of the invocation request response is the finished() signal is supposed to be issued?  The reference docs are very clear on this - they just say it is issued when the response message is "received", whatever that means (I understand that it is a future model, I'm not clear which is received in the life cycle integer invocation response).

    I am compiling against level API 10.2 BTW.

    I work, the only thing needed is to define the parent for the response, otherwise it will be deleted at the end of the function where it is created.

        bb::system::InvokeTargetReply *reply = invokemanager.invoke(request);
        reply->setParent(this);
    

    The parent is responsible to remove the answer, so be sure to remove it in your home.

    void ApplicationUI::onInvokeTargetFinished() {
        qDebug() << "The onInvokeTargetFinished() slot was reached";
        bb::system::InvokeTargetReply *reply = qobject_cast(sender());
        reply->deleteLater();
    }
    
  • HDR5010KB-digital recorder - signal does not always come through the use of HDMI

    Hello

    I bought the product above in October. Since then, I have had intermittent problems. When switching on the channel AV on my TV (a Panasonic TX-P42S20B) signal is not always crossed when you use the HDMI channel (I also connected via a SCART, and who works so always seems to be a problem HDMI.) It is particularly obvious when the recorder has been used for a while (be it for recording or playback.) It is not overheating (or if this is the case, not to the degree I get a warning message) and turn off the power to the electric network seems to correct the problem, but it's a pain.

    I tried to change the hdmi cable, as well as to try different channels AV on my TV and it did not help. Is this a common problem or make me a defective unit?

    Any suggestion would be appreciated

    Have you noticed the same problem using other devices connected to your TV (using the same cable)?

  • Script of not shooting

    Hi all

    I'm new to the application development and still in the learning phase, I began with the construction of the example Hello World for OS 7 and made a few tweaks for coding by adding additional features and by invoking the native maps app. When I upgraded to a Q10 I then carried on the application successfully to OS10 and decided to give him the native look and feel by using BBUI.js, but in doing so, it seems that one of the javascripts is not shooting.

    I tried all kinds of variations to rewrite the code but still no joy. I even used web Inspector, but it does not report them to the top of all the problems.

    If someone is able to help my coding how would you like to see.

    What about Dave

    Hello

    I solved my problem by setting a preference of background color in my config file

    Its a steep learning curve.

    Thank you

  • I am trying to be moved from the first, but in the list of adobe programs to download, rather than see the installation option, there is only the opportunity to evaluate, and once the download is finished the program will not open. What should I do to dow

    I am trying to be moved from the first, but in the list of adobe programs to download, rather than see the installation option, there is only the opportunity to evaluate, and once the download is finished the program will not open. What should I do to download the first?

    If you have a first subscription (check here, Adobe ID) and you have a 64-bit computer, Troubleshooting FAQ: what should I do if I have a subscription, but my application acts as if I had a trial?

  • itemEditEnd not shooting in DataGrid

    In a specific DataGrid is not shooting - all others in my work as an app very well. I got another Flex developer to look at my code just in case I go crazy or something and he thinks that it is a bug in the Flex framework somewhere I use Flex Builder 2.0.1 FWIW


    The following isolated code has the same behavior (breakpoint in onEdit event listener func does not trigger). A large part of it may seem superfluous, but in a real application, it is necessary in the real application (I just tried to isolate the cause!).

    Any ideas?

    Quote:

    <? XML version = "1.0" encoding = "utf-8"? >
    "" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml '
    creationComplete = "onInit (); »
    >
    < mx:Canvas
    ' xmlns:MX =' http://www.adobe.com/2006/mxml '
    xmlns:WOCCU = "" org.WOCCU.Components. * ""
    Width = "100%" height = "100%" id = "ccc".
    paddingTop = paddingLeft = "0" "0" paddingRight = "0".
    >
    < mx:Script >
    <! [CDATA]
    Import mx.events.DataGridEvent;
    Import mx.events.DataGridEventReason;
    Import mx.collections.ArrayCollection;

    DataProvider
    private var _dp:ArrayCollection;

    This will contain a table (hash) accessible by bottombar or somesync
    [Bindable]
    public var bottomBar:Array;

    public function onInit (): void
    {
    _dp = new collection ArrayCollection ([{PK: 'Mast', label: "XXX" col1: 'Matthews', col2: 'XEXE', level: 1}]);
    entrygrid.dataProvider = _dp;
    trace ('init');

    }


    public void refresh (): void
    {
    TODO: check if the ID of the entity and other accessories are not empty!
    Refresh the content or somesync
    }

    Callback function - when the data arrives
    protected function onData(result:Array):void
    {
    Built our dataprovider or somesync
    var tmpDPRow:Array;
    var _bottomBar:Array = new Array();
    _dp = new ArrayCollection();

    for (var j: String in result) {}
    First of all, check level. If 0 this bottombar line belongs.
    If (result [j] ['level'] == '0') {}
    pk: String var = result [j] ['PK'];
    PK = PK. Replace("-","_"); n ' is not valid in the ID of the object, to replace us with _
    _bottomBar [pk] = new Object();
    _bottomBar [pk] ['label'] is result [j] ['label'];.
    _bottomBar [pk] ['value'] is [j] result ['col2'];.
    } else {}
    Go on the fields
    tmpDPRow = new Array();
    tmpDPRow ["PK"] = result [j] ['PK'];
    tmpDPRow ['label'] = result [j] ['label'];
    tmpDPRow ["col1"] = result [j] ["col1"];
    tmpDPRow ['col2'] = result [j] ['col2'];
    _dp. AddItem (tmpDPRow);
    }
    }

    Apply the lower bar
    this.bottomBar = _bottomBar;
    Apply to all the data to the datagrid control
    this.entrygrid.dataProvider = _dp;

    }

    public void onEdit(event:DataGridEvent):void {}

    trace ("fire on the whole!");
    If (event.reason == DataGridEventReason.CANCELLED) {}
    return;
    }

    SHOULD any EMERGENCY UPDATE frickin database!
    This.Refresh (); Subtotals have changed - need to update
    }


    []] >
    < / mx:Script >
    <!--
    Note the hack below: column widths are ridiculously large values
    The idea is that Flex will resize down and maintain proportions
    ->
    "" < mx:DataGrid xmlns:mx = ' http://www.adobe.com/2006/mxml '
    Width = "100%" height = "100%" showHeaders = 'false' itemEditEnd = "onEdit (event)" id = "entrygrid" > "
    < mx:columns >
    < mx:DataGridColumn = "0" visible width is 'false' dataField is 'PK' >
    < / mx:DataGridColumn >
    < mx:DataGridColumn width = "70000" itemRenderer = "mx.controls.TextInput" editable = "false" dataField = "label" > "
    < / mx:DataGridColumn >
    < mx:DataGridColumn width = "15000" itemRenderer = "mx.controls.TextInput" editable = "false" dataField = "col1" > "
    < / mx:DataGridColumn >

    < mx:DataGridColumn width = "15000" itemRenderer = "mx.controls.TextInput" rendererIsEditor = "true" editable = "true" dataField = "col2" > "
    < / mx:DataGridColumn >
    < / mx:columns >
    < / mx:DataGrid >
    < / mx:Canvas >
    < / mx:Application >
  • Finished SystemToast SIGNAL not

    No idea why this is happening? Is this a bug?

    void HelpPage::showToastNotification()
    {
        SystemToast *toast = new SystemToast(this);
        toast->setBody("Success.");
        toast->button()->setLabel("Open");
    
        QObject::connect(toast, SIGNAL(finished(SystemUiResult::Type)),
                this,  SLOT(onToastFinished(SystemUiResult::Type)));
    
        toast->show();
    }
    
    void HelpPage::onToastFinished(bb::system::SystemUiResult::Type result)
    {
          showDialog("Test","Success"); //THIS LINE NEVER GETS CALLED
    
          SystemToast *toast = qobject_cast(sender());
          toast->deleteLater();
    }
    

    Hello

    Use namespace in the list of parameters.

    all

    public slots:          void onToastFinished(bb::system::SystemUiResult::Type);
    

    .cpp

    #include "applicationui.hpp"
    
    #include 
    #include 
    
    using namespace bb::cascades;
    using namespace bb::system;
    
    ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
            QObject(app) {
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
        qml->setContextProperty("app", this);
        root = qml->createRootObject();
        app->setScene(root);
    
        SystemToast *toast = new SystemToast(this);
        toast->setBody("Success.");
        toast->button()->setLabel("Open");
    
        QObject::connect(toast, SIGNAL(finished(bb::system::SystemUiResult::Type)), this,
                SLOT(onToastFinished(bb::system::SystemUiResult::Type)));
    
        toast->show();
    }
    
    void ApplicationUI::onToastFinished(bb::system::SystemUiResult::Type result) {
        qDebug() << "Got it";
        SystemToast *toast = qobject_cast(sender());
        toast->deleteLater();
    }
    

  • finish the signal for a toast of system?

    Here

    http://developer.BlackBerry.com/Cascades/reference/bb__system__systemtoast.html#function-finished-VA...

    It says that you can do something once the toast of the system is done.

    I have a toast built and displayed in a function of the CPP.

    {...
    bb::system::SystemToast *toast = new SystemToast(this);
    toast->setBody("Yippie!");
    toast->show();
    ...
    }
    

    How I code so I can get this signal? I've been java dong before so I'm a little lost with RPC. I got the toast works well in my application. The QML calls the RPC function. So I want to do it all in the PRC not in QML.

    Try:

    Somewhere in your PPS file...

    #include 
    #include public slots:
        void onSTFinished(bb::system::SystemUiResult::Type);
    

    Somewhere in your cpp file...

    #include 
    #include using namespace bb::system;
    
    ........    bool res = connect(toast,                    SIGNAL(finished(bb::system::SystemUiResult::Type)),                    this,                    SLOT(onSTFinished(bb::system::SystemUiResult::Type)));    Q_ASSERT(res);    Q_UNUSED(res);........ 
    
    void yourClass::onSTFinished(bb::system::SystemUiResult::Type uiResult){     // Do something with uiResult or ... another... }
    
  • Leaves open and closing signals do not seem to work

    Of the clues as to what special qml/qt/cascades magical thing you need to do to get the sheet open and closed signals to deliver?

    The Basic code fragment is

    Sheet sheet is iNewSheet-> Construct();.
    bool ok = connect (sheet, SIGNAL (closed ()), this, SLOT (onSheetClosed ()));
    Q_ASSERT (OK);
    OK = Connect (Sheet, signal (Opened ()), this, slot (onSheetOpened ()));
    Q_ASSERT (OK);
    sheet-> open();

    Both links it seem to work - as in there is no assert.

    The sheet is open ok, but no signal is transmitted

    The sheet can be closed ok, but no closed signal is transmitted.

    We also tried the openedChanged() signal, but that doesn't seem to be delivered either

    If any readers

    No idea what we have changed but the

    Plug finished animation + is now open and the

    Care ended animatng + is now completely closed

    signals which do not seem to work previously now work.

    We can only guess its something to do with the parameters of the method 'connect' or maybe the location of the statements of breeders or possibly using "Q_SLOTS" and not statement 'niche roles' or some other thing random Qt that would be taken by either the preprocessor, the compiler C runtime connect() returns value or other tools applied to the CBC to he mangle in Qt code.

    What exactly is the problem with normal standard C++ interface inheritance for most of these?

  • signal does not

    I have a sheet declared in my QML file, which has the id "splashscreen.

    When my application is performing a calculation task intensive, I signal of working().

    I have this code attached to the main element of my QML file:

    onCreationCompleted: {}
    _encryptedattachment.finished.connect (splashscreen. Close);
    Console.log ("Connected");
    }

    If I open the application via an invoke on a file that needs deciphering, the

    _encryptedattachment. Working.Connect (splashscreen. Open);

    do not open the splashscreen, even if the event is raised (I checked in the debugger that the code)

    issue of working()

    is executed).

    UPDATE:

    I changed the code as follows:

    onCreationCompleted: {}
    SplashScreen. Open();
    _encryptedattachment. Working.Connect (showSplash);
    _encryptedattachment.finished.connect (hideSplash);
    Console.log ("Connected");
    }
    function showSplash() {}
    Console.log ("open splashscreen");
    SplashScreen. Open();
    }
    function hideSplash() {}
    Console.log ("narrow splashscreen");
    SplashScreen. Close();
    }

    all log messages were printed in the location provided, but the journal has never reopened. Is this a bug in the system?

    OK, I found the problem. Decryption of long-term blocked user interface updates, something I thought was ok because I use an external process to make decryption.

    The solution was to add QCoreApplication:rocessEvents(). to the decryption loop.

  • Programmatically trigger a structure of the event with the value (signaling) is not responding

    Hey, in my attached program I check if the two steps of translation are in a specific position. If Yes, I want my code to execute a sequence of movements. If this isn't the case, I'm asking the user if he wants contributed from this position anyway. It has three options: Yes, go to load (the specific position) and cancel. If he hits Yes, I am using a property of signal value which should update the controls Boolean true, allowing the sequence. Cancellation and work "to load" perfectly fine, but 'Yes' does not work. I think I need a structure of the event to ahndle the value of the Boolean control 'x' change event, however, the addition of this structure of the event for some reason any even do not allow me to click on the Start button of the procedure.
    Thanks for any help in advance.
    Doug

    Really, you should look into using a State Machine.  You should have really not what happens inside a structure of the event.

    In addition, I would like to use a shift register to store this value instead of a front panel control.

  • Error to the element of the queue with simulated signal, but not with the DAQ hardware

    Hello.  I get an error code 1 when I run my VI in simulation mode, which is only 3 simulate subvis signal at different frequencies.  The block diagram shows jpg file and the probe is after I stop the VI.  Note that there is an invalid refnum.  I don't know why that is.  I am also including the watch of the probe after a few iterations, there is no error on the probe 64 until I stop the VI, and also noted that there have been no queue items.  This of course means that I don't get to remove the data in loop 2.  An interesting note is that the system works fine when I run the program in data acquisition mode, which is the other case behind the 'simulate signals. "  In this case, the only thing is the DAQ assistant and dynamic data of the tunnel cable.  Everyone can't see what I could do wrong?  Thank you.

    Thanks for looking at my post.  I thought about it about five minutes ago.  I didn't have a timeout on the handeler event, so it was not double check for new items in the queue.  I don't know yet why the probe shows showes that items have not put in the queue because they certainly were.  Maybe "queue items 0" means that there are no items saved in the queue. ?

    Your concern is interesting and deserves a check...  I just ran it without registration, and it seems that the release of the case (the default) record structure is just an empty DDT, a placeholder, I guess.

  • The installation of Zoo Tycoon 2 in Windows 7, now I can not install the expansion packs.

    Thanks to the person here who has posted the trick to set virtual memory to 2048, I got edition of Zoo Tycoon 2 guards running. Now that I'm trying to add expansion packs, I get the message that I did not install Zoo Tycoon first, and that I need to install it. What?

    Before using the virtual memory fix, I found here, I tried to run in XP mode, using the also found instructions here. I wonder if this is the reason why I get the error message, and if so, should I uninstall and reinstall without changing the compatibility mode?

    Running Windows 7 Professional 64-bit. I solved my problem by uninstalling Zookeeper Collection, replace and reset maximum memory of 2048.

    Once I thought I had installed as an administrator or as the account of my children, I have had no problem by uninstalling Zookeepers Collection and put it back. Install the expansion packs was easy after that.

    I'm going to bookmark the Zoo Tycoon Support site for later use. Thank you.

  • Why is the trigger of the DAQ signal works not as I expect?

    Using the DAQ Assistant, I have received a signal at a rate of 100 k Hz and number of samples of 75 k. I would like a light every time that the amplitude of the signal falls below 1. As you can see from my attached graph, the amplitude becomes less than 1. However, the light does not turn. Any suggestions on what I'm doing wrong or misunderstanding, that I might have? This is my first project with the DAQ Assistant, then perhaps there is something simple that I'm missing.

    Hello

    The problem in your VI is that you gain 75 k samples, but you check if the second sample is less than 1V.

    This is because the Index Array node, it will give you only a single element of the array, which means a single sample.

    You should take just a sample at a time, or send the table going into a tunnel of indexing. But that could slow things down when you have so many samples.

  • DAQmx generated signal is not continuous

    Hello

    I have a question affecting the DAQmx functions in combination with LabVIEW RT. I use DAQmx write on a target RT is a feature to send an analog signal to the AO0. And what happens is that I only get short impulses whenever the data acquisition function is enabled. Failure is not recognizable when you work with a duration of 1 ms, but when switching to a slower rate, it is clearly visible.

    I am using the following options:

    Sample (on request)

    Terminal config: CSR

    Min 0 V

    V max 4

    Do I have to use the function of synchronization DAQmx or something like that?

    When I use the standard screw RT, the RT Assistant product I can only use the write function DAQmx that it works everything just... tested with a flat structure of sequence with 4 frames, 2 different output signals and 2 for the waiting time. So I think it's a failure of programming...

    I have no idea what my fault is, any suggestions?

    Thank you

    You should definitely use task start and clear job instead of a single write functions.  Take a look at a few examples DAQmx in LV if you don't know what I mean.

    My guess is that, given that you use a single entry and not to perpetuate the task, the task is closed after the writing of single point.  When the task is closed, LV is automatic setting the output to zero.

Maybe you are looking for