Tuesday, March 22, 2011

Version 1.0 is in the horizon...

As of now I have a working application that can either write the chats to the disk or upload the chat messages to a gmail account! Woohoo!

I believe I finally stabilized on a format, for messages and signatures (used to validate and merge chats) and I believe I won't diverge much from the current format now.

Some interesting things I learned from uploading messages to gmail:

- It is not enough to set the "Date" header in the mime message, you need to set the sent date as well to make sure the messages are sorted correctly

- After uploading messages, when the messages are retrieved by the application, I found that all line breaks in the message body were converted to CRLF (instead of the LF that were in the messages when I uploaded).

- It is essential to user MimeUtilty encode/decode when setting mail header values, specially if they have accents.

Well, as I expected, implementing the first version that could upload to gmail wasn't hard after all the work I have done implementing the disk version.

I still have to do some tests running the application from two different computers running the same account. Also, even tough I tested chat merging against the disk history, I still didn't test against the mail messages.

As for the next step in the development: I must make it work under windows and linux 32bit. I just found the other day that my mavenized skype4java isn't working under windows.. I won't release the first version before making sure everything works under windows and linux at least. I can't guarantee OSX, since I can't test it, but I'll make an effort.

That is for now. See ya.

Thursday, March 17, 2011

Skype 2 Disk

As of now I managed to get everything I need to save the history to the disk and update the files, merging when needed.

It is now possible to take a history from another computer, for example, and run skype2gmail to update the files, consolidating without duplications. Implementing this feature enabled me to develop all the concepts I need to send the messages to gmail and update them, also without duplication. I just need to develop few classes that make the connection and edit gmail using ldap.

I already made some simple concept tests that are capable of sending mail, so I believe the first working version will soon be out. The first version will need to be ran from the command line once and will require an external mean to keep running once in a while. Also, there are a lot of optimizations that will be left for the next version.

So, I'm planning the following features:

- can store the chat history in a directory in the filesystem
- can store the chat history in a gmail or google apps mail account
- in both cases, it will be able to consolidate the chats, which means there won't be duplicate messages
- it will be "parallel" safe, that is, running two instances in different machines won't conflict when updating gmail at the same time.
- will run under linux (both 32-bit and 64-bit) and windows


- will always fetch the entire history to update the storage (gmail/disk)
- won't send store voice chats (I don't know whether I'll ever do that)
- won't regurlarly automatically
- will require the user to provide the mail credentials in a file in the .skype2gmail directory or ask every run
- created mail messages won't have the sender actual mail, only his skype name
- might not work under OS-X (I don't have means to test it under OS-X)

Some features I'm planning for the future:

- use a mechanism to detect whether the last update was in less than 24 hours in the giving machine; if so, I can use only the recent chat history to update the storage, which is A LOT faster (almost a minute vs less than 2 seconds)

- create indexes to speedup storage update (instead of looking all entries, it will use the index to learn which entries need to be updated just by checking the index)

- run in the system tray regularly, with configurable schedule

- since it may keep running, it may only ask gmail credentials when starting and store in the memory (don't need to ask again in the next update)

- will keep allowing the user to save the credentials in the filesystem

- integrate with gnome-keyring to store credentials

- will be more robust (this depends on skype4java fixes)

- will allow the user to specify, for each skype name, a mail address, so the chat messages will in gmail will have the correct mail address

This is only what I'm able to remember now. I'll certainly take requests from the community once the application is at least implementing the above features (heck, I might take good suggestions anytime) =)

Skype4Java API

Along the project, I took the mission of making the Skype4Java project more reliable. I found that the Skype API under linux is very tricky and doesn't always works as expected. I found several problems.

First, after running for some time, the X-11 Atom "_SKYPE_INSTANCE" just disappears. After that, the skype4java doesn't be able to attach to the running skype and, of course, skype2gmail stops working.

Well, I changed the code and used a workaround, so the native library is now able to find the skype window used by the API under linux even when the atom is gone.

The second problem I faced was mixed responses. Sometimes when two messages are sent through the skype api "very fast", the former message's response was truncated and the later's message response was concatenated. There's no need to say how troubling this was. The application keeps waiting for both responses and got stuck forever.

Fixed the concatenation problem, which was a bug in the native library, but I still couldn't figure out why the first message's response was truncated. I worked around this problem changing the way the java api works. Instead of "ping ponging" after every request (to keep alive), when the timeout comes I changed to retry the request. This made the library much more reliable and it seems it works all the time (except when the api fails to connect to skype, which is happening sometimes).

Sometime in the future I'll have to address mainly in the following problems with the Skype4Java:

- Sometimes (not very often), the application simply doesn't connect. It seems the application sends the request to skype, but there's no response. It always work to retry just after canceling the application. I suppose I can fix by retrying the connection after a short timeout.

- I intend to figure why the native library receives partial messages sometimes. For now, after the connection is established, the application always works to the end, so the workaround seems to be working fine, but it might be the reason the connection fails sometimes. Also, the application will certainly work faster when this problem is fixed, since the requests won't have to be retried as often.

Oh yeah, this development is getting more interesting every day

Wednesday, March 2, 2011

Recording your skype chat with Gmail

I've started writing a java application that will send your skype chat history to any gmail or google apps account you have, even if you use skype in multiple computers.

The first version is already completed and just dumps your chats in the file system. The next step is to make chat history consolidation, allowing dumping multiple skype histories in the same directory.

And finally, the first release will send your chats to a gmail account.

Keep checking to learn when it is done!