Developing new functionality to store call record


#1

Hi,
i’m an italian developer. Usually I write code in c# but during university studies I learn java se. Now i downloaded and open in eclipse the project and I want insert two new functionality.

  1. automatic start a registration when a call is starting
  2. send call record to ftp server

I make a new package under src and it have a ConfigEditor.java and a config.json file.
ConfigEditor.java manipulate config.json file.

When I run project after deploy-and-run from ant it call me an error because ConfigEditor is not found.
How can I resolve it?


#2

You are talking about Jitsi Desktop? If your answer is yes, then search the archive, there are multiple threads about it. Jitsi Desktop is OSGi based, and everything is bundles, you either didn’t integrated in a bundle or you are using it from another bundle without exporting and importing the package.


#3

I not found it…
Today, build success but when i run project it tell me that my class is not found.

If I post code can you help me?


#4

How can I edit code to introduce for example a line of code like:

import org.json.simple.JSONObject;
JSONObject obj = new JSONObject();

I insert this line in manifest file of package that I edited:

org.json.simple.JSONObject

When I run code it give me an error:

org.osgi.framework.BundleException: Unable to resolve net.java.sip.communicator.neomedia [138](R 138.0): missing requirement [net.java.sip.communicator.neomedia [138](R 138.0)] osgi.wiring.package; (osgi.wiring.package=org.json.simple.JSONObject) Unresolved requirements: [[net.java.sip.communicator.neomedia [138](R 138.0)] osgi.wiring.package; (osgi.wiring.package=org.json.simple.JSONObject)]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4149)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2119)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1373)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
at java.lang.Thread.run(Thread.java:748)
java.lang.NullPointerException
at net.java.sip.communicator.plugin.notificationwiring.NotificationManager.init(NotificationManager.java:1004)
at net.java.sip.communicator.plugin.notificationwiring.NotificationWiringActivator.start(NotificationWiringActivator.java:68)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2240)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2146)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1373)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
at java.lang.Thread.run(Thread.java:748)

There is a tutorial on how to edit code? Thanks!


#5

Is there a bundle that exports it (the json package)?
There are couple of examples here: https://desktop.jitsi.org/Documentation/DeveloperDocumentation


#6

Is there a bundle that exports it (the json package)?
I think no…
How can achive that?


#7

There are multiple libraries in the project, check the lib/installer-exclude folder. And see in the build.xml how it is done. If the library is already OSGi compatible its just a matter of copy the lib and start it in felix.client.run.properties, if it is not, you also need to create a manifest file and re-pack the jar file before the copy operation.


#8

I can’t run.

This is what I have or I do:
lib/installer-exclude/json-simple-1.1.1.jar
I maked manifest for the library using a wizard procedure of Eclipse and put inside lib/installer-exclude manifest file that I rename json-simple-1.1.1.manifest.mf
This is the body of file:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: 1
Bundle-SymbolicName: json-simple-1.1.1
Bundle-Version: 1.0.0
Bundle-ClassPath: json-simple-1.1.1.jar
Export-Package: org.json.simple,
org.json.simple.parser
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Automatic-Module-Name: json-simple-1.1.1

In lib I have a file named felix.client.run.properties but i not edit this.

In src\net\java\sip\communicator\impl\neomedia\CallRecordingConfigForm.java at the end of function loadValues i write this code:

try
{
String configPath = “C:\Users\pier\git\jitsi\src\itaca\solution\utils\config.json”;
Object obj = new JSONParser().parse(new FileReader(configPath));
JSONObject jo = (JSONObject) obj;
Boolean autoRecording = (Boolean) jo.get(“auto_recording”);
Map ftp = ((Map)jo.get(“ftp”));
String ftp_user = (String) ftp.get(“user”);
String ftp_password = (String) ftp.get(“password”);
String ftp_url = (String) ftp.get(“url”);
String ftp_directory = (String) ftp.get(“directory”);
}
catch(Exception e)
{
e.printStackTrace();
}

When I run project it give me this error:
Caused by: java.lang.ClassNotFoundException: org.json.simple.parser.JSONParser not found by net.java.sip.communicator.neomedia [138]

What I miss? How can i check if a library is OSGi compatible?


#9

Have you looked how bundles are created in build.xml, as I have suggested?

Create one for your lib and add it to the list of bundles tasks: https://github.com/jitsi/jitsi/blob/959ecfa865e4ab30ddb94467db3e92980f39d475/build.xml#L906

You should activate your new bundle in felix.client.run.properties.

Those steps are already described in the development documentation: https://desktop.jitsi.org/Documentation/CreatingServices


#10

again classNotFound exception.

This is what I do. In jitsi/build.xml I write the following:

		<!-- Creates a bundle containing the json-simple-1.1.1 lib.-->
		<jar compress="false" destfile="${bundles.dest}/json-simple-1.1.1.jar"
            manifest="${lib.noinst}/json-simple-1.1.1.manifest.mf">
			<zipfileset src="${lib.noinst}/json-simple-1.1.1.jar" prefix=""/>
		</jar>
	</target>

Yet in build xml I add targetName where required:

<!--ALL BUNDLES-->
<target name="bundles"
    depends="bundle-sc-launcher,bundle-util,bundle-service-dns,
    bundle-impl-dns,bundle-dns-config,
    bundle-splash-screen,
    bundle-configuration,bundle-configuration-slick,
    bundle-history,bundle-history-slick,bundle-messagehistory, bundle-msghistory-slick,
    bundle-callhistory, bundle-callhistory-slick, bundle-popupmessagehandler-slick,
    bundle-netaddr,bundle-netaddr-slick,bundle-slickless,
    bundle-slick-runner,bundle-sip,bundle-sip-slick,bundle-fileaccess,
    bundle-fileaccess-slick,bundle-neomedia,bundle-ldap,
    bundle-googlecontacts-service,bundle-googlecontacts,
    bundle-hid-service,bundle-hid,
    bundle-resource-manager,bundle-resources-defaultpack,
    bundle-protocol,bundle-protocol-media,bundle-icq,
    bundle-icq-slick,bundle-mock,bundle-smacklib,bundle-json-simple-1.1.1,bundle-jmdnslib,

I have a question so I start to understand something. The changes you made me make in build.xml only allow to make a bundle?

jitsi/lib/felix.client.run.properties I write the following:

felix.auto.start.80=
reference:file:sc-bundles/shutdown-timeout.jar
reference:file:sc-bundles/json-simple-1.1.1.jar

What’s the number 80?

Now I run “make-and-deploy” with ant, run with debug configuration like suggested in tutorial to run in Eclipse and i got classNotFound exception.


#11

You have an error, missing \.

This is the start lavel for the bundles: https://osgi.org/specification/osgi.core/7.0.0/framework.startlevel.html


#12

I have backslash in my code. I think when i copy and paste it was deleted.
What are we forgetting?


#13

@damencho can you help me to solve this problem?


#14

If you send github.com fork with your changes, I may take a look over the weekend …


#15

@damencho This is what i did:

  1. fork in my git hub account original repository of jitsi.
  2. create a new project that is referred to: https://github.com/arakanoid/jitsi
  3. do edit to various files
  4. right click on project -> team -> commit
  5. you can find new update project in: https://github.com/arakanoid/jitsi

#16

How do you repro the problem, just start jitsi?

One recommendation, when pushing changes for someone to review them, do not push formatting changes as you did in build.xml:


Basically this is beyond reviewable :slight_smile:


#17

And make sure it at least builds:

BUILD FAILED
/Users/damencho/dev/tmp/jitsi/build.xml:2144: Manifest file: /Users/damencho/dev/tmp/jitsi/src/itaca/solution/utils/utils.manifest.mf does not exist.

Total time: 19 seconds


#18

sorry,
these are old bundles that I maked only for test. I forgot to delete them.

New commit is available.


#19

And how do you repro the problem? What are the steps?


#20

Your error is:

     [java] java.lang.NoClassDefFoundError: org/json/simple/parser/JSONParser
     [java] 	at net.java.sip.communicator.impl.neomedia.CallRecordingConfigForm.loadValues(CallRecordingConfigForm.java:330)

Just add org.json.simple.parser in neomedia manifest.

$ git diff
diff --git a/src/net/java/sip/communicator/impl/neomedia/neomedia.manifest.mf b/src/net/java/sip/communicator/impl/neomedia/neomedia.manifest.mf
index 5cf537fea..228ba26c9 100644
--- a/src/net/java/sip/communicator/impl/neomedia/neomedia.manifest.mf
+++ b/src/net/java/sip/communicator/impl/neomedia/neomedia.manifest.mf
@@ -68,6 +68,7 @@ Import-Package: apple.awt,
  org.jitsi.util.swing,
  org.apache.commons.compress.compressors.bzip2,
  org.json.simple,
+ org.json.simple.parser,
  org.osgi.framework,
  org.w3c.dom,
  org.xml.sax,