Skip to main content

[jxta-c] Modify PlatformConfig components

1 reply [Last post]
Joined: 2008-06-18

Hi all,

I'm wondering what is the best way for creating/modifying PlatformConfig config file for jxta-c.

I see that initially jxta_PlatformConfig_create_default() can be used for creating default configuration. The question is how I can obtain single advertisement, modify some of its parameters and write it back into the config file.

For example get TCP transport advertisement, change interface address and port and write it to the file again.

I see there is some API methods for getting/setting parameters from/to jxta_PA, example jxta_PA_get_GID()/jxta_PA_set_GID. But I don't see any like this for setting TCP Advertisement part.

Another approach I'm considering is:
ad = jxta_TCPTransportAdvertisement_new();

testfile = fopen(argv[1], "r");
jxta_TCPTransportAdvertisement_parse_file(ad, testfile);

but I'm not sure this will work at all since I don't see how to write the modified parameter back to the orginal file

Hope I'm clear enough :)

Thank you,

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2008-06-18

After little more investigation I think I've found the most correct approach (for now) :). I'll test it later.

Here it is:

jxta_PA *pConfigAdv = jxta_PlatformConfig_read(PLATFORM_CONFIG_FILENAME.toAscii());
Jxta_svc *pTCPSvc;
jxta_PA_get_Svc_with_id(pConfigAdv, jxta_tcpproto_classid, &pTCPSvc);
Jxta_TCPTransportAdvertisement *pTCPAdv = jxta_svc_get_TCPTransportAdvertisement(pTCPSvc);
jxta_TCPTransportAdvertisement_set_InterfaceAddress(pTCPAdv, ip.toIPv4Address());
jxta_PlatformConfig_write(pConfigAdv, PLATFORM_CONFIG_FILENAME.toAscii());