Is MobileMe the ONE?

Desktop June 12th, 2008

The 3G iPhone and the accompanied MobileMe service introduced in WWDC 2008 stirred the buzz in the blogosphere as ever. MobileMe logo The MobileMe tries to solve the long-lasting synchronization problem, which Microsoft have not figured out a panacea for both enterprise market and mass customers. Apple’s answer seems like an intuitive and elegant solution in the first impression, and we may wonder, is MobileMe the ONE?

I really doubt it, based on some common sense and reasonable guess as the service is not available so far, please correct me in your comment if I am wrong.

Push model may not cross the enterprise boundary
Push mail has been very successful in the enterprise world, but why there are no such things like push document, push worksheet? The instantaneous synchronization is just purely wasted in most cases, even not that inviting in the Corp net which is powered by Gigabit ethernet, let alone the consumers are using much slower high speed internet or 3G wireless connection.

There is no silver bullet to resolve conflicts
MobileMe supports family pack, so it is possible that one file is edited in different computers. The conflict has to be resolved however fast the synchronization is. We also need to track the version number because it is hard to tell which copy is the latest without network time synchronization, so ultimately MobileMe would be a version control system. But according to my personal experience, there is no more intuitive way to resolve the conflict than three-way diff. But this is less user-friendly and not an available option if you are working with images or videos.

Accessibility and Interoperability
These are not big issues for die hard Apple fans. I believe Bonjour would automatically configure the firewall and all made-by-Apple applications would talk to MobileMe without any problem. No idea whether Apple would release the protocol document, like Microsoft did recently, to encourage 3rd party interoperability.

I personally prefer SSH, RSync and SVN( maybe Mercury later), periodically back up to my friends in a different zip code for extra safety.

ID3 tag for programmers

Desktop February 7th, 2008

If you feel unease to do anything in a command line, or you have no idea about what regular expression is, please stop; I am quite sure this recipe is just not your cup of tea.

eyeD3util is a small, yet powerful IMHO, package that handles nasty ID3 tags that GUI may not offer. As the name suggests, it is based upon eyeD3, thanks to Travis’ great work. There are three apps targeting different etches:

eyeD3conv.py
eyeD3conv.py convert the ill-encoded tag, and convert them to Unicode. Check this for a full story. Though never tested other than Chinese GB2312, theoretically, it can handle the tag encoded in non-latin1 locale. Please leave a comment if you have a success story.

eyeD3ffn.py
What if no tag attached like Hanes? Well, if we could get the essential information, the track number and name, we may add other meta data using eyeD3. This script parses the filename via the regular expression to get all available meta data you need, for example:

eyeD3ffn.py “(?P<n>.*) - (?P<t>.*)\.mp3″ “02 - 祝我幸福.mp3″
Apply ID3 v2.3 tag to 02 - 祝我幸福.mp3
setTrackNum:  [‘02′, None]
setTitle:  祝我幸福

eyeD3validate.py
To be a perfectionist, I would rather check whether the MP3 file includes all essential information required: title, artist, album, track number, year of publish and genre. This script just did the minimum, nothing less, nothing more.

Comments? Feedbacks?

Migrate to MTP

Desktop, Gentoo December 15th, 2007

About nine months ago, I tried to embrace MTP since Creative Lab does not support their own proprietorial protocol(libnjb is the open source implementation) in Windows Vista, and I was really frustrated by the lame upgrade support.

Here is a chance for me to get a 2nd generation Zune which is powered by MTP. Although libmtp is still in very early stage to bridge the gap, we could predict its future from the history.

Amarok supports MTP if the USE flag mtp is enabled. However, the latest stable version 1.4.7-r2 has a bug when transfer file with CJK characters. The bug happens when interfacing with libmtp:

int ret = LIBMTP_Send_Track_From_File(
-        m_device, bundle.url().path().latin1(), trackmeta,
+        m_device, bundle.url().path().local8Bit(), trackmeta,
         progressCallback, this, parent_id
     );

The bug is fixed in SVN (ticket), but if we take non-utf8-locale users into account, for example, MagicLinux takes GB2312 as the default locale, local8Bit may have more flexibility than hard-coded utf8, and it also worked in the UTF8 environment.

Here is the patch , and as usual, an ebuild for Gentoo users (manual).

Small fix for libnjb to transfer Chinese tags

Desktop, Gentoo July 17th, 2007

I once mentioned that some Chinese characters are missing in Creative ZenMirco when using Amarok + libnjb. I checked the libnjb-2.4.4 source code and found that the text codec conversion from UTF-8/ISO8859-1 to UCS2 big-endian is home-brew instead of the standard libiconv, maybe the libiconv is overkill since only three codecs are really needed. According to the specification of UTF-8

U-00000000 – U-0000007F: 0xxxxxxx
U-00000080 – U-000007FF: 110xxxxx 10xxxxxx
U-00000800 – U-0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx
U-00010000 – U-001FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
U-00200000 – U-03FFFFFF: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx
10xxxxxx
U-04000000 – U-7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx
10xxxxxx 10xxxxxx

while the libnjb developers made a small mistake, so all 0×80xx characters are categorized as abnormal.

if (numbytes == 2 && str[i+1] > 0×80) {
                        … …
                } else if (numbytes == 3 && str[i+1] > 0×80 && str[i+2] > 0×80) {
                        … …
                } else {
                  /* Abnormal string character, just skip */

Here is a patch against libnjb-2.2.4, you may adapt it to libnjb-2.2.5 as well. For Gentoo users’ convenience, here is the ebuild.

I am just curious why this bug has been here for such a long time. How many Chinese Linux/BSD users take UTF-8 as the locale, transfer music to Creative ZenMicro? Are these three factors are really small that make this almost never gonna happen?

HOWTO display Chinese in Creative ZenMicro using Amarok

Desktop, Gentoo June 25th, 2007

Creative is less creative in building software, that is why so many users are asking how to display Chinese character in Creative ZenMicro using either Windows Media Player or Creative MediaSource. But this company really build solid hardware, and I could resist the temptation of ZenMicro RED 5G (refurbished) 49$ with free shipping from Outpost. So I got another one and found the same annoyance happened to Amarok 1.4.6. Amarok is open sourced, that leave the door open for me to dig into the problem.

According to the solution,

1. Go to your Control Panel
2. Select Regional and Language Options
3. Go to the Advanced tab
4. See the Language for Non-Unicode programs
5. Select Chinese PRC
6. The system will prompt you to restart.

it looks like the Creative ZenMicro uses the GB2312 code page to display Chinese. So the first move to solve this problem is to convert the ID3 tag to GB2312 before the track is downloaded to the device:

// $TOPSRC/amarok/src/mediadevice/njb/track.cpp
    QTextCodec *codec = QTextCodec::codecFromName(“GB2312″);
    // orig: NJB_Songid_Addframe( songid, NJB_Songid_Frame_New_Title( m_bundle.title().utf8() ) );
    NJB_Songid_Addframe( songid, NJB_Songid_Frame_New_Title( codec->fromUnicode(m_bundle.title()) ) );

Good news is the old messy code disappeared, the bad news is we have new messy code. It is worthy understanding how the device stores the information and how libnjb is designed for the developers. So I sent an email to the libnjb developers, and got the reply from Linus Walleij in a short period:

The Zen Micro like all Zens use UCS2 as internal representation. However
the libnjb library uses UTF-8 as input/output format if requested, so it
shouldn’t matter.
… …
It is however very important that the client calls the libnjb function
NJB_Set_Unicode() with the UTF-8 flag, in order for it to work. Else
libnjb will assume encoding is in ISO8859-1 and drop a lot of information
by making approximations and mangling chinese totally. The call should be
made before any other initialization

I combed the Amarok’s source code, and found the bug, Amarok’s developers setup the Unicode after call the NJB_Discover, it may be too late. Once we move that function call earlier, it works. You can download this patch here, and if you are a Gentoo user, here is the ebuild. Check out this HOWTO if you are not clear how to setup the portage overlay.

Further reading showed that the problem is caused by the transport layer from Creative which is built without Unicode support, that drops the ball, and Windows user could do nothing but request Creative to rebuild the code with Unicode; or they can use libnjb derived application, such as NomadSync(not tested yet).

Update Some Chinese characters are missing without a hint, like 一, 言, no idea which cause the bug. If you are using Creative ZenMicro, could you help to test it in Windows and leave a comment here?