Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Call one c++ function from app c++ class

I know this is a simple solution, but I haven't figured it out.  Maybe what I am trying to do is the wrong way for c++.

 

I have the applicationui class that handles the main application functions.

I have another class called MarketingService that handles the web service calls and return to store my data to a database.

 

So, far, everything works fine.  I'm able to use the app to get input from the user, store the data locally to the sql database and then send the data to the server the web service.  The issue comes when the ListView needs to be refreshed with the updated status after the web service returns. 

 

Trying this in the trigger doesn't work, because the function doesn't return the web service update complete, so the status hasn't been updated yet before the emit is sent.

 

_marketingWS.insertSalesLead(listNavPage.selectedItemID);
_app.refreshDataModel();

 So, what I want to do is call the _app.refreshDataModel() or maybe even an _app.updateStatus() function in the MarketingService results function. 

 

I have included the applicationui.h file in the MarketingService file. 

I've attempted to create another instance of ApplicationUI.  

ApplicationUI appt = new ApplicationUI();
appt.updateLeadStatus(idValue, "1");

 

I'm not sure what to do to get this fixed.  Refreshing the ListView with the updated data is the end goal.

 

I guess last resort is to put the web service call

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 16,984
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Call one c++ function from app c++ class

There are several options here, but i think the most Qt-like is to use signals and slots.
you can connect a signal from your service to your app class and update the datamodel there.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: Call one c++ function from app c++ class

I think you might be misinterperting what I need to do.

 

The web service result needs to call the function in the ApplicationUI after it finishes.

In the soapXML example, the "app" class handles everything, in my app, I seperated the web service into its own class. 

 

Unless you are saying that I should be able to call the signal in ApplicationUI from MarketingService without creating an instance of the ApplicationUI.

 

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 16,984
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Call one c++ function from app c++ class

I guess you create your marketingservice in the applicationUI class. You can connect its signal there (as you have a reference to both classes)
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: Call one c++ function from app c++ class

That seems to defeat the purpose of seperating out the web service into a different class.

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: Call one c++ function from app c++ class

And doing that apparently didn't fix the initial issue.

 

The ListView still doesn't update after the value has changed.

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: Call one c++ function from app c++ class

Fixed the ListView issue by callin the read list again.

 

I think I will look at the Twitter Timeline example some more to see if that has a fix for the different class for webservice issue.

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 16,984
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Call one c++ function from app c++ class

if you want to access the class from the outside you could create a static accessor, often used in conjunction with a singleton pattern.

example:
LoggerService * LoggerService::instance() {
static LoggerService instance; //private constructor call
return &instance;
}
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter