Wednesday, October 28, 2015

XMPP Chat - part one(Connection)

Here I am showing the steps to implement XMPP in to Blackberry 10 Application


  • Download QXMPP source code from here
  • Add required files in to the xmpp folder
  • Add QXmppClient *m_xmppClient; in application.h file
  • Add the following lines to application.cpp file
            m_xmppClient = new QXmppClient;
            QXmppConfiguration config;
            config.setAutoAcceptSubscriptions(true);
            config.setHost("hostname"); //ip added
            config.setDomain("domainname");//example.com
            config.setUser("username");
            config.setPassword("password");
            //config.setAutoReconnectionEnabled(true);
            m_xmppClient->connectToServer(config, QXmppPresence::Available);
            m_xmppClient->logger()->setLoggingType(QXmppLogger::StdoutLogging);
            
            //SIGNALS FOR XMPP CONNECTION
             connect(m_xmppClient, SIGNAL(connected()), this, SLOT(onChatConnected()));
             connect(m_xmppClient, SIGNAL(messageReceived(const QXmppMessage)), this,
                           SLOT(onMessageReceived(const QXmppMessage)));
  • void ApplicationUI::onMessageReceived(const QXmppMessage &message){
             qCritical()<<"Connected to XMPP"
          }




  • Will describe all the methods of XMPP in the next part.....


Tuesday, October 13, 2015

Wait Dialogue in Blackberry 10

Hi All,

  Here is the code for adding an activity indicator in Blackberry 10 like Android Progress Indicator.
This will disable all the components in the UI and show the indicator. This can be used for http requets

here is the code

Activity.qml page

import bb.cascades 1.0
Container {
    background: Color.Transparent
    
    layout: DockLayout {
    
    }
    
    minWidth: 720 // width of the screen
    minHeight: 1280 // height of the screen
    
    Container {
        minWidth: 650
        maxWidth: 650
        minHeight: 100
        maxHeight: 100
        background: Color.create("#a6c8e0")
        horizontalAlignment: HorizontalAlignment.Center
        verticalAlignment: VerticalAlignment.Center
        layout: DockLayout {
            
        }
        Container {
            background: Color.Gray
            minWidth: 646
            maxWidth: 646
            minHeight: 96
            maxHeight: 96
            horizontalAlignment: HorizontalAlignment.Center
            verticalAlignment: VerticalAlignment.Center
            leftPadding: 50
            layout: StackLayout {
                orientation: LayoutOrientation.LeftToRight
            }
            
            ActivityIndicator {
                minWidth: 80
                minHeight: 80
                objectName: "customActivityIndicator"
                horizontalAlignment: HorizontalAlignment.Center
                verticalAlignment: VerticalAlignment.Center
                running: true
            }
            Label {
                verticalAlignment: VerticalAlignment.Center
                text: qsTr("Loading please wait...")
                textStyle.fontSize: FontSize.Small
                textStyle.color: Color.create("#1F2E56")
            }
        }
       
    }
    attachedObjects:[ ImagePaintDefinition {
            id: receiveItem
            imageSource: "asset:///images/info_bg_common.amd"
    }]

}



Following is the method for adding add removing activity indicator in the screen


This is the CPP code

void DialogueUtils::addActivityDialogue()
{
    activityDialogue = new Dialog;
    QmlDocument *qmlacitivity = QmlDocument::create("asset:///Activity.qml");
    activityRootContainer = qmlacitivity->createRootObject<Container>();

    customActivityIndicator = activityRootContainer->findChild<ActivityIndicator*>(
            "customActivityIndicator");
    customActivityIndicator->start();
    activityDialogue->setContent(activityRootContainer);
    activityDialogue->open();
}


void DialogueUtils::removeActivityDialogue()
{
    customActivityIndicator->stop();
    activityDialogue->close();
}


To use this indicator in a page 
dialogueUtils-> addActivityDialogue();

To remove this 
dialogueUtils-> removeActivityDialogue();