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: 146
Registered: ‎07-03-2013
My Device: BB 9360
My Carrier: WIND

BBM Profile Info in NOT main.cpp

So, i was going over the tutorials/samples for registering the app on BBM and it does get registered. I have the registrationHandler object in the main.cpp class. 

now, i have another class which does all the math and some ui stuff. what i want is based on the succesfull registration on BBM and defining userProfile, how can i get the personal message in the other cpp class?
I mean, in the main.cpp, we have:

    RegistrationHandler *registrationHandler = new RegistrationHandler(uuid, &app);

    Profile *profile = new Profile(registrationHandler->context(), &app);

    QObject::connect(registrationHandler, SIGNAL(registered()), profile, SLOT(show()));

 which initates the registrationHandler class and Profile class.

Now if there is a function called personalMessage in the profile class, how can i invoke that method? since we have defined the Profile class in the main.cpp, i want to invoke the personalMessage() in the other cpp class. 

Do i need to re-instantiate in the other cpp class and then call the function?

 

Thanks!

BlackBerry Development Advisor
Posts: 15,117
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: BBM Profile Info in NOT main.cpp

Where is your other class instantiated from?  If it's also from main you could give it a reference to your Profile instance when you create it. 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360
My Carrier: WIND

Re: BBM Profile Info in NOT main.cpp

Yup, my other class is instantiated from the main class too.

so, you mean, pass the profile reference via the object of the other class?

 

Thanks!

BlackBerry Development Advisor
Posts: 15,117
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: BBM Profile Info in NOT main.cpp

Yes, exactly.  Same type thing you are doing when instantiating the Profile class (the BBM Context object gets passed into it).

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360
My Carrier: WIND

Re: BBM Profile Info in NOT main.cpp

Thanks Mark!
I'll try it soon and once satisfied, i will mark it as "accept as solution". 

Developer
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360
My Carrier: WIND

Re: BBM Profile Info in NOT main.cpp

Hey Mark, 

I just tried something like:

 

    OtherMain mainApp;

    mainApp.printValue(profile->personalMessage());

 So, OtherMain is my main class which does all the math. and i am invoking printValue(...) in the OtherMain.cpp with the profile's personal message, but it is causing the application to crash? i can't see the logs why the application crashed. 

but if remove the mainApp.printValue(...) line, it just works fine. 


Any ideas why it is causing it to crash. 

btw, the above snippet is from main.cpp.

 

Thanks

S.

BlackBerry Development Advisor
Posts: 15,117
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: BBM Profile Info in NOT main.cpp

What is printValue doing?  Have you stepped through it?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360
My Carrier: WIND

Re: BBM Profile Info in NOT main.cpp

It is a just a basic function which takes QString as an argument and prints on the console using qDebug() << "MESSAGE " << value;

I will try to debug it more, but is my approach for profile personal message right?

Developer
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360
My Carrier: WIND

Re: BBM Profile Info in NOT main.cpp

Hi Mark, 

in my main.cpp file, i have the following code:

    RegistrationHandler *registrationHandler = new RegistrationHandler(uuid, &app);
    Profile *profile = new Profile(registrationHandler->context(), &app);
    QObject::connect(registrationHandler, SIGNAL(registered()), profile, SLOT(show()));

    myApp mainApp;

 

myApp is the main cpp file that does all the work. i am printing some message as soon as we instantiate the myApp. 

in the logs, i see something weird:

BBMSP Services initialized 
inside UserProfileDelegate::UserProfileDelegate 
inside UtilsDelegate::UtilsDelegate 
 
PRINTING SOME TEXT WHEN myApp is instantiated

84  : Start of Message : PPSMonitor::readyRead 
"@platform
msg::bbm
...
RegistrationEventHandler::pushPermissionEvent : - "Success" - 
ApplicationDelegate::notifyRegistrationEvent "Success" 
Received a BBM Social Platform registration access state= 0 
Ignoring BBM Social Platform access state= 0 when progress= 0 

 So, shouldn't 

PRINTING SOME TEXT WHEN myApp is instantiated

 this be coming at the end once the app is registered with BBM because we are calling myApp after 

    QObject::connect(registrationHandler, SIGNAL(registered()), profile, SLOT(show()));

 

if i print the registrationState in myApp, it gives as "1" which is "unknown". not exactly sure what that means? is it because the app is already registered and we are trying to register again (my running the application again)?

Please suggest.

 

Thanks
S.

BlackBerry Development Advisor
Posts: 15,117
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: BBM Profile Info in NOT main.cpp

This line:

 

QObject::connect(registrationHandler, SIGNAL(registered()), profile, SLOT(show()));

Connects the signal to the slot.  It does not run until the signal is fired by the registration process.  So it sounds like you are trying to print out the profile information before registration is complete.  Make sure you don't call it before show() runs and only if registration was success.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker