Author |
Message |
veikkorajamaki Brekeke Newbie
![](images/spacer.gif)
Joined: 23 Nov 2007 Posts: 3
|
Posted: Fri Nov 23, 2007 8:46 am Post subject: Need advice on Dialplan plugins |
|
|
1. Brekeke Product Name and version:
Brekeke SIP Server 2.1.5.6/239
2. Java version:
jre1.6.0_03
jdk1.6.0_03
3. OS type and the version:
Windows 2003 server
4. UA (phone), gateway or other hardware/software involved:
Siemens gigaset S450IP phone
5. Select your network pattern from http://www.brekeke-sip.com/bbs/network/networkpatterns.html :
Pattern 1
6. Your problem:
I came upon http://www.brekeke-sip.com/download/bss/bss_tutorial_dialplan_plugin.txt and tried to create a dialplan plugin of my own, with a goal to replace dialed number X with SIP Uri from file C:\Documents and Settings\All Users\phonebook.props .This because personal edition of the SIP server can handle only 5 dialplan rules and my SIP phone can only dial numbers and not vanity SIP uri's. But I am having trouble with it and have no experience in Java, here is the source code for my phonebook class:
Code: |
package plugin;
import java.util.*;
import java.io.*;
public class phonebook {
// get new address from phonebook file
//
// Syntax:
// $phonebook.findentry( dialednumber )
//
// Returns:
// aliased SIP-URI from phonebook if such exists
static public String findentry( String[] arg, com.brekeke.net.sip.SIPpacket sippacket, Properties pr ) throws Exception {
if ( ( arg != null ) && ( arg[0] != null) ) {
String sipnumber = arg[0] ;
try {
Properties aliaslist = new Properties();
File phonebookdir = new File(System.getenv("ALLUSERSPROFILE"));
File phonebookfile = new File(phonebookdir, "phonebook.props");
aliaslist.load(new FileInputStream(phonebookfile));
return ( aliaslist.getProperty(sipnumber) );
}
catch(Exception e) {
return ( null ) ;
}
}
return ( null ) ;
}
} |
I Compiled it with command: javac -cp C:\Progra~1\Brekeke\proxy\webapps\proxy\WEB-INF\lib\ondosip.jar phonebook.java
-the compile produced no errors.
Then I moved the resulting phonebook.class to directory: C:\Program Files\Brekeke\proxy\webapps\proxy\WEB-INF\classes
-Such directory did not exist I had to create it
And I added line: dialplan.plugins.matching.pkg=com.brekeke.plugin
To file: C:\Program Files\Brekeke\proxy\webapps\proxy\WEB-INF\work\sv\sv.properties
-I tried also line: dialplan.plugins.matching.pkg=plugin,but that did not work either.
when I try to make Dialplan with: $phonebook.findentry( "%1" )=(.+) it is colored red, this indicates error I think? Should the new class be in the variable dropdown list when all is OK?
Restarting SIP server or computer did not help.
I sure that someone who has done this succesfully, can tell me what I am doing wrong... |
|
Back to top |
|
lakeview Brekeke Master Guru
![](images/spacer.gif)
Joined: 15 Nov 2007 Posts: 319
Location: Florida
|
Posted: Fri Nov 23, 2007 1:00 pm Post subject: |
|
|
I have little experiences with dialplan plug-ins..
>> dialplan.plugins.matching.pkg=com.brekeke.plugin
You need to set it as "dialplan.plugins.matching.pkg=plugin" because your class package is "plugin"..
>> it is colored red, this indicates error I think?
you don't have to worry about it..
anyway.. if you try a sample code in the plugin document, what happen? |
|
Back to top |
|
veikkorajamaki Brekeke Newbie
![](images/spacer.gif)
Joined: 23 Nov 2007 Posts: 3
|
Posted: Sun Nov 25, 2007 5:23 am Post subject: |
|
|
lakeview wrote: |
You need to set it as "dialplan.plugins.matching.pkg=plugin" because your class package is "plugin".. |
OK this was mentioned in the sample document, just didn't notice it, but it didn't solve it.
lakeview wrote: |
anyway.. if you try a sample code in the plugin document, what happen? |
Could not get the sample working either and I tested the code I wrote could not get it working with command: java phonebook.findentry ,but that might be because there is no main function there? The try...catch part does what it should though.
Code: |
import java.util.*;
import java.io.*;
class test {
public static void main(String[] args) {
String sipnumber = "007"; //arg[0] ;
try {
Properties aliaslist = new Properties();
File phonebookdir = new File(System.getenv("ALLUSERSPROFILE"));
File phonebookfile = new File(phonebookdir, "phonebook.props");
aliaslist.load(new FileInputStream(phonebookfile));
System.out.println(aliaslist.getProperty(sipnumber));
}
catch(Exception e) {
System.out.println("Exception");
}
}
} |
retrieves value of 007 = ????????
from phonebook.props file in all users folder. |
|
Back to top |
|
veikkorajamaki Brekeke Newbie
![](images/spacer.gif)
Joined: 23 Nov 2007 Posts: 3
|
Posted: Mon Nov 26, 2007 1:43 am Post subject: |
|
|
veikkorajamaki wrote: |
lakeview wrote: |
You need to set it as "dialplan.plugins.matching.pkg=plugin" because your class package is "plugin".. |
OK this was mentioned in the sample document, just didn't notice it, but it didn't solve it. |
Solution found! In addition to correct package name in sv.properties file, the phonebook class needed to be in directory: C:\Program Files\Brekeke\proxy\webapps\proxy\WEB-INF\classes\plugin
Instead of: C:\Program Files\Brekeke\proxy\webapps\proxy\WEB-INF\classes
Thanks for your help lakeview, in this issue. |
|
Back to top |
|
lakeview Brekeke Master Guru
![](images/spacer.gif)
Joined: 15 Nov 2007 Posts: 319
Location: Florida
|
Posted: Tue Dec 04, 2007 7:12 pm Post subject: |
|
|
Wow. You did! |
|
Back to top |
|
alasdair.ramsay@dsx.ie Brekeke Newbie
![](images/spacer.gif)
Joined: 12 Nov 2009 Posts: 2
Location: Milton Keynes, UK
|
Posted: Fri Nov 13, 2009 11:35 am Post subject: |
|
|
veikkorajamaki wrote: |
Solution found! In addition to correct package name in sv.properties file, the phonebook class needed to be in directory: C:\Program Files\Brekeke\proxy\webapps\proxy\WEB-INF\classes\plugin
Instead of: C:\Program Files\Brekeke\proxy\webapps\proxy\WEB-INF\classes
Thanks for your help lakeview, in this issue. |
I'd like to just 'bump' this thread, because despite being two years old... the documentation is *still* not correct.
I've just wasted two weeks trying to get to the bottom of this problem and only solved it when I resorted to reading every thread with dialplan and plugin in it!
Brekeke, sort it out! |
|
Back to top |
|
Mike Support Team
![](images/spacer.gif)
Joined: 07 Mar 2005 Posts: 733
Location: Sunny San Mateo
|
Posted: Wed Nov 25, 2009 4:55 pm Post subject: |
|
|
Hi alasdair,
Sorry for the inconvenience.
We've updated the Dial Plan Plug-in Developer's Guide.
Since the sample Java package name is "plugin" in the document, please create the directory "plugin" under classes directory.
It means.. if you use a different package name such as "myproject" , you need to create the directory "myproject" under classes directory.
To avoid this confusion, I recommend that you create JAR file and put it on lib directory.
Regards, |
|
Back to top |
|
alasdair.ramsay@dsx.ie Brekeke Newbie
![](images/spacer.gif)
Joined: 12 Nov 2009 Posts: 2
Location: Milton Keynes, UK
|
Posted: Wed Nov 25, 2009 5:31 pm Post subject: |
|
|
Thanks!
Java has been a steeper learning curve than I'd hoped ![Wink](images/smiles/icon_wink.gif) |
|
Back to top |
|
Mike Support Team
![](images/spacer.gif)
Joined: 07 Mar 2005 Posts: 733
Location: Sunny San Mateo
|
Posted: Mon Nov 30, 2009 11:26 am Post subject: |
|
|
Hi alasdair,
I'm interested in your project..
What kind of plug-in software are you creating?
Thanks |
|
Back to top |
|
|