Skip to content

Commit 81870c0

Browse files
committed
experimental tweaked version on weupnp
1 parent d72efda commit 81870c0

16 files changed

Lines changed: 1458 additions & 13 deletions

File tree

android.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</configuration>
88
</facet>
99
</component>
10-
<component name="NewModuleRootManager" inherit-compiler-output="false">
10+
<component name="NewModuleRootManager" inherit-compiler-output="true">
1111
<output url="file://$MODULE_DIR$/build/classes/main" />
1212
<output-test url="file://$MODULE_DIR$/build/classes/test" />
1313
<exclude-output />

common/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ dependencies {
66
compile 'log4j:log4j:1.2.17'
77
compile 'org.fourthline.cling:cling-core:2.0.1'
88
compile 'org.fourthline.cling:cling-support:2.0.1'
9+
compile 'org.bitlet:weupnp:0.1.2'
910
compile fileTree(dir: 'libs', include: ['*.jar'])
1011
testCompile 'junit:junit:4.10'
1112
}

common/common.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<orderEntry type="library" exported="" name="log4j-1.2.17" level="project" />
3232
<orderEntry type="library" exported="" name="cling-core-2.0.1" level="project" />
3333
<orderEntry type="library" exported="" name="cling-support-2.0.1" level="project" />
34+
<orderEntry type="library" exported="" name="weupnp-0.1.2" level="project" />
3435
<orderEntry type="library" exported="" name="jackson-annotations-2.3.0" level="project" />
3536
<orderEntry type="library" exported="" name="jackson-core-2.3.3" level="project" />
3637
<orderEntry type="library" exported="" name="seamless-util-1.1.0" level="project" />

common/src/main/java/org/syncloud/common/upnp/Router.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ public interface Router {
99

1010
int getPortMappingsCount();
1111

12-
boolean canToManipulatePorts(String myIp);
12+
boolean canManipulatePorts(String myIp);
1313
}

common/src/main/java/org/syncloud/common/upnp/UPnPFactory.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22

33
import org.fourthline.cling.android.AndroidUpnpServiceConfiguration;
44
import org.syncloud.common.upnp.cling.ClingUPnP;
5+
import org.syncloud.common.upnp.weupnp.WeUPnP;
56

67
public class UPnPFactory {
7-
public static UPnP createUPnP(String name) {
8-
return new ClingUPnP(new AndroidUpnpServiceConfiguration());
8+
public enum TYPE {CLING, WEUPNP}
9+
public static UPnP createUPnP(TYPE type) {
10+
switch (type) {
11+
case CLING:
12+
return new ClingUPnP(new AndroidUpnpServiceConfiguration());
13+
case WEUPNP:
14+
default:
15+
return new WeUPnP();
16+
}
917
}
1018
}

common/src/main/java/org/syncloud/common/upnp/cling/ClingRouter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private <T extends ActionCallback> T sync(UpnpService upnpService, T callback) {
119119
}
120120

121121
@Override
122-
public boolean canToManipulatePorts(String myIp) {
122+
public boolean canManipulatePorts(String myIp) {
123123

124124
final Optional<Long> availableExternalPort = getAvailableExternalPort();
125125
if(!availableExternalPort.isPresent())

common/src/main/java/org/syncloud/common/upnp/cling/ClingUPnP.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
import org.fourthline.cling.UpnpService;
77
import org.fourthline.cling.UpnpServiceConfiguration;
88
import org.fourthline.cling.UpnpServiceImpl;
9+
import org.syncloud.common.upnp.UPnP;
910

10-
public class ClingUPnP implements org.syncloud.common.upnp.UPnP {
11+
public class ClingUPnP implements UPnP {
1112

1213
public static final int TIMEOUT = 60;
1314
private static Logger logger = Logger.getLogger(ClingUPnP.class);

0 commit comments

Comments
 (0)