Commit 99e7fd65 authored by jehan's avatar jehan

registration is back :-)

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@63 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 5b671e3c
......@@ -36,6 +36,7 @@ import javax.security.cert.CertificateException;
import org.apache.log4j.Logger;
import org.linphone.p2pproxy.api.P2pProxyException;
import org.linphone.p2pproxy.core.sipproxy.superpeers.P2pUserRegistrationAdvertisement;
......@@ -203,6 +204,7 @@ public class JxtaNetworkManager {
// associating an advertisement name space with the proper obect
// in this cast the AdvertisementTutorial
AdvertisementFactory.registerAdvertisementInstance(P2pUserProfileAdvertisement.getAdvertisementType(),new P2pUserProfileAdvertisement.Instantiator());
AdvertisementFactory.registerAdvertisementInstance(P2pUserRegistrationAdvertisement.getAdvertisementType(),new P2pUserRegistrationAdvertisement.Instantiator());
mRendezVousService = mNetworkPeerGroup.getRendezVousService();
......
......@@ -185,7 +185,7 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
mProvider=new SipProvider(lViaAddress,lPort,lProto,SipProvider.ALL_INTERFACES);
mProvider.addSipProviderListener(SipProvider.PROMISQUE,this);
mPool = Executors.newCachedThreadPool();
mSuperPeerProxy = new SuperPeerProxy(aJxtaNetworkManager, "sip:"+mProvider.getViaAddress()+":"+mProvider.getPort());
mSuperPeerProxy = new SuperPeerProxy(aJxtaNetworkManager, "sip:"+mProvider.getViaAddress()+":"+mProvider.getPort(),mRegistrationTab);
}
public synchronized void onReceivedMessage(SipProvider aProvider, Message aMessage) {
......@@ -244,8 +244,6 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
}
// add Via only udp
SipUtils.addVia(aProvider,aMessage);
// add recordRoute
SipUtils.addRecordRoute(aProvider,aMessage);
try {
mSuperPeerProxy.proxyRequest(aProvider, aMessage);
}catch (P2pProxyUserNotFoundException e) {
......@@ -295,7 +293,7 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
mRegistrationTab.put(lFromName, lRegistration);
} else {
// create negative answers
mLog.info("account for user ["+lFromName+"not crteated yet");
mLog.info("account for user ["+lFromName+"] not created yet");
Message lresp = MessageFactory.createResponse(aMessage,404,"Not found",null);
lTransactionServer.respondWith(lresp);
return;
......
......@@ -39,7 +39,7 @@ public class JxtaNetworkResources {
JxtaNetworkResources (String aUserName, JxtaNetworkManager aJxtaNetworkManager,String aRegistrarAddress) {
mJxtaNetworkManager = aJxtaNetworkManager;
mP2pUserRegistrationAdvertisement = (P2pUserRegistrationAdvertisement) AdvertisementFactory.newAdvertisement(P2pUserProfileAdvertisement.getAdvertisementType());
mP2pUserRegistrationAdvertisement = (P2pUserRegistrationAdvertisement) AdvertisementFactory.newAdvertisement(P2pUserRegistrationAdvertisement.getAdvertisementType());
mP2pUserRegistrationAdvertisement.setID(IDFactory.newCodatID(mJxtaNetworkManager.getPeerGroup().getPeerGroupID(), aUserName.toString().getBytes()));
mP2pUserRegistrationAdvertisement.setUserName(aUserName.toString());
mP2pUserRegistrationAdvertisement.setRegistrarAddress(aRegistrarAddress.toString());
......
......@@ -36,6 +36,7 @@ import org.zoolu.sip.address.SipURL;
import org.zoolu.sip.header.Header;
import org.zoolu.sip.header.MultipleHeader;
import org.zoolu.sip.header.RecordRouteHeader;
import org.zoolu.sip.header.RequestLine;
import org.zoolu.sip.header.RouteHeader;
import org.zoolu.sip.message.Message;
import org.zoolu.sip.provider.SipProvider;
......@@ -69,41 +70,35 @@ public class SuperPeerProxy implements SipProxy, RegistrationHandler {
throw new P2pProxyUserNotFoundException("user ["+lTo+"] not found");
}
}
// add recordRoute
SipUtils.addRecordRoute(aProvider,aMessage);
} else {
//just look at route set
MultipleHeader lMultipleRecordRoute = aMessage.getRecordRoutes();
if (lMultipleRecordRoute != null) {
lMultipleRecordRoute.removeTop();
MultipleHeader lMultipleRoute = aMessage.getRoutes();
if (lMultipleRoute != null) {
lMultipleRoute.removeTop();
}
if (lMultipleRecordRoute.getTop() != null) {
lNextHope = ((RecordRouteHeader)lMultipleRecordRoute.getTop()).getNameAddress().getAddress();
if (lMultipleRoute != null && lMultipleRoute.isEmpty()== false) {
lNextHope = ((RecordRouteHeader)lMultipleRoute.getTop()).getNameAddress().getAddress();
} else {
// last proxy, get route
// last proxy, get route from request uri
lNextHope = aMessage.getRequestLine().getAddress();
}
throw new P2pProxyException("not implemented yet");
}
//RequestLine lRequestLine = new RequestLine(lSipMessage.getRequestLine().getMethod(),lNextHope);
//lSipMessage.setRequestLine(lRequestLine);
MultipleHeader lMultipleRoute = aMessage.getRoutes();
RouteHeader lRouteHeader = new RouteHeader(new NameAddress(lNextHope+";lr"));
//lRouteHeader.setParameter("lr", null);
if (lMultipleRoute != null) {
lMultipleRoute.addTop(lRouteHeader);
aMessage.setRoutes(lMultipleRoute);
} else {
aMessage.addRouteHeader(lRouteHeader);
}
// add Via only udp
SipUtils.addVia(aProvider,aMessage);
// add recordRoute
SipUtils.addRecordRoute(aProvider,aMessage);
aMessage.setRequestLine(new RequestLine(aMessage.getRequestLine().getMethod(), lNextHope));
aProvider.sendMessage(aMessage);
}
public void proxyResponse(SipProvider provider, Message message) throws P2pProxyException {
// TODO Auto-generated method stub
public void proxyResponse(SipProvider aProvider, Message aMessage) throws P2pProxyException {
if (mLog.isInfoEnabled()) mLog.info("processing response " +aMessage);
//1 remove via header
SipUtils.removeVia(aProvider,aMessage);
aProvider.sendMessage(aMessage);
}
......
......@@ -32,6 +32,7 @@ import org.linphone.p2pproxy.core.JxtaNetworkManager;
import org.linphone.p2pproxy.core.P2pProxyAccountManagement;
import org.linphone.p2pproxy.core.P2pProxyAccountManagementMBean;
import org.linphone.p2pproxy.core.P2pProxyInstanceImpl;
import org.linphone.p2pproxy.core.P2pProxyMain;
import org.linphone.p2pproxy.test.utils.DefaultCallListener;
import org.linphone.p2pproxy.test.utils.SipClient;
import org.zoolu.sip.address.NameAddress;
......@@ -61,10 +62,12 @@ public class P2pProxyTester extends TestCase {
}
protected void setUp() throws Exception {
// setup logging
PropertyConfigurator.configure("log4j.properties");
if (mP2pProxyInstance == null) {
// setup logging
System.setProperty("org.linphone.p2pproxy.home", ".");
P2pProxyMain.staticLoadTraceConfigFile();
//PropertyConfigurator.configure("log4j.properties");
setupJxta();
mProvider = mP2pProxyInstance.getSipClientProvider() ;
mSipClient = new SipClient(mProvider, mDefaultSipIdentity,RDV_DISCOVERY_TIMEOUT*2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment