Need advice on Dialplan plugins

Discuss any topic about Brekeke SIP Server.

Moderator: Brekeke Support Team

Post Reply
veikkorajamaki
Posts: 3
Joined: Fri Nov 23, 2007 7:39 am

Need advice on Dialplan plugins

Post by veikkorajamaki »

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/ ... terns.html :
Pattern 1

6. Your problem:
I came upon http://www.brekeke-sip.com/download/bss ... 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: Select all

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...
lakeview
Posts: 319
Joined: Thu Nov 15, 2007 11:54 am
Location: Florida

Post by lakeview »

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?
veikkorajamaki
Posts: 3
Joined: Fri Nov 23, 2007 7:39 am

Post by veikkorajamaki »

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: Select all

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.
veikkorajamaki
Posts: 3
Joined: Fri Nov 23, 2007 7:39 am

Post by veikkorajamaki »

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.
lakeview
Posts: 319
Joined: Thu Nov 15, 2007 11:54 am
Location: Florida

Post by lakeview »

Wow. You did!
alasdair.ramsay@dsx.ie
Posts: 2
Joined: Thu Nov 12, 2009 7:47 am
Location: Milton Keynes, UK

Post by alasdair.ramsay@dsx.ie »

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!
Mike
Posts: 733
Joined: Mon Mar 07, 2005 2:25 pm
Location: Sunny San Mateo
Contact:

Post by Mike »

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,
alasdair.ramsay@dsx.ie
Posts: 2
Joined: Thu Nov 12, 2009 7:47 am
Location: Milton Keynes, UK

Post by alasdair.ramsay@dsx.ie »

Thanks!

Java has been a steeper learning curve than I'd hoped ;)
Mike
Posts: 733
Joined: Mon Mar 07, 2005 2:25 pm
Location: Sunny San Mateo
Contact:

Post by Mike »

Hi alasdair,

I'm interested in your project..
What kind of plug-in software are you creating?

Thanks
Post Reply