summaryrefslogtreecommitdiff
path: root/plugins/mRadio/i_myservice.inc
diff options
context:
space:
mode:
authorAlexey Kulakov <panda75@bk.ru>2014-02-02 09:39:36 +0000
committerAlexey Kulakov <panda75@bk.ru>2014-02-02 09:39:36 +0000
commit7c53c3c262dd67bbe9bcac3971621face2455f82 (patch)
treedc3ac8c5fb55a284a82a2b55968bf6d6d3de19b5 /plugins/mRadio/i_myservice.inc
parent5abedf89d15719fb5e2ba394363ad85264ac2f58 (diff)
Miranda API update
mRadio:refactoring git-svn-id: http://svn.miranda-ng.org/main/trunk@8000 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/mRadio/i_myservice.inc')
-rw-r--r--plugins/mRadio/i_myservice.inc141
1 files changed, 140 insertions, 1 deletions
diff --git a/plugins/mRadio/i_myservice.inc b/plugins/mRadio/i_myservice.inc
index d938a08d92..4f50cf573c 100644
--- a/plugins/mRadio/i_myservice.inc
+++ b/plugins/mRadio/i_myservice.inc
@@ -137,8 +137,147 @@ begin
else
EQ_OFF;
end;
- if eq[0].wnd<>0 then // if options opened
+ if eq[0].wnd<>0 then // if options opened (can use hVolCtrl)
begin
CheckDlgButton(GetParent(eq[0].wnd),IDC_EQOFF,isEQ_OFF);
end;
end;
+
+//----- Import-export -----
+
+function ImportOneStation(group:PAnsiChar;section:pointer):int;
+var
+ p:pWideChar;
+ pc:pAnsiChar;
+begin
+ result:=0;
+ pc:=GetParamSectionStr(section,'URL');
+ if pc<>nil then
+ begin
+ result:=CallService(MS_DB_CONTACT_ADD,0,0);
+ if result<>0 then
+ begin
+ CallService(MS_PROTO_ADDTOCONTACT,result,lparam(PluginName));
+ DBWriteString(result,PluginName,optStationURL,pc);
+ DBWriteString(result,PluginName,optFirstName ,pc);
+
+ pc:=GetParamSectionStr(section,optBitrate,'0');
+ DBWriteString(result,PluginName,optBitrate,pc);
+ DBWriteWord (result,PluginName,optAge ,StrToInt(pc));
+
+ pc:=GetParamSectionStr(section,'Name',GetSectionName(section));
+ DBWriteString(result,strCList ,optMyHandle,pc);
+ DBWriteString(result,PluginName,optNick ,pc);
+
+ pc:=GetParamSectionStr(section,optGenre,'unknown');
+ DBWriteString(result,PluginName,optGenre ,pc);
+ DBWriteString(result,PluginName,optLastName,pc);
+
+ SetStatus(result,ID_STATUS_OFFLINE);
+
+ if group=nil then
+ group:=GetParamSectionStr(section,optGroup);
+
+ AnsiToWide(group,p,MirandaCP);
+ CreateGroupW(p,result);
+ mFreeMem(p);
+ CallService(MS_IGNORE_IGNORE,result,IGNOREEVENT_ALL);
+ end;
+ end;
+end;
+
+function ImportAll(wParam:WPARAM;lParam:LPARAM):int; cdecl;
+var
+ dst:array [0..MAX_PATH-1] of AnsiChar;
+ pc:pAnsiChar;
+ lstorage,section,list:pointer;
+begin
+ result:=0;
+ if lParam<>0 then
+ StrCopy(dst,PAnsiChar(lParam));
+ if (lParam<>0) or ShowDlg(dst,'radio.ini',nil,true) then
+ begin
+ lstorage:=OpenStorage(dst);
+ if lstorage<>nil then
+ begin
+ list:=GetSectionList(lstorage);
+
+ pc:=list;
+ while pc^<>#0 do
+ begin
+ section:=SearchSection(lstorage,pc);
+ if ImportOneStation(pAnsiChar(wParam),section)<>0 then inc(result);
+ while pc^<>#0 do inc(pc);
+ inc(pc);
+ end;
+
+ FreeSectionList(list);
+
+ CloseStorage(lstorage);
+ end;
+ end;
+end;
+
+procedure ExportRadioContact(num:integer;fname:PAnsiChar;hContact:THANDLE);
+var
+ pc:pAnsiChar;
+ section:array [0..15] of AnsiChar;
+begin
+ IntToStr(section,num);
+ pc:=DBReadString(hContact,strCList,optMyHandle);
+ WritePrivateProfileStringA(section,'Name',pc,fname);
+ mFreeMem(pc);
+
+ pc:=DBReadString(hContact,PluginName,optStationURL);
+ WritePrivateProfileStringA(section,'URL',pc,fname);
+ mFreeMem(pc);
+
+ pc:=DBReadString(hContact,PluginName,optGenre);
+ if pc<>nil then
+ begin
+ WritePrivateProfileStringA(section,optGenre,pc,fname);
+ mFreeMem(pc);
+ end;
+
+ pc:=DBReadString(hContact,PluginName,optBitrate);
+ if pc<>nil then
+ begin
+ WritePrivateProfileStringA(section,optBitrate,pc,fname);
+ mFreeMem(pc);
+ end;
+
+ pc:=DBReadString(hContact,strCList,optGroup);
+ if pc<>nil then
+ begin
+ WritePrivateProfileStringA(section,optGroup,pc,fname);
+ mFreeMem(pc);
+ end;
+end;
+
+function ExportAll(wParam:WPARAM;lParam:LPARAM):int; cdecl;
+var
+ dst:array [0..MAX_PATH-1] of AnsiChar;
+ hContact:THANDLE;
+begin
+ result:=0;
+ if lParam<>0 then
+ StrCopy(dst,PAnsiChar(lParam));
+ if (lParam<>0) or ShowDlg(dst,'radio.ini',nil,false) then
+ begin
+ if (wParam<>0) and (CallService(MS_DB_CONTACT_IS,wParam,0)<>0) then
+ begin
+ result:=1;
+ ExportRadioContact(result,dst,wParam)
+ end
+ else
+ begin
+ hContact:=db_find_first(PluginName);
+ while hContact<>0 do
+ begin
+ inc(result);
+ ExportRadioContact(result,dst,hContact);
+ hContact:=db_find_next(hContact,PluginName);
+ end;
+ end;
+ end;
+end;