hook.c 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. #include "includes.h"
  2. ASSIST_DEF uiAssist;
  3. unsigned char assistResult;
  4. void uTimerStart(unsigned int *timerId, unsigned int dlyTime){
  5. *timerId=getAppTick()+dlyTime/KEY_TIMER_TICK;
  6. }
  7. char uTimerExpired(unsigned int *timerId){
  8. return ((getAppTick()>*timerId)?1:0);
  9. }
  10. void UiassistStart(unsigned char type){
  11. uiAssist.type=type;
  12. uiAssist.machine=0;
  13. uiAssist.status=1;
  14. }
  15. void UiassistEnd(unsigned char type){
  16. uiAssist.type=type;
  17. uiAssist.machine=0;
  18. uiAssist.status=0;
  19. assistResult=0;
  20. }
  21. unsigned char getAssistResult(void){
  22. unsigned char ret=0;
  23. ret=assistResult;
  24. if(assistResult) assistResult=0;
  25. return ret;
  26. }
  27. bnd_group_t groups[5];
  28. bnd_member_t bndmembers[5];
  29. char SimpleInfoScan(unsigned char firstIn,unsigned char direction)
  30. {
  31. static char first=1;
  32. static unsigned char machine;
  33. static unsigned int timer;
  34. char buf[40];//30
  35. char ret =0;
  36. short TatolNum;
  37. char i,len;
  38. if(firstIn && first){
  39. sutPocStatus.handleIndex=0;//μ±?°ò3
  40. machine=0;
  41. first=0;
  42. ret=0;
  43. }
  44. switch(machine){
  45. case 0:
  46. sutPocStatus.ListUpdate=0;
  47. sutPocStatus.ListFillIndex=0;
  48. sutPocStatus.ListDetailValid=0;
  49. if(sutUIstatus.Status==UIS_MENU_GROUP_SEL){
  50. TatolNum=broad_get_groupcount();
  51. if(TatolNum>=0){
  52. sutPocStatus.ListUpdate=1;
  53. sutPocStatus.ListCurOnlineNum=TatolNum;
  54. MSG_INFO(1,"GET tatol %d---",TatolNum);
  55. machine=2;
  56. }else{
  57. MSG_INFO(1,"GET tatol failed---");
  58. }
  59. }else{
  60. TatolNum=broad_get_membercount(sutPocStatus.LocalGroup.ID);
  61. if(TatolNum>=0){
  62. sutPocStatus.ListUpdate=1;
  63. sutPocStatus.ListCurOnlineNum=TatolNum;
  64. MSG_INFO(1,"GET tatol %d---",TatolNum);
  65. machine=2;
  66. }else{
  67. MSG_INFO(1,"GET tatol failed---");
  68. }
  69. }
  70. break;
  71. case 1:
  72. if(sutPocStatus.ListUpdate || uTimerExpired(&timer) ){
  73. if(sutPocStatus.ListCurOnlineNum<=0){
  74. sutPocStatus.ListFillIndex=0;
  75. MSG_INFO(1,"sutPocStatus.ListUpdate==%d,ListCurOnlineNum==%d\r\n",sutPocStatus.ListUpdate,sutPocStatus.ListCurOnlineNum);
  76. goto QUIT_FUNCTION;
  77. }
  78. machine=2;
  79. }
  80. break;
  81. case 2:
  82. if(firstIn!=1){
  83. if(direction==1){
  84. sutPocStatus.handleIndex ++;
  85. if(sutPocStatus.handleIndex>sutPocStatus.ListCurOnlineNum/5){
  86. sutPocStatus.handleIndex=0;
  87. }
  88. if(sutPocStatus.ListCurOnlineNum%5==0){
  89. if(sutPocStatus.handleIndex==sutPocStatus.ListCurOnlineNum/5)sutPocStatus.handleIndex=0;
  90. }
  91. }
  92. else {
  93. if(sutPocStatus.handleIndex>0)sutPocStatus.handleIndex--;
  94. else if(sutPocStatus.handleIndex==0){
  95. if(sutPocStatus.ListCurOnlineNum%5==0)sutPocStatus.handleIndex=(sutPocStatus.ListCurOnlineNum/5)-1;
  96. else sutPocStatus.handleIndex=sutPocStatus.ListCurOnlineNum/5;
  97. MSG_INFO(1,"sutPocStatus.ListCurOnlineNum===%d,sutPocStatus.handleIndex==%d\r\n",sutPocStatus.ListCurOnlineNum,sutPocStatus.handleIndex);
  98. }
  99. }
  100. }
  101. /*
  102. ????2ù×÷?????¨ ?¤?á?μsutPocStatus.ExceptionReadNum
  103. */
  104. if((sutPocStatus.handleIndex+1)*5 >sutPocStatus.ListCurOnlineNum){ //3?1y ê×ò3 +1
  105. snprintf(buf, sizeof(buf), "over:%d",sutPocStatus.handleIndex);
  106. MSG_INFO(1, buf);
  107. if(sutPocStatus.ListCurOnlineNum%5==0)sutPocStatus.ExceptionReadNum=5;
  108. else sutPocStatus.ExceptionReadNum=sutPocStatus.ListCurOnlineNum%5;
  109. } else{
  110. sutPocStatus.ExceptionReadNum=5; //
  111. }
  112. sutPocStatus.ListFillIndex=0;
  113. machine=3;
  114. break;
  115. case 3:
  116. sutPocStatus.ListGetOneFlag=0;
  117. if(sutUIstatus.Status==UIS_MENU_GROUP_SEL){
  118. memset(groups,0,sizeof(bnd_group_t)*5);
  119. TatolNum=sutPocStatus.handleIndex*5;
  120. TatolNum = broad_get_grouplist(groups, 16, TatolNum, 5);
  121. MSG_INFO(1,"GET except %d---",TatolNum);
  122. if(TatolNum>=0){
  123. sutPocStatus.ListDetailValid=1;
  124. sutPocStatus.ListFillIndex=TatolNum;
  125. for(i=0;i<TatolNum;i++){
  126. if(Utf8ToGbkOrUnicode(&groups[i].name,strlen(&groups[i].name),&sutPocStatus.AllGroups[i].name,&len,0)){
  127. MSG_INFO(1,"change erro-----");
  128. }
  129. sutPocStatus.AllGroups[i].ID=groups[i].gid;
  130. MSG_INFO(1,"GET___GROUPid[%d]____GroupName[%s]",sutPocStatus.AllGroups[i].ID,&sutPocStatus.AllGroups[i].name);
  131. }
  132. sutPocStatus.ListGetOneFlag=1;
  133. machine=4;
  134. }else{
  135. uTimerStart(&timer, 2000);
  136. machine=4;
  137. }
  138. }else{
  139. memset(bndmembers,0,sizeof(bnd_member_t)*5);
  140. memset(sutPocStatus.AllUsers,0,sizeof(sutPocStatus.AllUsers));
  141. TatolNum=sutPocStatus.handleIndex*5;
  142. TatolNum = broad_get_memberlist(sutPocStatus.LocalGroup.ID,bndmembers, 16, TatolNum, 5);
  143. MSG_INFO(1,"GET except %d---",TatolNum);
  144. if(TatolNum>=0){
  145. sutPocStatus.ListDetailValid=1;
  146. sutPocStatus.ListFillIndex=TatolNum;
  147. for(i=0;i<TatolNum;i++){
  148. if(Utf8ToGbkOrUnicode(&bndmembers[i].name,strlen(&bndmembers[i].name),&sutPocStatus.AllUsers[i].name,&len,0)){
  149. MSG_INFO(1,"change erro-----");
  150. }
  151. sutPocStatus.AllUsers[i].ID=bndmembers[i].uid;
  152. ////1在线不在组,2,离线,3在线在组
  153. if(bndmembers[i].state==3)sutPocStatus.AllUsers[i].status=1;//在线在组
  154. else if(bndmembers[i].state==2)sutPocStatus.AllUsers[i].status=0;
  155. else if(bndmembers[i].state==1)sutPocStatus.AllUsers[i].status=2;
  156. MSG_INFO(1,"GET___USERid[%d]____USERName[%s]",sutPocStatus.AllUsers[i].ID,&sutPocStatus.AllUsers[i].name);
  157. }
  158. sutPocStatus.ListGetOneFlag=1;
  159. machine=4;
  160. }else{
  161. uTimerStart(&timer, 2000);
  162. machine=4;
  163. }
  164. }
  165. break;
  166. case 4:
  167. if(sutPocStatus.ListGetOneFlag){
  168. machine=5;
  169. }
  170. if(uTimerExpired(&timer)){
  171. machine=5;
  172. }
  173. break;
  174. case 5:
  175. QUIT_FUNCTION:
  176. first=1;
  177. guiClearRect(0, 40, GLCD_WIDTH-1, GLCD_HEIGHT-32,guiGetBackColor());
  178. machine=0;//
  179. return 1;
  180. break;
  181. }
  182. return ret;
  183. }
  184. void HookGroupUserInfo()
  185. {
  186. if(uiAssist.status!=0){
  187. switch(uiAssist.type){
  188. case 0: //
  189. switch(uiAssist.machine){
  190. case 0: //初次
  191. if(SimpleInfoScan(1, 2)){
  192. assistResult=1;
  193. uiAssist.status=0;
  194. }
  195. break;
  196. }
  197. break;
  198. case 1: //上翻
  199. switch(uiAssist.machine){
  200. case 0:
  201. if(SimpleInfoScan(0,0)){
  202. assistResult=1;
  203. uiAssist.status=0;
  204. }
  205. break;
  206. }
  207. break;
  208. case 2: //下翻
  209. switch(uiAssist.machine){
  210. case 0:
  211. if(SimpleInfoScan(0,1)){
  212. assistResult=1;
  213. uiAssist.status=0;
  214. }
  215. break;
  216. }
  217. break;
  218. }
  219. }
  220. }
  221. static unsigned int volTime;
  222. static unsigned char volWorkStatus=0;
  223. #define VOL_BAR_LENGTH 100
  224. #define VOL_HAR_HEIGHT 10
  225. #define VOL_START_X ((GLCD_WIDTH-(VOL_BAR_LENGTH+2)-2)/2)
  226. #define VOL_START_Y (UI_BOTTOM_SHOW_Y-2-(VOL_HAR_HEIGHT+2)-2)
  227. #define VOL_HEIGH 16
  228. static void volTimeDlyStart(unsigned int time){
  229. uTimerStart(&volTime, time);
  230. volWorkStatus=1;
  231. }
  232. void HookVolToutCheck(void){
  233. #if 1
  234. unsigned short x=GLCD_WIDTH/2-16;
  235. unsigned short y=VOL_START_Y;
  236. if(volWorkStatus==0) return;
  237. if(uTimerExpired(&volTime)==0) return;
  238. volWorkStatus=0;
  239. if(sutUIstatus.Status!=UIS_STANDBY) return;
  240. guiClearRect(x, y, x+16+16, y+VOL_HEIGH, guiGetBackColor());
  241. #else
  242. unsigned short x=VOL_START_X;//102为音量框长度,其中100为有效长度
  243. unsigned short y=VOL_START_Y;//32为音量框高度,其中30为有效高度
  244. if(volWorkStatus==0) return;
  245. if(uTimerExpired(&volTime)==0) return;
  246. volWorkStatus=0;
  247. if(sutUIstatus.Status!=UIS_STANDBY) return;
  248. guiClearRect(x-21, y, x+(VOL_BAR_LENGTH+2)+2-1, y+(VOL_HAR_HEIGHT+2)+2, guiGetBackColor());
  249. #endif
  250. }
  251. void volUiFlash(unsigned char lev){
  252. #if 1//使用喇叭显示
  253. unsigned short x=GLCD_WIDTH/2-16;
  254. unsigned short y=VOL_START_Y;
  255. char info[10];
  256. guiClearRect(x, y, x+16+16, y+VOL_HEIGH, guiGetBackColor());
  257. guiShowBmp(x, y, "volume.bmp");
  258. snprintf(info, sizeof(info), "%d", lev);
  259. guiShowStr(x+16, y+1, info, FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  260. volTimeDlyStart(2000);
  261. #else//使用进度条显示
  262. unsigned short x=VOL_START_X;//102为音量框长度,其中100为有效长度
  263. unsigned short y=VOL_START_Y;//32为音量框高度,其中30为有效高度
  264. char info[10];
  265. guiClearRect(x-21, y, x+(VOL_BAR_LENGTH+2)+2-1, y+(VOL_HAR_HEIGHT+2)+2, guiGetBackColor());
  266. guiDrawRect(x, y, x+(VOL_BAR_LENGTH+2)+2-1, y+(VOL_HAR_HEIGHT+2)+2, 1, COLOR_BLACK);
  267. x += 2;y += 2;
  268. snprintf(info, sizeof(info), "%d", lev);
  269. guiShowStr(x-strlen(info)*8-5, y-1, info, FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  270. guiFillRect(x, y, x+lev*10-1, y+(VOL_HAR_HEIGHT+0),COLOR_STATUS_BAR);
  271. volTimeDlyStart(2000);
  272. #endif
  273. }