[icq-devel] Problems processing tlv 0x2711 in advanced message



Christophe Minguet (freesurf) c.minguet at freesurf.fr
Tue Nov 26 01:17:38 CET 2002


Hi ! Your right ... The doc talks about a URL-type message 
.. It's actualy an SMS-type message ... Here is how i decode it :
Sorry, it's late, so i copy/paste my java code, and it's kinda dirty ...
But .. It's working :)
       
        char[]data=tlv2711.getData(); // the Value of TLV 2711
        if (data[0]!=0x1B) return; // not a message !
        byte msgType= (byte)data[45];
        byte msgFlag= (byte)data[46];
        if (msgType==26) // an SMS type message, can be url, contact req
/ send, greeting card
        {
          int
msgLen=Utils.toInt(Utils.reverse(Utils.subArray(data,51,53)));
          int pos=53+msgLen;
          int
msgTypeLen=Utils.toInt(Utils.reverse(Utils.subArray(data,pos,pos+2)));
          int pos2=pos+(2+18);
          int
msgTypeDescLen=Utils.toInt(Utils.reverse(Utils.subArray(data,pos2,pos2+4
)));
          pos2+=4;
          String msgTypeDesc=new
String(Utils.subArray(data,pos2,pos2+msgTypeDescLen));
          pos+=msgTypeLen+2;
          int
nextLen=(int)Utils.toLong(Utils.reverse(Utils.subArray(data,pos,pos+4)))
;
          pos+=4;
          String url="";
          while (nextLen>0)
          {
            int
urlLen=(int)Utils.toLong(Utils.reverse(Utils.subArray(data,pos,pos+2)));
            int
urlLen2=(int)Utils.toLong(Utils.reverse(Utils.subArray(data,pos+2,pos+4)
));
            pos+=4;
            if (urlLen2==0)
            {
              url=new
String(Utils.unicodeToUTF8(Utils.subArray(data,pos,pos+urlLen)));
              pos+=urlLen;
              nextLen-=(urlLen+4);
            }
            else nextLen-=4;
          }
        }

msgTypeDesc is a string describing what in in "url" 
this "url" fields contains subfields separated by character 0xFE 

Hope this will help. 
C u 

Chris





More information about the icq-devel mailing list