#include "fb_lib.h"
#include "game.h"
#include "vcard.h"
INT*viewPos,*cardPos,viewLen,dataLen;
U8 *viewBuf,*viewData,**viewTitle;
INT totalLine,startLine,endLine,dispLine;
U8 *lineBuf,cardVersion;
static const U8 UtfEncode8Bit[] = "CHARSET=UTF-8;ENCODING=8BIT:";
static const U8 UtfEncodePrin[] = "CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE";
static INT decLen[2] = {28,39};
static int viewLinePos[MAX_LINE+1]={10,60,90,120,150,180};
static const U8 *CardDataTitle[2][13]=
{
//outlook
{
"\r\nN:",//姓名
"\r\nTITLE:",//职业
"\r\nORG:",//组织
"\r\nTEL;WORK;VOICE:",//工作电话
"\r\nTEL;HOME;VOICE:",//家庭电话
"\r\nTEL;CELL;VOICE:",//手机
"\r\nTEL;WORK;FAX:",//传真
"\r\nADR;WORK:",//地址
"\r\nEMAIL;PREF;INTERNET:",//EMAIL
"\r\nURL;WORK:",//主页
"",//无语言
"",//无性别
"",//无生日
},
{
"\r\nX-SKYPE-DISPLAYNAME",//显示的名称
"",//无职业
"",//无组织
"\r\nTEL;WORK",//工作电话
"\r\nTEL;HOME",//家庭电话
"\r\nTEL;CELL",//手机
"",//无传真
"",//无地址,包含在国家,PROVINCE,CITY子串之中.
"\r\nEMAIL",//EMAIL
"\r\nURL", //主页
"\r\nX-SKYPE-LANGUAGE:",//语言
"\r\nX-SKYPE-SEX:",//性别
"\r\nBDAY:",//生日
}
};
static const U8 *CardViewTitle[]=
{
"",//姓名
"",//职业
"",//单位
"电话(O):",
"电话(H):",
"手 机 :",
"传 真 :",
"地 址 :",
"E-Mali :",
"主 页 :",
"语 言 :",
"性 别 :",
"生 日 :",
"邮 编 :",
};
void GetNewLineData_Skype(U8 *dataBuf,U8 index)
{
INT pos;
U8 *ptr = dataBuf;
if(*ptr == ':')
{
ptr += 1;
pos = GetSubString(ptr,"\r\n",0);
if(pos >= 0)
{
memcpy(viewBuf+viewLen,ptr,pos);
viewLen += pos;
viewTitle[totalLine] = CardViewTitle[index];
viewPos[totalLine ++] = viewLen;
}
}
else if(*ptr == ';')
{
ptr += 1;
if(mystrcmp(ptr,UtfEncode8Bit,decLen[0]) == 0)
{
ptr += decLen[0];
pos = GetSubString(ptr,"\r\n",0);
if(pos)
{
pos = Utf8Bit2Gb(ptr,viewBuf+viewLen,pos);
viewLen += pos;
viewTitle[totalLine] = CardViewTitle[index];
viewPos[totalLine ++] = viewLen;
}
}
else if(mystrcmp(ptr,UtfEncodePrin,decLen[1])==0)
{
ptr += decLen[0];
pos = GetSubString(ptr,"\r\n",0);
if(pos)
{
pos = UtfPrin2Gb(ptr,viewBuf+viewLen,pos);
viewLen += pos;
viewTitle[totalLine] = CardViewTitle[index];
viewPos[totalLine ++] = viewLen;
}
}
}
}
void GetName_outlook(U8 *dataBuf)
{
//得到姓名
INT i;
INT pos = GetSubString(dataBuf,CardDataTitle[0][CNAME],1);//姓.名.英文称呼.中文称呼
if(pos >= 0)
{
U8 *nameBuf[10];
INT nameLen[10]={0},i;
U8 *ptr = dataBuf + pos;
for(i = 0; i < 5; i ++)
{
nameBuf[i] = ptr;
if(i == 4)
nameLen[i] = GetSubString(ptr,"\r",1);
else
nameLen[i] = GetSubString(ptr,";",1);
ptr += nameLen[i];
}
for(i = 0; i < 5; i ++)
{
if(i == 3)
continue;
memcpy(viewBuf+viewLen,nameBuf[i],nameLen[i]-1);
viewLen += nameLen[i] - 1;
}
viewTitle[totalLine] = CardViewTitle[CNAME];
viewPos[totalLine ++] = viewLen;
}
else//未命名
{
viewTitle[totalLine] = CardViewTitle[CNAME];
strcpy(viewBuf+viewLen,"未命名");
viewLen += 6;
viewPos[totalLine ++] = viewLen;
}
}
void GetMetier_outlook(U8 *dataBuf)
{//职务
INT pos = GetSubString(dataBuf,CardDataTitle[0][CMETIER],1);
if(pos >= 0)
{
U8 *ptr = dataBuf + pos;
pos = GetSubString(ptr,"\r\n",0);
if(pos >= 0)
{
memcpy(viewBuf+viewLen,ptr,pos);
viewLen += pos;
viewTitle[totalLine] = CardViewTitle[CMETIER];
viewPos[totalLine ++] = viewLen;
}
}
}
void GetOrg_outlook(U8 *dataBuf)
{
//公司+部门
INT pos = GetSubString(dataBuf,CardDataTitle[0][CORG],1);
if(pos >= 0)
{
U8 *ptr = dataBuf + pos;
INT len = GetSubString(ptr,"\r\n",0);
if(len >= 0)
{
for(pos = 0; pos < len; pos ++)
{
if(ptr[pos] != ';')
viewBuf[viewLen ++] = ptr[pos];
}
viewTitle[totalLine] = CardViewTitle[CORG];
viewPos[totalLine ++] = viewLen;
}
}
}
void GetAddr_outlook(U8 *dataBuf)
{
//地址+邮编
INT pos = GetSubString(dataBuf,CardDataTitle[0][CADDR],1); //ADR;WORK:;硬盘MP3;体育西路;海淀区;北京市;10086;中国
if(pos >= 0)
{
INT AddrLen[10],i;
U8 *AddrBuf[10];
U8 *ptr = dataBuf + pos;
for(i = 0; i < 7; i ++)
{
AddrBuf[i] = ptr;
if(i == 6)
AddrLen[i] = GetSubString(ptr,"\r",1);
else
AddrLen[i] = GetSubString(ptr,";",1);
ptr += AddrLen[i];
}
//地址
for(i = 6; i > 0; i --)
{
if(i == 5)
continue;
memcpy(viewBuf+viewLen,AddrBuf[i],AddrLen[i]-1);
viewLen += AddrLen[i] - 1;
}
viewTitle[totalLine] = CardViewTitle[CADDR];
viewPos[totalLine ++] = viewLen;
//邮编
i = 5;
memcpy(viewBuf+viewLen,AddrBuf[i],AddrLen[i]-1);
viewLen += AddrLen[i] - 1;
viewTitle[totalLine] = CardViewTitle[CCODE];
viewPos[totalLine ++] = viewLen;
}
}
void GetCardTel_outlook(U8 *dataBuf)
{
U8 *ptr;
INT pos,i;
for( i = 0; i < 4; i ++)
{
ptr = dataBuf;
pos = GetSubString(ptr,CardDataTitle[0][CWORKTEL+i],1);
if(pos == -1)
continue;
ptr += pos;
pos = GetSubString(ptr,"\r\n",0);
if(pos >= 0)
{
memcpy(viewBuf+viewLen,ptr,pos);
viewLen += pos;
viewTitle[totalLine] = CardViewTitle[CWORKTEL+i];
viewPos[totalLine ++] = viewLen;
}
}
}
void GetEmail_outlook(U8 *dataBuf)
{
INT pos = GetSubString(dataBuf,CardDataTitle[0][CEMAIL],1);
if(pos >= 0)
{
U8 *ptr = dataBuf + pos;
pos = GetSubString(ptr,"\r\n",0);
if(pos >= 0)
{
memcpy(viewBuf+viewLen,ptr,pos);
viewLen += pos;
viewTitle[totalLine] = CardViewTitle[CEMAIL];
viewPos[totalLine ++] = viewLen;
}
}
}
void GetInternet_outlook(U8 *dataBuf)
{
INT pos = GetSubString(dataBuf,CardDataTitle[0][CURL],1);
if(pos >= 0)
{
U8 *ptr = dataBuf + pos;
pos = GetSubString(ptr,"\r\n",1);
memcpy(viewBuf+viewLen,ptr,pos);
viewLen +=pos;
viewTitle[totalLine] = CardViewTitle[CURL];
viewPos[totalLine ++] = viewLen;
}
}
INT GetCardNum(void)
{
INT totalnum,datasize,pos;
U8 *dataBuf = DiskData;
totalnum = datasize = pos =0;
cardPos[totalnum] = datasize;
while(1)
{
pos = GetSubString(dataBuf,"BEGIN:VCARD",0);
if(pos == -1)
break;
pos = GetSubString(dataBuf,"END:VCARD",1);
if(pos == -1)
break;
dataBuf += pos;
cardPos[totalnum +1] = cardPos[totalnum] + pos;
totalnum += 1;
}
if(totalnum == 0)
MessageBox(NULL,FileErrorMsg[sPara.language][0],MB_OK);
return totalnum;
}
INT InitCardData_outlook(U8 *dataBuf)
{
viewLen = totalLine= 0;
viewPos[totalLine ++] = viewLen;
GetName_outlook(dataBuf);
GetMetier_outlook(dataBuf);
GetCardTel_outlook(dataBuf);
GetOrg_outlook(dataBuf);
GetAddr_outlook(dataBuf);
GetEmail_outlook(dataBuf);
GetInternet_outlook(dataBuf);
viewBuf[viewLen] = 0;
return totalLine -1;
}
static void GetName_Skype(U8 *dataBuf)//inx,0,name,1,username,2,昵称3,显示名称
{
INT pos = GetSubString(dataBuf,CardDataTitle[1][CNAME],1);
if(pos>= 0)
GetNewLineData_Skype(dataBuf+pos,CNAME);
else if((pos = GetSubString(dataBuf,"\r\nX-SKYPE-USERNAME",1)) >= 0)
GetNewLineData_Skype(dataBuf+pos,CNAME);
else if((pos = GetSubString(dataBuf,"\r\nN",1)) >= 0)
GetNewLineData_Skype(dataBuf+pos,CNAME);
}
static void GetBirthDay_Skype(U8 *dataBuf)
{
INT pos;
U8 *ptr;
pos = GetSubString(dataBuf,CardDataTitle[1][CBIRTHDAY],1);
if(pos>= 0)
{
ptr = dataBuf + pos;
pos = GetSubString(ptr,"\r\n",0);
if(pos == 6)
{
memcpy(viewBuf+viewLen,ptr,4);
viewLen += 4;
memcpy(viewBuf+viewLen,"年",2);
viewLen += 2;
memcpy(viewBuf+viewLen,ptr+4,2);
viewLen += 2;
memcpy(viewBuf+viewLen,"月",2);
viewLen += 2;
memcpy(viewBuf + viewLen,ptr + 6,2);
viewLen += 2;
memcpy(viewBuf+viewLen,"日",2);
viewLen += 2;
viewTitle
评论0