amonchakai / Hg10

Hg10 -- A XMPP Client for BlackBerry 10 (aiming Google Talk)
20 stars 11 forks source link

Unable to Connect to Internal XMPP Server (Balance) - Support For Workspace (Proxy Detection) #42

Closed Stonedge closed 9 years ago

Stonedge commented 9 years ago

I'm unable to connect to internal server using the mds connection (provided by BES Server), Did I miss Something?

So I've searched for a solution...

Here my founding:

In case of a BB10 over BES server it would be great to support the Secure Workspace Proxy. I've encounter setup where the xmpp server was internal only, on a device setup using balance their an proxy availiable to secure apps(installed in workspace) that offer connection to the internal server Since the Qxmpp Library support QNetworkProxy::setApplicationProxy this should not be an hard modification.

Here how to get automatically the proxy setting (would work also for personal zone too):

// Set up proxy if we need one
// Code from httpProxy sample
netstatus_proxy_details_t details;
memset(&details, 0, sizeof(details));
bool proxyWasNotRequired = false;
if (netstatus_get_proxy_details(&details) != BPS_FAILURE) {
    /* if proxy is required, then set proxy */
    if (details.http_proxy_host == NULL) {
        proxyWasNotRequired = true;
        qDebug() << "No proxy required!";
    } else {
        // Create proxy and set details as available
        _proxy = new QNetworkProxy();
        _proxy->setType(QNetworkProxy::HttpProxy);
        _proxy->setHostName(details.http_proxy_host);
        if (details.http_proxy_port != 0) {
            _proxy->setPort(details.http_proxy_port);
        }
        if (details.http_proxy_login_user != NULL) {
            _proxy->setUser(details.http_proxy_login_user);
        }
        if (details.http_proxy_login_password != NULL) {
            _proxy->setPassword(details.http_proxy_login_passw​ord);
        }
    }
} else {
    qDebug() << "Error attempting to get proxy details";
}

The only step missing is to set the application proxy: QNetworkProxy::setApplicationProxy(_proxy);

Having an check box in the advanced settings named "Internal Server (Workspace)" Could be great to enable and disable.

amonchakai commented 9 years ago

Hi,

Thanks a lot for this contribution! Sure, I can add something like this for the next release.

amonchakai commented 9 years ago

done. should be ok.