Skip to content

Commit

Permalink
bb: support push_type in clientregister
Browse files Browse the repository at this point in the history
  • Loading branch information
genywind committed Oct 4, 2012
1 parent e2a05d8 commit 4c70b18
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
26 changes: 24 additions & 2 deletions platform/bb/RubyVM/src/com/rho/sync/ClientRegister.java
Expand Up @@ -102,7 +102,8 @@ public String getRegisterBody(String strClientID)throws Exception
int port = RhoConf.getInstance().getInt("push_port");

return SyncThread.getSyncEngine().getProtocol().getClientRegisterBody( strClientID, m_strDevicePin,
port > 0 ? port : DEFAULT_PUSH_PORT, m_sysInfo.getPlatform());
port > 0 ? port : DEFAULT_PUSH_PORT, m_sysInfo.getPlatform(),
isPushServiceEnabled() ? "bis" : "" );
}

private boolean doRegister( SyncEngine oSync )throws Exception
Expand Down Expand Up @@ -147,5 +148,26 @@ private boolean doRegister( SyncEngine oSync )throws Exception
}

return false;
}
}

public static boolean isMDSPushEnabled()
{
if ( !RhoConf.getInstance().isExist("push_options") )
return true;

String strOptions = RhoConf.getInstance().getString("push_options");

return strOptions.indexOf("mds") >= 0;
}

public static boolean isPushServiceEnabled()
{
if ( !RhoConf.getInstance().isExist("push_options") )
return false;

String strOptions = RhoConf.getInstance().getString("push_options");

return strOptions.indexOf("push_service") >= 0;
}

}
2 changes: 1 addition & 1 deletion platform/bb/RubyVM/src/com/rho/sync/ISyncProtocol.java
Expand Up @@ -35,7 +35,7 @@ public interface ISyncProtocol
public abstract String getClientCreateUrl();

public abstract String getClientRegisterUrl();
public abstract String getClientRegisterBody( String strClientID, String strPin, int nPort, String strType );
public abstract String getClientRegisterBody( String strClientID, String strPin, int nPort, String strType, String strPushType );

public abstract String getClientResetUrl(String strClientID);
public abstract String getClientChangesUrl();
Expand Down
5 changes: 3 additions & 2 deletions platform/bb/RubyVM/src/com/rho/sync/SyncProtocol_3.java
Expand Up @@ -61,12 +61,13 @@ public String getClientRegisterUrl()
return RhoConf.getInstance().getPath("syncserver") + "clientregister";
}

public String getClientRegisterBody( String strClientID, String strPin, int nPort, String strType )
public String getClientRegisterBody( String strClientID, String strPin, int nPort, String strType, String strPushType )
{
return "{\"client_id\":" + JSONEntry.quoteValue(strClientID) +
",\"device_pin\":" + JSONEntry.quoteValue(strPin) +
",\"device_port\":\"" + nPort +
"\",\"device_type\":" + JSONEntry.quoteValue(strType) + "}";
"\",\"device_type\":" + JSONEntry.quoteValue(strType) +
"\",\"push_type\":" + JSONEntry.quoteValue(strPushType) + "}";
}

public String getClientResetUrl(String strClientID)
Expand Down
Expand Up @@ -225,7 +225,7 @@ public void onPlatformActivate()
{
if ( com.rho.Capabilities.ENABLE_PUSH )
{
if ( !rhomobile.PushListeningThread.isPushServiceEnabled() )
if ( !com.rho.sync.ClientRegister.isPushServiceEnabled() )
return;

getUiApplication().invokeLater( new Runnable()
Expand Down
20 changes: 0 additions & 20 deletions platform/bb/rhodes/src/rhomobile/PushListeningThread.java
Expand Up @@ -72,26 +72,6 @@ protected synchronized void stop()
}
}

public static boolean isMDSPushEnabled()
{
if ( !RhoConf.getInstance().isExist("push_options") )
return true;

String strOptions = RhoConf.getInstance().getString("push_options");

return strOptions.indexOf("mds") >= 0;
}

public static boolean isPushServiceEnabled()
{
if ( !RhoConf.getInstance().isExist("push_options") )
return false;

String strOptions = RhoConf.getInstance().getString("push_options");

return strOptions.indexOf("push_service") >= 0;
}

public void run()
{

Expand Down
2 changes: 1 addition & 1 deletion platform/bb/rhodes/src/rhomobile/RhodesApplication.java
Expand Up @@ -1462,7 +1462,7 @@ public void run()

if ( com.rho.Capabilities.ENABLE_PUSH )
{
if ( PushListeningThread.isMDSPushEnabled() )
if ( com.rho.sync.ClientRegister.isMDSPushEnabled() )
{
_pushListeningThread = new PushListeningThread();
_pushListeningThread.start();
Expand Down

0 comments on commit 4c70b18

Please sign in to comment.