|
@@ -6,6 +6,8 @@
|
|
|
#define LEARN_LIST "learnLists" //任务简表总表
|
|
|
#define LEARN_LIST_TMP "learnListsTmp" //临时任务简表总表
|
|
|
#define LEARN_RANK "learnRank" //排名临时表,不需要删除
|
|
|
+#define LEARN_CLASS "learnClass"
|
|
|
+#define LEARN_NOTICE "learnNotice"
|
|
|
#define LEARN_UPDATE_MAX 10 //一次性最多拉取任务个数
|
|
|
#define SHOW_TABLE_MAX_BYTES 40
|
|
|
|
|
@@ -22,6 +24,9 @@
|
|
|
#define OBJECT_NNAME "nickname"
|
|
|
#define OBJECT_TYPE "type"
|
|
|
#define OBJECT_TOKEN "token"
|
|
|
+#define OBJECT_CONTENT_DETAIL "content"
|
|
|
+#define OBJECT_SPEED_PARAM "scoreSpeedParam"
|
|
|
+#define OBJECT_VOLUME_PARAM "scoreVolumeParam"
|
|
|
|
|
|
static void httpCallBack(char *msg, int len);
|
|
|
typedef enum{
|
|
@@ -45,7 +50,11 @@ typedef enum{
|
|
|
LEARN_END,
|
|
|
|
|
|
|
|
|
- LEARN_RANK_GET_DETAIL
|
|
|
+ LEARN_RANK_GET_DETAIL,
|
|
|
+ LEARN_CLASS_GET_DETAIL,
|
|
|
+ LEARN_NOTICE_GET_DETAIL,
|
|
|
+ LEARN_NOTICE_GET_DETAIL_SHOW,
|
|
|
+ LEARN_GET_PARAM,
|
|
|
}LEARN_STATUS;
|
|
|
static unsigned char charaNum;//单词个数
|
|
|
static unsigned int taskID[LEARN_UPDATE_MAX];
|
|
@@ -99,6 +108,7 @@ void sdCardCtl(bool status){
|
|
|
}else{
|
|
|
nwy_sdk_sdcard_unmount();
|
|
|
CTL_SD_PWR(0);
|
|
|
+ MSG_INFO(1, "SD card unmount");
|
|
|
}
|
|
|
}
|
|
|
static void learnUpdateStatus(LEARN_STATUS newStatus){
|
|
@@ -168,6 +178,9 @@ void learnGetNextPage(short direction){
|
|
|
}
|
|
|
/*********************从文件中获取用户信息******************************/
|
|
|
typedef struct{
|
|
|
+ bool paramReady;
|
|
|
+ double scoreSpeedParam;
|
|
|
+ double scoreVolumeParam;
|
|
|
bool ready;
|
|
|
unsigned char type;
|
|
|
unsigned int uid;
|
|
@@ -176,9 +189,10 @@ typedef struct{
|
|
|
char nname[30];
|
|
|
char token[20];
|
|
|
}USER_INFO;
|
|
|
-USER_INFO usr={false,0xff};
|
|
|
-unsigned long getLearnUid(void){return usr.uid;}
|
|
|
-unsigned long getLearnGid(void){return usr.gid;}
|
|
|
+USER_INFO usr={false,1,1,false,0xff};
|
|
|
+unsigned int getLearnUid(void){return usr.uid;}
|
|
|
+unsigned int getLearnGid(void){return usr.gid;}
|
|
|
+char *getLearnGName(void){return usr.gname;}
|
|
|
char *getLearnToken(void){return usr.token;}
|
|
|
bool isUserInfoReady(void){return usr.ready;}
|
|
|
void learnUserInfoClear(void){usr.ready=false;}
|
|
@@ -218,35 +232,35 @@ bool cJSONProcessUinfo(char *msg){
|
|
|
return true;
|
|
|
}
|
|
|
/*************************从文件中获取用户信息******************************/
|
|
|
-bool learnTaskUpdate(LEARN_STATUS type, void *para1, void *para2){
|
|
|
+bool learnTaskUpdate(LEARN_STATUS type, void *para1, void *para2, bool needShow){
|
|
|
char url[200],tmp[10];
|
|
|
unsigned char *msg=NULL;
|
|
|
unsigned int len=0,i;
|
|
|
UHTTP_ENUM httpType;
|
|
|
//触发获取任务列表操作
|
|
|
if(sutApp.pocPpp==0 || sutPocStatus.logined==0){
|
|
|
- showInfoBox("无网络/未登录",2000);
|
|
|
+ if(true==needShow) showInfoBox("无网络/未登录",2000);
|
|
|
learnUpdateStatus(LEARN_END);
|
|
|
return false;
|
|
|
}
|
|
|
if(type==LEARN_DB_GET_INFO){//获取用户信息
|
|
|
- httpType=UHTTP_TASK_GET;
|
|
|
+ httpType=UHTTP_FILE_GET;
|
|
|
snprintf(url, sizeof(url), "%s/api/cai/UserInfo?account=%d&password=%s", LEARN_HTTP_URL, sutApp.account.psn, sutApp.account.password);
|
|
|
MSG_INFO(1, "Learn get user info");
|
|
|
}else if(type==LEARN_GET_LIST){//获取任务列表
|
|
|
- httpType=UHTTP_TASK_GET;
|
|
|
+ httpType=UHTTP_FILE_GET;
|
|
|
snprintf(url, sizeof(url), "%s/api/cai/BriefTask?gid=%d&uid=%d&token=%s", LEARN_HTTP_URL, getLearnGid(),getLearnUid(),getLearnToken());
|
|
|
MSG_INFO(1, "Learn get total list");
|
|
|
}else if(type==LEARN_DB_SYNC_ADD_PAGE_WAIT){//根据页获取详细表
|
|
|
int *page=(int *)para1;
|
|
|
int *size=(int *)para2;
|
|
|
- httpType=UHTTP_TASK_GET;
|
|
|
+ httpType=UHTTP_FILE_GET;
|
|
|
snprintf(url, sizeof(url), "%s/api/cai/DetailedTask?gid=%d&uid=%d&page=%d&size=%d&token=%s", LEARN_HTTP_URL, getLearnGid(),getLearnUid(),*page,*size,getLearnToken());
|
|
|
MSG_INFO(1, "Learn get detail,page:%d,size:%d", *page,*size);
|
|
|
}else if(type==LEARN_DB_SYNC_ADD_SOME_WAIT){//根据tid获取详细表
|
|
|
unsigned int *tids=(unsigned int *)para1;
|
|
|
unsigned char *num=(unsigned char *)para2;
|
|
|
- httpType=UHTTP_TASK_GET;
|
|
|
+ httpType=UHTTP_FILE_GET;
|
|
|
snprintf(url, sizeof(url), "%s/api/cai/DetailedTask?gid=%d&uid=%d&token=%s&tids=[%d", LEARN_HTTP_URL,getLearnGid(),getLearnUid(),getLearnToken(),tids[0]);
|
|
|
for(i=1;i<*num;i++){
|
|
|
snprintf(tmp, sizeof(tmp),",%d", tids[i]);
|
|
@@ -261,12 +275,29 @@ bool learnTaskUpdate(LEARN_STATUS type, void *para1, void *para2){
|
|
|
snprintf(url, sizeof(url), "%s/api/cai/HandIn",LEARN_HTTP_URL);
|
|
|
MSG_INFO(1, "Learn upload audio:%d bytes", len);
|
|
|
}else if(type==LEARN_RANK_GET_DETAIL){
|
|
|
- httpType=UHTTP_RANK_GET;
|
|
|
+ httpType=UHTTP_FILE_GET;
|
|
|
unsigned char *rankType=(unsigned char *)para1;
|
|
|
snprintf(url, sizeof(url), "%s/api/cai/%slyRanking?uid=%d&gid=%d&token=%s", LEARN_HTTP_URL,(*rankType==0)?"Month":"Week" ,getLearnUid(),getLearnGid(),getLearnToken());
|
|
|
MSG_INFO(1, "Learn get %s rank", (*rankType==0)?"month":"week");
|
|
|
+ }else if(type==LEARN_CLASS_GET_DETAIL){
|
|
|
+ httpType=UHTTP_FILE_GET;
|
|
|
+ snprintf(url, sizeof(url), "%s/api/cai/Timetable?uid=%d&gid=%d&token=%s", LEARN_HTTP_URL, getLearnUid(), getLearnGid(), getLearnToken());
|
|
|
+ MSG_INFO(1, "Learn get class detail");
|
|
|
+ }else if(type==LEARN_NOTICE_GET_DETAIL){
|
|
|
+ httpType=UHTTP_FILE_GET;
|
|
|
+ snprintf(url, sizeof(url), "%s/api/cai/NotificationBrief?uid=%d&gid=%d&token=%s", LEARN_HTTP_URL, getLearnUid(), getLearnGid(), getLearnToken());
|
|
|
+ MSG_INFO(1, "Learn get notice detail");
|
|
|
+ }else if(type==LEARN_NOTICE_GET_DETAIL_SHOW){
|
|
|
+ int *id=(int *)para1;
|
|
|
+ httpType=UHTTP_FILE_GET;
|
|
|
+ snprintf(url, sizeof(url), "%s/api/cai/NotificationContent?uid=%d&id=%d&token=%s", LEARN_HTTP_URL, getLearnUid(), *id, getLearnToken());
|
|
|
+ MSG_INFO(1, "Learn get notice detail show");
|
|
|
+ }else if(type==LEARN_GET_PARAM){
|
|
|
+ httpType=UHTTP_FILE_GET;
|
|
|
+ snprintf(url, sizeof(url), "%s/api/cai/Config?uid=%d&token=%s", LEARN_HTTP_URL, getLearnUid(), getLearnToken());
|
|
|
+ MSG_INFO(1, "Learn get param");
|
|
|
}
|
|
|
- showInfoBox("请稍候",5000);
|
|
|
+ if(true==needShow) showInfoBox("请稍候",5000);
|
|
|
learnHttpStart(httpType,url, LEARN_PORT, httpCallBack,msg, len);
|
|
|
return true;
|
|
|
}
|
|
@@ -282,23 +313,22 @@ void uiShowLearnTask(char update){
|
|
|
uiMenuShowBottomLine();
|
|
|
guiShowMessageBox("请稍候");
|
|
|
uiMenuShowBottomIndacitor("查看", "返回");
|
|
|
- if(needUpdate) sdCardCtl(true);
|
|
|
+ sdMount();
|
|
|
#if 1
|
|
|
if(isUserInfoReady()==false){
|
|
|
- if(true==learnTaskUpdate(LEARN_DB_GET_INFO,NULL, NULL)) learnUpdateStatus(LEARN_DB_WAIT_INFO);
|
|
|
+ if(true==learnTaskUpdate(LEARN_DB_GET_INFO,NULL, NULL,true)) learnUpdateStatus(LEARN_DB_WAIT_INFO);
|
|
|
}else{
|
|
|
if(needUpdate!=0){
|
|
|
MSG_INFO(1, "learn task need sync");
|
|
|
- if(true==learnTaskUpdate(LEARN_GET_LIST,NULL, NULL)) learnUpdateStatus(LEARN_WAIT_LIST);
|
|
|
+ if(true==learnTaskUpdate(LEARN_GET_LIST,NULL, NULL,true)) learnUpdateStatus(LEARN_WAIT_LIST);
|
|
|
}else learnUpdateStatus(LEARN_DB_SYNC_DONE);//子菜单返回时,直接读取显示,不去同步
|
|
|
}
|
|
|
needUpdate=0;
|
|
|
#else
|
|
|
if(needUpdate!=0){
|
|
|
MSG_INFO(1, "learn task need sync");
|
|
|
- if(true==learnTaskUpdate(LEARN_GET_LIST,NULL, NULL)) learnUpdateStatus(LEARN_WAIT_LIST);
|
|
|
+ if(true==learnTaskUpdate(LEARN_GET_LIST,NULL, NULL,true)) learnUpdateStatus(LEARN_WAIT_LIST);
|
|
|
}else learnUpdateStatus(LEARN_DB_SYNC_DONE);//子菜单返回时,直接读取显示,不去同步
|
|
|
- needUpdate=0;
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -484,7 +514,7 @@ static void LearnTaskProcess(void){
|
|
|
MSG_INFO(1, "LEARN_DB_WAIT_INFO:%d",ret);
|
|
|
switch(ret){
|
|
|
case 0://获取用户信息成功,获取简表信息
|
|
|
- if(true==learnTaskUpdate(LEARN_GET_LIST,NULL, NULL)) learnUpdateStatus(LEARN_WAIT_LIST);
|
|
|
+ if(true==learnTaskUpdate(LEARN_GET_LIST,NULL, NULL,true)) learnUpdateStatus(LEARN_WAIT_LIST);
|
|
|
else{
|
|
|
showInfoBox("更新失败",2000);
|
|
|
learnUpdateStatus(LEARN_END);
|
|
@@ -611,7 +641,7 @@ static void LearnTaskProcess(void){
|
|
|
learnAddNum=0;
|
|
|
learnUpdateStatus(LEARN_DB_SYNC_ADD_PAGE_WAIT);
|
|
|
learnDetailEnd=false;//检测是否下载完毕使用
|
|
|
- learnTaskUpdate(LEARN_DB_SYNC_ADD_PAGE_WAIT,(void *)&page, (void *)&size);
|
|
|
+ learnTaskUpdate(LEARN_DB_SYNC_ADD_PAGE_WAIT,(void *)&page, (void *)&size,true);
|
|
|
uTimerStart(&learnTick, 2000);
|
|
|
}else{//根据两个简表,添加回LEARN_LIST中没有,但LEARN_LIST_TMP中有的任务
|
|
|
for(i=0;i<LEARN_UPDATE_MAX;i++) tidTable[i]=0;
|
|
@@ -664,7 +694,7 @@ static void LearnTaskProcess(void){
|
|
|
//发起新的文件获取(根据任务ID获取)
|
|
|
//文件ID表在tidTable中,个数为learnAddNum个
|
|
|
learnUpdateStatus(LEARN_DB_SYNC_ADD_SOME_WAIT);
|
|
|
- learnTaskUpdate(LEARN_DB_SYNC_ADD_SOME_WAIT,(void *)tidTable, (void *)&learnAddNum);
|
|
|
+ learnTaskUpdate(LEARN_DB_SYNC_ADD_SOME_WAIT,(void *)tidTable, (void *)&learnAddNum,true);
|
|
|
MSG_ERR(1, "update tids:%d", learnAddNum);
|
|
|
}
|
|
|
break;
|
|
@@ -777,13 +807,13 @@ static void LearnTaskProcess(void){
|
|
|
releaseBuf(&sutJson.bufTask[i]);
|
|
|
releaseJson(&sutJson.jsonTask[i]);
|
|
|
}
|
|
|
- sdCardCtl(false);
|
|
|
+ sdUnmount();
|
|
|
uISetNextStatus(UIS_MENU_MAIN);
|
|
|
needUpdate=1;
|
|
|
break;
|
|
|
case LEARN_END:
|
|
|
if(uTimerExpired(&learnTick)){
|
|
|
- sdCardCtl(false);
|
|
|
+ sdUnmount();
|
|
|
uISetNextStatus(UIS_MENU_MAIN);
|
|
|
needUpdate=1;
|
|
|
}
|
|
@@ -839,6 +869,14 @@ static void httpCallBack(char *msg, int len){
|
|
|
cJSONSaveTaskFile(msg);
|
|
|
}else if(ret==LEARN_RANK_GET_DETAIL){
|
|
|
cJSONSaveFile(LEARN_RANK, msg,outLen);
|
|
|
+ }else if(ret==LEARN_CLASS_GET_DETAIL){
|
|
|
+ cJSONSaveFile(LEARN_CLASS, msg, outLen);
|
|
|
+ }else if(ret==LEARN_NOTICE_GET_DETAIL){
|
|
|
+ cJSONSaveFile(LEARN_NOTICE, msg, outLen);
|
|
|
+ }else if(ret==LEARN_NOTICE_GET_DETAIL_SHOW){
|
|
|
+ cJSONTakeContent(msg, outLen);
|
|
|
+ }else if(ret==LEARN_GET_PARAM){
|
|
|
+ cJSONTakeParam(msg, outLen);
|
|
|
}
|
|
|
MSG_INFO(1, "httpCallBack end");
|
|
|
}
|
|
@@ -1230,7 +1268,7 @@ void uiShowLearnTaskDetailResponse(void){
|
|
|
pcm=learnGetTmpAudioBuf();
|
|
|
plen=learnGetTmpAudioLength();
|
|
|
learnRecSetStatus(LEARN_RECORD_UPLOAD);
|
|
|
- learnTaskUpdate(LEARN_RECORD_UPLOAD,(void *)pcm, (void *)&plen);
|
|
|
+ learnTaskUpdate(LEARN_RECORD_UPLOAD,(void *)pcm, (void *)&plen,true);
|
|
|
break;
|
|
|
}
|
|
|
}else if(MKEY_VALUE_DOWN==key){
|
|
@@ -1255,11 +1293,16 @@ void uiShowLearnTaskDetailResponse(void){
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-static void learnShowResult(void){
|
|
|
- char info1[30],info2[30];
|
|
|
- snprintf(info1, sizeof(info1), "Volume:%d", learnGetRecordMaxVolume());
|
|
|
- snprintf(info2, sizeof(info2), "Speed:%d", learnGetRecordRecSpeed());
|
|
|
- guiShowTwoMessage(info1, info2);
|
|
|
+static void learnShowResult(void){
|
|
|
+ double score;
|
|
|
+ char info[30];
|
|
|
+ unsigned char speed=learnGetRecordRecSpeed();
|
|
|
+ if(speed<=0) speed=1;
|
|
|
+ score=usr.scoreSpeedParam*speed+usr.scoreVolumeParam*learnGetRecordMaxVolume();
|
|
|
+ snprintf(info, sizeof(info), "Score:%f", score);
|
|
|
+ MSG_INFO(1, "sparam:%f,speed:%d,vparam:%f,volume:%d,scroe:%f",usr.scoreSpeedParam,speed,usr.scoreVolumeParam,learnGetRecordMaxVolume(),score);
|
|
|
+ guiShowMessageBox(info);
|
|
|
+ //guiShowTwoMessage(info1, info2);
|
|
|
}
|
|
|
static void learnRecordDoneProcess(void){
|
|
|
|
|
@@ -1285,20 +1328,18 @@ void uiShowLearnRank(char update){
|
|
|
};
|
|
|
char Freatrue[2]={0,1};
|
|
|
if(update){
|
|
|
- if(needUpdate) sdCardCtl(true);
|
|
|
+ sdMount();
|
|
|
guiClearAll(guiGetBackColor());
|
|
|
guiShowCaption(0,"学习排名",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
|
|
|
uiMenuShowBottomLine();
|
|
|
ListBoxInit(&sutListBox, rankMode, 0, learnIcon, Freatrue);
|
|
|
uiMenuShowBottomIndacitor("查看", "返回");
|
|
|
- needUpdate=0;
|
|
|
}
|
|
|
}
|
|
|
void LearnRankSelResponse(void){
|
|
|
unsigned short key=ListBoxResponse(&sutListBox);
|
|
|
if(MKEY_VALUE_ESC==key){
|
|
|
- needUpdate=1;
|
|
|
- sdCardCtl(false);
|
|
|
+ sdUnmount();
|
|
|
uISetNextStatus(UIS_MENU_MAIN);
|
|
|
}else if(MKEY_VALUE_MENU==key){
|
|
|
if(sutListBox.handle==0){
|
|
@@ -1395,11 +1436,11 @@ void uiShowLearnRankDetail(char update){
|
|
|
if(isUserInfoReady()==false){//如果未获取用户信息,先获取用户信息
|
|
|
needGetUinfo=true;
|
|
|
learnUpdateStatus(LEARN_DB_WAIT_INFO);
|
|
|
- learnTaskUpdate(LEARN_DB_GET_INFO,NULL, NULL);
|
|
|
+ learnTaskUpdate(LEARN_DB_GET_INFO,NULL, NULL,true);
|
|
|
}else{//否则可以直接获取排名
|
|
|
needGetUinfo=false;
|
|
|
learnUpdateStatus(LEARN_RANK_GET_DETAIL);
|
|
|
- learnTaskUpdate(LEARN_RANK_GET_DETAIL,(void*)&rankType, NULL);
|
|
|
+ learnTaskUpdate(LEARN_RANK_GET_DETAIL,(void*)&rankType, NULL,true);
|
|
|
MSG_ERR(1, "update rank detail %s", (rankType==0)?"month":"week");
|
|
|
}
|
|
|
}
|
|
@@ -1412,7 +1453,7 @@ void uiShowLearnRankDetail(char update){
|
|
|
if(needGetUinfo==true){
|
|
|
needGetUinfo=false;
|
|
|
learnUpdateStatus(LEARN_RANK_GET_DETAIL);
|
|
|
- learnTaskUpdate(LEARN_RANK_GET_DETAIL,(void*)&rankType, NULL);
|
|
|
+ learnTaskUpdate(LEARN_RANK_GET_DETAIL,(void*)&rankType, NULL,true);
|
|
|
MSG_ERR(1, "update rank detail %s", (rankType==0)?"month":"week");
|
|
|
}else{
|
|
|
rankShowReady=true;
|
|
@@ -1429,6 +1470,7 @@ void uiShowLearnRankDetail(char update){
|
|
|
break;
|
|
|
}
|
|
|
nwy_sleep(1500);
|
|
|
+ getStackStruct()->ok_back=1;
|
|
|
uISetNextStatus(UIS_MENU_RANK_SEL);
|
|
|
}
|
|
|
}
|
|
@@ -1447,6 +1489,316 @@ void LearnRankDetailSelResponse(void){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+typedef struct{
|
|
|
+ int week;
|
|
|
+ char time[15];
|
|
|
+ char subject[30*2];
|
|
|
+}CLASS_DEF;
|
|
|
+typedef struct{
|
|
|
+ unsigned int item;//rankResult实际使用的个数
|
|
|
+ unsigned int num;//rankResult分配的个数(释放时使用)
|
|
|
+ CLASS_DEF **classResult;
|
|
|
+}CLASS_RESULT_DEF;
|
|
|
+CLASS_RESULT_DEF classes={0,0,0,NULL};
|
|
|
+bool classShowReady;
|
|
|
+static void classInfoDetailShow(unsigned char direction){
|
|
|
+ static int tIndex=0;
|
|
|
+
|
|
|
+ if(classes.item==0){
|
|
|
+ guiShowMessageBox("无数据");
|
|
|
+ return;
|
|
|
+ }else if(classes.item==1) tIndex=0;
|
|
|
+ else{
|
|
|
+ if(direction==0) tIndex=0;
|
|
|
+ else if(direction==1){
|
|
|
+ if(++tIndex>=classes.item) tIndex=0;
|
|
|
+ }else if(direction==2){
|
|
|
+ if(tIndex==0) tIndex=classes.item-1;
|
|
|
+ else tIndex--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ guiClearRect(0,UI_CONTENT_SHOW_Y,GLCD_WIDTH-1,UI_BOTTOM_SHOW_Y-2,guiGetBackColor());
|
|
|
+ //显示
|
|
|
+ if(classes.classResult==NULL){
|
|
|
+ MSG_WARN(1, "class no data");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ char info[50];
|
|
|
+ int x=1,y=UI_CONTENT_SHOW_Y;
|
|
|
+ //显示week
|
|
|
+ snprintf(info, sizeof(info), "week:%d", classes.classResult[tIndex]->week);
|
|
|
+ guiShowStr(x, y, info, FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
|
|
|
+ y+=17;
|
|
|
+ //显示time
|
|
|
+ snprintf(info, sizeof(info), "time:%s", classes.classResult[tIndex]->time);
|
|
|
+ guiShowStr(x, y, info, FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
|
|
|
+ y+=17;
|
|
|
+ //显示subject
|
|
|
+ snprintf(info, sizeof(info), "subject:%s", classes.classResult[tIndex]->subject);
|
|
|
+ guiShowStr(x, y, info, FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
|
|
|
+}
|
|
|
+static void getClassShowMessage(void);
|
|
|
+/*课程表*/
|
|
|
+void uiShowLearnClassDetail(char update){
|
|
|
+ int ret;
|
|
|
+ static bool needGetUinfo=false;
|
|
|
+ if(update){
|
|
|
+ guiClearAll(guiGetBackColor());
|
|
|
+ guiShowCaption(0,"课程表",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
|
|
|
+ uiMenuShowBottomLine();
|
|
|
+ uiMenuShowBottomIndacitor(NULL, "返回");
|
|
|
+ if(sutApp.pocPpp==0){
|
|
|
+ guiShowMessageBox("无网络");
|
|
|
+ nwy_sleep(1500);
|
|
|
+ uISetNextStatus(UIS_MENU_LOCATION_SEL);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ classShowReady=false;
|
|
|
+ showInfoBox("请稍候",3000);
|
|
|
+ sdMount();
|
|
|
+ if(isUserInfoReady()==false){//如果未获取用户信息,先获取用户信息
|
|
|
+ needGetUinfo=true;
|
|
|
+ learnUpdateStatus(LEARN_DB_WAIT_INFO);
|
|
|
+ learnTaskUpdate(LEARN_DB_GET_INFO,NULL, NULL,true);
|
|
|
+ }else{//否则可以直接获取课程表
|
|
|
+ needGetUinfo=false;
|
|
|
+ learnUpdateStatus(LEARN_CLASS_GET_DETAIL);
|
|
|
+ learnTaskUpdate(LEARN_CLASS_GET_DETAIL,NULL, NULL,true);
|
|
|
+ MSG_ERR(1, "update class detail");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(false==classShowReady){
|
|
|
+ ret=getHttpLearnStatus();
|
|
|
+ if(uTimerExpired(&learnTick) || ret!=1){
|
|
|
+ MSG_INFO(1, "WAIT CLASS:%d",ret);
|
|
|
+ switch(ret){
|
|
|
+ case 0://功获取到了信息
|
|
|
+ if(needGetUinfo==true){
|
|
|
+ needGetUinfo=false;
|
|
|
+ learnUpdateStatus(LEARN_CLASS_GET_DETAIL);
|
|
|
+ learnTaskUpdate(LEARN_CLASS_GET_DETAIL,NULL, NULL,true);
|
|
|
+ MSG_ERR(1, "update class detail");
|
|
|
+ }else{//处理
|
|
|
+ MSG_INFO(1, "class info get ok");
|
|
|
+ classShowReady=true;
|
|
|
+ getClassShowMessage();
|
|
|
+ classInfoDetailShow(0);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ case 2://获取失败
|
|
|
+ guiShowMessageBox("获取失败");
|
|
|
+ break;
|
|
|
+ default://获取超时
|
|
|
+ hearnHttpOverTime();
|
|
|
+ guiShowMessageBox("获取超时");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ nwy_sleep(1500);
|
|
|
+ getStackStruct()->ok_back=1;
|
|
|
+ uISetNextStatus(UIS_MENU_LOCATION_SEL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+static void learnClassReleaseDB(void);
|
|
|
+void LearnClassDetailResponse(void){
|
|
|
+ if(classShowReady==true){
|
|
|
+ switch(getKeyValue()){
|
|
|
+ case MKEY_VALUE_ESC:
|
|
|
+ learnClassReleaseDB();
|
|
|
+ uISetNextStatus(UIS_MENU_LOCATION_SEL);
|
|
|
+ break;
|
|
|
+ case MKEY_VALUE_DOWN:classInfoDetailShow(1);break;
|
|
|
+ case MKEY_VALUE_UP:classInfoDetailShow(2);break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+typedef struct{
|
|
|
+ int id;
|
|
|
+ char time[15];
|
|
|
+ char title[30];
|
|
|
+}NOTICE_DEF;
|
|
|
+typedef struct{
|
|
|
+ unsigned int item;//rankResult实际使用的个数
|
|
|
+ unsigned int num;//rankResult分配的个数(释放时使用)
|
|
|
+ NOTICE_DEF **noticeResult;
|
|
|
+}NOTICE_RESULT_DEF;
|
|
|
+NOTICE_RESULT_DEF notices={0,0,0,NULL};
|
|
|
+bool noticeShowReady;
|
|
|
+static int noticetIndex=0;
|
|
|
+static void noticeInfoDetailShow(unsigned char direction){
|
|
|
+ if(notices.item==0){
|
|
|
+ guiShowMessageBox("无数据");
|
|
|
+ return;
|
|
|
+ }else if(notices.item==1) noticetIndex=0;
|
|
|
+ else{
|
|
|
+ if(direction==0) noticetIndex=0;
|
|
|
+ else if(direction==1){
|
|
|
+ if(++noticetIndex>=notices.item) noticetIndex=0;
|
|
|
+ }else if(direction==2){
|
|
|
+ if(noticetIndex==0) noticetIndex=notices.item-1;
|
|
|
+ else noticetIndex--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ guiClearRect(0,UI_CONTENT_SHOW_Y,GLCD_WIDTH-1,UI_BOTTOM_SHOW_Y-2,guiGetBackColor());
|
|
|
+ //显示
|
|
|
+ if(notices.noticeResult==NULL){
|
|
|
+ MSG_WARN(1, "notice no data");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ char info[50];
|
|
|
+ int x=1,y=UI_CONTENT_SHOW_Y;
|
|
|
+ //显示title
|
|
|
+ snprintf(info, sizeof(info), "title:%s", notices.noticeResult[noticetIndex]->title);
|
|
|
+ guiShowStr(x, y, info, FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
|
|
|
+ y+=17;
|
|
|
+ //显示time
|
|
|
+ snprintf(info, sizeof(info), "time:%s", notices.noticeResult[noticetIndex]->time);
|
|
|
+ guiShowStr(x, y, info, FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
|
|
|
+}
|
|
|
+static void getNoticeShowMessage(void);
|
|
|
+/*消息通知*/
|
|
|
+void uiShowLearnNoticeDetail(char update){
|
|
|
+ int ret;
|
|
|
+ static bool needGetUinfo=false;
|
|
|
+ if(update){
|
|
|
+ guiClearAll(guiGetBackColor());
|
|
|
+ guiShowCaption(0,"消息通知",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
|
|
|
+ uiMenuShowBottomLine();
|
|
|
+ uiMenuShowBottomIndacitor("阅读", "返回");
|
|
|
+ if(sutApp.pocPpp==0){
|
|
|
+ guiShowMessageBox("无网络");
|
|
|
+ nwy_sleep(1500);
|
|
|
+ uISetNextStatus(UIS_MENU_LOCATION_SEL);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(noticeShowReady==false){
|
|
|
+ showInfoBox("请稍候",3000);
|
|
|
+ sdMount();
|
|
|
+ if(isUserInfoReady()==false){//如果未获取用户信息,先获取用户信息
|
|
|
+ needGetUinfo=true;
|
|
|
+ learnUpdateStatus(LEARN_DB_WAIT_INFO);
|
|
|
+ learnTaskUpdate(LEARN_DB_GET_INFO,NULL, NULL,true);
|
|
|
+ }else{//否则可以直接获取课程表
|
|
|
+ needGetUinfo=false;
|
|
|
+ learnUpdateStatus(LEARN_NOTICE_GET_DETAIL);
|
|
|
+ learnTaskUpdate(LEARN_NOTICE_GET_DETAIL,NULL, NULL,true);
|
|
|
+ MSG_ERR(1, "update notice detail");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(false==noticeShowReady){
|
|
|
+ ret=getHttpLearnStatus();
|
|
|
+ if(uTimerExpired(&learnTick) || ret!=1){
|
|
|
+ MSG_INFO(1, "WAIT NOTICE:%d",ret);
|
|
|
+ switch(ret){
|
|
|
+ case 0://功获取到了信息
|
|
|
+ if(needGetUinfo==true){
|
|
|
+ needGetUinfo=false;
|
|
|
+ learnUpdateStatus(LEARN_NOTICE_GET_DETAIL);
|
|
|
+ learnTaskUpdate(LEARN_NOTICE_GET_DETAIL,NULL, NULL,true);
|
|
|
+ MSG_ERR(1, "update notice detail");
|
|
|
+ }else{//处理
|
|
|
+ MSG_INFO(1, "notice info get ok");
|
|
|
+ noticeShowReady=true;
|
|
|
+ getNoticeShowMessage();
|
|
|
+ noticeInfoDetailShow(0);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ case 2://获取失败
|
|
|
+ guiShowMessageBox("获取失败");
|
|
|
+ break;
|
|
|
+ default://获取超时
|
|
|
+ hearnHttpOverTime();
|
|
|
+ guiShowMessageBox("获取超时");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ nwy_sleep(1500);
|
|
|
+ getStackStruct()->ok_back=1;
|
|
|
+ uISetNextStatus(UIS_MENU_LOCATION_SEL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+static void learnNoticeReleaseDB(void);
|
|
|
+unsigned char noticeHandle;
|
|
|
+void LearnNoticeResponse(void){
|
|
|
+ if(noticeShowReady==true){
|
|
|
+ switch(getKeyValue()){
|
|
|
+ case MKEY_VALUE_ESC:
|
|
|
+ learnNoticeReleaseDB();
|
|
|
+ noticeShowReady=false;
|
|
|
+ uISetNextStatus(UIS_MENU_LOCATION_SEL);
|
|
|
+ break;
|
|
|
+ case MKEY_VALUE_DOWN:noticeInfoDetailShow(1);break;
|
|
|
+ case MKEY_VALUE_UP:noticeInfoDetailShow(2);break;
|
|
|
+ case MKEY_VALUE_MENU:
|
|
|
+ uISetNextStatus(UIS_MENU_LOCATION_NOTICE_DETAIL);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+bool noticeDetailReady=false;
|
|
|
+/*消息通知详情*/
|
|
|
+void uiShowLearnNoticeDetailShow(char update){
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ if(update){
|
|
|
+ guiClearAll(guiGetBackColor());
|
|
|
+ guiShowCaption(0,notices.noticeResult[noticetIndex]->title,UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
|
|
|
+ uiMenuShowBottomLine();
|
|
|
+ uiMenuShowBottomIndacitor(NULL, "返回");
|
|
|
+ if(sutApp.pocPpp==0){
|
|
|
+ guiShowMessageBox("无网络");
|
|
|
+ nwy_sleep(1500);
|
|
|
+ uISetNextStatus(UIS_MENU_LOCATION_SEL);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ showInfoBox("请稍候",3000);
|
|
|
+ sdMount();
|
|
|
+ noticeDetailReady=false;
|
|
|
+ learnUpdateStatus(LEARN_NOTICE_GET_DETAIL_SHOW);
|
|
|
+ learnTaskUpdate(LEARN_NOTICE_GET_DETAIL_SHOW,(void *)¬ices.noticeResult[noticetIndex]->id, NULL,true);
|
|
|
+ MSG_ERR(1, "update notice detail show");
|
|
|
+ }
|
|
|
+ if(false==noticeDetailReady){
|
|
|
+ ret=getHttpLearnStatus();
|
|
|
+ if(uTimerExpired(&learnTick) || ret!=1){
|
|
|
+ MSG_INFO(1, "WAIT NOTICE SHOW:%d",ret);
|
|
|
+ switch(ret){
|
|
|
+ case 0://功获取到了信息
|
|
|
+ //处理
|
|
|
+ noticeDetailReady=true;
|
|
|
+ MSG_INFO(1, "notice info get ok");
|
|
|
+ noticeInfoDetailShowContent(0);
|
|
|
+ return;
|
|
|
+ case 2://获取失败
|
|
|
+ guiShowMessageBox("获取失败");
|
|
|
+ break;
|
|
|
+ default://获取超时
|
|
|
+ hearnHttpOverTime();
|
|
|
+ guiShowMessageBox("获取超时");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ nwy_sleep(1500);
|
|
|
+ noticeShowReady=false;
|
|
|
+ getStackStruct()->ok_back=1;
|
|
|
+ uISetNextStatus(UIS_MENU_LOCATION_SEL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void LearnNoticeDetailResponse(void){
|
|
|
+ if(noticeDetailReady==true){
|
|
|
+ switch(getKeyValue()){
|
|
|
+ case MKEY_VALUE_ESC:
|
|
|
+ noticeShowReady=false;
|
|
|
+ uISetNextStatus(UIS_MENU_LOCATION_NOTICE);
|
|
|
+ break;
|
|
|
+ case MKEY_VALUE_DOWN:noticeInfoDetailShowContent(1);break;
|
|
|
+ //case MKEY_VALUE_UP:noticeInfoDetailShowContent(2);break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
#define OBJECT_AVG_NAME "avg"
|
|
|
#define OBJECT_SCORE_NAME "score"
|
|
@@ -1611,6 +1963,400 @@ static void getRankShowMessage(unsigned char ranktype){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#define OBJECT_WEEK_NAME "week"
|
|
|
+#define OBJECT_TIME_NAME "time"
|
|
|
+#define OBJECT_SUBJECT_NAME "subject"
|
|
|
+
|
|
|
+static char *classBuffer=NULL;
|
|
|
+cJSON* classJson=NULL;
|
|
|
+static void learnClassReleaseDB(void){
|
|
|
+ int i;
|
|
|
+ releaseBuf(&classBuffer);
|
|
|
+ if(NULL!=classes.classResult){
|
|
|
+ for(i=0;i<classes.num;i++){
|
|
|
+ if(classes.classResult[i]!=NULL) releaseBuf(&classes.classResult[i]);
|
|
|
+ }
|
|
|
+ releaseBuf(&classes.classResult);
|
|
|
+ }
|
|
|
+ releaseJson(&classJson);
|
|
|
+}
|
|
|
+
|
|
|
+static void getClassShowMessage(void){
|
|
|
+ //从LEARN_CLASS文件中读取内容出来解析
|
|
|
+ CLASS_DEF **classPtr=NULL;
|
|
|
+ int fd=-1,i=0;
|
|
|
+ char info[50];
|
|
|
+
|
|
|
+ ranks.item=0;
|
|
|
+ snprintf(info, sizeof(info), "%s/%s", SD_TOKEN,LEARN_CLASS);
|
|
|
+ fd=nwy_sdk_fopen(info, NWY_RDONLY);
|
|
|
+ if(fd<0){
|
|
|
+ MSG_WARN(1, "Class file open failed");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ long size=nwy_sdk_fsize_fd(fd);
|
|
|
+ if(size<=0){
|
|
|
+ MSG_WARN(1, "Class file data error");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ releaseBuf(&classBuffer);
|
|
|
+ classBuffer=(char *)createBuf(size);
|
|
|
+ //classBuffer=(char *)malloc(size);
|
|
|
+ if(NULL == classBuffer){
|
|
|
+ MSG_ERR(1, "class buffer malloc error");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ //MSG_INFO(1, "[mem malloc]%x", classBuffer);
|
|
|
+ memset(classBuffer, 0, size);
|
|
|
+ nwy_sdk_fread(fd, classBuffer, size);
|
|
|
+ nwy_sdk_fclose(fd);
|
|
|
+ fd=-1;
|
|
|
+ //解析json
|
|
|
+ MSG_INFO(1, "Class data analyse len:%d",size);
|
|
|
+ if(NULL!=classes.classResult){
|
|
|
+ for(i=0;i<classes.num;i++){
|
|
|
+ if(classes.classResult[i]!=NULL) releaseBuf(&classes.classResult[i]);
|
|
|
+ }
|
|
|
+ releaseBuf(&classes.classResult);
|
|
|
+ }
|
|
|
+ classes.num=0;
|
|
|
+
|
|
|
+ classJson = createJson(classBuffer);
|
|
|
+ //classJson = cJSON_Parse(classBuffer);
|
|
|
+ if(NULL==classJson){
|
|
|
+ MSG_WARN(1, "class json null");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ //MSG_INFO(1, "class json:%x", classJson);
|
|
|
+ cJSON* item = cJSON_GetObjectItem(classJson, OBJECT_LIST);
|
|
|
+ if(NULL==item){
|
|
|
+ MSG_ERR(1, "class json failed");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ int num=cJSON_GetArraySize(item);
|
|
|
+ if(num<=0){
|
|
|
+ MSG_WARN(1, "class array num:%d",num);
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ MSG_INFO(1, "class num:%d",num);
|
|
|
+ classPtr=(CLASS_DEF **)createBuf(sizeof(CLASS_DEF *)*num);
|
|
|
+ //classPtr=(CLASS_DEF **)malloc(sizeof(CLASS_DEF *)*num);
|
|
|
+ if(NULL==classPtr){
|
|
|
+ MSG_ERR(1,"class malloc failed");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ //MSG_INFO(1, "[mem malloc]%x", classPtr);
|
|
|
+ classes.num=num;
|
|
|
+ for(i=0;i<num;i++) classPtr[i]=NULL;
|
|
|
+ for(i=0;i<num;i++){
|
|
|
+ classPtr[i]=(CLASS_DEF *)createBuf(sizeof(CLASS_DEF));
|
|
|
+ //classPtr[i]=(CLASS_DEF *)malloc(sizeof(CLASS_DEF));
|
|
|
+ if(NULL==classPtr[i]){
|
|
|
+ MSG_ERR(1, "class[%d] malloc failed", i);
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ //MSG_INFO(1, "[mem malloc %d]%x", i, classPtr[i]);
|
|
|
+ }
|
|
|
+ cJSON* element,*t;
|
|
|
+ i=0;
|
|
|
+ for(;;){
|
|
|
+ element=cJSON_GetArrayItem(item,i);
|
|
|
+ if(NULL==element) break;
|
|
|
+ //week
|
|
|
+ t=cJSON_GetObjectItem(element, OBJECT_WEEK_NAME);
|
|
|
+ if(NULL==t) classPtr[i]->week=-1;
|
|
|
+ else classPtr[i]->week=atoi(t->valuestring);
|
|
|
+ //time
|
|
|
+ t=cJSON_GetObjectItem(element, OBJECT_TIME_NAME);
|
|
|
+ if(NULL==t) classPtr[i]->time[0]='\0';
|
|
|
+ else snprintf(classPtr[i]->time, sizeof(classPtr[i]->time), "%s", t->valuestring);
|
|
|
+ //subject
|
|
|
+ t=cJSON_GetObjectItem(element, OBJECT_SUBJECT_NAME);
|
|
|
+ if(NULL==t) classPtr[i]->subject[0]='\0';
|
|
|
+ else snprintf(classPtr[i]->subject, sizeof(classPtr[i]->subject), "%s", t->valuestring);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ classes.item=i;
|
|
|
+ classes.classResult=classPtr;
|
|
|
+ MSG_INFO(1, "class valid num:%d",i);
|
|
|
+ return;
|
|
|
+
|
|
|
+ R_EXIT:
|
|
|
+ releaseJson(&classJson);
|
|
|
+ releaseBuf(&classBuffer);
|
|
|
+ if(fd>0) nwy_sdk_fclose(fd);
|
|
|
+ if(classPtr != NULL){
|
|
|
+ for(i=0;i<num;i++) releaseBuf(&classPtr[i]);
|
|
|
+ releaseBuf(&classPtr);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#define OBJECT_ID_NAME "id"
|
|
|
+#define OBJECT_TITLE_NAME "title"
|
|
|
+
|
|
|
+static char *noticeBuffer=NULL;
|
|
|
+cJSON* noticeJson=NULL;
|
|
|
+static void learnNoticeReleaseDB(void){
|
|
|
+ int i;
|
|
|
+ releaseBuf(¬iceBuffer);
|
|
|
+ if(NULL!=notices.noticeResult){
|
|
|
+ for(i=0;i<notices.num;i++){
|
|
|
+ if(notices.noticeResult[i]!=NULL) releaseBuf(¬ices.noticeResult[i]);
|
|
|
+ }
|
|
|
+ releaseBuf(¬ices.noticeResult);
|
|
|
+ }
|
|
|
+ releaseJson(¬iceJson);
|
|
|
+}
|
|
|
+
|
|
|
+static void getNoticeShowMessage(void){
|
|
|
+ //从LEARN_CLASS文件中读取内容出来解析
|
|
|
+ NOTICE_DEF **noticePtr=NULL;
|
|
|
+ int fd=-1,i=0;
|
|
|
+ char info[50];
|
|
|
+
|
|
|
+ notices.item=0;
|
|
|
+ snprintf(info, sizeof(info), "%s/%s", SD_TOKEN,LEARN_NOTICE);
|
|
|
+ fd=nwy_sdk_fopen(info, NWY_RDONLY);
|
|
|
+ if(fd<0){
|
|
|
+ MSG_WARN(1, "Notice file open failed");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ long size=nwy_sdk_fsize_fd(fd);
|
|
|
+ if(size<=0){
|
|
|
+ MSG_WARN(1, "Notice file data error");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ releaseBuf(¬iceBuffer);
|
|
|
+ noticeBuffer=(char *)createBuf(size);
|
|
|
+ //noticeBuffer=(char *)malloc(size);
|
|
|
+ if(NULL == noticeBuffer){
|
|
|
+ MSG_ERR(1, "notice buffer malloc error");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ //MSG_INFO(1, "[mem malloc]%x", noticeBuffer);
|
|
|
+ memset(noticeBuffer, 0, size);
|
|
|
+ nwy_sdk_fread(fd, noticeBuffer, size);
|
|
|
+ nwy_sdk_fclose(fd);
|
|
|
+ fd=-1;
|
|
|
+ //解析json
|
|
|
+ MSG_INFO(1, "Notice data analyse len:%d",size);
|
|
|
+ if(NULL!=notices.noticeResult){
|
|
|
+ for(i=0;i<notices.num;i++){
|
|
|
+ if(notices.noticeResult[i]!=NULL) releaseBuf(¬ices.noticeResult[i]);
|
|
|
+ }
|
|
|
+ releaseBuf(¬ices.noticeResult);
|
|
|
+ }
|
|
|
+ notices.num=0;
|
|
|
+
|
|
|
+ noticeJson = createJson(noticeBuffer);
|
|
|
+ //noticeJson = cJSON_Parse(noticeBuffer);
|
|
|
+ if(NULL==noticeJson){
|
|
|
+ MSG_WARN(1, "notice json null");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ //MSG_INFO(1, "notice json:%x", noticeJson);
|
|
|
+ cJSON* item = cJSON_GetObjectItem(noticeJson, OBJECT_LIST);
|
|
|
+ if(NULL==item){
|
|
|
+ MSG_ERR(1, "notice json failed");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ int num=cJSON_GetArraySize(item);
|
|
|
+ if(num<=0){
|
|
|
+ MSG_WARN(1, "notice array num:%d",num);
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ MSG_INFO(1, "notice num:%d",num);
|
|
|
+ noticePtr=(NOTICE_DEF **)createBuf(sizeof(NOTICE_DEF *)*num);
|
|
|
+ //noticePtr=(NOTICE_DEF **)malloc(sizeof(NOTICE_DEF *)*num);
|
|
|
+ if(NULL==noticePtr){
|
|
|
+ MSG_ERR(1,"notice malloc failed");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ //MSG_INFO(1, "[mem malloc]%x", noticePtr);
|
|
|
+ notices.num=num;
|
|
|
+ for(i=0;i<num;i++) noticePtr[i]=NULL;
|
|
|
+ for(i=0;i<num;i++){
|
|
|
+ noticePtr[i]=(NOTICE_DEF *)createBuf(sizeof(NOTICE_DEF));
|
|
|
+ //noticePtr[i]=(CLASS_DEF *)malloc(sizeof(CLASS_DEF));
|
|
|
+ if(NULL==noticePtr[i]){
|
|
|
+ MSG_ERR(1, "notice[%d] malloc failed", i);
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ //MSG_INFO(1, "[mem malloc %d]%x", i, noticePtr[i]);
|
|
|
+ }
|
|
|
+ cJSON* element,*t;
|
|
|
+ i=0;
|
|
|
+ for(;;){
|
|
|
+ element=cJSON_GetArrayItem(item,i);
|
|
|
+ if(NULL==element) break;
|
|
|
+ //id
|
|
|
+ t=cJSON_GetObjectItem(element, OBJECT_ID_NAME);
|
|
|
+ if(NULL==t) noticePtr[i]->id=-1;
|
|
|
+ else noticePtr[i]->id=atoi(t->valuestring);
|
|
|
+ //time
|
|
|
+ t=cJSON_GetObjectItem(element, OBJECT_TIME_NAME);
|
|
|
+ if(NULL==t) noticePtr[i]->time[0]='\0';
|
|
|
+ else snprintf(noticePtr[i]->time, sizeof(noticePtr[i]->time), "%s", t->valuestring);
|
|
|
+ //title
|
|
|
+ t=cJSON_GetObjectItem(element, OBJECT_TITLE_NAME);
|
|
|
+ if(NULL==t) noticePtr[i]->title[0]='\0';
|
|
|
+ else snprintf(noticePtr[i]->title, sizeof(noticePtr[i]->title), "%s", t->valuestring);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ notices.item=i;
|
|
|
+ notices.noticeResult=noticePtr;
|
|
|
+ MSG_INFO(1, "notice valid num:%d",i);
|
|
|
+ return;
|
|
|
+
|
|
|
+ R_EXIT:
|
|
|
+ releaseJson(¬iceJson);
|
|
|
+ releaseBuf(¬iceBuffer);
|
|
|
+ if(fd>0) nwy_sdk_fclose(fd);
|
|
|
+ if(noticePtr != NULL){
|
|
|
+ for(i=0;i<num;i++) releaseBuf(¬icePtr[i]);
|
|
|
+ releaseBuf(¬icePtr);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+char *noticeDetailContent=NULL;
|
|
|
+//char *testShowData="这是一条测试信息,长度为100,然后呢就一直显示吧,我也不知道能显示多少,所以只能临时搞一段文字来显示看看效果如何了,然后再给100000000000元作者吧,作为酬劳,我也不知道是否足够呢。";
|
|
|
+void noticeInfoDetailShowContent(char direction){
|
|
|
+ int x=1,y=UI_CONTENT_SHOW_Y;
|
|
|
+ char *ptr=noticeDetailContent;
|
|
|
+ static int showlen,showIndex,len;
|
|
|
+ if(direction==0){
|
|
|
+ showlen=strlen(ptr);
|
|
|
+ showIndex=0;
|
|
|
+ }
|
|
|
+ guiClearRect(0,UI_CONTENT_SHOW_Y,GLCD_WIDTH-1,UI_BOTTOM_SHOW_Y-2,guiGetBackColor());
|
|
|
+ MessageEditInit(&sutMEdit, x, y+2 , ptr, FONT_MODE_16X16);
|
|
|
+ len=MessageEditShow(&sutMEdit,ptr+showIndex);
|
|
|
+ if(len !=0) showIndex+=len;
|
|
|
+ else showIndex=0;
|
|
|
+}
|
|
|
+void cJSONTakeContent(char *msg, int len){
|
|
|
+ //msg={"id":"7","content":"通知测试2"}
|
|
|
+ //提取"content"内容项到noticeInfoDetailShowContent中
|
|
|
+ releaseBuf(¬iceDetailContent);
|
|
|
+ cJSON* nJson=NULL;
|
|
|
+ nJson = createJson(msg);
|
|
|
+ if(NULL==nJson){
|
|
|
+ MSG_WARN(1, "notice detail show json null");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ cJSON* item = cJSON_GetObjectItem(nJson, OBJECT_CONTENT_DETAIL);
|
|
|
+ if(NULL==item){
|
|
|
+ MSG_ERR(1, "notice detail show json failed");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ int length=strlen(item->valuestring)+1;
|
|
|
+ char *ptr=(char *)createBuf(len*sizeof(char));
|
|
|
+ if(ptr==NULL){
|
|
|
+ MSG_ERR(1, "notice detail show malloc err");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ memcpy(ptr, item->valuestring, len);
|
|
|
+ ptr[len]=0;
|
|
|
+ noticeDetailContent=ptr;
|
|
|
+ R_EXIT:
|
|
|
+ releaseJson(&nJson);
|
|
|
+}
|
|
|
+
|
|
|
+void cJSONTakeParam(char *msg, int len){
|
|
|
+ //msg={"scoreSpeedParam": "1.0","scoreVolumeParam": "1.0"}
|
|
|
+ bool sparamOk=false;
|
|
|
+ bool vparamOk=false;
|
|
|
+ cJSON* nJson=NULL;
|
|
|
+ nJson = createJson(msg);
|
|
|
+ if(NULL==nJson){
|
|
|
+ MSG_WARN(1, "param detail json null");
|
|
|
+ goto R_EXIT;
|
|
|
+ }
|
|
|
+ cJSON* item = cJSON_GetObjectItem(nJson, OBJECT_SPEED_PARAM);
|
|
|
+
|
|
|
+ if(NULL==item) MSG_ERR(1, "param speed json failed");
|
|
|
+ else{
|
|
|
+ usr.scoreSpeedParam=atof(item->valuestring);
|
|
|
+ sparamOk=true;
|
|
|
+ }
|
|
|
+
|
|
|
+ item = cJSON_GetObjectItem(nJson, OBJECT_VOLUME_PARAM);
|
|
|
+
|
|
|
+ if(NULL==item) MSG_ERR(1, "param volume json failed");
|
|
|
+ else{
|
|
|
+ usr.scoreVolumeParam=atof(item->valuestring);
|
|
|
+ vparamOk=true;
|
|
|
+ }
|
|
|
+ if(sparamOk==true && vparamOk==true){
|
|
|
+ MSG_INFO(1, "sparam:%f, vparam:%f", usr.scoreSpeedParam, usr.scoreVolumeParam);
|
|
|
+ usr.paramReady=true;
|
|
|
+ }
|
|
|
+ R_EXIT:
|
|
|
+ releaseJson(&nJson);
|
|
|
+}
|
|
|
+//没获取账户信息,则定时尝试获取
|
|
|
+void LearnUsrInfoCheck(unsigned int interval){
|
|
|
+ static char step=0;
|
|
|
+ static unsigned int waitTimer;
|
|
|
+ unsigned char ret;
|
|
|
+ if(sutPocStatus.logined==0) return;
|
|
|
+ if(true==isUserInfoReady() && true==usr.paramReady){
|
|
|
+ if(step!=0) step=0;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ switch(step){
|
|
|
+ case 0://发起获取账户信息请求
|
|
|
+ step=1;
|
|
|
+ learnUpdateStatus(LEARN_DB_WAIT_INFO);
|
|
|
+ learnTaskUpdate(LEARN_DB_GET_INFO,NULL, NULL,false);
|
|
|
+ uTimerStart(&waitTimer, 5000);
|
|
|
+ break;
|
|
|
+ case 1://等待获取结果
|
|
|
+ ret=getHttpLearnStatus();
|
|
|
+ if(uTimerExpired(&waitTimer) || ret !=1){
|
|
|
+ MSG_INFO(1, "Wait user account:%d", ret);
|
|
|
+ if(ret==0) step=2;
|
|
|
+ else step=0;//重新获取
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2://发起参数获取请求
|
|
|
+ step=3;
|
|
|
+ learnUpdateStatus(LEARN_GET_PARAM);
|
|
|
+ learnTaskUpdate(LEARN_GET_PARAM,NULL, NULL,false);
|
|
|
+ uTimerStart(&waitTimer, 5000);
|
|
|
+ break;
|
|
|
+ case 3://等待获取结果
|
|
|
+ ret=getHttpLearnStatus();
|
|
|
+ if(uTimerExpired(&waitTimer) || ret !=1){
|
|
|
+ MSG_INFO(1, "Wait param:%d", ret);
|
|
|
+ if(ret==0) step=4;//停止
|
|
|
+ else step=2;//重新获取
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 4://IDLE
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+void uiShowLearnGroup(char type){
|
|
|
+ static unsigned int gid=0xffffffff;
|
|
|
+ if(false==isUserInfoReady()) return;
|
|
|
+ if(type) goto S_NOW;
|
|
|
+ if(gid == getLearnGid()) return;
|
|
|
+ gid=getLearnGid();
|
|
|
+ S_NOW:
|
|
|
+ uiShowLearnGName(getLearnGName());
|
|
|
+}
|
|
|
+static bool sdMountStatus=false;
|
|
|
+void sdUnmount(void){
|
|
|
+ sdCardCtl(false);
|
|
|
+ sdMountStatus=false;
|
|
|
+}
|
|
|
+void sdMount(void){
|
|
|
+ if(sdMountStatus==false){
|
|
|
+ sdCardCtl(true);
|
|
|
+ sdMountStatus=true;
|
|
|
+ }
|
|
|
+}
|
|
|
bool sdCardTest(void){
|
|
|
const char *table="sdTest.txt";
|
|
|
char file[50];
|