VPN Providers integration guide (Experimental)

Posted by Popcorn-Time on August 21, 2015
New features

Integrate Your Android VPN client with Popcorn Time in 5 simple steps:

 

1. Import the popcorn-api.aar to your project.

2. Add “popcorn-api” module to your project’s dependencies

3. Create a class which extends PopcornVpnReceiver. For example:

public class SimplePopcornVpnReceiver extends PopcornVpnReceiver {

    @Override
    protected int getVpnStatus(@NonNull Context context) {
//        Return current state of vpn client (VpnClient.STATUS_CONNECTED, VpnClient.STATUS_DISCONNECTED)
        return VpnClient.STATUS_DISCONNECTED;
    }

    @Override
    protected void onVpnConnect(@NonNull Context context) {
        // Called when popcorn app tell vpn client to connect vpn
    }

    @Override
    protected void onVpnDisconnect(@NonNull Context context) {
        // Called when popcorn app tell vpn client to disconnect vpn
    }
}

 

4. Add PopcornVpnReceiver to manifest:

<receiver android:name=".SimplePopcornVpnReceiver"
android:exported="true">
<intent-filter>
<action android:name="se.popcorn_time.api.action.APP"/>
</intent-filter>
</receiver>

Now your VPN client can receive messages from Popcorn Time.
5. It is recommended to report back to Popcorn Time about status changes. for example:

VpnClient vpnClient = PopcornVpnApi.createClient(getBaseContext());
if (connected) {
   vpnClient.setStatus(VpnClient.STATUS_CONNECTED);
}
else {
   vpnClient.setStatus(VpnClient.STATUS_DISCONNECTED);
}
PopcornVpnApi.sendStatus(getBaseContext(), vpnClient);

 

Integrate Your Desktop VPN client with Popcorn Time in 3 simple steps:

 
1. Import the vpnIntegration.h and vpnIntegration.cpp files to your Qt project, or port the named pipes (Windows) or Unix Domain Sockets (Mac OS X) Qt handlers to plain C/C++.

2. Use

TVpnIntegration::setVpnInstalled( true )

to set your VPN application executable (for VPN service detection).
Don’t forget to call

TVpnIntegration::setVpnInstalled( false )

on VPN client uninstall.

3. Use Qt signals

TVpnIntegrationServer::connectCommand() 
TVpnIntegrationServer::disconnectCommand()

as control source from integrated application, and

TVpnIntegrationServer::onNotifyConnectionStatus( bool )
TVpnIntegrationServer::onAuthFailed()

as data feed to integrated application.

That’s all! Now your VPN client is fully integrated with Popcorn Time!
You can find the full app source code here

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>