From de34b251b442cdf72b13c407d6b60c343c123bb3 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Thu, 16 Jan 2014 03:11:48 +0000 Subject: sync git-svn-id: http://svn.miranda-ng.org/main/trunk@7674 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Watrack/myshows/i_myshows_api.inc | 68 +++++++++++++++---------------- plugins/Watrack/myshows/i_myshows_opt.inc | 2 - plugins/Watrack/myshows/myshows.pas | 11 +++-- 3 files changed, 40 insertions(+), 41 deletions(-) (limited to 'plugins/Watrack/myshows') diff --git a/plugins/Watrack/myshows/i_myshows_api.inc b/plugins/Watrack/myshows/i_myshows_api.inc index 572cc3ee31..2e9f51773d 100644 --- a/plugins/Watrack/myshows/i_myshows_api.inc +++ b/plugins/Watrack/myshows/i_myshows_api.inc @@ -68,7 +68,7 @@ function GetMD5(const data;datalen:integer;var digest:TMD5Hash):TMD5Hash; begin FillChar(digest,16,0); - mir_md5_hash(pmir_md5_byte_t(data),datalen,digest); + mir_md5_hash(pbyte(data),datalen,digest); result:=digest; end; @@ -154,9 +154,9 @@ var buf:array [0..511] of AnsiChar; // bufw:array [0..511] of WideChar; res,pc:PAnsiChar; - {img,}shId,epId:pAnsiChar; + epId:pAnsiChar; + shId:pWideChar; // imgw:pWideChar; - json:TJSONSERVICEINTERFACE; jn,jroot:PJSONNODE; begin result:=false; @@ -171,21 +171,13 @@ begin res:=SendRequest(buf,REQUEST_GET); if uint_ptr(res)>$0FFF then begin - CallService(MS_JSON_GETINTERFACE,wparam(@json),0); + jroot:=json_parse(res); - jroot:=json.parse(res); + jn:=json_get(jroot,'show'); + shId:=json_as_string(json_get(jn,'id')); - jn:=json.get(jroot,'show'); - shId:=json.as_string(json.get(jn,'id')); - - jn:=json.get(jn,'episodes'); - epId:=json.name(json.at(jn,0)); -{ -kinopoiskId -image -ruTitle -episodes:{:{id: -} + jn:=json_get(jn,'episodes'); + epId:=json_name(json_at(jn,0)); end else begin @@ -195,7 +187,9 @@ episodes:{:{id: end; // Show mark as "watching" - StrCopy(StrCopyE(StrCopyE(buf,API_URL+'profile/shows/'),shId),'/watching'); + pc:=StrCopyE(buf,API_URL+'profile/shows/'); + FastWideToAnsiBuf(shId,pc); + StrCat(pc,'/watching'); if SendMSRequest(buf,show) then begin // Episode check @@ -206,42 +200,44 @@ episodes:{:{id: { if si.cover=nil then begin - jn:=json.get(jroot,'show'); - img:=json.as_string(json.get(jn,'image')); + jn:=json_get(jroot,'show'); + img:=json_as_string(json_get(jn,'image')); si:=pointer(CallService(MS_WAT_RETURNGLOBAL,WAT_INF_UNICODE,0)); FastAnsiToWide(img,pSongInfoW(si)^.cover); - json.free(img); + json_free(img); end; } //!! add option to show it?? if ServiceExists(MS_POPUP_SHOWMESSAGE)<>0 then begin - json.free(shId); - json.free(epId); + json_free(shId); + json_free(epId); - jn:=json.get(jroot,'show'); - shId:=json.as_string(json.get(jn,'title')); + jn:=json_get(jroot,'show'); + shId:=json_as_string(json_get(jn,'title')); - jn:=json.get(jn,'episodes'); - epId:=json.as_string(json.get(jn,'title')); + jn:=json_get(jn,'episodes'); + pWideChar(epId):=json_as_string(json_get(jn,'title')); - StrCopy( - StrCopyE( - StrCopyE( - StrCopyE( - StrCopyE(buf,'Show "'), + mGetMem(pc,1024); + StrCopyW( + StrCopyEW( + StrCopyEW( + StrCopyEW( + StrCopyEW(pWideChar(pc),'Show "'), shId), '"'#13#10'episode "'), - epId), + pWideChar(epId)), '" checked'); - CallService(MS_POPUP_SHOWMESSAGE,TWPARAM(@buf),SM_NOTIFY); + CallService(MS_POPUP_SHOWMESSAGEW,TWPARAM(pc),SM_NOTIFY); + mFreeMem(pc); end; result:=true; end; end; - json.free(shId); - json.free(epId); + json_free(shId); + json_free(epId); - json.delete_(jroot); + json_delete(jroot); end; diff --git a/plugins/Watrack/myshows/i_myshows_opt.inc b/plugins/Watrack/myshows/i_myshows_opt.inc index f136c4c658..42b9e88cee 100644 --- a/plugins/Watrack/myshows/i_myshows_opt.inc +++ b/plugins/Watrack/myshows/i_myshows_opt.inc @@ -8,8 +8,6 @@ const optScrobble:pAnsiChar='myshows/scrobble'; procedure SaveOpt; -var - tmppass:array [0..255] of AnsiChar; begin DBWriteString(0,PluginShort,optPassword,msh_password); DBWriteString(0,PluginShort,optLogin ,msh_login); diff --git a/plugins/Watrack/myshows/myshows.pas b/plugins/Watrack/myshows/myshows.pas index 5715c530d9..a26c7dd4ae 100644 --- a/plugins/Watrack/myshows/myshows.pas +++ b/plugins/Watrack/myshows/myshows.pas @@ -28,6 +28,7 @@ type var msh_tries, msh_scrobpos:integer; + sic:THANDLE; slast:THANDLE; MSData:tMyShowsData; const @@ -108,7 +109,6 @@ begin begin if pSongInfo(lParam).width>0 then // for video only begin - if ServiceExists(MS_JSON_GETINTERFACE)<>0 then begin timervalue:=integer(pSongInfo(lParam).total)*10*msh_scrobpos; // 1000(msec) div 100(%) if timervalue=0 then @@ -252,6 +252,8 @@ begin result:=0; end; +var + plStatusHook:THANDLE; function InitProc(aGetStatus:boolean=false):integer; begin // slastinf:=CreateServiceFunction(MS_WAT_MYSHOWSINFO,@SrvMyShowsInfo); @@ -275,9 +277,9 @@ begin slast:=CreateServiceFunction(MS_WAT_MYSHOWS,@SrvMyShows); if hMenuMyShows=0 then CreateMenus; - HookEvent(ME_SKIN2_ICONSCHANGED,@IconChanged); + sic:=HookEvent(ME_SKIN2_ICONSCHANGED,@IconChanged); if (msh_on and 4)=0 then - HookEvent(ME_WAT_NEWSTATUS,@NewPlStatus); + plStatusHook:=HookEvent(ME_WAT_NEWSTATUS,@NewPlStatus); end; procedure DeInitProc(aSetDisable:boolean); @@ -286,6 +288,8 @@ begin SetModStatus(0); DestroyServiceFunction(slast); + UnhookEvent(plStatusHook); + UnhookEvent(sic); if hTimer<>0 then begin @@ -313,6 +317,7 @@ begin mmyshows.Init :=@InitProc; mmyshows.DeInit :=@DeInitProc; mmyshows.AddOption :=@AddOptionsPage; + mmyshows.Check :=nil; mmyshows.ModuleName:='MyShows.ru'; ModuleLink :=@mmyshows; -- cgit v1.2.3