3.3 函数实现 插件向外暴露的都是标准的操作接口,都从基类plugBse、absPimCpp继承而来,或者从其他插件功能继承再加以重写。有些型号手机需要重新实现所有的基类接口,从别的派生类继承实现起来比较困难,这样也是开发量最大的情况。以下对于数据封装后会以absfile形式存在,也就是虚拟文件,根据实现的函数不同从而具有各自不同的接口,但都以两种方式存在,一种是在本地磁盘建立一个文件,所有对该方式建立的absfile操作,都在操作标准的磁盘文件;另外一种是在内存中申请一动态堆栈区,来保存信息从而实现absfile,然后可以用操作文件方式对该内存区进行数据处理,这也是配置的内存文件。以下是在开发中实现的接口: 内容来自论文无忧网 www.paper51.com
3.3.1 配置信息 paper51.com 通过实现getProf函数,给出配置信息到absFile可以在PC与软件连接中,传递给界面一些参数,让界面来根据文件配置加载相应的功能,不仅对于该模块需要实现getProf函数,所有模块都需要根据该模块的特性来重写接口: 内容来自论文无忧网 www.paper51.com intMotoVcs::getProf(AbsFile *prof) paper51.com { paper51.com int ret, titleLen; 内容来自www.paper51.com
char rsp[256]; 内容来自www.paper51.com if (this->vcsProfObj) { 内容来自论文无忧网 www.paper51.com prof->printf(prof,"%s", this->vcsProfObj); http://www.paper51.com AbsFile_dbgOut(prof); 内容来自论文无忧网 www.paper51.com
return 0; http://www.paper51.com } copyright paper51.com if ((ret = enter()) < 0) { paper51.com
TRACE_LINE(); http://www.paper51.com
return ret; copyright paper51.com } http://www.paper51.com // rsp: ..+MDBR:500,44,64,8,2....OK.. paper51.com if ((ret = AtTe_getAny(this->at,"+MDBR=?", "+MDBR", http://www.paper51.com "+CME",rsp, sizeof(rsp), NULL)) < 0) http://www.paper51.com return ret; paper51.com AbsFileMem_reset(this->rspBuf,rsp, sizeof(rsp), ret, 0); paper51.com if ((ret =AtLex_do(this->rspBuf, this->token)) != AT_ATOM) paper51.com return-CNSE_PROT; paper51.com // 500 paper51.com if ((ret =AtLex_do(this->rspBuf, this->token)) != AT_NUM) 内容来自www.paper51.com
return-CNSE_PROT; paper51.com
if ((ret =AtLex_do(this->rspBuf, this->token)) != ',') paper51.com
return-CNSE_PROT; 内容来自www.paper51.com // 44 内容来自论文无忧网 www.paper51.com if ((ret =AtLex_do(this->rspBuf, this->token)) != AT_NUM) http://www.paper51.com return-CNSE_PROT; paper51.com
if ((ret =AtLex_do(this->rspBuf, this->token)) != ',') copyright paper51.com return -CNSE_PROT; http://www.paper51.com // 64 copyright paper51.com if ((ret =AtLex_do(this->rspBuf, this->token)) != AT_NUM) http://www.paper51.com return-CNSE_PROT; paper51.com
titleLen =atoi(StrBuf_buf(this->token)); paper51.com prof->printf(prof,"[Base]\r\n"); copyright paper51.com
prof->printf(prof,"OpSupp=getInfo,listById,writeById,readById,removeById\r\n"); copyright paper51.com prof->printf(prof,"[FieldListEvent]\r\n"); copyright paper51.com prof->printf(prof,"(T)(%d)(UNICODE)=\r\n", titleLen * 2); paper51.com prof->printf(prof,"(DA)(60)(UNICODE)=\r\n"); 内容来自www.paper51.com prof->printf(prof,"(DS)(60)(UNICODE)=\r\n"); paper51.com prof->printf(prof,"(DE)(60)(UNICODE)=\r\n"); 内容来自www.paper51.com prof->printf(prof,"(R)(60)(UNICODE)=selList(0,1,2,3,4,6)\r\n"; http://www.paper51.com return 0; copyright paper51.com } copyright paper51.com 在absfile中会得到信息: http://www.paper51.com [Base] 内容来自论文无忧网 www.paper51.com OpSupp=listById,readById,writeById,removeById,getInfo 内容来自www.paper51.com [FieldListEvent] http://www.paper51.com (T)(%d)(UNICODE)= 内容来自www.paper51.com (DA)(60)(UNICODE)= paper51.com (DS)(60)(UNICODE)= 内容来自www.paper51.com (DE)(60)(UNICODE)= http://www.paper51.com
(R)(60)(UNICODE)=selList(0,1,2,3,4,6) copyright paper51.com
从该配置信息可以看出支持操作有:下载、读取、新增、删除。 内容来自www.paper51.com 同时也传递给界面所支持的字段有:T、DA、DS、DE、R和对每一个字段编码方式、字符长度作了约束。其中selList中选项表示可能的取值。 copyright paper51.com 3.3.2 构造函数实现 copyright paper51.com
构造函数中分为该功能模块构造、和操作时的构造,但都是为了能满足对内存堆栈申请、操作时对事件或者日程安排的开关: paper51.com (1)功能模块构造:实现对虚拟文件的堆栈分配、存储信息的堆栈分配,还有相关信息的初始化。MotoVcs::MotoVcs(ItfMng*itfMng, AtTe *_at, char *_vcsProfObj) http://www.paper51.com
:PlugBase(itfMng) paper51.com { copyright paper51.com this->at= _at; copyright paper51.com this->rspBuf= AbsFileMem_new(NULL, 0, 0, 0); http://www.paper51.com
this->token= StrBuf_new(128); paper51.com
this->maxReadPerTime= 1; copyright paper51.com
this->cs[0]= '\0'; copyright paper51.com this->vcsProfObj= _vcsProfObj; http://www.paper51.com
} 内容来自www.paper51.com (2)功能操作构造:当要对vEvent或者vTodo操作时候,根据系统的设计,需要设置信息开关 +MDBL=1,否则不能读取和其余操作,设置编码方式,但都需要先从手机中读取,然后根据支持操作来设置编码,界面都是统一按照UTF-8编码数据、该款手机优先支持UCS2编码,这些是由手机系统所决定。 内容来自www.paper51.com int MotoVcs::init() paper51.com { 内容来自论文无忧网 www.paper51.com intret; 内容来自www.paper51.com charbuf[128], *cs; copyright paper51.com CnsCharsetcharset; 内容来自www.paper51.com if(((ret = AtTe_setAny(this->at, "+MDBL=1", "+CME", NULL))< 0) && 内容来自www.paper51.com
(NetUtil_isFaultErr(ret))) http://www.paper51.com returnret; paper51.com
if((ret = GmcTe3_testCs(this->at, buf, sizeof(buf))) < 0) { http://www.paper51.com if(NetUtil_isFaultErr(ret)) 内容来自论文无忧网 www.paper51.com
returnret; http://www.paper51.com
else 内容来自www.paper51.com
return0; 内容来自www.paper51.com } 内容来自论文无忧网 www.paper51.com else{ paper51.com //先支持 UCS2 编码 copyright paper51.com
if(StrUtil_stristr(buf, "UCS2")) { paper51.com charset= CS_UCS2; 内容来自www.paper51.com cs= "UCS2"; 内容来自论文无忧网 www.paper51.com } copyright paper51.com
elseif (StrUtil_stristr(buf, "UTF-8")) { 内容来自www.paper51.com charset= CS_UTF8; 内容来自论文无忧网 www.paper51.com cs= "UTF-8"; 内容来自论文无忧网 www.paper51.com elseif (StrUtil_stristr(buf, "UTF8")) { 内容来自www.paper51.com this->utf8Ira= CNS_TRUE; 内容来自www.paper51.com charset= CS_UTF8; 内容来自www.paper51.com cs= "UTF8"; http://www.paper51.com
} paper51.com else{ 内容来自论文无忧网 www.paper51.com charset= CS_ASCII; http://www.paper51.com
cs= "GSM"; 内容来自论文无忧网 www.paper51.com } paper51.com if(*this->cs) { copyright paper51.com cs= this->cs; 内容来自论文无忧网 www.paper51.com if(StrUtil_stristr(cs, "UTF-8")) paper51.com charset= CS_UTF8; http://www.paper51.com // for MOTOs 内容来自论文无忧网 www.paper51.com elseif (StrUtil_stristr(cs, "UTF8")) { copyright paper51.com charset= CS_UTF8; 内容来自www.paper51.com
this->utf8Ira= CNS_TRUE; paper51.com } 内容来自www.paper51.com elseif (StrUtil_stristr(cs, "UCS2")) 内容来自论文无忧网 www.paper51.com
charset= CS_UCS2; 内容来自www.paper51.com else paper51.com charset= CS_ASCII; http://www.paper51.com } paper51.com if((ret = GmcTe3_setCs(this->at, cs)) < 0) { copyright paper51.com
if(NetUtil_isFaultErr(ret)) http://www.paper51.com returnret; copyright paper51.com else paper51.com return0; 内容来自www.paper51.com } paper51.com this->charset= charset; copyright paper51.com this->savedCharset= this->charset; copyright paper51.com
} 内容来自www.paper51.com return0; paper51.com } http://www.paper51.com 3.3.3信息获取 http://www.paper51.com
在对事件或者日程下载时候,会两次操作接口getInfo,第一次传递给界面信息如:最大索引、存储容量、剩余空间、有的可以读取出使用量等信息。第二次得到最大索引、存储容量等信息,给循环控制参数,用来设置读取时候方式。 内容来自论文无忧网 www.paper51.com
对于串口缓冲区中数据都是通过AtLex_do,或者BnfLex_do来对字段解析。然后保存到变量中,这种读取方式是在操作内存文件。 内容来自论文无忧网 www.paper51.com intMotoVcs::getInfo(StrBuf* did, int* capa, int* used, http://www.paper51.com
int* freed, int *indexLow, int*indexHigh, int* indexOwn) 内容来自www.paper51.com { 内容来自www.paper51.com int ret; 内容来自论文无忧网 www.paper51.com char rsp[256]; paper51.com if ((ret = enter()) < 0) copyright paper51.com return ret; paper51.com
if (capa) copyright paper51.com
*capa = -1; 内容来自论文无忧网 www.paper51.com
if (used) 内容来自论文无忧网 www.paper51.com *used = -1; paper51.com if (freed) http://www.paper51.com *freed =-1; 内容来自论文无忧网 www.paper51.com if (indexLow) paper51.com
*indexLow =-1; paper51.com if (indexHigh) 内容来自www.paper51.com *indexHigh= -1; http://www.paper51.com // rsp: ..+MDBR: 500,44,64,8,2....OK.. http://www.paper51.com if ((ret = AtTe_getAny(this->at,"+MDBR=?", "+MDBR", copyright paper51.com "+CME",rsp, sizeof(rsp), NULL)) < 0) http://www.paper51.com
return ret; 内容来自www.paper51.com AbsFileMem_reset(this->rspBuf,rsp, sizeof(rsp), ret, 0); copyright paper51.com
if ((ret =AtLex_do(this->rspBuf, this->token)) != AT_ATOM) copyright paper51.com return-CNSE_PROT; paper51.com
if ((ret =AtLex_do(this->rspBuf, this->token)) != AT_NUM) copyright paper51.com return-CNSE_PROT; paper51.com if (capa) 内容来自论文无忧网 www.paper51.com *capa =atoi(StrBuf_buf(this->token)); http://www.paper51.com if (indexLow) copyright paper51.com *indexLow =0; 内容来自论文无忧网 www.paper51.com
if (indexHigh) http://www.paper51.com *indexHigh= atoi(StrBuf_buf(this->token)) - 1; http://www.paper51.com if ((ret =AtLex_do(this->rspBuf, this->token)) != ',') http://www.paper51.com return-CNSE_PROT; 内容来自www.paper51.com if ((ret =AtLex_do(this->rspBuf, this->token)) != AT_NUM) copyright paper51.com return-CNSE_PROT; 内容来自论文无忧网 www.paper51.com if (used) 内容来自论文无忧网 www.paper51.com *used =atoi(StrBuf_buf(this->token)); copyright paper51.com if (indexOwn) http://www.paper51.com
*indexOwn =-1; 内容来自论文无忧网 www.paper51.com return 0; 内容来自论文无忧网 www.paper51.com } 内容来自www.paper51.com
3.3.4数据下载 http://www.paper51.com 当打开读取开关后,更具读取AT命令,设置读取的条数,也就是一次让手机返回给串口缓存数据包大小,可以一次读取一条信息,也可以一次读取十条信息。Motoralor系列手机不能首先得到有多少条信息记录,所以只能读取所有的记录,即使只有一条也会读取全部信息,由于每次解析一条,所以会多次调用listById接口。每一次调用,都是读取缓存数据,然后根据前面章节中提到的字段依次解析存放到一个结构体中,对标题、日期等都需要经过编码后载保存。由于Motoralor系列手机不能直接读取出结束时间,只能得到开始时间到结束时间的分钟数,不足一分钟会置为0保存,然后通过函数换算成结束日期和时间,最后读取保存的字段、字段值写成一个标准格式的vCalendar内存文件传递给界面,用于显示给用户: copyright paper51.com
int MotoVcs::listById(int *index, AbsFile *item, CnsBoolfirst) copyright paper51.com
{ paper51.com intret, tmp; copyright paper51.com charcmd[64]; http://www.paper51.com if((ret = enter()) < 0) copyright paper51.com returnret; 内容来自论文无忧网 www.paper51.com if(first) { http://www.paper51.com if((ret = getInfo(NULL, NULL, &this->used, NULL, http://www.paper51.com &this->indexLow,&this->indexHigh, NULL)) < 0) 内容来自论文无忧网 www.paper51.com returnret; 内容来自论文无忧网 www.paper51.com if (this->used== 0 || ((tmp = this->indexHigh - this->indexLow + 1) == 0)) 内容来自www.paper51.com return0; paper51.com
this->listed= 0; paper51.com this->curIndex = this->indexLow + min(this->maxReadPerTime,tmp); 内容来自论文无忧网 www.paper51.com sprintf(cmd,"+MDBR=%d,%d", this->indexLow, this->curIndex - 1); http://www.paper51.com if((ret = AtTe_sendCmd(this->at, cmd)) < 0) 内容来自论文无忧网 www.paper51.com returnret; http://www.paper51.com
} paper51.com ret =readOne(index, item); 内容来自www.paper51.com if (ret== 1) { http://www.paper51.com AbsFile_dbgOut(item); 内容来自www.paper51.com this->listed++; paper51.com returnret; 内容来自论文无忧网 www.paper51.com } 内容来自论文无忧网 www.paper51.com else if(ret < 0) 内容来自www.paper51.com
returnret; 内容来自www.paper51.com else if(ret == 0) { 内容来自www.paper51.com
if(this->used >= 0 && this->listed >= this->used) copyright paper51.com return0; paper51.com while((tmp = this->indexHigh - this->curIndex + 1) > 0 && paper51.com (this->used< 0 || this->listed < this->used)) { 内容来自www.paper51.com this->oldCur= this->curIndex; copyright paper51.com this->curIndex+= min(tmp, this->maxReadPerTime); copyright paper51.com sprintf(cmd,"+MDBR=%d,%d", this->oldCur, this->curIndex - 1); 内容来自www.paper51.com
if((ret = AtTe_sendCmd(this->at, cmd)) < 0) { http://www.paper51.com TRACE_LINE(); copyright paper51.com returnret; copyright paper51.com } copyright paper51.com if((ret = readOne(index, item) == 1)) { 内容来自www.paper51.com this->listed++; 内容来自www.paper51.com AbsFile_dbgOut(item); paper51.com returnret; http://www.paper51.com } 内容来自论文无忧网 www.paper51.com elseif (ret != 0) paper51.com returnret; paper51.com
} copyright paper51.com return0; copyright paper51.com } 内容来自论文无忧网 www.paper51.com return0; copyright paper51.com } 内容来自www.paper51.com
该函数定义为类的私有函数,主要是来读取一条记录后返回,所有的字段检索,字段值存储,以及写成标准格式的absfile都在内部实现: paper51.com int MotoVcs::readOne(int *index, AbsFile *item) paper51.com { 内容来自论文无忧网 www.paper51.com intret, bufLen, rcvd, i = 0, ruleType; 内容来自论文无忧网 www.paper51.com charbuf[1024], rule[8]; copyright paper51.com CnsResultresult; copyright paper51.com
VcalFieldvCalFields[10]; copyright paper51.com
CnsTimecnsDate, cnsMargin, cnsDst; 内容来自论文无忧网 www.paper51.com
VpiRulevpiRule; http://www.paper51.com bufLen= sizeof(buf); paper51.com if((ret = AtTe_recvFrmLine(this->at, NULL, buf, bufLen, copyright paper51.com
&rcvd,&result, NULL)) < 0) copyright paper51.com returnret; 内容来自www.paper51.com if (ret== AT_RSP_RESULT) paper51.com
return0; paper51.com
while(1) { 内容来自论文无忧网 www.paper51.com if(StrUtil_strincmp(buf, "+MDBRE:", strlen("+MDBRE:")) == 0){ copyright paper51.com if((ret = AtTe_recvFrmLine(this->at, NULL, buf, bufLen, 内容来自论文无忧网 www.paper51.com &rcvd,&result, NULL)) < 0) 内容来自论文无忧网 www.paper51.com returnret; 内容来自www.paper51.com if(ret == AT_RSP_RESULT) paper51.com return0; 内容来自论文无忧网 www.paper51.com } 内容来自论文无忧网 www.paper51.com else paper51.com
break; copyright paper51.com } 内容来自论文无忧网 www.paper51.com memset(vCalFields,0x00, sizeof(vCalFields)); copyright paper51.com //+MDBR:1,"title",1,1,"14:00","05-10-2007",60,"13:55","05-10-2007",1 http://www.paper51.com AbsFileMem_reset(this->rspBuf,buf + 6, bufLen - 6, rcvd - 6, 0); http://www.paper51.com // 得到索引号 copyright paper51.com
if((ret = AtLex_do(this->rspBuf, this->token)) != AT_NUM) copyright paper51.com return-CNSE_PROT; 内容来自www.paper51.com if(index) copyright paper51.com *index= atoi(StrBuf_buf(this->token)); 内容来自论文无忧网 www.paper51.com
// 得到标题,进行编码使其从UCS2编码,转换到界面的UTF-8编码方式 内容来自www.paper51.com
if((ret = AtLex_do(this->rspBuf, this->token)) != ',') 内容来自www.paper51.com return-CNSE_PROT; 内容来自www.paper51.com if ((ret =BnfLex_get1(this->rspBuf, this->token, ",")) != BNF_STR&& ret != BNF_ATOM) 内容来自www.paper51.com return-CNSE_PROT; copyright paper51.com StrUtil_strxfrm(vCalFields[i].type,"T", sizeof("T")); copyright paper51.com strPhoneToStd(StrBuf_buf(this->token), 内容来自论文无忧网 www.paper51.com
vCalFields[i].value,sizeof(vCalFields[i].value)); paper51.com i++; 内容来自论文无忧网 www.paper51.com
if((ret = AtLex_do(this->rspBuf, this->token)) != ',') 内容来自www.paper51.com return-CNSE_PROT; 内容来自www.paper51.com if((ret = AtLex_do(this->rspBuf, this->token)) != AT_NUM) http://www.paper51.com return-CNSE_PROT; http://www.paper51.com if((ret = AtLex_do(this->rspBuf, this->token)) != ',') 内容来自www.paper51.com return-CNSE_PROT; 内容来自论文无忧网 www.paper51.com if((ret = AtLex_do(this->rspBuf, this->token)) != AT_NUM) 内容来自论文无忧网 www.paper51.com return-CNSE_PROT; 内容来自www.paper51.com // 得到开始时间 http://www.paper51.com if((ret = AtLex_do(this->rspBuf, this->token)) != ',') paper51.com
return-CNSE_PROT; 内容来自论文无忧网 www.paper51.com if((ret = AtLex_do(this->rspBuf, this->token)) != AT_STRING) http://www.paper51.com return-CNSE_PROT; 内容来自论文无忧网 www.paper51.com
memset(&cnsDate,0x00, sizeof(cnsDate)); paper51.com
sscanf(StrBuf_buf(this->token),"%d:%d",&cnsDate.hour, 内容来自www.paper51.com &cnsDate.minute); 内容来自论文无忧网 www.paper51.com // 得到开始日期, copyright paper51.com if((ret = AtLex_do(this->rspBuf, this->token)) != ',') 内容来自论文无忧网 www.paper51.com
return-CNSE_PROT; 内容来自www.paper51.com if((ret = AtLex_do(this->rspBuf, this->token)) != AT_STRING) 内容来自www.paper51.com return-CNSE_PROT; 内容来自www.paper51.com sscanf(StrBuf_buf(this->token),"%d-%d-%d", http://www.paper51.com &cnsDate.month,&cnsDate.day, &cnsDate.year); http://www.paper51.com StrUtil_strxfrm(vCalFields[i].type,"DS", sizeof("DS")); 内容来自www.paper51.com Iso8601Date_enc(&cnsDate,vCalFields[i].value, copyright paper51.com
sizeof(vCalFields[i].value),CNS_TRUE); 内容来自www.paper51.com i++; 内容来自论文无忧网 www.paper51.com // 得到结束日期,由于该系列手机不能直接得到结束时间,需要换算 内容来自www.paper51.com if((ret = AtLex_do(this->rspBuf, this->token)) != ',') 内容来自论文无忧网 www.paper51.com return-CNSE_PROT; paper51.com
if((ret = AtLex_do(this->rspBuf, this->token)) != AT_NUM) paper51.com
return-CNSE_PROT; 内容来自www.paper51.com memset(&cnsMargin,0x00, sizeof(cnsMargin)); paper51.com
memset(&cnsDst,0x00, sizeof(cnsDst)); 内容来自www.paper51.com cnsMargin.minute= -(atoi(StrBuf_buf(this->token))); copyright paper51.com if((ret = DateMargin2CnsTime(&cnsDate, cnsMargin, &cnsDst)) < 0) paper51.com return-CNSE_PROT; http://www.paper51.com StrUtil_strxfrm(vCalFields[i].type,"DE", sizeof("DE")); 内容来自www.paper51.com Iso8601Date_enc(&cnsDst,vCalFields[i].value, http://www.paper51.com sizeof(vCalFields[i].value),CNS_TRUE); http://www.paper51.com i++; 内容来自论文无忧网 www.paper51.com // 提醒时间 内容来自www.paper51.com if((ret = AtLex_do(this->rspBuf, this->token)) != ',') copyright paper51.com return-CNSE_PROT; 内容来自www.paper51.com
if((ret = AtLex_do(this->rspBuf, this->token)) != AT_STRING) http://www.paper51.com return-CNSE_PROT; paper51.com memset(&cnsDate,0x00, sizeof(cnsDate)); 内容来自论文无忧网 www.paper51.com sscanf(StrBuf_buf(this->token),"%d:%d",&cnsDate.hour,&cnsDate.minute); 内容来自论文无忧网 www.paper51.com
// 提醒日期 内容来自论文无忧网 www.paper51.com if((ret = AtLex_do(this->rspBuf, this->token)) != ',') 内容来自www.paper51.com return-CNSE_PROT; http://www.paper51.com if((ret = AtLex_do(this->rspBuf, this->token)) != AT_STRING) http://www.paper51.com return-CNSE_PROT; http://www.paper51.com sscanf(StrBuf_buf(this->token),"%d-%d-%d", paper51.com &cnsDate.month,&cnsDate.day, &cnsDate.year); 内容来自论文无忧网 www.paper51.com StrUtil_strxfrm(vCalFields[i].type,"DA", sizeof("DA")); http://www.paper51.com
Iso8601Date_enc(&cnsDate,vCalFields[i].value, 内容来自论文无忧网 www.paper51.com sizeof(vCalFields[i].value),CNS_TRUE); paper51.com i++; 内容来自论文无忧网 www.paper51.com
// 得到重复类型,系统默认为 0 内容来自www.paper51.com if((ret = AtLex_do(this->rspBuf, this->token)) != ',') 内容来自论文无忧网 www.paper51.com
return-CNSE_PROT; http://www.paper51.com if((ret = AtLex_do(this->rspBuf, this->token)) != AT_NUM) http://www.paper51.com return-CNSE_PROT; 内容来自论文无忧网 www.paper51.com ruleType= atoi(StrBuf_buf(this->token)); 内容来自www.paper51.com memset(&vpiRule,0x00, sizeof(vpiRule)); http://www.paper51.com switch(ruleType) { paper51.com case 1: //每天重复发生 paper51.com sprintf(rule,"%d,1,0", RULE_TYPE_DAILY); copyright paper51.com StrUtil_strxfrm(vCalFields[i].type,"R", sizeof("R")); paper51.com StrUtil_strxfrm(vCalFields[i].value,rule, strlen(rule) + 1); paper51.com break; paper51.com case 2: //每周 paper51.com
sprintf(rule,"%d,1,0", RULE_TYPE_WEEKLY); paper51.com StrUtil_strxfrm(vCalFields[i].type,"R", sizeof("R")); 内容来自www.paper51.com
StrUtil_strxfrm(vCalFields[i].value,rule, strlen(rule) + 1); 内容来自论文无忧网 www.paper51.com break; copyright paper51.com case 3: //每月的该日重复发生 http://www.paper51.com sprintf(rule,"%d,1,0", RULE_TYPE_MONTHLY_POS); 内容来自www.paper51.com StrUtil_strxfrm(vCalFields[i].type,"R", sizeof("R")); copyright paper51.com StrUtil_strxfrm(vCalFields[i].value,rule, strlen(rule) + 1); paper51.com break; paper51.com case 4: //每月的该天重复发生 paper51.com sprintf(rule,"%d,1,0", RULE_TYPE_MONTHLY_DAY); 内容来自www.paper51.com StrUtil_strxfrm(vCalFields[i].type,"R", sizeof("R")); 内容来自论文无忧网 www.paper51.com StrUtil_strxfrm(vCalFields[i].value,rule, strlen(rule) + 1); 内容来自www.paper51.com
break; http://www.paper51.com case 5: //每年重复发生 内容来自论文无忧网 www.paper51.com sprintf(rule,"%d,1,0", RULE_TYPE_YEARLY_DAY); paper51.com StrUtil_strxfrm(vCalFields[i].type,"R", sizeof("R")); 内容来自www.paper51.com StrUtil_strxfrm(vCalFields[i].value,rule, strlen(rule) + 1); http://www.paper51.com break; 内容来自www.paper51.com default: 内容来自论文无忧网 www.paper51.com
sprintf(rule,"%d,1,0", RULE_TYPE_UNKNOW); paper51.com
StrUtil_strxfrm(vCalFields[i].type,"R", sizeof("R")); paper51.com StrUtil_strxfrm(vCalFields[i].value,rule, strlen(rule) + 1); copyright paper51.com break; copyright paper51.com } copyright paper51.com if((ret = Vcal_enc(item, VPICAL_TYPE_VEVENT, paper51.com
vCalFields,sizeof(vCalFields) / sizeof(vCalFields[0]))) < 0) 内容来自www.paper51.com returnret; 内容来自论文无忧网 www.paper51.com return1; http://www.paper51.com
} http://www.paper51.com //由于标题采用UCS2编码,需要转换成UTF-8编码方式 内容来自www.paper51.com voidMotoVcs::strPhoneToStd(char *src, char *dst, int dstLen) paper51.com { copyright paper51.com int len, tmpLen; paper51.com
unsigned char *tmpBuf = NULL; 内容来自论文无忧网 www.paper51.com if (this->charset == CS_UCS2) { http://www.paper51.com tmpLen =strlen(src); paper51.com
tmpBuf =(unsigned char*)malloc(tmpLen); paper51.com memset(tmpBuf,0x00, tmpLen); copyright paper51.com len =IraUtil_iraToBuf((unsigned char*)src, tmpBuf, tmpLen); copyright paper51.com // len:转换后的字节数 http://www.paper51.com len =CsUtil_ucs2ToUtf8((unsigned short*)tmpBuf, len, dst, dstLen); 内容来自论文无忧网 www.paper51.com } paper51.com else if (this->charset ==CS_GSM) { copyright paper51.com len =StrUtil_strxfrm(dst, src, dstLen); 内容来自www.paper51.com } 内容来自论文无忧网 www.paper51.com else if (this->charset ==CS_UTF8) { copyright paper51.com if(!this->utf8Ira) 内容来自论文无忧网 www.paper51.com
len= StrUtil_strxfrm(dst, src, dstLen); paper51.com else { 内容来自www.paper51.com len= IraUtil_iraToBuf((unsigned char*)src, (unsigned char*)dst, dstLen); 内容来自论文无忧网 www.paper51.com } paper51.com } 内容来自论文无忧网 www.paper51.com if (tmpBuf) { 内容来自www.paper51.com free(tmpBuf); paper51.com tmpBuf =NULL; 内容来自论文无忧网 www.paper51.com
} http://www.paper51.com } 内容来自论文无忧网 www.paper51.com |