uaprofile2wurfl.pl: creating WURFL profiles right out of UAProf
by Max Rozanoff, Perpetum Mobile
uaprofile2wurfl.pl is a Perl script that does what its name promises:
Feed it a UAprof profile and you'll get a WURFL XML snippet representing the WURFL
profile of the same device.
Here is the script in action:
luca# perl uaprofile2wurfl.pl http://wap.sonyericsson.com/UAprof/R306R101.xml
<wurfl_patch>
<devices>
<device user_agent="" fall_back="__ver1" id="__ver1_"/>
<device user_agent="" actual_device_root="true" fall_back="generic" id="__ver1">
<group id="product_info">
<capability name="brand_name" value="SonyEricsson"/>
<capability name="model_name" value="R306"/>
</group>
<group id="markup">
<capability name="html_wi_oma_xhtmlmp_1_0" value="false"/>
<capability name="wml_1_2" value="true"/>
<capability name="wmlscript_1_3" value="false"/>
<capability name="wmlscript_1_0" value="true"/>
<capability name="wml_1_1" value="true"/>
<capability name="wmlscript_1_2" value="false"/>
<capability name="wmlscript_1_1" value="true"/>
<capability name="wml_1_3" value="true"/>
<capability name="preferred_markup" value="html_wi_oma_xhtmlmp_1_0"/>
<capability name="html_wi_w3_xhtmlbasic" value="false"/>
</group>
<group id="xhtml_ui">
<capability name="xhtmlmp_preferred_mime_type" value="text/html"/>
<capability name="xhtml_table_support" value="true"/>
</group>
<group id="display">
<capability name="columns" value="11"/>
<capability name="resolution_height" value="160"/>
<capability name="max_image_height" value="160"/>
<capability name="rows" value="9"/>
<capability name="max_image_width" value="128"/>
<capability name="resolution_width" value="128"/>
</group>
:
[omitted]
:
</device>
</devices>
</wurfl_patch>
Pretty straighforward, isn't it?
Of course, this was the simplest example possible. There are quite a few parameters
you can play with to fine tune how uaprofile2wurfl.pl works for you.
#-------------------------------------------------------
# usage:
# perl [-output_file -ua -uashort -suffix \
# -brand -model -voices -colors] uaprofile
# parameters: output_file - output file, STDOUT if omited
# ua - full user agent string
# uashort - short user agent string (will be used for
# parent device)
# suffix - suffix in wurflid. wurflid will be
# created as [BRAND]_[MODEL]_ver1_[SUFFIX]
# brand - manufacturer
# model - model name
# voices - amount of polyphonic voices
# colors - amount of main screen colors
# uaprofile - phone profile, can be a link
Here is one usage example:
# example: perl uaprofile2wurfl.pl \
# -output_file tst \
# -ua 'SonyEricssonR306/R1AB002 Browser/1.0 \
Profile/MIDP-2.0 Configuration/CLDC-1.1' \
# -uashort SonyEricssonR306 \
# -suffix sub10 \
# -brand SonyEricsson \
# -model R306 \
# -voices 32 \
# -colors 65536 \
# http://wap.sonyericsson.com/UAprof/R306R101.xml
Will the script run out of the box? it should, unless you are on Windows.
Luca was running ActiveState and had some troubles, but nothing that couldn't be fixed
with the following advice:
To run this script you should install extra modules:
XML-NamespaceSupport
XML-LibXML-Common
XML-SAX
XML-LibXML
if you are using perl under windows, please use tcool repositary
to install this modules:
From binary perl directory run ppm.bat
(for me its was d:\perl\bin\ppm.bat)
In this program go to menu Edit->Preference, then remove
the activestate repository and after add a repository with name "tcool"
and location "http://ppm.tcool.org/archives/",
then install listed modules.
Here is the list of capabilities "covered" by the script:
"product_info": brand_name,model_name
"markup": html_wi_oma_xhtmlmp_1_0,wml_1_2,wmlscript_1_3,wmlscript_1_0,wml_1_1,
wmlscript_1_2,wmlscript_1_1,wml_1_3,preferred_markup,html_wi_w3_xhtmlbasic
"xhtml_ui": xhtmlmp_preferred_mime_type,xhtml_table_support,
"display": columns,resolution_height,max_image_height,rows,max_image_width,
resolution_width
"image_format": png,bmp,wbmp,jpg,gif_animated,gif,colors
"sound_format": mp3,voices,rmf,imelody,amr,awb,mms_midi_monophonic,mms_midi_polyphonic,
midi_polyphonic,au,ringtone_mmf,midi_monophonic,mmf,aac,wav
"object_download": ringtone_voices,video_mp4,video_3gpp,video,video_vcodec_h263_0,
directdownload_support
"drm": oma_v_1_0_combined_delivery,oma_v_1_0_forwardlock,oma_v_1_0_separate_delivery
"mms": receiver,mms_awb,mms_amr,mms_au,mms_max_size,mms_aac,mms_midi_monophonic,
mms_midi_polyphonic,mms_mmf,mms_max_width,mms_video,mms_bmp,mms_png,
mms_max_height,mms_vcalendar,mms_wbmp,mms_3gpp,mms_jpeg_baseline,sender,
mms_wav,mms_mp4,mms_mp3,mms_gif_static,mms_vcard
Of course, comments and suggestions are welcome. You can direct them at
Max Rozanoff perpetum.mobile@gmail.com, Nandu ltd, Internet Development
Download
Click here to download uaprofile2wurfl.pl
|