Monday, May 23, 2011

Java Tray Icon Transparency Under Linux

Well, like many people before me, I had problems with my tray icons under linux. The JDK implementation has a bug that renders tray icons with transparency with an ugly gray background instead of the transparent background.

This is really annoying to me and I really don't like the idea of providing an application that looks half-assed. So, I actually got around this problem creating a small native library that implements the tray icon using gtk.

So, if you end up having tray icon problems, you may use my little artifact. The source code is here. I also deployed in the central, you can use it putting the following dependency:

<groupId>com.github.taksan</groupId>
<artifactId>native-tray-adapter</artifactId>
<version>1.1</version>

The usage is very simple:

 SystemTrayAdapter trayAdapter = SystemTrayProvider.getSystemTray();  
 URL imageUrl = getClass().getResource("myImage.svg");  
 String tooltip = "I'm transparent under linux!";   
 PopupMenu popup = produceMyPopupMenu();  
 TrayIconAdapter trayIconAdapter = trayAdapter.createAndAddTrayIcon(  
    imageUrl,   
    tooltip,  
    popup);  

Enjoy!

Friday, May 6, 2011

First run bug

I just uploaded a new version fixing a bug that would make the application crash the first time you run against a non-synchronized account.

I didn't notice this bug because I was testing against an account that already had the "Skype-Chats" label (shame on me =).

See ya.

Monday, May 2, 2011

Alpha version available

I'm glad to announce that I have an alpha version that does mostly everything. You can grab it from here or just use the panel in the side frame.

To use it, just do:

java - jar skype2gmail-1.0.jar --mail

It will ask whatever it needs to synchronize. And you can also use as the following:

java - jar skype2gmail.jar --disk

It will dump all your messages to directory in the user home ($HOME/.skype2gmail/history).

Feel free to report any bugs or send any feature requests!

Enjoy!

It is hard to trash messages from gmail..

I found out that it is very hard to remove a message from gmail using the LDAP api. At first, I just tried doing the following:

((Message)message).setFlag(Flags.Flag.DELETED, true);
...
folder.close(true)

This should work for common ldap accounts, but it doesn't work properly in gmail. It just removes the message from the "folder", which is actually mapped as a gmail label. The message will remain under "All messages". Next, I found that I should move the message to the trash folder:

Folder skypeFolder = mailStore.getFolder("Skype-Chats");
Folder trash =  mailStore.getFolder("[Gmail]/Trash");

Message[] messagesToRemove = new Message[]{messageToRemove};
skypeFolder.copyMessages(messagesToRemove, trash);
// and just to make sure
mimeMessage.setFlag(Flags.Flag.DELETED, true);

Well, it did work... kinda. A problem still remained: if you send a new message with the same sender and subject, the "deleted" message gets resurrected.

I couldn't figure out how to remove it permanently. I got around the problem changing the subject, when need...