Commit a4774638 authored by jehan's avatar jehan

update p2pproxy.h with lookup media resource

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@168 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent ed401ca6
......@@ -100,6 +100,25 @@ int p2pproxy_accountmgt_deleteAccount(const char* user_name);
/****************************/
/***resource management******/
/****************************/
/**
* Structure to store resource list, must be instanciated by
* p2pproxy_resourcemgt_new_resource_list and deleted by p2pproxy_resourcemgt_delete_resource_list.
*
*/
struct p2pproxy_resourcemgt_resource_list {
char[]* resource_uri; /* uri list*/
unsigned char size; /*number of element in the list*/
} p2pproxy_resourcemgt_resource_list_t;
/**
* Instanciate a p2pproxy_resourcemgt_resource_list
*/
p2pproxy_resourcemgt_resource_list_t* p2pproxy_resourcemgt_new_resource_list();
/**
* delete a p2pproxy_resourcemgt_resource_list
*/
void p2pproxy_resourcemgt_delete_resource_list(p2pproxy_resourcemgt_resource_list_t* resource_list);
/**
* access a proxy registrar sip addreess for a given domaine name
* @param [out] proxy_uri buffer allocated by the user
......@@ -108,6 +127,13 @@ int p2pproxy_accountmgt_deleteAccount(const char* user_name);
* @return status code P2PPROXY_NO_ERROR, P2PPROXY_ERROR_RESOURCELOCATOR_SERVER_NOT_FOUND
*/
int p2pproxy_resourcemgt_lookup_sip_proxy(char* proxy_uri,size_t size, char* domaine) ;
/**
* access a media ressource addresses for a given domaine name
* @param [out] p2pproxy_resourcemgt_resource_list_t allocated by the user
* @param [in] domaine name
* @return status code P2PPROXY_NO_ERROR, P2PPROXY_ERROR_RESOURCELOCATOR_SERVER_NOT_FOUND
*/
int p2pproxy_resourcemgt_lookup_media_resource(p2pproxy_resourcemgt_resource_list_t* resource_list, char* domaine) ;
/*
* notify the library at a given proxy is no longuer reachable
* @param [in] proxy sip uri
......@@ -115,6 +141,12 @@ int p2pproxy_resourcemgt_lookup_sip_proxy(char* proxy_uri,size_t size, char* dom
*/
int p2pproxy_resourcemgt_revoke_sip_proxy(char* proxy_uri);
/*
* notify the library at a given Media resoure is no longuer reachable
* @param [in] media resource uri (udp://hostname:port)
* @return status code P2PPROXY_NO_ERROR
*/
int p2pproxy_resourcemgt_revoke_media_resource(char* resource_uri);
#endif /*SWIG*/
......
......@@ -443,8 +443,8 @@ public static int getState() {
public static int revokeSipProxy(String aProxy) {
try {
isReady();
mLog.error("not implemented");
return P2pProxylauncherConstants.P2PPROXY_ERROR;
mP2pProxyManagement.revokeSipProxy(aProxy);
return P2pProxylauncherConstants.P2PPROXY_NO_ERROR;
} catch (P2pProxyException e) {
return P2pProxylauncherConstants.P2PPROXY_NOT_CONNECTED;
}
......
......@@ -10,65 +10,62 @@ import org.linphone.p2pproxy.core.sipproxy.NetworkResourceAdvertisement;
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrar;
public class P2pProxyResourceManagementImpl implements P2pProxyResourceManagement {
protected final JxtaNetworkManager mJxtaNetworkManager;
private final static Logger mLog = Logger.getLogger(P2pProxyResourceManagementImpl.class);
P2pProxyResourceManagementImpl(JxtaNetworkManager aJxtaNetworkManager) {
mJxtaNetworkManager = aJxtaNetworkManager;
}
public String[] lookupSipProxiesUri(String aDomaine) throws P2pProxyException {
try {
if (!DOMAINE.equals(aDomaine)) {
//unknown domaine
return new String[0];
}
List<NetworkResourceAdvertisement> lSipProxyRegistrarAdvertisements = (List<NetworkResourceAdvertisement>) (mJxtaNetworkManager.getAdvertisementList(null, "Name",SipProxyRegistrar.ADV_NAME, true,2));
String[] lAddresses = new String[lSipProxyRegistrarAdvertisements.size()];
for (int i=0;i<lSipProxyRegistrarAdvertisements.size();i++) {
lAddresses[i] = lSipProxyRegistrarAdvertisements.get(i).getAddress();
}
return lAddresses;
}catch (Exception e) {
throw new P2pProxyException(e);
}
protected final JxtaNetworkManager mJxtaNetworkManager;
}
public void revokeSipProxy(String aProxy) throws P2pProxyException {
try {
NetworkResourceAdvertisement lSipProxyRegistrarAdvertisement = (NetworkResourceAdvertisement) (mJxtaNetworkManager.getAdvertisement(null, NetworkResourceAdvertisement.ADDRESS_TAG, true));
mJxtaNetworkManager.getPeerGroup().getDiscoveryService().flushAdvertisement(lSipProxyRegistrarAdvertisement);
mLog.info(aProxy +"revoked");
} catch (Exception e) {
throw new P2pProxyException(e);
}
}
public String[] getMediaServerList() throws P2pProxyException {
try {
private final static Logger mLog = Logger.getLogger(P2pProxyResourceManagementImpl.class);
P2pProxyResourceManagementImpl(JxtaNetworkManager aJxtaNetworkManager) {
mJxtaNetworkManager = aJxtaNetworkManager;
}
public String[] lookupSipProxiesUri(String aDomaine) throws P2pProxyException {
try {
if (!DOMAINE.equals(aDomaine)) {
//unknown domaine
return new String[0];
}
List<NetworkResourceAdvertisement> lSipProxyRegistrarAdvertisements = (List<NetworkResourceAdvertisement>) (mJxtaNetworkManager.getAdvertisementList(null, "Name",SipProxyRegistrar.ADV_NAME, true,2));
String[] lAddresses = new String[lSipProxyRegistrarAdvertisements.size()];
for (int i=0;i<lSipProxyRegistrarAdvertisements.size();i++) {
lAddresses[i] = lSipProxyRegistrarAdvertisements.get(i).getAddress();
}
return lAddresses;
}catch (Exception e) {
throw new P2pProxyException(e);
}
List<NetworkResourceAdvertisement> lMediaResoureAdvertisements = (List<NetworkResourceAdvertisement>) (mJxtaNetworkManager.getAdvertisementList(null, "Name",MediaResourceService.ADV_NAME, true,2));
String[] lAddresses = new String[lMediaResoureAdvertisements.size()];
for (int i=0;i<lMediaResoureAdvertisements.size();i++) {
lAddresses[i] = lMediaResoureAdvertisements.get(i).getAddress();
}
return lAddresses;
}catch (Exception e) {
throw new P2pProxyException(e);
}
}
public void revokeMediaServer(String aMediaServer) throws P2pProxyException {
try {
List<NetworkResourceAdvertisement> lMediaResourceAdvertisement = (List<NetworkResourceAdvertisement>) (mJxtaNetworkManager.getAdvertisementList(null,MediaResourceService.ADV_NAME, true));
for (NetworkResourceAdvertisement lMediaResource:lMediaResourceAdvertisement) {
if (lMediaResource.getAddress().equals("udp://"+aMediaServer)) {
mJxtaNetworkManager.getPeerGroup().getDiscoveryService().flushAdvertisement(lMediaResource);
mLog.info(aMediaServer +" revoked");
}
}
} catch (Exception e) {
throw new P2pProxyException(e);
}
}
}
public void revokeSipProxy(String aProxy) throws P2pProxyException {
revokeNetworkResoure(aProxy, SipProxyRegistrar.ADV_NAME);
}
public String[] getMediaServerList() throws P2pProxyException {
try {
List<NetworkResourceAdvertisement> lMediaResoureAdvertisements = (List<NetworkResourceAdvertisement>) (mJxtaNetworkManager.getAdvertisementList(null, "Name",MediaResourceService.ADV_NAME, true,2));
String[] lAddresses = new String[lMediaResoureAdvertisements.size()];
for (int i=0;i<lMediaResoureAdvertisements.size();i++) {
lAddresses[i] = lMediaResoureAdvertisements.get(i).getAddress();
}
return lAddresses;
}catch (Exception e) {
throw new P2pProxyException(e);
}
}
public void revokeMediaServer(String aMediaServer) throws P2pProxyException {
revokeNetworkResoure(aMediaServer, MediaResourceService.ADV_NAME);
}
private void revokeNetworkResoure(String aResource,String anAdvName) throws P2pProxyException {
try {
List<NetworkResourceAdvertisement> lMediaResourceAdvertisement = (List<NetworkResourceAdvertisement>) (mJxtaNetworkManager.getAdvertisementList(null,anAdvName, true));
for (NetworkResourceAdvertisement lMediaResource:lMediaResourceAdvertisement) {
if (lMediaResource.getAddress().equals("udp://"+aResource)) {
mJxtaNetworkManager.getPeerGroup().getDiscoveryService().flushAdvertisement(lMediaResource);
mLog.info(aResource +" revoked");
}
}
} catch (Exception e) {
throw new P2pProxyException(e);
}
}
}
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