Skip to main content

Posts

Showing posts from March, 2008

Talk to asterisk with Asterisk-java

I just found the java way to talk to my trixbox. With Asterisk-java you can handle call from asterisk server via the FastAGI protocal , use the Manager api to connect to Asterisk server, send action and handle event. Last the Live api instead of using actions and events like the Manager api it use active domain objects (live objects) that represent Asterisk concepts like a channel or an extension. more example on tutorial page .

Adding ip address on trixbox[without X]

On Ubuntu, to manage ip address of the box in console, we need to edit /etc/network/interfaces. By default ubuntu is set to using dhcp as you will see. auto eth0 iface eth0 inet dhcp changing "dhcp" to "static" and add network information auto eth0 iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 will change the box to use static ip address. Adding more ip address on this interface can be done by add script below to the same "interfaces" file.[ note that we have :1 after eth0 ] auto eth0:1 iface eth0:1 inet static address 192.168.1.109 netmask 255.255.255.0 broadcast 192.168.1.255 Trixbox use centos. Like other redhat family, it has system-config-network utility or if you want to play with the configuration file, adding ip address is done by create new file in /etc/sysconfig/network-scripts like in mycase. I have

R4FXO card Installation note

Last year I have played with trixbox for two week and leave it sit under my desk for a long time. Last week I just got a new card to play with. It's Rhino R4FXO[4 FXO ports]. My goal now is make trixbox know the card and config it properly. I start with reinstall trixbox with the almost latest version[trixbox ce 2.4.2]. Upgrade all packages[Include zaptel driver 1.4.9.2-4] note: this zaptel driver is not work with current rhino driver in repos[for now 21/03/08]. It need to manual download the driver and install from console[ more detail ] After base system is ready. Install R4FXO card. 1. Shutdown the box. 2. Put R4FXO card to the pci slot. Boot trixbox again and run command 'genzaptelconf' to generate configuration files automatically. The config file is '/etc/zaptel.conf' and '/etc/asterisk/zapata-chanels.conf'. mine is look like this. [trixbox1.localdomain ~]# cat /etc/asterisk/zapata-channels.conf ; Autogenerated by /usr/sbin/genzaptelconf -- do not han

Shadow Text Effect on JLabel

I found the trick to create shawdow text on JLabel from java forum . Instead of use JLabel.setText() set string to JLabel, he create Image and get Graphics2D by Image.createGraphics(). Then use TextLayout draw overlapping string on that Graphics2D. example code int w = 500; int h = 120; Font font = new Font("Lucida Bright", Font.ITALIC, 72); String text = "Shadow Text"; BufferedImage image = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB); Graphics2D g = image.createGraphics(); adjustGraphics(g); //start off all white: g.setPaint(Color.WHITE); g.fillRect(0, 0, w, h); //draw "shadow" text: to be blurred next TextLayout textLayout = new TextLayout(text, font, g.getFontRenderContext()); g.setPaint(new Color(128,128,255)); textLayout.draw(g, 15, 105); g.dispose(); //blur the shadow: result is sorted in image

using Class.getResource() load resource file in Eclipse

There are many ways to load resource file in java app. What sun recommended is using Class.getResource(" resource_name ") or Class.getResourceAsStream(" resource_name ") then you will get URL and InputStream respectively. If resource_name is specified without "/", it will be prepend with Class package. So resource file must be in same place[folder structure] as the Class. What I love to do is call getResource() with "/" and put resource file at the root of package. This way i can have separate resource folder. below is in Eclipse, 1. From Package explorer right click src folder->click import 2. In import dialog, Choose General->File System ->next 3. from directory:->Browse to your resource folder. 4. to folder:-> I add "resource" as a folder name under src folder. then click "Finish". In the code, load resource with this.getClass().getResource("/resource/buttons1.png") or this.getClass().getResourceAs

tinymce_imce.patch fixing browse button not showing up

Few week ago, I get tinymce module work on my new site. When I create new content and want to add the picture. Tinymce allow me only add url for an image. Anyway I found another module called IMCE . It work together with tinymce and allow me to upload image from my computer. After installation, I can't see browse button when click add image??? my environments is (Drupal5.7+TinyMCE5.x-1.9+TinyMCE3.0+IMCE5.x-1.0). Many post tell me to add <?php print $closure;?> to page.tpl.php file, that not work for me. mine already have it. Today I found the patch from here . It work well for my case. To apply patch[I do this on my local box then upload tinymce.module and imce_set_tinymce.js to host] pnix@pnix-a7n:drupal$ ls imce tinymce tinymce-5.x-1.9.tar.gz imce-5.x-1.0.tar.gz tinymce_3_0_1.zip tinymce_imce.patch pnix@pnix-a7n:drupal_modules$ patch -p0<tinymce_imce.patch patching file tinymce/tinymce.module patching file imce/imce_set_tinymce.js pnix@pnix

Changing partition label on Ubuntu

I found this howto from community docs while searching for rename my usb drive. Not many times you need to do this but if you want, here is the summary. You need few programs depends on the your partition type. mtools for fat32 ntfsprogs for ntfs e2label for ext2 or ext3 reiserfstune for reiserfs(v3) Install which you need by 'sudo aptitude install [program name]' note : check your partition type by 'mount' or 'df -T'. For me, my usb is fat32 changing label is done by pnix@pnix-a7n:~$ sudo mlabel -i /dev/sdb :: myusbdrive pnix@pnix-a7n:~$ upper command, I just change label to 'myusbdrive'. for other partition types, below are some examples. sudo ntfslabel /dev/sda1 newlabel sudo e2label /dev/sda1 newlabel sudo reiserfstune -l newlabel /dev/sda1 update [many thanks for comment]: for ext2/ext3 you also can use tune2fs like this sudo tune2fs -L newlabel /dev/sda1 note : may be it's need to umount device before try changing label to get it work. T